problem
stringlengths
26
131k
labels
class label
2 classes
Python Pandas update a dataframe value from another dataframe : <p>I have two dataframes in python. I want to update rows in first dataframe using matching values from another dataframe. Second dataframe serves as an override. </p> <p>Here is an example with same data and code: </p> <p>DataFrame 1 : </p> <p><a href="https://i.stack.imgur.com/QPJs2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QPJs2.png" alt="enter image description here"></a></p> <p>DataFrame 2: </p> <p><a href="https://i.stack.imgur.com/Xbpmh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Xbpmh.png" alt="enter image description here"></a></p> <p>I want to update update dataframe 1 based on matching code and name. In this example Dataframe 1 should be updated as below: </p> <p><a href="https://i.stack.imgur.com/JA3Fl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JA3Fl.png" alt="enter image description here"></a></p> <p>Note : Row with Code =2 and Name= Company2 is updated with value 1000 (coming from Dataframe 2) </p> <pre><code>import pandas as pd data1 = { 'Code': [1, 2, 3], 'Name': ['Company1', 'Company2', 'Company3'], 'Value': [200, 300, 400], } df1 = pd.DataFrame(data1, columns= ['Code','Name','Value']) data2 = { 'Code': [2], 'Name': ['Company2'], 'Value': [1000], } df2 = pd.DataFrame(data2, columns= ['Code','Name','Value']) </code></pre> <p>Any pointers or hints? </p>
0debug
Angular2 child property change not firing update on bound property : <p>I have a simple custom directive with an input, that I'm binding to in my component. But for whatever reason, the ngOnchanges() method doesn't fire when changing a child property of the input property.</p> <p>my.component.ts</p> <pre><code>import {Component} from 'angular2/core'; import {MyDirective} from './my.directive'; @Component({ directives: [MyDirective], selector: 'my-component', templateUrl: 'Template.html' }) export class MyComponent { test: { one: string; } = { one: "1" } constructor( ) { this.test.one = "2"; } clicked() { console.log("clicked"); var test2: { one: string; } = { one :"3" }; this.test = test2; // THIS WORKS - because I'm changing the entire object this.test.one = "4"; //THIS DOES NOT WORK - ngOnChanges is NOT fired= } } </code></pre> <p>my.directive.ts</p> <pre><code>import {Directive, Input} from 'angular2/core'; import {OnChanges} from 'angular2/core'; @Directive({ selector: '[my-directive]', inputs: ['test'] }) export class MyDirective implements OnChanges { test: { one: string; } = { one: "" } constructor() { } ngOnChanges(value) { console.log(value); } } </code></pre> <p>template.html</p> <pre><code>&lt;div (click)="clicked()"&gt; Click to change &lt;/div&gt; &lt;div my-directive [(test)]="test"&gt; </code></pre> <p>Can anyone tell me why?</p>
0debug
how can we run protractor specs in firefox? : how we run protractor on fire fox for automation ? is it possible then mention version of fire fox,selenium,nodejs .i try yhis code capabilities: { 'browserName': 'firefox' // or 'safari' },
0debug
static int pci_piix4_ide_initfn(PCIDevice *dev) { PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev); pci_config_set_vendor_id(d->dev.config, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(d->dev.config, PCI_DEVICE_ID_INTEL_82371AB); return pci_piix_ide_initfn(d); }
1threat
React JS Error: Invalid attempt to destructure non-iterable instance : <p>I have a sort filter that takes an array to populate the options. Trying to see the option <code>value</code> equal to the text within the array but I get the error within the title: </p> <pre><code>Invalid attempt to destructure non-iterable instance </code></pre> <p>I need to pass the text as the value within the option tag so that when the user updates the filter, the correct text displays to the choice the user made.</p> <p>Here is my code: </p> <pre><code>function Sorting({by, order, rp}: SortingProps) { const opts = [ ['Price (low)', 'price', 'asc'], ['Price (high)', 'price', 'desc'], ['Discount (low)', 'discount', 'asc'], ['Discount (high)', 'discount', 'desc'], ['Most popular', 'arrival', 'latest'], ['Most recent', 'arrival', 'latest'], ]; const onChange = (i) =&gt; { const [text, by, order] = opts[i]; refresh({so: {[by]: order}}); /* GA TRACKING */ ga('send', 'event', 'My Shop Sort By', text, 'Used'); }; return ( &lt;div className={cn(shop.sorting, rp.sorting.fill &amp;&amp; shop.sortingFill)}&gt; &lt;Select className={shop.sortingSelect} label="Sort By" onChange={onChange} value={`${by}:${order}`}&gt; {opts.map(([text], i) =&gt; &lt;Option key={i} value={text}&gt;{text}&lt;/Option&gt; )} &lt;/Select&gt; &lt;/div&gt; ) } </code></pre>
0debug
Do I need to escape dash character in regex? : <p>I'm trying to understand dash character <code>-</code> needs to escape using backslash in regex?</p> <p>Consider this:</p> <pre><code>var url = '/user/1234-username'; var pattern = /\/(\d+)\-/; var match = pattern.exec(url); var id = match[1]; // 1234 </code></pre> <p>As you see in the above regex, I'm trying to extract the number of id from the url. Also I escaped <code>-</code> character in my regex using backslash <code>\</code>. But when I remove that backslash, still all fine ....! In other word, both of these are fine:</p> <ul> <li><a href="https://regex101.com/r/sJ5mX4/1" rel="noreferrer"><code>/\/(\d+)\-/</code></a></li> <li><a href="https://regex101.com/r/sJ5mX4/2" rel="noreferrer"><code>/\/(\d+)-/</code></a></li> </ul> <p>Now I want to know, which one is correct <em>(standard)</em>? Do I need to escape dash character in regex? </p>
0debug
Picking a city and display content : <p>am new to web development i have developed one website and now i want to place a text field on top corner and give options to pick a city and display content based on selected city. for example: in a web page i should have a text box, if i enter some city name it should display tat cities contents (use case: if i select Delhi it should display Delhi's content, if i select Mumbai it should display Mumbai's content how can i achieve this task ) any code, any references can be appreciated, Thanks in advance. (HTML, javascript, java anything is ok)</p>
0debug
Skimage: how to show image : <p>I am novice at skimage and I try to show the image in my ipython notebook:\</p> <pre><code>from skimage import data, io coins = data.coins() io.imshow(coins) </code></pre> <p>But I see only the following string:</p> <pre><code>&lt;matplotlib.image.AxesImage at 0x7f8c9c0cc6d8&gt; </code></pre> <p>Can anyboby explain how to show image right under the code like here: <a href="http://i.stack.imgur.com/yvE9y.png" rel="noreferrer">Correct output</a></p>
0debug
filter syntax where some items may or may not be selected : <p>I've got 3 dropdown boxes on my asp.net form: Country, State and City. I want to use these to filter my data. However, I also want the user to have the ability to not use the filters, or not use <em>all</em> the filters.</p> <p>For instance, they may not want to filter at all. Or they may only want to filter by Country. Or only by Country/State. Or, if it's not the US, then by Country/City.</p> <p>I'm stuck on how to write this. Right now I have:</p> <pre><code> SqlDataAdapter adapter = new SqlDataAdapter("Select * from [MOS_Role] where [Country_ID] = @CoID AND [State_ID] = @StID AND [City_ID] = @CiID ORDER BY [Role] ASC", con2); adapter.SelectCommand.Parameters.AddWithValue("@CoID", Convert.ToInt32(ddlCountry.SelectedValue)); adapter.SelectCommand.Parameters.AddWithValue("@StID", Convert.ToInt32(ddlState.SelectedValue)); adapter.SelectCommand.Parameters.AddWithValue("@CiID", Convert.ToInt32(ddlCity.SelectedValue)); </code></pre> <p>but that doesn't work when you leave a dropdown unselected.</p>
0debug
How to you write this s = ( (n % 2 ) == 0 ? "0" : "1") +s; as an if-else statement? : <p>I have this method in java:</p> <pre><code>public static string intToBinary(int n) { string s = ""; while (n &gt; 0) { s = ( (n % 2 ) == 0 ? "0" : "1") +s; n = n / 2; } return s; } </code></pre> <p>I'd like to write it without the question mark. I tried this: </p> <pre><code>public static String intToBinary(int n) { String s = ""; while (n &gt; 0){ if ((n%2)==0) { s = "0"; } else { s = "1"; } s += s; n = n / 2; } return s; } </code></pre> <p>Doesn't seem to work though. Does anyone know why? </p> <p>Insight would be much appreciated. </p>
0debug
static void test_submit_co(void) { WorkerTestData data; Coroutine *co = qemu_coroutine_create(co_test_cb); qemu_coroutine_enter(co, &data); g_assert_cmpint(active, ==, 1); g_assert_cmpint(data.ret, ==, -EINPROGRESS); qemu_aio_wait_all(); g_assert_cmpint(active, ==, 0); g_assert_cmpint(data.ret, ==, 0); }
1threat
how to find if a record has roman numerals in SQL Server? : <p>I want to detect records from a table (SQL Server) if it has roman numerals.</p> <p>Table has data as follows:</p> <pre><code> Column A | Column B ----------------------------- 1 | AMC I XYZAQS 2 | ABC IV 2 XYZQWS 3 | ANR XVI ANCVP 4 | SWD POL 2# </code></pre> <p>So, the result will be the first 3 records</p>
0debug
How to re-write `while(true)` in Java Stream API : <p>Can this Java code be re-written by Stream API?</p> <pre class="lang-java prettyprint-override"><code>while (true) { ... if (isTrue()) break; } private boolean isTrue() { ... </code></pre>
0debug
Why is my SQL PHP Code not working? : <p>My PHP code is not working.</p> <pre><code>&lt;?php include config.php; function addEntryInDB() { $nxtaddr = $_POST ["txin_src"]; $nxtkey = $_POST ["txin_key"]; $coinaddr = $_POST ["txout_src"]; $burntxid = $_POST ["txid"]; $coinkey = $_POST ["txout_src"]; mysql_select_db($sql_db, $conn); if(!$conn ) { die('Could not connect: ' . mysql_error()); } $sql = ("INSERT INTO X ( NXTAddress, NXTPubKey, AltCoinAddr, AltCoinKeys, PoBTXID, ContactDateCreated ) VALUES ( '$nxtaddr', '$nxtkey', '$coinaddr', '$coinkey', '$burntxid', NOW() )") mysql_query($sql, $conn); mysql_close($conn); } </code></pre> <p>I am mostly getting unexpected T_STRING related errors. I know it screams amateur hour but any help would be umm... helpful </p>
0debug
i want to extract a sub string from a string in oracle sql : fnd YGY LOOKUP_TYPE = 'welcome' HELO HIASDH LOOKUP_TYPE = 'home' hello how are you? Above is the string and i want output as welcome home
0debug
Why cant we use .append with string object in java? : import java.lang.StringBuffer.*; import java.io.*; class chk { public static void main() { System.out.print('\u000c'); String k="catering"; * String l=k.append(5); (shows error here) System.out.println(l); } } i cant understand why it is showing an error?? is it that we cant access methods from other class(ex.Stringbuffer class) from string class?? plz help!!
0debug
Why can't I declare a thread in an if in C++? Is there a way around? : <p>I am trying to use threading in an if statement. </p> <p>The following code gives an error saying t1 in t1.join is not declared in this scope. Is there a way to make the loop skip the first thread operation and start multithreading for the other passes?</p> <pre><code> #include &lt;thread&gt; void someFunction() {/*someTask*/} void main() { bool isFirstRun = true; while(true){ if(isFirstRun==false){std::thread t1(someFunction);} //some long task if(isFirstRun==false){t1.join} if(isFirstRun){isFirstRun = false;} } } </code></pre> <p>More generally, is there a way to create a thread like a global variable in C++ and control its execution anywhere in the code? I saw the following in java and thought this might solve my problem if implemented in C++:</p> <pre><code>Thread t1 = new Thread(new EventThread("e1")); //some tasks here t1.start(); //some tasks here t1.join(); </code></pre>
0debug
cant able to get length of string array : I am getting output in string format then I split it and want to do further processing, here is my code snippet, if(str != null && !str.isEmpty()){ String[] splitLine = str.split("~"); String splitData[]; int i=0; for( i=0;i<splitLine.length;i++){ splitData = splitLine[i].split("#"); if(Long.parseLong(splitData[0]) == oid) isParent = true; break; } } But problem is that I am unable to get length of **splitLine String array** and also eclipse show warning as a **dead code** for i++ inside for loop, I am cant able to understand why this happen does anybody have idea about it.
0debug
Python subprocess .check_call vs .check_output : <p>My python script (python 3.4.3) calls a bash script via subprocess:</p> <pre><code>import subprocess as sp res = sp.check_output("bashscript", shell=True) </code></pre> <p>The <strong>bashscript</strong> contains the following line:</p> <pre><code>ssh -MNf somehost </code></pre> <p>which opens a shared master connection to some remote host to allow some subsequent operations.</p> <p>When executing the python script, it will prompt for password for the <code>ssh</code> line but then it blocks after the password is entered and never returns. When I ctrl-C to terminate the script, I see that the connection was properly established (so <code>ssh</code> line was successfully executed).</p> <p>I don't have this blocking problem when using <code>check_call</code> instead of <code>check_output</code>, but <code>check_call</code> does not retrieve stdout. I'd like to understand what exactly is causing the blocking behavior for <code>check_output</code>, probably related to some subtlety with <code>ssh -MNf</code>.</p>
0debug
Why does this implicit cast not result in compile-time error? : <p>Just trying to understand C#. Just considering the following simplified example.</p> <pre><code>void Main() { IList&lt;IAnimal&gt; animals = new List&lt;IAnimal&gt; { new Chicken(), new Cow(), }; // Shouldn't this line result in a compile-time error? foreach (Chicken element in animals) { } } public interface IAnimal { } public class Cow : IAnimal { } public class Chicken : IAnimal { } </code></pre> <p>Although the first iteration succeeds, the second does not. Honestly I expected this to fail on compile time. Does anyone understand why it only fails at runtime?</p>
0debug
Correct way to change a list of strings to list of ints : <pre><code>dict = {0: ['2', '6'], 1: ['2'], 2: ['3']} print("Original: ") print(dict) for key,vals in dict.items(): vals = [int(s) for s in vals] print("New: ") print(dict) </code></pre> <p>Output:</p> <pre><code>Original: {0: ['2', '6'], 1: ['2'], 2: ['3']} New: {0: ['2', '6'], 1: ['2'], 2: ['3']} </code></pre> <p>I can't figure why the list of values is not changing, I have tried the map() function and it also does not work, any reason why?</p>
0debug
document.write('<script src="evil.js"></script>');
1threat
how to set string b to equal a when a has spaces in it c : <p>I have a string called that can continue a value with spaces for it as an example</p> <pre><code>char *a="this is a test" </code></pre> <p>I want to declare another string</p> <pre><code>char *b=NULL; </code></pre> <p>so I can then assign the value of a to b such as </p> <pre><code>b=a; </code></pre> <p>however currently b will only hold any characters up to the first space (in this example b= "this"). How do I get it to hold the entire string </p>
0debug
Covert columns of a dataframes to list : I have a data.frame NOAA_OLR_TEST NOAA_OLR_TEST <- structure(list(DATE_START = structure(c(1170720000, 1170806400,1170892800, 1170979200, 1171065600, 1171152000, 1171238400, 1171324800,1171411200, 1171497600), class = c("POSIXct", "POSIXt")), DATE_END = structure(c(1171065600,1171152000, 1171238400, 1171324800, 1171411200, 1171497600, 1171584000,1171670400, 1171756800, 1171843200), class = c("POSIXct", "POSIXt")), LONGITUDE = c(-89.5, -89.5, -89.5, -89.5, -89.5, -88.5, -88.5,-88.5, -88.5, -88.5), LATITUDE = c(-179.5, -179.5, -179.5, -179.5,-179.5, -179.5, -179.5, -179.5, -179.5, -179.5), OLR_DATA_1 = c(150,146, 146, 142, NA, 150, 158, 155, 143, 142), OLR_DATA_2 = c(146,146, 142, 141, 150, NA, 155, 143, 142, 138), OLR_DATA_3 = c(146,NA, 141, 150, 158, 155, 143, 142, 138, 135), OLR_DATA_4 = c(142,141, 150, 158, 155, 143, 142, 138, 135, NA), OLR_DATA_5 = c(141,150, NA, 155, 143, 142, 138, 135, 140, 139)), .Names = c("DATE_START","DATE_END", "LONGITUDE", "LATITUDE", "OLR_DATA_1", "OLR_DATA_2","OLR_DATA_3", "OLR_DATA_4", "OLR_DATA_5"), row.names = c(NA,10L), class = "data.frame") I wan to covert No.5 to No.9 columns of the dataframes NOAA_OLR_TEST[5:9] to a list xy.list <- as.list(as.data.frame(t(NOAA_OLR_TEST[5:9]))) How can I combine NOAA_OLR_TEST[1:4] and xy.list? I use mapply,Map,cbind, all of them have some erros. or there have simply method to covert columns of a dataframes to list thanks
0debug
e1000e_io_read(void *opaque, hwaddr addr, unsigned size) { E1000EState *s = opaque; uint32_t idx; uint64_t val; switch (addr) { case E1000_IOADDR: trace_e1000e_io_read_addr(s->ioaddr); return s->ioaddr; case E1000_IODATA: if (e1000e_io_get_reg_index(s, &idx)) { val = e1000e_core_read(&s->core, idx, sizeof(val)); trace_e1000e_io_read_data(idx, val); return val; } return 0; default: trace_e1000e_wrn_io_read_unknown(addr); return 0; } }
1threat
IntelliJ Optimize Imports for the entire scala project : <p>One of the very useful features of IntelliJ is that when I am done editing a file, I can do a "optimize imports". this removes all the unused imports from my code.</p> <p>This is very useful, but I have to do it for every file.</p> <p>Can I do "optimize imports" for the entire project?</p>
0debug
How to use slugify in Python 3? : <p>I'm trying to use <a href="https://github.com/un33k/python-slugify" rel="noreferrer">slugify</a>, which I installed using <code>pip3 install slugify</code>. However, in the interpreter, if I try to slugify the string <code>'hello'</code> I see the following:</p> <pre><code>Python 3.5.2 (default, Nov 17 2016, 17:05:23) Type "copyright", "credits" or "license" for more information. IPython 5.1.0 -- An enhanced Interactive Python. ? -&gt; Introduction and overview of IPython's features. %quickref -&gt; Quick reference. help -&gt; Python's own help system. object? -&gt; Details about 'object', use 'object??' for extra details. In [1]: from slugify import slugify In [2]: slugify('hello') --------------------------------------------------------------------------- NameError Traceback (most recent call last) &lt;ipython-input-2-a58110f37579&gt; in &lt;module&gt;() ----&gt; 1 slugify('hello') /usr/local/lib/python3.5/dist-packages/slugify.py in slugify(string) 22 23 return re.sub(r'[-\s]+', '-', ---&gt; 24 unicode( 25 re.sub(r'[^\w\s-]', '', 26 unicodedata.normalize('NFKD', string) NameError: name 'unicode' is not defined In [3]: slugify(u'hello') --------------------------------------------------------------------------- NameError Traceback (most recent call last) &lt;ipython-input-3-acc9f7b8d41e&gt; in &lt;module&gt;() ----&gt; 1 slugify(u'hello') /usr/local/lib/python3.5/dist-packages/slugify.py in slugify(string) 22 23 return re.sub(r'[-\s]+', '-', ---&gt; 24 unicode( 25 re.sub(r'[^\w\s-]', '', 26 unicodedata.normalize('NFKD', string) NameError: name 'unicode' is not defined </code></pre> <p>By contrast, in Python 2 the latter does work:</p> <pre><code>Python 2.7.12 (default, Nov 19 2016, 06:48:10) Type "copyright", "credits" or "license" for more information. IPython 2.4.1 -- An enhanced Interactive Python. ? -&gt; Introduction and overview of IPython's features. %quickref -&gt; Quick reference. help -&gt; Python's own help system. object? -&gt; Details about 'object', use 'object??' for extra details. In [1]: from slugify import slugify In [2]: slugify(u'hello') Out[2]: u'hello' </code></pre> <p>How can I get this to work in Python 3?</p>
0debug
static void fw_cfg_comb_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { switch (size) { case 1: fw_cfg_write(opaque, (uint8_t)value); break; case 2: fw_cfg_select(opaque, (uint16_t)value); break; } }
1threat
static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream) { struct ogg *ogg = s->priv_data; int idx = ogg->nstreams++; AVStream *st; struct ogg_stream *os; ogg->streams = av_realloc (ogg->streams, ogg->nstreams * sizeof (*ogg->streams)); memset (ogg->streams + idx, 0, sizeof (*ogg->streams)); os = ogg->streams + idx; os->serial = serial; os->bufsize = DECODER_BUFFER_SIZE; os->buf = av_malloc(os->bufsize); os->header = -1; if (new_avstream) { st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->id = idx; avpriv_set_pts_info(st, 64, 1, 1000000); } return idx; }
1threat
cakephp - Controller::invokeAction taking lot of time : <p>I am working on cakephp 2.x. I found in the transaction trace summary of New Relic, that there are some APIs which are taking a lot of time(almost 20-30 sec) to execute out of which almost 90% of the time is spent in the Controller::invokeAction method.</p> <p>Can somebody explain why so much time is spent on invokeAction method.</p>
0debug
django media url tag : <p>Does django have <code>media</code> tag similar to <code>static</code> and <code>url</code> and how to setup it?</p> <pre><code>{% static 'styles/boo.css' %} {% url 'some_app:some_name' %} Is this possible: {% media 'what here' %}? </code></pre> <p>How to setup it?</p>
0debug
Why can a python generator only be used once? : <p>Once I use a generator once, it can't be used again. Why is this?</p> <p>Consider the following code:</p> <pre><code>def generator(n): a = 1 for _ in range(n): yield a a += 1 def run_generator(generator): for a in generator: print(a, end = " ") </code></pre> <p>If I were to execute this:</p> <pre><code>count_generator = generator(10) run_generator(count_generator) run_generator(count_generator) </code></pre> <p>It would only print: </p> <pre><code>1 2 3 4 5 6 7 8 9 10 </code></pre> <p>Basically, the generator just dies after a single execution.</p> <p>I know that the fact that a generator can only be used once is something built into Python, but why is it like this? Is there a specific reason to only allowing a generator object to be executed once?</p>
0debug
Django: How to rollback (@transaction.atomic) without raising exception? : <p>I'm using Django's command to perform some tasks involving database manipulation:</p> <pre><code>class SomeCommand(BaseCommand): @transaction.atomic def handle(self, *args, **options): # Some stuff on the database </code></pre> <p>If an exception is thrown during execution of my program, <code>@transaction.atomic</code> guarantees rollback. Can I force this behavior without throwing exception? Something like:</p> <pre><code># Doing some stuff, changing objects if some_condition: # ABANDON ALL CHANGES AND RETURN </code></pre>
0debug
Free pascal exit code 201 : <p><a href="https://i.stack.imgur.com/VSzBL.png" rel="nofollow noreferrer">my code</a></p> <p>I'm trying to make a program to generate amicable numbers under 10000, but after i pressed ctrl+f9, it exited with exit code 201. How do i fix that?</p>
0debug
static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AVSContext *h = avctx->priv_data; MpegEncContext *s = &h->s; int input_size; const uint8_t *buf_end; const uint8_t *buf_ptr; AVFrame *picture = data; uint32_t stc = -1; s->avctx = avctx; if (buf_size == 0) { if (!s->low_delay && h->DPB[0].f.data[0]) { *data_size = sizeof(AVPicture); *picture = *(AVFrame *) &h->DPB[0]; } return 0; } buf_ptr = buf; buf_end = buf + buf_size; for(;;) { buf_ptr = ff_find_start_code(buf_ptr,buf_end, &stc); if(stc & 0xFFFFFE00) return FFMAX(0, buf_ptr - buf - s->parse_context.last_index); input_size = (buf_end - buf_ptr)*8; switch(stc) { case CAVS_START_CODE: init_get_bits(&s->gb, buf_ptr, input_size); decode_seq_header(h); break; case PIC_I_START_CODE: if(!h->got_keyframe) { if(h->DPB[0].f.data[0]) avctx->release_buffer(avctx, (AVFrame *)&h->DPB[0]); if(h->DPB[1].f.data[0]) avctx->release_buffer(avctx, (AVFrame *)&h->DPB[1]); h->got_keyframe = 1; } case PIC_PB_START_CODE: *data_size = 0; if(!h->got_keyframe) break; init_get_bits(&s->gb, buf_ptr, input_size); h->stc = stc; if(decode_pic(h)) break; *data_size = sizeof(AVPicture); if(h->pic_type != AV_PICTURE_TYPE_B) { if(h->DPB[1].f.data[0]) { *picture = *(AVFrame *) &h->DPB[1]; } else { *data_size = 0; } } else *picture = *(AVFrame *) &h->picture; break; case EXT_START_CODE: break; case USER_START_CODE: break; default: if (stc <= SLICE_MAX_START_CODE) { init_get_bits(&s->gb, buf_ptr, input_size); decode_slice_header(h, &s->gb); } break; } } }
1threat
Does a return statement end a method? : <p>Let's say I have a method, for instance, the one I'm working on is a boolean <em>Empty</em> method, that simply returns false if the list (technically it's a stack using linked lists) is empty, and returns true if it has values. </p> <p>I have an if statement that returns false if the first value of the list is null (considering it's a stack) and returns true if it has values. Here is that method in my code:</p> <pre><code>public boolean empty(){ if(list.getFirst() == null){ return false; } else{ System.out.println("Stack has values."); } return true; } </code></pre> <p>my question is, if I have determined that the list is empty and return false, will the method end there? Or, in other words, does a method stop doing things once it gets a return message?</p>
0debug
Register custom user model with admin auth : <p>In a Django project, I have a custom user model that adds one extra field:</p> <pre><code>class User(AbstractUser): company = models.ForeignKey(Company, null=True, blank=True) </code></pre> <p>This model is defined in my app, say <code>MyApp.models</code>.</p> <p>How can I get the new <code>User</code> model to show up under "Authentication and Authorization" as the original <code>django.contrib.auth</code> model? </p> <p><a href="https://i.stack.imgur.com/AZxiV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AZxiV.png" alt="enter image description here"></a></p>
0debug
Shareable Key Value Pair in Android : <p>Good day mates! I am wondering if there are ways to create a shareable key-value pair in Android? What I meant by shareable is that a file that can be viewed in file manager. Any help will be much appreciated. Thank you very much!</p>
0debug
Golang: get a slice of tuples (hour, minute) : I've got a problem that I couldn't resolve. I've got a list of minutes: minutes := int{0, 30} // Minutes are 0 and 30 And a four parameters: `start`, `startBreak`, `stop`, `stopBreak`: start := types.NewTuple(9, 30) // It represents "9:30" startBreak := types.NewTuple(12, 0) // It represents "12:00" stop := types.NewTuple(21, 0) // It represents "21:00" stopBreak := types.NewTuple(14, 30) // It represents "14:30" I want to get a slice of tuples `(hour, minutes)` using all the minutes in the `minutes` slice and they must not be included in the range `startBreak-stopBreak` (it can be equal to `startBreak` or `stopBreak`, so the range will become `12:30, 13:00, 13:30, 14:00`) and `stop-start` (it can be equal to `start` and `stop`, so the range will become `21:30, 22:00, 22:30, ..., 8:30, 9:00`). For example, using those four parameters, the final result will be: 9:30, 10:00, 10:30, 11:00, 11:30, 12:00, 14:30, 15:00, 15:30, 16:00, 16:30, 17:00, 17:30, 18:00, 18:30, 19:00, 19:30, 20:00, 20:30, 21:00 Thank you all!
0debug
int ff_nvdec_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx, int dpb_size) { AVHWFramesContext *frames_ctx = (AVHWFramesContext*)hw_frames_ctx->data; const AVPixFmtDescriptor *sw_desc; int cuvid_codec_type, cuvid_chroma_format; sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt); if (!sw_desc) return AVERROR_BUG; cuvid_codec_type = map_avcodec_id(avctx->codec_id); if (cuvid_codec_type < 0) { av_log(avctx, AV_LOG_ERROR, "Unsupported codec ID\n"); return AVERROR_BUG; } cuvid_chroma_format = map_chroma_format(avctx->sw_pix_fmt); if (cuvid_chroma_format < 0) { av_log(avctx, AV_LOG_VERBOSE, "Unsupported chroma format\n"); return AVERROR(EINVAL); } if (avctx->thread_type & FF_THREAD_FRAME) dpb_size += avctx->thread_count; frames_ctx->format = AV_PIX_FMT_CUDA; frames_ctx->width = avctx->coded_width; frames_ctx->height = avctx->coded_height; frames_ctx->sw_format = sw_desc->comp[0].depth > 8 ? AV_PIX_FMT_P010 : AV_PIX_FMT_NV12; frames_ctx->initial_pool_size = dpb_size; return 0; }
1threat
Twig Syntax Error in Symfony 3 : <blockquote> <p>An exception has been thrown during the compilation of a template ("Bundle "AdescBundles" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file?") in "AdescBundle:Default:index.html.twig"</p> </blockquote>
0debug
void stq_phys(target_phys_addr_t addr, uint64_t val) { val = tswap64(val); cpu_physical_memory_write(addr, &val, 8); }
1threat
static int jp2_find_codestream(Jpeg2000DecoderContext *s) { int32_t atom_size; int found_codestream = 0, search_range = 10; s->buf += 12; while (!found_codestream && search_range) { atom_size = AV_RB32(s->buf); if (AV_RB32(s->buf + 4) == JP2_CODESTREAM) { found_codestream = 1; s->buf += 8; } else { s->buf += atom_size; search_range--; } } if (found_codestream) return 1; return 0; }
1threat
Where to learn Tizen Native Wearable Basics : <p>I'm trying to develop an app for my Galaxy Watch which runs on Tizen. I'm not able to find any wholesome tutorial out there for Tizen. Do you mind recommending me some? </p> <p>Thanks</p>
0debug
Initialize new Hash Table, pointers issue : <p>I have this exercise for homework that follows:</p> <p>Consider the following definition to represent dynamic hashtables with collision treatment chaining.</p> <pre><code>typedef struct entry{ char key[10]; void *info; struct entry *next; } *Entry; typedef struct hashT{ int hashsize; Entry *table; } *HashTable; </code></pre> <p>Define `HashTable newTable(int hashsize) note that the memmory necessary must be allocated and that all table entrys must be initialized with empty list.</p> <p>My proposition is this:</p> <pre><code>HashTable newTable(int hashSize){ Entry *table = malloc(sizeof((struct entry)*hashSize)); HashTable *h = malloc(sizeof(struct hashT)); h-&gt;hashSize = hashSize; h-&gt;table = table; return h; } </code></pre> <p>im pretty sure the logic is correct. my problem is with pointers. for example, sometime I see (char *), or in this case (table *) before the malloc function... Is this necessary?</p> <p>and for the return, should I return h, or *h? and whats the difference?</p> <p>thank you</p>
0debug
How to select an option from dropdown select : <p>I can click the selector but my question is how to select one of the options from the dropdown list? </p> <pre><code> await page.click('#telCountryInput &gt; option:nth-child(4)') </code></pre> <p>Click the option using CSS selector does not work.</p> <p>For example, select a country code from a list like below,</p> <p><a href="https://i.stack.imgur.com/m7eLD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/m7eLD.png" alt="enter image description here"></a></p>
0debug
static int decode_rle(uint8_t *bitmap, int linesize, int w, int h, const uint8_t *buf, int start, int buf_size, int is_8bit) { GetBitContext gb; int bit_len; int x, y, len, color; uint8_t *d; if (start >= buf_size) bit_len = (buf_size - start) * 8; init_get_bits(&gb, buf + start, bit_len); x = 0; y = 0; d = bitmap; for(;;) { if (get_bits_count(&gb) > bit_len) if (is_8bit) len = decode_run_8bit(&gb, &color); else len = decode_run_2bit(&gb, &color); len = FFMIN(len, w - x); memset(d + x, color, len); x += len; if (x >= w) { y++; if (y >= h) break; d += linesize; x = 0; align_get_bits(&gb); } } return 0; }
1threat
I was working on Titanic Dataset from kaggle when I faced a problem in round function : While executing the following command :- percent_2 = (round(percent_1, 1)).sort_values(ascending=False), following error occured :- "{0}".format(str(converter))) TypeError: cannot convert the series to <type 'float'>. What is it happening?
0debug
RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, int base_year) { RTCState *s; int io_memory; s = qemu_mallocz(sizeof(RTCState)); s->irq = irq; s->cmos_data[RTC_REG_A] = 0x26; s->cmos_data[RTC_REG_B] = 0x02; s->cmos_data[RTC_REG_C] = 0x00; s->cmos_data[RTC_REG_D] = 0x80; s->base_year = base_year; rtc_set_date_from_host(s); s->periodic_timer = qemu_new_timer(rtc_clock, rtc_periodic_timer, s); s->second_timer = qemu_new_timer(rtc_clock, rtc_update_second, s); s->second_timer2 = qemu_new_timer(rtc_clock, rtc_update_second2, s); s->next_second_time = qemu_get_clock(rtc_clock) + (get_ticks_per_sec() * 99) / 100; qemu_mod_timer(s->second_timer2, s->next_second_time); io_memory = cpu_register_io_memory(rtc_mm_read, rtc_mm_write, s); cpu_register_physical_memory(base, 2 << it_shift, io_memory); register_savevm("mc146818rtc", base, 1, rtc_save, rtc_load, s); #ifdef TARGET_I386 if (rtc_td_hack) register_savevm("mc146818rtc-td", base, 1, rtc_save_td, rtc_load_td, s); #endif qemu_register_reset(rtc_reset, s); return s; }
1threat
if else operator issue : Please check the code bellow. On first if section however all my conditions get false its not going to else. its always running the if inside codes. to be more details "ViewBag.gtQuickDate" this viewbag not containing any of value as shown bellow also other viewbags not containing the value then why its not running the else if? any mistake you found on operator then let me know. Thanks in advance if (ViewBag.subcattxt != "" & ViewBag.callFrom == "result" & ViewBag.gtQuickDate != "2015y" || ViewBag.gtQuickDate != "2016y" || ViewBag.gtQuickDate != "2017y" || ViewBag.gtQuickDate != "blank") { } else if (ViewBag.subcattxt != "" & ViewBag.callFrom == "result" & ViewBag.gtQuickDate == "2015y" || ViewBag.gtQuickDate == "2016y" || ViewBag.gtQuickDate == "2017y" || ViewBag.gtQuickDate != "blank") { }
0debug
static void smbios_build_type_0_fields(const char *t) { char buf[1024]; unsigned char major, minor; if (get_param_value(buf, sizeof(buf), "vendor", t)) smbios_add_field(0, offsetof(struct smbios_type_0, vendor_str), buf, strlen(buf) + 1); if (get_param_value(buf, sizeof(buf), "version", t)) smbios_add_field(0, offsetof(struct smbios_type_0, bios_version_str), buf, strlen(buf) + 1); if (get_param_value(buf, sizeof(buf), "date", t)) smbios_add_field(0, offsetof(struct smbios_type_0, bios_release_date_str), buf, strlen(buf) + 1); if (get_param_value(buf, sizeof(buf), "release", t)) { sscanf(buf, "%hhu.%hhu", &major, &minor); smbios_add_field(0, offsetof(struct smbios_type_0, system_bios_major_release), &major, 1); smbios_add_field(0, offsetof(struct smbios_type_0, system_bios_minor_release), &minor, 1); } }
1threat
static bool cmd_write_dma(IDEState *s, uint8_t cmd) { bool lba48 = (cmd == WIN_WRITEDMA_EXT); if (!s->bs) { ide_abort_command(s); return true; } ide_cmd_lba48_transform(s, lba48); ide_sector_start_dma(s, IDE_DMA_WRITE); s->media_changed = 1; return false; }
1threat
SQL - Need to transpose the value : Need advise on how to get the output from the below table Weeks Hoursofoperation W 7-7 T 8-6 Th 8-6 Sa 9-1 M 9-6 F 9-6 [enter image description here][1] Need to get the output value as MF 9-6, TTh 8-6, W 7-7, Sa 9-1 [1]: https://i.stack.imgur.com/u14i1.jpg
0debug
void qemu_sem_wait(QemuSemaphore *sem) { #if defined(__APPLE__) || defined(__NetBSD__) pthread_mutex_lock(&sem->lock); --sem->count; while (sem->count < 0) { pthread_cond_wait(&sem->cond, &sem->lock); } pthread_mutex_unlock(&sem->lock); #else int rc; do { rc = sem_wait(&sem->sem); } while (rc == -1 && errno == EINTR); if (rc < 0) { error_exit(errno, __func__); } #endif }
1threat
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { char buf[4096]; if (!mon) return; if (monitor_ctrl_mode(mon)) { return; } vsnprintf(buf, sizeof(buf), fmt, ap); monitor_puts(mon, buf); }
1threat
Don't really understand the $_SESSION variable : I'm trying to create a login form (new to php and coding) and I made it work but I don't exactly understand what I'm doing in my code and would love to understand it. I included notes about what I understand and what I dont understand in my code. 1.Anyways, my main problem is with the "$_SESSION['umsco'] = $username" why do you need to apply the $username variable to it for it to work? 2.I don't really understand the $result thing in general. Thank you to anyone who is willing to help me in advance, it's honestly appreciated. ```php // I include the database file so we can get the information from there and apply it in here as well. include "dbc.php"; // here we select the variables we want from the table 'members'. $sql = "SELECT id, firstName, lastName FROM members"; // here we do something that I dont really know but this is standard procedure. $result = mysqli_query($conn, $sql); // declaring username $username = $_POST["username"]; $password = $_POST["password"]; // my result thing, again, standard procedure. $result = $conn->query($sql); // we insert all values in row, standard procedure. $row = $result->fetch_assoc(); // here we check if the username is the same as the database. if ($username == $row["firstName"]) { // if it's correct then we start a session session_start(); // we give a session some random letters or numbers and set it to $username, not exactly sure why, but it wont work without it. $_SESSION['umsco'] = $username; // we change the location to secrect.php header("location: secret.php"); } // we close the connection, not sure if this is needed, but it seems logical. $conn->close(); ```
0debug
void dump_format(AVFormatContext *ic, int index, const char *url, int is_output) { int i; uint8_t *printed = av_mallocz(ic->nb_streams); if (ic->nb_streams && !printed) return; av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n", is_output ? "Output" : "Input", index, is_output ? ic->oformat->name : ic->iformat->name, is_output ? "to" : "from", url); dump_metadata(NULL, ic->metadata, " "); if (!is_output) { av_log(NULL, AV_LOG_INFO, " Duration: "); if (ic->duration != AV_NOPTS_VALUE) { int hours, mins, secs, us; secs = ic->duration / AV_TIME_BASE; us = ic->duration % AV_TIME_BASE; mins = secs / 60; secs %= 60; hours = mins / 60; mins %= 60; av_log(NULL, AV_LOG_INFO, "%02d:%02d:%02d.%02d", hours, mins, secs, (100 * us) / AV_TIME_BASE); } else { av_log(NULL, AV_LOG_INFO, "N/A"); } if (ic->start_time != AV_NOPTS_VALUE) { int secs, us; av_log(NULL, AV_LOG_INFO, ", start: "); secs = ic->start_time / AV_TIME_BASE; us = ic->start_time % AV_TIME_BASE; av_log(NULL, AV_LOG_INFO, "%d.%06d", secs, (int)av_rescale(us, 1000000, AV_TIME_BASE)); } av_log(NULL, AV_LOG_INFO, ", bitrate: "); if (ic->bit_rate) { av_log(NULL, AV_LOG_INFO,"%d kb/s", ic->bit_rate / 1000); } else { av_log(NULL, AV_LOG_INFO, "N/A"); } av_log(NULL, AV_LOG_INFO, "\n"); } for (i = 0; i < ic->nb_chapters; i++) { AVChapter *ch = ic->chapters[i]; av_log(NULL, AV_LOG_INFO, " Chapter #%d.%d: ", index, i); av_log(NULL, AV_LOG_INFO, "start %f, ", ch->start * av_q2d(ch->time_base)); av_log(NULL, AV_LOG_INFO, "end %f\n", ch->end * av_q2d(ch->time_base)); dump_metadata(NULL, ch->metadata, " "); } if(ic->nb_programs) { int j, k, total = 0; for(j=0; j<ic->nb_programs; j++) { AVMetadataTag *name = av_metadata_get(ic->programs[j]->metadata, "name", NULL, 0); av_log(NULL, AV_LOG_INFO, " Program %d %s\n", ic->programs[j]->id, name ? name->value : ""); dump_metadata(NULL, ic->programs[j]->metadata, " "); for(k=0; k<ic->programs[j]->nb_stream_indexes; k++) { dump_stream_format(ic, ic->programs[j]->stream_index[k], index, is_output); printed[ic->programs[j]->stream_index[k]] = 1; } total += ic->programs[j]->nb_stream_indexes; } if (total < ic->nb_streams) av_log(NULL, AV_LOG_INFO, " No Program\n"); } for(i=0;i<ic->nb_streams;i++) if (!printed[i]) dump_stream_format(ic, i, index, is_output); av_free(printed); }
1threat
std::lock_guard or std::scoped_lock? : <p>C++17 introduced a new lock class called <a href="http://en.cppreference.com/w/cpp/thread/scoped_lock/scoped_lock" rel="noreferrer"><code>std::scoped_lock</code></a>. </p> <p>Judging from the documentation it looks similar to the already existing <code>std::lock_guard</code> class.</p> <p>What's the difference and when should I use it?</p>
0debug
static int handle_connection(HTTPContext *c) { int len, ret; switch(c->state) { case HTTPSTATE_WAIT_REQUEST: case RTSPSTATE_WAIT_REQUEST: if ((c->timeout - cur_time) < 0) return -1; if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; if (!(c->poll_entry->revents & POLLIN)) return 0; len = read(c->fd, c->buffer_ptr, 1); if (len < 0) { if (errno != EAGAIN && errno != EINTR) return -1; } else if (len == 0) { return -1; } else { uint8_t *ptr; c->buffer_ptr += len; ptr = c->buffer_ptr; if ((ptr >= c->buffer + 2 && !memcmp(ptr-2, "\n\n", 2)) || (ptr >= c->buffer + 4 && !memcmp(ptr-4, "\r\n\r\n", 4))) { if (c->state == HTTPSTATE_WAIT_REQUEST) { ret = http_parse_request(c); } else { ret = rtsp_parse_request(c); } if (ret < 0) return -1; } else if (ptr >= c->buffer_end) { return -1; } } break; case HTTPSTATE_SEND_HEADER: if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; if (!(c->poll_entry->revents & POLLOUT)) return 0; len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { av_freep(&c->pb_buffer); return -1; } } else { c->buffer_ptr += len; if (c->stream) c->stream->bytes_served += len; c->data_count += len; if (c->buffer_ptr >= c->buffer_end) { av_freep(&c->pb_buffer); if (c->http_error) { return -1; } c->state = HTTPSTATE_SEND_DATA_HEADER; c->buffer_ptr = c->buffer_end = c->buffer; } } break; case HTTPSTATE_SEND_DATA: case HTTPSTATE_SEND_DATA_HEADER: case HTTPSTATE_SEND_DATA_TRAILER: if (!c->is_packetized) { if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; if (!(c->poll_entry->revents & POLLOUT)) return 0; } if (http_send_data(c) < 0) return -1; break; case HTTPSTATE_RECEIVE_DATA: if (c->poll_entry->revents & (POLLERR | POLLHUP)) return -1; if (!(c->poll_entry->revents & POLLIN)) return 0; if (http_receive_data(c) < 0) return -1; break; case HTTPSTATE_WAIT_FEED: if (c->poll_entry->revents & (POLLIN | POLLERR | POLLHUP)) return -1; break; case HTTPSTATE_WAIT: if (compute_send_delay(c) <= 0) c->state = HTTPSTATE_SEND_DATA; break; case HTTPSTATE_WAIT_SHORT: c->state = HTTPSTATE_SEND_DATA; break; case RTSPSTATE_SEND_REPLY: if (c->poll_entry->revents & (POLLERR | POLLHUP)) { av_freep(&c->pb_buffer); return -1; } if (!(c->poll_entry->revents & POLLOUT)) return 0; len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { av_freep(&c->pb_buffer); return -1; } } else { c->buffer_ptr += len; c->data_count += len; if (c->buffer_ptr >= c->buffer_end) { av_freep(&c->pb_buffer); start_wait_request(c, 1); } } break; case HTTPSTATE_READY: break; default: return -1; } return 0; }
1threat
Read for inputs individualy [C] : I want to read inputs individually, that means that I enter a character, press enter and then ask for the second input. The problem is that when the program asks me to input the character it asks for both at the same time. This is my code: #include <stdio.h> int main(){ printf("Enter a character \n"); char a = 0; a = getchar(); printf("You entered: %c \n",a); putchar(a); printf("\n"); char b[2]; puts(b); gets(b); printf("You entered: %c \n",b[0]); puts(b);
0debug
Calling a void method to a static main method : I've been trying to call a void method to my static main method for about two hours now. Here's what I have: public static void main(String[] args){ Scene scene = new Scene(); Animate animate = new animate(); animate(); //I've tried it by itself, but no luck } public void animate(){ sun.slowMoveHorizontal(5000); moon.slowHorizontal(400); } If anyone could help it would be much appreciated. The text says, "Add a call to animate in your main method just below the line that creates the Scene object." If that helps. Maybe I'm just dumb.
0debug
static void uhci_frame_timer(void *opaque) { UHCIState *s = opaque; int64_t expire_time; uint32_t frame_addr, link, old_td_ctrl, val, int_mask; int cnt, ret; UHCI_TD td; UHCI_QH qh; uint32_t old_async_qh; if (!(s->cmd & UHCI_CMD_RS)) { qemu_del_timer(s->frame_timer); s->status |= UHCI_STS_HCHALTED; return; } s->frnum = (s->frnum + 1) & 0x7ff; if (s->pending_int_mask) { s->status2 |= s->pending_int_mask; s->status |= UHCI_STS_USBINT; uhci_update_irq(s); } old_async_qh = s->async_qh; frame_addr = s->fl_base_addr + ((s->frnum & 0x3ff) << 2); cpu_physical_memory_read(frame_addr, (uint8_t *)&link, 4); le32_to_cpus(&link); int_mask = 0; cnt = FRAME_MAX_LOOPS; while ((link & 1) == 0) { if (--cnt == 0) break; if (link & 2) { if (link == s->async_qh) { old_async_qh = 0; break; } cpu_physical_memory_read(link & ~0xf, (uint8_t *)&qh, sizeof(qh)); le32_to_cpus(&qh.link); le32_to_cpus(&qh.el_link); depth_first: if (qh.el_link & 1) { link = qh.link; } else if (qh.el_link & 2) { link = qh.el_link; } else if (s->async_qh) { link = qh.link; } else { if (--cnt == 0) break; cpu_physical_memory_read(qh.el_link & ~0xf, (uint8_t *)&td, sizeof(td)); le32_to_cpus(&td.link); le32_to_cpus(&td.ctrl); le32_to_cpus(&td.token); le32_to_cpus(&td.buffer); old_td_ctrl = td.ctrl; ret = uhci_handle_td(s, &td, &int_mask, 0); if (old_td_ctrl != td.ctrl) { val = cpu_to_le32(td.ctrl); cpu_physical_memory_write((qh.el_link & ~0xf) + 4, (const uint8_t *)&val, sizeof(val)); } if (ret < 0) break; if (ret == 2) { s->async_qh = link; } else if (ret == 0) { qh.el_link = td.link; val = cpu_to_le32(qh.el_link); cpu_physical_memory_write((link & ~0xf) + 4, (const uint8_t *)&val, sizeof(val)); if (qh.el_link & 4) { goto depth_first; } } link = qh.link; } } else { cpu_physical_memory_read(link & ~0xf, (uint8_t *)&td, sizeof(td)); le32_to_cpus(&td.link); le32_to_cpus(&td.ctrl); le32_to_cpus(&td.token); le32_to_cpus(&td.buffer); old_td_ctrl = td.ctrl; ret = uhci_handle_td(s, &td, &int_mask, 0); if (old_td_ctrl != td.ctrl) { val = cpu_to_le32(td.ctrl); cpu_physical_memory_write((link & ~0xf) + 4, (const uint8_t *)&val, sizeof(val)); } if (ret < 0) break; if (ret == 2) { s->async_frame_addr = frame_addr; } link = td.link; } } s->pending_int_mask = int_mask; if (old_async_qh) { #ifdef DEBUG printf("Discarding USB packet\n"); #endif usb_cancel_packet(&s->usb_packet); s->async_qh = 0; } expire_time = qemu_get_clock(vm_clock) + (ticks_per_sec / FRAME_TIMER_FREQ); qemu_mod_timer(s->frame_timer, expire_time); }
1threat
static inline abi_long do_msgsnd(int msqid, abi_long msgp, unsigned int msgsz, int msgflg) { struct target_msgbuf *target_mb; struct msgbuf *host_mb; abi_long ret = 0; if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0)) return -TARGET_EFAULT; host_mb = malloc(msgsz+sizeof(long)); host_mb->mtype = (abi_long) tswapal(target_mb->mtype); memcpy(host_mb->mtext, target_mb->mtext, msgsz); ret = get_errno(msgsnd(msqid, host_mb, msgsz, msgflg)); free(host_mb); unlock_user_struct(target_mb, msgp, 0); return ret; }
1threat
objective c NSArray to NSString : Server side is java: First create a string 'Hello world.' for example, and then use java code to convert this string to be a byte array, then send to ios client. My ios client use NSStream to read the data, and got the array. Now I want to convert this array to be the string 'Hello world'. How to do that? I have tried to convert the array to nsdata and then to nsstring, but it fails. And also I try to convert the array to a string ,but it seems to convert the number in array to be a string number instead of my expected string 'Hello world'.
0debug
mypy "is not valid as a type" for types constructed with type() : <pre><code>Foo = type('Foo', (), {}) Bar = Optional[Foo] </code></pre> <p>mypy complains <code>error: Variable "packagename.Foo" is not valid as a type</code></p> <p>Is there a way around this besides doing</p> <pre><code>Class Foo: pass Bar = Optional[Foo] </code></pre> <p>?</p>
0debug
static void output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost) { int ret = 0; if (ost->nb_bitstream_filters) { int idx; ret = av_bsf_send_packet(ost->bsf_ctx[0], pkt); if (ret < 0) goto finish; idx = 1; while (idx) { ret = av_bsf_receive_packet(ost->bsf_ctx[idx - 1], pkt); if (ret == AVERROR(EAGAIN)) { ret = 0; idx--; continue; } else if (ret < 0) goto finish; if (!(ost->bsf_extradata_updated[idx - 1] & 1)) { ret = avcodec_parameters_copy(ost->st->codecpar, ost->bsf_ctx[idx - 1]->par_out); if (ret < 0) goto finish; ost->bsf_extradata_updated[idx - 1] |= 1; } if (idx < ost->nb_bitstream_filters) { if (!(ost->bsf_extradata_updated[idx] & 2)) { ret = avcodec_parameters_copy(ost->bsf_ctx[idx]->par_out, ost->bsf_ctx[idx - 1]->par_out); if (ret < 0) goto finish; ost->bsf_extradata_updated[idx] |= 2; } ret = av_bsf_send_packet(ost->bsf_ctx[idx], pkt); if (ret < 0) goto finish; idx++; } else write_packet(of, pkt, ost); } } else write_packet(of, pkt, ost); finish: if (ret < 0 && ret != AVERROR_EOF) { av_log(NULL, AV_LOG_ERROR, "Error applying bitstream filters to an output " "packet for stream #%d:%d.\n", ost->file_index, ost->index); if(exit_on_error) exit_program(1); } }
1threat
static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table = qemu_blockalign(bs, s->cluster_size); int ret; int refcount; int i, j; for (i = 0; i < s->l1_size; i++) { uint64_t l1_entry = s->l1_table[i]; uint64_t l2_offset = l1_entry & L1E_OFFSET_MASK; if (!l2_offset) { continue; } refcount = get_refcount(bs, l2_offset >> s->cluster_bits); if (refcount < 0) { continue; } if ((refcount == 1) != ((l1_entry & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "ERROR OFLAG_COPIED L2 cluster: l1_index=%d " "l1_entry=%" PRIx64 " refcount=%d\n", i, l1_entry, refcount); res->corruptions++; } ret = bdrv_pread(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)); if (ret < 0) { fprintf(stderr, "ERROR: Could not read L2 table: %s\n", strerror(-ret)); res->check_errors++; goto fail; } for (j = 0; j < s->l2_size; j++) { uint64_t l2_entry = be64_to_cpu(l2_table[j]); uint64_t data_offset = l2_entry & L2E_OFFSET_MASK; int cluster_type = qcow2_get_cluster_type(l2_entry); if ((cluster_type == QCOW2_CLUSTER_NORMAL) || ((cluster_type == QCOW2_CLUSTER_ZERO) && (data_offset != 0))) { refcount = get_refcount(bs, data_offset >> s->cluster_bits); if (refcount < 0) { continue; } if ((refcount == 1) != ((l2_entry & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "ERROR OFLAG_COPIED data cluster: " "l2_entry=%" PRIx64 " refcount=%d\n", l2_entry, refcount); res->corruptions++; } } } } ret = 0; fail: qemu_vfree(l2_table); return ret; }
1threat
How to target child element in JavaScript : <p>How to target the img element in JavaScript to change img src. </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-html lang-html prettyprint-override"><code>&lt;body&gt; &lt;div class="cover"&gt; &lt;img src="img.jpg" width="60" height="60"&gt; &lt;/div&gt; &lt;/body&gt;</code></pre> </div> </div> </p>
0debug
static inline void gen_op_movo(int d_offset, int s_offset) { tcg_gen_ld_i64(cpu_tmp1_i64, cpu_env, s_offset); tcg_gen_st_i64(cpu_tmp1_i64, cpu_env, d_offset); tcg_gen_ld_i64(cpu_tmp1_i64, cpu_env, s_offset + 8); tcg_gen_st_i64(cpu_tmp1_i64, cpu_env, d_offset + 8); }
1threat
Program type already present: BuildConfig : <p>I'm trying to generate a release build but im not able because of mutidex issues my project has all the multidex enabled and dependencies added </p> <p>The error i'm receiving is :</p> <pre><code>Execution failed for task ':app:transformClassesWithMultidexlistForRelease Caused by: com.android.build.api.transform.TransformException: Error while generating the main dex list. </code></pre> <p>and aslo:</p> <pre><code>Caused by: com.android.tools.r8.errors.CompilationError: Program type already present: com.myapp.BuildConfig </code></pre>
0debug
dma_write(void *opaque, target_phys_addr_t addr, uint64_t val64, unsigned int size) { struct fs_dma_ctrl *ctrl = opaque; uint32_t value = val64; int c; if (size != 4) { dma_winvalid(opaque, addr, value); } c = fs_channel(addr); addr &= 0xff; addr >>= 2; switch (addr) { case RW_DATA: ctrl->channels[c].regs[addr] = value; break; case RW_CFG: ctrl->channels[c].regs[addr] = value; dma_update_state(ctrl, c); break; case RW_CMD: if (value & ~1) printf("Invalid store to ch=%d RW_CMD %x\n", c, value); ctrl->channels[c].regs[addr] = value; channel_continue(ctrl, c); break; case RW_SAVED_DATA: case RW_SAVED_DATA_BUF: case RW_GROUP: case RW_GROUP_DOWN: ctrl->channels[c].regs[addr] = value; break; case RW_ACK_INTR: case RW_INTR_MASK: ctrl->channels[c].regs[addr] = value; channel_update_irq(ctrl, c); if (addr == RW_ACK_INTR) ctrl->channels[c].regs[RW_ACK_INTR] = 0; break; case RW_STREAM_CMD: if (value & ~1023) printf("Invalid store to ch=%d " "RW_STREAMCMD %x\n", c, value); ctrl->channels[c].regs[addr] = value; D(printf("stream_cmd ch=%d\n", c)); channel_stream_cmd(ctrl, c, value); break; default: D(printf ("%s c=%d " TARGET_FMT_plx "\n", __func__, c, addr)); break; } }
1threat
How to call javascript function from <script> tag? : <pre><code>&lt;html&gt; &lt;script&gt; //some largeFunction() //load a script dynamically based on the previous code document.write("&lt;script src='//...'&gt;&lt;\/script&gt;"); &lt;/script&gt; &lt;/html&gt; </code></pre> <p>Question: is it possible to move the <code>largeFunction()</code> out of the static <code>html</code> page and put it into a <code>js</code> file? If yes, how could I then call that function statically before writing the <code>&lt;script&gt;</code> tag?</p>
0debug
Spring Boot Admin: No option to refresh configuration : <p>I am trying to integrate spring-boot-admin with an existing project which is using actuator and spring cloud config server. I am able to change the external property file and send a post request to <strong>/refresh</strong> endpoint from postman. It works fine and I can see updated value in client app. I have disabled all security for actuator endpoints for now to try spring-boot-admin. My problem is that, I can not see any option to change and refresh configuration in spring-boot-admin UI. I have created an issue but there is no update as of now so thought of sharing this problem here. All the details are available here. Does anyone have any idea what I have missed?</p> <p><a href="https://github.com/codecentric/spring-boot-admin/issues/1344" rel="nofollow noreferrer">https://github.com/codecentric/spring-boot-admin/issues/1344</a></p> <p>Before doing a downvote please have a look at the above link. Let me know if need any more details.</p>
0debug
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *ctx, const AVFrame *frame) { void *surface = ff_dxva2_get_surface(frame); unsigned i; for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) if (DXVA_CONTEXT_SURFACE(avctx, ctx, i) == surface) return i; assert(0); return 0; }
1threat
static BlockBackend *bdrv_first_blk(BlockDriverState *bs) { BdrvChild *child; QLIST_FOREACH(child, &bs->parents, next_parent) { if (child->role == &child_root) { assert(bs->blk); return child->opaque; } } assert(!bs->blk); return NULL; }
1threat
Why no Array.prototype.flatMap in javascript? : <p><code>flatMap</code> is incredibly useful on collections, but javascript does not provide one while having <code>Array.prototype.map</code>. Why?</p> <p>Is there any way to emulate <code>flatMap</code> in javascript in both easy and efficient way w/o defining <code>flatMap</code> manually?</p>
0debug
uint64_t helper_cvttq(CPUAlphaState *env, uint64_t a) { return inline_cvttq(env, a, FP_STATUS.float_rounding_mode, 1); }
1threat
SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES) Can You Help Me : I am currently working on a website for H1Z1: King of the Kill. Now, I've been facing an annoying problem for a while... I keep getting this error: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES) And I don't know how to fix it. I have installed mysql, apache2, php and phpmyadmin. Then I've changed a few things in the .htaccess file and changed AllowOverride from none to all (not sure where I did this again). That's all I've done with the server. I read people talking about databases, but I've only got 1 DB. Please help someone, would be really appreciated. If my information is too shitty, make sure to reply. I will respond as fast as possible. Kind regards, NewbieDev.
0debug
static int rv34_decoder_alloc(RV34DecContext *r) { r->intra_types_stride = r->s.mb_width * 4 + 4; r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma)); r->cbp_luma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma)); r->deblock_coefs = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs)); r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist)); r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type)); if (!(r->cbp_chroma && r->cbp_luma && r->deblock_coefs && r->intra_types_hist && r->mb_type)) { rv34_decoder_free(r); return AVERROR(ENOMEM); } r->intra_types = r->intra_types_hist + r->intra_types_stride * 4; return 0; }
1threat
HomeKit - Changing Lightbulb Color Without Transition : <p>I am making an app that uses HomeKit enabled lights for notifications. When I write a new value to the hue characteristic of a lightbulb, the color is transitioned from it's current hue to the hue written. So instead of going from it's currently color (let's say Red) immediately to the written color (let's say Purple) it goes from Red, Pink to Purple as well as all the "in between" colors.</p> <p>How can I <em>immediately</em> change the color of a HomeKit Enabled lightbulb from one color to the next without this transition?</p>
0debug
Chrome dev tools fails to show response even the content returned has header Content-Type:text/html; charset=UTF-8 : <p>Why does my chrome developer tools show "Failed to show response data" in response when the content returned is of type text/html?</p> <p>What is the alternative to see the returned response in developer tools?</p>
0debug
Can you use @ViewChild() or similar with a router-outlet? How if so? : <p>I repeatedly run into a situation where I'd like to access a child component existing on the other side of a router outlet rather than a selector:</p> <pre><code>Like: &lt;router-outlet&gt;&lt;/router-outlet&gt; NOT: &lt;selector-name&gt;&lt;/selector-name&gt; </code></pre> <p>This conflicts with the ViewChild functionality as I know it, yet it seems like my component should be able to see and interact with what's inside that router-outlet just as easily as with what's inside a selector-tag.</p> <p>For instance I tried this:</p> <pre><code>export class RequestItemCatsComp { @ViewChild('child') child: RequestItemsComp; ***etc...*** ngAfterViewInit() { if (this.child) // Always child is undefined this.groupId = this.child.groupId; } } </code></pre> <p>But naturally, <strong>child is undefined</strong> because this is the wrong way. Is there a right way?</p> <p>I'm trying to use a service to share the data but then run into another problem "expression has changed after it was checked" which I'm hoping to remedy without a hack or enabling prod mode.</p>
0debug
Java - how do i set a value every "n" minute : <p>double x = 0;</p> <p>every 20 minutes the x shall add by 5. every 30 minutes the x shall add by 6. every hour the x shall add by 12.</p> <p>and every remaining second shall add by 0.2</p>
0debug
Select/deselect checkbox buttons in Swift 3 : How to know my button selected or not in swift 3 `.selected` property not found. when i type ButtonName.selected not found in Swift 3 (Xcode 8.0) if let button = sender as? UIButton { if button.selected { // set selected button.selected = true } else { // set deselected button.selected = false } }
0debug
Set time but for every day in ruby : I am new to Ruby and I made something to test the time but i dont know how i create a fix time for every day.If i would want to use it i would need to change it every day. Got some tips for me? This is the Code: time1 = Time.new puts time1.strftime("%H:%M:%S") # | # V Change here t = Time.new(2017, 9, 8, 14, 30, 0) dist = ((t - time1) /60 ).round dist1 = dist/60 dist2 = dist while dist2 > 60 dist2 = dist2 -60 end puts "just #{dist1} hours and #{dist2} min left."
0debug
Delete record from database - C# : I'm trying to delete record from data base MSSQL by entering the ID and hit delete btn. i didn't get any error and it give recorded deleted successful but once i check database i see the record doesn't deleted protected void btnDelete_Click(object sender, EventArgs e) { try { if (txtImgID.Text == "") { Response.Write("Enter Image Id To Delete"); } else { SqlCommand cmd = new SqlCommand(); SqlConnection con = new SqlConnection(); //con = new SqlConnection(ConfigurationManager.ConnectionStrings ("GMSConnectionString").ConnectionString); con = new SqlConnection(ConfigurationManager.ConnectionStrings["GMSConnectionString"].ConnectionString); con.Open(); cmd = new SqlCommand("delete from certf where id=" + txtImgID.Text + "", con); lblsubmitt.Text = "Data Deleted Sucessfully"; } } catch (Exception) { lblsubmitt.Text = "You haven't Submited any data"; } } }
0debug
SignInManager.PasswordSignInAsync generate many database access : <p>In my application, I use ASP.NET Identity. Every thing is work fine but by testing, I found that the following command produces many database accesses: SignInManager.PasswordSignInAsync:</p> <pre><code>var result = await SignInManager.PasswordSignInAsync(user.UserName, model.Password, model.RememberMe, shouldLockout: true); </code></pre> <p>I notice this problem when testing the application using performance test. The test shows that the login request needs huge time to get response. The following figure shows result of performance test for the login request: <a href="https://i.stack.imgur.com/Tq05m.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Tq05m.jpg" alt="enter image description here"></a>.</p> <p>Then I use SQL Server Profiler to check what happen when the command SignInManager.PasswordSignInAsync is executed. It shows that a lot of database accesses is generated. The following is taken from SQL Server Profiler:</p> <pre><code>exec sp_executesql N'SELECT TOP (1) [Extent1].[Id] AS [Id], [Extent1].[UserFullName] AS [UserFullName], [Extent1].[UserId] AS [UserId], [Extent1].[Online] AS [Online], [Extent1].[LastOnlineDate] AS [LastOnlineDate], [Extent1].[BrithDate] AS [BrithDate], [Extent1].[Job] AS [Job], [Extent1].[Gender] AS [Gender], [Extent1].[CountryId] AS [CountryId], [Extent1].[LivesIn] AS [LivesIn], [Extent1].[RelationId] AS [RelationId], [Extent1].[Religion] AS [Religion], [Extent1].[FirstSchool] AS [FirstSchool], [Extent1].[SecondSchool] AS [SecondSchool], [Extent1].[University] AS [University], [Extent1].[ContactInfo] AS [ContactInfo], [Extent1].[Email] AS [Email], [Extent1].[EmailConfirmed] AS [EmailConfirmed], [Extent1].[PasswordHash] AS [PasswordHash], [Extent1].[SecurityStamp] AS [SecurityStamp], [Extent1].[PhoneNumber] AS [PhoneNumber], [Extent1].[PhoneNumberConfirmed] AS [PhoneNumberConfirmed], [Extent1].[TwoFactorEnabled] AS [TwoFactorEnabled], [Extent1].[LockoutEndDateUtc] AS [LockoutEndDateUtc], [Extent1].[LockoutEnabled] AS [LockoutEnabled], [Extent1].[AccessFailedCount] AS [AccessFailedCount], [Extent1].[UserName] AS [UserName] FROM [dbo].[AspNetUsers] AS [Extent1] WHERE ((UPPER([Extent1].[UserName])) = (UPPER(@p__linq__0))) OR ((UPPER([Extent1].[UserName]) IS NULL) AND (UPPER(@p__linq__0) IS NULL))',N'@p__linq__0 nvarchar(4000)',@p__linq__0=N'User1@gmail.com' exec sp_executesql N'SELECT [Extent1].[Id] AS [Id], [Extent1].[UserId] AS [UserId], [Extent1].[ClaimType] AS [ClaimType], [Extent1].[ClaimValue] AS [ClaimValue] FROM [dbo].[AspNetUserClaims] AS [Extent1] WHERE [Extent1].[UserId] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT [Extent1].[Id] AS [Id], [Extent1].[UserId] AS [UserId], [Extent1].[ClaimType] AS [ClaimType], [Extent1].[ClaimValue] AS [ClaimValue] FROM [dbo].[AspNetUserClaims] AS [Extent1] WHERE [Extent1].[UserId] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT [Extent1].[LoginProvider] AS [LoginProvider], [Extent1].[ProviderKey] AS [ProviderKey], [Extent1].[UserId] AS [UserId] FROM [dbo].[AspNetUserLogins] AS [Extent1] WHERE [Extent1].[UserId] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT [Extent1].[UserId] AS [UserId], [Extent1].[RoleId] AS [RoleId] FROM [dbo].[AspNetUserRoles] AS [Extent1] WHERE [Extent1].[UserId] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT TOP (1) [Extent1].[Id] AS [Id], [Extent1].[UserFullName] AS [UserFullName], [Extent1].[UserId] AS [UserId], [Extent1].[Online] AS [Online], [Extent1].[LastOnlineDate] AS [LastOnlineDate], [Extent1].[BrithDate] AS [BrithDate], [Extent1].[Job] AS [Job], [Extent1].[Gender] AS [Gender], [Extent1].[CountryId] AS [CountryId], [Extent1].[LivesIn] AS [LivesIn], [Extent1].[RelationId] AS [RelationId], [Extent1].[Religion] AS [Religion], [Extent1].[FirstSchool] AS [FirstSchool], [Extent1].[SecondSchool] AS [SecondSchool], [Extent1].[University] AS [University], [Extent1].[ContactInfo] AS [ContactInfo], [Extent1].[Email] AS [Email], [Extent1].[EmailConfirmed] AS [EmailConfirmed], [Extent1].[PasswordHash] AS [PasswordHash], [Extent1].[SecurityStamp] AS [SecurityStamp], [Extent1].[PhoneNumber] AS [PhoneNumber], [Extent1].[PhoneNumberConfirmed] AS [PhoneNumberConfirmed], [Extent1].[TwoFactorEnabled] AS [TwoFactorEnabled], [Extent1].[LockoutEndDateUtc] AS [LockoutEndDateUtc], [Extent1].[LockoutEnabled] AS [LockoutEnabled], [Extent1].[AccessFailedCount] AS [AccessFailedCount], [Extent1].[UserName] AS [UserName] FROM [dbo].[AspNetUsers] AS [Extent1] WHERE [Extent1].[Id] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT [Extent1].[Id] AS [Id], [Extent1].[UserId] AS [UserId], [Extent1].[ClaimType] AS [ClaimType], [Extent1].[ClaimValue] AS [ClaimValue] FROM [dbo].[AspNetUserClaims] AS [Extent1] WHERE [Extent1].[UserId] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT [Extent1].[LoginProvider] AS [LoginProvider], [Extent1].[ProviderKey] AS [ProviderKey], [Extent1].[UserId] AS [UserId] FROM [dbo].[AspNetUserLogins] AS [Extent1] WHERE [Extent1].[UserId] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT [Extent1].[UserId] AS [UserId], [Extent1].[RoleId] AS [RoleId] FROM [dbo].[AspNetUserRoles] AS [Extent1] WHERE [Extent1].[UserId] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT TOP (1) [Extent1].[Id] AS [Id], [Extent1].[UserFullName] AS [UserFullName], [Extent1].[UserId] AS [UserId], [Extent1].[Online] AS [Online], [Extent1].[LastOnlineDate] AS [LastOnlineDate], [Extent1].[BrithDate] AS [BrithDate], [Extent1].[Job] AS [Job], [Extent1].[Gender] AS [Gender], [Extent1].[CountryId] AS [CountryId], [Extent1].[LivesIn] AS [LivesIn], [Extent1].[RelationId] AS [RelationId], [Extent1].[Religion] AS [Religion], [Extent1].[FirstSchool] AS [FirstSchool], [Extent1].[SecondSchool] AS [SecondSchool], [Extent1].[University] AS [University], [Extent1].[ContactInfo] AS [ContactInfo], [Extent1].[Email] AS [Email], [Extent1].[EmailConfirmed] AS [EmailConfirmed], [Extent1].[PasswordHash] AS [PasswordHash], [Extent1].[SecurityStamp] AS [SecurityStamp], [Extent1].[PhoneNumber] AS [PhoneNumber], [Extent1].[PhoneNumberConfirmed] AS [PhoneNumberConfirmed], [Extent1].[TwoFactorEnabled] AS [TwoFactorEnabled], [Extent1].[LockoutEndDateUtc] AS [LockoutEndDateUtc], [Extent1].[LockoutEnabled] AS [LockoutEnabled], [Extent1].[AccessFailedCount] AS [AccessFailedCount], [Extent1].[UserName] AS [UserName] FROM [dbo].[AspNetUsers] AS [Extent1] WHERE [Extent1].[Id] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT [Extent1].[Id] AS [Id], [Extent1].[UserId] AS [UserId], [Extent1].[ClaimType] AS [ClaimType], [Extent1].[ClaimValue] AS [ClaimValue] FROM [dbo].[AspNetUserClaims] AS [Extent1] WHERE [Extent1].[UserId] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT [Extent1].[LoginProvider] AS [LoginProvider], [Extent1].[ProviderKey] AS [ProviderKey], [Extent1].[UserId] AS [UserId] FROM [dbo].[AspNetUserLogins] AS [Extent1] WHERE [Extent1].[UserId] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT [Extent1].[UserId] AS [UserId], [Extent1].[RoleId] AS [RoleId] FROM [dbo].[AspNetUserRoles] AS [Extent1] WHERE [Extent1].[UserId] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT TOP (1) [Extent1].[Id] AS [Id], [Extent1].[UserFullName] AS [UserFullName], [Extent1].[UserId] AS [UserId], [Extent1].[Online] AS [Online], [Extent1].[LastOnlineDate] AS [LastOnlineDate], [Extent1].[BrithDate] AS [BrithDate], [Extent1].[Job] AS [Job], [Extent1].[Gender] AS [Gender], [Extent1].[CountryId] AS [CountryId], [Extent1].[LivesIn] AS [LivesIn], [Extent1].[RelationId] AS [RelationId], [Extent1].[Religion] AS [Religion], [Extent1].[FirstSchool] AS [FirstSchool], [Extent1].[SecondSchool] AS [SecondSchool], [Extent1].[University] AS [University], [Extent1].[ContactInfo] AS [ContactInfo], [Extent1].[Email] AS [Email], [Extent1].[EmailConfirmed] AS [EmailConfirmed], [Extent1].[PasswordHash] AS [PasswordHash], [Extent1].[SecurityStamp] AS [SecurityStamp], [Extent1].[PhoneNumber] AS [PhoneNumber], [Extent1].[PhoneNumberConfirmed] AS [PhoneNumberConfirmed], [Extent1].[TwoFactorEnabled] AS [TwoFactorEnabled], [Extent1].[LockoutEndDateUtc] AS [LockoutEndDateUtc], [Extent1].[LockoutEnabled] AS [LockoutEnabled], [Extent1].[AccessFailedCount] AS [AccessFailedCount], [Extent1].[UserName] AS [UserName] FROM [dbo].[AspNetUsers] AS [Extent1] WHERE [Extent1].[Id] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 exec sp_executesql N'SELECT [Extent1].[Id] AS [Id], [Extent1].[UserId] AS [UserId], [Extent1].[ClaimType] AS [ClaimType], [Extent1].[ClaimValue] AS [ClaimValue] FROM [dbo].[AspNetUserClaims] AS [Extent1] WHERE [Extent1].[UserId] = @p__linq__0',N'@p__linq__0 int',@p__linq__0=2103 </code></pre> <p>The above queries are just a part of the result. The same queries are executed several times. Is this the normal case or there is a problem ?</p> <p>If it is a problem, how it can be solved.</p>
0debug
using setTimeout on promise chain : <p>Here i am trying to wrap my head around promises.Here on first request i fetch a set of links.and on next request i fetch the content of first link.But i want to make a delay before returning next promise object.So i use setTimeout on it.But it gives me the following JSON error (<strong><code>without setTimeout() it works just fine</code></strong>)</p> <blockquote> <p>SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data</p> </blockquote> <p><strong><em>i would like to know why it fails?</em></strong></p> <pre><code>let globalObj={}; function getLinks(url){ return new Promise(function(resolve,reject){ let http = new XMLHttpRequest(); http.onreadystatechange = function(){ if(http.readyState == 4){ if(http.status == 200){ resolve(http.response); }else{ reject(new Error()); } } } http.open("GET",url,true); http.send(); }); } getLinks('links.txt').then(function(links){ let all_links = (JSON.parse(links)); globalObj=all_links; return getLinks(globalObj["one"]+".txt"); }).then(function(topic){ writeToBody(topic); setTimeout(function(){ return getLinks(globalObj["two"]+".txt"); // without setTimeout it works fine },1000); }); </code></pre>
0debug
C# creating objects in bulk takes lot of time even after using Parllel.Foreach : I am trying to create objects in bulk (> 4000), it takes more than 8 secs. allrows is list<object[]> with 4000 records. ConcurrentBag<data> lstdatas= new ConcurrentBag<data>(); Parallel.ForEach(allRows, (row) => { lstdatas.Add(new data() { Id= row["NB"], ColumnId = row["COLUMN_ID"]], Value= row["VALUE"]], }); }); Please suggest.
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
How to generate a list of numbers which made from n digit? : <p>how many numbers can we generate from n digit? For example: from 1,2,3, we can generate 1,2,3,12,13,21,....321. And how can we generate a list containing those numbers in python?</p>
0debug
How to make Twitter Bootstrap (Bootstap 4 beta) menu dropdown on hover rather than click : How to make Twitter Bootstrap (Bootstap 4 beta) menu dropdown on hover rather than click here is my code PS: I need in an example a hover on a submenu dropdown <!-- Header --> <div> <nav id="mainNavbar" class="navbar navbar-expand-lg navbar-light justify-content-end" > <div class="{{config.containerType}}"> <button class="navbar-toggler navbar-toggler-right btn" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation" (click)="toggleCollapsed()"> <span class="navbar-toggler-icon"></span> </button> <!--Logo--> <a *ngIf="config.logo" routerLink="{{config.logo.routerLink}}" class="navbar-brand"> <img src="{{config.logo.src}}" alt="Image Description" class="img-fluid img-res" > </a> <!--End Logo--> <div id="navbarSupportedContent" [ngClass]="{'collapse': collapsed, 'navbar-collapse': true}"> <ul *ngIf="config.menu.content" class="navbar-nav text-uppercase" > <li *ngFor="let item of config.menu.content" class="menu-item dropdown "> <a > <span dropdown (onShown)="onShown()" (onHidden)="onHidden()" (isOpenChange)="isOpenChange()"> <a *ngIf="item.routerLink" href dropdownToggle (click)="false" [ngStyle]="item.style" routerLink="{{item.routerLink}}" routerLinkActive="menu-item-active ; selectSlider(item)">{{item.name}}</a> <a *ngIf="!item.routerLink" href dropdownToggle (click)="false" [ngStyle]="item.style">{{item.name}}</a> <div *ngIf="item.submenu"> <ul *dropdownMenu class="dropdown-menu"> <li *ngFor="let choice of item.submenu"> <a [ngStyle]="choice.style" class="dropdown-item" routerLink="{{choice.routerLink}}">{{choice.name}}</a> </li> </ul> </div> </span> </a> </li> </ul> </div> </div> </nav> </div> <!-- End Header -->
0debug
static int dshow_read_packet(AVFormatContext *s, AVPacket *pkt) { struct dshow_ctx *ctx = s->priv_data; AVPacketList *pktl = NULL; while (!ctx->eof && !pktl) { WaitForSingleObject(ctx->mutex, INFINITE); pktl = ctx->pktl; if (pktl) { *pkt = pktl->pkt; ctx->pktl = ctx->pktl->next; av_free(pktl); ctx->curbufsize -= pkt->size; } ResetEvent(ctx->event[1]); ReleaseMutex(ctx->mutex); if (!pktl) { if (dshow_check_event_queue(ctx->media_event) < 0) { ctx->eof = 1; } else if (s->flags & AVFMT_FLAG_NONBLOCK) { return AVERROR(EAGAIN); } else { WaitForMultipleObjects(2, ctx->event, 0, INFINITE); } } } return ctx->eof ? AVERROR(EIO) : pkt->size; }
1threat
ajax post is not sending param : Req :in web application using struts/velocity javascript need to pass parameter to a method in java class. I have used ajax post call to servlet. But not able to receive the parameter in action class. javascript function ---------------------- funtion posttoservlet(){ var id=2 var param="Count="+id; var xmlhttp= new XMLHttpRequest(); xmlhttp.open("POST","DataServlet.action",true); xmhttp.setrequestheader('contenttype','plain/text'); xmlhttp.send(param); } struts.xml __________________________ <action name="DataServlet" method="getfromjs" class=com.test.servletpost> </action> servletpost.java ---------------------- public void getfromjs(){ syso(servletactioncontext.getrequest().getparameter("Count")); // This is printing null instead of printing "2". Please advise. } Iam confused why the parameter are not posted properly
0debug
Best way to handle false unused imports in intellij : <p>Intellij falsely marked some import of Scala implicits as not being use. Is there a way to prevent it from deleting those import when optimized them explicitly for a specific import and not prevent optimized import for the entire project ? </p>
0debug
Glide Loader is not Loading Image Properly : I am Using Glide Loader to load my images. my code is working but it changes images continuously.... Here is my Code Glide.with(ctx).load(image).asBitmap() .dontTransform() .placeholder(R.drawable.cart) .into(new SimpleTarget < Bitmap > () { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { photoImageView.setImageBitmap(resource); Glide.with(ctx).`enter code here`load(image).into(post_image); post_image.setImageBitmap(resource); }
0debug
what does VOLUME command do in Dockerfile? : <p>I am having it difficulty in understanding added advantage of VOLUME(<a href="https://docs.docker.com/engine/reference/builder/#volume" rel="noreferrer">https://docs.docker.com/engine/reference/builder/#volume</a>) . </p> <p>In Dockerfile one can have mkdir to create a directory. Once the directory is created we can have handle to it. why specify a VOLUME (mount)and assign to that directory? What advantage VOLUME mount gives? I am trying to understand here without VOLUME what will we miss. </p> <p>to me its looks like a redundant function , however I might be wrong.</p>
0debug
static int vnc_client_io_error(VncState *vs, int ret, int last_errno) { if (ret == 0 || ret == -1) { if (ret == -1) { switch (last_errno) { case EINTR: case EAGAIN: #ifdef _WIN32 case WSAEWOULDBLOCK: #endif return 0; default: break; } } VNC_DEBUG("Closing down client sock %d %d\n", ret, ret < 0 ? last_errno : 0); qemu_set_fd_handler2(vs->csock, NULL, NULL, NULL, NULL); closesocket(vs->csock); qemu_del_timer(vs->timer); qemu_free_timer(vs->timer); if (vs->input.buffer) qemu_free(vs->input.buffer); if (vs->output.buffer) qemu_free(vs->output.buffer); #ifdef CONFIG_VNC_TLS vnc_tls_client_cleanup(vs); #endif audio_del(vs); VncState *p, *parent = NULL; for (p = vs->vd->clients; p != NULL; p = p->next) { if (p == vs) { if (parent) parent->next = p->next; else vs->vd->clients = p->next; break; } parent = p; } if (!vs->vd->clients) dcl->idle = 1; qemu_free(vs->old_data); qemu_free(vs); return 0; } return ret; }
1threat
How to make scatterplots according to specific requirements of color? : <pre><code>colored = c('red','blue','yellow') plot(iris$Petal.length,iris$Petal.Width) </code></pre> <p>I was trying to plot iris$Pedal.width and iris$Pedal.length, and I wanted the color to follow the species of the flowers.(there are 3 species 'setosa','versicolor','Virginia')</p> <p>I create a color vector, and I want all the setosa to be red, all versicolor to be blue and all Virginia to be yellow. how can I use the color vector in plot(iris$Pedal.width,iris$Pedal.length) to achieve this goal?</p>
0debug
ionic 2 error cordova not available : <p>I am trying to use the cordova GooglePlus plugin in a new ionic 2 project (latest ionic2 version) but I always run into errors regarding cordova. The plugin is properly installed and shows up in the plugin folder.</p> <p>One approach I tried is this:</p> <pre><code>import { GooglePlus } from "ionic-native"; </code></pre> <p>and then</p> <pre><code>GooglePlus.login().then(...) </code></pre> <p>The login method executes but always throws an error saying <code>"cordova_not_available"</code></p> <p>I want to test the app with <code>ionic serve</code> on my windows system first before deploying it to my android phone. How can I make cordova available in the localhost server? From searching I understand that cordova.js is generated and always included in the deploy package for the device.</p> <p>Another approach I tried is using</p> <pre><code>window.plugins.googleplus.login(...) </code></pre> <p>But this approach does not go through the typescript compiler who does not know anything about a plugins property on the windows object.</p> <p>How can I fix this?</p>
0debug