problem
stringlengths
26
131k
labels
class label
2 classes
WKWebView doesn't run JavaScript when on background : <p>I noticed that sometimes when the webview is moved to background (have another view controller on top), it stops JavaScript functions execution, and executes them only when returning back to foreground.<br> <a href="https://stackoverflow.com/questions/26514090/wkwebview-does-not-run-javascriptxml-http-request-with-out-adding-a-parent-vie">here</a> a thread with a similar issue but most of the solutions was some kind of hack, like adding the webview to the key window, or looping dummy calls to evaluateJavaScript so the webview wouldn't go to idle mode and stop JavaScript.<br> Those solutions work btw, but I don't like them at all.<br> I was wondering if there was a better solution for this problem, any way to configure the webView to prevent going into idle mode, or more elegant way to prioritize JavaScript.<br> Thanks.</p>
0debug
JS - Block user from typing phone number : <p>I have a booking website like AirBnB and my users can exchange message between each other in my website.</p> <p>I would like to block my users from exchanging telephone number and email address in these messages.</p> <p>The way I am using is to look for 4 numeric digits together or @ and delete these before it sends the message.</p> <p>Please, is there a better way to do it?</p> <p>Thanks.</p>
0debug
def fifth_Power_Sum(n) : sm = 0 for i in range(1,n+1) : sm = sm + (i*i*i*i*i) return sm
0debug
PHP: How to know if number is in a interval of int? : <p>I have a variable of int type called <code>myNumber</code> and I need to know if it is in the interval [100, 200].</p> <p>Example:</p> <pre><code>if (myNumber in (100, 200)) { echo 'Yes'; } </code></pre> <p>I wonder if PHP has a <code>in</code> function or similar.</p>
0debug
Remove unused css with React and Webpack : <p>I'm trying to remove unused css classes from my app using <a href="https://github.com/webpack-contrib/purifycss-webpack" rel="noreferrer">purify-css</a> for WebPack.</p> <p>To build this project I'm usin <code>React</code>, <code>scss</code>, <code>WebPack</code> and <code>PostCss</code> to build and compile everything.</p> <p>So far I was able to have progress, but there is something wrong and I don't know why, but the expected result isn't correct. I have a very very basic setup just to test these scenarios, so this is my index.html and app.js files (the only files I have so far):</p> <p><strong>index.html</strong></p> <pre><code>&lt;body&gt; &lt;nav&gt; &lt;a href=""&gt;home&lt;/a&gt; &lt;/nav&gt; &lt;hr /&gt; &lt;div id="app"&gt;&lt;/div&gt; &lt;footer class="my-other-heading"&gt;&lt;/footer&gt; &lt;/body&gt; </code></pre> <p><strong>app.js</strong></p> <pre><code>class App extends React.Component { render() { return ( &lt;h1 className="my-other-heading"&gt;Mamamia!&lt;/h1&gt; ); } } render(&lt;App /&gt;, window.document.getElementById("app")); </code></pre> <p>On the css files I'm using <a href="https://necolas.github.io/normalize.css/" rel="noreferrer">Normalize.css</a> (with a bunch of css classess) and just 3 custom classes:</p> <pre><code>.my-class { background-color: #CCDDEE; } .my-heading { color: red; } .my-other-heading { color: blue; } </code></pre> <p>The expected output should contain only these classes:</p> <pre><code>html, body, nav, a, hr, div, footer, h1, .my-other-heading </code></pre> <p>However it has some other classes:</p> <pre><code>.my-heading, h2, h3, h4, [type='checkbox'] (and other similar, e.g.: [type='button'] </code></pre> <p>Why is this happening? It's removing almost all the classes it should, but some of them are still here, and classes that are clearly not being used on the index file. I don't know if they persist because of some other declaration on the React side, but i'm refering only the src files. This is my purify-css config:</p> <pre><code>new PurifyCSSPlugin({ paths: glob.sync([ path.join(__dirname, '..', 'src', '**/*.html'), path.join(__dirname, '..', 'src', '**/*.js'), ]), }) </code></pre>
0debug
static inline void gen_op_clear_ieee_excp_and_FTT(void) { tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~(FSR_FTT_MASK | FSR_CEXC_MASK)); }
1threat
static void write_bootloader(uint8_t *base, int64_t run_addr, int64_t kernel_entry) { uint32_t *p; p = (uint32_t *)base; stl_p(p++, 0x08000000 | ((run_addr + 0x580) & 0x0fffffff) >> 2); stl_p(p++, 0x00000000); stl_p(base + 0x500, run_addr + 0x0580); stl_p(base + 0x504, run_addr + 0x083c); stl_p(base + 0x520, run_addr + 0x0580); stl_p(base + 0x52c, run_addr + 0x0800); stl_p(base + 0x534, run_addr + 0x0808); stl_p(base + 0x538, run_addr + 0x0800); stl_p(base + 0x53c, run_addr + 0x0800); stl_p(base + 0x540, run_addr + 0x0800); stl_p(base + 0x544, run_addr + 0x0800); stl_p(base + 0x548, run_addr + 0x0800); stl_p(base + 0x54c, run_addr + 0x0800); stl_p(base + 0x550, run_addr + 0x0800); stl_p(base + 0x554, run_addr + 0x0800); p = (uint32_t *) (base + 0x580); if (semihosting_get_argc()) { stl_p(p++, 0x00000000); } else { stl_p(p++, 0x24040002); } stl_p(p++, 0x3c1d0000 | (((ENVP_ADDR - 64) >> 16) & 0xffff)); stl_p(p++, 0x37bd0000 | ((ENVP_ADDR - 64) & 0xffff)); stl_p(p++, 0x3c050000 | ((ENVP_ADDR >> 16) & 0xffff)); stl_p(p++, 0x34a50000 | (ENVP_ADDR & 0xffff)); stl_p(p++, 0x3c060000 | (((ENVP_ADDR + 8) >> 16) & 0xffff)); stl_p(p++, 0x34c60000 | ((ENVP_ADDR + 8) & 0xffff)); stl_p(p++, 0x3c070000 | (loaderparams.ram_low_size >> 16)); stl_p(p++, 0x34e70000 | (loaderparams.ram_low_size & 0xffff)); stl_p(p++, 0x3c09b400); #ifdef TARGET_WORDS_BIGENDIAN stl_p(p++, 0x3c08df00); #else stl_p(p++, 0x340800df); #endif stl_p(p++, 0xad280068); stl_p(p++, 0x3c09bbe0); #ifdef TARGET_WORDS_BIGENDIAN stl_p(p++, 0x3c08c000); #else stl_p(p++, 0x340800c0); #endif stl_p(p++, 0xad280048); #ifdef TARGET_WORDS_BIGENDIAN stl_p(p++, 0x3c084000); #else stl_p(p++, 0x34080040); #endif stl_p(p++, 0xad280050); #ifdef TARGET_WORDS_BIGENDIAN stl_p(p++, 0x3c088000); #else stl_p(p++, 0x34080080); #endif stl_p(p++, 0xad280058); #ifdef TARGET_WORDS_BIGENDIAN stl_p(p++, 0x3c083f00); #else stl_p(p++, 0x3408003f); #endif stl_p(p++, 0xad280060); #ifdef TARGET_WORDS_BIGENDIAN stl_p(p++, 0x3c08c100); #else stl_p(p++, 0x340800c1); #endif stl_p(p++, 0xad280080); #ifdef TARGET_WORDS_BIGENDIAN stl_p(p++, 0x3c085e00); #else stl_p(p++, 0x3408005e); #endif stl_p(p++, 0xad280088); stl_p(p++, 0x3c1f0000 | ((kernel_entry >> 16) & 0xffff)); stl_p(p++, 0x37ff0000 | (kernel_entry & 0xffff)); stl_p(p++, 0x03e00009); stl_p(p++, 0x00000000); p = (uint32_t *) (base + 0x800); stl_p(p++, 0x03e00009); stl_p(p++, 0x24020000); stl_p(p++, 0x03e06821); stl_p(p++, 0x00805821); stl_p(p++, 0x00a05021); stl_p(p++, 0x91440000); stl_p(p++, 0x254a0001); stl_p(p++, 0x10800005); stl_p(p++, 0x00000000); stl_p(p++, 0x0ff0021c); stl_p(p++, 0x00000000); stl_p(p++, 0x08000205); stl_p(p++, 0x00000000); stl_p(p++, 0x01a00009); stl_p(p++, 0x01602021); stl_p(p++, 0x03e06821); stl_p(p++, 0x00805821); stl_p(p++, 0x00a05021); stl_p(p++, 0x00c06021); stl_p(p++, 0x91440000); stl_p(p++, 0x0ff0021c); stl_p(p++, 0x00000000); stl_p(p++, 0x254a0001); stl_p(p++, 0x258cffff); stl_p(p++, 0x1580fffa); stl_p(p++, 0x00000000); stl_p(p++, 0x01a00009); stl_p(p++, 0x01602021); stl_p(p++, 0x3c08b800); stl_p(p++, 0x350803f8); stl_p(p++, 0x91090005); stl_p(p++, 0x00000000); stl_p(p++, 0x31290040); stl_p(p++, 0x1120fffc); stl_p(p++, 0x00000000); stl_p(p++, 0x03e00009); stl_p(p++, 0xa1040000); }
1threat
How does request pass through filter even though servlet mapping is not present? : <p>I have web.xml which contains just a filter, Which maps to a specific URL pattern. If I give a url which matches the pattern. It goes through the filter comes back and gives 404 status. I understand that this is because the there is no resource mapped in web.xml. Why would it go through the filter?</p> <p>Can I keep a wrapper around filter response and modify the response to a meaningful one instead of giving 404?</p>
0debug
how to disable button for somtime on click in android studio : I'm using **android studio** and i want to make a button disable when clicked for say 2 seconds and make it enable automatically after 2 seconds. i don't know where to start from. Can someone give me the code for doing this?
0debug
android - Is possible delete a file from external/internal storage from PHP? : <p>I need to remove a file from internal/external storage in smartphone that have my app installed, using PHP. I can't update my app if I don't remove this file. How can I do it?</p> <p>Thanks</p>
0debug
static void omap_tcmi_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; if (size != 4) { return omap_badwidth_write32(opaque, addr, value); } switch (addr) { case 0x00: case 0x04: case 0x08: case 0x10: case 0x14: case 0x18: case 0x1c: case 0x20: case 0x24: case 0x28: case 0x2c: case 0x30: case 0x3c: case 0x40: s->tcmi_regs[addr >> 2] = value; break; case 0x0c: s->tcmi_regs[addr >> 2] = (value & 0xf) | (1 << 4); break; default: OMAP_BAD_REG(addr); } }
1threat
static int msf_read_header(AVFormatContext *s) { unsigned codec, align, size; AVStream *st; avio_skip(s->pb, 4); st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; codec = avio_rb32(s->pb); st->codec->channels = avio_rb32(s->pb); if (st->codec->channels <= 0) return AVERROR_INVALIDDATA; size = avio_rb32(s->pb); st->codec->sample_rate = avio_rb32(s->pb); if (st->codec->sample_rate <= 0) return AVERROR_INVALIDDATA; align = avio_rb32(s->pb) ; if (align > INT_MAX / st->codec->channels) return AVERROR_INVALIDDATA; st->codec->block_align = align; switch (codec) { case 0: st->codec->codec_id = AV_CODEC_ID_PCM_S16BE; break; case 3: st->codec->block_align = 16 * st->codec->channels; st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX; break; case 7: st->need_parsing = AVSTREAM_PARSE_FULL_RAW; st->codec->codec_id = AV_CODEC_ID_MP3; break; default: avpriv_request_sample(s, "Codec %d", codec); return AVERROR_PATCHWELCOME; } st->duration = av_get_audio_frame_duration(st->codec, size); avio_skip(s->pb, 0x40 - avio_tell(s->pb)); avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); return 0; }
1threat
rdt_parse_sdp_line (AVFormatContext *s, int st_index, PayloadContext *rdt, const char *line) { AVStream *stream = s->streams[st_index]; const char *p = line; if (av_strstart(p, "OpaqueData:buffer;", &p)) { rdt->mlti_data = rdt_parse_b64buf(&rdt->mlti_data_size, p); } else if (av_strstart(p, "StartTime:integer;", &p)) stream->first_dts = atoi(p); else if (av_strstart(p, "ASMRuleBook:string;", &p)) { int n, first = -1; for (n = 0; n < s->nb_streams; n++) if (s->streams[n]->id == stream->id) { int count = s->streams[n]->index + 1; if (first == -1) first = n; if (rdt->nb_rmst < count) { RMStream **rmst= av_realloc(rdt->rmst, count*sizeof(*rmst)); if (!rmst) return AVERROR(ENOMEM); memset(rmst + rdt->nb_rmst, 0, (count - rdt->nb_rmst) * sizeof(*rmst)); rdt->rmst = rmst; rdt->nb_rmst = count; } rdt->rmst[s->streams[n]->index] = ff_rm_alloc_rmstream(); rdt_load_mdpr(rdt, s->streams[n], (n - first) * 2); if (s->streams[n]->codec->codec_id == CODEC_ID_AAC) s->streams[n]->codec->frame_size = 1; } } return 0; }
1threat
float to byte[4] to float without using BitConverter? : <p>How can I convert a float to an array of bytes then re-convert the byte array to float without using BitConverter??</p> <p>Thanks in advance.</p>
0debug
How to preserve space in HTML select option list : <select name='test'> <option value='north' india>north india</option> <option value='goa'>goa</option> </select> If I select "north india" in the list PHP echos only "north". Why is that?
0debug
MockMvc no longer handles UTF-8 characters with Spring Boot 2.2.0.RELEASE : <p>After I upgraded to the newly released <code>2.2.0.RELEASE</code> version of Spring Boot some of my tests failed. It appears that the <code>MediaType.APPLICATION_JSON_UTF8</code> has been deprecated and is no longer returned as default content type from controller methods that do not specify the content type explicitly.</p> <p>Test code like</p> <pre><code>String content = mockMvc.perform(get("/some-api") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andReturn() .getResponse() .getContentAsString(); </code></pre> <p>suddenly did not work anymore as the content type was mismatched as shown below</p> <pre><code>java.lang.AssertionError: Content type Expected :application/json;charset=UTF-8 Actual :application/json </code></pre> <p>Changing the code to <code>.andExpect(content().contentType(MediaType.APPLICATION_JSON))</code> resolved the issue for now. </p> <p>But now when comparing <code>content</code> to the expected serialized object there is still a mismatch if there are any special characters in the object. It appears that the <code>.getContentAsString()</code> method does not make use of the UTF-8 character encoding by default (any more).</p> <pre><code>java.lang.AssertionError: Response content expected:&lt;[{"description":"Er hörte leise Schritte hinter sich."}]&gt; but was:&lt;[{"description":"Er hörte leise Schritte hinter sich."}]&gt; Expected :[{"description":"Er hörte leise Schritte hinter sich."}] Actual :[{"description":"Er hörte leise Schritte hinter sich."}] </code></pre> <p>How can I get <code>content</code> in UTF-8 encoding?</p>
0debug
"REST API Client" option in Visual Studio for ASP.NET Core projects? : <p>I've got a ASP.NET REST API up and running in Azure. From an older .NET 4.5 project in Visual I've generated a client using this menu option:</p> <p><a href="https://i.stack.imgur.com/8eHGA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8eHGA.png" alt="Old .NET 4.5 project"></a></p> <p>But when I create a new ASP.NET Core (ASP.NET 5) project, and want to generate the client there is no such option:</p> <p><a href="https://i.stack.imgur.com/BdTYE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BdTYE.png" alt="New ASP.NET Core project"></a></p> <p>What is the intended way to generate the client for my REST api in ASP.NET Core projects?</p>
0debug
static int msrle_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MsrleContext *s = avctx->priv_data; int istride = FFALIGN(avctx->width*avctx->bits_per_coded_sample, 32) / 8; int ret; s->buf = buf; s->size = buf_size; if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) return ret; if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) { const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); if (pal) { s->frame->palette_has_changed = 1; memcpy(s->pal, pal, AVPALETTE_SIZE); } memcpy(s->frame->data[1], s->pal, AVPALETTE_SIZE); } if (avctx->height * istride == avpkt->size) { int linesize = (avctx->width * avctx->bits_per_coded_sample + 7) / 8; uint8_t *ptr = s->frame->data[0]; uint8_t *buf = avpkt->data + (avctx->height-1)*istride; int i, j; for (i = 0; i < avctx->height; i++) { if (avctx->bits_per_coded_sample == 4) { for (j = 0; j < avctx->width - 1; j += 2) { ptr[j+0] = buf[j>>1] >> 4; ptr[j+1] = buf[j>>1] & 0xF; } if (avctx->width & 1) ptr[j+0] = buf[j>>1] >> 4; } else { memcpy(ptr, buf, linesize); } buf -= istride; ptr += s->frame->linesize[0]; } } else { bytestream2_init(&s->gb, buf, buf_size); ff_msrle_decode(avctx, (AVPicture*)s->frame, avctx->bits_per_coded_sample, &s->gb); } if ((ret = av_frame_ref(data, s->frame)) < 0) return ret; *got_frame = 1; return buf_size; }
1threat
static inline void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2) { TCGv r_temp, zero; r_temp = tcg_temp_new(); zero = tcg_const_tl(0); tcg_gen_andi_tl(cpu_cc_src, src1, 0xffffffff); tcg_gen_andi_tl(r_temp, cpu_y, 0x1); tcg_gen_andi_tl(cpu_cc_src2, src2, 0xffffffff); tcg_gen_movcond_tl(TCG_COND_EQ, cpu_cc_src2, r_temp, zero, zero, cpu_cc_src2); tcg_temp_free(zero); tcg_gen_andi_tl(r_temp, cpu_cc_src, 0x1); tcg_gen_shli_tl(r_temp, r_temp, 31); tcg_gen_shri_tl(cpu_tmp0, cpu_y, 1); tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, 0x7fffffff); tcg_gen_or_tl(cpu_tmp0, cpu_tmp0, r_temp); tcg_gen_andi_tl(cpu_y, cpu_tmp0, 0xffffffff); gen_mov_reg_N(cpu_tmp0, cpu_psr); gen_mov_reg_V(r_temp, cpu_psr); tcg_gen_xor_tl(cpu_tmp0, cpu_tmp0, r_temp); tcg_temp_free(r_temp); tcg_gen_shli_tl(cpu_tmp0, cpu_tmp0, 31); tcg_gen_shri_tl(cpu_cc_src, cpu_cc_src, 1); tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, cpu_tmp0); tcg_gen_add_tl(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); tcg_gen_mov_tl(dst, cpu_cc_dst); }
1threat
How to find the features names of the coefficients using scikit linear regression? : <pre><code>#training the model model_1_features = ['sqft_living', 'bathrooms', 'bedrooms', 'lat', 'long'] model_2_features = model_1_features + ['bed_bath_rooms'] model_3_features = model_2_features + ['bedrooms_squared', 'log_sqft_living', 'lat_plus_long'] model_1 = linear_model.LinearRegression() model_1.fit(train_data[model_1_features], train_data['price']) model_2 = linear_model.LinearRegression() model_2.fit(train_data[model_2_features], train_data['price']) model_3 = linear_model.LinearRegression() model_3.fit(train_data[model_3_features], train_data['price']) # extracting the coef print model_1.coef_ print model_2.coef_ print model_3.coef_ </code></pre> <p>If I change the order of the features, the coef are still printed in the same order, hence I would like to know the mapping of the feature with the coeff</p>
0debug
I'm a beginner in php and i want to echo this properly but the error says : <pre><code>Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\project\homepage.php on line 235 </code></pre> <p>I want to echo my post in my wall if it has a content to post but if the length of my textarea is &lt;0 or above to 160 I want to echo an error then redirect to same page. But if it has a content I want to echo that messages.</p> <pre><code>&lt;?php //build query for displaying post messages $strQuery = "SELECT * FROM freedom_wall ORDER BY id DESC"; // execute if ($hQuery = $objConnection-&gt;query($strQuery)) { //get data while($row=$hQuery-&gt;fetch_assoc()){ $link_address = "files.php"; ?&gt; &lt;hr&gt; &lt;?php $postbody = $_POST['post_msg']; if (strlen($postbody) &gt; 160 || strlen($postbody) &lt; 1) { echo ("&lt;script LANGUAGE='JavaScript'&gt; window.alert('Nothing to post!'); window.location.href='homepage.php'; &lt;/script&gt;"); } else { //This is where I received the error i'm hard enough in using ' and " with concats echo "&lt;br&gt;&lt;h4&gt;&lt;?php echo $row['username']; ?&gt;&lt;/h4&gt; &lt;p&gt;&lt;h4&gt;&lt;?php echo $row['post_msg']; ?&gt;&lt;/h4&gt; &lt;?php echo '&lt;a href='".$link_address."'&gt;".$row["post_file"]."&lt;/a&gt;';?&gt; &lt;/p&gt;"; ?&gt; Please help me </code></pre>
0debug
static void avc_luma_mid_and_aver_dst_4x4_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride) { v16i8 src0, src1, src2, src3, src4; v16i8 mask0, mask1, mask2; v8i16 hz_out0, hz_out1, hz_out2, hz_out3; v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8; v8i16 res0, res1, res2, res3; v16u8 dst0, dst1, dst2, dst3; v16u8 tmp0, tmp1, tmp2, tmp3; LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2); LD_SB5(src, src_stride, src0, src1, src2, src3, src4); src += (5 * src_stride); XORI_B5_128_SB(src0, src1, src2, src3, src4); hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1, mask0, mask1, mask2); hz_out2 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3, mask0, mask1, mask2); PCKOD_D2_SH(hz_out0, hz_out0, hz_out2, hz_out2, hz_out1, hz_out3); hz_out4 = AVC_HORZ_FILTER_SH(src4, src4, mask0, mask1, mask2); LD_SB4(src, src_stride, src0, src1, src2, src3); XORI_B4_128_SB(src0, src1, src2, src3); hz_out5 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1, mask0, mask1, mask2); hz_out7 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3, mask0, mask1, mask2); PCKOD_D2_SH(hz_out5, hz_out5, hz_out7, hz_out7, hz_out6, hz_out8); res0 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out0, hz_out1, hz_out2, hz_out3, hz_out4, hz_out5); res1 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out1, hz_out2, hz_out3, hz_out4, hz_out5, hz_out6); res2 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out2, hz_out3, hz_out4, hz_out5, hz_out6, hz_out7); res3 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out3, hz_out4, hz_out5, hz_out6, hz_out7, hz_out8); LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); tmp0 = PCKEV_XORI128_UB(res0, res1); tmp1 = PCKEV_XORI128_UB(res2, res3); PCKEV_D2_UB(dst1, dst0, dst3, dst2, tmp2, tmp3); AVER_UB2_UB(tmp0, tmp2, tmp1, tmp3, tmp0, tmp1); ST4x4_UB(tmp0, tmp1, 0, 2, 0, 2, dst, dst_stride); }
1threat
static int parse_chap(struct iscsi_context *iscsi, const char *target) { QemuOptsList *list; QemuOpts *opts; const char *user = NULL; const char *password = NULL; list = qemu_find_opts("iscsi"); if (!list) { return 0; } opts = qemu_opts_find(list, target); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return 0; } } user = qemu_opt_get(opts, "user"); if (!user) { return 0; } password = qemu_opt_get(opts, "password"); if (!password) { error_report("CHAP username specified but no password was given"); return -1; } if (iscsi_set_initiator_username_pwd(iscsi, user, password)) { error_report("Failed to set initiator username and password"); return -1; } return 0; }
1threat
A bit of math programming. 4 colors on a grid : <p>Let's say I have a grid</p> <pre><code>----- | | | ----- | | | ----- </code></pre> <p>And I have 4 colors, Red, Blue, Green, and Yellow. I am trying to figure out how many different combinations there can be using those colors in the each way. For instance I might have:</p> <pre><code>BR BR BY BY GY YG RG GR </code></pre> <p>etc. I can use the same color more than once so it can be like this:</p> <pre><code>BB BB BB RR or even BR or BB </code></pre> <p>I tried drawing out the different combos but I always end up getting more confused the more I draw them out. I'm trying to figure this out because I'm using it for a tile system for a game I'm trying to plan out. I just need to know the different combos so I'd know how many tiles I'd need to cover everything.</p> <p>There has to be a math way to solve this, I just can't figure it out for the life of me. </p> <p>Thanks in advance oh math programming gods. I'll be forever in your debt</p>
0debug
Regex replace +46 to 0 JavaScript : <p>I'm trying to learn regex. I need to find +46 and replace it with 0. I've been racking my brain but I can't figure out the correct syntax. I'm trying to do it in JS with replace.</p> <p>Any takers?</p>
0debug
static int mlp_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { MLPParseContext *mp = s->priv_data; int sync_present; uint8_t parity_bits; int next; int i, p = 0; *poutbuf_size = 0; if (buf_size == 0) return 0; if (!mp->in_sync) { for (i = 0; i < buf_size; i++) { mp->pc.state = (mp->pc.state << 8) | buf[i]; if ((mp->pc.state & 0xfffffffe) == 0xf8726fba && mp->pc.index + i >= 7) { mp->in_sync = 1; mp->bytes_left = 0; break; } } if (!mp->in_sync) { ff_combine_frame(&mp->pc, END_NOT_FOUND, &buf, &buf_size); return buf_size; } ff_combine_frame(&mp->pc, i - 7, &buf, &buf_size); return i - 7; } if (mp->bytes_left == 0) { for(; mp->pc.overread>0; mp->pc.overread--) { mp->pc.buffer[mp->pc.index++]= mp->pc.buffer[mp->pc.overread_index++]; } if (mp->pc.index + buf_size < 2) { ff_combine_frame(&mp->pc, END_NOT_FOUND, &buf, &buf_size); return buf_size; } mp->bytes_left = ((mp->pc.index > 0 ? mp->pc.buffer[0] : buf[0]) << 8) | (mp->pc.index > 1 ? mp->pc.buffer[1] : buf[1-mp->pc.index]); mp->bytes_left = (mp->bytes_left & 0xfff) * 2; if (mp->bytes_left <= 0) { goto lost_sync; } mp->bytes_left -= mp->pc.index; } next = (mp->bytes_left > buf_size) ? END_NOT_FOUND : mp->bytes_left; if (ff_combine_frame(&mp->pc, next, &buf, &buf_size) < 0) { mp->bytes_left -= buf_size; return buf_size; } mp->bytes_left = 0; sync_present = (AV_RB32(buf + 4) & 0xfffffffe) == 0xf8726fba; if (!sync_present) { parity_bits = 0; for (i = -1; i < mp->num_substreams; i++) { parity_bits ^= buf[p++]; parity_bits ^= buf[p++]; if (i < 0 || buf[p-2] & 0x80) { parity_bits ^= buf[p++]; parity_bits ^= buf[p++]; } } if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) { av_log(avctx, AV_LOG_INFO, "mlpparse: Parity check failed.\n"); goto lost_sync; } } else { GetBitContext gb; MLPHeaderInfo mh; init_get_bits(&gb, buf + 4, (buf_size - 4) << 3); if (ff_mlp_read_major_sync(avctx, &mh, &gb) < 0) goto lost_sync; avctx->bits_per_raw_sample = mh.group1_bits; if (avctx->bits_per_raw_sample > 16) avctx->sample_fmt = AV_SAMPLE_FMT_S32; else avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->sample_rate = mh.group1_samplerate; s->duration = mh.access_unit_size; if (mh.stream_type == 0xbb) { avctx->channels = mlp_channels[mh.channels_mlp]; avctx->channel_layout = ff_mlp_layout[mh.channels_mlp]; } else { if (mh.channels_thd_stream2) { avctx->channels = truehd_channels(mh.channels_thd_stream2); avctx->channel_layout = ff_truehd_layout(mh.channels_thd_stream2); } else { avctx->channels = truehd_channels(mh.channels_thd_stream1); avctx->channel_layout = ff_truehd_layout(mh.channels_thd_stream1); } } } if (!mh.is_vbr) avctx->bit_rate = mh.peak_bitrate; mp->num_substreams = mh.num_substreams; } *poutbuf = buf; *poutbuf_size = buf_size; return next; lost_sync: mp->in_sync = 0; return 1; }
1threat
How can I prevent my website from shells or malwares uploading? : <p>I have a image and video sharing website , I think which is not secure. Because anyone can upload shells or malwares instead of image and video. So I want to know how YouTube or Facebook prevent them from this vulnerability. Please tell me anybody.</p>
0debug
How to modify tcp congestion algorithm? : i am going to modify the tcp congestion algorithm(such as Vegas,Reno).I know this will need to modify the kernel of linux,but i do not know hot to do it.I want to know that if i want to change the RTT time of Vegas,what should i do?.I really appreciate your help,Thank you.
0debug
select data from one coloum according to second coloumn : hello i think the title is not correct but here explain you about the exect problem. i have a table name 'testdata' in which four rows:- [enter image description here][1] [1]: https://i.stack.imgur.com/WSDH8.png in this image have structure of table. now my recruitment is :- i want data according to bada no. in with total of Daily Milk ex.:- 1. b1 have total dailymilk is 15 2. b2 have total dailymilk is 14 3. b3 have total dailymilk is 18 i want something like:- [enter image description here][2] [2]: https://i.stack.imgur.com/SnIFn.png Hope you understand. Help me Please
0debug
How to define folder colors in powershell? : <blockquote> <p>Can put colors in directory like this image?</p> </blockquote> <p><a href="https://i.stack.imgur.com/tseWs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tseWs.png" alt="Console color settings"></a></p> <p><a href="https://devblogs.microsoft.com/commandline/new-experimental-console-features/" rel="nofollow noreferrer">devblogs.microsoft</a></p>
0debug
int tlb_set_page_exec(CPUState *env, target_ulong vaddr, target_phys_addr_t paddr, int prot, int is_user, int is_softmmu) { PhysPageDesc *p; unsigned long pd; unsigned int index; target_ulong address; target_phys_addr_t addend; int ret; CPUTLBEntry *te; p = phys_page_find(paddr >> TARGET_PAGE_BITS); if (!p) { pd = IO_MEM_UNASSIGNED; } else { pd = p->phys_offset; } #if defined(DEBUG_TLB) printf("tlb_set_page: vaddr=" TARGET_FMT_lx " paddr=0x%08x prot=%x u=%d smmu=%d pd=0x%08lx\n", vaddr, (int)paddr, prot, is_user, is_softmmu, pd); #endif ret = 0; #if !defined(CONFIG_SOFTMMU) if (is_softmmu) #endif { if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM && !(pd & IO_MEM_ROMD)) { address = vaddr | pd; addend = paddr; } else { address = vaddr; addend = (unsigned long)phys_ram_base + (pd & TARGET_PAGE_MASK); } for (i = 0; i < env->nb_watchpoints; i++) { if (vaddr == (env->watchpoint[i].vaddr & TARGET_PAGE_MASK)) { if (address & ~TARGET_PAGE_MASK) { env->watchpoint[i].is_ram = 0; address = vaddr | io_mem_watch; } else { env->watchpoint[i].is_ram = 1; pd = (pd & TARGET_PAGE_MASK) | io_mem_watch | IO_MEM_ROMD; } } } index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); addend -= vaddr; te = &env->tlb_table[is_user][index]; te->addend = addend; if (prot & PAGE_READ) { te->addr_read = address; } else { te->addr_read = -1; } if (prot & PAGE_EXEC) { te->addr_code = address; } else { te->addr_code = -1; } if (prot & PAGE_WRITE) { if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_ROM || (pd & IO_MEM_ROMD)) { te->addr_write = vaddr | (pd & ~(TARGET_PAGE_MASK | IO_MEM_ROMD)); } else if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_RAM && !cpu_physical_memory_is_dirty(pd)) { te->addr_write = vaddr | IO_MEM_NOTDIRTY; } else { te->addr_write = address; } } else { te->addr_write = -1; } } #if !defined(CONFIG_SOFTMMU) else { if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM) { if (!(env->hflags & HF_SOFTMMU_MASK)) ret = 2; } else { void *map_addr; if (vaddr >= MMAP_AREA_END) { ret = 2; } else { if (prot & PROT_WRITE) { if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_ROM || #if defined(TARGET_HAS_SMC) || 1 first_tb || #endif ((pd & ~TARGET_PAGE_MASK) == IO_MEM_RAM && !cpu_physical_memory_is_dirty(pd))) { VirtPageDesc *vp; vp = virt_page_find_alloc(vaddr >> TARGET_PAGE_BITS, 1); vp->phys_addr = pd; vp->prot = prot; vp->valid_tag = virt_valid_tag; prot &= ~PAGE_WRITE; } } map_addr = mmap((void *)vaddr, TARGET_PAGE_SIZE, prot, MAP_SHARED | MAP_FIXED, phys_ram_fd, (pd & TARGET_PAGE_MASK)); if (map_addr == MAP_FAILED) { cpu_abort(env, "mmap failed when mapped physical address 0x%08x to virtual address 0x%08x\n", paddr, vaddr); } } } } #endif return ret; }
1threat
React linter airbnb proptypes array : <p>I have the following <code>PropTypes</code>:</p> <pre><code>SmartTable.propTypes = { name: React.PropTypes.string.isRequired, cols: React.PropTypes.array.isRequired, rows: React.PropTypes.array.isRequired, }; </code></pre> <p>but the linter says me:</p> <p><code>Prop type array is forbidden</code>, how can I change it?</p>
0debug
static inline void gen_op_fcmpeq(int fccno) { switch (fccno) { case 0: gen_helper_fcmpeq(cpu_env); break; case 1: gen_helper_fcmpeq_fcc1(cpu_env); break; case 2: gen_helper_fcmpeq_fcc2(cpu_env); break; case 3: gen_helper_fcmpeq_fcc3(cpu_env); break; } }
1threat
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
JavaScript - Output random OBJECT from array of objects : <p>Quick question, I have an array of objects:</p> <pre><code>var objects = [ {username: jon, count: 5}, {username: sally, count: 7}, {username: mark, count: 9, ] </code></pre> <p>I want to output one of these objects at random so that I can access its properties and not just it's index. How do I do this?</p>
0debug
How to tell DocumentDB SDK to use camelCase during linq query? : <p>Considering the document <code>{ "userName": "user1" }</code> stored in the User collection, and the following <code>User</code> class: </p> <pre><code>public class User { public string Id { get; set; } public string UserName { get; set; } } </code></pre> <p>With the following JSON.net settings:</p> <pre><code>JsonConvert.DefaultSettings = () =&gt; { return new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), }; }; </code></pre> <p>When I query with Linq as such:</p> <pre><code>var t = _client.CreateDocumentQuery&lt;User&gt;(_collection.SelfLink) .Where(u =&gt; u.UserName == "user1").AsDocumentQuery().ExecuteNextAsync(); t.Wait(); var users = t.Result; var user = users.FirstOrDefault(); </code></pre> <p><code>user</code> is null. Changing the Document to have a pascal casing or the POCO to use a camel casing solves the issue. Of course I do not want any of those as I want my JSON objects and C# objects to be "standarized". </p> <p>How can I tell the DocumentDB SDK to map my object's property names using camel casing, similar as JSON.net?</p>
0debug
static void pc_q35_init_1_4(QEMUMachineInitArgs *args) { pc_sysfw_flash_vs_rom_bug_compatible = true; has_pvpanic = false; x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE); pc_q35_init(args); }
1threat
Limiting Jenkins pipeline to running only on specific nodes : <p>I'm building jobs that will be using Jenkins piplines extensively. Our nodes are designated per project by their tags, but unlike regular jobs the pipeline build does not seem to have the "Restrict where this project can be run" checkbox. How can I specify on which node the pipeline will run the way I do for regular jobs?</p>
0debug
bool arm_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) { return regime_using_lpae_format(env, mmu_idx); }
1threat
static void opt_pass(const char *pass_str) { int pass; pass = atoi(pass_str); if (pass != 1 && pass != 2) { fprintf(stderr, "pass number can be only 1 or 2\n"); ffmpeg_exit(1); } do_pass = pass; }
1threat
void ff_h261_encode_init(MpegEncContext *s){ static int done = 0; if (!done) { done = 1; init_rl(&h261_rl_tcoeff); } s->min_qcoeff= -127; s->max_qcoeff= 127; s->y_dc_scale_table= s->c_dc_scale_table= ff_mpeg1_dc_scale_table; }
1threat
Jenkins Amazon ECR Plugin login issue "Authorization Token has expired" : <p>I've followed the instructions on the Amazon ECR Plugin (<a href="https://wiki.jenkins-ci.org/display/JENKINS/Amazon+ECR" rel="noreferrer">https://wiki.jenkins-ci.org/display/JENKINS/Amazon+ECR</a>, which simply instructs a user to install the Amazon ECR configure the Docker Build &amp; Deploy plugin), but Jenkins is unable to authenticate with ECR.</p> <p>The error message produced is:</p> <pre><code>denied: Your Authorization Token has expired. Please run 'aws ecr get-login' to fetch a new one. </code></pre> <p>Any advice anyone can provide is greatly appreciated.</p>
0debug
Sklearn: Is there any way to debug Pipelines? : <p>I have created some pipelines for classification task and I want to check out what information is being present/stored at each stage (e.g. text_stats, ngram_tfidf). How could I do this.</p> <pre><code>pipeline = Pipeline([ ('features',FeatureUnion([ ('text_stats', Pipeline([ ('length',TextStats()), ('vect', DictVectorizer()) ])), ('ngram_tfidf',Pipeline([ ('count_vect', CountVectorizer(tokenizer=tokenize_bigram_stem,stop_words=stopwords)), ('tfidf', TfidfTransformer()) ])) ])), ('classifier',MultinomialNB(alpha=0.1)) ]) </code></pre>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
Count level of object depth : <p>I have a <strong>javascript</strong> object and I would like to count the number of nested depth.</p> <p>Example Object</p> <p><strong>Answer</strong> should be equal 4 (count level depth)</p> <pre><code>data: { first: [ { value: '', children: [ { value: '', children: [ { value: '', children: [ { value: '', children: [], }, { value: '', children: [], }, ], }, ], }, ], }, ], </code></pre> <p></p>
0debug
void do_nego (void) { if (likely(T0 != INT32_MIN)) { xer_ov = 0; T0 = -Ts0; } else { xer_ov = 1; xer_so = 1; } }
1threat
GenericList *visit_next_list(Visitor *v, GenericList **list, size_t size) { assert(list && size >= sizeof(GenericList)); return v->next_list(v, list, size); }
1threat
How to Deserialize a list of objects from json in flutter : <p>I am using the dart package json_serializable for json serialization. Looking at the flutter documentation it shows how to deserialize a single object as follow:</p> <pre><code>Future&lt;Post&gt; fetchPost() async { final response = await http.get('https://jsonplaceholder.typicode.com/posts/1'); if (response.statusCode == 200) { // If the call to the server was successful, parse the JSON return Post.fromJson(json.decode(response.body)); } else { // If that call was not successful, throw an error. throw Exception('Failed to load post'); } } </code></pre> <p>However, I am not familiar enough with dart to figure out how to do the same for a list of items instead of a single instance.</p>
0debug
int virtio_gpu_create_mapping_iov(struct virtio_gpu_resource_attach_backing *ab, struct virtio_gpu_ctrl_command *cmd, struct iovec **iov) { struct virtio_gpu_mem_entry *ents; size_t esize, s; int i; if (ab->nr_entries > 16384) { qemu_log_mask(LOG_GUEST_ERROR, "%s: nr_entries is too big (%d > 1024)\n", __func__, ab->nr_entries); return -1; } esize = sizeof(*ents) * ab->nr_entries; ents = g_malloc(esize); s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num, sizeof(*ab), ents, esize); if (s != esize) { qemu_log_mask(LOG_GUEST_ERROR, "%s: command data size incorrect %zu vs %zu\n", __func__, s, esize); g_free(ents); return -1; } *iov = g_malloc0(sizeof(struct iovec) * ab->nr_entries); for (i = 0; i < ab->nr_entries; i++) { hwaddr len = ents[i].length; (*iov)[i].iov_len = ents[i].length; (*iov)[i].iov_base = cpu_physical_memory_map(ents[i].addr, &len, 1); if (!(*iov)[i].iov_base || len != ents[i].length) { qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to map MMIO memory for" " resource %d element %d\n", __func__, ab->resource_id, i); virtio_gpu_cleanup_mapping_iov(*iov, i); g_free(ents); g_free(*iov); *iov = NULL; return -1; } } g_free(ents); return 0; }
1threat
Filtering out letters only and numbers only from dictionary : So basically I have a dictionary called dict_info. Which consists different types of keys. However, I'd like to iterate through these dictionaries then filter out the ones that has ONLY letters and ONLY integers. However if they have both for instance 123456s, 123456q and 123456b. These three key has letters and integers on it. So I'd like to create a json file saving these three key-value. And I'd like to have a space inbetween digits and letters. Like 123456 s, 123456 q, and 123456 b. So output in my json would something like with everything filtered out output: { 123456 q : check 123456 b : check 123456 s : check } def check_if_works(): dict_info = {} dict_info['1234'] = "check" dict_info['12456s'] = "check" dict_info['12456q'] = "check" dict_info['12456b'] = "check" dict_info['123456'] = "check" dict_info['asdftes'] = "check" dict_info['asdftess'] = "check" dict_info['asdftessd'] = "check" arr = [] for key,value in dict_info.iteritems(): try: check_if_digits_only = int(key) check_if_letters_only = key.isalpha() except: new_dict = {} new_dict[key] = value arr.append(new_dict) print arr with open('output.json','wb') as outfile: json.dump(arr,outfile,indent=4) check_if_works()
0debug
static void qemu_laio_completion_cb(EventNotifier *e) { struct qemu_laio_state *s = container_of(e, struct qemu_laio_state, e); while (event_notifier_test_and_clear(&s->e)) { struct io_event events[MAX_EVENTS]; struct timespec ts = { 0 }; int nevents, i; do { nevents = io_getevents(s->ctx, MAX_EVENTS, MAX_EVENTS, events, &ts); } while (nevents == -EINTR); for (i = 0; i < nevents; i++) { struct iocb *iocb = events[i].obj; struct qemu_laiocb *laiocb = container_of(iocb, struct qemu_laiocb, iocb); laiocb->ret = io_event_ret(&events[i]); qemu_laio_process_completion(s, laiocb); } } }
1threat
Pyrhon Abstract class - object.__init__() takes no parameters : import abc class AbsBaseClass(abc.ABC): def __init__(self,x): self.x=x class DerivedClass(AbsBaseClass): def __init__(self,y): super(AbsBaseClass,self).__init__(y) ob=DerivedClass(5)
0debug
How to create a directory in plunker? : <p>How do you create a directory in a plunker ? or if there is a directory how do you create a new file/move in that directory ?</p> <p>Do you need to use an external tool for this ?</p> <p><code>Ex :</code> I have edited this existing <a href="http://plnkr.co/edit/ZfeAwx8ye3xRWjAUSIyn?p=options">angular2 plunker</a>, I have created <strong>myFile.ts</strong> file, I would like to move it in the <strong>app folder</strong>.<br> <a href="http://plnkr.co/edit/ZfeAwx8ye3xRWjAUSIyn?p=options">http://plnkr.co/edit/ZfeAwx8ye3xRWjAUSIyn?p=options</a></p>
0debug
static void xhci_port_update(XHCIPort *port, int is_detach) { port->portsc = PORTSC_PP; if (port->uport->dev && port->uport->dev->attached && !is_detach && (1 << port->uport->dev->speed) & port->speedmask) { port->portsc |= PORTSC_CCS; switch (port->uport->dev->speed) { case USB_SPEED_LOW: port->portsc |= PORTSC_SPEED_LOW; break; case USB_SPEED_FULL: port->portsc |= PORTSC_SPEED_FULL; break; case USB_SPEED_HIGH: port->portsc |= PORTSC_SPEED_HIGH; break; case USB_SPEED_SUPER: port->portsc |= PORTSC_SPEED_SUPER; break; } } if (xhci_running(port->xhci)) { port->portsc |= PORTSC_CSC; XHCIEvent ev = { ER_PORT_STATUS_CHANGE, CC_SUCCESS, port->portnr << 24}; xhci_event(port->xhci, &ev, 0); DPRINTF("xhci: port change event for port %d\n", port->portnr); } }
1threat
int qemu_acl_remove(qemu_acl *acl, const char *match) { qemu_acl_entry *entry; int i = 0; QTAILQ_FOREACH(entry, &acl->entries, next) { i++; if (strcmp(entry->match, match) == 0) { QTAILQ_REMOVE(&acl->entries, entry, next); return i; } } return -1; }
1threat
void helper_check_iow(CPUX86State *env, uint32_t t0) { check_io(env, t0, 2); }
1threat
Google chrome wrong returns the html : My input on php and i using XAMPP <a class="is-hidden-desktop"> <a id="sessionPanel"> <a class="navbar-item" onclick="$('#loginModal').toggleClass('is-active');$('#loginModalCard').animateCss('bounceInUp');" data-target="loginModal"> Giriş Yap</a> </a> </a> [Chrome output][1] [1]: https://i.stack.imgur.com/1fdnk.png
0debug
how to remove special character(\\\) from java string : String str="CHOICE(IS_PRESENT(\\\"CLIP\\\") ADD_CFS(\\\"SL6\\\") REMOVE_CFS(\\\"SMS\\\"))"; I wish to remove /// from java string please help
0debug
In R language /Tool. Find the sum of first 'N' whole numbers by using conditions? : Could you please write a code in R language for the following **Find the sum of first 20 whole number** by using while/for or IF conditions. Also suggest me the alternatives. so that I can learn different ways of writing a code. Thank You.
0debug
webpack dev server: watch arbitrary directory files and reload : <p>Is it possible to make webpack-dev-server reload whenever a specified set of arbitrary files changes?</p> <p>Something along the lines of:</p> <pre><code>devServer: { watchTheseFiles: [ 'path/to/files', 'path/to/more/files' ] } </code></pre> <p>And even more granularly, can I specify a regex of which files to watch?</p> <p>I'm doing this as a bit of a hack to reload when I trigger certain changes in arbitrary files (they could be <code>.txt</code>, <code>.png</code>, whatever...)</p> <p>At the moment, the specified paths in <code>contentBase</code> don't seem to trigger reload when files change.</p>
0debug
List final list of properties - Spring Cloud Config Server : <p>Spring Cloud Config Server accepts multiple profile and returns the properties for all the profiles when I access the /env endpoint of the application. The response lists the properties specific to each profile. If same property is present in 2 different property files , the one that is defined last takes precedence. Is there a way to get the final list of property key and values that will be used by the application?</p>
0debug
Disable cascade delete on EF Core 2 globally : <p>I need to know about ways of disabling cascade delete in <code>EF Core 2</code> globally. Any help is appricated.</p> <p>In EF 6.x we used following code to disable cascade delete on both <code>OneToMany</code> and <code>ManyToMany</code> realtions:</p> <pre><code>builder.Conventions.Remove&lt;OneToManyCascadeDeleteConvention&gt;(); builder.Conventions.Remove&lt;ManyToManyCascadeDeleteConvention&gt;(); </code></pre>
0debug
How can I get the raw request body in a Google Cloud Function? : <p>I need the raw request body to be able to SHA-1 digest it to validate the Facebook webhook X-Hub-Signature header that's passed along with the request to my Firebase Function (running on Google Cloud Functions).</p> <p>The problem is that in cases like this (with a <code>Content-Type: application/json</code> header) GCF automatically parses the body using <code>bodyParser.json()</code> which consumes the data from the stream (meaning it cannot be consumed again down the Express middleware chain) and only provides the parsed javascript object as <code>req.body</code>. The raw request buffer is discarded.</p> <p>I have tried to provide an Express app to <code>functions.https.onRequest()</code>, but that seems to be run as a child app or something with the request body already being parsed, just like when you pass a plain request-response callback to <code>onRequest()</code>.</p> <p>Is there any way to disable GCF from parsing the body for me? Or could I somehow specify my own <code>verify</code> callback to <code>bodyParser.json()</code>? Or is there some other way?</p> <p>PS: I first contacted Firebase support about this a week ago, but for lack of a response there I'm trying it here now.</p>
0debug
Grails...what's the latest IDE? : <p>Been out from the GRAILS-game for a while for various reasons.</p> <p>What IDE is the best now? Before it was really a, b, c - deploy but it seems it's not as tied to Eclipse as it was...is STS still in the game?</p> <p>Thanks in advance!</p>
0debug
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size, bps; size= RAW_SAMPLES*s->streams[0]->codec->block_align; ret= av_get_packet(s->pb, pkt, size); pkt->stream_index = 0; if (ret < 0) return ret; bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id); assert(bps); pkt->dts= pkt->pts= pkt->pos*8 / (bps * s->streams[0]->codec->channels); return ret; }
1threat
Dictionary<string, object> to Dictionary<string, float> : <p>I'm currently working on a .NET Framework 4.7.2 application. Given is a <code>Dictionary&lt;string, object&gt;</code>. I need to write a method to transform the structure to a <code>Dictionary&lt;string, float&gt;</code>.</p> <pre><code>private List&lt;KeyValuePair&lt;int, Dictionary&lt;string, float&gt;&gt;&gt; CreateResult(List&lt;Dictionary&lt;string, object&gt;&gt; items) { var result = new List&lt;KeyValuePair&lt;int, Dictionary&lt;string, float&gt;&gt;&gt;(); for (int i = 0; i &lt; items.Count; i++) { var item = items[i].ToDictionary&lt;string, float&gt;(v =&gt; v); // Error, wrong approach result.Add(new KeyValuePair&lt;int, Dictionary&lt;string, float&gt;&gt;(i, new Dictionary&lt;string, float&gt;(item))); } return result; } </code></pre> <p>Unfortunately my method does not work, neither I don't really know if it's the right approach to transform all values of my dictionary to type float.</p> <p>Do you know a good/save way to transform all values in my Dicitonary from type object to type float?</p> <p>Thank you very much!</p>
0debug
What is regularization loss in tensorflow? : <p>When training an Object Detection DNN with Tensorflows Object Detection API it's Visualization Plattform Tensorboard plots a scalar named <code>regularization_loss_1</code></p> <p>What is this? I know what regularization is (to make the Network good at generalizing through various methods like dropout) But it is not clear to me what this displayed loss could be.</p> <p>Thanks!</p>
0debug
static int mpc7_decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MPCContext *c = avctx->priv_data; GetBitContext gb; uint8_t *bits; int i, ch; int mb = -1; Band *bands = c->bands; int off, ret; int bits_used, bits_avail; memset(bands, 0, sizeof(*bands) * (c->maxbands + 1)); if(buf_size <= 4){ av_log(avctx, AV_LOG_ERROR, "Too small buffer passed (%i bytes)\n", buf_size); return AVERROR(EINVAL); } c->frame.nb_samples = buf[1] ? c->lastframelen : MPC_FRAME_SIZE; if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } bits = av_malloc(((buf_size - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE); c->dsp.bswap_buf((uint32_t*)bits, (const uint32_t*)(buf + 4), (buf_size - 4) >> 2); init_get_bits(&gb, bits, (buf_size - 4)* 8); skip_bits_long(&gb, buf[0]); for(i = 0; i <= c->maxbands; i++){ for(ch = 0; ch < 2; ch++){ int t = 4; if(i) t = get_vlc2(&gb, hdr_vlc.table, MPC7_HDR_BITS, 1) - 5; if(t == 4) bands[i].res[ch] = get_bits(&gb, 4); else bands[i].res[ch] = bands[i-1].res[ch] + t; } if(bands[i].res[0] || bands[i].res[1]){ mb = i; if(c->MSS) bands[i].msf = get_bits1(&gb); } } for(i = 0; i <= mb; i++) for(ch = 0; ch < 2; ch++) if(bands[i].res[ch]) bands[i].scfi[ch] = get_vlc2(&gb, scfi_vlc.table, MPC7_SCFI_BITS, 1); for(i = 0; i <= mb; i++){ for(ch = 0; ch < 2; ch++){ if(bands[i].res[ch]){ bands[i].scf_idx[ch][2] = c->oldDSCF[ch][i]; bands[i].scf_idx[ch][0] = get_scale_idx(&gb, bands[i].scf_idx[ch][2]); switch(bands[i].scfi[ch]){ case 0: bands[i].scf_idx[ch][1] = get_scale_idx(&gb, bands[i].scf_idx[ch][0]); bands[i].scf_idx[ch][2] = get_scale_idx(&gb, bands[i].scf_idx[ch][1]); break; case 1: bands[i].scf_idx[ch][1] = get_scale_idx(&gb, bands[i].scf_idx[ch][0]); bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1]; break; case 2: bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0]; bands[i].scf_idx[ch][2] = get_scale_idx(&gb, bands[i].scf_idx[ch][1]); break; case 3: bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0]; break; } c->oldDSCF[ch][i] = bands[i].scf_idx[ch][2]; } } } memset(c->Q, 0, sizeof(c->Q)); off = 0; for(i = 0; i < BANDS; i++, off += SAMPLES_PER_BAND) for(ch = 0; ch < 2; ch++) idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off); ff_mpc_dequantize_and_synth(c, mb, c->frame.data[0], 2); av_free(bits); bits_used = get_bits_count(&gb); bits_avail = (buf_size - 4) * 8; if(!buf[1] && ((bits_avail < bits_used) || (bits_used + 32 <= bits_avail))){ av_log(NULL,0, "Error decoding frame: used %i of %i bits\n", bits_used, bits_avail); return -1; } if(c->frames_to_skip){ c->frames_to_skip--; *got_frame_ptr = 0; return buf_size; } *got_frame_ptr = 1; *(AVFrame *)data = c->frame; return buf_size; }
1threat
static int yop_read_header(AVFormatContext *s) { YopDecContext *yop = s->priv_data; AVIOContext *pb = s->pb; AVCodecContext *audio_dec, *video_dec; AVStream *audio_stream, *video_stream; int frame_rate, ret; audio_stream = avformat_new_stream(s, NULL); video_stream = avformat_new_stream(s, NULL); video_stream->codec->extradata_size = 8; video_stream->codec->extradata = av_mallocz(video_stream->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!video_stream->codec->extradata) audio_dec = audio_stream->codec; audio_dec->codec_type = AVMEDIA_TYPE_AUDIO; audio_dec->codec_id = AV_CODEC_ID_ADPCM_IMA_APC; audio_dec->channels = 1; audio_dec->sample_rate = 22050; video_dec = video_stream->codec; video_dec->codec_type = AVMEDIA_TYPE_VIDEO; video_dec->codec_id = AV_CODEC_ID_YOP; avio_skip(pb, 6); frame_rate = avio_r8(pb); yop->frame_size = avio_r8(pb) * 2048; video_dec->width = avio_rl16(pb); video_dec->height = avio_rl16(pb); video_stream->sample_aspect_ratio = (AVRational){1, 2}; ret = avio_read(pb, video_dec->extradata, 8); if (ret < 8) return ret < 0 ? ret : AVERROR_EOF; yop->palette_size = video_dec->extradata[0] * 3 + 4; yop->audio_block_length = AV_RL16(video_dec->extradata + 6); if (yop->audio_block_length < 920 || yop->audio_block_length + yop->palette_size >= yop->frame_size) { av_log(s, AV_LOG_ERROR, "YOP has invalid header\n"); return AVERROR_INVALIDDATA; } avio_seek(pb, 2048, SEEK_SET); avpriv_set_pts_info(video_stream, 32, 1, frame_rate); return 0; }
1threat
Failed to find style 'coordinatorLayoutStyle' in current theme : <p>I'm using the latest version of android studio (3.0), along with latest build tools (27) and similar API level.</p> <p>The layout does not get rendered in the design tab and it's causing a lot of trouble especially that I'm using coordinator layout.</p> <p>How do I get around this problem? </p>
0debug
static int vnc_display_disable_login(DisplayState *ds) { VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display; if (!vs) { return -1; } if (vs->password) { g_free(vs->password); } vs->password = NULL; if (vs->auth == VNC_AUTH_NONE) { vs->auth = VNC_AUTH_VNC; } return 0; }
1threat
Ruby include a file? : Good day, I'm new in ruby and I'm figuring out how to include a file in ruby? I tried require and include but doesn't work. Here's the file I'd like to insert. It only contains procedures. *Not a module* file1.rb if Constants.elementExist(driver, 'Allow') == true allowElement = driver.find_element(:id, 'Allow') allowElement.click() sleep 1 wait.until { driver.find_element(:id, 'Ok').click() } username = driver.find_element(:id, 'UsernameInput') username.clear username.send_keys Constants.itech_email password = driver.find_element(:id, 'PasswordInput') password.clear password.send_keys Constants.itechPass driver.find_element(:id, 'Login').click else username = driver.find_element(:id, 'UsernameInput') username.clear username.send_keys Constants.itech_email password = driver.find_element(:id, 'PasswordInput') password.clear password.send_keys Constants.itechPass driver.find_element(:id, 'Login').click end That file contains a long line of codes that are re-usable or repeatable in my case. Its not inside a class or a module. Its a straight forward script. And I'd like to use this file on my second file inside a module. File2.rb module File2 module IOS **** insert File1.rb **** end end This way, it should just read the procedures, codes of the File1.rb inside the file2.rb. How to do this in ruby? Thank you! I hope you can help me out guys.
0debug
static int lmlm4_read_packet(AVFormatContext *s, AVPacket *pkt) { AVIOContext *pb = s->pb; int ret; unsigned int frame_type, packet_size, padding, frame_size; avio_rb16(pb); frame_type = avio_rb16(pb); packet_size = avio_rb32(pb); padding = -packet_size & 511; frame_size = packet_size - 8; if (frame_type > LMLM4_MPEG1L2 || frame_type == LMLM4_INVALID) { av_log(s, AV_LOG_ERROR, "invalid or unsupported frame_type\n"); return AVERROR(EIO); } if (packet_size > LMLM4_MAX_PACKET_SIZE) { av_log(s, AV_LOG_ERROR, "packet size exceeds maximum\n"); return AVERROR(EIO); } if ((ret = av_get_packet(pb, pkt, frame_size)) <= 0) return AVERROR(EIO); avio_skip(pb, padding); switch (frame_type) { case LMLM4_I_FRAME: pkt->flags = AV_PKT_FLAG_KEY; case LMLM4_P_FRAME: case LMLM4_B_FRAME: pkt->stream_index = 0; break; case LMLM4_MPEG1L2: pkt->stream_index = 1; break; } return ret; }
1threat
I would like to know if there is any way to get a square root to a list in python help me please : I want to make a condition in python that contains square root of lists so I can not find a specific command to do it. It should be mentioned that in MathLab if it can be done, the following code is from mathlab and I want to do the same in python secuencia=lenght(list) secuencia_2=[1,2,3,4,5,6,7,8] mathlab for j lengt (secuencia) if prod((sqrt(secuencia_1*secuencia_1))~= (sqrt(secuencia_2(j)*secuencia_2(j))))==1:
0debug
I am at a loss for why this is code is giving me a read acess violation. dereferencing pointer and subtracting another char should work in Theory : <p>I dunno why this doesn't work. the code has a problem with the *c in charToInt function but should be a legal statement in c. at least so I thought. I am excited to learn something new here.</p> <pre><code>int charToint(char *c) { return *c - '0'; } int main(void) { char c = '3'; printf("%d\n", charToint(c)); { </code></pre>
0debug
Beginner developer, 1 to 9 question console commands : <p>very recently I started to learn programming, started mostly with theory before getting my hands on the computer, question is, I need to build a program through the console on visual studios where the problem is, "make a program where a user needs to pick a number from 1 to 9, after he picks the number you have to make the program show " The number you picked is "X" " </p> <p>I am trully a beginner, I don't know how to validate just numbers 1 to 9.</p>
0debug
Creating border on the div element : I have this div: <div style="width:100px; height:100px; background-color:green"></div> I need to create border from right side of the `div` and to bind to the border mouse down event. Please help me to implement it.
0debug
Html Css How to remove black rectangle background from image : <p>I am getting below mention image <a href="https://i.stack.imgur.com/d1vah.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d1vah.png" alt="image with black rectangle background"></a></p> <p>Below is html div which i am using </p> <pre><code>&lt;div class="image-cropper"&gt; &lt;img [src]="url" alt="..." class="img-thumbnail"&gt; &lt;/div&gt; </code></pre> <p>Below is css : </p> <pre><code>.image-cropper { width: 100px; height: 100px; position: relative; overflow: hidden; border-radius: 50%; } img { display: inline; margin: 0 auto; height: 100%; width: auto; } </code></pre> <p>How can i clip the black background or make it transparent? Please suggest.</p>
0debug
static void win_stdio_close(CharDriverState *chr) { WinStdioCharState *stdio = chr->opaque; if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) { CloseHandle(stdio->hInputReadyEvent); } if (stdio->hInputDoneEvent != INVALID_HANDLE_VALUE) { CloseHandle(stdio->hInputDoneEvent); } if (stdio->hInputThread != INVALID_HANDLE_VALUE) { TerminateThread(stdio->hInputThread, 0); } g_free(chr->opaque); g_free(chr); }
1threat
How to do a proper upsert using sqlalchemy on postgresql? : <p>I would like to do an upsert using the "new" functionality added by postgresql 9.5, using sqlalchemy core. While it is implemented, I'm pretty confused by the syntax, which I can't adapt to my needs. Here is a sample code of what I would like to be able to do :</p> <pre><code>from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class User(Base): __tablename__ = 'test' a_id = Column('id',Integer, primary_key=True) a = Column("a",Integer) engine = create_engine('postgres://name:password@localhost/test') User().metadata.create_all(engine) meta = MetaData(engine) meta.reflect() table = Table('test', meta, autoload=True) conn = engine.connect() from sqlalchemy.dialects.postgresql import insert as psql_insert stmt = psql_insert(table).values({table.c['id']: bindparam('id'), table.c['a']: bindparam('a')}) stmt = stmt.on_conflict_do_update( index_elements=[table.c['id']], set_={'a': bindparam('a')}) list_of_dictionary = [{'id':1, 'a':1, }, {'id':2, 'a':2,}] conn.execute(stmt, list_of_dictionary) </code></pre> <p>I basicly want to insert a bulk of rows, and if one id is already taken, I want to update it with the value I initinaly wanted to insert. However sqlalchemy throw me this error :</p> <pre><code>CompileError: bindparam() name 'a' is reserved for automatic usage in the VALUES or SET clause of this insert/update statement. Please use a name other than column name when using bindparam() with insert() or update() (for example, 'b_a'). </code></pre> <p>While it is a known issue (see <a href="https://groups.google.com/forum/#!topic/sqlalchemy/VwiUlF1cz_o" rel="noreferrer">https://groups.google.com/forum/#!topic/sqlalchemy/VwiUlF1cz_o</a>), I didn't found any proper answer that does not require to modify either the keys of list_of_dictionary or the name of your columns.</p> <p>I want to know if there is a way of constructing stmt in a way to have a consistent behavior that does not depends on whether the keys of the variable list_of_dictionary are the name of the columns of the inserted table (my code works without error in those cases).</p>
0debug
Space between components in React Native styling : <p><a href="https://i.stack.imgur.com/Mr8uX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Mr8uX.png" alt="enter image description here"></a></p> <p>I have 6 <code>View</code> components (shown in the picture) , I want to have space between all 6 <code>View</code> components. </p> <p>My code:</p> <pre><code>&lt;View style={{flexDirection:'column',flex:6}}&gt; &lt;View style={{flex:2,flexDirection:"row",justifyContent:'space-between'}}&gt; &lt;View style={{backgroundColor:'red',flex:1}}&gt; &lt;/View&gt; &lt;View style={{backgroundColor:'blue',flex:1}}&gt; &lt;/View&gt; &lt;/View&gt; &lt;View style={{flex:2,flexDirection:"row",justifyContent:'space-between'}}&gt; &lt;View style={{backgroundColor:'white',flex:1}}&gt; &lt;/View&gt; &lt;View style={{backgroundColor:'black',flex:1}}&gt; &lt;/View&gt; &lt;/View&gt; &lt;View style={{flex:2,flexDirection:"row",justifyContent:'space-between'}}&gt; &lt;View style={{backgroundColor:'gray',flex:1}}&gt; &lt;/View&gt; &lt;View style={{backgroundColor:'yellow',flex:1}}&gt; &lt;/View&gt; &lt;/View&gt; &lt;/View&gt; </code></pre>
0debug
Calculate matrix hash value : as part of my final year project, I am testing the Bouncycastle library on SHA-3. I find the source code to calculate the hash value of a string: String input = "hello" ; SHA3.DigestSHA3 digestSHA3 = new SHA3.Digest256(); byte[] digest = digestSHA3.digest(input.getBytes()); System.out.println("SHA3-256 = " + Hex.toHexString(digest)); but i want to calculate the hash value of a matrix, hwo can help me?
0debug
static int asf_get_packet(AVFormatContext *s) { ASFContext *asf = s->priv_data; ByteIOContext *pb = &s->pb; uint32_t packet_length, padsize; int rsize = 9; int c; c = get_byte(pb); if (c != 0x82) { if (!url_feof(pb)) av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%"PRId64"\n", c, url_ftell(pb)); } if ((c & 0x0f) == 2) { if (get_le16(pb) != 0) { if (!url_feof(pb)) av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n"); return AVERROR_IO; } rsize+=2; } asf->packet_flags = get_byte(pb); asf->packet_property = get_byte(pb); DO_2BITS(asf->packet_flags >> 5, packet_length, asf->packet_size); DO_2BITS(asf->packet_flags >> 1, padsize, 0); DO_2BITS(asf->packet_flags >> 3, padsize, 0); if(packet_length >= (1U<<29)){ av_log(s, AV_LOG_ERROR, "invalid packet_length %d at:%"PRId64"\n", packet_length, url_ftell(pb)); return -1; } if(padsize >= (1U<<29)){ av_log(s, AV_LOG_ERROR, "invalid padsize %d at:%"PRId64"\n", padsize, url_ftell(pb)); return -1; } asf->packet_timestamp = get_le32(pb); get_le16(pb); if (asf->packet_flags & 0x01) { asf->packet_segsizetype = get_byte(pb); rsize++; asf->packet_segments = asf->packet_segsizetype & 0x3f; } else { asf->packet_segments = 1; asf->packet_segsizetype = 0x80; } asf->packet_size_left = packet_length - padsize - rsize; if (packet_length < asf->hdr.min_pktsize) padsize += asf->hdr.min_pktsize - packet_length; asf->packet_padsize = padsize; #ifdef DEBUG printf("packet: size=%d padsize=%d left=%d\n", asf->packet_size, asf->packet_padsize, asf->packet_size_left); #endif return 0; }
1threat
How do you create global variables without typing "global" in each function? : I'm trying to create a global variable, but from what I know you need to type "global" in every function. This example is in Python 2.7: a = 10 def change(): global a a = 2 print a def reverse(): global a a = 10 print a // Output: // 2 // 4 I'm trying to re-create the code above without the use of 'global' for every variable in every function I am going to create. Is there a better way to do this?
0debug
How to set all the values of an existing Pandas DataFrame to zero? : <p>I currently have an existing Pandas DataFrame with a date index, and columns each with a specific name.</p> <p>As for the data cells, they are filled with various float values.</p> <p>I would like to copy my DataFrame, but replace all these values with zero.</p> <p>The objective is to reuse the structure of the DataFrame (dimensions, index, column names), but clear all the current values by replacing them with zeroes.</p> <p>The way I'm currently achieving this is as follow:</p> <pre><code>df[df &gt; 0] = 0 </code></pre> <p>However, this would not replace any negative value in the DataFrame.</p> <p>Isn't there a more general approach to filling an entire existing DataFrame with a single common value?</p> <p>Thank you in advance for your help.</p>
0debug
Mysterious number 6174 [Kaprekar Theorem] in Java : <p>In 1949 the mathematician D. R. Kaprekar, devised a process now known as Kaprekar's operation. First choose a four digit number where the digits are not all the same (that is not 1111, 2222,...). Then rearrange the digits to get the largest and smallest numbers these digits can make. Finally, subtract the smallest number from the largest to get a new number, and carry on repeating the operation for each new number.</p> <blockquote> <p>Let's try it out, starting with the number 2005, the digits of last year. The maximum number we can make with these digits is 5200, and the minimum is 0025 or 25 (if one or more of the digits is zero, embed these in the left hand side of the minimum number)</p> </blockquote> <pre><code>5200 - 0025 = 5175 7551 - 1557 = 5994 9954 - 4599 = 5355 5553 - 3555 = 1998 9981 - 1899 = 8082 8820 - 0288 = 8532 8532 - 2358 = 6174 </code></pre> <p>Now Objective is verify this theorem &amp; find the number of iteration take to reach 6174.</p> <blockquote> <p><strong>Can anyone give a better algorithm?</strong> Here is my code.</p> </blockquote> <pre><code>public int VerifyKaprekarTheorem(int m) { if (m &lt;= 1000 || m &gt; 9999) { return -1; } String orginal = String.valueOf(m); int count = 0; while (true) { int Max = Integer.parseInt(sortString(orginal, false)); int Min = Integer.parseInt(sortString(orginal, true)); count++; int diff = Max - Min; if (diff == 6174) { break; } orginal = String.valueOf(diff); } return count; } public static String sortString(String Source, boolean assendingOrder) { char[] original = String.valueOf(Source).toCharArray(); Arrays.sort(original); if (assendingOrder) { return new String(original); } char[] dessending = new char[original.length]; for (int i = original.length - 1; i &gt;= 0; i--) { dessending[i] = original[(original.length - 1) - i]; } return new String(dessending); } </code></pre> <blockquote> <p>and testcase</p> </blockquote> <pre><code>public void testCase01() { int actual = VerifyKaprekarTheorem(4321); assertEquals(3, actual); } </code></pre>
0debug
void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width, int height, int64_t pts) { ContextInfo *ci = (ContextInfo *) ctx; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; int rowsize = picture->linesize[0]; #if 0 av_log(NULL, AV_LOG_DEBUG, "pix_fmt = %d, width = %d, pts = %lld, ci->next_pts = %lld\n", pix_fmt, width, pts, ci->next_pts); #endif if (pts < ci->next_pts) return; if (width < ci->min_width) return; ci->next_pts = pts + 1000000; if (pix_fmt == PIX_FMT_YUV420P) { uint8_t *y, *u, *v; int width2 = width >> 1; int inrange = 0; int pixcnt; int h; int h_start, h_end; int w_start, w_end; h_end = 2 * ((ci->inset * height) / 200); h_start = height - h_end; w_end = (ci->inset * width2) / 100; w_start = width2 - w_end; pixcnt = ((h_start - h_end) >> 1) * (w_start - w_end); y = picture->data[0] + h_end * picture->linesize[0] + w_end * 2; u = picture->data[1] + h_end * picture->linesize[1] / 2 + w_end; v = picture->data[2] + h_end * picture->linesize[2] / 2 + w_end; for (h = h_start; h > h_end; h -= 2) { int w; for (w = w_start; w > w_end; w--) { unsigned int r,g,b; HSV hsv; int cb, cr, yt, r_add, g_add, b_add; YUV_TO_RGB1_CCIR(u[0], v[0]); YUV_TO_RGB2_CCIR(r, g, b, y[0]); get_hsv(&hsv, r, g, b); if (ci->debug > 1) av_log(NULL, AV_LOG_DEBUG, "(%d,%d,%d) -> (%d,%d,%d)\n", r,g,b,hsv.h,hsv.s,hsv.v); if (hsv.h >= ci->dark.h && hsv.h <= ci->bright.h && hsv.s >= ci->dark.s && hsv.s <= ci->bright.s && hsv.v >= ci->dark.v && hsv.v <= ci->bright.v) { inrange++; } else if (ci->zapping) { y[0] = y[1] = y[rowsize] = y[rowsize + 1] = 16; u[0] = 128; v[0] = 128; } y+= 2; u++; v++; } y += picture->linesize[0] * 2 - (w_start - w_end) * 2; u += picture->linesize[1] - (w_start - w_end); v += picture->linesize[2] - (w_start - w_end); } if (ci->debug) av_log(NULL, AV_LOG_INFO, "Fish: Inrange=%d of %d = %d threshold\n", inrange, pixcnt, 1000 * inrange / pixcnt); if (inrange * 1000 / pixcnt >= ci->threshold) { int size; char *buf; AVPicture picture1; static int frame_counter; static int foundfile; if ((frame_counter++ % 20) == 0) { DIR *d; foundfile = 0; d = opendir(ci->dir); if (d) { struct dirent *dent; while ((dent = readdir(d))) { if (strncmp("fishimg", dent->d_name, 7) == 0) { if (strcmp(".ppm", dent->d_name + strlen(dent->d_name) - 4) == 0) { foundfile++; } } } closedir(d); } } if (foundfile < ci->file_limit) { FILE *f; char fname[256]; size = avpicture_get_size(PIX_FMT_RGB24, width, height); buf = av_malloc(size); avpicture_fill(&picture1, buf, PIX_FMT_RGB24, width, height); ci->toRGB_convert_ctx = sws_getCachedContext(ci->toRGB_convert_ctx, width, height, pix_fmt, width, height, PIX_FMT_RGB24, sws_flags, NULL, NULL, NULL); if (ci->toRGB_convert_ctx == NULL) { av_log(NULL, AV_LOG_ERROR, "Cannot initialize the toRGB conversion context\n"); return; } sws_scale(ci->toRGB_convert_ctx, picture->data, picture->linesize, 0, height, picture1.data, picture1.linesize); snprintf(fname, sizeof(fname), "%s/fishimg%ld_%"PRId64".ppm", ci->dir, (long)(av_gettime() / 1000000), pts); f = fopen(fname, "w"); if (f) { fprintf(f, "P6 %d %d 255\n", width, height); fwrite(buf, width * height * 3, 1, f); fclose(f); } av_free(buf); ci->next_pts = pts + ci->min_interval; } } } }
1threat
int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char *buf, int buf_size) { int64_t buffer_start; int buffer_size; int overlap, new_size, alloc_size; if (s->write_flag) return AVERROR(EINVAL); buffer_size = s->buf_end - s->buffer; if ((buffer_start = s->pos - buffer_size) > buf_size) return AVERROR(EINVAL); overlap = buf_size - buffer_start; new_size = buf_size + buffer_size - overlap; alloc_size = FFMAX(s->buffer_size, new_size); if (alloc_size > buf_size) if (!(buf = av_realloc_f(buf, 1, alloc_size))) return AVERROR(ENOMEM); if (new_size > buf_size) { memcpy(buf + buf_size, s->buffer + overlap, buffer_size - overlap); buf_size = new_size; } av_free(s->buffer); s->buf_ptr = s->buffer = buf; s->buffer_size = alloc_size; s->pos = buf_size; s->buf_end = s->buf_ptr + buf_size; s->eof_reached = 0; s->must_flush = 0; return 0; }
1threat
I need an real-life project for practice with python and Django : <p>I'm working as an apprentice for a software company in Germany. The most time I work for projects with Visual Basic for Application (Excel). For my finals I need more practice in modern languages. I like to build a web-application for free, can be a little project or something bigger, the important thing is that I learn a few things about planing a project, speaking with the customer about the project and build the application. </p> <p>Why Python and Django? Aside from VBA, I learned Python for my own projects. But writing application for myself is not the same like working for a customer.</p> <p>Best Regards, Tobias.M</p>
0debug
How do you create reusable Animations in Angular 2 : <p>I'm playing with the Animation API, and I'd like to create a reusable animation like say sliding in content for top level router views. I managed to get through the funky meta data syntax (which is actually pretty cool once get past the crazy idea of using metadata) to get the animations mostly working.</p> <pre><code> @Component({ //moduleId: module.id, selector: 'album-display', templateUrl: './albumDisplay.html', animations: [ trigger('slideIn', [ state('*', style({ transform: 'translateX(100%)', })), state('in', style({ transform: 'translateX(0)', })), state('out', style({ transform: 'translateX(-100%)', })), transition('* =&gt; in', animate('600ms ease-in')), transition('in =&gt; out', animate('600ms ease-in')) ]) ] }) export class AlbumDisplay implements OnInit { slideInState = 'in'; ... } </code></pre> <p>And then assigning that to my top level element in the component:</p> <pre><code> &lt;div class="container" [@slideIn]="slideInState"&gt; </code></pre> <p>So this works, but how can I make this reusable? I don't want to stick this meta data onto every view. Since this is metadata I'm not sure how you could make this reusable.</p>
0debug
static void megasas_command_complete(SCSIRequest *req, uint32_t status, size_t resid) { MegasasCmd *cmd = req->hba_private; uint8_t cmd_status = MFI_STAT_OK; trace_megasas_command_complete(cmd->index, status, resid); if (req->io_canceled) { return; } if (cmd->req == NULL) { cmd_status = megasas_finish_internal_dcmd(cmd, req, resid); if (cmd_status == MFI_STAT_INVALID_STATUS) { return; } } else { req->status = status; trace_megasas_scsi_complete(cmd->index, req->status, cmd->iov_size, req->cmd.xfer); if (req->status != GOOD) { cmd_status = MFI_STAT_SCSI_DONE_WITH_ERROR; } if (req->status == CHECK_CONDITION) { megasas_copy_sense(cmd); } cmd->frame->header.scsi_status = req->status; } cmd->frame->header.cmd_status = cmd_status; megasas_complete_command(cmd); }
1threat
What is C++ string's default capacity? : <p>Consider the following snippet:</p> <pre><code>string line; line = ""; cout &lt;&lt; line[400] &lt;&lt; endl; //Works, random character cout &lt;&lt; line[20000] &lt;&lt; endl; //Segmentation Fault </code></pre> <p>Looks like c++ string has a default capacity to prevent bad things happen when reaching beyond the boundary. But I can't find any more resources on this topic.</p> <p>I compiled the snippet with clang under mac environment. </p>
0debug
How to acces a class which is in a folder c# (wpf) : I'm building a WPF application. I'm almost finished with one part of it, and now I wanna clean up the code a bit. English is not my native language (so sorry if this gets marked ass a duplicate) and I couldn't find anything about this, so I hope someone can help me out. If i have public voids in a class called 'class.cs' and this class is in a folder called 'classes', how do I access the class so I can use it's functions?
0debug
Maximum Throughput of this system : Given this System, and assuming we pipelined it with the minimum number of registers: [Click me for the picture][1] How can I calculate the maximum throughput without even knowing what's the minimum number of the registers needed to pipeline this? [1]: http://i.stack.imgur.com/kMkFC.jpg
0debug
uint32_t HELPER(lpebr)(CPUS390XState *env, uint32_t f1, uint32_t f2) { float32 v1; float32 v2 = env->fregs[f2].d; v1 = float32_abs(v2); env->fregs[f1].d = v1; return set_cc_nz_f32(v1); }
1threat
static void grlib_irqmp_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { IRQMP *irqmp = opaque; IRQMPState *state; assert(irqmp != NULL); state = irqmp->state; assert(state != NULL); addr &= 0xff; switch (addr) { case LEVEL_OFFSET: value &= 0xFFFF << 1; state->level = value; return; case PENDING_OFFSET: return; case FORCE0_OFFSET: value &= 0xFFFE; state->force[0] = value; grlib_irqmp_check_irqs(irqmp->state); return; case CLEAR_OFFSET: value &= ~1; state->pending &= ~value; return; case MP_STATUS_OFFSET: return; case BROADCAST_OFFSET: value &= 0xFFFE; state->broadcast = value; return; default: break; } if (addr >= MASK_OFFSET && addr < FORCE_OFFSET) { int cpu = (addr - MASK_OFFSET) / 4; assert(cpu >= 0 && cpu < IRQMP_MAX_CPU); value &= ~1; state->mask[cpu] = value; grlib_irqmp_check_irqs(irqmp->state); return; } if (addr >= FORCE_OFFSET && addr < EXTENDED_OFFSET) { int cpu = (addr - FORCE_OFFSET) / 4; assert(cpu >= 0 && cpu < IRQMP_MAX_CPU); uint32_t force = value & 0xFFFE; uint32_t clear = (value >> 16) & 0xFFFE; uint32_t old = state->force[cpu]; state->force[cpu] = (old | force) & ~clear; grlib_irqmp_check_irqs(irqmp->state); return; } if (addr >= EXTENDED_OFFSET && addr < IRQMP_REG_SIZE) { int cpu = (addr - EXTENDED_OFFSET) / 4; assert(cpu >= 0 && cpu < IRQMP_MAX_CPU); value &= 0xF; state->extended[cpu] = value; return; } trace_grlib_irqmp_writel_unknown(addr, value); }
1threat
Is there a better way to convert string list having nan values to list : input list = `'[12,2,4,nan,0]'` ouput = `['12','2','4','nan','0']` One option is yaml.safe_load(), But it's too slow. I am looking for a efficient way to transform.
0debug
What is a dehydrated detector and how am I using one here? : <p>I'm using a simple directive to focus a text input when the element is active using <code>*ngIf</code>. This is contained within a <code>*ngFor</code> loop.</p> <p>When the first <code>*ngIf</code> is activated, the input focuses as expected. When another input is activated I get the error:</p> <p><code>EXCEPTION: Attempt to use a dehydrated detector.</code></p> <p>I don't understand what this means and how I can prevent the error. The functionality still works even with the error.</p> <pre><code>@Directive({ selector: '[myAutoFocus]' }) export class AutoFocusDirective { constructor(private elem: ElementRef) { window.setTimeout(function() { elem.nativeElement.querySelector('input').focus(); }); } } </code></pre> <p>```</p>
0debug
static void zynq_xadc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) { ZynqXADCState *s = (ZynqXADCState *)opaque; int reg = offset / 4; int xadc_reg; int xadc_cmd; int xadc_data; if (!zynq_xadc_check_offset(reg, false)) { qemu_log_mask(LOG_GUEST_ERROR, "zynq_xadc: Invalid write access " "to addr %" HWADDR_PRIx "\n", offset); return; } switch (reg) { case CFG: s->regs[CFG] = val; break; case INT_STS: s->regs[INT_STS] &= ~val; break; case INT_MASK: s->regs[INT_MASK] = val & INT_ALL; break; case CMDFIFO: xadc_cmd = extract32(val, 26, 4); xadc_reg = extract32(val, 16, 10); xadc_data = extract32(val, 0, 16); if (s->regs[MCTL] & MCTL_RESET) { qemu_log_mask(LOG_GUEST_ERROR, "zynq_xadc: Sending command " "while comm channel held in reset: %" PRIx32 "\n", (uint32_t) val); break; } if (xadc_reg > ZYNQ_XADC_NUM_ADC_REGS && xadc_cmd != CMD_NOP) { qemu_log_mask(LOG_GUEST_ERROR, "read/write op to invalid xadc " "reg 0x%x\n", xadc_reg); break; } switch (xadc_cmd) { case CMD_READ: xadc_push_dfifo(s, s->xadc_regs[xadc_reg]); break; case CMD_WRITE: s->xadc_regs[xadc_reg] = xadc_data; case CMD_NOP: xadc_push_dfifo(s, 0); break; } break; case MCTL: s->regs[MCTL] = val & 0x00fffeff; break; } zynq_xadc_update_ints(s); }
1threat
Use 5.0V instead of 3.3V with the Raspberry Pi GPIO 'in' pins : <p>Is it possible to use the GPIO pins with 5V instead of 3.3V without destroying the Raspberry Pi? I need to handle window contacts in python, which needs 5V to work properly. <br><br></p> <p>Greetings<br> Epileptic_Software</p>
0debug