problem
stringlengths
26
131k
labels
class label
2 classes
static void vmxnet3_deactivate_device(VMXNET3State *s) { VMW_CBPRN("Deactivating vmxnet3..."); s->device_active = false; }
1threat
Java - Performance difference betwen static and non static : How big is difference in performance, when class is initialized everytime and methods are not static (new Class()) or methods in this class are static and usage of them is like Class.method()? Example code: pastebin.com/riAFFPV7 Thanks for any answer! PS. Sorry, if I did any mistake. English is not my main language. :P
0debug
Is there any alternative to the code below for attaching files in the google spreadhseet (depreciation error(UIapp))? : I must admit I cannot programme the solution I am seeking from scratch, usually I manipulate codes available for solving issues that I face regularly. The problem while running the code I was using "UiApp has been deprecated. Please use HtmlService instead.". I looked into Htmlservice documentation but did not get any idea how I could convert the entire UIapp code into functional html code. If someone has already solved file attachment problem due to deprecation(UIapp), then it would be a great help. Or, if anyone can suggest me anything that I can use as an alternative pls advise me. // upload document into google spreadsheet // and put link to it into current cell function onOpen(e) { var ss = SpreadsheetApp.getActiveSpreadsheet() var menuEntries = []; menuEntries.push({name: "File...", functionName: "doGet"}); ss.addMenu("Attach ...", menuEntries); } function doGet(e) { var app = UiApp.createApplication().setTitle("upload attachment into Google Drive"); SpreadsheetApp.getActiveSpreadsheet().show(app); var form = app.createFormPanel().setId('frm').setEncoding('multipart/form-data'); var formContent = app.createVerticalPanel(); form.add(formContent); formContent.add(app.createFileUpload().setName('thefile')); // these parameters need to be passed by form // in doPost() these cannot be found out anymore formContent.add(app.createHidden("activeCell", SpreadsheetApp.getActiveRange().getA1Notation())); formContent.add(app.createHidden("activeSheet", SpreadsheetApp.getActiveSheet().getName())); formContent.add(app.createHidden("activeSpreadsheet", SpreadsheetApp.getActiveSpreadsheet().getId())); formContent.add(app.createSubmitButton('Submit')); app.add(form); SpreadsheetApp.getActiveSpreadsheet().show(app); return HtmlService.createHtmlOutputFromFile('Index'); } function doPost(e) { var app = UiApp.getActiveApplication(); app.createLabel('saving...'); var fileBlob = e.parameter.thefile; var doc = DriveApp.getFolderById('enterfolderId').createFile(fileBlob); var label = app.createLabel('file uploaded successfully'); // write value into current cell var value = 'hyperlink("' + doc.getUrl() + '";"' + doc.getName() + '")' var activeSpreadsheet = e.parameter.activeSpreadsheet; var activeSheet = e.parameter.activeSheet; var activeCell = e.parameter.activeCell; var label = app.createLabel('file uploaded successfully'); app.add(label); SpreadsheetApp.openById(activeSpreadsheet).getSheetByName(activeSheet).getRange(activeCell).setFormula(value); app.close(); return app; }
0debug
Python: Opencv: error: (-215) size.width>0 && size.height>0 in function cv::imshow : <p>I am trying to load image using openCV in python but I am getting error like: </p> <p>error: C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:325: error: (-215) size.width>0 &amp;&amp; size.height>0 in function cv::imshow</p> <p>Does it has to do any thing with the size of the image? What can be possible solution of this error? </p> <p>I am sending you the trace back in attachment. Thanks<a href="https://i.stack.imgur.com/jcz2q.png" rel="nofollow noreferrer">enter image description here</a></p> <pre><code>import cv2 , time import numpy as np img = cv2.imread ('C:\Users\Ravi\.spyder\Ravi_Pic.jpc', 0) cv2.imshow('Ravi',img) </code></pre>
0debug
If condition not working inside a callback function : <p>if i write like so, things work</p> <pre><code>var p1Button = document.getElementById("p1Button"); var p1Score = 0; var p1Span = document.getElementById("p1ScoreSpan"); var p2Button = document.getElementById("p2Button"); var p2Score = 0; var p2Span = document.getElementById("p2ScoreSpan"); var winningScore = document.querySelector("#targetScore").textContent var gameOver = false; //for the reset button var resetButton = document.getElementById("ResetButton"); p1Button.addEventListener("click", function(){ // console.log(gameOver) if(!gameOver) { p1Score++; if(p1Score == winningScore) { p1Span.classList.add('winner'); gameOver = true; } p1Span.textContent = p1Score; } }) p2Button.addEventListener("click", function () { console.log(gameOver) if (!gameOver) { p2Score++; if(p2Score == winningScore){ p2Span.classList.add('winner'); gameOver = true; }} p2Span.textContent = p2Score; }) </code></pre> <p>But to keep it 'DRY' creating a function and using it as the callback doesn't seem to work. Below is the code snippet, that runs ones even without me clicking the 'buttons' defined in HTML</p> <pre><code>var callBackfunct = function (playerScore, playerSpan) { console.log(gameOver) console.log(winningScore) if (!gameOver) { playerScore++; if (playerScore == winningScore) { playerSpan.classList.add('winner'); gameOver = true; } } playerSpan.textContent = playerScore; console.log(gameOver) } p1Button.addEventListener("click", callBackfunct(p1Score, p1Span)); p2Button.addEventListener("click", callBackfunct(p2Score, p2Span)); </code></pre> <p>Where did i err'ed? I am expecting that when i click on the player1 button, the callback function is called by hnouring the if conditions</p>
0debug
React native flexbox - how to do percentages || columns || responsive || grid etc : <p>After working with react native on iOS for the last couple of weeks, I seem to have come across some shortcomings of flex styling... Particularly when it comes to "responsive" behavior. </p> <p>For instance, lets say you want to create a view that contains cards (the metadata for these cards comes from an API). You want the cards to be 50% of the view width minus the margin &amp; padding, and to wrap after each 2.</p> <p><a href="https://i.stack.imgur.com/IKGF1.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/IKGF1.jpg" alt="enter image description here"></a></p> <p>The current implementation I have for this view splits the returned array into rows with 2 items. The list container has <code>flex: 1, flexDirection: 'column</code>, the rows have <code>flex: 1</code> and then each card has <code>flex: 1</code>. The end result is each row has 2 columns which evenly take up half the view width. </p> <p>It seems like there is no trivial way to do this in React Native styles, without using javascript to do some sort of pre-processing on the data so that it comes out styled correctly. Does anyone have any suggestions? </p>
0debug
.net 5 Web API controller action arguments are always null : I did see a few threads here addressing similar issue but unfortunately nothing could solve my problem (so far). **CONTROLLER METHOD** Following is my controller method: <!-- begin snippet: js hide: false --> <!-- language: lang-html --> namespace apiservice.Controllers{ [Route("api/[controller]")] public class BookStoreController : Controller{ private BookContext _ctx; public BookStoreController(BookContext context) { _ctx = context; } [EnableCors("AllowAll")] [RouteAttribute("SearchBooks")] [HttpGet("searchbooks/{key}")] public async Task<object> SearchBooks(string key){ using(var cmd = _ctx.Database.GetDbConnection().CreateCommand()){ cmd.CommandText = "SearchBooks"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@Key", SqlDbType.NVarChar) {Value = key}); if(cmd.Connection.State == ConnectionState.Closed) cmd.Connection.Open(); var retObj = new List<dynamic>(); using (var dataReader = await cmd.ExecuteReaderAsync()){ while(await dataReader.ReadAsync()){ //Namespace for ExpandoObject: System.dynamic var dataRow = new ExpandoObject() as IDictionary<string, object>; for (var iFiled = 0; iFiled < dataReader.FieldCount; iFiled++) dataRow.Add(dataReader.GetName(iFiled), dataReader[iFiled]); retObj.Add((ExpandoObject)dataRow); } } if(!retObj.Any()) return JsonConvert.SerializeObject("No matching record found"); else return JsonConvert.SerializeObject(retObj); } } } } <!-- end snippet --> When I check the console for output it says `fail: Microsoft.AspNet.Server.Kestrel[13] An unhandled exception was thrown by the application. System.Data.SqlClient.SqlException (0x80131904): Procedure or function 'SearchBooks' expects parameter '@Key', which was not supplied.` I have created another website locally, specially to test the CORS issue (which works fine). I am calling the above method via `AJAX` in the following way: <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <script type='text/javascript'> $.ajax({ type: "POST", url: "http://localhost:5000/api/bookstore/SearchBooks", data: { 'key': 'van' }, dataType: 'json', contentType:"application/json", success: function (res) { $("#response").html(res); }, error: function (err) { } }); </script> <!-- end snippet --> Problem is the value of argument `key` in controller method `SearchBooks` is always `null`! But if I create a `model` (below) **MODEL** <!-- begin snippet: js hide: false --> <!-- language: lang-html --> public class SearchViewModel{ public string SearchKey {get; set;} } <!-- end snippet --> and then if I modify my `AJAX` to pass value to this `model` like following, everything works just fine! <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <script type='text/javascript'> var searchModel={ key: 'van' } $.ajax({ type: "POST", data: JSON.stringify(searhModel), url: "http://localhost:5000/api/bookstore/searchbooks", contentType:"application/json", success: function (res) { $("#response").html(res); }, error: function (err) { } }); </script> <!-- end snippet --> Please help!
0debug
Remove socket connection : <p>I have a problem with removing socket connection. I'm using :</p> <pre><code>socket.close(); </code></pre> <p>but when I try to open another socket connection from the same process, I get this error :</p> <pre><code>java.net.ConnectException: Connection refused: connect </code></pre> <p>Where am I going wrong, thanks by advance.</p>
0debug
How can I know how much space to allocate in an array? : I am creating a simple program (code below). Which asks for your name, and says hello back to you. I was just wondering the comments I made in the code are correct. I am trying to understand how arrays are created and how we allocate space for them, and treat them so we don't go out of bounds in memory #include <stdio.h> // "-" (no quotes, just the dash) means garbage values int main() { char name[5]; // name = [0] [1] [2] [3] [4] [5] // - - - - - - char fav_nums[5]; // fav_nums = [0] [1] [2] [3] [4] [5] // - - - - - - printf("What is your name (max characters 5)?\n"); scanf("%s\n", name); // I typed "Sammy" (no quotes) // name = [0] [1] [2] [3] [4] [5] // S a m m y \0 printf("Hi, %s\n", name); printf("Enter your 5 favorite numbers!\n"); int i = 0; while (i < 5) { scanf("%d", fav_nums[i]); i++; } // I typed 2 3 6 7 1 // fav_nums = [0] [1] [2] [3] [4] [5] // 2 3 6 7 1 - fav_nums[5] = '\0'; // fav_nums = [0] [1] [2] [3] [4] [5] // 2 3 6 7 1 \0 printf("Cool, I love"); i = 0; while (i < 5) { printf(" %d", fav_num[i]); i++; } printf("\n"); return 0; }
0debug
define as paramater in c. Why working? : in my last personal **c** project i've played a bit with files. One thing i've tried was having a define as a parameter. At the end is a code snippet so that you know what i mean. My question is: Why is it working? Where is the data stored? Is it in line with ANSI-C? I know that the code is not perfect, but it explains what i mean ;) #include <stdio.h> #define FILE_NAME "test.txt" void open_file(FILE**, char*); int main(int argc, char *argv[]) { FILE* file; open_file(&file, FILE_NAME); return 0; } void open_file(FILE** file, char* filename) { *(file)=fopen(filename, "r"); }
0debug
Interrupted windows 2008 server R2 install : <p>I interrupted an install of Windows 2008 server on a fast machine that was taking too long with the intentional of using an alternative boot media to the USB flash drive I was using. (It kept showing me a message saying it was preparing my computer for first time use for nearly 2 hrs). I therefore removed the USB drive and surprisingly it then came up with the message asking to either start in safe mode or a normal start. I choose a normal start and it booted fine. Should I have confidence in using this as a production server or should I just go for a clean install ?</p>
0debug
delet distince data from table in php : <p><a href="https://i.stack.imgur.com/sS1t3.png" rel="nofollow noreferrer">table</a></p> <p>In these picture you can show one sql table in these table i have a coloum which name is "matrix_unique_id" in thst coloum i have many same id and in each id i store one image the image coloum name is image_path. Now i want to delete all the image in one unique id accept one image.For example: in these 6665682 id i have 25 images now i want to delete all images accept one means when execute the query it delete 24 images and left one.</p> <p>what i do?</p>
0debug
Is there an interactive visual html editor? : <p>Is there any kind of decent program for html/css that lets you build a website visually? I'm thinking something more along the lines of adobe illustrator or google docs, that lets you put content onto a page and drag things to where you need them to be, but spits out html code when you're done. Something like google web designer but more flushed out and functional, as it's still in beta and has a long way to go. Also, what are these kinds of programs called? (originally thought they where WYSIWYGs )</p>
0debug
how to create in-memory folder in java : <p>how to create in-memory folder in java. I have a requirement of creating a folder in-memory and then write files in it. Is it possible? If yes how?</p>
0debug
for loop within a loop JS : i am trying to search for my name in a text using for loop within a for loop. but it's returning half of the letters and sometimes undefined. var text = 'huurrr hurrrh u rajat huhuhw dwhidwid sdijhsid \ hurhrhr hrher rajat ekkdwihd ruidhwui rajat'; var myName= 'rajat'; var hits = []; for (var i = 0; i < text.length; i++) { if (text[i] === 'r') { for (var j= i; j <= myName.length; j++) { hits.push(myName[j]); } } } console.log(hits); can somebody help with this please ?
0debug
static int unin_internal_pci_host_init(PCIDevice *d) { pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_I_PCI); d->config[0x08] = 0x00; pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0C] = 0x08; d->config[0x0D] = 0x10; d->config[0x34] = 0x00; return 0; }
1threat
vubr_set_mem_table_exec(VubrDev *dev, VhostUserMsg *vmsg) { int i; VhostUserMemory *memory = &vmsg->payload.memory; dev->nregions = memory->nregions; DPRINT("Nregions: %d\n", memory->nregions); for (i = 0; i < dev->nregions; i++) { void *mmap_addr; VhostUserMemoryRegion *msg_region = &memory->regions[i]; VubrDevRegion *dev_region = &dev->regions[i]; DPRINT("Region %d\n", i); DPRINT(" guest_phys_addr: 0x%016"PRIx64"\n", msg_region->guest_phys_addr); DPRINT(" memory_size: 0x%016"PRIx64"\n", msg_region->memory_size); DPRINT(" userspace_addr 0x%016"PRIx64"\n", msg_region->userspace_addr); DPRINT(" mmap_offset 0x%016"PRIx64"\n", msg_region->mmap_offset); dev_region->gpa = msg_region->guest_phys_addr; dev_region->size = msg_region->memory_size; dev_region->qva = msg_region->userspace_addr; dev_region->mmap_offset = msg_region->mmap_offset; mmap_addr = mmap(0, dev_region->size + dev_region->mmap_offset, PROT_READ | PROT_WRITE, MAP_SHARED, vmsg->fds[i], 0); if (mmap_addr == MAP_FAILED) { vubr_die("mmap"); } dev_region->mmap_addr = (uint64_t) mmap_addr; DPRINT(" mmap_addr: 0x%016"PRIx64"\n", dev_region->mmap_addr); } return 0; }
1threat
How to find Xpath for the banner text? : [enter image description here][1] [1]: https://i.stack.imgur.com/l09ro.png The text is Investors/ Lenders get access to creditworthy borrowers to lend funds as per their risk appetite and gain attractive stable returns or monthly income to create wealth. How to find xpath for mentioned text?
0debug
Karate UI Automation support : <p>wanted to explore on Karate UI Automation (selenium) support. found out that a jar is available for it click [<a href="https://search.maven.org/search?q=a:karate-core]" rel="nofollow noreferrer">https://search.maven.org/search?q=a:karate-core]</a> </p> <p>any blogs which can help to start with it like: browser configuration Initiating the webdriver/karate driver?</p> <p>karate UI automation documentation provided few code snippets but no clue on how to start, please guide.</p> <p>Added karate jar available (<a href="https://search.maven.org/search?q=a:karate-core" rel="nofollow noreferrer">https://search.maven.org/search?q=a:karate-core</a>) but when i try driver.location("<a href="http://sampledotcom" rel="nofollow noreferrer">http://sampledotcom</a>") writing this code on feature file, the gherkin is not identifying these lines</p>
0debug
i m beginner of Advance java("program jdbc") : java.sql.SQLSyntaxErrorException: ORA-01745: invalid host/bind variable name at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396) at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191) at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207) at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1010) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3657) at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1350) at ImageRerive.main(ImageRerive.java:70)
0debug
Replacement css tags in sql server : I need to replace <span style="text-decoration: underline;"> as <span style="text-decoration: underline;"><u> and </span> to </u></span>. Only replace </span> for <span style="text-decoration: underline;">. No need to replace </span> for <span style="background-color: #ffff00;"> Sql, css, HTML, sql-server declare @text varchar(max) set @text = '<font color="Gray"><b>123123) <span style="text-decoration: underline;"><em><br /> </em></span> <div><span style="text-decoration: underline;">Tested from 14.82 Phoenix CRM QA <span style="background-color: #ffff00;">DB(Version 06/22/2019)&nbsp;</span><br /> </span> <div><span style="text-decoration: underline;"><br /> </span></div> <span style="text-decoration: underline;">Tested from 14.82 Phoenix CRM QA DB(Version 06/22/2019)&nbsp;<br /> </span> <div>&nbsp;</div> <span style="text-decoration: underline;">Tested from 14.82 Phoenix CRM QA DB(Version 06/22/2019)&nbsp;<br /> </span> <div>&nbsp;</div> <span style="text-decoration: underline;">Tested from 14.82 Phoenix CRM QA DB(Version 06/22/2019)&nbsp;<br /> </span> <div>&nbsp;</div> <span style="text-decoration: underline;">Tested from 14.82 Phoenix CRM QA DB(Version 06/22/2019)&nbsp;<br /> </span> <div>&nbsp;</div> <span style="text-decoration: underline;"><br /> </span></div></b></font>' <font color="Gray"><b>123123) <span style="text-decoration: underline;"><u><em><br /> </em></u></span> <div><span style="text-decoration: underline;"><u>Tested from 14.82 Phoenix CRM QA <span style="background-color: #ffff00;">DB(Version 06/22/2019)&nbsp;<br /> </u></span> <div><span style="text-decoration: underline;"><u><br /> </u></span></div> <span style="text-decoration: underline;"><u>Tested from 14.82 Phoenix CRM QA DB(Version 06/22/2019)&nbsp;<br /> </u></span> <div>&nbsp;</div> <span style="text-decoration: underline;"><u>Tested from 14.82 Phoenix CRM QA DB(Version 06/22/2019)&nbsp;<br /> </u></span> <div>&nbsp;</div> <span style="text-decoration: underline;"><u>Tested from 14.82 Phoenix CRM QA DB(Version 06/22/2019)&nbsp;<br /> </u></span> <div>&nbsp;</div> <span style="text-decoration: underline;"><u>Tested from 14.82 Phoenix CRM QA DB(Version 06/22/2019)&nbsp;<br /> </u></span> <div>&nbsp;</div> <span style="text-decoration: underline;"><u><br /> </u></span></div></b></font>
0debug
void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, bool deprecated) { Location loc; DriveInfo *dinfo; int unit; loc_push_none(&loc); for (unit = 0; unit <= bus->info->max_target; unit++) { dinfo = drive_get(IF_SCSI, bus->busnr, unit); if (dinfo == NULL) { continue; } qemu_opts_loc_restore(dinfo->opts); if (deprecated) { if (blk_get_attached_dev(blk_by_legacy_dinfo(dinfo))) { continue; } if (!dinfo->is_default) { error_report("warning: bus=%d,unit=%d is deprecated with this" " machine type", bus->busnr, unit); } } scsi_bus_legacy_add_drive(bus, blk_by_legacy_dinfo(dinfo), unit, false, -1, NULL, &error_fatal); } loc_pop(&loc); }
1threat
Loading View while ListView Is Fulling : <p>I was trying to make a code that while filling a ListView there is a Loading View.</p> <p>An example?</p> <p>Thank you very much</p>
0debug
What is the difference between using pointer vector or non pointer vector? : <pre><code>private: vector&lt;float*&gt; m_values; vector&lt;float&gt; *m_index; vector&lt;float*&gt; *m_rowptr; </code></pre> <p>What would be the best way to save a large data structure, using vectors?</p>
0debug
Elements in array of user-defined type all change when one changes : <p>There is an illogical change happening in my array called "animals". Whenever I change one element in the array, all the other elements change along with it. I have no idea why this is happening.</p> <p>When I run the program below, the console writes</p> <pre><code>Sugar, Dog Sugar, Dog </code></pre> <p>That should not be happening. I should be getting </p> <pre><code>Fluffy, Cat Sugar, Dog </code></pre> <p>Please look at the relevant code below:</p> <pre><code>//Program.cs namespace AnimalProgram { class Program { static void Main(string[] args) { AnimalInfo vitalStats = new AnimalInfo("vital statistics", new string[] { "name", "sex", "species", "breed", "age" }); //name, species, breed, sex, age. AnimalInfo veterinarian = new AnimalInfo("veterinarian", new string[] { "Vet Name", "Name of Vet's Practice" }); List&lt;AnimalInfo&gt; animalStats = new List&lt;AnimalInfo&gt; {vitalStats, veterinarian }; Animal cat1 = new Animal(); Animal dog1 = new Animal(); Animal[] animals = new Animal[2] { cat1, dog1}; for(int i = 0; i &lt; animals.Count(); i++) animals[i].initializeAnimalInfo(animalStats); AnimalInfo cat1vitals= new AnimalInfo("vital statistics", new string[] { "Fluffy", "F", "Cat", "American Shorthair", "5" }); AnimalInfo dog1vitals = new AnimalInfo("vital statistics", new string[] { "Sugar", "F", "Dog", "Great Dane", "7" }); AnimalInfo cat1vet = new AnimalInfo("veterinarian", new string[] { "Joe Schmoe", "Joe's Veterinary" }); AnimalInfo dog1vet = new AnimalInfo("veterinarian", new string[] { "Jim Blow", "Jim's Garage" }); cat1.UpdateAnimalInfo(new List&lt;AnimalInfo&gt;() { cat1vitals, cat1vet }); dog1.UpdateAnimalInfo(new List&lt;AnimalInfo&gt;() { dog1vitals, dog1vet }); Console.WriteLine(cat1.animalProperties[0].info[0] + ", " + cat1.animalProperties[0].info[2]); Console.WriteLine(dog1.animalProperties[0].info[0] + ", " + dog1.animalProperties[0].info[2]); Console.ReadLine(); } } </code></pre> <p>}</p> <pre><code>//Animal.cs using System.Collections.Generic; using System.Linq; namespace AnimalProgram { class Animal { public List&lt;AnimalInfo&gt; animalProperties; public Animal() { } public void initializeAnimalInfo(List&lt;AnimalInfo&gt; aInfo) { animalProperties = aInfo; } public void UpdateAnimalInfo(List&lt;AnimalInfo&gt; targetInfo) { for (int i = 0; i &lt; targetInfo.Count(); i++) animalProperties[i].info = targetInfo[i].info; } } </code></pre> <p>}</p> <pre><code>//AnimalInfo.cs namespace AnimalProgram { public class AnimalInfo { public string infoName; public string [] info; public AnimalInfo(string iName, string [] information) { infoName = iName; info = information; } } </code></pre> <p>}</p>
0debug
What is the difference between Python's functions cls.score and cls.cv_result_ give? : I have written a logistic regression code in Python (Anaconda 3.5.2 with sklearn 0.18.2). I am doing **gridsearchCV()** and **train_test_split**. My goal is to find final (average) accuracy over the '10' folds with standard error on the test data. Additionally, I am predicting *correctly predicted class labels*, creating a *confusion matrix* and preparing a *classification report* summary. Please advise in the following: (1) Is my code correct? Please check each part. (2) I have tried two different sklearn functions, clf.score() and clf.cv_results_. I see that both give different results. Which one is correct? (I am not showing run results, but you may try it on any data). import numpy as np import pandas as pd from sklearn.linear_model import LogisticRegression from sklearn.model_selection import GridSearchCV, train_test_split from sklearn.metrics import classification_report,confusion_matrix from sklearn.pipeline import Pipeline # Load any n x m data and label column. No missing or NaN values. # I am skipping loading data part. One can load any data to test below code. sc = StandardScaler() lr = LogisticRegression() pipe = Pipeline(steps=[('sc', sc), ('lr', lr)]) parameters = {'lr__C': [0.001, 0.01]} if __name__ == '__main__': clf = GridSearchCV(pipe, parameters, n_jobs=-1, cv=10, refit=True) X_train, X_test, y_train, y_test = train_test_split(Data, labels, random_state=0) # Train the classifier on data1's feature and target data clf.fit(X_train, y_train) print("Accuracy on training set: {:.2f}% \n".format((clf.score(X_train, y_train))*100)) print("Accuracy on test set: {:.2f}%\n".format((clf.score(X_test, y_test))*100)) print("Best Parameters: ") print(clf.best_params_) # Alternately using cv_results_ print("Accuracy on training set: {:.2f}% \n", (clf.cv_results_['mean_train_score'])*100)) print("Accuracy on test set: {:.2f}%\n", (clf.cv_results_['mean_test_score'])*100)) # Predict class labels y_pred = clf.best_estimator_.predict(X_test) # Confusion Matrix class_names = ['Positive', 'Negative'] confMatrix = confusion_matrix(y_test, y_pred) print(confMatrix) # Accuracy Report classificationReport = classification_report(labels, y_pred, target_names=class_names) print(classificationReport) I will appreciate any advise.
0debug
Swap rootViewController with animation? : <p>Im trying to swap to another root view controller with a tab bar; via app delegate, and I want to add transition animation. By default it would only show the view without any animation.</p> <pre><code>let tabBar = self.instantiateViewController(storyBoard: "Main", viewControllerID: "MainTabbar") let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.window = UIWindow(frame: UIScreen.main.bounds) appDelegate.window?.rootViewController = tabBar appDelegate.window?.makeKeyAndVisible() </code></pre> <p>That's how I swapped to another rootview controller.</p>
0debug
void OPPROTO op_cli(void) { raise_exception(EXCP0D_GPF); }
1threat
Populate a spinner based on the selection of another spinner. : I have to populate states depending on the selected country.I also have to capture the items selected in other spinners. But the listener methods are not getting called. .... countriesSpinner.setOnItemSelectedListener(this); statesSpinner.setOnItemSelectedListener(this); yearSpinner.setOnItemSelectedListener(this); public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // On selecting a spinner item switch(view.getId()){ case R.id.countriesSpinner: { Log.i("selected country",selectedCountry); selectedCountry = parent.getItemAtPosition(position).toString(); populateStates(); ArrayAdapter stateAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, states); statesSpinner.setAdapter(stateAdapter); } break; case R.id.statesSpinner: { selectedState=parent.getItemAtPosition(position).toString(); } break; case R.id.yearSpinner: { selectedYear=parent.getItemAtPosition(position).toString(); } } } @Override public void onNothingSelected(AdapterView<?> parent) { }
0debug
Laravel yield attribute : <p>I'm trying to set an attribute using <strong>@yield</strong> and <strong>@section</strong>, but how? I tried to use</p> <pre><code>&lt;html @yield('mainApp')&gt; </code></pre> <p>and</p> <pre><code>@section('mainApp','id="myid"') </code></pre> <p>but it returns <strong>id=&amp;quot;myid&amp;quot;</strong> instead of <strong>id="myid"</strong></p> <p>I know that I can manage it with a default <em>id</em> but I don't like this way, and also what if I need to use a custom attribute?</p>
0debug
Socket.io gives CORS error even if I allowed cors it on server : <p>My node server and client are running on different ports(3001,5347 respectively). On client I had used,</p> <pre><code>var socket = io('http://127.0.0.1:3001'); </code></pre> <p>On server I tried all of following one by one</p> <pre><code> 1) io.set('origins', '*:*'); 2) io.set('origins', 'http://127.0.0.1:5347'); 3) io.set('origins', '*'); 4) io.set('origins', '127.0.0.1:5347'); </code></pre> <p>But I'm getting following error:</p> <blockquote> <p>XMLHttpRequest cannot load <a href="http://127.0.0.1:3001/socket.io/?EIO=3&amp;transport=polling&amp;t=1456799439856-4590" rel="noreferrer">http://127.0.0.1:3001/socket.io/?EIO=3&amp;transport=polling&amp;t=1456799439856-4590</a>. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'null' is therefore not allowed access.</p> </blockquote> <p>Note: I'm using express on server and I'm already using cors middleware in following way:</p> <pre><code>app.use(cors()); </code></pre> <p>Where app and cors are instances of express and cors respectively.</p>
0debug
static void parse_drive(DeviceState *dev, const char *str, void **ptr, const char *propname, Error **errp) { BlockBackend *blk; blk = blk_by_name(str); if (!blk) { error_setg(errp, "Property '%s.%s' can't find value '%s'", object_get_typename(OBJECT(dev)), propname, str); return; } if (blk_attach_dev(blk, dev) < 0) { DriveInfo *dinfo = blk_legacy_dinfo(blk); if (dinfo->type != IF_NONE) { error_setg(errp, "Drive '%s' is already in use because " "it has been automatically connected to another " "device (did you need 'if=none' in the drive options?)", str); } else { error_setg(errp, "Drive '%s' is already in use by another device", str); } return; } *ptr = blk; }
1threat
void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) { MigrationState *s = migrate_get_current(); if (params->has_compress_level && (params->compress_level < 0 || params->compress_level > 9)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level", "is invalid, it should be in the range of 0 to 9"); } if (params->has_compress_threads && (params->compress_threads < 1 || params->compress_threads > 255)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_threads", "is invalid, it should be in the range of 1 to 255"); } if (params->has_decompress_threads && (params->decompress_threads < 1 || params->decompress_threads > 255)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "decompress_threads", "is invalid, it should be in the range of 1 to 255"); } if (params->has_cpu_throttle_initial && (params->cpu_throttle_initial < 1 || params->cpu_throttle_initial > 99)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu_throttle_initial", "an integer in the range of 1 to 99"); } if (params->has_cpu_throttle_increment && (params->cpu_throttle_increment < 1 || params->cpu_throttle_increment > 99)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu_throttle_increment", "an integer in the range of 1 to 99"); } if (params->has_compress_level) { s->parameters.compress_level = params->compress_level; } if (params->has_compress_threads) { s->parameters.compress_threads = params->compress_threads; } if (params->has_decompress_threads) { s->parameters.decompress_threads = params->decompress_threads; } if (params->has_cpu_throttle_initial) { s->parameters.cpu_throttle_initial = params->cpu_throttle_initial; } if (params->has_cpu_throttle_increment) { s->parameters.cpu_throttle_increment = params->cpu_throttle_increment; } if (params->has_tls_creds) { g_free(s->parameters.tls_creds); s->parameters.tls_creds = g_strdup(params->tls_creds); } if (params->has_tls_hostname) { g_free(s->parameters.tls_hostname); s->parameters.tls_hostname = g_strdup(params->tls_hostname); } }
1threat
Cant connect to SQL data base C# : Ive installed and reinstalled SQL server express 2014 and visual studio still wont let me connect to a database. It wont even let me create a database. here is a image of the error message. Has anyone encountered this before? [error message][1] [1]: http://i.stack.imgur.com/GEjPp.png
0debug
What functions do Arrays in Google Apps Script support? : <p>I keep on finding that Array functions are missing in GAS, eg calling <code>find</code> gives the error: <code>Cannot find function find in object</code> </p> <p>The only docs I can find on this are somewhat ambiguous: <a href="https://developers.google.com/apps-script/guides/services/#basic_javascript_features" rel="noreferrer">https://developers.google.com/apps-script/guides/services/#basic_javascript_features</a></p> <blockquote> <p>Apps Script is based on JavaScript 1.6, plus a few features from 1.7 and 1.8. Many basic JavaScript features are thus available in addition to the built-in and advanced Google services: you can use common objects like Array, Date, RegExp, and so forth, as well as the Math and Object global objects. However, because Apps Script code runs on Google's servers (not client-side, except for HTML-service pages), browser-based features like DOM manipulation or the Window API are not available.</p> </blockquote> <p>How can I see what exact methods are available on Array?</p>
0debug
How to make a question, with an integer in it, asked again when it is left blank : <p>I am fairly new to python and I am not sure how to make a question involving an integer asked again when an invalid character is entered or it is left blank. Could someone please help me.</p> <p>I have only tried what I know and nothing has really worked.</p> <pre><code># Asks for age age = int(input("Please enter your age: ")) # Prevents age from being left blank # I need help with this part </code></pre>
0debug
int ff_MPV_common_frame_size_change(MpegEncContext *s) { int i, err = 0; if (s->slice_context_count > 1) { for (i = 0; i < s->slice_context_count; i++) { free_duplicate_context(s->thread_context[i]); } for (i = 1; i < s->slice_context_count; i++) { av_freep(&s->thread_context[i]); } } else free_duplicate_context(s); if ((err = free_context_frame(s)) < 0) return err; if (s->picture) for (i = 0; i < MAX_PICTURE_COUNT; i++) { s->picture[i].needs_realloc = 1; } s->last_picture_ptr = s->next_picture_ptr = s->current_picture_ptr = NULL; if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && !s->progressive_sequence) s->mb_height = (s->height + 31) / 32 * 2; else s->mb_height = (s->height + 15) / 16; if ((s->width || s->height) && av_image_check_size(s->width, s->height, 0, s->avctx)) return AVERROR_INVALIDDATA; if ((err = init_context_frame(s))) goto fail; s->thread_context[0] = s; if (s->width && s->height) { int nb_slices = s->slice_context_count; if (nb_slices > 1) { for (i = 1; i < nb_slices; i++) { s->thread_context[i] = av_malloc(sizeof(MpegEncContext)); memcpy(s->thread_context[i], s, sizeof(MpegEncContext)); } for (i = 0; i < nb_slices; i++) { if (init_duplicate_context(s->thread_context[i]) < 0) goto fail; s->thread_context[i]->start_mb_y = (s->mb_height * (i) + nb_slices / 2) / nb_slices; s->thread_context[i]->end_mb_y = (s->mb_height * (i + 1) + nb_slices / 2) / nb_slices; } } else { if (init_duplicate_context(s) < 0) goto fail; s->start_mb_y = 0; s->end_mb_y = s->mb_height; } s->slice_context_count = nb_slices; } return 0; fail: ff_MPV_common_end(s); return err; }
1threat
method does not override or implement a method from a supertype : I just started in Android Studio and I want to make a soundboard but i keep getting that error when I run my code public class MainActivity extends AppCompatActivity { Button bt; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); bt = (Button) findViewById(R.id.asta_e); final MediaPlayer mp = MediaPlayer.create(this, R.raw.sample); bt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mp.start(); } }); } Button bt1; @Override protected void onCreate2(Bundle savedInstanceState) { super.onCreate(savedInstanceState); bt1 = (Button) findViewById(R.id.boomba); final MediaPlayer mp =MediaPlayer.create(this, R.raw.boomba); bt1.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { mp.start(); } }); } }
0debug
Reading and recording character ASCII values to vector : <p>I'm attempting to open a text file, read the the file character by character, and store the ascii value of each character to a vector.</p> <p>I am successful in opening and reading the file, but I am confused as to why the integer values are not being stored in my vector. All the values are being stored as 0s. </p> <p>Sounds silly, but I wasn't sure if casting the char c to an integer was the issue, so I stored the (int) c value to a variable i before inputting it into the vector. The problem is, I know i is storing the ASCII values as intended, but I couldn't figure out why these values weren't being transferred to the vector. </p> <pre><code> char c; std::vector&lt;int&gt; ascii; while( inFile.get(c) ) { std::cout &lt;&lt; c; ascii.push_back( (int) c ); } inFile.close(); std::cout &lt;&lt; std::endl; for(auto&amp; i : ascii) { std::cout &lt;&lt; ascii[i] &lt;&lt; " "; } </code></pre> <p>odoylerules</p> <p>0 0 0 0 0 0 0 0 0 0 0 </p>
0debug
Using if and elif in list comprehension in python3 : Please I'm trying to use list comprehension to Write a program that prints the numbers from 1-100. But for multiples of 3, print 'fizz', for multiples of 5, print 'buzz', for multiples of 3 & 5, print 'fizzbuzz'" I also used for loops `for num in range(1, 101):` `if num %3 == 0 and num%5 == 0:` print('fizzbuzz') elif num%3 == 0: print('fizz') elif num%5 ==0: print('buzz') else: print(num)
0debug
please help to solve python error..i tried lots : File "/usr/local/lib/python3.7/dist-packages/speech_recognition/__init__.py", line 108, in get_pyaudio import pyaudio ModuleNotFoundError: No module named 'pyaudio' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "speechrecog.py", line 5, in <module> with sr.Microphone() as source: File "/usr/local/lib/python3.7/dist-packages/speech_recognition/__init__.py", line 79, in __init__ self.pyaudio_module = self.get_pyaudio() File "/usr/local/lib/python3.7/dist-packages/speech_recognition/__init__.py", line 110, in get_pyaudio raise AttributeError("Could not find PyAudio; check installation") AttributeError: Could not find PyAudio; check installation
0debug
Python Flask- datetime.datetime has no attribute datetime : I keep having an issue with the module datetime at this section of the code whenever i run it, it should add the time to the alarm manager from the datetime-local input from the html part. But whenever the text and date are added an error of datetime.datetime is not an attribute of datetime. ``` import os import sched import time from flask import Flask, render_template, url_for, request , redirect, jsonify from flask_sqlalchemy import SQLAlchemy from datetime import datetime app=Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] ='sqlite:///tabledata.db' #relative path db = SQLAlchemy(app) class Table(db.Model): id = db.Column(db.Integer, primary_key=True) #refrencing id of each entry content = db.Column(db.String(50), nullable=True) #the content that holds date_created = db.Column(db.DateTime, default=datetime.utcnow) #print the date it was made alarm = db.Column(db.DateTime) #stores the alarm def __repr__(self): return '<Task %r>' % self.id #every new task made returns its own id @app.route('/',methods=['POST','GET']) #adding two methods posting and getting def index(): if request.method == 'POST': #submitting form task_content = request.form['content'] #create new task from user input alarm_content = request.form['alarm'] alarm_tmp = alarm_content.replace('T', '-').replace(':', '-').split('-') alarm_tmp = [int(v) for v in alarm_tmp] alarm_datetime = datetime.datetime(*alarm_tmp) task = Table(content=task_content,alarm=alarm_content) #have the contents = input try: db.session.add(new_task) #add to database db.session.commit() return redirect('/') #redirect to input page except: return 'There was an error' else: tasks = Table.query.order_by(Table.date_created).all() #showing all contents on site return render_template('index.html',tasks=tasks) #user viewing the page if __name__ =="__main__": app.run(debug=True) #debugging true so errors are displayed ```
0debug
static void vp7_idct_add_c(uint8_t *dst, int16_t block[16], ptrdiff_t stride) { int i, a1, b1, c1, d1; int16_t tmp[16]; for (i = 0; i < 4; i++) { a1 = (block[i * 4 + 0] + block[i * 4 + 2]) * 23170; b1 = (block[i * 4 + 0] - block[i * 4 + 2]) * 23170; c1 = block[i * 4 + 1] * 12540 - block[i * 4 + 3] * 30274; d1 = block[i * 4 + 1] * 30274 + block[i * 4 + 3] * 12540; AV_ZERO64(block + i * 4); tmp[i * 4 + 0] = (a1 + d1) >> 14; tmp[i * 4 + 3] = (a1 - d1) >> 14; tmp[i * 4 + 1] = (b1 + c1) >> 14; tmp[i * 4 + 2] = (b1 - c1) >> 14; } for (i = 0; i < 4; i++) { a1 = (tmp[i + 0] + tmp[i + 8]) * 23170; b1 = (tmp[i + 0] - tmp[i + 8]) * 23170; c1 = tmp[i + 4] * 12540 - tmp[i + 12] * 30274; d1 = tmp[i + 4] * 30274 + tmp[i + 12] * 12540; dst[0 * stride + i] = av_clip_uint8(dst[0 * stride + i] + ((a1 + d1 + 0x20000) >> 18)); dst[3 * stride + i] = av_clip_uint8(dst[3 * stride + i] + ((a1 - d1 + 0x20000) >> 18)); dst[1 * stride + i] = av_clip_uint8(dst[1 * stride + i] + ((b1 + c1 + 0x20000) >> 18)); dst[2 * stride + i] = av_clip_uint8(dst[2 * stride + i] + ((b1 - c1 + 0x20000) >> 18)); } }
1threat
Returning true and a value from class function : <p>In my project i return <code>True</code> from a function within my class, when looking over the code i need to return <code>True</code> plus a <strong><em>URL value</em></strong> but i am coming in to issues, i would instanciate the class like:</p> <pre><code>if Engine(driver).mode_login_and_post(driver, "http://" + xml_site_name.get_text() + "/wp-login.php", s_user, s_pass, xml_content_title.get_text(), body_with_html, SLEEP, captcha, verify=False) == True: run more code once true is returned ... looking to get the returned value of a url here is possible ... </code></pre> <p><code>Engine</code> is the class i have instantiated, the way it is now this works fine, i'm getting back <code>True</code> so i continue with the code execution, is there a way to get back <code>True</code> plus another value (in this case a URL) to use in the rest of the code execution? i cannot think of away to do this, any help would be appreciated.</p>
0debug
static int dtext_prepare_text(AVFilterContext *ctx) { DrawTextContext *dtext = ctx->priv; uint32_t code = 0, prev_code = 0; int x = 0, y = 0, i = 0, ret; int text_height, baseline; char *text = dtext->text; uint8_t *p; int str_w = 0, len; int y_min = 32000, y_max = -32000; FT_Vector delta; Glyph *glyph = NULL, *prev_glyph = NULL; Glyph dummy = { 0 }; int width = ctx->inputs[0]->w; int height = ctx->inputs[0]->h; #if HAVE_LOCALTIME_R time_t now = time(0); struct tm ltime; uint8_t *buf = dtext->expanded_text; int buf_size = dtext->expanded_text_size; if (!buf) buf_size = 2*strlen(dtext->text)+1; localtime_r(&now, &ltime); while ((buf = av_realloc(buf, buf_size))) { *buf = 1; if (strftime(buf, buf_size, dtext->text, &ltime) != 0 || *buf == 0) break; buf_size *= 2; } if (!buf) return AVERROR(ENOMEM); text = dtext->expanded_text = buf; dtext->expanded_text_size = buf_size; #endif if ((len = strlen(text)) > dtext->nb_positions) { FT_Vector *p = av_realloc(dtext->positions, len * sizeof(*dtext->positions)); if (!p) { av_freep(dtext->positions); dtext->nb_positions = 0; return AVERROR(ENOMEM); } else { dtext->positions = p; dtext->nb_positions = len; } } for (i = 0, p = text; *p; i++) { GET_UTF8(code, *p++, continue;); dummy.code = code; glyph = av_tree_find(dtext->glyphs, &dummy, glyph_cmp, NULL); if (!glyph) ret = load_glyph(ctx, &glyph, code); if (ret) return ret; y_min = FFMIN(glyph->bbox.yMin, y_min); y_max = FFMAX(glyph->bbox.yMax, y_max); } text_height = y_max - y_min; baseline = y_max; glyph = NULL; for (i = 0, p = text; *p; i++) { GET_UTF8(code, *p++, continue;); if (prev_code == '\r' && code == '\n') continue; prev_code = code; if (is_newline(code)) { str_w = FFMAX(str_w, x - dtext->x); y += text_height; x = 0; continue; } prev_glyph = glyph; dummy.code = code; glyph = av_tree_find(dtext->glyphs, &dummy, glyph_cmp, NULL); if (dtext->use_kerning && prev_glyph && glyph->code) { FT_Get_Kerning(dtext->face, prev_glyph->code, glyph->code, ft_kerning_default, &delta); x += delta.x >> 6; } if (x + glyph->bbox.xMax >= width) { str_w = FFMAX(str_w, x); y += text_height; x = 0; } dtext->positions[i].x = x + glyph->bitmap_left; dtext->positions[i].y = y - glyph->bitmap_top + baseline; if (code == '\t') x = (x / dtext->tabsize + 1)*dtext->tabsize; else x += glyph->advance; } str_w = FFMIN(width - 1, FFMAX(str_w, x)); y = FFMIN(y + text_height, height - 1); dtext->w = str_w; dtext->h = y; return 0; }
1threat
void ccw_dstream_init(CcwDataStream *cds, CCW1 const *ccw, ORB const *orb) { g_assert(!(orb->ctrl1 & ORB_CTRL1_MASK_MIDAW)); cds->flags = (orb->ctrl0 & ORB_CTRL0_MASK_I2K ? CDS_F_I2K : 0) | (orb->ctrl0 & ORB_CTRL0_MASK_C64 ? CDS_F_C64 : 0) | (ccw->flags & CCW_FLAG_IDA ? CDS_F_IDA : 0); cds->count = ccw->count; cds->cda_orig = ccw->cda; ccw_dstream_rewind(cds); if (!(cds->flags & CDS_F_IDA)) { cds->op_handler = ccw_dstream_rw_noflags; } else { assert(false); } }
1threat
Is the identifier in a for loop a variable - Python? : Is the letter identifier considered a variable? text = ("Hello") for letter in text: print (letter)
0debug
Vue JS focus next input on enter : <p>I have 2 inputs and want switch focus from first to second when user press Enter. I tried mix jQuery with Vue becouse I can't find any function to focus on something in Vue documentation:</p> <pre><code>&lt;input v-on:keyup.enter="$(':focus').next('input').focus()" ...&gt; &lt;input ...&gt; </code></pre> <p>But on enter I see error in console:</p> <pre><code>build.js:11079 [Vue warn]: Property or method "$" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in anonymous component - use the "name" option for better debugging messages.)warn @ build.js:11079has @ build.js:9011keyup @ build.js:15333(anonymous function) @ build.js:10111 build.js:15333 Uncaught TypeError: $ is not a function </code></pre>
0debug
Get superclass name in ES6 : <p>I have a class, and another class that extends that class.</p> <pre><code>class Shape { constructor() { return this; } } class Circle extends Shape { constructor() { super(); return this; } } let foo = new Circle(); </code></pre> <p>I can get foo's class with</p> <pre><code>let className = foo.constructor.name // returns string 'Circle' </code></pre> <p>Is it possible to get the name of foo's superclass ('Shape') in a similar manner?</p>
0debug
How to remove a key of an array? : <p>I need to remove <strong>[picture_names]</strong> from my <code>array</code>. Help me to remove this?</p> <p><a href="https://i.stack.imgur.com/xOJuX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xOJuX.jpg" alt="enter image description here"></a></p>
0debug
What is diff between requestIdToken and requestServerAuthCode in google singnin : <p>I am not able to differentiate between these two: requestIdToken and requestServerAuthCode, when we signin with google api from android device.</p> <p>My requirement is to provide option for users to login in android device, and after login sync data to my server. Server need to validate logged in user request from android device. I am thinking to use "requestIdToken". On the server side i am using google client library to fetch user info from requestIdToken.</p>
0debug
Can i program games with unity by python ?? I don't know c# : <p>I want to start 3d games programming , should I start 2d first ? please give me useful course . Does unity accept python ? If not , what do you prefer( directpython, openlg,panda3d ) Please give me useful course . I'm beginner Sorry about my bad English And what is game engine</p> <p>If you know only one answer please answer :) </p>
0debug
C++ error expected ";" before 'endl' how to fix it? : <p>Im just started studing c++ and im just learned how for , while , if works and im creating very simple decision game based in console and i have problems with endl; line bc its saying expected ';' before 'endl' and i have problem with it . oh and if someone is wondering what language im using in "" its polish</p> <p>I tried everything i can ;_;</p> <pre><code>#include &lt;iostream&gt; #include &lt;windows.h&gt; #include &lt;cstdlib&gt; string wybor; int main() { cout &lt;&lt; "budzisz sie w totalej ciemnosci ale zauwazasz w oddali dom"endl; cout &lt;&lt; "A. idz do domu"endl; cout &lt;&lt; "B.Podskocz w miejscu"endl; cin &gt;&gt; wybor; return 0; } </code></pre>
0debug
static void local_mapped_file_attr(int dirfd, const char *name, struct stat *stbuf) { FILE *fp; char buf[ATTR_MAX]; int map_dirfd; map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR); if (map_dirfd == -1) { return; } fp = local_fopenat(map_dirfd, name, "r"); close_preserve_errno(map_dirfd); if (!fp) { return; } memset(buf, 0, ATTR_MAX); while (fgets(buf, ATTR_MAX, fp)) { if (!strncmp(buf, "virtfs.uid", 10)) { stbuf->st_uid = atoi(buf+11); } else if (!strncmp(buf, "virtfs.gid", 10)) { stbuf->st_gid = atoi(buf+11); } else if (!strncmp(buf, "virtfs.mode", 11)) { stbuf->st_mode = atoi(buf+12); } else if (!strncmp(buf, "virtfs.rdev", 11)) { stbuf->st_rdev = atoi(buf+12); } memset(buf, 0, ATTR_MAX); } fclose(fp); }
1threat
Custom View constructor in Android 4.4 crashes on Kotlin, how to fix? : <p>I have a custom view written in Kotlin using JvmOverloads that I could have default value.</p> <pre><code>class MyView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyle: Int = 0, defStyleRes: Int = 0 ) : LinearLayout(context, attrs, defStyle, defStyleRes) </code></pre> <p>All works fine in Android 5.1 and above.</p> <p>However it crashes in 4.4, since the constructor in 4.4 doesn't have <code>defStyleRes</code>. How could I have that supported that in 5.1 and above I could have <code>defStyleRes</code> but not in 4.4, without need to explicitly having 4 constructors defined like we did in Java?</p> <p>Note: The below would works fine in 4.4, but then we loose the <code>defStyleRes</code>.</p> <pre><code>class MyView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyle: Int = 0 ) : LinearLayout(context, attrs, defStyle) </code></pre>
0debug
php strom reset setting whenever PC automaticaly restrart : Sometime during too much of load my PC automatically restart during working so that when i logged in again then it reset my PHP storm setting any one know how to get rid of this?
0debug
How to do this effect? :S : <p>I'll be more then grateful if someone can give me some hints in achieving this effect from here: <a href="http://branditylab.com/#branditylab/home" rel="nofollow">http://branditylab.com/#branditylab/home</a></p>
0debug
Mock FingerprintManager in Android tests : <p>Is there a way to simulate or mock <a href="https://developer.android.com/reference/android/hardware/fingerprint/FingerprintManager.html#authenticate(android.hardware.fingerprint.FingerprintManager.CryptoObject,%20android.os.CancellationSignal,%20int,%20android.hardware.fingerprint.FingerprintManager.AuthenticationCallback,%20android.os.Handler)" rel="noreferrer">FingerprintManager.authenticate()</a>? I want to write instrumented tests for my fingerprint authenticator.</p> <p>I'm fine if there's a solution with a restriction that the tests can be run either on an emulator or a device. I use JUnit 4.12.</p>
0debug
Object *container_get(Object *root, const char *path) { Object *obj, *child; gchar **parts; int i; parts = g_strsplit(path, "/", 0); assert(parts != NULL && parts[0] != NULL && !parts[0][0]); obj = root; for (i = 1; parts[i] != NULL; i++, obj = child) { child = object_resolve_path_component(obj, parts[i]); if (!child) { child = object_new("container"); object_property_add_child(obj, parts[i], child, NULL); } } g_strfreev(parts); return obj; }
1threat
static void ehci_advance_async_state(EHCIState *ehci) { const int async = 1; switch(ehci_get_state(ehci, async)) { case EST_INACTIVE: if (!(ehci->usbcmd & USBCMD_ASE)) { break; } ehci_set_usbsts(ehci, USBSTS_ASS); ehci_set_state(ehci, async, EST_ACTIVE); case EST_ACTIVE: if ( !(ehci->usbcmd & USBCMD_ASE)) { ehci_clear_usbsts(ehci, USBSTS_ASS); ehci_set_state(ehci, async, EST_INACTIVE); break; } if (ehci->usbcmd & USBCMD_IAAD) { DPRINTF("ASYNC: doorbell request acknowledged\n"); ehci->usbcmd &= ~USBCMD_IAAD; ehci_set_interrupt(ehci, USBSTS_IAA); break; } if (ehci->usbsts & USBSTS_IAA) { DPRINTF("IAA status bit still set.\n"); break; } if (ehci->asynclistaddr == 0) { break; } ehci_set_state(ehci, async, EST_WAITLISTHEAD); ehci_advance_state(ehci, async); break; default: fprintf(stderr, "ehci: Bad asynchronous state %d. " "Resetting to active\n", ehci->astate); assert(0); } }
1threat
static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, long dstW, long chrDstW) { #ifdef HAVE_MMX if(uDest != NULL) { asm volatile( YSCALEYUV2YV121 :: "r" (chrSrc + chrDstW), "r" (uDest + chrDstW), "g" (-chrDstW) : "%"REG_a ); asm volatile( YSCALEYUV2YV121 :: "r" (chrSrc + 2048 + chrDstW), "r" (vDest + chrDstW), "g" (-chrDstW) : "%"REG_a ); } asm volatile( YSCALEYUV2YV121 :: "r" (lumSrc + dstW), "r" (dest + dstW), "g" (-dstW) : "%"REG_a ); #else int i; for(i=0; i<dstW; i++) { int val= lumSrc[i]>>7; if(val&256){ if(val<0) val=0; else val=255; } dest[i]= val; } if(uDest != NULL) for(i=0; i<chrDstW; i++) { int u=chrSrc[i]>>7; int v=chrSrc[i + 2048]>>7; if((u|v)&256){ if(u<0) u=0; else if (u>255) u=255; if(v<0) v=0; else if (v>255) v=255; } uDest[i]= u; vDest[i]= v; } #endif }
1threat
Converting list to dictonary : I have list which contains data as below Listing =['abc:123' ,'bcd:234','def:456'...] This above listing i derived it from a text file which has data similar to above. I need to convert the above to dictionary. D = [abc:123, Bcd:234, Def:456] Any suggestions. Help will much appreciated
0debug
static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size) { BDRVQcowState *s = bs->opaque; uint64_t i, nb_clusters; int refcount; nb_clusters = size_to_clusters(s, size); retry: for(i = 0; i < nb_clusters; i++) { uint64_t next_cluster_index = s->free_cluster_index++; refcount = get_refcount(bs, next_cluster_index); if (refcount < 0) { return refcount; } else if (refcount != 0) { goto retry; } } if (s->free_cluster_index - 1 > (INT64_MAX >> s->cluster_bits)) { return -EFBIG; } #ifdef DEBUG_ALLOC2 fprintf(stderr, "alloc_clusters: size=%" PRId64 " -> %" PRId64 "\n", size, (s->free_cluster_index - nb_clusters) << s->cluster_bits); #endif return (s->free_cluster_index - nb_clusters) << s->cluster_bits; }
1threat
PPC_OP(subfc) { T0 = T1 - T0; if (T0 <= T1) { xer_ca = 1; } else { xer_ca = 0; } RETURN(); }
1threat
Toggle class on and off in jquery with button : <p>I'm new to javascript but I'm having a hard time toggle this class on and off.</p> <p><a href="https://jsfiddle.net/spadez/o2s0hmtv/2/" rel="nofollow">https://jsfiddle.net/spadez/o2s0hmtv/2/</a></p> <pre><code>$( "#togglebtn" ).click(function() { $(.mynav).toggleClass( "modal" ); }); </code></pre> <p>Based on tutorials this should work, but the button doesn't seem to do anything. Can anyone show me where I went wrong please?</p>
0debug
group rows into different datasets by condition.. ( picture attached) : favorite I need to create 7 datasets ((local, web, call, local&call, local&web, call&web, all ) depending on if the customer has used a channel from the below sample data. [please see this picture for more details on the sample table][1] So if a customer has used all three channels in one instance and in the other instance he just uses either of them, then that row with Customer=1 should go to the'all' dataset. Similarly for 3, if he has used local and web in one instance and just web in another instance, then it should go to the 'local&web' dataset. Customer IDs should not be duplicated in other dataset i.e. customer 1 can belong to wither one of the dataset only. I am stuck with this, can anyone give me a snippet of either sas or sql code to proceed further. Thanks ! [1]: http://i.stack.imgur.com/OAIMp.png
0debug
static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq) { V9fsVirtioState *v = (V9fsVirtioState *)vdev; V9fsState *s = &v->state; V9fsPDU *pdu; ssize_t len; while ((pdu = pdu_alloc(s))) { struct { uint32_t size_le; uint8_t id; uint16_t tag_le; } QEMU_PACKED out; VirtQueueElement *elem; elem = virtqueue_pop(vq, sizeof(VirtQueueElement)); if (!elem) { pdu_free(pdu); break; } BUG_ON(elem->out_num == 0 || elem->in_num == 0); QEMU_BUILD_BUG_ON(sizeof(out) != 7); v->elems[pdu->idx] = elem; len = iov_to_buf(elem->out_sg, elem->out_num, 0, &out, sizeof(out)); BUG_ON(len != sizeof(out)); pdu->size = le32_to_cpu(out.size_le); pdu->id = out.id; pdu->tag = le16_to_cpu(out.tag_le); qemu_co_queue_init(&pdu->complete); pdu_submit(pdu); } }
1threat
functions and callbacks - JS : <p>I was given three functions that sends 2 parameter with callbacks, however I don't understand the codes even though there are comments on it and how can I log or manipulate data or the array or object using these functions.</p> <pre><code>// Define a function, each, which takes in a collection and // uses a callback on the elements of collection // Collection can be either an array or an object var each = function(collection, callback){ if(Array.isArray(collection)){ for(var i=0;i&lt;collection.length;i++){ callback(collection[i]); } } else{ for(var key in collection){ callback(collection[key]); } } }; // Define a function, map, which uses a callback on a collection and returns an array // example, times3 of the array, [3,6,9,12,15] // Create an empty array and push the values from the callback // onto that array. Then return the array // You must use each function instead of a for-loop. // Each element of collection will be passed as an argument into // the function parameter which then uses the call-back from the outer scope! var map = function(collection, callback){ var new_Array = []; each(collection, function(x){ new_Array.push(callback(x)); }); return new_Array; }; // Define a function filter, which checks the boolean value of the callback // on the element of collection // output each boolean value of the callback // example, even of an array, [1,2,3,4,5] -&gt; false, true, false, true, false var filter = function(collection, callback){ each(collection, function(item){ if(callback(item)){ return item; } }); }; var myObj = { num1: 1, num2: 2, num3: [3, 5, 6] }; var myArr = [2, 4, 6, 8, 9]; var output = each(myObj); console.log(output); </code></pre> <p>Any idea? Can anyone explain (in layman's term) to me how these code works and how to manipulate them?</p>
0debug
insert function is doesn't add a new elements : <p>I wrote a program which should to insert elements in the list compare with their costs, but it doesn't work. I enter one element and then program doesn't work. And I can't understand what's wrong.</p> <p>here is an exactly the exercise:</p> <h2>Modify the list, so elements on the list are ordered by price. New items added to the list should be inserted into the right place</h2> <pre><code> #include &lt;iostream&gt; #include &lt;string&gt; using namespace std; typedef struct listt { string name; float price; struct listt *next; }listt; typedef listt* listPtr; void insertt(listPtr *, string, float); void printList(listPtr); void instruct(); int main() { unsigned int choice; float costs; string itemName; listPtr head = NULL; instruct(); cin &gt;&gt; choice; while(choice != 3) { switch(choice) { case 1: cout &lt;&lt; "Please enter the name of the item:" &lt;&lt; endl; cin &gt;&gt; itemName; cout &lt;&lt; "Please enter the cost of item: " &lt;&lt;endl; cin &gt;&gt; costs; insertt(&amp;head, itemName, costs); break; case 2: printList(head); break; } cout&lt;&lt;"Choose the operation\n"; cin &gt;&gt; choice; } cout&lt;&lt;"end of operation"; return 0; } void instruct(void) { cout&lt;&lt;"Choose the operation\n" &lt;&lt; "1.Fill the list\n" &lt;&lt; "2.Print the list\n" &lt;&lt; "3.End operation\n"; } void insertt(listPtr *itemList, string nm, float cst) { listPtr previousPt; listPtr currentPt; listPtr newPtr; if(newPtr != NULL){ newPtr-&gt;name = nm; newPtr-&gt;price = cst; newPtr-&gt;next = *itemList; } previousPt = NULL; currentPt = *itemList; while(currentPt != NULL &amp;&amp; cst &gt; currentPt-&gt;price ) { previousPt = currentPt; currentPt = currentPt-&gt;next; } if(currentPt == NULL) { newPtr-&gt;next = *itemList; *itemList = newPtr; } else{ previousPt-&gt;next = newPtr; newPtr-&gt;next = currentPt; } } void printList(listPtr hh) { while(hh-&gt;next != NULL) { cout &lt;&lt; hh-&gt;name &lt;&lt;" " &lt;&lt; hh-&gt;price&lt;&lt; endl; hh = hh-&gt;next; } } </code></pre>
0debug
Swift "for" inside of ( ) what is this..? : <pre><code>func getIndex(for priority: Task.Priority) -&gt; Int { prioritizedTasks.firstIndex { $0.priority == priority }! } </code></pre> <p>what is "for" inside of ()? It is for loop...? what is $0 ? I tried to find them in apple document but I don't know the operator name for them...</p>
0debug
Getting Warning Didn't find class "com.qualcomm.qti.Performance" : <p>My app is working fine but I am getting this warning every time when I test my app in my physical device. I am not using any such third party library which can cause this type of issue. My LogCat view.</p> <pre><code>E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]] </code></pre> <p>Is this issue will cause some serious issue in future or not. Thanks in Advance :)</p>
0debug
single command to stop and remove docker container : <p>Is there any command which can combine the <code>docker stop</code> and <code>docker rm</code> command together ? Each time I want to delete a running container, I need to execute 2 commands sequentially, I wonder if there is a combined command can simplify this process.</p> <pre><code>docker stop CONTAINER_ID docker rm CONTATINER_ID </code></pre>
0debug
int qemu_chr_fe_write_all(CharDriverState *s, const uint8_t *buf, int len) { int offset = 0; int res = 0; qemu_mutex_lock(&s->chr_write_lock); while (offset < len) { do { res = s->chr_write(s, buf + offset, len - offset); if (res == -1 && errno == EAGAIN) { g_usleep(100); } } while (res == -1 && errno == EAGAIN); if (res <= 0) { break; } offset += res; } if (offset > 0) { qemu_chr_fe_write_log(s, buf, offset); } qemu_mutex_unlock(&s->chr_write_lock); if (res < 0) { return res; } return offset; }
1threat
Where to put code to run after startup is completed : <p>I have an aspnetcore app.</p> <p>During startup, it does the usual startup actions.</p> <p>After these are complete, I need to do some verification to ensure it was set up correctly. In particular, I need to call a stored procedure in the database using the default connection string. In other words, I need to create a class that uses dependency injection so that needs to be complete before it is called.</p> <p>Just not sure where to put such code in StartUp.</p>
0debug
static inline int get_scale(GetBitContext *gb, int level, int value) { if (level < 5) { value += get_bitalloc(gb, &dca_scalefactor, level); } else if (level < 8) value = get_bits(gb, level + 1); return value; }
1threat
Does anyone have the "Documentation URL"s in PyCharm for the following libraries: : <p>I'm a fan of the "quick documentation" feature of PyCharm &amp; other Jetbrains IDEs, but it needs to know the specific "Documentation URL" for each library, that gets set under <code>Preferences &gt; Tools &gt; Python External Documentation</code> settings.</p> <p>I was wondering if anybody has worked it out for any of the following libraries:</p> <ul> <li>Tensorflow</li> <li>PyTorch</li> <li>Matplotlib</li> <li>Seaborn</li> <li>Pandas</li> </ul>
0debug
Killing gracefully a .NET Core daemon running on Linux : <p>I created a .NET Core console application running as a daemon on a Ubuntu 14.04 machine.</p> <p>I want to stop the service without forcing it, being able to handle a kill event.</p> <p>How can I achieve this?</p>
0debug
Get first value from in mysql : <p>I have column in mysql table </p> <pre><code> uid , valueid , date 11 , 23, "2019-01-01" 11 , 24, "2019-02-01" 11 , 22, "2019-05-01" </code></pre> <p>i want result in this format</p> <pre><code>id , valueid , date 11 , 23 , "2019-01-01" </code></pre> <p>get always first value id i.e is 23 </p>
0debug
Input type number increment using scroll : <p>I'm having some hard time figuring out how to implement "input type number" increment using scroll feature. </p> <p>My question may sound confusing, so I attached an example. </p> <p><a href="https://i.stack.imgur.com/JXMRg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JXMRg.png" alt="enter image description here"></a></p> <p><strong>Live preview: <a href="https://webuyfiredamagedhouses.com/cash-offer/" rel="nofollow noreferrer">https://webuyfiredamagedhouses.com/cash-offer/</a></strong></p>
0debug
301 Redirection in PHP : I'm trying to redirect a URL in PHP. Used following code in the .htaccess file: Redirect /old_file_path /new_file_path Redirection is working fine but the URL that I get is in a different format: /new_file_path/?/old_file_path How do I fix this?
0debug
Is colorama the only way to change the python shell output colour? : <p>So I have been trying to change the colour of the output in the shell, but it just ends up returning boxes. I am using python 3.7.4.</p> <p><a href="https://i.stack.imgur.com/qPF6C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qPF6C.png" alt="The code and the output"></a></p>
0debug
cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu, VCardResponse **response) { CACPKIAppletData *pki_applet = NULL; VCardAppletPrivate *applet_private = NULL; int size, next; unsigned char *sign_buffer; vcard_7816_status_t status; VCardStatus ret = VCARD_FAIL; applet_private = vcard_get_current_applet_private(card, apdu->a_channel); assert(applet_private); pki_applet = &(applet_private->u.pki_data); switch (apdu->a_ins) { case CAC_UPDATE_BUFFER: *response = vcard_make_response( VCARD7816_STATUS_ERROR_CONDITION_NOT_SATISFIED); ret = VCARD_DONE; break; case CAC_GET_CERTIFICATE: if ((apdu->a_p2 != 0) || (apdu->a_p1 != 0)) { *response = vcard_make_response( VCARD7816_STATUS_ERROR_P1_P2_INCORRECT); break; } assert(pki_applet->cert != NULL); size = apdu->a_Le; if (pki_applet->cert_buffer == NULL) { pki_applet->cert_buffer = pki_applet->cert; pki_applet->cert_buffer_len = pki_applet->cert_len; } size = MIN(size, pki_applet->cert_buffer_len); next = MIN(255, pki_applet->cert_buffer_len - size); *response = vcard_response_new_bytes( card, pki_applet->cert_buffer, size, apdu->a_Le, next ? VCARD7816_SW1_WARNING_CHANGE : VCARD7816_SW1_SUCCESS, next); pki_applet->cert_buffer += size; pki_applet->cert_buffer_len -= size; if ((*response == NULL) || (next == 0)) { pki_applet->cert_buffer = NULL; } if (*response == NULL) { *response = vcard_make_response( VCARD7816_STATUS_EXC_ERROR_MEMORY_FAILURE); } ret = VCARD_DONE; break; case CAC_SIGN_DECRYPT: if (apdu->a_p2 != 0) { *response = vcard_make_response( VCARD7816_STATUS_ERROR_P1_P2_INCORRECT); break; } size = apdu->a_Lc; sign_buffer = g_realloc(pki_applet->sign_buffer, pki_applet->sign_buffer_len + size); memcpy(sign_buffer+pki_applet->sign_buffer_len, apdu->a_body, size); size += pki_applet->sign_buffer_len; switch (apdu->a_p1) { case 0x80: pki_applet->sign_buffer = sign_buffer; pki_applet->sign_buffer_len = size; *response = vcard_make_response(VCARD7816_STATUS_SUCCESS); break; case 0x00: status = vcard_emul_rsa_op(card, pki_applet->key, sign_buffer, size); if (status != VCARD7816_STATUS_SUCCESS) { *response = vcard_make_response(status); break; } *response = vcard_response_new(card, sign_buffer, size, apdu->a_Le, VCARD7816_STATUS_SUCCESS); if (*response == NULL) { *response = vcard_make_response( VCARD7816_STATUS_EXC_ERROR_MEMORY_FAILURE); } break; default: *response = vcard_make_response( VCARD7816_STATUS_ERROR_P1_P2_INCORRECT); break; } g_free(sign_buffer); pki_applet->sign_buffer = NULL; pki_applet->sign_buffer_len = 0; ret = VCARD_DONE; break; case CAC_READ_BUFFER: *response = vcard_make_response( VCARD7816_STATUS_ERROR_COMMAND_NOT_SUPPORTED); ret = VCARD_DONE; break; default: ret = cac_common_process_apdu(card, apdu, response); break; } return ret; }
1threat
avs_decode_frame(AVCodecContext * avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; const uint8_t *buf_end = avpkt->data + avpkt->size; int buf_size = avpkt->size; AvsContext *const avs = avctx->priv_data; AVFrame *picture = data; AVFrame *const p = &avs->picture; const uint8_t *table, *vect; uint8_t *out; int i, j, x, y, stride, vect_w = 3, vect_h = 3; AvsVideoSubType sub_type; AvsBlockType type; GetBitContext change_map; if (avctx->reget_buffer(avctx, p)) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } p->reference = 3; p->pict_type = AV_PICTURE_TYPE_P; p->key_frame = 0; out = avs->picture.data[0]; stride = avs->picture.linesize[0]; if (buf_end - buf < 4) return AVERROR_INVALIDDATA; sub_type = buf[0]; type = buf[1]; buf += 4; if (type == AVS_PALETTE) { int first, last; uint32_t *pal = (uint32_t *) avs->picture.data[1]; first = AV_RL16(buf); last = first + AV_RL16(buf + 2); if (first >= 256 || last > 256 || buf_end - buf < 4 + 4 + 3 * (last - first)) return AVERROR_INVALIDDATA; buf += 4; for (i=first; i<last; i++, buf+=3) { pal[i] = (buf[0] << 18) | (buf[1] << 10) | (buf[2] << 2); pal[i] |= 0xFFU << 24 | (pal[i] >> 6) & 0x30303; } sub_type = buf[0]; type = buf[1]; buf += 4; } if (type != AVS_VIDEO) return -1; switch (sub_type) { case AVS_I_FRAME: p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; case AVS_P_FRAME_3X3: vect_w = 3; vect_h = 3; break; case AVS_P_FRAME_2X2: vect_w = 2; vect_h = 2; break; case AVS_P_FRAME_2X3: vect_w = 2; vect_h = 3; break; default: return -1; } if (buf_end - buf < 256 * vect_w * vect_h) return AVERROR_INVALIDDATA; table = buf + (256 * vect_w * vect_h); if (sub_type != AVS_I_FRAME) { int map_size = ((318 / vect_w + 7) / 8) * (198 / vect_h); if (buf_end - table < map_size) return AVERROR_INVALIDDATA; init_get_bits(&change_map, table, map_size * 8); table += map_size; } for (y=0; y<198; y+=vect_h) { for (x=0; x<318; x+=vect_w) { if (sub_type == AVS_I_FRAME || get_bits1(&change_map)) { if (buf_end - table < 1) return AVERROR_INVALIDDATA; vect = &buf[*table++ * (vect_w * vect_h)]; for (j=0; j<vect_w; j++) { out[(y + 0) * stride + x + j] = vect[(0 * vect_w) + j]; out[(y + 1) * stride + x + j] = vect[(1 * vect_w) + j]; if (vect_h == 3) out[(y + 2) * stride + x + j] = vect[(2 * vect_w) + j]; } } } if (sub_type != AVS_I_FRAME) align_get_bits(&change_map); } *picture = avs->picture; *got_frame = 1; return buf_size; }
1threat
static always_inline void _cpu_ppc_store_hdecr (CPUState *env, uint32_t hdecr, uint32_t value, int is_excp) { ppc_tb_t *tb_env = env->tb_env; __cpu_ppc_store_decr(env, &tb_env->hdecr_next, tb_env->hdecr_timer, &cpu_ppc_hdecr_excp, hdecr, value, is_excp); }
1threat
static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { int8_t tc[4]; tc[0] = tc0_table[index_a][bS[0]]; tc[1] = tc0_table[index_a][bS[1]]; tc[2] = tc0_table[index_a][bS[2]]; tc[3] = tc0_table[index_a][bS[3]]; h->h264dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc); } else { h->h264dsp.h264_v_loop_filter_luma_intra(pix, stride, alpha, beta); } }
1threat
Elements wider than window - CSS : <p>When I check my website with Safari browser on smartphone (iPhone) or MacBook, then some elements of my website are wider than the browser window e.g. the <code>body</code>-tag. I have checked the website with dev-tool and it seems that it begins at a width of 600px and underneath. I dont see this problem in Chrome. </p> <p>You can see a screenshot here and see that the window has a width of 375px but the <code>body</code>-tag is 439px wide. </p> <p><a href="https://i.stack.imgur.com/V0n2o.png" rel="noreferrer"><img src="https://i.stack.imgur.com/V0n2o.png" alt="Screenshot"></a></p> <p>I am applying this CSS-rules because I read this should solve the problem but it isn't for me, unfortunately.</p> <pre><code>* { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } </code></pre> <p>Here is the website I am talking about: <a href="http://www.firma-info.no" rel="noreferrer">http://www.firma-info.no</a></p> <p>I hope somebody has an advice for me. </p> <p>Thanks in advance!</p>
0debug
Difference between width & height and the style image attribute : <p>Why use a style image attribute rather than just coding width and height for each image? </p>
0debug
why we should use docker for .Net core : <p>My Question is why should we use Docker with .Net core according to Microsoft .Net core is platform independent framework so we can host .net core app on any platform. Please guide me about that it is really confusing. Thanks in Advance.</p>
0debug
PHP How to allow subdomain to check for registered account? : <p>I made a website website.org and a subdomain for it subdomain.website.org. On the main domain, I have set up a user login system with a MySQL database. On the main domain, the php code can successfully check whether the user has logged in or not. However, since the registration/login page is inside the main domain directory, the webpages on the subdomain are unable to do the same. How do I make it so that both domains connect to the same database and check for the same account?</p>
0debug
How can I write an exponent in pycharm (not just in python) : I want this to appear: "ax<sup>2</sup>+ bx + c." How can I do this in pycharm or any other IDE?
0debug
Bootstrap vertical alignment not working no matter what : <p>I've read tons of different topics and articles about that common issue but still no working solution. Now I'm kinda desperate so I'd very grateful for any help and here's code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.auth-tab { background-color: red; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt; &lt;div class="container-fluid"&gt; &lt;div class="row justify-content-center align-items-center"&gt; &lt;div class="auth-tab col-xs-12 col-sm-8 col-md-5 col-lg-6 col-xl-6"&gt; sth &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt;</code></pre> </div> </div> </p> <p>What I want is to vertically and horizontally align <code>.auth-tab</code></p>
0debug
Swap two registers using only AND, OR, NOT, XOR? : <p>Consider you have a processor with AND, OR, XOR, NOT and 2 registers X &amp; Y. What is the smartest way to swap the values of the 2 registers?</p>
0debug
While catching exeption why do we use the Exception's subclasses as the o/p clearly gives us the exact exception? : <pre><code>public class Test{ public static void main(String args[]){ try{ int data=25/0; System.out.println(data); } catch( ArithmeticException e) { System.out.println(e); } } } </code></pre> <p>o/p:java.lang.ArithmeticException: / by zero</p> <p>In this code even if I catch the exception using the <strong>ArithmaticException</strong> class or directly the <strong>Exception</strong> class, the o/p is the same. Then why do we use the subclasses in different catch statements instead of directly using <strong>Exception</strong> class everytime?</p>
0debug
How do I use my input from 2 cases in to a 3rd case? All in one switch : So, I have been stuck with this problem for 3 hours now. My google-fu is rubbish so I haven't been able to word out my problem accurately. Scanner in = new Scanner(System.in); int menuSel; do{ System.out.println("1. Adult Tickets"); System.out.println("2. Child Tickets"); System.out.println("3. Finalise Order"); System.out.println("4. Cancel Order"); System.out.println("Please select an option from the list:"); menuSel = in.nextInt(); switch(menuSel){ case 1: System.out.println("Number of tickets:"); int adult = in.nextInt(); double adultTotal=(adult*15.5); System.out.println("Total price for " + adult + " tickets is $" + adultTotal); break; case 2: System.out.println("Number of tickets:"); int child = in.nextInt(); double childTotal=(child*5.75); System.out.println("Total price for " + child + " tickets is $" + childTotal); break; case 3: adult=?; child=?; adultTotal=(adult*15.5); childTotal=(child*5.75); System.out.println("Your order of " + adult + "adult ticket(s) and "+ child + "child ticket(s) amounts to $" +(childTotal+adultTotal)); } In this code I have an issue with case 3. I cannot seem to get the variables 'adult' and 'child' to display properly. I get the "local variable may not be initialized" error. I do not want to declare variables at the main because I am inputting the values in case 1 and 2. I would like case 3 to display what I input in case 1 in case 2 as values. Sorry if this is a stupid question, I have been stuck at this problem for 3 hours and unfortunately I do not know how to progress further.
0debug
How to put conditions in loop statements : <p>This program is to take input from the user and to give output back showing how many numbers were above the average of the array and below it. I'm trying to put a condition on the loops to exit getting input.</p> <pre><code>import java.util.Scanner; public class analyzeScores { public static void count(int[] list) { Scanner input = new Scanner(System.in); for(int i = 0; i &lt; list.length;i++) { if(list[i] != 0) list[i] = input.nextInt(); } } public static void sorts(int[] lists, int average) { int high = 0; int low = 0; for(int i = 0; i &lt; lists.length; i++) { if(lists[i] &gt;= average) { high +=1; } else { low += 1; } } System.out.println("The number of higher then average scores is " + high); System.out.println("The number of lower then average scores is " + low); } public static void main(String[] args) { int[] list = new int[10]; System.out.println("Enter the scores: "); count(list); int total = 0; for (int i = 0; i &lt; list.length;i++) { total += list[i]; } total = total / list.length; sorts(list, total); } } </code></pre> <p>I'm trying to figure out how to implement a way to input 0 to exit the loop in the count(int[] list) method. I tried to implement if(list[i] != 0) but messes the whole code up</p>
0debug
How can we convert 2014-06-02 04:23:16 UTC to usual excel date time format? : <p>I am trying to convert the UTC time stamp format to usual Excel Date time format. Kindly suggest</p>
0debug
void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp) { CharDriverState *chr; chr = qemu_chr_new("qtest", qtest_chrdev, NULL); if (chr == NULL) { error_setg(errp, "Failed to initialize device for qtest: \"%s\"", qtest_chrdev); return; } qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr); qemu_chr_fe_set_echo(chr, true); inbuf = g_string_new(""); if (qtest_log) { if (strcmp(qtest_log, "none") != 0) { qtest_log_fp = fopen(qtest_log, "w+"); } } else { qtest_log_fp = stderr; } qtest_chr = chr; }
1threat
Selenium Java: Detecting if a file has been generated and moving a file from one directory to another : For Selenium with Java, I have a test case scenario that involves many steps amongst which: A- Checking whether a certain file has been generated in a certain directory. B- moving this file from this directory to another specific directory. How can A & B be implemented ?
0debug
Method reference - invalid method reference - cannot be reference from static context : <p>I have following piece of code </p> <pre><code>StringJoiner joiner = new StringJoiner(", "); joiner.add("Something"); Function&lt;StringJoiner,Integer&gt; lengthFunc = StringJoiner::length; Function&lt;CharSequence,StringJoiner&gt; addFunc = StringJoiner::add; </code></pre> <p>Last line cause an error </p> <pre><code>Error:(54, 53) java: invalid method reference non-static method add(java.lang.CharSequence) cannot be referenced from a static context </code></pre> <p>I understand that this method can't be used in static way and I should have something like :</p> <pre><code>Function&lt;CharSequence,StringJoiner&gt; addFunc = joiner::add; </code></pre> <p>instead. However I can't understand why third line, with <code>StringJoiner::length;</code> is for java compiler perfectly correct. Can someboedy explain me why is that ?</p>
0debug
setup_requires with Cython? : <p>I'm creating a <code>setup.py</code> file for a project with some Cython extension modules.</p> <p>I've already gotten this to work:</p> <pre><code>from setuptools import setup, Extension from Cython.Build import cythonize setup( name=..., ..., ext_modules=cythonize([ ... ]), ) </code></pre> <p>This installs fine. However, this assumes Cython is installed. What if it's not installed? I understand this is what the <code>setup_requires</code> parameter is for:</p> <pre><code>from setuptools import setup, Extension from Cython.Build import cythonize setup( name=..., ..., setup_requires=['Cython'], ..., ext_modules=cythonize([ ... ]), ) </code></pre> <p>However, if Cython isn't already installed, this will of course fail:</p> <pre><code>$ python setup.py install Traceback (most recent call last): File "setup.py", line 2, in &lt;module&gt; from Cython.Build import cythonize ImportError: No module named Cython.Build </code></pre> <p>What's the proper way to do this? I need to somehow import <code>Cython</code> only after the <code>setup_requires</code> step runs, but I need <code>Cython</code> in order to specify the <code>ext_modules</code> values.</p>
0debug