problem
stringlengths
26
131k
labels
class label
2 classes
What are the skills required to work on joomla site : <p>I am developer myself with experience on html/css, bootstrap, javascript, jquery and nodejs. I have never worked with php till now.</p> <p>Is php a essential skill when working with joomla. Can I get it working with javascript instead of php if there is any customization required?</p>
0debug
expo is out of date uninstall and run again to upgrade : <p>when running my app on ios simulator, I am getting the following error <code>This version of the Expo app is out of date. Uninstall the app and run again to upgrade.</code></p> <p>Here is how I tried to upgrade expo-cli yet not successful</p> <ol> <li><p><code>npm update -g</code></p></li> <li><p><code>yarn add global expo-cli</code></p></li> <li><code>npm uninstall expo-cli</code></li> <li><code>npm cache clean --force</code></li> <li><code>yarn add global expo-cli</code></li> </ol> <p>Here is app.json</p> <pre><code>"expo": { "name": "firebase-reacte-native", "slug": "firebase-reacte-native", "privacy": "public", "sdkVersion": "32.0.0", "platforms": [ .... </code></pre> <p>Here is package.json</p> <pre><code>"dependencies": { "expo": "^32.0.0", "react": "16.5.0", "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz" } </code></pre> <p>All I want to do is run ios-simulator without the error message on ios simulator as <code>there was a problem loading the requested app. The experience you requested requires a newer version of the Expo Client app.</code></p>
0debug
Bootstrap4 adding scrollbar to div : <p>I am using <a href="http://v4-alpha.getbootstrap.com/components/navs/#stacked-pills" rel="noreferrer">stacked pills</a> inside a <code>div</code>. The problem is, sometimes the <code>div</code> contains a lot of pills. How can I add a scrollbar for it?</p> <pre><code>&lt;div class="row col-md-2"&gt; &lt;ul class="nav nav-pills nav-stacked"&gt; &lt;li class="nav-item"&gt; &lt;a class="nav-link active" href="#"&gt;Active&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item"&gt; &lt;a class="nav-link" href="#"&gt;Link&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item"&gt; &lt;a class="nav-link" href="#"&gt;Link&lt;/a&gt; &lt;/li&gt; &lt;li class="nav-item"&gt; &lt;a class="nav-link disabled" href="#"&gt;Disabled&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>Can I add a class for the div to make stacked pills scrollable?</p>
0debug
Do I need to complete a Subject for it to be garbage collected? : <p>I follow a cleanup pattern in my Angular components that looks like this:</p> <pre><code>class SomeComponent implements OnInit, OnDestroy { private destroy$ = new Subject(); ngOnInit() { service.someStream().takeUntil(this.destroy$).subscribe(doSomething); } ngOnDestroy() { this.destroy$.next(true); } } </code></pre> <p>This has the benefit of automatically unsubscribing when the component is destroyed.</p> <p>My question is: Does a reference to <code>destroy$</code> stick around indefinitely because I haven't called <code>this.destroy$.complete()</code>, or will it get GC'ed when the parent class is collected?</p>
0debug
int AUD_write (SWVoiceOut *sw, void *buf, int size) { int bytes; if (!sw) { return size; } if (!sw->hw->enabled) { dolog ("Writing to disabled voice %s\n", SW_NAME (sw)); return 0; } bytes = sw->hw->pcm_ops->write (sw, buf, size); return bytes; }
1threat
I am getting a NullPointerException when i run this code : <p>Hi guys i have a NullPointerException when i run this code ,and its pointing on the model = (DefaultTableModel) DbUtils.resultSetToTableModel(rs) , and i have imported the net.proteanit.sql.DbUtils , any ideas ?</p> <pre><code>public void setTableValues(){ try { cn.start(); String sql = "select id,first_name as Firstname,last_name as Lastname,email,phone,description as AllergyInfo from clients where isDeleted=0"; rs = cn.executeSelect(sql); model = (DefaultTableModel) DbUtils.resultSetToTableModel(rs); jTable1.setModel(model); rowSorter = new TableRowSorter&lt;&gt;(jTable1.getModel()); jTable1.setRowSorter(rowSorter); cn.stop(); } catch (SQLException ex) { Logger.getLogger(Clients.class.getName()).log(Level.SEVERE, null, ex); } } </code></pre>
0debug
How it is possible to initialize an array in this form with null values? (Java) : <p>How it is possible to initialize an array in this form with null values in Java?</p> <pre><code>int array[][] = { {1, 6, 4, 1,-1}, {6, 3, 3, 3, 9}, {6, 3, 3, 3, 9}, {6, 3, 3, 3, 9}, {6, 3, 3, 3, 9} }; </code></pre> <p>I tried that, but it doesn't work (is that possible?):</p> <pre><code>int array[][] = { {1, 6, 4, 1,-1}, {6, null, 3, 3, 9}, {6, 3, 3, 3, 9}, {6, 3, 3, null, 9}, {6, 3, 3, 3, 9} }; </code></pre> <p>Thanks</p>
0debug
Interval datatype in Pandas - find midpoint, left, center etc : <p>In pandas 20.1, with the interval type, is it possible to find the midpoint, left or center values in a series.</p> <p><strong>For example:</strong></p> <ol> <li><p>Create an interval datatype column, and perform some aggregation calculations over these intervals: </p> <pre><code>df_Stats = df.groupby(['month',pd.cut(df['Distances'], np.arange(0, 135,1))]).agg(aggregations) </code></pre></li> </ol> <p>This returns df_Stats with an interval column datatype : <code>df['Distances']</code></p> <ol start="2"> <li><p>Now I want to associate the left end of the interval to the result of these aggregations using a series function:</p> <pre><code>df['LeftEnd'] = df['Distances'].left </code></pre></li> </ol> <p>However, I can run this element wise:</p> <pre><code> df.loc[0]['LeftEnd'] = df.loc[0]['Distances'].left </code></pre> <p>This works. Thoughts?</p>
0debug
Web service integration in Java : <p>I have created a web application, now i was asked by my professor to integrate it with another application using a provided web service.Given this is my first time working with web services, i read a lot about it(wsdl,SOAP..). But i still seem to be confused about the concept. I have 2 application mine and another one. The data saved in my application, needs to be saved in the second application, and i am given a wsdl file. I imported the file to eclipse and created the java classes of the wsdl file using Eclipse kepler. What i need is a bit clarification on how the concept in my case works? The same database should be on both sides? What do i need to do? Any help on clarifying this would be much appreciated.</p>
0debug
Javscript - JSON - How to parse an external JSON the correct way : I have an external JSON file 'devices.json'. { "Android":[ {"modell":"Samsung Galaxy S9+", "version":"8.0", "formfactor":"smartphone"}, {"modell":"Google Pixel 2XL", "version":"9.0", "formfactor":"smartphone"}, {"modell":"OnePlus One+", "version":"7.1.1", "formfactor":"smartphone"}, {"modell":"Motorola Moto G (3rd Generation)", "version":"6.0.1", "formfactor":"smartphone"}, {"modell":"Motorola Moto G (1st Generation)", "version":"5.1", "formfactor":"smartphone"}, {"modell":"Phicomm Clue C230", "version":"4.3", "formfactor":"smartphone"}, {"modell":"Huawei MediaPad M3 Lite 8", "version":"7.0", "formfactor":"tablet"}, {"modell":"Xiaomi Mi Pad", "version":"5.1", "formfactor":"tablet"}, {"modell":"Samsung Galaxy Tab 3 (7.0) Lite", "version":"4.2.2", "formfactor":"tablet"}, {"modell":"Amazon Fire Tablet 7 (5th Gen)", "version":"Fire OS 5.3.3", "formfactor":"tablet"} ], "iOS":[ {"modell":"iPhone 7", "version":"12beta", "formfactor":"smartphone"}, {"modell":"iPhone 5s", "version":"11.4.1", "formfactor":"smartphone"}, {"modell":"iPad Air", "version":"11.4.1", "formfactor":"tablet"}, {"modell":"iPad 3", "version":"9.3.5", "formfactor":"tablet"} ], "Windows":[ {"version":"Windows 10"}, {"version":"Windows 8.1"}, {"version":"Windows 7"} ], "macOS":[ {"modell":"Macbook Air", "version":"10.13.5"} ], "Linux":[ {"version":"Mint"}, {"version":"Kubuntu"}, {"version":"elemetaryOS"}, {"version":"openSUSE"}, {"version":"CentOS"}, {"version":"Fedora"}, {"version":"Oracle Linux"}, {"version":"Red Hat"} ] } Now I want to parse this with a button click and have an output like this: > Samsung Galaxy S9+ (Android 8.0), Google Pixel 2XL (Android 9), OnePlus One etc... I don't really know how to parse the JSON the best way. Something like this? <script> function getArray(){ return $.getJSON('devices.json'); } getArray().done( function(json) { console.log(json); // show the json data in console // Android for(var i = 0; i < json.Android.length; i++) { var obj = json.Android[i]; console.log(obj); } // Android for(var i = 0; i < json.iOS.length; i++) { var obj = json.iOS[i]; console.log(obj); } }); </script> Thanks in advance
0debug
Should an oAuth server give the same accessToken to a same client request? : <p>I am developing an oAuth2 server and I've stumbled upon this question.</p> <p>Lets suppose a scenario where my tokens are set to expire within one hour. On this timeframe, some client goes through the implicit auth fifty times using the same <code>client_id</code> and same <code>redirect_uri</code>. Basically same everything.</p> <p>Should I give it the same <code>accessToken</code> generated on the first request on the subsequent ones until it expires or should I issue a new <code>accessToken</code> on every request?</p> <p>The benefits of sending the same token is that I won't leave stale and unused tokens of a client on the server, minimizing the window for an attacker trying to guess a valid token.</p> <p>I know that I should rate-limit things and I am doing it, but in the case of a large botnet attack from thousands of different machines, some limits won't take effect immediately.</p> <p>However, I am not sure about the downsides of this solution and that's why I came here. Is it a valid solution?</p>
0debug
polling envelope status in docusign using webhooks and c# : <p>I was reading about polling to get the status changes for a Docusign envelope. The article mentioned Webhooks, but gave very few code examples, and the examples were in Python and PHP. </p> <p>I would like to find out how to use Webhooks in c#.</p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Confused about how rounding floats work : **I'm trying to round the value that I gain through 'GetFloat()' (say .478 to .48) and then use it in the if statements but i'm somewhat confused regarding rounding floats and such. Will i also need to cast it to an int? I'd greatly appreciate any help you can give with my code.** ---------- #include <stdio.h> #include <math.h> int main(void) { //declared variables float change; int num = 0; float change_r; // prompts for amount owed { printf("Please provide the amount owed: "); change = GetFloat() * 100; while (change > 0) float change_r = roundf(change); } { // if statements for calculating number of coins required if (change >= 25) { change = change - 25; num ++; } if (change >= 10 && change < 25) { change = change - 10; num ++; } if (change >= 5 && change < 10) { change = change - 5; num ++; } if (change >= 1 && change < 5) { change = change - 1; num ++; } } printf("%d\n", num); }
0debug
C# Winform: Setting the file save location : <p>My program must produce files from some given data. I'm dealing with PDFs and Excel documents. How do I allow the user to set the directory where the files will be saved? I'm not referring to <code>SaveFileDialog</code> where the user must choose the directory every time. I want the files to automatically be saved to the directory previously specified by the user. Something to this effect:</p> <p><a href="https://i.stack.imgur.com/BDSXE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BDSXE.png" alt="YTD"></a></p> <p>Most immediate solution I can think of is to store the directory in a file and read it every time a file is to be saved.</p> <p>I also read about <a href="https://stackoverflow.com/questions/5789252/properties-settings-default-save-where-is-that-file">Properties.Settings.Default.Save()</a>, but is it relevant to my case? </p>
0debug
static int wavpack_decode_block(AVCodecContext *avctx, int block_no, void *data, int *data_size, const uint8_t *buf, int buf_size) { WavpackContext *wc = avctx->priv_data; WavpackFrameContext *s; void *samples = data; int samplecount; int got_terms = 0, got_weights = 0, got_samples = 0, got_entropy = 0, got_bs = 0, got_float = 0; int got_hybrid = 0; const uint8_t* orig_buf = buf; const uint8_t* buf_end = buf + buf_size; int i, j, id, size, ssize, weights, t; int bpp, chan, chmask; if (buf_size == 0){ *data_size = 0; return 0; } if(block_no >= wc->fdec_num && wv_alloc_frame_context(wc) < 0){ av_log(avctx, AV_LOG_ERROR, "Error creating frame decode context\n"); return -1; } s = wc->fdec[block_no]; if(!s){ av_log(avctx, AV_LOG_ERROR, "Context for block %d is not present\n", block_no); return -1; } if(!s->samples_left){ memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr)); memset(s->ch, 0, sizeof(s->ch)); s->extra_bits = 0; s->and = s->or = s->shift = 0; s->got_extra_bits = 0; } if(!wc->mkv_mode){ s->samples = AV_RL32(buf); buf += 4; if(!s->samples){ *data_size = 0; return 0; } }else{ s->samples = wc->samples; } s->frame_flags = AV_RL32(buf); buf += 4; if(s->frame_flags&0x80){ bpp = sizeof(float); avctx->sample_fmt = AV_SAMPLE_FMT_FLT; } else if((s->frame_flags&0x03) <= 1){ bpp = 2; avctx->sample_fmt = AV_SAMPLE_FMT_S16; } else { bpp = 4; avctx->sample_fmt = AV_SAMPLE_FMT_S32; } samples = (uint8_t*)samples + bpp * wc->ch_offset; s->stereo = !(s->frame_flags & WV_MONO); s->stereo_in = (s->frame_flags & WV_FALSE_STEREO) ? 0 : s->stereo; s->joint = s->frame_flags & WV_JOINT_STEREO; s->hybrid = s->frame_flags & WV_HYBRID_MODE; s->hybrid_bitrate = s->frame_flags & WV_HYBRID_BITRATE; s->post_shift = 8 * (bpp-1-(s->frame_flags&0x03)) + ((s->frame_flags >> 13) & 0x1f); s->CRC = AV_RL32(buf); buf += 4; if(wc->mkv_mode) buf += 4; wc->ch_offset += 1 + s->stereo; s->max_samples = *data_size / (bpp * avctx->channels); s->max_samples = FFMIN(s->max_samples, s->samples); if(s->samples_left > 0){ s->max_samples = FFMIN(s->max_samples, s->samples_left); buf = buf_end; } while(buf < buf_end){ id = *buf++; size = *buf++; if(id & WP_IDF_LONG) { size |= (*buf++) << 8; size |= (*buf++) << 16; } size <<= 1; ssize = size; if(id & WP_IDF_ODD) size--; if(size < 0){ av_log(avctx, AV_LOG_ERROR, "Got incorrect block %02X with size %i\n", id, size); break; } if(buf + ssize > buf_end){ av_log(avctx, AV_LOG_ERROR, "Block size %i is out of bounds\n", size); break; } if(id & WP_IDF_IGNORE){ buf += ssize; continue; } switch(id & WP_IDF_MASK){ case WP_ID_DECTERMS: s->terms = size; if(s->terms > MAX_TERMS){ av_log(avctx, AV_LOG_ERROR, "Too many decorrelation terms\n"); buf += ssize; continue; } for(i = 0; i < s->terms; i++) { s->decorr[s->terms - i - 1].value = (*buf & 0x1F) - 5; s->decorr[s->terms - i - 1].delta = *buf >> 5; buf++; } got_terms = 1; break; case WP_ID_DECWEIGHTS: if(!got_terms){ av_log(avctx, AV_LOG_ERROR, "No decorrelation terms met\n"); continue; } weights = size >> s->stereo_in; if(weights > MAX_TERMS || weights > s->terms){ av_log(avctx, AV_LOG_ERROR, "Too many decorrelation weights\n"); buf += ssize; continue; } for(i = 0; i < weights; i++) { t = (int8_t)(*buf++); s->decorr[s->terms - i - 1].weightA = t << 3; if(s->decorr[s->terms - i - 1].weightA > 0) s->decorr[s->terms - i - 1].weightA += (s->decorr[s->terms - i - 1].weightA + 64) >> 7; if(s->stereo_in){ t = (int8_t)(*buf++); s->decorr[s->terms - i - 1].weightB = t << 3; if(s->decorr[s->terms - i - 1].weightB > 0) s->decorr[s->terms - i - 1].weightB += (s->decorr[s->terms - i - 1].weightB + 64) >> 7; } } got_weights = 1; break; case WP_ID_DECSAMPLES: if(!got_terms){ av_log(avctx, AV_LOG_ERROR, "No decorrelation terms met\n"); continue; } t = 0; for(i = s->terms - 1; (i >= 0) && (t < size); i--) { if(s->decorr[i].value > 8){ s->decorr[i].samplesA[0] = wp_exp2(AV_RL16(buf)); buf += 2; s->decorr[i].samplesA[1] = wp_exp2(AV_RL16(buf)); buf += 2; if(s->stereo_in){ s->decorr[i].samplesB[0] = wp_exp2(AV_RL16(buf)); buf += 2; s->decorr[i].samplesB[1] = wp_exp2(AV_RL16(buf)); buf += 2; t += 4; } t += 4; }else if(s->decorr[i].value < 0){ s->decorr[i].samplesA[0] = wp_exp2(AV_RL16(buf)); buf += 2; s->decorr[i].samplesB[0] = wp_exp2(AV_RL16(buf)); buf += 2; t += 4; }else{ for(j = 0; j < s->decorr[i].value; j++){ s->decorr[i].samplesA[j] = wp_exp2(AV_RL16(buf)); buf += 2; if(s->stereo_in){ s->decorr[i].samplesB[j] = wp_exp2(AV_RL16(buf)); buf += 2; } } t += s->decorr[i].value * 2 * (s->stereo_in + 1); } } got_samples = 1; break; case WP_ID_ENTROPY: if(size != 6 * (s->stereo_in + 1)){ av_log(avctx, AV_LOG_ERROR, "Entropy vars size should be %i, got %i", 6 * (s->stereo_in + 1), size); buf += ssize; continue; } for(j = 0; j <= s->stereo_in; j++){ for(i = 0; i < 3; i++){ s->ch[j].median[i] = wp_exp2(AV_RL16(buf)); buf += 2; } } got_entropy = 1; break; case WP_ID_HYBRID: if(s->hybrid_bitrate){ for(i = 0; i <= s->stereo_in; i++){ s->ch[i].slow_level = wp_exp2(AV_RL16(buf)); buf += 2; size -= 2; } } for(i = 0; i < (s->stereo_in + 1); i++){ s->ch[i].bitrate_acc = AV_RL16(buf) << 16; buf += 2; size -= 2; } if(size > 0){ for(i = 0; i < (s->stereo_in + 1); i++){ s->ch[i].bitrate_delta = wp_exp2((int16_t)AV_RL16(buf)); buf += 2; } }else{ for(i = 0; i < (s->stereo_in + 1); i++) s->ch[i].bitrate_delta = 0; } got_hybrid = 1; break; case WP_ID_INT32INFO: if(size != 4){ av_log(avctx, AV_LOG_ERROR, "Invalid INT32INFO, size = %i, sent_bits = %i\n", size, *buf); buf += ssize; continue; } if(buf[0]) s->extra_bits = buf[0]; else if(buf[1]) s->shift = buf[1]; else if(buf[2]){ s->and = s->or = 1; s->shift = buf[2]; }else if(buf[3]){ s->and = 1; s->shift = buf[3]; } buf += 4; break; case WP_ID_FLOATINFO: if(size != 4){ av_log(avctx, AV_LOG_ERROR, "Invalid FLOATINFO, size = %i\n", size); buf += ssize; continue; } s->float_flag = buf[0]; s->float_shift = buf[1]; s->float_max_exp = buf[2]; buf += 4; got_float = 1; break; case WP_ID_DATA: s->sc.offset = buf - orig_buf; s->sc.size = size * 8; init_get_bits(&s->gb, buf, size * 8); s->data_size = size * 8; buf += size; got_bs = 1; break; case WP_ID_EXTRABITS: if(size <= 4){ av_log(avctx, AV_LOG_ERROR, "Invalid EXTRABITS, size = %i\n", size); buf += size; continue; } s->extra_sc.offset = buf - orig_buf; s->extra_sc.size = size * 8; init_get_bits(&s->gb_extra_bits, buf, size * 8); s->crc_extra_bits = get_bits_long(&s->gb_extra_bits, 32); buf += size; s->got_extra_bits = 1; break; case WP_ID_CHANINFO: if(size <= 1){ av_log(avctx, AV_LOG_ERROR, "Insufficient channel information\n"); return -1; } chan = *buf++; switch(size - 2){ case 0: chmask = *buf; break; case 1: chmask = AV_RL16(buf); break; case 2: chmask = AV_RL24(buf); break; case 3: chmask = AV_RL32(buf); break; case 5: chan |= (buf[1] & 0xF) << 8; chmask = AV_RL24(buf + 2); break; default: av_log(avctx, AV_LOG_ERROR, "Invalid channel info size %d\n", size); chan = avctx->channels; chmask = avctx->channel_layout; } if(chan != avctx->channels){ av_log(avctx, AV_LOG_ERROR, "Block reports total %d channels, decoder believes it's %d channels\n", chan, avctx->channels); return -1; } if(!avctx->channel_layout) avctx->channel_layout = chmask; buf += size - 1; break; default: buf += size; } if(id & WP_IDF_ODD) buf++; } if(!s->samples_left){ if(!got_terms){ av_log(avctx, AV_LOG_ERROR, "No block with decorrelation terms\n"); return -1; } if(!got_weights){ av_log(avctx, AV_LOG_ERROR, "No block with decorrelation weights\n"); return -1; } if(!got_samples){ av_log(avctx, AV_LOG_ERROR, "No block with decorrelation samples\n"); return -1; } if(!got_entropy){ av_log(avctx, AV_LOG_ERROR, "No block with entropy info\n"); return -1; } if(s->hybrid && !got_hybrid){ av_log(avctx, AV_LOG_ERROR, "Hybrid config not found\n"); return -1; } if(!got_bs){ av_log(avctx, AV_LOG_ERROR, "Packed samples not found\n"); return -1; } if(!got_float && avctx->sample_fmt == AV_SAMPLE_FMT_FLT){ av_log(avctx, AV_LOG_ERROR, "Float information not found\n"); return -1; } if(s->got_extra_bits && avctx->sample_fmt != AV_SAMPLE_FMT_FLT){ const int size = get_bits_left(&s->gb_extra_bits); const int wanted = s->samples * s->extra_bits << s->stereo_in; if(size < wanted){ av_log(avctx, AV_LOG_ERROR, "Too small EXTRABITS\n"); s->got_extra_bits = 0; } } s->samples_left = s->samples; }else{ init_get_bits(&s->gb, orig_buf + s->sc.offset, s->sc.size); skip_bits_long(&s->gb, s->sc.bits_used); if(s->got_extra_bits){ init_get_bits(&s->gb_extra_bits, orig_buf + s->extra_sc.offset, s->extra_sc.size); skip_bits_long(&s->gb_extra_bits, s->extra_sc.bits_used); } } if(s->stereo_in){ if(avctx->sample_fmt == AV_SAMPLE_FMT_S16) samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S16); else if(avctx->sample_fmt == AV_SAMPLE_FMT_S32) samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S32); else samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_FLT); samplecount >>= 1; }else{ const int channel_stride = avctx->channels; if(avctx->sample_fmt == AV_SAMPLE_FMT_S16) samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_S16); else if(avctx->sample_fmt == AV_SAMPLE_FMT_S32) samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_S32); else samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_FLT); if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S16){ int16_t *dst = (int16_t*)samples + 1; int16_t *src = (int16_t*)samples; int cnt = samplecount; while(cnt--){ *dst = *src; src += channel_stride; dst += channel_stride; } }else if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S32){ int32_t *dst = (int32_t*)samples + 1; int32_t *src = (int32_t*)samples; int cnt = samplecount; while(cnt--){ *dst = *src; src += channel_stride; dst += channel_stride; } }else if(s->stereo){ float *dst = (float*)samples + 1; float *src = (float*)samples; int cnt = samplecount; while(cnt--){ *dst = *src; src += channel_stride; dst += channel_stride; } } } wc->samples_left = s->samples_left; return samplecount * bpp; }
1threat
Best user role permissions database design practice? : <p>I want to design database for a web app in which user can access particular tabs based on the permissions given to a role.</p> <p>What I have done so far is I created two tables <strong>USER_TABLE</strong> and <strong>USER_ROLES</strong>.</p> <p><strong>USER_TABLE</strong> has below fields:</p> <ul> <li>id (primary key)</li> <li>user_name</li> <li>password</li> <li>first_name</li> <li>last_name </li> <li>created_date</li> <li>role_id_fk (foreign key)</li> </ul> <p><strong>USER_ROLES</strong> has below fields:</p> <ul> <li><p>id (primary key)</p></li> <li><p>role_name (e.g. ADMIN, TAB1_USER, TAB2_USER)</p></li> <li><p>created_date</p></li> </ul> <p>Here, the user having role_name "<strong>ADMIN</strong>" can see all the tabs, other users can access specific tabs only. </p> <p>My question is do I need to create a table <strong>USER_PERMISSIONS</strong> having foreign key in <strong>USER_ROLES</strong> table with below fields:</p> <ul> <li>id (primary key)</li> <li>permission_type (ALL, TAB1, TAB2....)</li> </ul> <p>or should I manage this at my code level? What would be the cons and pros of both approaches?</p>
0debug
static void do_video_stats(AVOutputStream *ost, AVInputStream *ist, int frame_size) { static FILE *fvstats=NULL; static INT64 total_size = 0; struct tm *today; time_t today2; char filename[40]; AVCodecContext *enc; int frame_number; INT64 ti; double ti1, bitrate, avg_bitrate; if (!fvstats) { today2 = time(NULL); today = localtime(&today2); sprintf(filename, "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min, today->tm_sec); fvstats = fopen(filename,"w"); if (!fvstats) { perror("fopen"); exit(1); } } ti = MAXINT64; enc = &ost->st->codec; total_size += frame_size; if (enc->codec_type == CODEC_TYPE_VIDEO) { frame_number = ist->frame_number; fprintf(fvstats, "frame= %5d q= %2d ", frame_number, enc->quality); if (do_psnr) fprintf(fvstats, "PSNR= %6.2f ", enc->psnr_y); fprintf(fvstats,"f_size= %6d ", frame_size); if (!ist->discard && ist->pts < ti) { ti = ist->pts; } ti1 = (double)ti / 1000000.0; if (ti1 < 0.01) ti1 = 0.01; bitrate = (double)(frame_size * 8) * enc->frame_rate / FRAME_RATE_BASE / 1000.0; avg_bitrate = (double)(total_size * 8) / ti1 / 1000.0; fprintf(fvstats, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", (double)total_size / 1024, ti1, bitrate, avg_bitrate); fprintf(fvstats,"type= %s\n", enc->key_frame == 1 ? "I" : "P"); } }
1threat
static void ehci_port_test(struct qhc *hc, int port, uint32_t expect) { void *addr = hc->base + 0x64 + 4 * port; uint32_t value = qpci_io_readl(hc->dev, addr); uint16_t mask = ~(PORTSC_CSC | PORTSC_PEDC | PORTSC_OCC); #if 0 fprintf(stderr, "%s: %d, have 0x%08x, want 0x%08x\n", __func__, port, value & mask, expect & mask); #endif g_assert((value & mask) == (expect & mask)); }
1threat
static void *ff_realloc_static(void *ptr, unsigned int size) { int i; if(!ptr) return av_mallocz_static(size); for(i = 0; i < last_static; i++) { if(array_static[i] == ptr) { array_static[i] = av_realloc(array_static[i], size); return array_static[i]; } } return NULL; }
1threat
load rtf file into UITextView in Swift 2 : <p>Can somebody help me to load an rtf text into UITextView with Swift 2? The answers I've gotten are old and out of date. The text is instructions on how to play the game I'm writing in an app. So far, all I've been able to do is to copy and paste all the rtf text into the placeholder box. This works for iPhones in the simulator, but when trying it in the iPad simulator or iPhone 6 Plus there appears double vertical scroll bars when I do this. It looks messy.</p> <p>I also now have a real plain text of the same file, so we can try that too.</p>
0debug
void tcg_gen_brcondi_i64(TCGCond cond, TCGv_i64 arg1, int64_t arg2, int label) { if (cond == TCG_COND_ALWAYS) { tcg_gen_br(label); } else if (cond != TCG_COND_NEVER) { TCGv_i64 t0 = tcg_const_i64(arg2); tcg_gen_brcond_i64(cond, arg1, t0, label); tcg_temp_free_i64(t0); } }
1threat
void dsputil_init(DSPContext* c, AVCodecContext *avctx) { int i; ff_check_alignment(); #if CONFIG_ENCODERS if(avctx->dct_algo==FF_DCT_FASTINT) { c->fdct = fdct_ifast; c->fdct248 = fdct_ifast248; } else if(avctx->dct_algo==FF_DCT_FAAN) { c->fdct = ff_faandct; c->fdct248 = ff_faandct248; } else { c->fdct = ff_jpeg_fdct_islow; c->fdct248 = ff_fdct248_islow; } #endif if(avctx->lowres==1){ if(avctx->idct_algo==FF_IDCT_INT || avctx->idct_algo==FF_IDCT_AUTO || !CONFIG_H264_DECODER){ c->idct_put= ff_jref_idct4_put; c->idct_add= ff_jref_idct4_add; }else{ c->idct_put= ff_h264_lowres_idct_put_c; c->idct_add= ff_h264_lowres_idct_add_c; } c->idct = j_rev_dct4; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(avctx->lowres==2){ c->idct_put= ff_jref_idct2_put; c->idct_add= ff_jref_idct2_add; c->idct = j_rev_dct2; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(avctx->lowres==3){ c->idct_put= ff_jref_idct1_put; c->idct_add= ff_jref_idct1_add; c->idct = j_rev_dct1; c->idct_permutation_type= FF_NO_IDCT_PERM; }else{ if(avctx->idct_algo==FF_IDCT_INT){ c->idct_put= ff_jref_idct_put; c->idct_add= ff_jref_idct_add; c->idct = j_rev_dct; c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; }else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER ) && avctx->idct_algo==FF_IDCT_VP3){ c->idct_put= ff_vp3_idct_put_c; c->idct_add= ff_vp3_idct_add_c; c->idct = ff_vp3_idct_c; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(avctx->idct_algo==FF_IDCT_WMV2){ c->idct_put= ff_wmv2_idct_put_c; c->idct_add= ff_wmv2_idct_add_c; c->idct = ff_wmv2_idct_c; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(avctx->idct_algo==FF_IDCT_FAAN){ c->idct_put= ff_faanidct_put; c->idct_add= ff_faanidct_add; c->idct = ff_faanidct; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) { c->idct_put= ff_ea_idct_put_c; c->idct_permutation_type= FF_NO_IDCT_PERM; }else{ c->idct_put= ff_simple_idct_put; c->idct_add= ff_simple_idct_add; c->idct = ff_simple_idct; c->idct_permutation_type= FF_NO_IDCT_PERM; } } if (CONFIG_H264_DECODER) { c->h264_idct_add= ff_h264_idct_add_c; c->h264_idct8_add= ff_h264_idct8_add_c; c->h264_idct_dc_add= ff_h264_idct_dc_add_c; c->h264_idct8_dc_add= ff_h264_idct8_dc_add_c; c->h264_idct_add16 = ff_h264_idct_add16_c; c->h264_idct8_add4 = ff_h264_idct8_add4_c; c->h264_idct_add8 = ff_h264_idct_add8_c; c->h264_idct_add16intra= ff_h264_idct_add16intra_c; } c->get_pixels = get_pixels_c; c->diff_pixels = diff_pixels_c; c->put_pixels_clamped = put_pixels_clamped_c; c->put_signed_pixels_clamped = put_signed_pixels_clamped_c; c->add_pixels_clamped = add_pixels_clamped_c; c->add_pixels8 = add_pixels8_c; c->add_pixels4 = add_pixels4_c; c->sum_abs_dctelem = sum_abs_dctelem_c; c->gmc1 = gmc1_c; c->gmc = ff_gmc_c; c->clear_block = clear_block_c; c->clear_blocks = clear_blocks_c; c->pix_sum = pix_sum_c; c->pix_norm1 = pix_norm1_c; c->pix_abs[0][0] = pix_abs16_c; c->pix_abs[0][1] = pix_abs16_x2_c; c->pix_abs[0][2] = pix_abs16_y2_c; c->pix_abs[0][3] = pix_abs16_xy2_c; c->pix_abs[1][0] = pix_abs8_c; c->pix_abs[1][1] = pix_abs8_x2_c; c->pix_abs[1][2] = pix_abs8_y2_c; c->pix_abs[1][3] = pix_abs8_xy2_c; #define dspfunc(PFX, IDX, NUM) \ c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## NUM ## _c; \ c->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## NUM ## _x2_c; \ c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## NUM ## _y2_c; \ c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## NUM ## _xy2_c dspfunc(put, 0, 16); dspfunc(put_no_rnd, 0, 16); dspfunc(put, 1, 8); dspfunc(put_no_rnd, 1, 8); dspfunc(put, 2, 4); dspfunc(put, 3, 2); dspfunc(avg, 0, 16); dspfunc(avg_no_rnd, 0, 16); dspfunc(avg, 1, 8); dspfunc(avg_no_rnd, 1, 8); dspfunc(avg, 2, 4); dspfunc(avg, 3, 2); #undef dspfunc c->put_no_rnd_pixels_l2[0]= put_no_rnd_pixels16_l2_c; c->put_no_rnd_pixels_l2[1]= put_no_rnd_pixels8_l2_c; c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c; c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c; c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c; c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c; c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c; c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c; c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c; c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c; c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c; c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c; c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c; c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c; c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c; c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c; c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c; c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c; c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c; c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c; #define dspfunc(PFX, IDX, NUM) \ c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \ c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \ c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \ c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \ c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \ c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \ c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \ c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \ c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \ c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \ c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \ c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \ c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \ c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \ c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \ c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c dspfunc(put_qpel, 0, 16); dspfunc(put_no_rnd_qpel, 0, 16); dspfunc(avg_qpel, 0, 16); dspfunc(put_qpel, 1, 8); dspfunc(put_no_rnd_qpel, 1, 8); dspfunc(avg_qpel, 1, 8); dspfunc(put_h264_qpel, 0, 16); dspfunc(put_h264_qpel, 1, 8); dspfunc(put_h264_qpel, 2, 4); dspfunc(put_h264_qpel, 3, 2); dspfunc(avg_h264_qpel, 0, 16); dspfunc(avg_h264_qpel, 1, 8); dspfunc(avg_h264_qpel, 2, 4); #undef dspfunc c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_c; c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_c; c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_c; c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c; c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c; c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c; c->put_no_rnd_vc1_chroma_pixels_tab[0]= put_no_rnd_vc1_chroma_mc8_c; c->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_no_rnd_vc1_chroma_mc8_c; c->weight_h264_pixels_tab[0]= weight_h264_pixels16x16_c; c->weight_h264_pixels_tab[1]= weight_h264_pixels16x8_c; c->weight_h264_pixels_tab[2]= weight_h264_pixels8x16_c; c->weight_h264_pixels_tab[3]= weight_h264_pixels8x8_c; c->weight_h264_pixels_tab[4]= weight_h264_pixels8x4_c; c->weight_h264_pixels_tab[5]= weight_h264_pixels4x8_c; c->weight_h264_pixels_tab[6]= weight_h264_pixels4x4_c; c->weight_h264_pixels_tab[7]= weight_h264_pixels4x2_c; c->weight_h264_pixels_tab[8]= weight_h264_pixels2x4_c; c->weight_h264_pixels_tab[9]= weight_h264_pixels2x2_c; c->biweight_h264_pixels_tab[0]= biweight_h264_pixels16x16_c; c->biweight_h264_pixels_tab[1]= biweight_h264_pixels16x8_c; c->biweight_h264_pixels_tab[2]= biweight_h264_pixels8x16_c; c->biweight_h264_pixels_tab[3]= biweight_h264_pixels8x8_c; c->biweight_h264_pixels_tab[4]= biweight_h264_pixels8x4_c; c->biweight_h264_pixels_tab[5]= biweight_h264_pixels4x8_c; c->biweight_h264_pixels_tab[6]= biweight_h264_pixels4x4_c; c->biweight_h264_pixels_tab[7]= biweight_h264_pixels4x2_c; c->biweight_h264_pixels_tab[8]= biweight_h264_pixels2x4_c; c->biweight_h264_pixels_tab[9]= biweight_h264_pixels2x2_c; c->draw_edges = draw_edges_c; #if CONFIG_CAVS_DECODER ff_cavsdsp_init(c,avctx); #endif #if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER ff_mlp_init(c, avctx); #endif #if CONFIG_VC1_DECODER || CONFIG_WMV3_DECODER ff_vc1dsp_init(c,avctx); #endif #if CONFIG_WMV2_DECODER || CONFIG_VC1_DECODER || CONFIG_WMV3_DECODER ff_intrax8dsp_init(c,avctx); #endif #if CONFIG_RV30_DECODER ff_rv30dsp_init(c,avctx); #endif #if CONFIG_RV40_DECODER ff_rv40dsp_init(c,avctx); c->put_rv40_qpel_pixels_tab[0][15] = put_rv40_qpel16_mc33_c; c->avg_rv40_qpel_pixels_tab[0][15] = avg_rv40_qpel16_mc33_c; c->put_rv40_qpel_pixels_tab[1][15] = put_rv40_qpel8_mc33_c; c->avg_rv40_qpel_pixels_tab[1][15] = avg_rv40_qpel8_mc33_c; #endif c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c; c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c; c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c; c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c; c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c; c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c; c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c; c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c; #define SET_CMP_FUNC(name) \ c->name[0]= name ## 16_c;\ c->name[1]= name ## 8x8_c; SET_CMP_FUNC(hadamard8_diff) c->hadamard8_diff[4]= hadamard8_intra16_c; c->hadamard8_diff[5]= hadamard8_intra8x8_c; SET_CMP_FUNC(dct_sad) SET_CMP_FUNC(dct_max) #if CONFIG_GPL SET_CMP_FUNC(dct264_sad) #endif c->sad[0]= pix_abs16_c; c->sad[1]= pix_abs8_c; c->sse[0]= sse16_c; c->sse[1]= sse8_c; c->sse[2]= sse4_c; SET_CMP_FUNC(quant_psnr) SET_CMP_FUNC(rd) SET_CMP_FUNC(bit) c->vsad[0]= vsad16_c; c->vsad[4]= vsad_intra16_c; c->vsad[5]= vsad_intra8_c; c->vsse[0]= vsse16_c; c->vsse[4]= vsse_intra16_c; c->vsse[5]= vsse_intra8_c; c->nsse[0]= nsse16_c; c->nsse[1]= nsse8_c; #if CONFIG_SNOW_ENCODER c->w53[0]= w53_16_c; c->w53[1]= w53_8_c; c->w97[0]= w97_16_c; c->w97[1]= w97_8_c; #endif c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c; c->add_bytes= add_bytes_c; c->add_bytes_l2= add_bytes_l2_c; c->diff_bytes= diff_bytes_c; c->add_hfyu_median_prediction= add_hfyu_median_prediction_c; c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c; c->bswap_buf= bswap_buf; #if CONFIG_PNG_DECODER c->add_png_paeth_prediction= ff_add_png_paeth_prediction; #endif c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_c; c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_c; c->h264_v_loop_filter_luma_intra= h264_v_loop_filter_luma_intra_c; c->h264_h_loop_filter_luma_intra= h264_h_loop_filter_luma_intra_c; c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_c; c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_c; c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_c; c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_c; c->h264_loop_filter_strength= NULL; if (CONFIG_ANY_H263) { c->h263_h_loop_filter= h263_h_loop_filter_c; c->h263_v_loop_filter= h263_v_loop_filter_c; } if (CONFIG_VP3_DECODER) { c->vp3_h_loop_filter= ff_vp3_h_loop_filter_c; c->vp3_v_loop_filter= ff_vp3_v_loop_filter_c; } if (CONFIG_VP6_DECODER) { c->vp6_filter_diag4= ff_vp6_filter_diag4_c; } c->h261_loop_filter= h261_loop_filter_c; c->try_8x8basis= try_8x8basis_c; c->add_8x8basis= add_8x8basis_c; #if CONFIG_SNOW_DECODER c->vertical_compose97i = ff_snow_vertical_compose97i; c->horizontal_compose97i = ff_snow_horizontal_compose97i; c->inner_add_yblock = ff_snow_inner_add_yblock; #endif #if CONFIG_VORBIS_DECODER c->vorbis_inverse_coupling = vorbis_inverse_coupling; #endif #if CONFIG_AC3_DECODER c->ac3_downmix = ff_ac3_downmix_c; #endif #if CONFIG_FLAC_ENCODER c->flac_compute_autocorr = ff_flac_compute_autocorr; #endif c->vector_fmul = vector_fmul_c; c->vector_fmul_reverse = vector_fmul_reverse_c; c->vector_fmul_add_add = ff_vector_fmul_add_add_c; c->vector_fmul_window = ff_vector_fmul_window_c; c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c; c->float_to_int16 = ff_float_to_int16_c; c->float_to_int16_interleave = ff_float_to_int16_interleave_c; c->add_int16 = add_int16_c; c->sub_int16 = sub_int16_c; c->scalarproduct_int16 = scalarproduct_int16_c; c->shrink[0]= ff_img_copy_plane; c->shrink[1]= ff_shrink22; c->shrink[2]= ff_shrink44; c->shrink[3]= ff_shrink88; c->prefetch= just_return; memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab)); memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab)); if (HAVE_MMX) dsputil_init_mmx (c, avctx); if (ARCH_ARM) dsputil_init_arm (c, avctx); if (CONFIG_MLIB) dsputil_init_mlib (c, avctx); if (HAVE_VIS) dsputil_init_vis (c, avctx); if (ARCH_ALPHA) dsputil_init_alpha (c, avctx); if (ARCH_PPC) dsputil_init_ppc (c, avctx); if (HAVE_MMI) dsputil_init_mmi (c, avctx); if (ARCH_SH4) dsputil_init_sh4 (c, avctx); if (ARCH_BFIN) dsputil_init_bfin (c, avctx); for(i=0; i<64; i++){ if(!c->put_2tap_qpel_pixels_tab[0][i]) c->put_2tap_qpel_pixels_tab[0][i]= c->put_h264_qpel_pixels_tab[0][i]; if(!c->avg_2tap_qpel_pixels_tab[0][i]) c->avg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i]; } switch(c->idct_permutation_type){ case FF_NO_IDCT_PERM: for(i=0; i<64; i++) c->idct_permutation[i]= i; break; case FF_LIBMPEG2_IDCT_PERM: for(i=0; i<64; i++) c->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2); break; case FF_SIMPLE_IDCT_PERM: for(i=0; i<64; i++) c->idct_permutation[i]= simple_mmx_permutation[i]; break; case FF_TRANSPOSE_IDCT_PERM: for(i=0; i<64; i++) c->idct_permutation[i]= ((i&7)<<3) | (i>>3); break; case FF_PARTTRANS_IDCT_PERM: for(i=0; i<64; i++) c->idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3); break; case FF_SSE2_IDCT_PERM: for(i=0; i<64; i++) c->idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7]; break; default: av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n"); } }
1threat
How to run a js file? : <p>I'm trying to get all links of the articles of one blog ( <a href="https://www.mrmoneymustache.com" rel="nofollow noreferrer">https://www.mrmoneymustache.com</a> ) so I can compile them into a pdf, but i'm a complete noob in javascript. Somebody on reddit told me to use this code, which is supposed to do what I want :</p> <pre><code>const fs = require('fs'); const EventEmitter = require('events').EventEmitter; const fetch = require('node-fetch'); const cheerio = require('cheerio'); const e = new EventEmitter(); e.on('fetchPage', link =&gt; { fetch(link).then(r =&gt; r.text()).then(cheerio.load).then($ =&gt; { const nextLink = $(".next_post a").attr('href'); if (nextLink === undefined) return; // end on final page const postTitle = $(".headline").text(); const postContent = $(".post_content").html(); console.log(postTitle); fs.writeFileSync(postTitle + ".html", postContent); setTimeout(() =&gt; e.emit('fetchPage', nextLink), 5000); }); }); e.emit('fetchPage', 'https://whatever/post1'); </code></pre> <p>But I dont really get how I am supposed to run this program.. Help please ?</p>
0debug
New to Python ! reading data from txt file : def main(): file_output=open(r'C:\Users\P\Desktop\randominput.txt','r') for num in file_output: number=file_output.read() print(number) main() output: 48 85 58 16 11 82 Actual data in the txt file is 53 48 85 58 16 11 82 Why is my python program not reading the first number??
0debug
static int vc1test_write_header(AVFormatContext *s) { AVCodecContext *avc = s->streams[0]->codec; AVIOContext *pb = s->pb; if (avc->codec_id != CODEC_ID_WMV3) { av_log(s, AV_LOG_ERROR, "Only WMV3 is accepted!\n"); return -1; } avio_wl24(pb, 0); avio_w8(pb, 0xC5); avio_wl32(pb, 4); avio_write(pb, avc->extradata, 4); avio_wl32(pb, avc->height); avio_wl32(pb, avc->width); avio_wl32(pb, 0xC); avio_wl24(pb, 0); avio_w8(pb, 0x80); avio_wl32(pb, 0); if (s->streams[0]->r_frame_rate.den && s->streams[0]->r_frame_rate.num == 1) avio_wl32(pb, s->streams[0]->r_frame_rate.den); else avio_wl32(pb, 0xFFFFFFFF); avpriv_set_pts_info(s->streams[0], 32, 1, 1000); return 0; }
1threat
While Running C program on X-Code this is what it is showing up in error - Thread 1: EXC_BAD_ACCESS (code=1, address=0x68) : [This is Exactly what XCode is showing when I'm running the code.][1] [1]: https://i.stack.imgur.com/lXjq3.jpg ` #include <stdio.h> int main() { FILE *f1; char c; printf("Data Input\n\n"); f1 = fopen("/Users/karanjeetsinghbagga/Desktop/File Management in C/Fille Management in C/INPUT.txt", "W"); while((c=getchar())!= EOF) putc(c,f1); fclose(f1); printf("\nData Output\n\n"); f1 = fopen("/Users/karanjeetsinghbagga/Desktop/File Management in C/Fille Management in C/INPUT.txt", "R"); while((c=getchar()) !=EOF) printf("%c",c); fclose(f1); return 0; }` *This is the code which I was writing And it is directly copied from E.Balagurusamy Programming in Ansi C. I tried even creating a text file and putting it in the source folder of the code also changed the execution folder for the code but it is not running and when the same code is being run using terminal it is showing -* ***Segmentation fault: 11*** please help me with this and do consider that I am a beginner in ***X-Code, MacOS, and coding in C***.
0debug
static void ohci_reset(OHCIState *ohci) { OHCIPort *port; int i; ohci->ctl = 0; ohci->old_ctl = 0; ohci->status = 0; ohci->intr_status = 0; ohci->intr = OHCI_INTR_MIE; ohci->hcca = 0; ohci->ctrl_head = ohci->ctrl_cur = 0; ohci->bulk_head = ohci->bulk_cur = 0; ohci->per_cur = 0; ohci->done = 0; ohci->done_count = 7; ohci->fsmps = 0x2778; ohci->fi = 0x2edf; ohci->fit = 0; ohci->frt = 0; ohci->frame_number = 0; ohci->pstart = 0; ohci->lst = OHCI_LS_THRESH; ohci->rhdesc_a = OHCI_RHA_NPS | ohci->num_ports; ohci->rhdesc_b = 0x0; ohci->rhstatus = 0; for (i = 0; i < ohci->num_ports; i++) { port = &ohci->rhport[i]; port->ctrl = 0; if (port->port.dev) ohci_attach(&port->port, port->port.dev); } if (ohci->async_td) { usb_cancel_packet(&ohci->usb_packet); ohci->async_td = 0; } dprintf("usb-ohci: Reset %s\n", ohci->name); }
1threat
static int migration_rate_limit(void *opaque) { MigrationState *s = opaque; int ret; ret = qemu_file_get_error(s->file); if (ret) { return ret; } if (s->bytes_xfer >= s->xfer_limit) { return 1; } return 0; }
1threat
INSERTING VALUES ATOMATICALLY TO A COLUMN : I have a requirement there are 3 columns in a SQL server table, the columns are starttime, endtime, journeytime while inserting table values I enter starttime, endtime column values the 3rd column values will be generated from endtime -starttime. how it's possible while creating a table. Can anyone help on this THANKS
0debug
static target_ulong get_sigframe(struct target_sigaction *ka, CPUPPCState *env, int frame_size) { target_ulong oldsp, newsp; oldsp = env->gpr[1]; if ((ka->sa_flags & TARGET_SA_ONSTACK) && (sas_ss_flags(oldsp))) { oldsp = (target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size); } newsp = (oldsp - frame_size) & ~0xFUL; return newsp; }
1threat
static int disas_vfp_insn(CPUState * env, DisasContext *s, uint32_t insn) { uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask; int dp, veclen; TCGv addr; TCGv tmp; TCGv tmp2; if (!arm_feature(env, ARM_FEATURE_VFP)) return 1; if (!vfp_enabled(env)) { if ((insn & 0x0fe00fff) != 0x0ee00a10) return 1; rn = (insn >> 16) & 0xf; if (rn != ARM_VFP_FPSID && rn != ARM_VFP_FPEXC && rn != ARM_VFP_MVFR1 && rn != ARM_VFP_MVFR0) return 1; } dp = ((insn & 0xf00) == 0xb00); switch ((insn >> 24) & 0xf) { case 0xe: if (insn & (1 << 4)) { rd = (insn >> 12) & 0xf; if (dp) { int size; int pass; VFP_DREG_N(rn, insn); if (insn & 0xf) return 1; if (insn & 0x00c00060 && !arm_feature(env, ARM_FEATURE_NEON)) return 1; pass = (insn >> 21) & 1; if (insn & (1 << 22)) { size = 0; offset = ((insn >> 5) & 3) * 8; } else if (insn & (1 << 5)) { size = 1; offset = (insn & (1 << 6)) ? 16 : 0; } else { size = 2; offset = 0; } if (insn & ARM_CP_RW_BIT) { tmp = neon_load_reg(rn, pass); switch (size) { case 0: if (offset) tcg_gen_shri_i32(tmp, tmp, offset); if (insn & (1 << 23)) gen_uxtb(tmp); else gen_sxtb(tmp); break; case 1: if (insn & (1 << 23)) { if (offset) { tcg_gen_shri_i32(tmp, tmp, 16); } else { gen_uxth(tmp); } } else { if (offset) { tcg_gen_sari_i32(tmp, tmp, 16); } else { gen_sxth(tmp); } } break; case 2: break; } store_reg(s, rd, tmp); } else { tmp = load_reg(s, rd); if (insn & (1 << 23)) { if (size == 0) { gen_neon_dup_u8(tmp, 0); } else if (size == 1) { gen_neon_dup_low16(tmp); } for (n = 0; n <= pass * 2; n++) { tmp2 = new_tmp(); tcg_gen_mov_i32(tmp2, tmp); neon_store_reg(rn, n, tmp2); } neon_store_reg(rn, n, tmp); } else { switch (size) { case 0: tmp2 = neon_load_reg(rn, pass); gen_bfi(tmp, tmp2, tmp, offset, 0xff); dead_tmp(tmp2); break; case 1: tmp2 = neon_load_reg(rn, pass); gen_bfi(tmp, tmp2, tmp, offset, 0xffff); dead_tmp(tmp2); break; case 2: break; } neon_store_reg(rn, pass, tmp); } } } else { if ((insn & 0x6f) != 0x00) return 1; rn = VFP_SREG_N(insn); if (insn & ARM_CP_RW_BIT) { if (insn & (1 << 21)) { rn >>= 1; switch (rn) { case ARM_VFP_FPSID: if (IS_USER(s) && arm_feature(env, ARM_FEATURE_VFP3)) return 1; tmp = load_cpu_field(vfp.xregs[rn]); break; case ARM_VFP_FPEXC: if (IS_USER(s)) return 1; tmp = load_cpu_field(vfp.xregs[rn]); break; case ARM_VFP_FPINST: case ARM_VFP_FPINST2: if (IS_USER(s) || arm_feature(env, ARM_FEATURE_VFP3)) return 1; tmp = load_cpu_field(vfp.xregs[rn]); break; case ARM_VFP_FPSCR: if (rd == 15) { tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); tcg_gen_andi_i32(tmp, tmp, 0xf0000000); } else { tmp = new_tmp(); gen_helper_vfp_get_fpscr(tmp, cpu_env); } break; case ARM_VFP_MVFR0: case ARM_VFP_MVFR1: if (IS_USER(s) || !arm_feature(env, ARM_FEATURE_VFP3)) return 1; tmp = load_cpu_field(vfp.xregs[rn]); break; default: return 1; } } else { gen_mov_F0_vreg(0, rn); tmp = gen_vfp_mrs(); } if (rd == 15) { gen_set_nzcv(tmp); dead_tmp(tmp); } else { store_reg(s, rd, tmp); } } else { tmp = load_reg(s, rd); if (insn & (1 << 21)) { rn >>= 1; switch (rn) { case ARM_VFP_FPSID: case ARM_VFP_MVFR0: case ARM_VFP_MVFR1: break; case ARM_VFP_FPSCR: gen_helper_vfp_set_fpscr(cpu_env, tmp); dead_tmp(tmp); gen_lookup_tb(s); break; case ARM_VFP_FPEXC: if (IS_USER(s)) return 1; store_cpu_field(tmp, vfp.xregs[rn]); gen_lookup_tb(s); break; case ARM_VFP_FPINST: case ARM_VFP_FPINST2: store_cpu_field(tmp, vfp.xregs[rn]); break; default: return 1; } } else { gen_vfp_msr(tmp); gen_mov_vreg_F0(0, rn); } } } } else { op = ((insn >> 20) & 8) | ((insn >> 19) & 6) | ((insn >> 6) & 1); if (dp) { if (op == 15) { rn = ((insn >> 15) & 0x1e) | ((insn >> 7) & 1); } else { VFP_DREG_N(rn, insn); } if (op == 15 && (rn == 15 || rn > 17)) { rd = VFP_SREG_D(insn); } else { VFP_DREG_D(rd, insn); } if (op == 15 && (rn == 16 || rn == 17)) { rm = ((insn << 1) & 0x1e) | ((insn >> 5) & 1); } else { VFP_DREG_M(rm, insn); } } else { rn = VFP_SREG_N(insn); if (op == 15 && rn == 15) { VFP_DREG_D(rd, insn); } else { rd = VFP_SREG_D(insn); } rm = VFP_SREG_M(insn); } veclen = env->vfp.vec_len; if (op == 15 && rn > 3) veclen = 0; delta_m = 0; delta_d = 0; bank_mask = 0; if (veclen > 0) { if (dp) bank_mask = 0xc; else bank_mask = 0x18; if ((rd & bank_mask) == 0) { veclen = 0; } else { if (dp) delta_d = (env->vfp.vec_stride >> 1) + 1; else delta_d = env->vfp.vec_stride + 1; if ((rm & bank_mask) == 0) { delta_m = 0; } else { delta_m = delta_d; } } } if (op == 15) { switch (rn) { case 16: case 17: gen_mov_F0_vreg(0, rm); break; case 8: case 9: gen_mov_F0_vreg(dp, rd); gen_mov_F1_vreg(dp, rm); break; case 10: case 11: gen_mov_F0_vreg(dp, rd); gen_vfp_F1_ld0(dp); break; case 20: case 21: case 22: case 23: case 28: case 29: case 30: case 31: gen_mov_F0_vreg(dp, rd); break; default: gen_mov_F0_vreg(dp, rm); break; } } else { gen_mov_F0_vreg(dp, rn); gen_mov_F1_vreg(dp, rm); } for (;;) { switch (op) { case 0: gen_vfp_mul(dp); gen_mov_F1_vreg(dp, rd); gen_vfp_add(dp); break; case 1: gen_vfp_mul(dp); gen_vfp_neg(dp); gen_mov_F1_vreg(dp, rd); gen_vfp_add(dp); break; case 2: gen_vfp_mul(dp); gen_mov_F1_vreg(dp, rd); gen_vfp_sub(dp); break; case 3: gen_vfp_mul(dp); gen_vfp_neg(dp); gen_mov_F1_vreg(dp, rd); gen_vfp_sub(dp); break; case 4: gen_vfp_mul(dp); break; case 5: gen_vfp_mul(dp); gen_vfp_neg(dp); break; case 6: gen_vfp_add(dp); break; case 7: gen_vfp_sub(dp); break; case 8: gen_vfp_div(dp); break; case 14: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; n = (insn << 12) & 0x80000000; i = ((insn >> 12) & 0x70) | (insn & 0xf); if (dp) { if (i & 0x40) i |= 0x3f80; else i |= 0x4000; n |= i << 16; tcg_gen_movi_i64(cpu_F0d, ((uint64_t)n) << 32); } else { if (i & 0x40) i |= 0x780; else i |= 0x800; n |= i << 19; tcg_gen_movi_i32(cpu_F0s, n); } break; case 15: switch (rn) { case 0: break; case 1: gen_vfp_abs(dp); break; case 2: gen_vfp_neg(dp); break; case 3: gen_vfp_sqrt(dp); break; case 8: gen_vfp_cmp(dp); break; case 9: gen_vfp_cmpe(dp); break; case 10: gen_vfp_cmp(dp); break; case 11: gen_vfp_F1_ld0(dp); gen_vfp_cmpe(dp); break; case 15: if (dp) gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env); else gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env); break; case 16: gen_vfp_uito(dp); break; case 17: gen_vfp_sito(dp); break; case 20: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_shto(dp, 16 - rm); break; case 21: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_slto(dp, 32 - rm); break; case 22: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_uhto(dp, 16 - rm); break; case 23: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_ulto(dp, 32 - rm); break; case 24: gen_vfp_toui(dp); break; case 25: gen_vfp_touiz(dp); break; case 26: gen_vfp_tosi(dp); break; case 27: gen_vfp_tosiz(dp); break; case 28: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_tosh(dp, 16 - rm); break; case 29: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_tosl(dp, 32 - rm); break; case 30: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_touh(dp, 16 - rm); break; case 31: if (!arm_feature(env, ARM_FEATURE_VFP3)) return 1; gen_vfp_toul(dp, 32 - rm); break; default: printf ("rn:%d\n", rn); return 1; } break; default: printf ("op:%d\n", op); return 1; } if (op == 15 && (rn >= 8 && rn <= 11)) ; else if (op == 15 && rn > 17) gen_mov_vreg_F0(0, rd); else if (op == 15 && rn == 15) gen_mov_vreg_F0(!dp, rd); else gen_mov_vreg_F0(dp, rd); if (veclen == 0) break; if (op == 15 && delta_m == 0) { while (veclen--) { rd = ((rd + delta_d) & (bank_mask - 1)) | (rd & bank_mask); gen_mov_vreg_F0(dp, rd); } break; } veclen--; rd = ((rd + delta_d) & (bank_mask - 1)) | (rd & bank_mask); if (op == 15) { rm = ((rm + delta_m) & (bank_mask - 1)) | (rm & bank_mask); gen_mov_F0_vreg(dp, rm); } else { rn = ((rn + delta_d) & (bank_mask - 1)) | (rn & bank_mask); gen_mov_F0_vreg(dp, rn); if (delta_m) { rm = ((rm + delta_m) & (bank_mask - 1)) | (rm & bank_mask); gen_mov_F1_vreg(dp, rm); } } } } break; case 0xc: case 0xd: if (dp && (insn & 0x03e00000) == 0x00400000) { rn = (insn >> 16) & 0xf; rd = (insn >> 12) & 0xf; if (dp) { VFP_DREG_M(rm, insn); } else { rm = VFP_SREG_M(insn); } if (insn & ARM_CP_RW_BIT) { if (dp) { gen_mov_F0_vreg(0, rm * 2); tmp = gen_vfp_mrs(); store_reg(s, rd, tmp); gen_mov_F0_vreg(0, rm * 2 + 1); tmp = gen_vfp_mrs(); store_reg(s, rn, tmp); } else { gen_mov_F0_vreg(0, rm); tmp = gen_vfp_mrs(); store_reg(s, rn, tmp); gen_mov_F0_vreg(0, rm + 1); tmp = gen_vfp_mrs(); store_reg(s, rd, tmp); } } else { if (dp) { tmp = load_reg(s, rd); gen_vfp_msr(tmp); gen_mov_vreg_F0(0, rm * 2); tmp = load_reg(s, rn); gen_vfp_msr(tmp); gen_mov_vreg_F0(0, rm * 2 + 1); } else { tmp = load_reg(s, rn); gen_vfp_msr(tmp); gen_mov_vreg_F0(0, rm); tmp = load_reg(s, rd); gen_vfp_msr(tmp); gen_mov_vreg_F0(0, rm + 1); } } } else { rn = (insn >> 16) & 0xf; if (dp) VFP_DREG_D(rd, insn); else rd = VFP_SREG_D(insn); if (s->thumb && rn == 15) { addr = new_tmp(); tcg_gen_movi_i32(addr, s->pc & ~2); } else { addr = load_reg(s, rn); } if ((insn & 0x01200000) == 0x01000000) { offset = (insn & 0xff) << 2; if ((insn & (1 << 23)) == 0) offset = -offset; tcg_gen_addi_i32(addr, addr, offset); if (insn & (1 << 20)) { gen_vfp_ld(s, dp, addr); gen_mov_vreg_F0(dp, rd); } else { gen_mov_F0_vreg(dp, rd); gen_vfp_st(s, dp, addr); } dead_tmp(addr); } else { if (dp) n = (insn >> 1) & 0x7f; else n = insn & 0xff; if (insn & (1 << 24)) tcg_gen_addi_i32(addr, addr, -((insn & 0xff) << 2)); if (dp) offset = 8; else offset = 4; for (i = 0; i < n; i++) { if (insn & ARM_CP_RW_BIT) { gen_vfp_ld(s, dp, addr); gen_mov_vreg_F0(dp, rd + i); } else { gen_mov_F0_vreg(dp, rd + i); gen_vfp_st(s, dp, addr); } tcg_gen_addi_i32(addr, addr, offset); } if (insn & (1 << 21)) { if (insn & (1 << 24)) offset = -offset * n; else if (dp && (insn & 1)) offset = 4; else offset = 0; if (offset != 0) tcg_gen_addi_i32(addr, addr, offset); store_reg(s, rn, addr); } else { dead_tmp(addr); } } } break; default: return 1; } return 0; }
1threat
static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid) { char desc[DESC_SIZE], tmp_desc[DESC_SIZE]; char *p_name, *tmp_str; if (bdrv_pread(bs->file, 0x200, desc, DESC_SIZE) != DESC_SIZE) return -1; tmp_str = strstr(desc,"parentCID"); pstrcpy(tmp_desc, sizeof(tmp_desc), tmp_str); if ((p_name = strstr(desc,"CID")) != NULL) { p_name += sizeof("CID"); snprintf(p_name, sizeof(desc) - (p_name - desc), "%x\n", cid); pstrcat(desc, sizeof(desc), tmp_desc); } if (bdrv_pwrite(bs->file, 0x200, desc, DESC_SIZE) != DESC_SIZE) return -1; return 0; }
1threat
What trait / concept can guarantee memsetting an object is well defined? : <p>Let's say I have defined a <code>zero_initialize()</code> function:</p> <pre><code>template&lt;class T&gt; T zero_initialize() { T result; std::memset(&amp;result, 0, sizeof(result)); return result; } // usage: auto data = zero_initialize&lt;Data&gt;(); </code></pre> <p>Calling <code>zero_initialize()</code> for some types would lead to undefined behavior<sup>1, </sup><sup>2</sup>. I'm currently enforcing <code>T</code> to verify <a href="https://en.cppreference.com/w/cpp/types/is_pod" rel="noreferrer"><code>std::is_pod</code></a>. With that trait being deprecated in C++20 and the coming of concepts, I'm curious how <code>zero_initialize()</code> should evolve.</p> <ol> <li>What (minimal) trait / concept can guarantee memsetting an object is well defined?</li> <li>Should I use <a href="https://en.cppreference.com/w/cpp/memory/uninitialized_fill" rel="noreferrer"><code>std::uninitialized_fill</code></a> instead of <code>std::memset</code>? And why?</li> <li>Is this function made obsolete by one of C++ initialization syntaxes for a subset of types? Or will it be with the upcoming of future C++ versions?</li> </ol> <hr> <p><sup>1)</sup> <a href="https://stackoverflow.com/a/499078/5470596">Erase all members of a class</a>.<br> <sup>2)</sup> <a href="https://stackoverflow.com/a/30980240/5470596">What would be reason for “undefined behaviors” upon using memset on library class(std::string)? [closed]</a></p>
0debug
Flex layout not working on angular 5 : <p>I'm trying to use flex-layout on angular 5 but it's not working.</p> <p>This is my environment:</p> <pre><code> _ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | | / ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | | /_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___| |___/ Angular CLI: 1.6.1 Node: 9.3.0 OS: darwin x64 Angular: 5.1.3 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router @angular/cdk: 5.0.3 @angular/cli: 1.6.1 @angular/flex-layout: 2.0.0-beta.12-67e4bf5 @angular/material: 5.0.3 @angular-devkit/build-optimizer: 0.0.36 @angular-devkit/core: 0.0.22 @angular-devkit/schematics: 0.0.42 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.9.1 @schematics/angular: 0.1.11 @schematics/schematics: 0.0.11 typescript: 2.4.2 webpack: 3.10.0 </code></pre> <p>This is the import in app.module.ts:</p> <pre><code>import {FlexLayoutModule} from "@angular/flex-layout"; @NgModule({ imports: [ BrowserModule, HttpClientModule, AppRoutingModule, FormsModule, ReactiveFormsModule, MaterialModule, SocialLoginModule, FlexLayoutModule ], </code></pre> <p>No error on compilation.</p> <p>This is a test on a template:</p> <pre><code>&lt;div class="container" fxLayout fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="10px" fxLayoutGap.xs="0"&gt; &lt;div class="item item-1" fxFlex="15%"&gt;Item 1&lt;/div&gt; &lt;div class="item item-2" fxFlex="20%" fxFlexOrder="3"&gt;Item 2&lt;/div&gt; &lt;div class="item item-3" fxFlex&gt;Item 3&lt;/div&gt; &lt;/div&gt; &lt;div class="container" fxLayout fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="10px" fxLayoutGap.xs="0"&gt; &lt;div class="item item-4" fxFlex fxFlexOffset="50px" fxFlexOffset.xs="0"&gt;Item 4&lt;/div&gt; &lt;div class="item item-5" fxFlex="200px"&gt;Item 5&lt;/div&gt; &lt;/div&gt; </code></pre> <p>This is the result (not what expected):</p> <p><a href="https://i.stack.imgur.com/0FiIi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0FiIi.png" alt="enter image description here"></a></p>
0debug
List into text file python : I'm a beginner at python and I wanna ask how to make an array into a text file without the '[""]' because I can already make it into a text file but it appeares with the [""]. Thanks. entries =[] studentID =raw_input("Student ID: ") subjectChoose = raw_input("Subject Code: ") entries.append(subjectChoose) p = open(entries + '.txt' , 'w') p.write(str(studentID) + "\n" ) p.close() f = open(studentID + '.txt', 'w') f.write(str(entries) + "\n ") f.close()
0debug
void pci_register_vga(PCIDevice *pci_dev, MemoryRegion *mem, MemoryRegion *io_lo, MemoryRegion *io_hi) { assert(!pci_dev->has_vga); assert(memory_region_size(mem) == QEMU_PCI_VGA_MEM_SIZE); pci_dev->vga_regions[QEMU_PCI_VGA_MEM] = mem; memory_region_add_subregion_overlap(pci_dev->bus->address_space_mem, QEMU_PCI_VGA_MEM_BASE, mem, 1); assert(memory_region_size(io_lo) == QEMU_PCI_VGA_IO_LO_SIZE); pci_dev->vga_regions[QEMU_PCI_VGA_IO_LO] = io_lo; memory_region_add_subregion_overlap(pci_dev->bus->address_space_io, QEMU_PCI_VGA_IO_LO_BASE, io_lo, 1); assert(memory_region_size(io_hi) == QEMU_PCI_VGA_IO_HI_SIZE); pci_dev->vga_regions[QEMU_PCI_VGA_IO_HI] = io_hi; memory_region_add_subregion_overlap(pci_dev->bus->address_space_io, QEMU_PCI_VGA_IO_HI_BASE, io_hi, 1); pci_dev->has_vga = true; pci_update_vga(pci_dev); }
1threat
static int adx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { int buf_size = avpkt->size; ADXContext *c = avctx->priv_data; int16_t *samples; const uint8_t *buf = avpkt->data; int num_blocks, ch, ret; if (c->eof) { *got_frame_ptr = 0; return buf_size; } if (!c->header_parsed && buf_size >= 2 && AV_RB16(buf) == 0x8000) { int header_size; if ((ret = avpriv_adx_decode_header(avctx, buf, buf_size, &header_size, c->coeff)) < 0) { av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n"); return AVERROR_INVALIDDATA; } c->channels = avctx->channels; c->header_parsed = 1; if (buf_size < header_size) return AVERROR_INVALIDDATA; buf += header_size; buf_size -= header_size; } if (!c->header_parsed) return AVERROR_INVALIDDATA; num_blocks = buf_size / (BLOCK_SIZE * c->channels); if (!num_blocks || buf_size % (BLOCK_SIZE * avctx->channels)) { if (buf_size >= 4 && (AV_RB16(buf) & 0x8000)) { c->eof = 1; *got_frame_ptr = 0; return avpkt->size; } return AVERROR_INVALIDDATA; } c->frame.nb_samples = num_blocks * BLOCK_SAMPLES; if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } samples = (int16_t *)c->frame.data[0]; while (num_blocks--) { for (ch = 0; ch < c->channels; ch++) { if (adx_decode(c, samples + ch, buf, ch)) { c->eof = 1; buf = avpkt->data + avpkt->size; break; } buf_size -= BLOCK_SIZE; buf += BLOCK_SIZE; } samples += BLOCK_SAMPLES * c->channels; } *got_frame_ptr = 1; *(AVFrame *)data = c->frame; return buf - avpkt->data; }
1threat
Can someone explain these lines of Laravel code? : <p>I am completely new to Laravel and I have been given a project I need to edit. So I have been tracing through the project trying to understand what it is doing. I have read a lot of the docs and I have run across something I don't fully understand.</p> <p>Can someone help explain these lines of code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>$account = Account::find($account_id); $settings = $account-&gt;accountSettings;</code></pre> </div> </div> </p> <p>So specifically the: <code>Account::find($account_id);</code> and the <code>$account-&gt;accountSettings;</code></p> <p>Obviously, you aren't going to know what the variables contain and stuff, I am not asking for that. I am asking strictly for understanding WHAT is happening specifically.</p> <p>Thanks in advanced.</p>
0debug
How to change this date format of this '13/11/2017' : <p>Msg 242, Level 16, State 3, Line 1 The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.</p>
0debug
static int handle_primary_tcp_pkt(NetFilterState *nf, Connection *conn, Packet *pkt) { struct tcphdr *tcp_pkt; tcp_pkt = (struct tcphdr *)pkt->transport_header; if (trace_event_get_state(TRACE_COLO_FILTER_REWRITER_DEBUG)) { trace_colo_filter_rewriter_pkt_info(__func__, inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst), ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack), tcp_pkt->th_flags); trace_colo_filter_rewriter_conn_offset(conn->offset); } if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_SYN)) { conn->syn_flag = 1; } if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_ACK)) { if (conn->syn_flag) { conn->offset -= (ntohl(tcp_pkt->th_ack) - 1); conn->syn_flag = 0; } tcp_pkt->th_ack = htonl(ntohl(tcp_pkt->th_ack) + conn->offset); net_checksum_calculate((uint8_t *)pkt->data, pkt->size); } return 0; }
1threat
static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, uint32_t code_prefix, int n_prefix) { int i, j, k, n, table_size, table_index, nb, n1, index; uint32_t code; VLC_TYPE (*table)[2]; table_size = 1 << table_nb_bits; table_index = alloc_table(vlc, table_size); #ifdef DEBUG_VLC printf("new table index=%d size=%d code_prefix=%x n=%d\n", table_index, table_size, code_prefix, n_prefix); #endif if (table_index < 0) return -1; table = &vlc->table[table_index]; for(i=0;i<table_size;i++) { table[i][1] = 0; table[i][0] = -1; } for(i=0;i<nb_codes;i++) { GET_DATA(n, bits, i, bits_wrap, bits_size); GET_DATA(code, codes, i, codes_wrap, codes_size); if (n <= 0) continue; #if defined(DEBUG_VLC) && 0 printf("i=%d n=%d code=0x%x\n", i, n, code); #endif n -= n_prefix; if (n > 0 && (code >> n) == code_prefix) { if (n <= table_nb_bits) { j = (code << (table_nb_bits - n)) & (table_size - 1); nb = 1 << (table_nb_bits - n); for(k=0;k<nb;k++) { #ifdef DEBUG_VLC av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n", j, i, n); #endif if (table[j][1] != 0) { av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); return -1; } table[j][1] = n; table[j][0] = i; j++; } } else { n -= table_nb_bits; j = (code >> n) & ((1 << table_nb_bits) - 1); #ifdef DEBUG_VLC printf("%4x: n=%d (subtable)\n", j, n); #endif n1 = -table[j][1]; if (n > n1) n1 = n; table[j][1] = -n1; } } } for(i=0;i<table_size;i++) { n = table[i][1]; if (n < 0) { n = -n; if (n > table_nb_bits) { n = table_nb_bits; table[i][1] = -n; } index = build_table(vlc, n, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, (code_prefix << table_nb_bits) | i, n_prefix + table_nb_bits); if (index < 0) return -1; table = &vlc->table[table_index]; table[i][0] = index; } } return table_index; }
1threat
static void test_io_channel_command_fifo(bool async) { #define TEST_FIFO "tests/test-io-channel-command.fifo" QIOChannel *src, *dst; QIOChannelTest *test; char *srcfifo = g_strdup_printf("PIPE:%s,wronly", TEST_FIFO); char *dstfifo = g_strdup_printf("PIPE:%s,rdonly", TEST_FIFO); const char *srcargv[] = { "/bin/socat", "-", srcfifo, NULL, }; const char *dstargv[] = { "/bin/socat", dstfifo, "-", NULL, }; unlink(TEST_FIFO); if (access("/bin/socat", X_OK) < 0) { return; } if (mkfifo(TEST_FIFO, 0600) < 0) { abort(); } src = QIO_CHANNEL(qio_channel_command_new_spawn(srcargv, O_WRONLY, &error_abort)); dst = QIO_CHANNEL(qio_channel_command_new_spawn(dstargv, O_RDONLY, &error_abort)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, async, src, dst); qio_channel_test_validate(test); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); g_free(srcfifo); g_free(dstfifo); unlink(TEST_FIFO); }
1threat
Show an activity indicator at the end of a ListView in React-Native : <p>Looking for a way to append an activity indicator to the end of a ListView when the user has reached the end and the app is querying for more data from a server. I can add the indicator after the ListView but then it always show up.</p>
0debug
static int cpudef_setfield(const char *name, const char *str, void *opaque) { x86_def_t *def = opaque; int err = 0; if (!strcmp(name, "name")) { def->name = g_strdup(str); } else if (!strcmp(name, "model_id")) { strncpy(def->model_id, str, sizeof (def->model_id)); } else if (!strcmp(name, "level")) { setscalar(&def->level, str, &err) } else if (!strcmp(name, "vendor")) { cpyid(&str[0], &def->vendor1); cpyid(&str[4], &def->vendor2); cpyid(&str[8], &def->vendor3); } else if (!strcmp(name, "family")) { setscalar(&def->family, str, &err) } else if (!strcmp(name, "model")) { setscalar(&def->model, str, &err) } else if (!strcmp(name, "stepping")) { setscalar(&def->stepping, str, &err) } else if (!strcmp(name, "feature_edx")) { setfeatures(&def->features, str, feature_name, &err); } else if (!strcmp(name, "feature_ecx")) { setfeatures(&def->ext_features, str, ext_feature_name, &err); } else if (!strcmp(name, "extfeature_edx")) { setfeatures(&def->ext2_features, str, ext2_feature_name, &err); } else if (!strcmp(name, "extfeature_ecx")) { setfeatures(&def->ext3_features, str, ext3_feature_name, &err); } else if (!strcmp(name, "xlevel")) { setscalar(&def->xlevel, str, &err) } else { fprintf(stderr, "error: unknown option [%s = %s]\n", name, str); return (1); } if (err) { fprintf(stderr, "error: bad option value [%s = %s]\n", name, str); return (1); } return (0); }
1threat
Listar todos os valores de cada tabela do SQL : Preciso fazer uma listagem genérica que me traga todos os valores que tenho no banco, cada linha de banco. Minha aplicação precisa ler uma informação que muda e transita dentro no banco.
0debug
avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms, int w, int h, enum PixelFormat format) { AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer)); AVFilterBufferRef *picref = av_mallocz(sizeof(AVFilterBufferRef)); if (!pic || !picref) goto fail; picref->buf = pic; picref->buf->free = ff_avfilter_default_free_buffer; if (!(picref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps)))) goto fail; picref->video->w = w; picref->video->h = h; picref->perms = perms | AV_PERM_READ; pic->refcount = 1; picref->type = AVMEDIA_TYPE_VIDEO; picref->format = format; memcpy(pic->data, data, sizeof(pic->data)); memcpy(pic->linesize, linesize, sizeof(pic->linesize)); memcpy(picref->data, pic->data, sizeof(picref->data)); memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize)); return picref; fail: if (picref && picref->video) av_free(picref->video); av_free(picref); av_free(pic); return NULL; }
1threat
how to pass value into CGFloat - : I have a the following code which is cocoa touch class, which draws a simple pie chart, and with the value CGFloat I can adjust the image to show the correct information. how can i pass a value for example from a slider in the main view controler.swift to it, instead of having it fixed? public class PieChart : NSObject { public class func drawCanvas1(ratio ratio: CGFloat = 0.75) { //// Variable Declarations let expression: CGFloat = 90 + ratio * 360 let ovalPath = UIBezierPath(ovalInRect: CGRect(x: 0, y: -0, width: 112, height: 112)) UIColor.blackColor().setFill() ovalPath.fill() let oval2Rect = CGRect(x: 4, y: 4, width: 104, height: 104) let oval2Path = UIBezierPath() oval2Path.addArcWithCenter(CGPoint(x: oval2Rect.midX, y: oval2Rect.midY), radius: oval2Rect.width / 2, startAngle: -expression * CGFloat(M_PI)/180, endAngle: -90 * CGFloat(M_PI)/180, clockwise: true) oval2Path.addLineToPoint(CGPoint(x: oval2Rect.midX, y: oval2Rect.midY)) oval2Path.closePath() UIColor.redColor().setFill() oval2Path.fill() } }
0debug
What is pipenv [dev-packages] section for? : <p>I'm learning <a href="https://pipenv.readthedocs.io/en/latest/" rel="noreferrer">pipenv</a> and there's something I don't quite understand. Apparently your Pipfile can contain two sections:</p> <pre><code>[packages] ... [dev-packages] .... </code></pre> <p>As I understand it, the packages section is where the packages that you install are listed. But what is the dev-packages section for? How is it different from the packages section?</p>
0debug
java interface methods usage : <p>Hi I have been given the following interface and I need to implement bag using this interface, I'm a little confuse as how to use the methods, any help/hint would be appreciated. I need to add items to the bag and it should be able to accept duplicate items. Then I have remove an item and find an item.</p> <pre><code>public interface Things&lt;T&gt; extends Iterable&lt;T&gt; { public int size(); public boolean add(T x); public T remove(T x); public T find(T x); public void clear(); } //Implementing thing using bag public class Bag&lt;T&gt; implements Things&lt;T&gt; { @Override public int size() { // TODO Auto-generated method stub return 0; } @Override public String add(T x) { // TODO Auto-generated method stub return null; } @Override public String remove(T x) { // TODO Auto-generated method stub return null; } @Override public String find(T x) { // TODO Auto-generated method stub return null; } } public class ThingsDemo { public static void main(String args[]) { How to I use add(), remove(), and find method here? } } </code></pre>
0debug
SwiftUI Row Height of List - how to control? : <p>I have a simple List in SwiftUI. Code and Screenshot included below. I would like to reduce the height of each row in the list (so less space between lines and text lines closer together).</p> <p>I already tried to add a ".frame(height: 20)" to the HStack but it only allows the line spacing to be increased!</p> <p>Is there a way to do that?</p> <p>Thanks!</p> <p>Gerard</p> <pre><code>import SwiftUI struct PressureData: Identifiable { let id: Int let timeStamp: String let pressureVal: Int } struct ContentView : View { @State var pressureList = [ PressureData(id: 0, timeStamp: "11:49:57", pressureVal: 10), PressureData(id: 1, timeStamp: "11:49:56", pressureVal: 8), PressureData(id: 2, timeStamp: "11:49:55", pressureVal: 9), PressureData(id: 3, timeStamp: "11:49:54", pressureVal: 1), ] var body: some View { VStack { Text("Pressure Readings") .font(.system(size: 30)) List(pressureList) { row in HStack { Spacer() Text(row.timeStamp) Text("---&gt;") Text(String(row.pressureVal)) Spacer() } .frame(height: 30) } } } } </code></pre> <p><a href="https://i.stack.imgur.com/bY7AL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bY7AL.png" alt="enter image description here"></a></p>
0debug
"let-" is only supported on ng-template elements : <p>I am trying to get my frontend-application(Angular5.1.x) to run but it stops due to template parse error:</p> <pre><code>"let-" is only supported on ng-template elements. (" &lt;/thead&gt; &lt;tbody&gt; &lt;template ngFor [ngForOf]="rows" [ERROR -&gt;]let-rowz="$implicit" let- index="index"&gt; &lt;tr *ngIf="!(datePicker.onlyCurrentMonth &amp;&amp; rowz[0].sec"): ng:///DatepickerModule/DayPickerComponent.html@52:58 at syntaxError (compiler.js:485) at TemplateParser.parse (compiler.js:24633) at JitCompiler._parseTemplate (compiler.js:34442) at JitCompiler._compileTemplate (compiler.js:34417) at compiler.js:34318 at Set.forEach (&lt;anonymous&gt;) at JitCompiler._compileComponents (compiler.js:34318) at compiler.js:34188 at Object.then (compiler.js:474) at JitCompiler._compileModuleAndComponents (compiler.js:34187) </code></pre> <p>I figured I need to follow this on-topic issue, stating I need to use ngx-bootrap@ngx-bootstrap@2.0.0-beta.8, but it doesnt work with that or v.2.0.0-rc.0</p> <p><a href="https://github.com/valor-software/ngx-bootstrap/issues/3024" rel="noreferrer">https://github.com/valor-software/ngx-bootstrap/issues/3024</a></p> <p>...any help is appreciated</p>
0debug
static void kvmclock_vm_state_change(void *opaque, int running, RunState state) { KVMClockState *s = opaque; CPUState *cpu; int cap_clock_ctrl = kvm_check_extension(kvm_state, KVM_CAP_KVMCLOCK_CTRL); int ret; if (running) { struct kvm_clock_data data = {}; uint64_t time_at_migration = kvmclock_current_nsec(s); s->clock_valid = false; if (time_at_migration) { s->clock = time_at_migration; } data.clock = s->clock; ret = kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &data); if (ret < 0) { fprintf(stderr, "KVM_SET_CLOCK failed: %s\n", strerror(ret)); abort(); } if (!cap_clock_ctrl) { return; } CPU_FOREACH(cpu) { ret = kvm_vcpu_ioctl(cpu, KVM_KVMCLOCK_CTRL, 0); if (ret) { if (ret != -EINVAL) { fprintf(stderr, "%s: %s\n", __func__, strerror(-ret)); } return; } } } else { struct kvm_clock_data data; int ret; if (s->clock_valid) { return; } kvm_synchronize_all_tsc(); ret = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data); if (ret < 0) { fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", strerror(ret)); abort(); } s->clock = data.clock; s->clock_valid = true; } }
1threat
How can i start Docker YML file : How can I start Docker YML file. I have project on Node js, and i do not know how to run a finished docker file. OS Ubuntu 16.04 desktop.
0debug
Conditional Replace Values : <p>I have a data set called NFL. I am trying to flag PlayType by "Sack", replace the NA in PlayerPosition with "QB", and then go back to normal. I can't figure out the code to make it happen. So far I have this which is wrong:</p> <pre><code> NFL$PlayerPosition[NFL$PlayType == "Sack"] &lt;- "QB" </code></pre>
0debug
Syntax Error in Inline if ... else Syntax in Python : What exactly is wrong with the syntax and why in the following piece of code? I've counted the parentheses among other things yet am unable to figure it out. ` c = "" print("Yes") if c else print("No")` Note: It gives a Syntax error like the one below: `print("Yes") if c else print("No") ^ SyntaxError: invalid syntax`
0debug
Java: Allowed statements after labels : <p>I'm playing around with Java Syntax, so this is question arises purely from curiosity. This piece of code:</p> <pre><code>http://www.google.com Object val = 5 &lt;- 4; </code></pre> <p>does <strong>not</strong> compile, because a label (<code>http</code>) "must be followed by a statement". The following two variants do compile:</p> <pre><code>http://www.google.com { Object val = 5 &lt;- 4; } </code></pre> <p>and </p> <pre><code>Object val; http://www.google.com val = 5 &lt;- 4; </code></pre> <p>In both cases, I switched from a declaration to an expression. This makes me wonder what exactly is a "statement" in Java, but the <a href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/expressions.html" rel="noreferrer">doc</a> states:</p> <blockquote> <p>In addition to expression statements, there are two other kinds of statements: declaration statements and control flow statements. A declaration statement declares a variable.</p> </blockquote> <p>The <a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.7" rel="noreferrer">JLS</a> just says (on labels) that </p> <blockquote> <p>The Identifier is declared to be the label of the immediately contained Statement. </p> </blockquote> <p>It does not say anything about "expression statements".</p> <p>Did I miss something, or is this just an unclear/incorrect specification?</p>
0debug
Aml *aml_and(Aml *arg1, Aml *arg2) { Aml *var = aml_opcode(0x7B ); aml_append(var, arg1); aml_append(var, arg2); build_append_byte(var->buf, 0x00 ); return var; }
1threat
What does the value of 'leaf' in the following xgboost model tree diagram means? : <p><a href="https://i.stack.imgur.com/L1N2K.png" rel="noreferrer"><img src="https://i.stack.imgur.com/L1N2K.png" alt="enter image description here"></a></p> <p>I am guessing that it is conditional probability given that the above (tree branch) condition exists. However, I am not clear on it.</p> <p>If you want to read more about the data used or how do we get this diagram then go to : <a href="http://machinelearningmastery.com/visualize-gradient-boosting-decision-trees-xgboost-python/" rel="noreferrer">http://machinelearningmastery.com/visualize-gradient-boosting-decision-trees-xgboost-python/</a></p>
0debug
static bool sys_ops_accepts(void *opaque, target_phys_addr_t addr, unsigned size, bool is_write) { return is_write && size == 4; }
1threat
def add_K_element(test_list, K): res = [tuple(j + K for j in sub ) for sub in test_list] return (res)
0debug
static void blockdev_backup_abort(BlkActionState *common) { BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common); BlockDriverState *bs = state->bs; if (bs && bs->job && bs->job == state->job) { block_job_cancel_sync(bs->job); } }
1threat
Return <dd> knowing the previous <dt> beautiful soap - Python3 : I started using Beautiful Soap 4 two days ago. I want to get the <dd> knowing the previous tag(<dt>). I tried to get the number of episodes( <dt>Episodi</dt>) etc from https://www.animeclick.it/anime/2683/yojouhan-shinwa-taikei but since they aren't static(it can be that sometimes the tag that I want isn't everytime the third tag, for example) I wanted to know how to get it. Hope that someone can help me.
0debug
How do I remove outline on link click? : <p>When I click a link on my website it is creating an outline around the link like so</p> <p><a href="https://i.stack.imgur.com/d7IrT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/d7IrT.png" alt="enter image description here"></a></p> <p>I've tried adding:</p> <pre><code>a.image-link:focus { outline: 0; } </code></pre> <p>and</p> <pre><code>a {outline : none;} </code></pre> <p>But nothing seems to get rid of it. Is there a way to remove it?</p>
0debug
view-source in href shows error in console : <p><code>&lt;a href="view-source:http://stackoverflow.com"&gt;Click Me&lt;/a&gt;</code></p> <p>This used to work as a valid <code>href</code> attribute but it seems in the past few months it now shows an error in the console (I'm using Chrome): </p> <blockquote> <p>Not allowed to load local resource: view-source: <a href="http://stackoverflow.com">http://stackoverflow.com</a></p> </blockquote> <p>I found some links from 2013 where this was once a bug in Chrome but said it was fixed.</p> <p>Could someone point me to an authoritative source that can explain why this no longer works? I assume that this is security by the browser and not an angular issue (since <code>view-source</code> is whitelisted and used to work)</p>
0debug
JavaScript RegExp in replace() not working : <p>I have this code</p> <pre><code>var str = "Some text :$0"; var i = 0; alert(str.replace(new RegExp("\:\$" + i, "g"), 'here')); </code></pre> <p>see <a href="https://jsfiddle.net/3zyr03h0/" rel="nofollow">here</a>.</p> <p>Why is it not working? If I do it like this <code>/\:\$:0/g</code> instead of using the <code>RegExp</code> object then it works but I can't use a variable in the pattern that way. Whats wrong?</p>
0debug
static inline void vmxnet3_ring_write_curr_cell(Vmxnet3Ring *ring, void *buff) { vmw_shmem_write(vmxnet3_ring_curr_cell_pa(ring), buff, ring->cell_size); }
1threat
static void do_v7m_exception_exit(ARMCPU *cpu) { CPUARMState *env = &cpu->env; uint32_t type; uint32_t xpsr; bool ufault = false; bool return_to_sp_process = false; bool return_to_handler = false; bool rettobase = false; assert(arm_v7m_is_handler_mode(env)); type = env->regs[15]; if (env->thumb) { type |= 1; } qemu_log_mask(CPU_LOG_INT, "Exception return: magic PC %" PRIx32 " previous exception %d\n", type, env->v7m.exception); if (extract32(type, 5, 23) != extract32(-1, 5, 23)) { qemu_log_mask(LOG_GUEST_ERROR, "M profile: zero high bits in exception " "exit PC value 0x%" PRIx32 " are UNPREDICTABLE\n", type); } if (env->v7m.exception != ARMV7M_EXCP_NMI) { if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { int es = type & 1; if (armv7m_nvic_raw_execution_priority(env->nvic) >= 0) { env->v7m.faultmask[es] = 0; } } else { env->v7m.faultmask[M_REG_NS] = 0; } } switch (armv7m_nvic_complete_irq(env->nvic, env->v7m.exception)) { case -1: ufault = true; break; case 0: break; case 1: rettobase = true; break; default: g_assert_not_reached(); } switch (type & 0xf) { case 1: return_to_handler = true; break; case 13: return_to_sp_process = true; case 9: if (!rettobase && !(env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_NONBASETHRDENA_MASK)) { ufault = true; } break; default: ufault = true; } if (ufault) { env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK; armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); v7m_exception_taken(cpu, type | 0xf0000000); qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " "stackframe: failed exception return integrity check\n"); return; } switch_v7m_sp(env, return_to_sp_process); env->regs[0] = v7m_pop(env); env->regs[1] = v7m_pop(env); env->regs[2] = v7m_pop(env); env->regs[3] = v7m_pop(env); env->regs[12] = v7m_pop(env); env->regs[14] = v7m_pop(env); env->regs[15] = v7m_pop(env); if (env->regs[15] & 1) { qemu_log_mask(LOG_GUEST_ERROR, "M profile return from interrupt with misaligned " "PC is UNPREDICTABLE\n"); env->regs[15] &= ~1U; } xpsr = v7m_pop(env); xpsr_write(env, xpsr, ~XPSR_SPREALIGN); if (xpsr & XPSR_SPREALIGN) { env->regs[13] |= 4; } if (return_to_handler != arm_v7m_is_handler_mode(env)) { armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK; v7m_push_stack(cpu); v7m_exception_taken(cpu, type | 0xf0000000); qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on new stackframe: " "failed exception return integrity check\n"); return; } qemu_log_mask(CPU_LOG_INT, "...successful exception return\n"); }
1threat
static void qemu_event_read(void *opaque) { int fd = (intptr_t)opaque; ssize_t len; char buffer[512]; do { len = read(fd, buffer, sizeof(buffer)); } while ((len == -1 && errno == EINTR) || len == sizeof(buffer)); }
1threat
Optimice multiple window.location.href = "index.html" : I have multiples IDs in my HTML. When I click that element (.onclick) I want to redirect them all (window.location.href) to the same site. So far I have tried this code but doesn't works: document.getElementById("boxed", "inmerse", "flow", "scape", "fierce", "name6", "name7", "name8", "name9").onclick = () => window.location.href = "../3infoCardPremium/3infoCardPremium.html" This is the code that works ```javascript document.getElementById("boxed").onclick = () => window.location.href = "../3infoCardPremium/3infoCardPremium.html" document.getElementById("immerse").onclick = () => window.location.href = "../3infoCardPremium/3infoCardPremium.html" document.getElementById("flow").onclick = () => window.location.href = "../3infoCardPremium/3infoCardPremium.html" document.getElementById("scape").onclick = () => window.location.href = "../3infoCardPremium/3infoCardPremium.html" document.getElementById("fierce").onclick = () => window.location.href = "../3infoCardPremium/3infoCardPremium.html" document.getElementById("name6").onclick = () => window.location.href = "../3infoCardPremium/3infoCardPremium.html" document.getElementById("name7").onclick = () => window.location.href = "../3infoCardPremium/3infoCardPremium.html" document.getElementById("name8").onclick = () => window.location.href = "../3infoCardPremium/3infoCardPremium.html" document.getElementById("name9").onclick = () => window.location.href = "../3infoCardPremium/3infoCardPremium.html" ``` I'm expecting to create some function or another way to optimize the code.
0debug
Dependency Property mechanism : <p>Dependency property are static in nature, so if i create a bool type custom dependency property called as "IsGrayProperty", and implement it on two buttons. Then if I set the value in btn1 , why it should not be reflected in btn2, as the dependencyproperty is static and their is a .net wrapper property "IsGray"</p>
0debug
int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen) { int ret; #ifdef CONFIG_ACCEPT4 ret = accept4(s, addr, addrlen, SOCK_CLOEXEC); #else ret = accept(s, addr, addrlen); if (ret >= 0) { qemu_set_cloexec(ret); } #endif return ret; }
1threat
How do you disable indent checking on esLint? : <p>The indent rule seems impossible to disable; how (in config settings) do I disable this rule? thanks. </p>
0debug
Full screen (overlay status bar) alert activity Android : I wanna write an popup activity (similar to alert dialog) that is translucent, covering the status bar something looks like the screenshot below [Sample][1] [1]: https://i.stack.imgur.com/UtIWT.jpg
0debug
static void check_time(int wiggle) { struct tm start, date[4], end; struct tm *datep; time_t ts; ts = time(NULL); gmtime_r(&ts, &start); cmos_get_date_time(&date[0]); cmos_get_date_time(&date[1]); cmos_get_date_time(&date[2]); cmos_get_date_time(&date[3]); ts = time(NULL); gmtime_r(&ts, &end); if (tm_cmp(&date[0], &date[1]) == 0) { datep = &date[0]; } else if (tm_cmp(&date[1], &date[2]) == 0) { datep = &date[1]; } else if (tm_cmp(&date[2], &date[3]) == 0) { datep = &date[2]; } else { g_assert_not_reached(); } if (!(tm_cmp(&start, datep) <= 0 && tm_cmp(datep, &end) <= 0)) { time_t t, s; start.tm_isdst = datep->tm_isdst; t = mktime(datep); s = mktime(&start); if (t < s) { g_test_message("RTC is %ld second(s) behind wall-clock\n", (s - t)); } else { g_test_message("RTC is %ld second(s) ahead of wall-clock\n", (t - s)); } g_assert_cmpint(ABS(t - s), <=, wiggle); } }
1threat
Should I add .idea/assetWizardSettings.xml to gitignore? : <p>Should I add .idea/assetWizardSettings into git ignore? It is generated when I created launcher icons for adaptive and legacy </p>
0debug
Spreadsheet Question: Count If this work week? : I have a spreadsheet that has data in one column (H2:H500) and dates in another column (F2:F500). I would like a sum of the total number in the past work week (Monday-Friday). I'm not sure if I need to use =CountIfs or what. Any help would be greatly appreciated! Thank you
0debug
How to control docker-compose build order? : <p>I have three services to build, A、B and C. A should be built in the very first place, because B and C depend on A (they import A as image). I thought they should be built in order but I just find out they are built in some random order?</p> <p>So, how do I control build order in <code>docker-compose.yml</code>?</p>
0debug
Fail during installation of Pillow (Python module) in Linux : <p>I'm trying to install Pillow (Python module) using pip, but it throws this error:</p> <pre><code>ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting </code></pre> <p>So as the error says, I tried:</p> <pre><code>pip install pillow --global-option="--disable-jpeg" </code></pre> <p>But it fails with:</p> <pre><code>error: option --disable-jpeg not recognized </code></pre> <p>Any hints how to deal with it?</p>
0debug
How to get (without vba) the last available data on a row in Excel : <p>I have a question regarding a simple formula: Gn=Fn-En, but if En is an empty cell, then search on the same row (n), all the n-1 values in order to find the first non empty cell. Is it possible to make such formula but without having any vba code?</p> <p>Regards,</p>
0debug
void qemu_spice_add_memslot(SimpleSpiceDisplay *ssd, QXLDevMemSlot *memslot, qxl_async_io async) { if (async != QXL_SYNC) { #if SPICE_INTERFACE_QXL_MINOR >= 1 spice_qxl_add_memslot_async(&ssd->qxl, memslot, 0); #else abort(); #endif } else { ssd->worker->add_memslot(ssd->worker, memslot); } }
1threat
how to add <!DOCTYPE> to the starting of an xml file using python2.5? : <p>I have an xml file as follows:</p> <pre><code> &lt;sample&gt; &lt;attributes&gt; xyz &lt;/attributes&gt; &lt;/sample&gt; </code></pre> <p>I want to add to the starting of xml:</p> <pre><code> &lt;!DOCTYPE sample SYSTEM "location/sample.dtd"&gt; </code></pre> <p>I have to use python 2.5 only. So, can anybody please suggest how can i have this. I want final xml file to be:</p> <pre><code> &lt;sample&gt; &lt;!DOCTYPE sample SYSTEM "location/sample.dtd"&gt; &lt;attributes&gt; xyz &lt;/attributes&gt; &lt;/sample&gt; </code></pre>
0debug
How to generate symbol combinations? : <p>I have input <code>char[][]</code>. I need to generate possible combinations, where each char array provides symbol for correspond position. for example:</p> <pre><code> char[][] symbols = new char[][] { {'M', 'm'}, {'o', '0'}, {'i', 'l', '|', 'e'}, {'s', '$'} }; </code></pre> <p>using this input data should be generated :</p> <pre><code>Mois Moi$ Mols Mol$ MoLs ... m0e$ </code></pre> <p>I've got trouble how to make condition in arrays to update correct symbol from correct array and build than string.</p>
0debug
How to add array to JSON Object? : I want to stringify JSON Object like "data", {"data": [0,1,2,3,4,5,6,7], "name":"number"} How can I add array element into JSON Object?
0debug
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options) { int ret = 0; AVDictionary *tmp = NULL; if (avcodec_is_open(avctx)) return 0; if ((!codec && !avctx->codec)) { av_log(avctx, AV_LOG_ERROR, "No codec provided to avcodec_open2().\n"); return AVERROR(EINVAL); if ((codec && avctx->codec && codec != avctx->codec)) { av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, " "but %s passed to avcodec_open2().\n", avctx->codec->name, codec->name); return AVERROR(EINVAL); if (!codec) codec = avctx->codec; if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE) return AVERROR(EINVAL); if (options) av_dict_copy(&tmp, *options, 0); if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init) { if (lockmgr_cb) { if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN)) return -1; entangled_thread_counter++; if (entangled_thread_counter != 1) { av_log(avctx, AV_LOG_ERROR, "Insufficient thread locking. At least %d threads are " "calling avcodec_open2() at the same time right now.\n", entangled_thread_counter); ret = -1; goto end; avctx->internal = av_mallocz(sizeof(AVCodecInternal)); if (!avctx->internal) { ret = AVERROR(ENOMEM); goto end; avctx->internal->pool = av_mallocz(sizeof(*avctx->internal->pool)); if (!avctx->internal->pool) { ret = AVERROR(ENOMEM); avctx->internal->to_free = av_frame_alloc(); if (!avctx->internal->to_free) { ret = AVERROR(ENOMEM); avctx->internal->buffer_frame = av_frame_alloc(); if (!avctx->internal->buffer_frame) { ret = AVERROR(ENOMEM); avctx->internal->buffer_pkt = av_packet_alloc(); if (!avctx->internal->buffer_pkt) { ret = AVERROR(ENOMEM); if (codec->priv_data_size > 0) { if (!avctx->priv_data) { avctx->priv_data = av_mallocz(codec->priv_data_size); if (!avctx->priv_data) { ret = AVERROR(ENOMEM); goto end; if (codec->priv_class) { *(const AVClass **)avctx->priv_data = codec->priv_class; av_opt_set_defaults(avctx->priv_data); if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp)) < 0) } else { avctx->priv_data = NULL; if ((ret = av_opt_set_dict(avctx, &tmp)) < 0) if (avctx->coded_width && avctx->coded_height && !avctx->width && !avctx->height) ret = ff_set_dimensions(avctx, avctx->coded_width, avctx->coded_height); else if (avctx->width && avctx->height) ret = ff_set_dimensions(avctx, avctx->width, avctx->height); if (ret < 0) if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height) && ( av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx) < 0 || av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)) { av_log(avctx, AV_LOG_WARNING, "ignoring invalid width/height values\n"); ff_set_dimensions(avctx, 0, 0); if (avctx->width > 0 && avctx->height > 0) { if (av_image_check_sar(avctx->width, avctx->height, avctx->sample_aspect_ratio) < 0) { av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n", avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den); avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; if (av_codec_is_decoder(codec)) av_freep(&avctx->subtitle_header); if (avctx->channels > FF_SANE_NB_CHANNELS) { avctx->codec = codec; if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) && avctx->codec_id == AV_CODEC_ID_NONE) { avctx->codec_type = codec->type; avctx->codec_id = codec->id; if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type && avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) { av_log(avctx, AV_LOG_ERROR, "codec type or id mismatches\n"); avctx->frame_number = 0; if ((avctx->codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) && avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { ret = AVERROR_EXPERIMENTAL; if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && (!avctx->time_base.num || !avctx->time_base.den)) { avctx->time_base.num = 1; avctx->time_base.den = avctx->sample_rate; if (HAVE_THREADS) { ret = ff_thread_init(avctx); if (ret < 0) { if (!HAVE_THREADS && !(codec->capabilities & AV_CODEC_CAP_AUTO_THREADS)) avctx->thread_count = 1; if (av_codec_is_encoder(avctx->codec)) { int i; #if FF_API_CODED_FRAME FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) { ret = AVERROR(ENOMEM); FF_ENABLE_DEPRECATION_WARNINGS #endif if (avctx->codec->sample_fmts) { for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) { if (avctx->sample_fmt == avctx->codec->sample_fmts[i]) break; if (avctx->channels == 1 && av_get_planar_sample_fmt(avctx->sample_fmt) == av_get_planar_sample_fmt(avctx->codec->sample_fmts[i])) { avctx->sample_fmt = avctx->codec->sample_fmts[i]; break; if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) { av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n"); if (avctx->codec->pix_fmts) { for (i = 0; avctx->codec->pix_fmts[i] != AV_PIX_FMT_NONE; i++) if (avctx->pix_fmt == avctx->codec->pix_fmts[i]) break; if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE) { av_log(avctx, AV_LOG_ERROR, "Specified pix_fmt is not supported\n"); if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ420P || avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ422P || avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ440P || avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ444P) avctx->color_range = AVCOL_RANGE_JPEG; if (avctx->codec->supported_samplerates) { for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++) if (avctx->sample_rate == avctx->codec->supported_samplerates[i]) break; if (avctx->codec->supported_samplerates[i] == 0) { av_log(avctx, AV_LOG_ERROR, "Specified sample_rate is not supported\n"); if (avctx->codec->channel_layouts) { if (!avctx->channel_layout) { av_log(avctx, AV_LOG_WARNING, "channel_layout not specified\n"); } else { for (i = 0; avctx->codec->channel_layouts[i] != 0; i++) if (avctx->channel_layout == avctx->codec->channel_layouts[i]) break; if (avctx->codec->channel_layouts[i] == 0) { av_log(avctx, AV_LOG_ERROR, "Specified channel_layout is not supported\n"); if (avctx->channel_layout && avctx->channels) { if (av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) { av_log(avctx, AV_LOG_ERROR, "channel layout does not match number of channels\n"); } else if (avctx->channel_layout) { avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout); if (!avctx->rc_initial_buffer_occupancy) avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3 / 4; if (avctx->ticks_per_frame && avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) { av_log(avctx, AV_LOG_ERROR, "ticks_per_frame %d too large for the timebase %d/%d.", avctx->ticks_per_frame, avctx->time_base.num, avctx->time_base.den); if (avctx->hw_frames_ctx) { AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; if (frames_ctx->format != avctx->pix_fmt) { av_log(avctx, AV_LOG_ERROR, "Mismatching AVCodecContext.pix_fmt and AVHWFramesContext.format\n"); if (avctx->codec->init && !(avctx->active_thread_type & FF_THREAD_FRAME)) { ret = avctx->codec->init(avctx); if (ret < 0) { #if FF_API_AUDIOENC_DELAY if (av_codec_is_encoder(avctx->codec)) avctx->delay = avctx->initial_padding; #endif if (av_codec_is_decoder(avctx->codec)) { if (avctx->channel_layout) { int channels = av_get_channel_layout_nb_channels(avctx->channel_layout); if (!avctx->channels) avctx->channels = channels; else if (channels != avctx->channels) { av_log(avctx, AV_LOG_WARNING, "channel layout does not match number of channels\n"); avctx->channel_layout = 0; if (avctx->channels && avctx->channels < 0 || avctx->channels > FF_SANE_NB_CHANNELS) { #if FF_API_AVCTX_TIMEBASE if (avctx->framerate.num > 0 && avctx->framerate.den > 0) avctx->time_base = av_inv_q(avctx->framerate); #endif end: if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init) { entangled_thread_counter--; if (lockmgr_cb) { (*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE); if (options) { av_dict_free(options); *options = tmp; return ret; free_and_end: if (avctx->codec && (avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP)) avctx->codec->close(avctx); if (avctx->priv_data && avctx->codec && avctx->codec->priv_class) av_opt_free(avctx->priv_data); av_opt_free(avctx); #if FF_API_CODED_FRAME FF_DISABLE_DEPRECATION_WARNINGS av_frame_free(&avctx->coded_frame); FF_ENABLE_DEPRECATION_WARNINGS #endif av_dict_free(&tmp); av_freep(&avctx->priv_data); if (avctx->internal) { av_frame_free(&avctx->internal->to_free); av_freep(&avctx->internal->pool); av_freep(&avctx->internal); avctx->codec = NULL; goto end;
1threat
how to extract numbers from a equation given as a string in python? : <p>ex:- <strong>string</strong>="1x-2y-7" <strong>output</strong>=[1,-2,-7]</p> <p>I can get the number using <strong>isnumeric</strong> but I am not able to extract signs out of it </p>
0debug
How to convert array into JSON object in php : <p>I want to convert my array value:</p> <pre><code>Array ( [page_1] =&gt; fifth [page_2] =&gt; first [page_3] =&gt; fourth [page_4] =&gt; third ) </code></pre> <p>Into JSON format is given below</p> <pre><code>{s:6:"page_1";s:5:"third";s:6:"page_2";s:5:"first";s:6:"page_3";s:6:"fourth";s:6:"page_4";s:5:"fifth";} </code></pre> <p>Can anyone please help me</p>
0debug
How do you keep taking input as constantly C++ : Let's say that the input is like this: 2 xsad sadsad There are no constraints so how do you create a loop function that will keep on going that will store each of those in a string. Like the first number is the amount of lines of strings. How do you create a loop function that would read the first number ex: 1000 and keep storing it in different strings?
0debug
How does Python convert bytes into float? : <p>I have the following code snippet:</p> <pre><code>#!/usr/bin/env python3 print(float(b'5')) </code></pre> <p>Which prints <code>5.0</code> with no error (on Linux with utf-8 encoding). I'm very surprised that it doesn't give an error since Python is not supposed to know what encoding is used for the bytes object.</p> <p>Any insight?</p>
0debug
Python requests: URL base in Session : <p>When using a Session, it seems you need to provide the full URL each time, e.g.</p> <pre><code>session = requests.Session() session.get('http://myserver/getstuff') session.get('http://myserver/getstuff2') </code></pre> <p>This gets a little tedious. Is there a way to do something like:</p> <pre><code>session = requests.Session(url_base='http://myserver') session.get('/getstuff') session.get('/getstuff2') </code></pre>
0debug
static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx, float *samples, const double *lsps, const double *prev_lsps, float *excitation, float *synth) { WMAVoiceContext *s = ctx->priv_data; int n, n_blocks_x2, log_n_blocks_x2, cur_pitch_val; int pitch[MAX_BLOCKS], last_block_pitch; int bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)], block_nsamples; if (bd_idx < 0) { av_log(ctx, AV_LOG_ERROR, "Invalid frame type VLC code, skipping\n"); return -1; } block_nsamples = MAX_FRAMESIZE / frame_descs[bd_idx].n_blocks; if (frame_descs[bd_idx].acb_type == ACB_TYPE_ASYMMETRIC) { n_blocks_x2 = frame_descs[bd_idx].n_blocks << 1; log_n_blocks_x2 = frame_descs[bd_idx].log_n_blocks + 1; cur_pitch_val = s->min_pitch_val + get_bits(gb, s->pitch_nbits); cur_pitch_val = FFMIN(cur_pitch_val, s->max_pitch_val - 1); if (s->last_acb_type == ACB_TYPE_NONE || 20 * abs(cur_pitch_val - s->last_pitch_val) > (cur_pitch_val + s->last_pitch_val)) s->last_pitch_val = cur_pitch_val; for (n = 0; n < frame_descs[bd_idx].n_blocks; n++) { int fac = n * 2 + 1; pitch[n] = (MUL16(fac, cur_pitch_val) + MUL16((n_blocks_x2 - fac), s->last_pitch_val) + frame_descs[bd_idx].n_blocks) >> log_n_blocks_x2; } s->pitch_diff_sh16 = ((cur_pitch_val - s->last_pitch_val) << 16) / MAX_FRAMESIZE; } switch (frame_descs[bd_idx].fcb_type) { case FCB_TYPE_SILENCE: s->silence_gain = wmavoice_gain_silence[get_bits(gb, 8)]; break; case FCB_TYPE_AW_PULSES: aw_parse_coords(s, gb, pitch); break; } for (n = 0; n < frame_descs[bd_idx].n_blocks; n++) { int bl_pitch_sh2; switch (frame_descs[bd_idx].acb_type) { case ACB_TYPE_HAMMING: { int block_pitch, t1 = (s->block_conv_table[1] - s->block_conv_table[0]) << 2, t2 = (s->block_conv_table[2] - s->block_conv_table[1]) << 1, t3 = s->block_conv_table[3] - s->block_conv_table[2] + 1; if (n == 0) { block_pitch = get_bits(gb, s->block_pitch_nbits); } else block_pitch = last_block_pitch - s->block_delta_pitch_hrange + get_bits(gb, s->block_delta_pitch_nbits); last_block_pitch = av_clip(block_pitch, s->block_delta_pitch_hrange, s->block_pitch_range - s->block_delta_pitch_hrange); if (block_pitch < t1) { bl_pitch_sh2 = (s->block_conv_table[0] << 2) + block_pitch; } else { block_pitch -= t1; if (block_pitch < t2) { bl_pitch_sh2 = (s->block_conv_table[1] << 2) + (block_pitch << 1); } else { block_pitch -= t2; if (block_pitch < t3) { bl_pitch_sh2 = (s->block_conv_table[2] + block_pitch) << 2; } else bl_pitch_sh2 = s->block_conv_table[3] << 2; } } pitch[n] = bl_pitch_sh2 >> 2; break; } case ACB_TYPE_ASYMMETRIC: { bl_pitch_sh2 = pitch[n] << 2; break; } default: bl_pitch_sh2 = 0; break; } synth_block(s, gb, n, block_nsamples, bl_pitch_sh2, lsps, prev_lsps, &frame_descs[bd_idx], &excitation[n * block_nsamples], &synth[n * block_nsamples]); } if (s->do_apf) { double i_lsps[MAX_LSPS]; float lpcs[MAX_LSPS]; for (n = 0; n < s->lsps; n++) i_lsps[n] = cos(0.5 * (prev_lsps[n] + lsps[n])); ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1); postfilter(s, synth, samples, 80, lpcs, &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * frame_idx], frame_descs[bd_idx].fcb_type, pitch[0]); for (n = 0; n < s->lsps; n++) i_lsps[n] = cos(lsps[n]); ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1); postfilter(s, &synth[80], &samples[80], 80, lpcs, &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * frame_idx + 80], frame_descs[bd_idx].fcb_type, pitch[0]); } else memcpy(samples, synth, 160 * sizeof(synth[0])); s->frame_cntr++; if (s->frame_cntr >= 0xFFFF) s->frame_cntr -= 0xFFFF; s->last_acb_type = frame_descs[bd_idx].acb_type; switch (frame_descs[bd_idx].acb_type) { case ACB_TYPE_NONE: s->last_pitch_val = 0; break; case ACB_TYPE_ASYMMETRIC: s->last_pitch_val = cur_pitch_val; break; case ACB_TYPE_HAMMING: s->last_pitch_val = pitch[frame_descs[bd_idx].n_blocks - 1]; break; } return 0; }
1threat
How can I navigate to top of a page when I click a Button in Angular 2? : I have a form and on the buttom of the page I have a button and when I click it I want to navigate to the top of the page. How can I do that in Angular 2?
0debug
static int vpc_create(const char *filename, int64_t total_sectors, const char *backing_file, int flags) { uint8_t buf[1024]; struct vhd_footer* footer = (struct vhd_footer*) buf; struct vhd_dyndisk_header* dyndisk_header = (struct vhd_dyndisk_header*) buf; int fd, i; uint16_t cyls; uint8_t heads; uint8_t secs_per_cyl; size_t block_size, num_bat_entries; if (backing_file != NULL) return -ENOTSUP; fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) return -EIO; calculate_geometry(total_sectors, &cyls, &heads, &secs_per_cyl); total_sectors = (int64_t) cyls * heads * secs_per_cyl; memset(buf, 0, 1024); strncpy(footer->creator, "conectix", 8); strncpy(footer->creator_app, "qemu", 4); strncpy(footer->creator_os, "Wi2k", 4); footer->features = be32_to_cpu(0x02); footer->version = be32_to_cpu(0x00010000); footer->data_offset = be64_to_cpu(HEADER_SIZE); footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE); footer->major = be16_to_cpu(0x0005); footer->minor =be16_to_cpu(0x0003); footer->orig_size = be64_to_cpu(total_sectors * 512); footer->size = be64_to_cpu(total_sectors * 512); footer->cyls = be16_to_cpu(cyls); footer->heads = heads; footer->secs_per_cyl = secs_per_cyl; footer->type = be32_to_cpu(VHD_DYNAMIC); footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE)); block_size = 0x200000; num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512); if (write(fd, buf, HEADER_SIZE) != HEADER_SIZE) return -EIO; if (lseek(fd, 1536 + ((num_bat_entries * 4 + 511) & ~511), SEEK_SET) < 0) return -EIO; if (write(fd, buf, HEADER_SIZE) != HEADER_SIZE) return -EIO; if (lseek(fd, 3 * 512, SEEK_SET) < 0) return -EIO; memset(buf, 0xFF, 512); for (i = 0; i < (num_bat_entries * 4 + 511) / 512; i++) if (write(fd, buf, 512) != 512) return -EIO; memset(buf, 0, 1024); strncpy(dyndisk_header->magic, "cxsparse", 8); dyndisk_header->data_offset = be64_to_cpu(0xFFFFFFFF); dyndisk_header->table_offset = be64_to_cpu(3 * 512); dyndisk_header->version = be32_to_cpu(0x00010000); dyndisk_header->block_size = be32_to_cpu(block_size); dyndisk_header->max_table_entries = be32_to_cpu(num_bat_entries); dyndisk_header->checksum = be32_to_cpu(vpc_checksum(buf, 1024)); if (lseek(fd, 512, SEEK_SET) < 0) return -EIO; if (write(fd, buf, 1024) != 1024) return -EIO; close(fd); return 0; }
1threat
C# MySQL table entry counting from user selection : <p>I tried to write a code which will count rows in MySQL , same as combobox-selected text. For example in my MySQL database,i have a table(ogrencikayit) and in this table i have several columns.In my combobox there are 2 different selection which allows to select student class.When user select the class in combobox , label has to show count of total student in selected class.Here is my code;</p> <pre><code>DB database = new DB(); int kayitsayisi = -1; MySqlCommand cmd = new MySqlCommand("Select count(*) from ogrencikayit Where ogrsinif ="+comboBox3.Text.ToUpper()+"" , database.baglanti); database.baglanti.Open(); kayitsayisi = Convert.ToInt32(cmd.ExecuteScalar()); string kayitt = kayitsayisi.ToString(); label24.Text = kayitt; </code></pre> <p>Shortly; i try to find a code that it will read the name of the class name from combobox than it will search in database that how many student belongs to that class and it will show it to the label.</p>
0debug
Official locator strategies for the webdriver : <p>In the <a href="https://w3c.github.io/webdriver/webdriver-spec.html#locator-strategies" rel="noreferrer">official W3c webdirver documentation</a>, it's clearly stated that the location strategies are:</p> <pre><code>State Keyword CSS selector "css selector" Link text selector "link text" Partial link text selector "partial link text" Tag name "tag name" XPath selector "xpath" </code></pre> <p>However, <a href="https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol" rel="noreferrer">Selenium's wire protocol</a> allowed:</p> <pre><code>class name css selector id name link text partial link text tag name xpath </code></pre> <p>In THEORY, Selenium's docs are obsolete and the "real" story is in the new spec document. However... </p> <p>I ran some tests on the latest Chrome's own Webdriver, and I can confirm that <code>name</code> and <code>class name</code> both work; however, they are not in the specs.</p> <p>I remember reading on a Chromium issue that they would only ever implement the official Webdriver specs.</p> <p>Now: I <em>know</em> the generic answer, where "specs are not always followed 100%" etc. However, what I'd like to know is:</p> <ul> <li>Can you find the code in Chromium that implements this? (link would be most welcome)</li> <li>Have there been discussions about these in the Chromium mailing list?</li> <li>Are the "unofficial" commands (which are documented in the "old" selenium specs file) likely to stay? Where did you read so?</li> </ul>
0debug
static void channel_run(DBDMA_channel *ch) { dbdma_cmd *current = &ch->current; uint16_t cmd, key; uint16_t req_count; uint32_t phy_addr; DBDMA_DPRINTF("channel_run\n"); dump_dbdma_cmd(current); ch->regs[DBDMA_STATUS] &= cpu_to_be32(~WAKE); cmd = le16_to_cpu(current->command) & COMMAND_MASK; switch (cmd) { case DBDMA_NOP: nop(ch); return; case DBDMA_STOP: stop(ch); return; } key = le16_to_cpu(current->command) & 0x0700; req_count = le16_to_cpu(current->req_count); phy_addr = le32_to_cpu(current->phy_addr); if (key == KEY_STREAM4) { printf("command %x, invalid key 4\n", cmd); kill_channel(ch); return; } switch (cmd) { case OUTPUT_MORE: start_output(ch, key, phy_addr, req_count, 0); return; case OUTPUT_LAST: start_output(ch, key, phy_addr, req_count, 1); return; case INPUT_MORE: start_input(ch, key, phy_addr, req_count, 0); return; case INPUT_LAST: start_input(ch, key, phy_addr, req_count, 1); return; } if (key < KEY_REGS) { printf("command %x, invalid key %x\n", cmd, key); key = KEY_SYSTEM; } req_count = req_count & 0x0007; if (req_count & 0x4) { req_count = 4; phy_addr &= ~3; } else if (req_count & 0x2) { req_count = 2; phy_addr &= ~1; } else req_count = 1; switch (cmd) { case LOAD_WORD: load_word(ch, key, phy_addr, req_count); return; case STORE_WORD: store_word(ch, key, phy_addr, req_count); return; } }
1threat
Refractoring to be more SOLID : Im trying to rewrite my current piece of code into (see example0. But it doesnt know the carriage animal in my CheckIfAnimalFits method. How would I fix this without moving the entire foreach into the method Current code ``` public bool AddAnimaltoWagon(Animal animal) { if (CheckWagonFull(animal) == true ) { return false; } foreach (Animal carriageAnimal in Animals) { if (carriageAnimal.AnimalDiet == AnimalDiet.Carnivore && animal.Size <= carriageAnimal.Size || animal.AnimalDiet == AnimalDiet.Carnivore && animal.Size > carriageAnimal.Size) { return false; } } Animals.Add(animal); return true; } ``` trying to get ``` public bool AddAnimaltoWagon(Animal animal) { if (CheckWagonFull(animal) == true ) { return false; } foreach (Animal carriageAnimal in Animals) { if (CheckIfAnimalFits == false) { return false; } } Animals.Add(animal); return true; } public bool CheckIfAnimalFits(Animal animal) { if (carriageAnimal.AnimalDiet == AnimalDiet.Carnivore && animal.Size <= carriageAnimal.Size || animal.AnimalDiet == AnimalDiet.Carnivore && animal.Size > carriageAnimal.Size) { return false; } else { return true; } } ``` So it doesnt know `carriageAnimal` in my new method
0debug
Updating the same list with square values : <p>I want to declare a list in python3 and then update it with square values. e.g. </p> <pre><code>list1 = [1,2,3,4] </code></pre> <p>and Output should be the same list with square values:</p> <pre><code>list1 = [1,4,9,16] </code></pre> <p>I don't want to use another list. Please help?</p>
0debug
What is Complexity of a program and how to calculate it? : <p>I am a Java Developer, I wanted to know about Complexity of Program and its calculation ? (i am beginner please answer in simple terms that i can understand thanks in advance..!!)</p>
0debug
AttributeError: '_NamespacePath' object has no attribute 'sort' : <p>I downloaded anaconda and when try to launch jupyter notebook using cmd, the error appear as AttributeError: '_NamespacePath' object has no attribute 'sort'. I am launching jypyter by typing jupyter notebook in cmd in windows os. Thanks for solving my error</p>
0debug