problem
stringlengths
26
131k
labels
class label
2 classes
How do I remove 'None' items from the end of a list in Python : <p>A have a list that might contain items that are None. I would like to remove these items, but only if they appear at the end of the list, so:</p> <pre class="lang-py prettyprint-override"><code>[None, "Hello", None, "World", None, None] # Would become: [None, "Hello", None, "World"] </code></pre> <p>I have written a function, but I'm not sure this is the right way to go about it in python?:</p> <pre class="lang-py prettyprint-override"><code>def shrink(lst): # Start from the end of the list. i = len(lst) -1 while i &gt;= 0: if lst[i] is None: # Remove the item if it is None. lst.pop(i) else: # We want to preserve 'None' items in the middle of the list, so stop as soon as we hit something not None. break # Move through the list backwards. i -= 1 </code></pre> <p>Also a list comprehension as an alternative, but this seems inefficient and no more readable?:</p> <pre class="lang-py prettyprint-override"><code>myList = [x for index, x in enumerate(myList) if x is not None or myList[index +1:] != [None] * (len(myList[index +1:]))] </code></pre> <p>What it the pythonic way to remove items that are 'None' from the end of a list?</p>
0debug
Is it possible to duplicate `div` in css? : <p>Is it possible to duplicate <code>div</code> in css? for example I have div look like that:</p> <p><a href="https://i.stack.imgur.com/7Yurh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Yurh.png" alt="enter image description here"></a></p> <p>And I need to duplicate extactly like that without using javascript (for).</p> <p>Somehting like <code>background-repeat</code> just "div-repeat" or something else that make it work.</p>
0debug
how to express that a variable belongs to a set in cplex call by c ++ : I have a sensor node that has neighbors for example C (ij) to represent the set of neighbors of the point (ij) how it is presented with cplex and c ++ in a constraint thank you [enter image description here][1] [1]: https://i.stack.imgur.com/653q4.png
0debug
issue in python code conversion in html file in python : [for and if wasn't colored. it's like normal. The html file wasn't considered as python even i used correct syntax ][1] [1]: https://i.stack.imgur.com/Xo8jc.jpg
0debug
How to represent a variable key name in typescript interface? : <pre><code>interface Items { id: Item, } </code></pre> <p>id is not optional but it will have different name </p> <p>for example:</p> <pre><code>let items = { 34433ded : {name: "foo", price: 0.99}, 14d433dee : {name: "bar", price: 1.99}, } </code></pre>
0debug
Is there a way to include partial using html-webpack-plugin? : <p>I am using Webpack to compile my scripts and HTML (using <code>html-webpack-plugin</code>). The thing is, I have 5 HTML files that contains the same parts and I want to move these parts to separate <code>.html</code> files and then <code>include</code> these parts in every HTML file. This way, if I will change these smaller HTML files, it will recompile every HTML file to represent these changes.</p> <p>Webpack does this for .js files by default, but can I use something like that for HTML files?</p>
0debug
Custom border element with break in top : <p>I am trying to create an element in html and css for a website which has a custom border such that it is exactly like the image shown below. Thereby the element has a border that encompasses all sides with a break in the centre of the top-line and a letter of text centred in this break.</p> <p>Any help would be greatly appreciated.</p> <p><a href="https://i.stack.imgur.com/huJRB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/huJRB.png" alt="Mockup of custom element with break in the top border"></a></p>
0debug
Python: How to run a select amount of code n amount of times where user input is n : newbie to python: I'm having some trouble trying to repeat a certain part of code n times where n is user input. It would start off something like roominput = int(input("How many rooms do you require painting?")) The user would then input with an integer(n) and a select part of the program would repeat n amount of times, asking for the room name, room's dimensions and colour of paint for the wall. This is for a school project, so any help would be much appreciated. Thank you!
0debug
static int delta_decode(uint8_t *dst, const uint8_t *src, int src_size, unsigned val, const int8_t *table) { uint8_t *dst0 = dst; while (src_size--) { uint8_t d = *src++; val = av_clip_uint8(val + table[d & 0xF]); *dst++ = val; val = av_clip_uint8(val + table[d >> 4]); *dst++ = val; } return dst-dst0; }
1threat
static void handle_hint(DisasContext *s, uint32_t insn, unsigned int op1, unsigned int op2, unsigned int crm) { unsigned int selector = crm << 3 | op2; if (op1 != 3) { unallocated_encoding(s); return; } switch (selector) { case 0: return; case 3: s->base.is_jmp = DISAS_WFI; return; case 1: if (!parallel_cpus) { s->base.is_jmp = DISAS_YIELD; } return; case 2: if (!parallel_cpus) { s->base.is_jmp = DISAS_WFE; } return; case 4: case 5: return; default: return; } }
1threat
How to .js file $ajax code defined '$ not defined error''? : <pre><code>var deneme = document.createElement("SCRIPT"); deneme.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"; var nodeajax = document.createTextNode("function deneme() {console.log('dawdawdawd');$.ajax({ type: \"POST\", url: \"http://localhost:54371/checkbox.aspx/Check\", data: '{sayfa: 10 }', contentType: \"application/json; charset=utf-8\", dataType: \"json\", success: function (response) { console.log(response.d); alert('sdf'); }, failure: function (response) { console.log(response); } });}");); deneme.appendChild(nodeajax); document.body.appendChild(deneme); </code></pre> <p>How do I define ajax without using script tag in the .js file?</p> <p>' $ is not defined.' I get an error.</p>
0debug
BlockDriverState *bdrv_new(const char *device_name, Error **errp) { BlockDriverState *bs; int i; if (*device_name && !bdrv_is_valid_name(device_name)) { error_setg(errp, "Invalid device name"); return NULL; } if (bdrv_find(device_name)) { error_setg(errp, "Device with id '%s' already exists", device_name); return NULL; } if (bdrv_find_node(device_name)) { error_setg(errp, "Device name '%s' conflicts with an existing node name", device_name); return NULL; } bs = g_new0(BlockDriverState, 1); QLIST_INIT(&bs->dirty_bitmaps); pstrcpy(bs->device_name, sizeof(bs->device_name), device_name); if (device_name[0] != '\0') { QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list); } for (i = 0; i < BLOCK_OP_TYPE_MAX; i++) { QLIST_INIT(&bs->op_blockers[i]); } bdrv_iostatus_disable(bs); notifier_list_init(&bs->close_notifiers); notifier_with_return_list_init(&bs->before_write_notifiers); qemu_co_queue_init(&bs->throttled_reqs[0]); qemu_co_queue_init(&bs->throttled_reqs[1]); bs->refcnt = 1; bs->aio_context = qemu_get_aio_context(); return bs; }
1threat
static uint64_t hb_regs_read(void *opaque, target_phys_addr_t offset, unsigned size) { uint32_t *regs = opaque; uint32_t value = regs[offset/4]; if ((offset == 0x100) || (offset == 0x108) || (offset == 0x10C)) { value |= 0x30000000; } return value; }
1threat
int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples) { int i, nb_samples1; short *bufin[2]; short *bufout[2]; short *buftmp2[2], *buftmp3[2]; int lenout; if (s->input_channels == s->output_channels && s->ratio == 1.0 && 0) { memcpy(output, input, nb_samples * s->input_channels * sizeof(short)); return nb_samples; } for(i=0; i<s->filter_channels; i++){ bufin[i]= (short*) av_malloc( (nb_samples + s->temp_len) * sizeof(short) ); memcpy(bufin[i], s->temp[i], s->temp_len * sizeof(short)); buftmp2[i] = bufin[i] + s->temp_len; } lenout= (int)(4*nb_samples * s->ratio) + 16; bufout[0]= (short*) av_malloc( lenout * sizeof(short) ); bufout[1]= (short*) av_malloc( lenout * sizeof(short) ); if (s->input_channels == 2 && s->output_channels == 1) { buftmp3[0] = output; stereo_to_mono(buftmp2[0], input, nb_samples); } else if (s->output_channels >= 2 && s->input_channels == 1) { buftmp3[0] = bufout[0]; memcpy(buftmp2[0], input, nb_samples*sizeof(short)); } else if (s->output_channels >= 2) { buftmp3[0] = bufout[0]; buftmp3[1] = bufout[1]; stereo_split(buftmp2[0], buftmp2[1], input, nb_samples); } else { buftmp3[0] = output; memcpy(buftmp2[0], input, nb_samples*sizeof(short)); } nb_samples += s->temp_len; nb_samples1 = 0; for(i=0;i<s->filter_channels;i++) { int consumed; int is_last= i+1 == s->filter_channels; nb_samples1 = av_resample(s->resample_context, buftmp3[i], bufin[i], &consumed, nb_samples, lenout, is_last); s->temp_len= nb_samples - consumed; s->temp[i]= av_realloc(s->temp[i], s->temp_len*sizeof(short)); memcpy(s->temp[i], bufin[i] + consumed, s->temp_len*sizeof(short)); } if (s->output_channels == 2 && s->input_channels == 1) { mono_to_stereo(output, buftmp3[0], nb_samples1); } else if (s->output_channels == 2) { stereo_mux(output, buftmp3[0], buftmp3[1], nb_samples1); } else if (s->output_channels == 6) { ac3_5p1_mux(output, buftmp3[0], buftmp3[1], nb_samples1); } for(i=0; i<s->filter_channels; i++) av_free(bufin[i]); av_free(bufout[0]); av_free(bufout[1]); return nb_samples1; }
1threat
static int smc91c111_can_receive(NetClientState *nc) { smc91c111_state *s = qemu_get_nic_opaque(nc); if ((s->rcr & RCR_RXEN) == 0 || (s->rcr & RCR_SOFT_RST)) return 1; if (s->allocated == (1 << NUM_PACKETS) - 1) return 0; return 1; }
1threat
Java frontend beginner : <p>I have to build a simple java application so i am using Spring boot and hibernate as my frameworks . Its the first time i am doing this so i need all the help i can get, i manage to make the back end to work ,at least the most of it, but i was wondering what would be the easiest way to create a front end for my application ,something pretty basic , thank you in advance!</p> <p>here is my main model </p> <pre><code>... package com.scheduler.backend.model; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; @Entity @Table(name = "person") public class Person extends AbstractEntity { /** * */ //private static final long serialVersionUID = 1L; @Column private String firstName; @Column private String lastName; @Column private PersonType type; @Column private Long calendarId; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public PersonType getType() { return type; } public void setType(PersonType type) { this.type = type; } public Long getCalendarId() { return calendarId; } public void setCalendarId(Long calendarId) { this.calendarId = calendarId; } } ... </code></pre>
0debug
JavaScript: Equivalent of arrow function (how to not use an arrow) : <p>I am new to JavaScript, and I am struggling with how to change an arrow function with non-arrow function... Please help, and thank you very much in advance!</p> <pre><code>this.middleware(req,res,()=&gt;{ this.processRoutes(req,res); }); </code></pre>
0debug
ContainsKey on treemap throws NPE : So i have a comparator that i defined for my TreeMap to sort it by values, but when i use containsKey(anyKey) on a key that it does not contain it doesn't return false, but it throws a NullPointerException. Now what i don't understand is why it goes in my comparator for the containsKey() method and how i could find a solution... I've been stuck on this for a couple of hours and any help would be appriciated. Here is the code : public class test { public static void main(String[] args) { HashMap<Integer, Integer> map = new HashMap<>(); map.put(1,2); map.put(2, 3); Comparator<Integer> comp = new ValueComparator<Integer, Integer>(map); TreeMap<Integer, Integer> tm = new TreeMap<Integer, Integer>(comp); tm.putAll(map); System.out.println(tm.containsKey(1)); // returns true System.out.println(tm.containsKey(3)); //Throws NPE } } class ValueComparator<K, V extends Comparable<V>> implements Comparator<K>{ HashMap<K, V> map = new HashMap<K, V>(); public ValueComparator(HashMap<K, V> map){ this.map.putAll(map); } @Override public int compare(K s1, K s2) { return map.get(s1).compareTo(map.get(s2));//descending order } }
0debug
void HELPER(wsr_ibreaka)(uint32_t i, uint32_t v) { if (env->sregs[IBREAKENABLE] & (1 << i) && env->sregs[IBREAKA + i] != v) { tb_invalidate_phys_page_range( env->sregs[IBREAKA + i], env->sregs[IBREAKA + i] + 1, 0); tb_invalidate_phys_page_range(v, v + 1, 0); } env->sregs[IBREAKA + i] = v; }
1threat
How to calculate Determinant Matrix 2x2 -C : <p>So I <strong>need to calculate the determinant matrix on 2x2 matrix</strong>, <strong>simple one</strong>.. If you can, please write the code, because i don't understand like in the other thread, it's like i'm reading an English Literature + Code..</p> <pre><code>#include&lt;stdio.h&gt; int main(){ int x[2][2]={{1,2},{3,4}}; int i,j,d; for(i=0;i&lt;=1;i++){ for(j=0;j&lt;=1;j++){ printf(" %d ", x[i][j]); } printf(" \n"); } return 0; } </code></pre> <p>Thank You!</p>
0debug
static void parse_type_number(Visitor *v, const char *name, double *obj, Error **errp) { StringInputVisitor *siv = to_siv(v); char *endp = (char *) siv->string; double val; errno = 0; if (siv->string) { val = strtod(siv->string, &endp); } if (!siv->string || errno || endp == siv->string || *endp) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "number"); return; } *obj = val; }
1threat
TypeError: Mismatch between array dtype ('object') and format specifier ('%.18e') : <p>I have the following array:</p> <pre><code>X = np.array([image_array_to_vector1,image_array_to_vector2,image_array_to_vector3,image_array_to_vector4]) </code></pre> <p>A print out of <code>X</code> looks as follows:</p> <pre><code>[array([167, 167, 169, ..., 1, 1, 1], dtype=uint8) array([42, 43, 43, ..., 41, 36, 34], dtype=uint8) array([0, 0, 0, ..., 0, 0, 0], dtype=uint8) array([0, 0, 0, ..., 0, 0, 0], dtype=uint8)] </code></pre> <p>When I try to save the data as txt:</p> <pre><code>X_to_text_file = np.savetxt('x.txt',X) </code></pre> <p>I get the following:</p> <pre><code>File "/Library/Python/2.7/site-packages/numpy/lib/npyio.py", line 1258, in savetxt % (str(X.dtype), format)) TypeError: Mismatch between array dtype ('object') and format specifier ('%.18e') </code></pre> <p>Why is that? How can I solve the issue?</p> <p>Thanks.</p>
0debug
What does version name 'cp27' or 'cp35' mean in Python? : <p>What does version name 'cp27' or 'cp35' mean in Python?</p> <p>Like the files in <a href="https://pypi.python.org/pypi/gensim#downloads" rel="noreferrer">https://pypi.python.org/pypi/gensim#downloads</a></p> <p><a href="https://i.stack.imgur.com/gIQRy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gIQRy.png" alt="enter image description here"></a></p> <p>I am using Python 2.7 on a 64-bit Window 7 PC, and don't know which version of python package I should install.</p> <p>There are three questions:</p> <ol> <li><p>Which of "<strong>gensim-0.12.4-cp27-none-win_amd64.whl</strong>" or "<strong>gensim-0.12.4.win-amd64-py2.7.exe</strong>" should I install? I have installed 'WinPython-64bit-2.7.10.3' on 64-bit Window 7 PC which I am using.</p></li> <li><p>What does '<strong>cp27</strong>' mean in Python or Python version name? I searched online with keywords 'Python cp27' but failed to find any answers.</p></li> <li><p>Are there differences between these two versions of python packages? ('<strong>0.12.4-cp27-none-win_amd64</strong>' and '<strong>win-amd64-py2.7</strong>') If there are, what are the differences? </p></li> </ol>
0debug
Functions in Python vs Matlab : <p>I'm new to Python, coming from Matlab like many. I'm used to defining my functions as standalone .m files and calling them easily from a second script as long as the function is saved somewhere within the defined Matlab path. </p> <p>I've learned how to define a (user-defined) function in Python (def my_function() etc.), but I'm coming up short in my Google searches on a way to define the function in a a separate .py file A, and how to call it in another script B. All help files I can find give support on how to define the function within the same script. When I try calling the function (which I've defined as a .py file in the same folder I'm using for script A) my script doesn't recognize it. Do I need to be declaring the function at the beginning of my script? I'm getting the sense that Python is very different in the way it handles these things than Matlab--perhaps I can't do this?</p> <p>Cheers</p>
0debug
Which Algorithm does sortBy uses in Spark? : <p>Want to know how sorting is achieved in spark. where can i find algorithm used for writing an rdd operation. Thanks</p>
0debug
jquery clone() function not working : i don't know but the below code is not working. it is working fine when i add td instead of p. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> $(document).ready(function(){ $("button").click(function(){ $( "th:contains('2G Band') ~ p" ).clone().appendTo("#2g"); }); }); <!-- language: lang-html --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button>Clone element</button> <tr class="RowBG2"> <th rowspan="3" scope="rowgroup" style="text-align: left;vertical-align: top;" class="hdngArial specs-mainHeading bottom-border-section">Frequency</th> <th scope="row" align="left" class="hdngArial specs-subHeading RowBG1 bottom-border">2G Band</th> <p class="fasla RowBG1 specs-value bottom-border"><b>SIM1:</b> GSM 850 / 900 / 1800 / 1900<br><b>SIM2:</b> GSM 850 / 900 / 1800 / 1900 &nbsp;</p> </tr> <tr class="RowBG2" style="background-color: #ebf1fa; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 16px;"><td class="hdngArial" height="25" style="font-size: 10pt; font-weight: bold;">&nbsp;2G &nbsp;Band&nbsp;</td><td id="2g" colspan="2"></td></tr> <!-- end snippet -->
0debug
static void fw_cfg_boot_set(void *opaque, const char *boot_device, Error **errp) { fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); }
1threat
How to convert a String ("95941634.164") to a float : <p>When I tyr to convert a String "95941634.164" to a float and print the same, it is printing as 9.5941632E7 but not as 95941634.164.</p> <p>I tried following conversion methods Float.parseFloat() and Float.valueOf()</p> <pre><code>public static void main(String args[]) { String s = "95941634.164" ; Float f = Float.valueOf(s); System.out.println(f); System.out.println(Float.parseFloat("95941634.164")); } </code></pre> <p>Actual: 9.5941632E7 expected 95941634.164</p>
0debug
c++ 2D vector for loop : <p>I have a text file with data and I have put that into a 2D vector. I can print all of the data with this loop. </p> <pre><code>int M = 1024; int N = 768 // row / column int R = 49; int C = 36 // row / column for (double bx = 0; bx &lt; M; bx += R) for (double by = 0; by &lt; N; by += C) { for (int x = 0; ((x &lt; R) &amp;&amp; ((bx + x) &lt; M)); ++x) { for (int y = 0; ((y &lt; C) &amp;&amp; ((by + y) &lt; N)); ++y) { if ((bx + x) &gt;= M) { std::cout &lt;&lt; (bx + x) &lt;&lt; (by + y) &lt;&lt; " "; } cout &lt;&lt; MainIMG_2DVector[bx + x][by + y] &lt;&lt; " "; } } cout &lt;&lt; "\n\n\n" &lt;&lt; endl; } </code></pre> <p>If I want to get the first block of the data, I use this loop:</p> <pre><code>for (int i = 0; i &lt; 49; i++) { for (int j = 0; j &lt; 36; j++) { cout &lt;&lt; MainIMG_2DVector[i][j] &lt;&lt; " "; } } </code></pre> <p>When I compare the First block with the Data from the text file, it is correct.</p> <p>However if I get the Second Block of data and compare it with the text file, it is incorrect.</p> <pre><code>for (int i = 49; i &lt; 98; i++) { for (int j = 36; j &lt; 72; j++) { cout &lt;&lt; MainIMG_2DVector[i][j] &lt;&lt; " "; } } </code></pre> <p>I know the second loop is wrong but I don't know how to fix this. Can someone please help me.</p>
0debug
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { int i, ret = 0; if (!avpkt->data && avpkt->size) { av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n"); return AVERROR(EINVAL); if (!avctx->codec) return AVERROR(EINVAL); if (avctx->codec->type != AVMEDIA_TYPE_SUBTITLE) { av_log(avctx, AV_LOG_ERROR, "Invalid media type for subtitles\n"); return AVERROR(EINVAL); *got_sub_ptr = 0; avcodec_get_subtitle_defaults(sub); if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) { AVPacket pkt_recoded; AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(&tmp); pkt_recoded = tmp; ret = recode_subtitle(avctx, &pkt_recoded, &tmp); if (ret < 0) { *got_sub_ptr = 0; } else { avctx->internal->pkt = &pkt_recoded; if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE) sub->pts = av_rescale_q(avpkt->pts, avctx->pkt_timebase, AV_TIME_BASE_Q); ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &pkt_recoded); av_assert1((ret >= 0) >= !!*got_sub_ptr && !!*got_sub_ptr >= !!sub->num_rects); if (sub->num_rects && !sub->end_display_time && avpkt->duration && avctx->pkt_timebase.num) { AVRational ms = { 1, 1000 }; sub->end_display_time = av_rescale_q(avpkt->duration, avctx->pkt_timebase, ms); for (i = 0; i < sub->num_rects; i++) { if (sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) { av_log(avctx, AV_LOG_ERROR, "Invalid UTF-8 in decoded subtitles text; " "maybe missing -sub_charenc option\n"); avsubtitle_free(sub); return AVERROR_INVALIDDATA; if (tmp.data != pkt_recoded.data) { pkt_recoded.side_data = NULL; pkt_recoded.side_data_elems = 0; av_free_packet(&pkt_recoded); if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) sub->format = 0; else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB) sub->format = 1; avctx->internal->pkt = NULL; av_packet_free_side_data(&tmp); if(ret == tmp.size) ret = avpkt->size; if (*got_sub_ptr) avctx->frame_number++; return ret;
1threat
How to edit data from rich text box without deleting the current data in c# : <p>How to edit data in rich text box. I'm using like a button to click. When I click it, more data will be added to rich text box. But when I click it, it deleted the current data from box and replace with the new one. How do I make it so the old data and newly added data will stay in place ? </p>
0debug
static int read_packet(AVFormatContext *s, AVPacket *pkt) { ByteIOContext *pb = s->pb; PutBitContext pbo; uint16_t buf[8 * MAX_FRAME_SIZE + 2]; int packet_size; int sync; uint16_t* src=buf; int i, j, ret; if(url_feof(pb)) return AVERROR_EOF; sync = get_le16(pb); packet_size = get_le16(pb) / 8; assert(packet_size < 8 * MAX_FRAME_SIZE); ret = get_buffer(pb, (uint8_t*)buf, (8 * packet_size) * sizeof(uint16_t)); if(ret<0) return ret; if(ret != 8 * packet_size * sizeof(uint16_t)) return AVERROR(EIO); av_new_packet(pkt, packet_size); init_put_bits(&pbo, pkt->data, packet_size); for(j=0; j < packet_size; j++) for(i=0; i<8;i++) put_bits(&pbo,1, AV_RL16(src++) == BIT_1 ? 1 : 0); flush_put_bits(&pbo); pkt->duration=1; return 0; }
1threat
Updation in Google Cloud Storage library : I am working on a project and it requires latest version of google app engine cloud storage client. Where can I find the latest version?
0debug
Python Error IndexError: single positional indexer is out-of-bounds : Here is the error I can't seem to squash, dropping down my count to be one less than my actual rows fixes it, but that means it can't even read the last row. Traceback (most recent call last): File ".\gameRelease.py", line 306, in <module> NintendoSwitch() File ".\gameRelease.py", line 277, in NintendoSwitch main(system,data,color,calID) File ".\gameRelease.py", line 270, in main twitUpdate(tDay) File ".\gameRelease.py", line 97, in twitUpdate csvName = str((df.iloc[x,0])) File "C:\Users\UmbraTytan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\indexing.py", line 1367, in __getitem__ return self._getitem_tuple(key) File "C:\Users\UmbraTytan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\indexing.py", line 1737, in _getitem_tuple self._has_valid_tuple(tup) File "C:\Users\UmbraTytan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\indexing.py", line 204, in _has_valid_tuple if not self._has_valid_type(k, i): File "C:\Users\UmbraTytan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\indexing.py", line 1672, in _has_valid_type return self._is_valid_integer(key, axis) File "C:\Users\UmbraTytan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\indexing.py", line 1713, in _is_valid_integer raise IndexError("single positional indexer is out-of-bounds") IndexError: single positional indexer is out-of-bounds
0debug
How to Hide and show RelativeLayout header on scroll webview in android? : Actually, I have webView with custom relative layout header, and when we scroll up webView header should be hidden and when i scroll down header should be visible. plz suggest me if anyone have idea about it.
0debug
static int copy_stream_props(AVStream *st, AVStream *source_st) { int ret; if (st->codecpar->codec_id || !source_st->codecpar->codec_id) { if (st->codecpar->extradata_size < source_st->codecpar->extradata_size) { if (st->codecpar->extradata) { av_freep(&st->codecpar->extradata); st->codecpar->extradata_size = 0; } ret = ff_alloc_extradata(st->codecpar, source_st->codecpar->extradata_size); if (ret < 0) return ret; } memcpy(st->codecpar->extradata, source_st->codecpar->extradata, source_st->codecpar->extradata_size); return 0; } if ((ret = avcodec_parameters_copy(st->codecpar, source_st->codecpar)) < 0) return ret; st->r_frame_rate = source_st->r_frame_rate; st->avg_frame_rate = source_st->avg_frame_rate; st->time_base = source_st->time_base; st->sample_aspect_ratio = source_st->sample_aspect_ratio; av_dict_copy(&st->metadata, source_st->metadata, 0); return 0; }
1threat
static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end) { const uint8_t *buf_ptr= *pbuf_ptr; buf_ptr++; buf_end -= 2; while (buf_ptr < buf_end) { if(*buf_ptr==0){ while(buf_ptr < buf_end && buf_ptr[1]==0) buf_ptr++; if(buf_ptr[-1] == 0 && buf_ptr[1] == 1){ *pbuf_ptr = buf_ptr+3; return buf_ptr[2] + 0x100; } } buf_ptr += 2; } buf_end += 2; *pbuf_ptr = buf_end; return -1; }
1threat
Can get the data response : I am trying to get some data to my state, from a fake online rest api, the problem is the data is not getting to the state properly, so it's not showing up. I have tried to change the state to array or just like this ``` firstName: '', ...``` and it still wont work ``` import React, { Component } from 'react'; import axios from 'axios'; class Success extends Component { state = { firstName: [], username: [], email: [], id: [], show: false }; componentDidMount() { axios .get('https://jsonplaceholder.typicode.com/users') .then(res => this.setState({ firstName: res.data.name })); } onClick = () => { this.setState(prevState => ({ show: !prevState.show })); }; render() { return ( <div> <h1 className="font-weight-light" style={{ color: 'black', marginTop: '50px' }} > UserList: </h1> <div className="mt-5"> <ul className="list-group"> <li className="list-group-item"> {this.state.firstName} <div className="fas fa-angle-down" style={{ marginLeft: '98%' }} onClick={this.onClick} /> </li> {this.state.show === true ? ( <li className="list-group-item"> Username: {this.state.username} </li> ) : null} {this.state.show === true ? ( <li className="list-group-item">Email: {this.state.email}</li> ) : null} {this.state.show === true ? ( <li className="list-group-item">ID: {this.state.id}</li> ) : null} </ul> </div> </div> ); } } export default Success; ``` I want the data to get in the state and show up.
0debug
Foders and files created from external text file with same names to insert with corresponding same name.Batch : I was inspired on works of our colleagues from portal http://stackoverflow.com/questions/19732198/have-a-batch-create-text-files-based-on-a-list http://stackoverflow.com/questions/17648627/batch-script-to-read-input-text-file-and-make-text-file-for-each-line-of-input-t to develop creation from external a text file for example "comps.txt" ( comp1,comp2.... for each PC a batch script read from a list of PCs in a text file and create a text file for each line of text as local. Later in code are created folders files named - the same names ( comp1,comp2.... at the end we have text files : comp1.txt ,comp2.txt ... and folders: comp1 , comp2.... till 400 computers. Any idea how to add in code or write another separate batch code to move for each coresponding folder text file for text file comp1.txt->comp1 folder ,comp2.txt->comp2.txt .... We have more than 400 lines!! I am very begginers for any scrips working very hard every single day and this is my first question. My code in Windows Batch is below @echo off setlocal for /f "tokens=*" %%a in (comps.txt) do (type nul>"%%a.txt") for /f "tokens=*" %%a in (comps.txt) do ( echo This is line 1 of text>"%%a.txt" ) for /f %%i in (comps.txt) do mkdir %%i do ( echo "%%i.txt" ) endlocal [https://lookimg.com/images/2017/03/16/externalscreenshoot.jpg][1] [1]: https://i.stack.imgur.com/j8ylw.jpg
0debug
What is the difference between jedi and python language server in VS code IDE? : <p>I am using VS code for python development. I had to disable python language server and enable jedi to fix an excessive RAM consumption problem with python language server. Many people encountered similar problems when you search on Google.</p> <p>What is the difference between jedi and python language server?</p> <p>I am using Windows 10 64-bit, python 3.7.3.</p>
0debug
static void nbd_restart_write(void *opaque) { NbdClientSession *s = opaque; qemu_coroutine_enter(s->send_coroutine, NULL); }
1threat
static int h264_slice_header_init(H264Context *h, int reinit) { MpegEncContext *const s = &h->s; int i, ret; if( FFALIGN(s->avctx->width , 16 ) == s->width && FFALIGN(s->avctx->height, 16*(2 - h->sps.frame_mbs_only_flag)) == s->height && !h->sps.crop_right && !h->sps.crop_bottom && (s->avctx->width != s->width || s->avctx->height && s->height) ) { av_log(h->s.avctx, AV_LOG_DEBUG, "Using externally provided dimensions\n"); s->avctx->coded_width = s->width; s->avctx->coded_height = s->height; } else{ avcodec_set_dimensions(s->avctx, s->width, s->height); s->avctx->width -= (2>>CHROMA444)*FFMIN(h->sps.crop_right, (8<<CHROMA444)-1); s->avctx->height -= (1<<s->chroma_y_shift)*FFMIN(h->sps.crop_bottom, (16>>s->chroma_y_shift)-1) * (2 - h->sps.frame_mbs_only_flag); } s->avctx->sample_aspect_ratio = h->sps.sar; av_assert0(s->avctx->sample_aspect_ratio.den); if (h->sps.timing_info_present_flag) { int64_t den = h->sps.time_scale; if (h->x264_build < 44U) den *= 2; av_reduce(&s->avctx->time_base.num, &s->avctx->time_base.den, h->sps.num_units_in_tick, den, 1 << 30); } s->avctx->hwaccel = ff_find_hwaccel(s->avctx->codec->id, s->avctx->pix_fmt); if (reinit) { free_tables(h, 0); if ((ret = ff_MPV_common_frame_size_change(s)) < 0) { av_log(h->s.avctx, AV_LOG_ERROR, "ff_MPV_common_frame_size_change() failed.\n"); return ret; } } else { if ((ret = ff_MPV_common_init(s) < 0)) { av_log(h->s.avctx, AV_LOG_ERROR, "ff_MPV_common_init() failed.\n"); return ret; } } s->first_field = 0; h->prev_interlaced_frame = 1; init_scan_tables(h); if (ff_h264_alloc_tables(h) < 0) { av_log(h->s.avctx, AV_LOG_ERROR, "Could not allocate memory for h264\n"); return AVERROR(ENOMEM); } if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_SLICE)) { if (context_init(h) < 0) { av_log(h->s.avctx, AV_LOG_ERROR, "context_init() failed.\n"); return -1; } } else { for (i = 1; i < s->slice_context_count; i++) { H264Context *c; c = h->thread_context[i] = av_malloc(sizeof(H264Context)); memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext)); memset(&c->s + 1, 0, sizeof(H264Context) - sizeof(MpegEncContext)); c->h264dsp = h->h264dsp; c->sps = h->sps; c->pps = h->pps; c->pixel_shift = h->pixel_shift; c->cur_chroma_format_idc = h->cur_chroma_format_idc; init_scan_tables(c); clone_tables(c, h, i); } for (i = 0; i < s->slice_context_count; i++) if (context_init(h->thread_context[i]) < 0) { av_log(h->s.avctx, AV_LOG_ERROR, "context_init() failed.\n"); return -1; } } return 0; }
1threat
Changing JSON array with circe at scala : I have a JSON string with array as the following: { "cars": { "Nissan": [ {"model":"Sentra", "doors":4}, {"model":"Maxima", "doors":4}, ], "Ford": [ {"model":"Taurus", "doors":4}, {"model":"Escort", "doors":2} ] } } I would like to edit a new card brand, using ***circe*** at scala. Instead of "Nissan": [ {"model":"Sentra", "doors":4}, {"model":"Maxima", "doors":4}, ] I would like to have as a result: "Nissan": [ {"model":"Sentra", "doors":1000}, ], Thanks.
0debug
static void add_machine_test_cases(void) { const char *arch = qtest_get_arch(); QDict *response, *minfo; QList *list; const QListEntry *p; QObject *qobj; QString *qstr; const char *mname, *path; qtest_start("-machine none"); response = qmp("{ 'execute': 'query-machines' }"); g_assert(response); list = qdict_get_qlist(response, "return"); g_assert(list); for (p = qlist_first(list); p; p = qlist_next(p)) { minfo = qobject_to_qdict(qlist_entry_obj(p)); g_assert(minfo); qobj = qdict_get(minfo, "name"); g_assert(qobj); qstr = qobject_to_qstring(qobj); g_assert(qstr); mname = qstring_get_str(qstr); if (!is_blacklisted(arch, mname)) { path = g_strdup_printf("qom/%s", mname); qtest_add_data_func(path, g_strdup(mname), test_machine); } } qtest_end(); QDECREF(response); }
1threat
Unable to pick image from Gallery from Android Oreo : I am developing an app which needs picking up content from Internal/External Storage like photos , media etc ..... but in Android Oreo it is not working ...
0debug
Align both vertically and horizontally using Bootstrap flex : <p>After looking through the bootstrap 4 Flex doc, I can't seem to get the "align-item-center" property to work. I tested pretty much every example available online but really can't seem to change the vertical alignment of anything, it's driving me nuts. I join a simple HTML example I'm trying to make work. </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>.d-flex { display: -ms-flexbox !important; display: flex !important; } .justify-content-center { -ms-flex-pack: center !important; justify-content: center !important; } .align-items-center { -ms-flex-align: center !important; align-items: center !important; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="d-flex justify-content-center align-items-center"&gt; &lt;p&gt; This should be centered right ?&lt;/p&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>I'm using Bootstrap 4.4.1 and also have installed popper.js@latest and jquery@latest just to be sure. For further precision I'm only using a simple textline now but in the future I'll add elements whose size are not known until runtime.</p>
0debug
The address of a variable can be directly accessed by Ampersand....Then why do we use pointers isn't useless : The address of a variable can be directly accessed by Ampersand.Then why do we use pointers.Isn't useless? i have used ampersand and pointer and obtained the same output. #include <iostream> using namespace std; int main() { int score = 5; int *scorePtr; scorePtr = &score; cout << scorePtr << endl; cout << &score << endl; //output //0x23fe44 //0x23fe44 return 0; }
0debug
RetrieveAPIView without lookup field? : <p>By default RetrieveAPIView or RetrieveUpdateAPIView requires <code>lookup_field</code> to retrieve Model. </p> <p>However in my case, I want to retrieve my model by self.request.user. </p> <p>Here is views.py example</p> <pre><code>class ProfileRetrieveAndUpdateProfile(generics.RetrieveUpdateAPIView): queryset = Profile.objects.all() serializer_class = ProfileRetrieveAndUpdateSerializer lookup_field = 'user_id' def get_queryset(self): qs = Profile.objects.all() logged_in_user_profile = qs.filter(user=self.request.user) return logged_in_user_profile </code></pre> <p>Can I use RetrieveAPIView <strong>without lookup_field</strong>?</p>
0debug
Proper configuration for Jenkins GitHub Pull Request Builder downstream : <p>I'm trying to create two Jenkins jobs that both leverage the <a href="https://github.com/janinko/ghprb" rel="noreferrer" title="GitHub Pull Request Builder">GitHub Pull Request Builder plugin</a> in order to run multiple status checks, but I'm having trouble getting the status check from my downstream job to show up in my GitHub project.</p> <p>Here's the summarized CI flow I'd like to setup:</p> <ol> <li>A pull request is opened against my git repository which triggers <strong>Upstream</strong> job to run in Jenkins</li> <li><strong>Upstream</strong> reports its status based on the build and, if <code>SUCCESS</code>, should invoke <strong>Downstream</strong> job via a post-build action</li> <li><strong>Downstream</strong> runs and reports its own status check</li> </ol> <p>Step 3 is where I'm having issues. <strong>Downstream</strong> runs properly, but it does not post a status. The status is not even available under the <strong>Branches</strong> section of my GitHub project's settings. I'm not sure how <a href="https://github.com/janinko/ghprb" rel="noreferrer" title="GitHub Pull Request Builder">GHPRB</a> does the initial creation of the status check, but there are references to the context messaging in the Console Output:</p> <pre><code>14:58:23 Started by upstream project "upstream" build number 209 14:58:23 originally caused by: 14:58:23 GitHub pull request #114 of commit f1ff2819a5308f7819275e732cf44a2cc2ec31dc, no merge conflicts. 14:58:23 [EnvInject] - Loading node environment variables. 14:58:23 Building on master in workspace /store/jenkins/jobs/downstream/workspace 14:58:23 &gt; git rev-parse --is-inside-work-tree # timeout=10 14:58:23 Fetching changes from the remote Git repository 14:58:23 &gt; git config remote.origin.url &lt;removed for privacy&gt; # timeout=10 14:58:23 Fetching upstream changes from &lt;removed for privacy&gt; 14:58:23 &gt; git --version # timeout=10 14:58:23 &gt; git -c core.askpass=true fetch --tags --progress &lt;removed for privacy&gt; +refs/pull/*:refs/remotes/origin/pr/* 14:58:24 &gt; git rev-parse refs/remotes/origin/master^{commit} # timeout=10 14:58:24 &gt; git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 14:58:24 Checking out Revision eac390c51a1b8b591bfe879421bd5fad0421a1ec (refs/remotes/origin/master) 14:58:24 &gt; git config core.sparsecheckout # timeout=10 14:58:24 &gt; git checkout -f eac390c51a1b8b591bfe879421bd5fad0421a1ec 14:58:24 First time build. Skipping changelog. 14:58:24 [build] $ /store/jenkins/tools/hudson.tasks.Ant_AntInstallation/ant_1.8.2/bin/ant -DghprbStatusUrl= "-DghprbSUCCESSMessage=Packaging organization successfully cleaned" -DghprbStartedStatus=Undeploying -DghprbAddTestResults=false "-DghprbCommitStatusContext=Cleaning Packaging" "-DghprbERRORMessage=An error occurred during undeployment" -DghprbUpstreamStatus=true "-DghprbTriggeredStatus=Preparing destructive changes" "-DghprbFAILUREMessage=Packaging organization failed to clean properly" -DghprbShowMatrixStatus=false </code></pre> <p>Here are the relevant configuration sections for both Jenkins jobs:</p> <hr> <h2>Upstream Job</h2> <h3>Source Code Management: Git</h3> <ul> <li>Name: <code>origin</code></li> <li>Refspec: <code>+refs/pull/*:refs/remotes/origin/pr/*</code></li> <li>Branch Specifier: <code>${sha1}</code></li> </ul> <h3>Build Triggers</h3> <ul> <li>GitHub Pull Request Builder <ul> <li>Use github hooks for build triggering <code>✔︎</code></li> <li>Display build errors on downstream builds? <code>✔︎</code></li> <li><strong>Trigger Setup</strong> is populated with custom context messaging</li> </ul></li> </ul> <h3>Post-build Actions</h3> <ul> <li>Build other projects: <code>Downstream</code></li> </ul> <hr> <h2>Downstream Job</h2> <h3>Source Code Management: Git</h3> <ul> <li>Name: <code>origin</code></li> <li>Refspec: <code>+refs/pull/*:refs/remotes/origin/pr/*</code></li> <li>Branch Specifier: <code>*/master</code></li> </ul> <h3>Build Triggers</h3> <ul> <li>GitHub Pull Request Builder <ul> <li><strong>Trigger Setup</strong> is populated with custom context messaging</li> </ul></li> </ul> <h3>Build Environment</h3> <ul> <li>Set GitHub commit status with custom context and message (Must configure upstream job using GHPRB trigger) <code>✔︎</code> <ul> <li>Custom context messaging fields mirror those listed under the <strong>Trigger Setup</strong> section (I doubt both of these are required, but neither seem to be working currently)</li> </ul></li> </ul> <hr> <p>What am I missing? <strong>It should be noted</strong> that I do not have the Jobs DSL plugin installed so I cannot leverage <a href="https://github.com/janinko/ghprb#job-dsl-support" rel="noreferrer">the extension that GHPRB provides</a>.</p>
0debug
Is Redundant Programming in Java Inefficient? : <p>For example I have 3 calls of one method (always 3 calls) and I need to pass 1 to method for the first call 2 for the second and 3 for the third. I can solve that Problem in 2 ways. Either make 3 calls with 1, 2, 3 or use a for loop.</p> <pre><code>call(1); call(2); call(3); for (int i = 1; i &lt;= 3; i++) { call(i); } </code></pre> <p>The question is what will run faster. As I know this depends completly on the Java Compiler, because it could make optimizations on the for loop.</p> <p>In plain C the redundant way would be a little bit faster I guess, because there is no counter needed to increment and compare.</p>
0debug
static void gd_mouse_mode_change(Notifier *notify, void *data) { gd_update_cursor(container_of(notify, GtkDisplayState, mouse_mode_notifier), FALSE); }
1threat
Typescript | Warning about Missing Return Type of function, ESLint : <p>I have a <code>REACT-STATELESS-COMPONENT</code>, in a project with TypeScript. It has an error, saying, that </p> <pre><code>Missing return type on function.eslint(@typescript-eslint/explicit-function-return-type) </code></pre> <p>I am not sure what it wants me to do. Here is my code:</p> <pre><code>import React, { Fragment} from 'react'; import IProp from 'dto/IProp'; export interface Props { prop?: IProp; } const Component = &lt;T extends object&gt;({ prop }: Props &amp; T) =&gt; ( &lt;Fragment&gt; {prop? ( &lt;Fragment&gt; Some Component content.. &lt;/Fragment&gt; ) : null} &lt;/Fragment&gt; ); LicenseInfo.defaultProps: {}; export default Component; </code></pre> <p>Can you tell me what I need to do. I need to read about TS, but currently I don't get it at all. And I can't commit right now cause of this.</p>
0debug
function for Phone number to words in java for multiple digits : <p>I want to make a function like if I enter 9898974123 it should convert into such output: Nine Eight Nine Eight Nine Seven Four One Two Three</p>
0debug
How do I limit the number of auto-restarts on pm2? : <p>I have a node server running on pm2 which depends on some external services.</p> <p>When those servers go down I pm2 starts restarting my app, but this will keep going until it clogs up my cpu and ram on the server, restarting as much as 50 times a minute.</p> <p>Is there a way to limit the numbers of restarts on pm2? There is a way to restart the server when the server reaches a certain RAM memory level, so I would hope this feature I am asking for exists.</p>
0debug
void destroy_nic(dev_match_fn *match_fn, void *arg) { int i; NICInfo *nic; for (i = 0; i < MAX_NICS; i++) { nic = &nd_table[i]; if (nic->used) { if (nic->private && match_fn(nic->private, arg)) { if (nic->vlan) { VLANClientState *vc; vc = qemu_find_vlan_client(nic->vlan, nic->private); if (vc) qemu_del_vlan_client(vc); } net_client_uninit(nic); } } } }
1threat
How to decode Json with Curl? : <p>I want to echo the word 'Active' from the json.</p> <p>"status":"Active"</p> <p>PHP/CURL:</p> <pre><code>$ch = curl_init("http://ip:port/player_api.php?username=$username&amp;password=$password"); $headers = array(); $headers[] = "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0"; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); $result = curl_exec($ch); // Now i need to decode the json </code></pre> <p>Json:</p> <pre><code>{"user_info":{"username":"test","password":"test","message":"","auth":1,"status":"Active","exp_date":null,"is_trial":"0","active_cons":"0","created_at":"000","max_connections":"1","allowed_output_formats":["m3u8","ts","rtmp"]},"server_info":{"url":"111.111.111","port":"80","rtmp_port":"80","timezone":"test","time_now":"2018-03-20"}} </code></pre>
0debug
Why Closing a File Stream in Java is so Important : <p>With huge advancements in CUPs able to process mass amounts of information in fractions of seconds, why is it important that I close a file stream? </p>
0debug
¿Can someone explain this behaviour to me? : I was just trying some simple stuff with golang and got this behavior Can someone explain to me why? I feel I have a wrong misunderstanding of it... ``` package main import ( "fmt" ) func main() { s := []int{1, 2, 3} fmt.Println(s) fmt.Println("----") a:= s[0:2] fmt.Println(s) fmt.Println(a) a = append(a, 5) fmt.Println("----") fmt.Println(s) fmt.Println(a) a= append(a, 6) fmt.Println("----") fmt.Println(s) fmt.Println(a) } ``` Response: ``` [1 2 3] ---- [1 2 3] [1 2] ---- [1 2 5] [1 2 5] ---- [1 2 5] [1 2 5 6] ``` I was expecting: ``` [1 2 3] ---- [1 2 3] [1 2] ---- [1 2 3] [1 2 5] ---- [1 2 3] [1 2 5 6] ``` Thanks in advance, :)
0debug
Airflow tasks get stuck at "queued" status and never gets running : <p>I'm using Airflow v1.8.1 and run all components (worker, web, flower, scheduler) on kubernetes &amp; Docker. I use Celery Executor with Redis and my tasks are looks like:</p> <pre><code>(start) -&gt; (do_work_for_product1) ├ -&gt; (do_work_for_product2) ├ -&gt; (do_work_for_product3) ├ … </code></pre> <p>So the <code>start</code> task has multiple downstreams. And I setup concurrency related configuration as below:</p> <pre><code>parallelism = 3 dag_concurrency = 3 max_active_runs = 1 </code></pre> <p>Then when I run this DAG manually (not sure if it never happens on a scheduled task) , some downstreams get executed, but others stuck at "queued" status.</p> <p>If I clear the task from Admin UI, it gets executed. There is no worker log (after processing some first downstreams, it just doesn't output any log). </p> <p>Web server's log (not sure <code>worker exiting</code> is related)</p> <pre><code>/usr/local/lib/python2.7/dist-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.cache is deprecated, use flask_cache instead. .format(x=modname), ExtDeprecationWarning [2017-08-24 04:20:56,496] [51] {models.py:168} INFO - Filling up the DagBag from /usr/local/airflow_dags [2017-08-24 04:20:57 +0000] [27] [INFO] Handling signal: ttou [2017-08-24 04:20:57 +0000] [37] [INFO] Worker exiting (pid: 37) </code></pre> <p>There is no error log on scheduler, too. And a number of tasks get stuck is changing whenever I try this.</p> <p>Because I also use Docker I'm wondering if this is related: <a href="https://github.com/puckel/docker-airflow/issues/94" rel="noreferrer">https://github.com/puckel/docker-airflow/issues/94</a> But so far, no clue.</p> <p>Has anyone faced with a similar issue or have some idea what I can investigate for this issue...?</p>
0debug
How to use divideTiles() in Flutter? : <p>I am trying to build a ListView with dividers between each ListTile. I saw that there is a static method to do that called divideTiles() but i did not understand how to use that.. How/where is this function used?</p> <p>My code is a simple ListView with ListTiles as children.</p>
0debug
static int colo_packet_compare_common(Packet *ppkt, Packet *spkt) { trace_colo_compare_ip_info(ppkt->size, inet_ntoa(ppkt->ip->ip_src), inet_ntoa(ppkt->ip->ip_dst), spkt->size, inet_ntoa(spkt->ip->ip_src), inet_ntoa(spkt->ip->ip_dst)); if (ppkt->size == spkt->size) { return memcmp(ppkt->data, spkt->data, spkt->size); } else { trace_colo_compare_main("Net packet size are not the same"); return -1; } }
1threat
webpack dynamic module loader by require : <p>OK, i have searched high and low but cannot reliably deterrmine if this is or is not possible with webpack.</p> <p><a href="https://github.com/webpack/webpack/tree/master/examples/require.context" rel="noreferrer">https://github.com/webpack/webpack/tree/master/examples/require.context</a> Appears to indicate that one can pass a string to a function and it load a module... </p> <p>But my attempt is just not working: webpack.config.js</p> <pre><code>'use strict'; let webpack = require('webpack'), jsonLoader = require("json-loader"), path = require("path"), fs = require('fs'), nodeModules = {}; fs.readdirSync('node_modules') .filter(function(x) { return ['.bin'].indexOf(x) === -1; }) .forEach(function(mod) { nodeModules[mod] = 'commonjs ' + mod; }); let PATHS = { app: __dirname + '/src' }; module.exports = { context: PATHS.app, entry: { app: PATHS.app+'/server.js' }, target: 'node', output: { path: PATHS.app, filename: '../build/server.js' }, externals: nodeModules, performance: { hints: "warning" }, plugins: [ jsonLoader ], resolve: { modules: [ './node_modules', path.resolve(__dirname), path.resolve(__dirname + "/src"), path.resolve('./config') ] }, node: { fs: "empty" } }; </code></pre> <p>The server.js</p> <pre><code>let _ = require('lodash'); let modules = [ "modules/test" ]; require( 'modules/test' )(); _.map( modules, function( module ){ require( module ); }); </code></pre> <p>The module in modules/ named test.js</p> <pre><code>module.exports = () =&gt; { console.log('hello world'); }; </code></pre> <p>But the result is always the same... the pm2 logs just say hello world for the static require... but for the dynamic load of the same module</p> <blockquote> <p>Error: Cannot find module "."</p> </blockquote> <p>All i want to be able to do is loop through an array of paths to modules and load then... </p>
0debug
How does '= delete' work? Could someone explain this constructor? : <p>Working on making a hash-table. Trying to figure out how to better optimize my table. Found this interesting code, and can not seem to find any C++ documentation explaining how the bottom two lines of this code operate, or why this works. Can someone please explain? Additionally, are there alternative ways to do this same thing and offer more readability?</p> <pre><code>class Table { public: explicit Table(const int s); ~Table(); Table(const Table&amp;) = delete; Table &amp;operator = (const Table&amp;) = delete; </code></pre>
0debug
static void migration_completion(MigrationState *s, int current_active_state, bool *old_vm_running, int64_t *start_time) { int ret; if (s->state == MIGRATION_STATUS_ACTIVE) { qemu_mutex_lock_iothread(); *start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); *old_vm_running = runstate_is_running(); ret = global_state_store(); if (!ret) { ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); if (ret >= 0) { ret = bdrv_inactivate_all(); } if (ret >= 0) { qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); qemu_savevm_state_complete_precopy(s->to_dst_file, false); } } qemu_mutex_unlock_iothread(); if (ret < 0) { goto fail; } } else if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) { trace_migration_completion_postcopy_end(); qemu_savevm_state_complete_postcopy(s->to_dst_file); trace_migration_completion_postcopy_end_after_complete(); } if (migrate_postcopy_ram()) { int rp_error; trace_migration_completion_postcopy_end_before_rp(); rp_error = await_return_path_close_on_source(s); trace_migration_completion_postcopy_end_after_rp(rp_error); if (rp_error) { goto fail_invalidate; } } if (qemu_file_get_error(s->to_dst_file)) { trace_migration_completion_file_err(); goto fail_invalidate; } migrate_set_state(&s->state, current_active_state, MIGRATION_STATUS_COMPLETED); return; fail_invalidate: if (s->state == MIGRATION_STATUS_ACTIVE) { Error *local_err = NULL; bdrv_invalidate_cache_all(&local_err); if (local_err) { error_report_err(local_err); } } fail: migrate_set_state(&s->state, current_active_state, MIGRATION_STATUS_FAILED); }
1threat
Difference between audit and debounce in rxjs? : <p>I am reading the offical documentaion of rxjs and then i realized they both are doing exactly same thing.</p> <p>To me they both seems to exactly similar. </p> <p>Please someone point out difference between them (if any)</p>
0debug
C# - Count a specific word in richTextBox1 and send the result to label1 : <p>I'm not sure, if this question is unique, but I couldn't find the answer that I was looking for.</p> <p>I simply need a C# code that counts how many times a word appear in richTextBox1 and send the result to label1.</p> <p>Example; label1.text = how many times the word "house" appears in richTextBox1.</p> <p>I know that I should try first but believe me I tried and I failed. I am new to this so I hope someone can show me.</p> <p>Regards</p>
0debug
def generate_matrix(n): if n<=0: return [] matrix=[row[:] for row in [[0]*n]*n] row_st=0 row_ed=n-1 col_st=0 col_ed=n-1 current=1 while (True): if current>n*n: break for c in range (col_st, col_ed+1): matrix[row_st][c]=current current+=1 row_st+=1 for r in range (row_st, row_ed+1): matrix[r][col_ed]=current current+=1 col_ed-=1 for c in range (col_ed, col_st-1, -1): matrix[row_ed][c]=current current+=1 row_ed-=1 for r in range (row_ed, row_st-1, -1): matrix[r][col_st]=current current+=1 col_st+=1 return matrix
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
static int pci_cmd646_ide_initfn(PCIDevice *dev) { PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev); uint8_t *pci_conf = d->dev.config; qemu_irq *irq; int i; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_CMD); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_CMD_646); pci_conf[PCI_REVISION_ID] = 0x07; pci_conf[PCI_CLASS_PROG] = 0x8f; pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_IDE); pci_conf[0x51] = 0x04; if (d->secondary) { pci_conf[0x51] |= 0x08; } pci_register_bar(dev, 0, 0x8, PCI_BASE_ADDRESS_SPACE_IO, ide_map); pci_register_bar(dev, 1, 0x4, PCI_BASE_ADDRESS_SPACE_IO, ide_map); pci_register_bar(dev, 2, 0x8, PCI_BASE_ADDRESS_SPACE_IO, ide_map); pci_register_bar(dev, 3, 0x4, PCI_BASE_ADDRESS_SPACE_IO, ide_map); pci_register_bar(dev, 4, 0x10, PCI_BASE_ADDRESS_SPACE_IO, bmdma_map); pci_conf[PCI_INTERRUPT_PIN] = 0x01; irq = qemu_allocate_irqs(cmd646_set_irq, d, 2); for (i = 0; i < 2; i++) { ide_bus_new(&d->bus[i], &d->dev.qdev, i); ide_init2(&d->bus[i], irq[i]); bmdma_init(&d->bus[i], &d->bmdma[i]); d->bmdma[i].bus = &d->bus[i]; qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb, &d->bmdma[i].dma); } vmstate_register(&dev->qdev, 0, &vmstate_ide_pci, d); qemu_register_reset(cmd646_reset, d); return 0; }
1threat
perl code to find sum and average of specific columns : i want to calculate the average over all itemsX (where X is a digit) for each row in perl using windows i have file in format <p>id1 item1 cart1 id2 item2 cart2 id3 item3 cart3</p> <p>0 11 34 1 22 44 2 44 44</p> <p>1 44 44 55 66 34 45 55 33</p> want to find sum of item blocks and there average Any help in this regard thanks in anticipation
0debug
How to strip every character from a string except numeric characters and decimal point : <p>'US $109.90/ea' should become '109.90'</p>
0debug
DO YOU NEED ANY LANGUAGE TO LEARN TABLEAU OTHER THAN SQL? : DOES TABLEAU,QLIKVIEW AND PANORAMA REQUIRES ANY PROGRAMMING LANGUAGE TO LEARN ?
0debug
static int xan_decode_frame_type0(AVCodecContext *avctx) { XanContext *s = avctx->priv_data; uint8_t *ybuf, *prev_buf, *src = s->scratch_buffer; unsigned chroma_off, corr_off; int cur, last; int i, j; int ret; chroma_off = bytestream2_get_le32(&s->gb); corr_off = bytestream2_get_le32(&s->gb); if ((ret = xan_decode_chroma(avctx, chroma_off)) != 0) return ret; if (corr_off >= (s->gb.buffer_end - s->gb.buffer_start)) { av_log(avctx, AV_LOG_WARNING, "Ignoring invalid correction block position\n"); corr_off = 0; } bytestream2_seek(&s->gb, 12, SEEK_SET); ret = xan_unpack_luma(s, src, s->buffer_size >> 1); if (ret) { av_log(avctx, AV_LOG_ERROR, "Luma decoding failed\n"); return ret; } ybuf = s->y_buffer; last = *src++; ybuf[0] = last << 1; for (j = 1; j < avctx->width - 1; j += 2) { cur = (last + *src++) & 0x1F; ybuf[j] = last + cur; ybuf[j+1] = cur << 1; last = cur; } ybuf[j] = last << 1; prev_buf = ybuf; ybuf += avctx->width; for (i = 1; i < avctx->height; i++) { last = ((prev_buf[0] >> 1) + *src++) & 0x1F; ybuf[0] = last << 1; for (j = 1; j < avctx->width - 1; j += 2) { cur = ((prev_buf[j + 1] >> 1) + *src++) & 0x1F; ybuf[j] = last + cur; ybuf[j+1] = cur << 1; last = cur; } ybuf[j] = last << 1; prev_buf = ybuf; ybuf += avctx->width; } if (corr_off) { int dec_size; bytestream2_seek(&s->gb, 8 + corr_off, SEEK_SET); dec_size = xan_unpack(s, s->scratch_buffer, s->buffer_size); if (dec_size < 0) dec_size = 0; for (i = 0; i < dec_size; i++) s->y_buffer[i*2+1] = (s->y_buffer[i*2+1] + (s->scratch_buffer[i] << 1)) & 0x3F; } src = s->y_buffer; ybuf = s->pic.data[0]; for (j = 0; j < avctx->height; j++) { for (i = 0; i < avctx->width; i++) ybuf[i] = (src[i] << 2) | (src[i] >> 3); src += avctx->width; ybuf += s->pic.linesize[0]; } return 0; }
1threat
main( int argc, char *argv[] ) { GMainLoop *loop; GIOChannel *channel_stdin; char *qemu_host; char *qemu_port; VCardEmulOptions *command_line_options = NULL; char *cert_names[MAX_CERTS]; char *emul_args = NULL; int cert_count = 0; int c, sock; if (socket_init() != 0) return 1; while ((c = getopt(argc, argv, "c:e:pd:")) != -1) { switch (c) { case 'c': if (cert_count >= MAX_CERTS) { printf("too many certificates (max = %d)\n", MAX_CERTS); exit(5); } cert_names[cert_count++] = optarg; break; case 'e': emul_args = optarg; break; case 'p': print_usage(); exit(4); break; case 'd': verbose = get_id_from_string(optarg, 1); break; } } if (argc - optind != 2) { print_usage(); exit(4); } if (cert_count > 0) { char *new_args; int len, i; if (emul_args == NULL) { emul_args = (char *)"db=\"/etc/pki/nssdb\""; } #define SOFT_STRING ",soft=(,Virtual Reader,CAC,," len = strlen(emul_args) + strlen(SOFT_STRING) + 2; for (i = 0; i < cert_count; i++) { len += strlen(cert_names[i])+1; } new_args = g_malloc(len); strcpy(new_args, emul_args); strcat(new_args, SOFT_STRING); for (i = 0; i < cert_count; i++) { strcat(new_args, cert_names[i]); strcat(new_args, ","); } strcat(new_args, ")"); emul_args = new_args; } if (emul_args) { command_line_options = vcard_emul_options(emul_args); } qemu_host = g_strdup(argv[argc - 2]); qemu_port = g_strdup(argv[argc - 1]); sock = connect_to_qemu(qemu_host, qemu_port); if (sock == -1) { fprintf(stderr, "error opening socket, exiting.\n"); exit(5); } socket_to_send = g_byte_array_new(); qemu_mutex_init(&socket_to_send_lock); qemu_mutex_init(&pending_reader_lock); qemu_cond_init(&pending_reader_condition); vcard_emul_init(command_line_options); loop = g_main_loop_new(NULL, true); printf("> "); fflush(stdout); #ifdef _WIN32 channel_stdin = g_io_channel_win32_new_fd(STDIN_FILENO); #else channel_stdin = g_io_channel_unix_new(STDIN_FILENO); #endif g_io_add_watch(channel_stdin, G_IO_IN, do_command, NULL); #ifdef _WIN32 channel_socket = g_io_channel_win32_new_socket(sock); #else channel_socket = g_io_channel_unix_new(sock); #endif g_io_channel_set_encoding(channel_socket, NULL, NULL); g_io_channel_set_buffered(channel_socket, FALSE); VSCMsgInit init = { .version = htonl(VSCARD_VERSION), .magic = VSCARD_MAGIC, .capabilities = {0} }; send_msg(VSC_Init, 0, &init, sizeof(init)); g_main_loop_run(loop); g_main_loop_unref(loop); g_io_channel_unref(channel_stdin); g_io_channel_unref(channel_socket); g_byte_array_free(socket_to_send, TRUE); closesocket(sock); return 0; }
1threat
C# Invalid expression term 'bool' WPF : Thank you for taking the time to help. I have been working on a application for our help desk team to push out to end users. I would like for these users to be able to add an attachment by using a browse button and eventually by drag and dropping. I have got the email generating, all fields are pulling correctly but the attachment field. I am getting a Invalid expression term 'bool' in my attachment code. Any help would be appreciated. //Attachment button private void Attach_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); if (bool(dlg.ShowDialog)) { string FilePath = dlg.FileName.ToString(); Attachment1.Text = FilePath; } }
0debug
What is the easiest way for a beginner to get their CSS to link to their HTML in atom? : I am very new to coding, but have the basics down for the most part. I recently downloaded Atom and created very simple HTML and CSS files. I used the standard link method (as shown in the code), but cannot seem to get my css to link. My only install thus far has been webBoxio/atom-html-preview. ((HTML)) <!DOCTYPE HTML> <HTML> <body> <link rel="stylesheet" type="text/css" href="mine.css"> <h1>test</h1> <p>test</p> </body> </HTML> ((CSS)) h1, p { font-style: Sans-Serif ; }
0debug
static uint64_t uart_read(void *opaque, target_phys_addr_t addr, unsigned size) { LM32UartState *s = opaque; uint32_t r = 0; addr >>= 2; switch (addr) { case R_RXTX: r = s->regs[R_RXTX]; s->regs[R_LSR] &= ~LSR_DR; uart_update_irq(s); break; case R_IIR: case R_LSR: case R_MSR: r = s->regs[addr]; break; case R_IER: case R_LCR: case R_MCR: case R_DIV: error_report("lm32_uart: read access to write only register 0x" TARGET_FMT_plx, addr << 2); break; default: error_report("lm32_uart: read access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } trace_lm32_uart_memory_read(addr << 2, r); return r; }
1threat
How to detect C# (not CLR) version programmatically? : <p>I use C# for .NET. I know how to programmatically detect CLR version of a .NET assembly, but can’t find out how to programmatically detect the C# version in my code. Anyone has idea? TIA.</p>
0debug
int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, int is_write1, int mmu_idx) { X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; uint64_t ptep, pte; target_ulong pde_addr, pte_addr; int error_code = 0; int is_dirty, prot, page_size, is_write, is_user; hwaddr paddr; uint64_t rsvd_mask = PG_HI_RSVD_MASK; uint32_t page_offset; target_ulong vaddr; is_user = mmu_idx == MMU_USER_IDX; #if defined(DEBUG_MMU) printf("MMU fault: addr=%" VADDR_PRIx " w=%d u=%d eip=" TARGET_FMT_lx "\n", addr, is_write1, is_user, env->eip); #endif is_write = is_write1 & 1; if (!(env->cr[0] & CR0_PG_MASK)) { pte = addr; #ifdef TARGET_X86_64 if (!(env->hflags & HF_LMA_MASK)) { pte = (uint32_t)pte; } #endif prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; page_size = 4096; goto do_mapping; } if (env->cr[4] & CR4_PAE_MASK) { uint64_t pde, pdpe; target_ulong pdpe_addr; #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) { uint64_t pml4e_addr, pml4e; int32_t sext; sext = (int64_t)addr >> 47; if (sext != 0 && sext != -1) { env->error_code = 0; cs->exception_index = EXCP0D_GPF; return 1; } pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) & env->a20_mask; pml4e = ldq_phys(cs->as, pml4e_addr); if (!(pml4e & PG_PRESENT_MASK)) { goto do_fault; } if (pml4e & (rsvd_mask | PG_PSE_MASK)) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pml4e & PG_NX_MASK)) { goto do_fault_rsvd; } if (!(pml4e & PG_ACCESSED_MASK)) { pml4e |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pml4e_addr, pml4e); } ptep = pml4e ^ PG_NX_MASK; pdpe_addr = ((pml4e & PG_ADDRESS_MASK) + (((addr >> 30) & 0x1ff) << 3)) & env->a20_mask; pdpe = ldq_phys(cs->as, pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { goto do_fault; } if (pdpe & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pdpe & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pdpe ^ PG_NX_MASK; if (!(pdpe & PG_ACCESSED_MASK)) { pdpe |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pdpe_addr, pdpe); } if (pdpe & PG_PSE_MASK) { page_size = 1024 * 1024 * 1024; pte_addr = pdpe_addr; pte = pdpe; goto do_check_protect; } } else #endif { pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) & env->a20_mask; pdpe = ldq_phys(cs->as, pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { goto do_fault; } rsvd_mask |= PG_HI_USER_MASK | PG_NX_MASK; if (pdpe & rsvd_mask) { goto do_fault_rsvd; } ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK; } pde_addr = ((pdpe & PG_ADDRESS_MASK) + (((addr >> 21) & 0x1ff) << 3)) & env->a20_mask; pde = ldq_phys(cs->as, pde_addr); if (!(pde & PG_PRESENT_MASK)) { goto do_fault; } if (pde & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pde & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pde ^ PG_NX_MASK; if (pde & PG_PSE_MASK) { page_size = 2048 * 1024; pte_addr = pde_addr; pte = pde; goto do_check_protect; } if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pde_addr, pde); } pte_addr = ((pde & PG_ADDRESS_MASK) + (((addr >> 12) & 0x1ff) << 3)) & env->a20_mask; pte = ldq_phys(cs->as, pte_addr); if (!(pte & PG_PRESENT_MASK)) { goto do_fault; } if (pte & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pte & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pte ^ PG_NX_MASK; page_size = 4096; } else { uint32_t pde; pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) & env->a20_mask; pde = ldl_phys(cs->as, pde_addr); if (!(pde & PG_PRESENT_MASK)) { goto do_fault; } ptep = pde | PG_NX_MASK; if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { page_size = 4096 * 1024; pte_addr = pde_addr; pte = pde; goto do_check_protect; } if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pde_addr, pde); } pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask; pte = ldl_phys(cs->as, pte_addr); if (!(pte & PG_PRESENT_MASK)) { goto do_fault; } ptep &= pte | PG_NX_MASK; page_size = 4096; rsvd_mask = 0; } do_check_protect: if (pte & rsvd_mask) { goto do_fault_rsvd; } ptep ^= PG_NX_MASK; if ((ptep & PG_NX_MASK) && is_write1 == 2) { goto do_fault_protect; } switch (mmu_idx) { case MMU_USER_IDX: if (!(ptep & PG_USER_MASK)) { goto do_fault_protect; } if (is_write && !(ptep & PG_RW_MASK)) { goto do_fault_protect; } break; case MMU_KSMAP_IDX: if (is_write1 != 2 && (ptep & PG_USER_MASK)) { goto do_fault_protect; } case MMU_KNOSMAP_IDX: if (is_write1 == 2 && (env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK)) { goto do_fault_protect; } if ((env->cr[0] & CR0_WP_MASK) && is_write && !(ptep & PG_RW_MASK)) { goto do_fault_protect; } break; default: break; } is_dirty = is_write && !(pte & PG_DIRTY_MASK); if (!(pte & PG_ACCESSED_MASK) || is_dirty) { pte |= PG_ACCESSED_MASK; if (is_dirty) { pte |= PG_DIRTY_MASK; } stl_phys_notdirty(cs->as, pte_addr, pte); } prot = PAGE_READ; if (!(ptep & PG_NX_MASK)) prot |= PAGE_EXEC; if (pte & PG_DIRTY_MASK) { if (is_user) { if (ptep & PG_RW_MASK) prot |= PAGE_WRITE; } else { if (!(env->cr[0] & CR0_WP_MASK) || (ptep & PG_RW_MASK)) prot |= PAGE_WRITE; } } do_mapping: pte = pte & env->a20_mask; pte &= PG_ADDRESS_MASK & ~(page_size - 1); vaddr = addr & TARGET_PAGE_MASK; page_offset = vaddr & (page_size - 1); paddr = pte + page_offset; tlb_set_page(cs, vaddr, paddr, prot, mmu_idx, page_size); return 0; do_fault_rsvd: error_code |= PG_ERROR_RSVD_MASK; do_fault_protect: error_code |= PG_ERROR_P_MASK; do_fault: error_code |= (is_write << PG_ERROR_W_BIT); if (is_user) error_code |= PG_ERROR_U_MASK; if (is_write1 == 2 && (((env->efer & MSR_EFER_NXE) && (env->cr[4] & CR4_PAE_MASK)) || (env->cr[4] & CR4_SMEP_MASK))) error_code |= PG_ERROR_I_D_MASK; if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) { stq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), addr); } else { env->cr[2] = addr; } env->error_code = error_code; cs->exception_index = EXCP0E_PAGE; return 1; }
1threat
Powershell - Assigning an IP address but error : I am setting the IP address but received the following error message: +CategoryInfo: InvalidArgument (.....) (....), CimException +FullyQualifiedErrorId : Windows System Error 87, New-NETIPAddress
0debug
Spring boot does not load logback-spring.xml : <p>I have a sample Spring Boot application that uses Logback for logging. So I have <code>logback-spring.xml</code> next to the jar to configure the logging, however it does not work unless I specify it with <code>logging.config</code>, ex : <code>logging.config=logback-spring.xml</code>.</p> <p>I have looked into <a href="https://stackoverflow.com/questions/43937031/spring-boot-ignoring-logback-spring-xml">Spring Boot ignoring logback-spring.xml</a> where it suggests that it might be because there's already a <code>spring.xml</code> somewhere, but putting breakpoint on <code>org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(LoggingInitializationContext, LogFile)</code> shows that logFile is empty.</p> <p>Am I doing something wrong here ?</p>
0debug
SQL PHP Error: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given : <p>I'm trying to get the number of rows that contain null or empty fields so that if this number of rows is more than or equal to one, the user is prompted with an alert that tells them to complete these record(s), however I'm getting the error mentioned in the title.</p> <p>Code:</p> <pre><code>function incompleteTechLog() { include 'config.php'; // Connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn-&gt;connect_error) { die("Connection failed: " . $conn-&gt;connect_error); } $sql = "SELECT * FROM tbl_flights WHERE pilot_initial_post IS NULL OR = '' AND is_deleted = '0'"; // program allows for soft deleting so this must be included in the query $result = $conn-&gt;query($sql); $rows = mysqli_num_rows($result); if ($rows &gt;= 1) { echo "&lt;div class='alert alert-warning' role='alert'&gt;&lt;strong&gt;Minor Alert! &lt;/strong&gt;" . $rows . " tech log(s) are incomplete. Please check all aircraft tech logs.&lt;/div&gt;"; } else { $conn = null; } } </code></pre> <p>Any help would be greatly appreciated.</p>
0debug
void ff_avg_h264_qpel16_mc00_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avg_width16_msa(src, stride, dst, stride, 16); }
1threat
when to use Classes vs Objects vs Case Classes vs Traits : <p>This is what I understood so far.</p> <p>Classes should be used when we need to instantialte objects</p> <p>We use "Objects" only when we have a singleton requirement meaning no need for multiple instances of "objects". I am thinking when we are building common library functions or utility functions in a project, we can use "objects" that way we need to instantiate each time we use methods/functions in that Object.</p> <p>Case classes can be used when we want to save boilerplate code. Say we have "Stock" class. Each stock in general has hundreds of member variables. Instead of developer writing code for setters and getters, if we case class, it generates lot of default code.</p> <p>Traits: don't know when to use. Both Traits and Objects don't take parameters during initialization.</p> <p>Any more thoughts and ideas kindly share.</p>
0debug
calculate BMI and update BMI Column and update BMI in to range in php mysql : [database view][1] i need to calculate BMI and put that value to catagarize in that into range as( < 18, 18-24.9 ) below shows my quries but it is incorrect my program is in php mysql mysql_query("UPDATE ncd SET BMI =WeightKG/(HightM*HightM)"); mysql_query("UPDATE ncd SET BMIrage =2 WHERE BMI >18 AND BMI <25 "); mysql_query("UPDATE ncd SET BMIrage = 3 WHERE BMI >=25 AND BMI<= 30"); [1]: http://i.stack.imgur.com/D5aWq.png
0debug
When to use routing in Angular? : <p>I started building my first Angular app using routing with unique url for every "main" component. But then I discovered the material and really liked what the tabs are doing. </p> <p>What will be pros and cons of using angular routing together with Angular material when I can just render pages with mat-tab-group like this:</p> <pre><code>&lt;mat-tab-group&gt; &lt;mat-tab label="First"&gt; &lt;app-comp1&gt;&lt;/app-comp1&gt; &lt;/mat-tab&gt; &lt;mat-tab label="Second"&gt; &lt;app-comp2&gt;&lt;/app-comp2&gt; &lt;/mat-tab&gt; &lt;mat-tab label="Third"&gt; &lt;app-comp3&gt;&lt;/app-comp3&gt; &lt;/mat-tab&gt; &lt;/mat-tab-group&gt; </code></pre> <p>In my application I don't need to strictly restrict access to different components views.</p>
0debug
Tilde sign in python dataframe : <p>Im new to python and came across a code snippet.</p> <pre><code>df = df[~df['InvoiceNo'].str.contains('C')] </code></pre> <p>Would be much obliged if I could know whats the tilde signs usage in this context ?</p>
0debug
ptyhon: How to find the index with the same value in three arrays : Data shapes are <i> (675369, 3) ,(675369, 3) ,(670877, 3) </i>. The meaning of axis=1 is the xyz coordinate value. So want to get same xyz value in three arrays. How to find the index with the same value in three arrays
0debug
abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, int flags, int fd, abi_ulong offset) { abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; mmap_lock(); #ifdef DEBUG_MMAP { printf("mmap: start=0x" TARGET_ABI_FMT_lx " len=0x" TARGET_ABI_FMT_lx " prot=%c%c%c flags=", start, len, prot & PROT_READ ? 'r' : '-', prot & PROT_WRITE ? 'w' : '-', prot & PROT_EXEC ? 'x' : '-'); if (flags & MAP_FIXED) printf("MAP_FIXED "); if (flags & MAP_ANONYMOUS) printf("MAP_ANON "); switch(flags & MAP_TYPE) { case MAP_PRIVATE: printf("MAP_PRIVATE "); break; case MAP_SHARED: printf("MAP_SHARED "); break; default: printf("[MAP_TYPE=0x%x] ", flags & MAP_TYPE); break; } printf("fd=%d offset=" TARGET_ABI_FMT_lx "\n", fd, offset); } #endif if (offset & ~TARGET_PAGE_MASK) { errno = EINVAL; goto fail; } len = TARGET_PAGE_ALIGN(len); if (len == 0) goto the_end; real_start = start & qemu_host_page_mask; host_offset = offset & qemu_host_page_mask; if (!(flags & MAP_FIXED)) { host_len = len + offset - host_offset; host_len = HOST_PAGE_ALIGN(host_len); start = mmap_find_vma(real_start, host_len); if (start == (abi_ulong)-1) { errno = ENOMEM; goto fail; } } if ((qemu_real_host_page_size < TARGET_PAGE_SIZE) && !(flags & MAP_ANONYMOUS)) { struct stat sb; if (fstat (fd, &sb) == -1) goto fail; if (offset + len > sb.st_size) { len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset); } } if (!(flags & MAP_FIXED)) { unsigned long host_start; void *p; host_len = len + offset - host_offset; host_len = HOST_PAGE_ALIGN(host_len); p = mmap(g2h(start), host_len, prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) goto fail; host_start = (unsigned long)p; if (!(flags & MAP_ANONYMOUS)) { p = mmap(g2h(start), len, prot, flags | MAP_FIXED, fd, host_offset); if (p == MAP_FAILED) { munmap(g2h(start), host_len); goto fail; } host_start += offset - host_offset; } start = h2g(host_start); } else { if (start & ~TARGET_PAGE_MASK) { errno = EINVAL; goto fail; } end = start + len; real_end = HOST_PAGE_ALIGN(end); if ((unsigned long)start + len - 1 > (abi_ulong) -1) { errno = EINVAL; goto fail; } if (!(flags & MAP_ANONYMOUS) && (offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) { if ((flags & MAP_TYPE) == MAP_SHARED && (prot & PROT_WRITE)) { errno = EINVAL; goto fail; } retaddr = target_mmap(start, len, prot | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (retaddr == -1) goto fail; if (pread(fd, g2h(start), len, offset) == -1) goto fail; if (!(prot & PROT_WRITE)) { ret = target_mprotect(start, len, prot); assert(ret == 0); } goto the_end; } if (start > real_start) { if (real_end == real_start + qemu_host_page_size) { ret = mmap_frag(real_start, start, end, prot, flags, fd, offset); if (ret == -1) goto fail; goto the_end1; } ret = mmap_frag(real_start, start, real_start + qemu_host_page_size, prot, flags, fd, offset); if (ret == -1) goto fail; real_start += qemu_host_page_size; } if (end < real_end) { ret = mmap_frag(real_end - qemu_host_page_size, real_end - qemu_host_page_size, end, prot, flags, fd, offset + real_end - qemu_host_page_size - start); if (ret == -1) goto fail; real_end -= qemu_host_page_size; } if (real_start < real_end) { void *p; unsigned long offset1; if (flags & MAP_ANONYMOUS) offset1 = 0; else offset1 = offset + real_start - start; p = mmap(g2h(real_start), real_end - real_start, prot, flags, fd, offset1); if (p == MAP_FAILED) goto fail; } } the_end1: page_set_flags(start, start + len, prot | PAGE_VALID); the_end: #ifdef DEBUG_MMAP printf("ret=0x" TARGET_ABI_FMT_lx "\n", start); page_dump(stdout); printf("\n"); #endif tb_invalidate_phys_range(start, start + len); mmap_unlock(); return start; fail: mmap_unlock(); return -1; }
1threat
Get count of most common property-value in a list of json-objects : <p>Given data like</p> <pre><code>var data = [ { "a" : "x" ... (other properties) }, { "a" : "x" ... (other properties) }, { "a" : "y" ... (other properties) }, ] </code></pre> <p>The count of the most common "a"-property value would be 2, (for "x").</p> <p>Now, what would be the cleanest way to get this from <code>data</code>?</p> <p>I assume there might be a nice way to generate an array of the different counts, i.e. <code>[ 2 , 1 ]</code> in this case, and then run <code>Math.max(...array)</code> on this?</p> <p>But I can't seem to find a clean way of doing this?</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
Display Vuetify tooltip on disabled button : <p>I am having difficulty displaying a tooltip on a button that is disabled with Vuetify.</p> <p>I've made sure the tooltip can be displayed when the button is enabled, this works as expected. I think that <a href="https://stackoverflow.com/questions/51826891/how-do-i-enable-tooltips-on-a-disabled-text-field-in-vuetify">this question</a> is related, but I'm not well-versed enough to know if this applies to a <code>v-btn</code>. I attempted to create a custom class and add that to the specific <code>v-btn</code> element but I did not have any luck.</p> <h1>Example HTML</h1> <pre class="lang-html prettyprint-override"><code>&lt;div id="app"&gt; &lt;v-app id="inspire"&gt; &lt;v-container fluid class="text-xs-center"&gt; &lt;v-layout flex justify-space-between row wrap &gt; &lt;v-flex xs12&gt; &lt;v-btn @click="show = !show"&gt;toggle&lt;/v-btn&gt; &lt;/v-flex&gt; &lt;v-flex xs12 class="mt-5"&gt; &lt;v-tooltip v-model="show" top&gt; &lt;template v-slot:activator="{ on }"&gt; &lt;v-btn disabled icon v-on="on"&gt; &lt;v-icon color="grey lighten-1"&gt;shopping_cart&lt;/v-icon&gt; &lt;/v-btn&gt; &lt;/template&gt; &lt;span&gt;Programmatic tooltip&lt;/span&gt; &lt;/v-tooltip&gt; &lt;/v-flex&gt; &lt;/v-layout&gt; &lt;/v-container&gt; &lt;/v-app&gt; &lt;/div&gt; </code></pre> <h1>Example JavaScript</h1> <pre><code>new Vue({ el: '#app', data () { return { show: false } } }) </code></pre> <p><a href="https://codepen.io/anon/pen/ZNqpOW?editors=1010" rel="noreferrer">https://codepen.io/anon/pen/ZNqpOW?editors=1010</a></p> <p>I'm expecting that the tooltip can be displayed when hovering over a disabled button. I'm hoping to use this to explain why the button is disabled.</p>
0debug
Why do we need kafka to feed data to apache spark : <p>I am reading about <code>spark</code> and its <code>real-time stream</code> processing.I am confused that If <code>spark</code> can itself read stream from source such as <strong>twitter</strong> or <strong>file</strong>, then Why do we need <code>kafka</code> to feed data to <code>spark</code>? It would be great if someone explains me what advantage we get if we use <code>spark</code> with <code>kafka</code>. Thank you.</p>
0debug
Ember previous/next element of an array : I want to make a queue-like array, and I don't know how to move to the next element. I'm not using a for loop to iterate, because if the element of the array is deleted there is a problem. What Can I do? Greetings, Rafał
0debug
static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { SheepdogAIOCB acb; int ret; int64_t offset = (sector_num + nb_sectors) * BDRV_SECTOR_SIZE; BDRVSheepdogState *s = bs->opaque; if (offset > s->inode.vdi_size) { ret = sd_truncate(bs, offset); if (ret < 0) { return ret; } } sd_aio_setup(&acb, s, qiov, sector_num, nb_sectors, AIOCB_WRITE_UDATA); retry: if (check_overlapping_aiocb(s, &acb)) { qemu_co_queue_wait(&s->overlapping_queue); goto retry; } sd_co_rw_vector(&acb); sd_write_done(&acb); QLIST_REMOVE(&acb, aiocb_siblings); qemu_co_queue_restart_all(&s->overlapping_queue); return acb.ret; }
1threat
In Ruby, what's the advantage of #each_pair over #each when iterating through a hash? : <p>Let's say I want to access the values of a hash like this:</p> <pre><code>munsters = { "Herman" =&gt; { "age" =&gt; 32, "gender" =&gt; "male" }, "Lily" =&gt; { "age" =&gt; 30, "gender" =&gt; "female" }, "Grandpa" =&gt; { "age" =&gt; 402, "gender" =&gt; "male" }, "Eddie" =&gt; { "age" =&gt; 10, "gender" =&gt; "male" }, "Marilyn" =&gt; { "age" =&gt; 23, "gender" =&gt; "female"} } </code></pre> <p>I could use <code>#each</code> with two parameters:</p> <pre><code>munsters.each do |key, value| puts "#{name} is a #{values["age"]}-year-old #{values["gender"]}." end </code></pre> <p>Or I could use <code>#each_pair</code> with two parameters:</p> <pre><code>munsters.each_pair do |key, value| puts "#{name} is a #{values["age"]}-year-old #{values["gender"]}." end </code></pre> <p>Perhaps the difference between the two is not borne out in this simple example, but can someone help me to understand the advantage of using <code>#each_pair</code> over <code>#each</code> ?</p>
0debug
import heapq as hq def heap_sort(iterable): h = [] for value in iterable: hq.heappush(h, value) return [hq.heappop(h) for i in range(len(h))]
0debug
Is there any possibility to pass text between react component tags? : <p>I was wondering if it is possible in react to pass data between two React component tags</p> <p>Example: </p> <p><strong>Component.js</strong></p> <pre><code>var React = require('react'); export class MyComponent extends React.Component { render() { return /*some text*/; } } </code></pre> <p><strong>App.js</strong></p> <pre><code>/*rendered to page*/ &lt;MyComponent&gt;How do I display this text?&lt;/MyComponent&gt; </code></pre> <p>I know I could just add <code>this.props.text</code> but just curious if that's an option</p>
0debug
static always_inline void gen_op_subfo_64 (void) { gen_op_move_T2_T0(); gen_op_subf(); gen_op_check_subfo_64(); }
1threat
Unreachable statment : Please help me. Is this an error or a warning? 1How can i solve this?! Error is that the View v is unreachable statement public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { return super.getView(position, convertView, parent); View v; v = convertView; LayoutInflater li = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = li.inflate(R.layout.custom_layout, null); TextView champ = (TextView)v.findViewById(R.id.textView); TextView year = (TextView)v.findViewById(R.id.textView2); ImageView pic = (ImageView)v.findViewById(R.id.imageView); champ.setText(adaptArray.get(position).getChamp()); year.setText(adaptArray.get(position).getYear()); pic.setImageResource(adaptArray.get(position).getSport()); return v;
0debug