problem
stringlengths
26
131k
labels
class label
2 classes
How to make mobile site to android app : <p>I have developed a mobile site. And now I want to convert that to an android app.</p> <p>I am not so good in android. Can any one tell me where i can convert my mobile site to android app. Or do we have any software to do so. Or any tutorial site.</p> <p>I need to integrate adds in my app too. </p> <p>Please help me.</p> <p>Thanks</p>
0debug
Python: Turn Nested List to Dictionary : <p>I am trying to turn a nested list like this: (Example list)</p> <pre><code>[['A','1','2','3'], ['B','4','5','6'],...] </code></pre> <p>To a dictionary that looks like this</p> <pre><code>{'A':'1','2','3','B': '4','5','6'} </code></pre> <p>Can someone please help me?</p>
0debug
what does the question mark in tensorflow shape mean? : <p>I'm looking into magenta code, and printing its tensor object. I got this result:</p> <pre><code>Tensor("fully_connected/BiasAdd:0", shape=(?, 38), dtype=float32) </code></pre> <p>What does this question mark in shape mean?</p>
0debug
Git Extensions stored wrong credentials : <p>My username and password were stored somewhere in internals of Git Extensions. After some time it was necessary to give username and password again and I gave wrong pass many times.</p> <p>Now if I want to pull something etc. I receive <code>fatal: Authentication failed</code>. I cannot give new password, it seems to be stored and I don't know how to change it.</p> <p>Is it possible to delete the old credentials?</p> <p>I have 2.51.04 version. I have uninstalled it and install again and it doesnt help me.</p>
0debug
c# - Return color from a function : <p>I am making an application which will use function from another class, open color dialog and then return the color value to the form. I have written the class but I don't understand why it gives me an error. The error is</p> <blockquote> <p>Since 'Editing.ChooseColor' returns void, a return keyword must not be followed by an object expression.</p> </blockquote> <p>My class code is</p> <pre><code> public void ChooseColor() { ColorDialog ColorDialog = new ColorDialog(); ColorDialog.ShowDialog(); System.Drawing.Color Color = ColorDialog.Color; return Color; } </code></pre> <p>My form will call the function and the get the color value. Thanks for help.</p>
0debug
static void virtio_setup(uint64_t dev_info) { struct schib schib; int i; int r; bool found = false; bool check_devno = false; uint16_t dev_no = -1; blk_schid.one = 1; if (dev_info != -1) { check_devno = true; dev_no = dev_info & 0xffff; debug_print_int("device no. ", dev_no); blk_schid.ssid = (dev_info >> 16) & 0x3; if (blk_schid.ssid != 0) { debug_print_int("ssid ", blk_schid.ssid); if (enable_mss_facility() != 0) { virtio_panic("Failed to enable mss facility\n"); } } } for (i = 0; i < 0x10000; i++) { blk_schid.sch_no = i; r = stsch_err(blk_schid, &schib); if (r == 3) { break; } if (schib.pmcw.dnv) { if (!check_devno || (schib.pmcw.dev == dev_no)) { if (virtio_is_blk(blk_schid)) { found = true; break; } } } } if (!found) { virtio_panic("No virtio-blk device found!\n"); } virtio_setup_block(blk_schid); }
1threat
Are Angular2's services supposed to be stateless? : <p>I come from Java world where services are commonly meant to be stateless. Should be services in Angular2 also stateless? Or can we simply store the state, because we do not have to care about concurrent thread access as in Java example?</p> <p>At <a href="https://angular.io/docs/ts/latest/guide/router.html#!#teach-authguard-to-authenticate" rel="noreferrer">https://angular.io/docs/ts/latest/guide/router.html#!#teach-authguard-to-authenticate</a> in AuthService class the state is stored.</p> <p>Is it just to simplify the example or is it a common practice? I know that services are instantiated and live for the scope where they are declared, but that would mean that I would have to care where the service has been provided to know how long the state lasts.</p>
0debug
Retrieving random key from database? : [Retrieveing random key][1] [1]: https://i.stack.imgur.com/GTCXB.jpg How to retrieve random key from firebase Realtime database that are stored in list?
0debug
VS Code snippet - escape ${file} : <p>I'd like to create a snippet in VS Code, which includes exact string <code>${code}</code>. However, when I enter it in this form, VS Code tries to interpret it as snippet parameter. How should I escape it properly?</p>
0debug
php, simpleXML after clicking submit I want to come back to the same page using a relative path : This is 5 lines of what I have using an absolute path. this is part of a simpleXML parser in php <?php if (isset($_POST['lsr-submit'])) { header('Location: http://wft.com/customerentry.php'); } The problem is this is going to be on several servers so I need a relative path 'cusomerentry.php' I forgot how that's done...
0debug
Bootstrap Image Resposive not working in Chorme and Cedot Browser : My Bootstrap 4 connection is working in Mozillafox. But Not working in Chrome and Chedot Browser. My coder are given bellow. <div class="container"> <div class="row"> <img src="<?php echo esc_url(get_template_directory_uri());?>/imag /beard-czar-best.JPG" alt="ddd"> </div>
0debug
static void writer_close(WriterContext **wctx) { int i; if (!*wctx) return; if ((*wctx)->writer->uninit) (*wctx)->writer->uninit(*wctx); for (i = 0; i < SECTION_MAX_NB_LEVELS; i++) av_bprint_finalize(&(*wctx)->section_pbuf[i], NULL); if ((*wctx)->writer->priv_class) av_opt_free((*wctx)->priv); av_freep(&((*wctx)->priv)); av_freep(wctx); }
1threat
static void gen_compute_branch(DisasContext *ctx, uint32_t opc, int r1, int r2 , int32_t constant , int32_t offset) { TCGv temp, temp2; int n; switch (opc) { case OPC1_16_SB_J: case OPC1_32_B_J: gen_goto_tb(ctx, 0, ctx->pc + offset * 2); break; case OPC1_32_B_CALL: case OPC1_16_SB_CALL: gen_helper_1arg(call, ctx->next_pc); gen_goto_tb(ctx, 0, ctx->pc + offset * 2); break; case OPC1_16_SB_JZ: gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_d[15], 0, offset); break; case OPC1_16_SB_JNZ: gen_branch_condi(ctx, TCG_COND_NE, cpu_gpr_d[15], 0, offset); break; case OPC1_16_SBC_JEQ: gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_d[15], constant, offset); break; case OPC1_16_SBC_JNE: gen_branch_condi(ctx, TCG_COND_NE, cpu_gpr_d[15], constant, offset); break; case OPC1_16_SBRN_JZ_T: temp = tcg_temp_new(); tcg_gen_andi_tl(temp, cpu_gpr_d[15], 0x1u << constant); gen_branch_condi(ctx, TCG_COND_EQ, temp, 0, offset); tcg_temp_free(temp); break; case OPC1_16_SBRN_JNZ_T: temp = tcg_temp_new(); tcg_gen_andi_tl(temp, cpu_gpr_d[15], 0x1u << constant); gen_branch_condi(ctx, TCG_COND_NE, temp, 0, offset); tcg_temp_free(temp); break; case OPC1_16_SBR_JEQ: gen_branch_cond(ctx, TCG_COND_EQ, cpu_gpr_d[r1], cpu_gpr_d[15], offset); break; case OPC1_16_SBR_JNE: gen_branch_cond(ctx, TCG_COND_NE, cpu_gpr_d[r1], cpu_gpr_d[15], offset); break; case OPC1_16_SBR_JNZ: gen_branch_condi(ctx, TCG_COND_NE, cpu_gpr_d[r1], 0, offset); break; case OPC1_16_SBR_JNZ_A: gen_branch_condi(ctx, TCG_COND_NE, cpu_gpr_a[r1], 0, offset); break; case OPC1_16_SBR_JGEZ: gen_branch_condi(ctx, TCG_COND_GE, cpu_gpr_d[r1], 0, offset); break; case OPC1_16_SBR_JGTZ: gen_branch_condi(ctx, TCG_COND_GT, cpu_gpr_d[r1], 0, offset); break; case OPC1_16_SBR_JLEZ: gen_branch_condi(ctx, TCG_COND_LE, cpu_gpr_d[r1], 0, offset); break; case OPC1_16_SBR_JLTZ: gen_branch_condi(ctx, TCG_COND_LT, cpu_gpr_d[r1], 0, offset); break; case OPC1_16_SBR_JZ: gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_d[r1], 0, offset); break; case OPC1_16_SBR_JZ_A: gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_a[r1], 0, offset); break; case OPC1_16_SBR_LOOP: gen_loop(ctx, r1, offset * 2 - 32); break; case OPC1_16_SR_JI: tcg_gen_andi_tl(cpu_PC, cpu_gpr_a[r1], 0xfffffffe); tcg_gen_exit_tb(0); break; case OPC2_32_SYS_RET: case OPC2_16_SR_RET: gen_helper_ret(cpu_env); tcg_gen_exit_tb(0); break; case OPC1_32_B_CALLA: gen_helper_1arg(call, ctx->next_pc); gen_goto_tb(ctx, 0, EA_B_ABSOLUT(offset)); break; case OPC1_32_B_JLA: tcg_gen_movi_tl(cpu_gpr_a[11], ctx->next_pc); case OPC1_32_B_JA: gen_goto_tb(ctx, 0, EA_B_ABSOLUT(offset)); break; case OPC1_32_B_JL: tcg_gen_movi_tl(cpu_gpr_a[11], ctx->next_pc); gen_goto_tb(ctx, 0, ctx->pc + offset * 2); break; case OPCM_32_BRC_EQ_NEQ: if (MASK_OP_BRC_OP2(ctx->opcode) == OPC2_32_BRC_JEQ) { gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_d[r1], constant, offset); } else { gen_branch_condi(ctx, TCG_COND_NE, cpu_gpr_d[r1], constant, offset); } break; case OPCM_32_BRC_GE: if (MASK_OP_BRC_OP2(ctx->opcode) == OP2_32_BRC_JGE) { gen_branch_condi(ctx, TCG_COND_GE, cpu_gpr_d[r1], constant, offset); } else { constant = MASK_OP_BRC_CONST4(ctx->opcode); gen_branch_condi(ctx, TCG_COND_GEU, cpu_gpr_d[r1], constant, offset); } break; case OPCM_32_BRC_JLT: if (MASK_OP_BRC_OP2(ctx->opcode) == OPC2_32_BRC_JLT) { gen_branch_condi(ctx, TCG_COND_LT, cpu_gpr_d[r1], constant, offset); } else { constant = MASK_OP_BRC_CONST4(ctx->opcode); gen_branch_condi(ctx, TCG_COND_LTU, cpu_gpr_d[r1], constant, offset); } break; case OPCM_32_BRC_JNE: temp = tcg_temp_new(); if (MASK_OP_BRC_OP2(ctx->opcode) == OPC2_32_BRC_JNED) { tcg_gen_mov_tl(temp, cpu_gpr_d[r1]); tcg_gen_subi_tl(cpu_gpr_d[r1], cpu_gpr_d[r1], 1); gen_branch_condi(ctx, TCG_COND_NE, temp, constant, offset); } else { tcg_gen_mov_tl(temp, cpu_gpr_d[r1]); tcg_gen_addi_tl(cpu_gpr_d[r1], cpu_gpr_d[r1], 1); gen_branch_condi(ctx, TCG_COND_NE, temp, constant, offset); } tcg_temp_free(temp); break; case OPCM_32_BRN_JTT: n = MASK_OP_BRN_N(ctx->opcode); temp = tcg_temp_new(); tcg_gen_andi_tl(temp, cpu_gpr_d[r1], (1 << n)); if (MASK_OP_BRN_OP2(ctx->opcode) == OPC2_32_BRN_JNZ_T) { gen_branch_condi(ctx, TCG_COND_NE, temp, 0, offset); } else { gen_branch_condi(ctx, TCG_COND_EQ, temp, 0, offset); } tcg_temp_free(temp); break; case OPCM_32_BRR_EQ_NEQ: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_JEQ) { gen_branch_cond(ctx, TCG_COND_EQ, cpu_gpr_d[r1], cpu_gpr_d[r2], offset); } else { gen_branch_cond(ctx, TCG_COND_NE, cpu_gpr_d[r1], cpu_gpr_d[r2], offset); } break; case OPCM_32_BRR_ADDR_EQ_NEQ: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_JEQ_A) { gen_branch_cond(ctx, TCG_COND_EQ, cpu_gpr_a[r1], cpu_gpr_a[r2], offset); } else { gen_branch_cond(ctx, TCG_COND_NE, cpu_gpr_a[r1], cpu_gpr_a[r2], offset); } break; case OPCM_32_BRR_GE: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_JGE) { gen_branch_cond(ctx, TCG_COND_GE, cpu_gpr_d[r1], cpu_gpr_d[r2], offset); } else { gen_branch_cond(ctx, TCG_COND_GEU, cpu_gpr_d[r1], cpu_gpr_d[r2], offset); } break; case OPCM_32_BRR_JLT: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_JLT) { gen_branch_cond(ctx, TCG_COND_LT, cpu_gpr_d[r1], cpu_gpr_d[r2], offset); } else { gen_branch_cond(ctx, TCG_COND_LTU, cpu_gpr_d[r1], cpu_gpr_d[r2], offset); } break; case OPCM_32_BRR_LOOP: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_LOOP) { gen_loop(ctx, r1, offset * 2); } else { gen_goto_tb(ctx, 0, ctx->pc + offset * 2); } break; case OPCM_32_BRR_JNE: temp = tcg_temp_new(); temp2 = tcg_temp_new(); if (MASK_OP_BRC_OP2(ctx->opcode) == OPC2_32_BRR_JNED) { tcg_gen_mov_tl(temp, cpu_gpr_d[r1]); tcg_gen_mov_tl(temp2, cpu_gpr_d[r2]); tcg_gen_subi_tl(cpu_gpr_d[r1], cpu_gpr_d[r1], 1); gen_branch_cond(ctx, TCG_COND_NE, temp, temp2, offset); } else { tcg_gen_mov_tl(temp, cpu_gpr_d[r1]); tcg_gen_mov_tl(temp2, cpu_gpr_d[r2]); tcg_gen_addi_tl(cpu_gpr_d[r1], cpu_gpr_d[r1], 1); gen_branch_cond(ctx, TCG_COND_NE, temp, temp2, offset); } tcg_temp_free(temp); tcg_temp_free(temp2); break; case OPCM_32_BRR_JNZ: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_JNZ_A) { gen_branch_condi(ctx, TCG_COND_NE, cpu_gpr_a[r1], 0, offset); } else { gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_a[r1], 0, offset); } break; default: printf("Branch Error at %x\n", ctx->pc); } ctx->bstate = BS_BRANCH; }
1threat
static const char *local_mapped_attr_path(FsContext *ctx, const char *path, char *buffer) { char *dir_name; char *tmp_path = strdup(path); char *base_name = basename(tmp_path); dir_name = tmp_path; *(base_name - 1) = '\0'; snprintf(buffer, PATH_MAX, "%s/%s/%s/%s", ctx->fs_root, dir_name, VIRTFS_META_DIR, base_name); free(tmp_path); return buffer; }
1threat
void av_close_input_file(AVFormatContext *s) { int i; if (s->iformat->read_close) s->iformat->read_close(s); for(i=0;i<s->nb_streams;i++) { av_free(s->streams[i]); } if (s->packet_buffer) { AVPacketList *p, *p1; p = s->packet_buffer; while (p != NULL) { p1 = p->next; av_free_packet(&p->pkt); av_free(p); p = p1; } s->packet_buffer = NULL; } if (!(s->iformat->flags & AVFMT_NOFILE)) { url_fclose(&s->pb); } av_free(s->priv_data); av_free(s); }
1threat
Can someone explain this C++ code? : <p>I am a new here. I do not understand the if statement: i==0, It eliminates repetition. How it works? Thanks.</p> <pre><code>vector&lt;string&gt;words; for (string temp; cin &gt;&gt; temp;) words.push_back(temp); cout &lt;&lt; "Number of words:" &lt;&lt; words.size() &lt;&lt; '\n'; sort(words); for (int i = 0; i &lt; words.size(); ++i) if (i == 0 || words[i - 1] != words[i]) cout &lt;&lt; words[i] &lt;&lt; '\n'; </code></pre>
0debug
static av_cold int pcm_encode_init(AVCodecContext *avctx) { avctx->frame_size = 0; switch (avctx->codec->id) { case AV_CODEC_ID_PCM_ALAW: pcm_alaw_tableinit(); break; case AV_CODEC_ID_PCM_MULAW: pcm_ulaw_tableinit(); break; default: break; } avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id); avctx->block_align = avctx->channels * avctx->bits_per_coded_sample / 8; avctx->bit_rate = avctx->block_align * avctx->sample_rate * 8; avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); return 0; }
1threat
static void macio_nvram_writeb(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { MacIONVRAMState *s = opaque; addr = (addr >> s->it_shift) & (s->size - 1); s->data[addr] = value; NVR_DPRINTF("writeb addr %04x val %x\n", (int)addr, value); }
1threat
Xamarin Forms control the color/title of the header bar : <p>I have the following form created with Xamarin Forms. I have drawn in a red rectangle to highlight the problem area. I need the blue color in the header to be a different color and show a title.</p> <p><a href="https://i.stack.imgur.com/IrPuP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IrPuP.png" alt="enter image description here"></a></p> <p>Here is what I am trying to approximate. Please ignore the back arrow and the fact the hamburger menu is on the right (btw, can a MasterDetail have the hamburger on the right vs. left?).</p> <p><a href="https://i.stack.imgur.com/O09LB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/O09LB.png" alt="enter image description here"></a></p> <p>The following code is what I am using to create this. I am embedding my MainPage (which has the ListView) in a NavigationPage. Then I set the Detail page of a MasterDetailPage to the aforementioned NavigationPage. Setting the BackgroundColor property here isn't working. Notice the Title property isn't working either.</p> <p>How can I change the color and title of the header's background?</p> <pre><code> var navPage = new NavigationPage(new MainPage()); App.Current.MainPage = new MasterDetailPage { BackgroundColor = Color.FromHex("#174873"), Title = "MY DRIVES", Master = new MenuPage() { Title = "Master Page Title" }, Detail = navPage }; </code></pre>
0debug
static int encode_block(SVQ1EncContext *s, uint8_t *src, uint8_t *ref, uint8_t *decoded, int stride, int level, int threshold, int lambda, int intra) { int count, y, x, i, j, split, best_mean, best_score, best_count; int best_vector[6]; int block_sum[7] = { 0, 0, 0, 0, 0, 0 }; int w = 2 << (level + 2 >> 1); int h = 2 << (level + 1 >> 1); int size = w * h; int16_t (*block)[256] = s->encoded_block_levels[level]; const int8_t *codebook_sum, *codebook; const uint16_t(*mean_vlc)[2]; const uint8_t(*multistage_vlc)[2]; best_score = 0; if (intra) { codebook_sum = svq1_intra_codebook_sum[level]; codebook = ff_svq1_intra_codebooks[level]; mean_vlc = ff_svq1_intra_mean_vlc; multistage_vlc = ff_svq1_intra_multistage_vlc[level]; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { int v = src[x + y * stride]; block[0][x + w * y] = v; best_score += v * v; block_sum[0] += v; } } } else { codebook_sum = svq1_inter_codebook_sum[level]; codebook = ff_svq1_inter_codebooks[level]; mean_vlc = ff_svq1_inter_mean_vlc + 256; multistage_vlc = ff_svq1_inter_multistage_vlc[level]; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { int v = src[x + y * stride] - ref[x + y * stride]; block[0][x + w * y] = v; best_score += v * v; block_sum[0] += v; } } } best_count = 0; best_score -= (int)((unsigned)block_sum[0] * block_sum[0] >> (level + 3)); best_mean = block_sum[0] + (size >> 1) >> (level + 3); if (level < 4) { for (count = 1; count < 7; count++) { int best_vector_score = INT_MAX; int best_vector_sum = -999, best_vector_mean = -999; const int stage = count - 1; const int8_t *vector; for (i = 0; i < 16; i++) { int sum = codebook_sum[stage * 16 + i]; int sqr, diff, score; vector = codebook + stage * size * 16 + i * size; sqr = s->ssd_int8_vs_int16(vector, block[stage], size); diff = block_sum[stage] - sum; score = sqr - (diff * (int64_t)diff >> (level + 3)); if (score < best_vector_score) { int mean = diff + (size >> 1) >> (level + 3); av_assert2(mean > -300 && mean < 300); mean = av_clip(mean, intra ? 0 : -256, 255); best_vector_score = score; best_vector[stage] = i; best_vector_sum = sum; best_vector_mean = mean; } } av_assert0(best_vector_mean != -999); vector = codebook + stage * size * 16 + best_vector[stage] * size; for (j = 0; j < size; j++) block[stage + 1][j] = block[stage][j] - vector[j]; block_sum[stage + 1] = block_sum[stage] - best_vector_sum; best_vector_score += lambda * (+1 + 4 * count + multistage_vlc[1 + count][1] + mean_vlc[best_vector_mean][1]); if (best_vector_score < best_score) { best_score = best_vector_score; best_count = count; best_mean = best_vector_mean; } } } split = 0; if (best_score > threshold && level) { int score = 0; int offset = level & 1 ? stride * h / 2 : w / 2; PutBitContext backup[6]; for (i = level - 1; i >= 0; i--) backup[i] = s->reorder_pb[i]; score += encode_block(s, src, ref, decoded, stride, level - 1, threshold >> 1, lambda, intra); score += encode_block(s, src + offset, ref + offset, decoded + offset, stride, level - 1, threshold >> 1, lambda, intra); score += lambda; if (score < best_score) { best_score = score; split = 1; } else { for (i = level - 1; i >= 0; i--) s->reorder_pb[i] = backup[i]; } } if (level > 0) put_bits(&s->reorder_pb[level], 1, split); if (!split) { av_assert1(best_mean >= 0 && best_mean < 256 || !intra); av_assert1(best_mean >= -256 && best_mean < 256); av_assert1(best_count >= 0 && best_count < 7); av_assert1(level < 4 || best_count == 0); put_bits(&s->reorder_pb[level], multistage_vlc[1 + best_count][1], multistage_vlc[1 + best_count][0]); put_bits(&s->reorder_pb[level], mean_vlc[best_mean][1], mean_vlc[best_mean][0]); for (i = 0; i < best_count; i++) { av_assert2(best_vector[i] >= 0 && best_vector[i] < 16); put_bits(&s->reorder_pb[level], 4, best_vector[i]); } for (y = 0; y < h; y++) for (x = 0; x < w; x++) decoded[x + y * stride] = src[x + y * stride] - block[best_count][x + w * y] + best_mean; } return best_score; }
1threat
Add border for dots in UIPageControl : <p>I want to add border color for dots in UIPageControl. Here is the small picture of it:</p> <p><a href="https://i.stack.imgur.com/hE07m.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hE07m.png" alt="enter image description here"></a></p> <p>I am able to put second dot by configuring it from XCode but I cannot make the first and third circles' inside empty. Is there a simple way to achieve that?</p> <p>Thanks :)</p>
0debug
static float quantize_band_cost(struct AACEncContext *s, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits) { const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; const float CLIPPED_ESCAPE = 165140.0f*IQ; int i, j, k; float cost = 0; const int dim = cb < FIRST_PAIR_BT ? 4 : 2; int resbits = 0; #ifndef USE_REALLY_FULL_SEARCH const float Q34 = sqrtf(Q * sqrtf(Q)); const int range = aac_cb_range[cb]; const int maxval = aac_cb_maxval[cb]; int offs[4]; #endif if (!cb) { for (i = 0; i < size; i++) cost += in[i]*in[i]*lambda; if (bits) *bits = 0; return cost; } #ifndef USE_REALLY_FULL_SEARCH offs[0] = 1; for (i = 1; i < dim; i++) offs[i] = offs[i-1]*range; quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval); #endif for (i = 0; i < size; i += dim) { float mincost; int minidx = 0; int minbits = 0; const float *vec; #ifndef USE_REALLY_FULL_SEARCH int (*quants)[2] = &s->qcoefs[i]; mincost = 0.0f; for (j = 0; j < dim; j++) mincost += in[i+j]*in[i+j]*lambda; minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; minbits = ff_aac_spectral_bits[cb-1][minidx]; mincost += minbits; for (j = 0; j < (1<<dim); j++) { float rd = 0.0f; int curbits; int curidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; int same = 0; for (k = 0; k < dim; k++) { if ((j & (1 << k)) && quants[k][0] == quants[k][1]) { same = 1; break; } } if (same) continue; for (k = 0; k < dim; k++) curidx += quants[k][!!(j & (1 << k))] * offs[dim - 1 - k]; curbits = ff_aac_spectral_bits[cb-1][curidx]; vec = &ff_aac_codebook_vectors[cb-1][curidx*dim]; #else mincost = INFINITY; vec = ff_aac_codebook_vectors[cb-1]; for (j = 0; j < ff_aac_spectral_sizes[cb-1]; j++, vec += dim) { float rd = 0.0f; int curbits = ff_aac_spectral_bits[cb-1][j]; #endif if (IS_CODEBOOK_UNSIGNED(cb)) { for (k = 0; k < dim; k++) { float t = fabsf(in[i+k]); float di; if (vec[k] == 64.0f && t < 39.0f*IQ) { rd = INFINITY; break; } if (vec[k] == 64.0f) { if (t >= CLIPPED_ESCAPE) { di = t - CLIPPED_ESCAPE; curbits += 21; } else { int c = av_clip(quant(t, Q), 0, 8191); di = t - c*cbrt(c)*IQ; curbits += av_log2(c)*2 - 4 + 1; } } else { di = t - vec[k]*IQ; } if (vec[k] != 0.0f) curbits++; rd += di*di*lambda; } } else { for (k = 0; k < dim; k++) { float di = in[i+k] - vec[k]*IQ; rd += di*di*lambda; } } rd += curbits; if (rd < mincost) { mincost = rd; minidx = j; minbits = curbits; } } cost += mincost; resbits += minbits; if (cost >= uplim) return uplim; } if (bits) *bits = resbits; return cost; }
1threat
static int coroutine_fn mirror_iteration(MirrorBlockJob *s) { BlockDriverState *source = s->common.bs; BlockDriverState *target = s->target; QEMUIOVector qiov; int ret, nb_sectors; int64_t end; struct iovec iov; end = s->common.len >> BDRV_SECTOR_BITS; s->sector_num = bdrv_get_next_dirty(source, s->sector_num); nb_sectors = MIN(BDRV_SECTORS_PER_DIRTY_CHUNK, end - s->sector_num); bdrv_reset_dirty(source, s->sector_num, nb_sectors); iov.iov_base = s->buf; iov.iov_len = nb_sectors * 512; qemu_iovec_init_external(&qiov, &iov, 1); trace_mirror_one_iteration(s, s->sector_num, nb_sectors); ret = bdrv_co_readv(source, s->sector_num, nb_sectors, &qiov); if (ret < 0) { return ret; } return bdrv_co_writev(target, s->sector_num, nb_sectors, &qiov); }
1threat
AVOption *av_set_string(void *obj, const char *name, const char *val){ AVOption *o= find_opt(obj, name); if(!o || !val || o->offset<=0) return NULL; if(o->type != FF_OPT_TYPE_STRING){ double d=0, tmp_d; for(;;){ int i; char buf[256], *tail; for(i=0; i<sizeof(buf)-1 && val[i] && val[i]!='+'; i++) buf[i]= val[i]; buf[i]=0; val+= i; tmp_d= av_parse_num(buf, &tail); if(tail > buf) d+= tmp_d; else{ AVOption *o_named= find_opt(obj, buf); if(o_named && o_named->type == FF_OPT_TYPE_CONST) d+= o_named->default_val; else if(!strcmp(buf, "default")) d+= o->default_val; else if(!strcmp(buf, "max" )) d+= o->max; else if(!strcmp(buf, "min" )) d+= o->min; else return NULL; } if(*val == '+') val++; if(!*val) return av_set_number(obj, name, d, 1, 1); } return NULL; } memcpy(((uint8_t*)obj) + o->offset, val, sizeof(val)); return o; }
1threat
static void load_tc(QEMUFile *f, TCState *tc) { int i; for(i = 0; i < 32; i++) qemu_get_betls(f, &tc->gpr[i]); qemu_get_betls(f, &tc->PC); for(i = 0; i < MIPS_DSP_ACC; i++) qemu_get_betls(f, &tc->HI[i]); for(i = 0; i < MIPS_DSP_ACC; i++) qemu_get_betls(f, &tc->LO[i]); for(i = 0; i < MIPS_DSP_ACC; i++) qemu_get_betls(f, &tc->ACX[i]); qemu_get_betls(f, &tc->DSPControl); qemu_get_sbe32s(f, &tc->CP0_TCStatus); qemu_get_sbe32s(f, &tc->CP0_TCBind); qemu_get_betls(f, &tc->CP0_TCHalt); qemu_get_betls(f, &tc->CP0_TCContext); qemu_get_betls(f, &tc->CP0_TCSchedule); qemu_get_betls(f, &tc->CP0_TCScheFBack); qemu_get_sbe32s(f, &tc->CP0_Debug_tcstatus); }
1threat
What js module has currency formatting/ calculation? : <p>I am using react and looking for a module that can convert amounts based on currency symbol? What would be a good module for this?</p>
0debug
what is the fast way to drop columns in pandas dataframe from a list of column names : <p>I'm trying to figure out the fastest way to drop columns in df using a list of column names. this is a fancy feature reduction technique. This is what I am using now, and it is taking forever. Any suggestions are highly appreciated.</p> <pre><code> important2=(important[:-(len(important)-500)]) for i in important: if i in important2: pass else: df_reduced.drop(i, axis=1, inplace=True) df_reduced.head() </code></pre>
0debug
Sort WordCount Output by value [Hadoop] [Java Code] : Hello wonderful people of StackOverflow, My name is Ragnall and I am new to Hadoop. I am currently writing a Hadoop program that outputs the top 100 most tweeted hastags given a data set of tweets. I was able to output all the hashtags with the WordCount program. So the output looks like this, ignore the quotation marks: "#USA 2" "#Holy 5" "#SOS 3" "#Love 66" However, I ran into trouble when I attempt to sort them by their word frequencies (the value) with the code from here: http://santoshsorab.blogspot.com/2014/12/hadoop-java-map-reduce-sort-by-value.html I noticed that the key are integers instead of strings for the program input provided in the link above. I try changing a few parameters in the code to fit my usage but it didn't work out so well as I don't understand them so well. Please help me!
0debug
static unsigned int dec_btst_r(DisasContext *dc) { TCGv l0; DIS(fprintf (logfile, "btst $r%u, $r%u\n", dc->op1, dc->op2)); cris_cc_mask(dc, CC_MASK_NZ); l0 = tcg_temp_local_new(TCG_TYPE_TL); cris_alu(dc, CC_OP_BTST, l0, cpu_R[dc->op2], cpu_R[dc->op1], 4); cris_update_cc_op(dc, CC_OP_FLAGS, 4); t_gen_mov_preg_TN(dc, PR_CCS, l0); dc->flags_uptodate = 1; tcg_temp_free(l0); return 2; }
1threat
Customize Radio and Checkbox with CSS : <p>Is it possible to customize the look of radio and checkboxes only using CSS? I see there is a lot out there regarding this, but most solutions require the use of images and javascript. </p>
0debug
void ff_put_h264_qpel16_mc12_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_midh_qrt_16w_msa(src - (2 * stride) - 2, stride, dst, stride, 16, 0); }
1threat
static int htab_save_iterate(QEMUFile *f, void *opaque) { sPAPRMachineState *spapr = opaque; int fd; int rc = 0; if (!spapr->htab_shift) { qemu_put_be32(f, -1); return 0; } else { qemu_put_be32(f, 0); } if (!spapr->htab) { assert(kvm_enabled()); fd = get_htab_fd(spapr); if (fd < 0) { return fd; } rc = kvmppc_save_htab(f, fd, MAX_KVM_BUF_SIZE, MAX_ITERATION_NS); if (rc < 0) { return rc; } } else if (spapr->htab_first_pass) { htab_save_first_pass(f, spapr, MAX_ITERATION_NS); } else { rc = htab_save_later_pass(f, spapr, MAX_ITERATION_NS); } qemu_put_be32(f, 0); qemu_put_be16(f, 0); qemu_put_be16(f, 0); return rc; }
1threat
static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) { SWFContext *swf = s->priv_data; AVIOContext *pb = s->pb; AVStream *vst = NULL, *ast = NULL, *st = 0; int tag, len, i, frame, v, res; #if CONFIG_ZLIB if (swf->zpb) pb = swf->zpb; #endif for(;;) { uint64_t pos = avio_tell(pb); tag = get_swf_tag(pb, &len); if (tag < 0) return tag; if (len < 0) { av_log(s, AV_LOG_ERROR, "invalid tag length: %d\n", len); return AVERROR_INVALIDDATA; } if (tag == TAG_VIDEOSTREAM) { int ch_id = avio_rl16(pb); len -= 2; for (i=0; i<s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) goto skip; } avio_rl16(pb); avio_rl16(pb); avio_rl16(pb); avio_r8(pb); vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); vst->id = ch_id; vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = ff_codec_get_id(ff_swf_codec_tags, avio_r8(pb)); avpriv_set_pts_info(vst, 16, 256, swf->frame_rate); len -= 8; } else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) { for (i=0; i<s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) goto skip; } avio_r8(pb); v = avio_r8(pb); swf->samples_per_frame = avio_rl16(pb); ast = create_new_audio_stream(s, -1, v); if (!ast) return AVERROR(ENOMEM); len -= 4; } else if (tag == TAG_DEFINESOUND) { int ch_id = avio_rl16(pb); for (i=0; i<s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == ch_id) goto skip; } v = avio_r8(pb); ast = create_new_audio_stream(s, ch_id, v); if (!ast) return AVERROR(ENOMEM); ast->duration = avio_rl32(pb); if (((v>>4) & 15) == 2) { ast->skip_samples = avio_rl16(pb); len -= 2; } len -= 7; if ((res = av_get_packet(pb, pkt, len)) < 0) return res; pkt->pos = pos; pkt->stream_index = ast->index; return pkt->size; } else if (tag == TAG_VIDEOFRAME) { int ch_id = avio_rl16(pb); len -= 2; for(i=0; i<s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) { frame = avio_rl16(pb); len -= 2; if (len <= 0) goto skip; if ((res = av_get_packet(pb, pkt, len)) < 0) return res; pkt->pos = pos; pkt->pts = frame; pkt->stream_index = st->index; return pkt->size; } } } else if (tag == TAG_DEFINEBITSLOSSLESS || tag == TAG_DEFINEBITSLOSSLESS2) { #if CONFIG_ZLIB long out_len; uint8_t *buf = NULL, *zbuf = NULL, *pal; uint32_t colormap[AVPALETTE_COUNT] = {0}; const int alpha_bmp = tag == TAG_DEFINEBITSLOSSLESS2; const int colormapbpp = 3 + alpha_bmp; int linesize, colormapsize = 0; const int ch_id = avio_rl16(pb); const int bmp_fmt = avio_r8(pb); const int width = avio_rl16(pb); const int height = avio_rl16(pb); len -= 2+1+2+2; switch (bmp_fmt) { case 3: linesize = width; colormapsize = avio_r8(pb) + 1; len--; break; case 4: linesize = width * 2; break; case 5: linesize = width * 4; break; default: av_log(s, AV_LOG_ERROR, "invalid bitmap format %d, skipped\n", bmp_fmt); goto bitmap_end_skip; } linesize = FFALIGN(linesize, 4); if (av_image_check_size(width, height, 0, s) < 0 || linesize >= INT_MAX / height || linesize * height >= INT_MAX - colormapsize * colormapbpp) { av_log(s, AV_LOG_ERROR, "invalid frame size %dx%d\n", width, height); goto bitmap_end_skip; } out_len = colormapsize * colormapbpp + linesize * height; av_dlog(s, "bitmap: ch=%d fmt=%d %dx%d (linesize=%d) len=%d->%ld pal=%d\n", ch_id, bmp_fmt, width, height, linesize, len, out_len, colormapsize); zbuf = av_malloc(len); buf = av_malloc(out_len); if (!zbuf || !buf) { res = AVERROR(ENOMEM); goto bitmap_end; } len = avio_read(pb, zbuf, len); if (len < 0 || (res = uncompress(buf, &out_len, zbuf, len)) != Z_OK) { av_log(s, AV_LOG_WARNING, "Failed to uncompress one bitmap\n"); goto bitmap_end_skip; } for (i = 0; i < s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO && st->id == -3) break; } if (i == s->nb_streams) { vst = avformat_new_stream(s, NULL); if (!vst) { res = AVERROR(ENOMEM); goto bitmap_end; } vst->id = -3; vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO; avpriv_set_pts_info(vst, 64, 256, swf->frame_rate); st = vst; } st->codec->width = width; st->codec->height = height; if ((res = av_new_packet(pkt, out_len - colormapsize * colormapbpp)) < 0) goto bitmap_end; pkt->pos = pos; pkt->stream_index = st->index; switch (bmp_fmt) { case 3: st->codec->pix_fmt = AV_PIX_FMT_PAL8; for (i = 0; i < colormapsize; i++) if (alpha_bmp) colormap[i] = buf[3]<<24 | AV_RB24(buf + 4*i); else colormap[i] = 0xffU <<24 | AV_RB24(buf + 3*i); pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); if (!pal) { res = AVERROR(ENOMEM); goto bitmap_end; } memcpy(pal, colormap, AVPALETTE_SIZE); break; case 4: st->codec->pix_fmt = AV_PIX_FMT_RGB555; break; case 5: st->codec->pix_fmt = alpha_bmp ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB; break; default: av_assert0(0); } if (linesize * height > pkt->size) { res = AVERROR_INVALIDDATA; goto bitmap_end; } memcpy(pkt->data, buf + colormapsize*colormapbpp, linesize * height); res = pkt->size; bitmap_end: av_freep(&zbuf); av_freep(&buf); return res; bitmap_end_skip: av_freep(&zbuf); av_freep(&buf); #else av_log(s, AV_LOG_ERROR, "this file requires zlib support compiled in\n"); #endif } else if (tag == TAG_STREAMBLOCK) { for (i = 0; i < s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) { if (st->codec->codec_id == AV_CODEC_ID_MP3) { avio_skip(pb, 4); len -= 4; if (len <= 0) goto skip; if ((res = av_get_packet(pb, pkt, len)) < 0) return res; } else { if (len <= 0) goto skip; if ((res = av_get_packet(pb, pkt, len)) < 0) return res; } pkt->pos = pos; pkt->stream_index = st->index; return pkt->size; } } } else if (tag == TAG_JPEG2) { for (i=0; i<s->nb_streams; i++) { st = s->streams[i]; if (st->codec->codec_id == AV_CODEC_ID_MJPEG && st->id == -2) break; } if (i == s->nb_streams) { vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); vst->id = -2; vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = AV_CODEC_ID_MJPEG; avpriv_set_pts_info(vst, 64, 256, swf->frame_rate); st = vst; } avio_rl16(pb); len -= 2; if (len < 4) goto skip; if ((res = av_new_packet(pkt, len)) < 0) return res; if (avio_read(pb, pkt->data, 4) != 4) { av_free_packet(pkt); return AVERROR_INVALIDDATA; } if (AV_RB32(pkt->data) == 0xffd8ffd9 || AV_RB32(pkt->data) == 0xffd9ffd8) { pkt->size -= 4; res = avio_read(pb, pkt->data, pkt->size); } else { res = avio_read(pb, pkt->data + 4, pkt->size - 4); if (res >= 0) res += 4; } if (res != pkt->size) { if (res < 0) { av_free_packet(pkt); return res; } av_shrink_packet(pkt, res); } pkt->pos = pos; pkt->stream_index = st->index; return pkt->size; } else { av_log(s, AV_LOG_DEBUG, "Unknown tag: %d\n", tag); } skip: if(len<0) av_log(s, AV_LOG_WARNING, "Cliping len %d\n", len); len = FFMAX(0, len); avio_skip(pb, len); } }
1threat
static int ivi_init_tiles(IVIBandDesc *band, IVITile *ref_tile, int p, int b, int t_height, int t_width) { int x, y; IVITile *tile = band->tiles; for (y = 0; y < band->height; y += t_height) { for (x = 0; x < band->width; x += t_width) { tile->xpos = x; tile->ypos = y; tile->mb_size = band->mb_size; tile->width = FFMIN(band->width - x, t_width); tile->height = FFMIN(band->height - y, t_height); tile->is_empty = tile->data_size = 0; tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size); av_freep(&tile->mbs); tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo)); if (!tile->mbs) return AVERROR(ENOMEM); tile->ref_mbs = 0; if (p || b) { if (tile->num_MBs != ref_tile->num_MBs) { av_log(NULL, AV_LOG_DEBUG, "ref_tile mismatch\n"); return AVERROR_INVALIDDATA; } tile->ref_mbs = ref_tile->mbs; ref_tile++; } tile++; } } return 0; }
1threat
bool colo_supported(void) { return true; }
1threat
php Laravel- A non well formed numeric value encountered (on string) : <p>I have two function in my controller and service. I want to call a function in service. Here is my code : </p> <p><strong>Controller:</strong></p> <pre><code>public function findNeighborhoodGet(): array { $regionCenter = Request::get('region_center'); $distanceService = \App::make('App\web\one\Infrastructure\Service\Google\Map'); try { $userPoint = $distanceService-&gt;getOriginPoint($regionCenter); } . . . return $result } </code></pre> <p><strong>my service (Map.php) :</strong></p> <pre><code>public function getOriginPoint(string $origin):Point { dd($origin); return $this-&gt;getPointObject($origin); } </code></pre> <p>Actually , I get an error :</p> <pre><code>A non well formed numeric value encountered </code></pre> <p>at this line: <em>public function getOriginPoint(string $origin):Point</em></p> <p>How to solve it?</p>
0debug
CSS to draw slant line border : <p>I have not much experience in web designing, I was just trying to write a css to get the out put similar to this <a href="https://i.stack.imgur.com/oavxB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oavxB.png" alt="enter image description here"></a></p> <p>Can anyone help me to achieve this kind of header using css</p>
0debug
static int aac_decode_frame(AVCodecContext * avccontext, void * data, int * data_size, const uint8_t * buf, int buf_size) { AACContext * ac = avccontext->priv_data; GetBitContext gb; enum RawDataBlockType elem_type; int err, elem_id, data_size_tmp; init_get_bits(&gb, buf, buf_size*8); if (show_bits(&gb, 12) == 0xfff) { if ((err = parse_adts_frame_header(ac, &gb)) < 0) { av_log(avccontext, AV_LOG_ERROR, "Error decoding AAC frame header.\n"); return -1; } if (ac->m4ac.sampling_index > 11) { av_log(ac->avccontext, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); return -1; } } while ((elem_type = get_bits(&gb, 3)) != TYPE_END) { elem_id = get_bits(&gb, 4); err = -1; if(elem_type == TYPE_SCE && elem_id == 1 && !ac->che[TYPE_SCE][elem_id] && ac->che[TYPE_LFE][0]) { ac->che[TYPE_SCE][elem_id] = ac->che[TYPE_LFE][0]; ac->che[TYPE_LFE][0] = NULL; } if(elem_type < TYPE_DSE) { if(!ac->che[elem_type][elem_id]) return -1; if(elem_type != TYPE_CCE) ac->che[elem_type][elem_id]->coup.coupling_point = 4; } switch (elem_type) { case TYPE_SCE: err = decode_ics(ac, &ac->che[TYPE_SCE][elem_id]->ch[0], &gb, 0, 0); break; case TYPE_CPE: err = decode_cpe(ac, &gb, elem_id); break; case TYPE_CCE: err = decode_cce(ac, &gb, ac->che[TYPE_CCE][elem_id]); break; case TYPE_LFE: err = decode_ics(ac, &ac->che[TYPE_LFE][elem_id]->ch[0], &gb, 0, 0); break; case TYPE_DSE: skip_data_stream_element(&gb); err = 0; break; case TYPE_PCE: { enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); if((err = decode_pce(ac, new_che_pos, &gb))) break; err = output_configure(ac, ac->che_pos, new_che_pos); break; } case TYPE_FIL: if (elem_id == 15) elem_id += get_bits(&gb, 8) - 1; while (elem_id > 0) elem_id -= decode_extension_payload(ac, &gb, elem_id); err = 0; break; default: err = -1; break; } if(err) return err; } spectral_to_sample(ac); if (!ac->is_saved) { ac->is_saved = 1; *data_size = 0; return buf_size; } data_size_tmp = 1024 * avccontext->channels * sizeof(int16_t); if(*data_size < data_size_tmp) { av_log(avccontext, AV_LOG_ERROR, "Output buffer too small (%d) or trying to output too many samples (%d) for this frame.\n", *data_size, data_size_tmp); return -1; } *data_size = data_size_tmp; ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, 1024, avccontext->channels); return buf_size; }
1threat
Python- generate a symmetric list of list with half of nxn list of list data : <p>I have this list of list, and I would like to convert it into a symmetric list of list. What should I do? </p> <pre><code> [[0, 8, 4, 10, 12, 9, 15, 8, 11, 5, 9, 4, 10], [0, 0, 7, 6, 8, 6, 7, 10, 12, 9, 8, 7, 5], [0, 0, 0, 7, 9, 5, 8, 5, 4, 8, 6, 10, 8], [0, 0, 0, 0, 6, 11, 5, 9, 8, 12, 11, 6, 9], [0, 0, 0, 0, 0, 7, 9, 6, 9, 8, 4, 11, 10], [0, 0, 0, 0, 0, 0, 10, 4, 3, 10, 6, 5, 7], [0, 0, 0, 0, 0, 0, 0, 10, 9, 8, 5, 9, 10], [0, 0, 0, 0, 0, 0, 0, 0, 11, 5, 9, 6, 7], [0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 11, 11, 6], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 5], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] </code></pre>
0debug
Send iOS Push notification in php with .p8 file : <p>Apple has updated their push notification service and the certificate file received is now a .p8 file. There are many examples online of how to send a push notification with the .pem file but I can't find anything for a .p8 file. Does anyone have any code that works with the .p8 file?</p>
0debug
static void nfs_refresh_filename(BlockDriverState *bs, QDict *options) { NFSClient *client = bs->opaque; QDict *opts = qdict_new(); QObject *server_qdict; Visitor *ov; qdict_put(opts, "driver", qstring_from_str("nfs")); if (client->uid && !client->gid) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nfs: client->uid); } else if (!client->uid && client->gid) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nfs: client->gid); } else if (client->uid && client->gid) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nfs: client->server->host, client->path, client->uid, client->gid); } else { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nfs: } ov = qobject_output_visitor_new(&server_qdict); visit_type_NFSServer(ov, NULL, &client->server, &error_abort); visit_complete(ov, &server_qdict); assert(qobject_type(server_qdict) == QTYPE_QDICT); qdict_put_obj(opts, "server", server_qdict); qdict_put(opts, "path", qstring_from_str(client->path)); if (client->uid) { qdict_put(opts, "user", qint_from_int(client->uid)); } if (client->gid) { qdict_put(opts, "group", qint_from_int(client->gid)); } if (client->tcp_syncnt) { qdict_put(opts, "tcp-syn-cnt", qint_from_int(client->tcp_syncnt)); } if (client->readahead) { qdict_put(opts, "readahead-size", qint_from_int(client->readahead)); } if (client->pagecache) { qdict_put(opts, "page-cache-size", qint_from_int(client->pagecache)); } if (client->debug) { qdict_put(opts, "debug", qint_from_int(client->debug)); } visit_free(ov); qdict_flatten(opts); bs->full_open_options = opts; }
1threat
Spring Security OAuth2 - How to use OAuth2Authentication object? : <p>I have OAuth2 authorization server which provides user information:</p> <pre><code>public class User implements Serializable, UserDetails { private Long userID; private String username; private String password; private String fullName; private String email; private String avatar; private boolean enabled; // etc } @RestController @RequestMapping("/api") public class APIController { @RequestMapping("/me") public User me(@AuthenticationPrincipal User activeUser) { return activeUser; } } </code></pre> <p>Also I've implemented OAuth2 client as separate Spring Boot application.</p> <pre><code>@Configuration @EnableOAuth2Sso public class OAuth2ClientConfig extends WebSecurityConfigurerAdapter { @Override public void configure(HttpSecurity http) throws Exception { http.logout() .and() .antMatcher("/**").authorizeRequests() .antMatchers("/login").permitAll() .anyRequest().authenticated(); } } </code></pre> <p><strong>application.yml</strong></p> <pre><code>security: user: password: none oauth2: client: clientId: acme clientSecret: acmepassword accessTokenUri: http://localhost:9080/sso/oauth/token userAuthorizationUri: http://localhost:9080/sso/oauth/authorize resource: userInfoUri: http://localhost:9080/sso/api/me </code></pre> <p>User authenticates successfully:</p> <pre><code>@Controller public class MainController { @RequestMapping(value = "/") public String index(Principal principal) { System.out.println(principal); // org.springframework.security.oauth2.provider.OAuth2Authentication@c2e723e8: Principal: superadmin; Credentials: [PROTECTED]; Authenticated: true; Details: remoteAddress=&lt;ADDRESS&gt;, sessionId=&lt;SESSION&gt;, tokenType=bearertokenValue=&lt;TOKEN&gt;; Granted Authorities: {userRoleID=1, authority=ROLE_SUPERUSER} OAuth2Authentication auth = (OAuth2Authentication) principal; System.out.println(auth.getUserAuthentication().getDetails()); // {userID=1, username=superadmin, password=***, fullName=SuperUser, email=superadmin@example.org, avatar=null, enabled=true ... return "index"; } } </code></pre> <p>But I can't understand how to use provided OAuth2Authentication object in my application. It almost useless.</p> <p>When I'm trying to use any Thymeleaf security tag</p> <pre><code>&lt;span sec:authentication="principal.fullName"&gt;Username&lt;/span&gt; &lt;span sec:authentication="principal.authorities"&gt;Authorities&lt;/span&gt; &lt;span sec:authentication="principal.userAuthentication.details.fullName"&gt;Usernames&lt;/span&gt; </code></pre> <p>.. the following exception occurs:</p> <pre><code>Error retrieving value for property "property name here" of authentication object of class org.springframework.security.oauth2.provider.OAuth2Authentication </code></pre> <p>Standard Spring Security methods <code>isUserInRole()</code> not working too:</p> <pre><code>System.out.println(servletRequest.isUserInRole("ROLE_SUPERUSER")); // false </code></pre> <p>Should I implement custom Thymeleaf security dialect and hasRole() method? Or maybe simpler solution exists?</p>
0debug
VSCode editor - Restart NodeJs server when file is changed : <p>I am using Visual Studio Code as my editor for NodeJS project.</p> <p>Currently I need to manually restart server when I change files in my project.</p> <p>Is there any plugin or configuration change in VSCode that can restart NodeJS server automatically when I make change in files.</p>
0debug
Multiple variable let in Kotlin : <p>Is there any way to chain multiple lets for multiple nullable variables in kotlin?</p> <pre><code>fun example(first: String?, second: String?) { first?.let { second?.let { // Do something just if both are != null } } } </code></pre> <p>I mean, something like this:</p> <pre><code>fun example(first: String?, second: String?) { first?.let &amp;&amp; second?.let { // Do something just if both are != null } } </code></pre>
0debug
void *virtqueue_pop(VirtQueue *vq, size_t sz) { unsigned int i, head, max; hwaddr desc_pa = vq->vring.desc; VirtIODevice *vdev = vq->vdev; VirtQueueElement *elem; unsigned out_num, in_num; hwaddr addr[VIRTQUEUE_MAX_SIZE]; struct iovec iov[VIRTQUEUE_MAX_SIZE]; VRingDesc desc; if (!virtqueue_num_heads(vq, vq->last_avail_idx)) { return NULL; } out_num = in_num = 0; max = vq->vring.num; i = head = virtqueue_get_head(vq, vq->last_avail_idx++); if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_avail_event(vq, vq->last_avail_idx); } vring_desc_read(vdev, &desc, desc_pa, i); if (desc.flags & VRING_DESC_F_INDIRECT) { if (desc.len % sizeof(VRingDesc)) { error_report("Invalid size for indirect buffer table"); exit(1); } max = desc.len / sizeof(VRingDesc); desc_pa = desc.addr; i = 0; vring_desc_read(vdev, &desc, desc_pa, i); } do { if (desc.flags & VRING_DESC_F_WRITE) { virtqueue_map_desc(&in_num, addr + out_num, iov + out_num, VIRTQUEUE_MAX_SIZE - out_num, true, desc.addr, desc.len); } else { if (in_num) { error_report("Incorrect order for descriptors"); exit(1); } virtqueue_map_desc(&out_num, addr, iov, VIRTQUEUE_MAX_SIZE, false, desc.addr, desc.len); } if ((in_num + out_num) > max) { error_report("Looped descriptor"); exit(1); } } while ((i = virtqueue_read_next_desc(vdev, &desc, desc_pa, max)) != max); elem = virtqueue_alloc_element(sz, out_num, in_num); elem->index = head; for (i = 0; i < out_num; i++) { elem->out_addr[i] = addr[i]; elem->out_sg[i] = iov[i]; } for (i = 0; i < in_num; i++) { elem->in_addr[i] = addr[out_num + i]; elem->in_sg[i] = iov[out_num + i]; } vq->inuse++; trace_virtqueue_pop(vq, elem, elem->in_num, elem->out_num); return elem; }
1threat
Express and WebSocket listening on the same port : <p>I have an app.js which is used to trigger two events when some POST data are received: </p> <ol> <li>Insert POST data into a database</li> <li>Send a message to a client using a WebSocket</li> </ol> <p>Here is the <strong>app.js</strong> (only the important lines)</p> <pre><code>var express = require('express'); var bodyParser = require('body-parser'); var server = require('./server'); var app = express(); var port = process.env.PORT || 3000; app.post('/server', server); app.listen(port, function(){ console.log('Slack bot listening'); }); </code></pre> <p>And here is the <strong>server.js</strong> (only the important lines)</p> <pre><code>var db = require('./DB'); var WebSocketServer = require('ws').Server; var insertData = function(req, res){ var wss = new WebSocketServer({server: server}); console.log('WebSocketServer created'); wss.on('connection', function(wss){ wss.send(JSON.stringify('Socket open')); }); wss.on('close', function(){ console.log('WebServerSocket has been closed'); }); }; module.exports = insertData; </code></pre> <p>What I would like to achieve is to set the WebSocketServer in a way that it listen to the same port of the app. I thought about passing the <em>server</em> var from <strong>app.js</strong> to <strong>server.js</strong> but </p> <ol> <li>I think this a not an elegant way to do it</li> <li>I don't know how to do it</li> </ol> <p>What do you guys think? </p>
0debug
I'm getting an error while concatenating a null string to a string with some values : <p>For one of the following snippet I'm getting a run-time exception.</p> <pre><code>public class Demo { public static void main(String[] args) { String org="This is the new shit.This is the new."; String search="is"; String sub="was"; int i; String result=""; do{ i=org.indexOf(search); if(i==-1) break; result=result+org.substring(0,i); result=result+sub; result=result+org.substring(i+search.length()); org=result; }while(i!=-1); System.out.println(org); } </code></pre> <p>}</p> <p>The exception thrown is as follows:</p> <pre><code>at java.util.Arrays.copyOfRange(Unknown Source) at java.lang.String.&lt;init&gt;(Unknown Source) at java.lang.StringBuilder.toString(Unknown Source) at strings.Demo.main(Demo.java:16) </code></pre> <p>Can anyone tell why this exception is being thrown.</p>
0debug
(Java) Reading a file > convert it into and array and calculate the numbers : So i have a file called "results.txt" and has these values inside: 0118210:1801:XDCS1094:A:4 0118210:1801:XDCS2034:B+:4 0118210:1801:XDCS1043:C:3 0118024:1801:XDCS1094:B:4 0118024:1801:XDCS2094:A:4 So i want to read the file , make it an array and remove the delimiter and calculate based on the GPA formula. So this is my thoughts of how it should work but im still not so sure and im new to programming. I am also trying to make my results display in a new line instead of everything in one line as shown in the image.Any help would be appreciated thanks it is for my assignments [Line][1] public void run() { try{ do{ found=0; received = in.readLine(); array2=received.split(":"); if(received.equals("QUIT")) break; switch(received.charAt(0)) { case 'R': Register(); break; case 'L': login(); break; case 'V': View(); break; } }while(!received.equals("QUIT")); } catch(IOException e) { e.printStackTrace(); } public void View() throws IOException { String grade =""; in3 = new BufferedReader(new FileReader("results.txt")); while((result = in3.readLine()) !=null) { array4=result.split(":"); if((array2[1].equals(array4[0])) && (array2[2].equals(array4[1]))) { grade += array4[2]+" "+array4[3]+" "+array4[4]; found=1; } if(found==0) out.println("No Records"); } out.println(grade); GCPA(); } public void CGPA() throws IOException{ if(array4[3] == "A") { IntArray = Integer.parseInt(array4[3]); IntValue = IntArray * 4; } else if(array4[3] == "B") { IntArray = Integer.parseInt(array4[3]); IntValue = IntArray * 3; } IntCH += IntArray; IntCGPA = IntValue/IntCH; out.println(IntCGPA); } [1]: https://i.stack.imgur.com/6GL0b.png
0debug
static inline int RENAME(yuv420_rgb32)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ int y, h_size; if(c->srcFormat == PIX_FMT_YUV422P){ srcStride[1] *= 2; srcStride[2] *= 2; } h_size= (c->dstW+7)&~7; if(h_size*4 > dstStride[0]) h_size-=8; __asm__ __volatile__ ("pxor %mm4, %mm4;" ); for (y= 0; y<srcSliceH; y++ ) { uint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0]; uint8_t *_py = src[0] + y*srcStride[0]; uint8_t *_pu = src[1] + (y>>1)*srcStride[1]; uint8_t *_pv = src[2] + (y>>1)*srcStride[2]; long index= -h_size/2; __asm__ __volatile__ ( "movd (%2, %0), %%mm0;" "movd (%3, %0), %%mm1;" "movq (%5, %0, 2), %%mm6;" "1: \n\t" YUV2RGB "pxor %%mm3, %%mm3;" "movq %%mm0, %%mm6;" "movq %%mm1, %%mm7;" "movq %%mm0, %%mm4;" "movq %%mm1, %%mm5;" "punpcklbw %%mm2, %%mm6;" "punpcklbw %%mm3, %%mm7;" "punpcklwd %%mm7, %%mm6;" MOVNTQ " %%mm6, (%1);" "movq %%mm0, %%mm6;" "punpcklbw %%mm2, %%mm6;" "punpckhwd %%mm7, %%mm6;" MOVNTQ " %%mm6, 8 (%1);" "punpckhbw %%mm2, %%mm4;" "punpckhbw %%mm3, %%mm5;" "punpcklwd %%mm5, %%mm4;" MOVNTQ " %%mm4, 16 (%1);" "movq %%mm0, %%mm4;" "punpckhbw %%mm2, %%mm4;" "punpckhwd %%mm5, %%mm4;" MOVNTQ " %%mm4, 24 (%1);" "movd 4 (%2, %0), %%mm0;" "movd 4 (%3, %0), %%mm1;" "pxor %%mm4, %%mm4;" "movq 8 (%5, %0, 2), %%mm6;" "add $32, %1 \n\t" "add $4, %0 \n\t" " js 1b \n\t" : "+r" (index), "+r" (_image) : "r" (_pu - index), "r" (_pv - index), "r"(&c->redDither), "r" (_py - 2*index) ); } __asm__ __volatile__ (EMMS); return srcSliceH; }
1threat
static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque) { RDMAControlHeader reg_resp = { .len = sizeof(RDMARegisterResult), .type = RDMA_CONTROL_REGISTER_RESULT, .repeat = 0, }; RDMAControlHeader unreg_resp = { .len = 0, .type = RDMA_CONTROL_UNREGISTER_FINISHED, .repeat = 0, }; RDMAControlHeader blocks = { .type = RDMA_CONTROL_RAM_BLOCKS_RESULT, .repeat = 1 }; QEMUFileRDMA *rfile = opaque; RDMAContext *rdma = rfile->rdma; RDMALocalBlocks *local = &rdma->local_ram_blocks; RDMAControlHeader head; RDMARegister *reg, *registers; RDMACompress *comp; RDMARegisterResult *reg_result; static RDMARegisterResult results[RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE]; RDMALocalBlock *block; void *host_addr; int ret = 0; int idx = 0; int count = 0; int i = 0; CHECK_ERROR_STATE(); do { trace_qemu_rdma_registration_handle_wait(); ret = qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_NONE); if (ret < 0) { if (head.repeat > RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE) { error_report("rdma: Too many requests in this message (%d)." "Bailing.", head.repeat); ret = -EIO; switch (head.type) { case RDMA_CONTROL_COMPRESS: comp = (RDMACompress *) rdma->wr_data[idx].control_curr; network_to_compress(comp); trace_qemu_rdma_registration_handle_compress(comp->length, comp->block_idx, comp->offset); if (comp->block_idx >= rdma->local_ram_blocks.nb_blocks) { error_report("rdma: 'compress' bad block index %u (vs %d)", (unsigned int)comp->block_idx, rdma->local_ram_blocks.nb_blocks); ret = -EIO; block = &(rdma->local_ram_blocks.block[comp->block_idx]); host_addr = block->local_host_addr + (comp->offset - block->offset); ram_handle_compressed(host_addr, comp->value, comp->length); case RDMA_CONTROL_REGISTER_FINISHED: trace_qemu_rdma_registration_handle_finished(); goto out; case RDMA_CONTROL_RAM_BLOCKS_REQUEST: trace_qemu_rdma_registration_handle_ram_blocks(); qsort(rdma->local_ram_blocks.block, rdma->local_ram_blocks.nb_blocks, sizeof(RDMALocalBlock), dest_ram_sort_func); if (rdma->pin_all) { ret = qemu_rdma_reg_whole_ram_blocks(rdma); if (ret) { error_report("rdma migration: error dest " "registering ram blocks"); goto out; for (i = 0; i < local->nb_blocks; i++) { rdma->dest_blocks[i].remote_host_addr = (uintptr_t)(local->block[i].local_host_addr); if (rdma->pin_all) { rdma->dest_blocks[i].remote_rkey = local->block[i].mr->rkey; rdma->dest_blocks[i].offset = local->block[i].offset; rdma->dest_blocks[i].length = local->block[i].length; dest_block_to_network(&rdma->dest_blocks[i]); trace_qemu_rdma_registration_handle_ram_blocks_loop( local->block[i].block_name, local->block[i].offset, local->block[i].length, local->block[i].local_host_addr, local->block[i].src_index); blocks.len = rdma->local_ram_blocks.nb_blocks * sizeof(RDMADestBlock); ret = qemu_rdma_post_send_control(rdma, (uint8_t *) rdma->dest_blocks, &blocks); if (ret < 0) { error_report("rdma migration: error sending remote info"); goto out; case RDMA_CONTROL_REGISTER_REQUEST: trace_qemu_rdma_registration_handle_register(head.repeat); reg_resp.repeat = head.repeat; registers = (RDMARegister *) rdma->wr_data[idx].control_curr; for (count = 0; count < head.repeat; count++) { uint64_t chunk; uint8_t *chunk_start, *chunk_end; reg = &registers[count]; network_to_register(reg); reg_result = &results[count]; trace_qemu_rdma_registration_handle_register_loop(count, reg->current_index, reg->key.current_addr, reg->chunks); if (reg->current_index >= rdma->local_ram_blocks.nb_blocks) { error_report("rdma: 'register' bad block index %u (vs %d)", (unsigned int)reg->current_index, rdma->local_ram_blocks.nb_blocks); ret = -ENOENT; block = &(rdma->local_ram_blocks.block[reg->current_index]); if (block->is_ram_block) { if (block->offset > reg->key.current_addr) { error_report("rdma: bad register address for block %s" " offset: %" PRIx64 " current_addr: %" PRIx64, block->block_name, block->offset, reg->key.current_addr); host_addr = (block->local_host_addr + (reg->key.current_addr - block->offset)); chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) host_addr); } else { chunk = reg->key.chunk; host_addr = block->local_host_addr + (reg->key.chunk * (1UL << RDMA_REG_CHUNK_SHIFT)); chunk_start = ram_chunk_start(block, chunk); chunk_end = ram_chunk_end(block, chunk + reg->chunks); if (qemu_rdma_register_and_get_keys(rdma, block, (uintptr_t)host_addr, NULL, &reg_result->rkey, chunk, chunk_start, chunk_end)) { error_report("cannot get rkey"); ret = -EINVAL; goto out; reg_result->host_addr = (uintptr_t)block->local_host_addr; trace_qemu_rdma_registration_handle_register_rkey( reg_result->rkey); result_to_network(reg_result); ret = qemu_rdma_post_send_control(rdma, (uint8_t *) results, &reg_resp); if (ret < 0) { error_report("Failed to send control buffer"); goto out; case RDMA_CONTROL_UNREGISTER_REQUEST: trace_qemu_rdma_registration_handle_unregister(head.repeat); unreg_resp.repeat = head.repeat; registers = (RDMARegister *) rdma->wr_data[idx].control_curr; for (count = 0; count < head.repeat; count++) { reg = &registers[count]; network_to_register(reg); trace_qemu_rdma_registration_handle_unregister_loop(count, reg->current_index, reg->key.chunk); block = &(rdma->local_ram_blocks.block[reg->current_index]); ret = ibv_dereg_mr(block->pmr[reg->key.chunk]); block->pmr[reg->key.chunk] = NULL; if (ret != 0) { perror("rdma unregistration chunk failed"); ret = -ret; goto out; rdma->total_registrations--; trace_qemu_rdma_registration_handle_unregister_success( reg->key.chunk); ret = qemu_rdma_post_send_control(rdma, NULL, &unreg_resp); if (ret < 0) { error_report("Failed to send control buffer"); goto out; case RDMA_CONTROL_REGISTER_RESULT: error_report("Invalid RESULT message at dest."); ret = -EIO; goto out; default: error_report("Unknown control message %s", control_desc[head.type]); ret = -EIO; goto out; } while (1); out: if (ret < 0) { rdma->error_state = ret; return ret;
1threat
How does process manager keep track of the association between aggregates : <p>Does a process manager make use of correlation-ids or aggregate-specific identifies to keep track of the <em>process</em> it is managing?</p> <p>To put it more clearly with an example, consider Figure 2 on <a href="https://msdn.microsoft.com/en-us/library/jj591569.aspx" rel="noreferrer">Saga on Sagas</a>:</p> <p><a href="https://i.stack.imgur.com/YW3fM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YW3fM.png" alt="enter image description here"></a></p> <p>First of all, Process Manager sending a <code>OrderConfirmed</code> event is wrong right? I (as a process manager) cannot send events, only issue commands. Or am I wrong?</p> <p>Second, how does the process manager correlate the OrderCreated, SeatsReserved, PaymentReceived events from different aggregates? Is it correlation id that each aggregate honors (and copies over), or is it specific identifiers (e.g. SeatsReserved has an Order Id that refers to the Order Aggregate)?</p> <p>Finally, if it is the case of correlation ids, who <em>creates</em> them? Is it the client who issues a command, like <code>PlaceOrder(order_id, correlation_id)</code>? Is it the Aggregate that accepts the command like <code>PlaceOrder(order_id)</code> and then emits <code>OrderCreated(order_id, corr_id)</code> event? Or, is it the process manager (in some way) that is responsible for this? Alternatively, perhaps correlation ids have nothing to do with this?</p> <p>Thanks for any help.</p>
0debug
Wordpress best learning path : <p>Guys I am very good in <strong>PHP, Sql, HTML, CSS, Bootstrap, jQuery</strong> and others plus I know how to work with <strong>Laravel Frameword</strong>. I decided to start learning <strong>Wordpress</strong> because it is easy and fast in web development.</p> <p>The question is what is the best path or tutorial should I start learning while I have all those web design and development background.</p> <p>I found many tutorials on Youtube but I am very dispersed and don't know from where to start and what is the best tutorial I should start with.</p> <p>Thanks</p>
0debug
How can I combine row values into a new row in pandas : <p><a href="https://i.stack.imgur.com/uRW4d.png" rel="nofollow noreferrer">I would like to merge multiple rows with different names into a new row.</a></p>
0debug
Docker Multi-stage build - Copy failing : <p>I'm having some issues with a multi-stage Dockerfile for an ejected create-react-app. The Dockerfile is listed below:</p> <pre><code>FROM node:9.6.1 as builder RUN mkdir /usr/src/app WORKDIR /usr/src/app ENV PATH /usr/src/app/node_modules/.bin:$PATH COPY package.json /usr/src/app/package.json RUN npm install --silent COPY . /usr/src/app RUN npm run build FROM nginx:1.13.9-alpine COPY --from=builder /usr/src/app/build /usr/share/nginx/html EXPOSE 80 </code></pre> <p>The Dockerfile runs successfully until it gets to step 10 (COPY) where it throws the following error:</p> <pre><code>COPY failed: stat /var/lib/docker/overlay2/2fc8af4cb8db9777246cae48721d8a93917c73e415a02680f1e3a73c8780b903/merged/usr/src/app/build: no such file or directory </code></pre> <p>I've googled away but can't find a clear answer. Has anyone experienced anything similar?</p>
0debug
@babel/typescript doesn't throw errors while webpack build : <p>I am trying to transpile TypeScript with Babel 7's @babel/typescript preset. It works fine but for some reason, there aren't any error messages from TS in the build console.</p> <p>I have the next config:</p> <p>webpack.config.js</p> <pre><code>const outputPath = require('path').resolve(__dirname, './production'); const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { entry: [ './src/index.tsx' ], output: { path: outputPath, filename: '[name].[chunkhash].js', }, module: { rules: [ { test: /\.(ts|tsx)$/, exclude: /node_modules/, loader: 'babel-loader', }, { test: /\.js$/, exclude: /node_modules/, loader: 'source-map-loader', enforce: "pre" }, { test: /\.(jpe?g|png|gif|svg)$/i, loader: 'file-loader' }, { test: /\.(eot|svg|ttf|woff|woff2)$/, loader: 'file-loader' } ] }, plugins: [ new HtmlWebpackPlugin({template: './src/index.html'}) ], resolve: { extensions: ['.js', '.jsx', '.ts', '.tsx'] }, devServer: { contentBase: outputPath } }; </code></pre> <p>.babelrc</p> <pre><code>{ "presets": [ "@babel/preset-env", "@babel/typescript", "@babel/preset-react" ], "plugins": [ "react-hot-loader/babel", "@babel/plugin-transform-runtime", ] } </code></pre> <p>tsconfig.json</p> <pre><code>{ "compilerOptions": { "target": "es5", "module": "commonjs", "jsx": "react", "outDir": "./production/", "sourceMap": true, "noImplicitAny": true, "lib": ["esnext", "dom"] }, "include": [ "./src/**/*" ] } </code></pre> <p>And output is:</p> <pre><code>ℹ 「wds」: Project is running at http://localhost:8080/ ℹ 「wds」: webpack output is served from / ℹ 「wds」: Content not from webpack is served from /Users/me/projects/react/production ℹ 「wdm」: Hash: 1186927fe343142edc70 Version: webpack 4.29.3 Time: 1120ms Built at: 2019-02-13 19:41:10 Asset Size Chunks Chunk Names index.html 433 bytes [emitted] main.3bb79f4b9e2925734f50.js 1.64 MiB main [emitted] main Entrypoint main = main.3bb79f4b9e2925734f50.js [0] multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx 40 bytes {main} [built] ... ℹ 「wdm」: Compiled successfully. </code></pre> <p>It says that there aren't any errors. But there are TS errors in the code.</p> <p>If I change babel-loader to ts-loader, I will have:</p> <pre><code>ℹ 「wds」: Project is running at http://localhost:8080/ ℹ 「wds」: webpack output is served from / ℹ 「wds」: Content not from webpack is served from /Users/me/projects/react/production ✖ 「wdm」: Hash: 90ec6ae13f842d672d2d Version: webpack 4.29.3 Time: 1941ms Built at: 2019-02-13 19:42:35 Asset Size Chunks Chunk Names index.html 433 bytes [emitted] main.90f2073400581ecd9e5b.js 1.59 MiB main [emitted] main Entrypoint main = main.90f2073400581ecd9e5b.js ... ERROR in /Users/me/projects/react/src/actions/index.ts ./src/actions/index.ts [tsl] ERROR in /Users/me/projects/react/src/actions/index.ts(3,28) TS7006: Parameter 'type' implicitly has an 'any' type. ERROR in /Users/me/projects/react/src/actions/index.ts ./src/actions/index.ts [tsl] ERROR in /Users/me/projects/react/src/actions/index.ts(3,34) TS7019: Rest parameter 'argNames' implicitly has an 'any[]' type. ... ℹ 「wdm」: Failed to compile. </code></pre> <p>So, ts-loader shows the errors.</p> <p>How can I enable errors throwing for @babel/typescript?</p>
0debug
CSS 100vh is too tall on mobile due to browser UI : <p>What is the best way to solve this issue. Obviously all browsers on mobile have got a UI (address bar etc) at the top. This adds additional height to the viewport, so my website which is using 100vh is missing a section. </p> <p>I'd assume different browsers have different sized viewports due to this, I could simply do something like <code>height: calc(100vh - 50px)</code> or what ever the height is, but it won't match up on all mobile browsers right? </p>
0debug
extracting data with php : Helo friends, my code: <form> <input type="text" placeholder="name"> <input type="text" placeholder="email"> <input type="password" placeholder="pw"> <button type="button" id="insert">Insert</button> </form> my JS file: $('#CadAdmin').click(function(){ $('input').each(function(){ $.post('/require/jp/insert.php',{ dataUser:$(this).val() },function(res){ alert(res); }) }) }); my insert.php file: extract($_POST); print dataUser; here, its show all data, ok but, I want to get separete data, for ex: // print dataUser print $name.' '.$email.' '.$pw;
0debug
How can we search an element from the form element using css? : To make a search tab I have executed the following: `<form> <input type="text" name="search" placeholder="Search.."> </form> ` However if I want to search another element from the same html page like say a paragraph named "123" using this search tab how can I proceed?
0debug
static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index) { OutputStream *ost; AVStream *st = avformat_new_stream(oc, NULL); int idx = oc->nb_streams - 1, ret = 0; char *bsf = NULL, *next, *codec_tag = NULL; AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL; double qscale = -1; int i; if (!st) { av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n"); exit_program(1); } if (oc->nb_streams - 1 < o->nb_streamid_map) st->id = o->streamid_map[oc->nb_streams - 1]; GROW_ARRAY(output_streams, nb_output_streams); if (!(ost = av_mallocz(sizeof(*ost)))) exit_program(1); output_streams[nb_output_streams - 1] = ost; ost->file_index = nb_output_files - 1; ost->index = idx; ost->st = st; st->codecpar->codec_type = type; ret = choose_encoder(o, oc, ost); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Error selecting an encoder for stream " "%d:%d\n", ost->file_index, ost->index); exit_program(1); } ost->enc_ctx = avcodec_alloc_context3(ost->enc); if (!ost->enc_ctx) { av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n"); exit_program(1); } ost->enc_ctx->codec_type = type; ost->ref_par = avcodec_parameters_alloc(); if (!ost->ref_par) { av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding parameters.\n"); exit_program(1); } if (ost->enc) { AVIOContext *s = NULL; char *buf = NULL, *arg = NULL, *preset = NULL; ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc); MATCH_PER_STREAM_OPT(presets, str, preset, oc, st); if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) { do { buf = get_line(s); if (!buf[0] || buf[0] == '#') { av_free(buf); continue; } if (!(arg = strchr(buf, '='))) { av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n"); exit_program(1); } *arg++ = 0; av_dict_set(&ost->encoder_opts, buf, arg, AV_DICT_DONT_OVERWRITE); av_free(buf); } while (!s->eof_reached); avio_closep(&s); } if (ret) { av_log(NULL, AV_LOG_FATAL, "Preset %s specified for stream %d:%d, but could not be opened.\n", preset, ost->file_index, ost->index); exit_program(1); } } else { ost->encoder_opts = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, NULL); } ost->max_frames = INT64_MAX; MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st); for (i = 0; i<o->nb_max_frames; i++) { char *p = o->max_frames[i].specifier; if (!*p && type != AVMEDIA_TYPE_VIDEO) { av_log(NULL, AV_LOG_WARNING, "Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n"); break; } } ost->copy_prior_start = -1; MATCH_PER_STREAM_OPT(copy_prior_start, i, ost->copy_prior_start, oc ,st); MATCH_PER_STREAM_OPT(bitstream_filters, str, bsf, oc, st); while (bsf) { char *arg = NULL; if (next = strchr(bsf, ',')) *next++ = 0; if (arg = strchr(bsf, '=')) *arg++ = 0; if (!(bsfc = av_bitstream_filter_init(bsf))) { av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf); exit_program(1); } if (bsfc_prev) bsfc_prev->next = bsfc; else ost->bitstream_filters = bsfc; if (arg) if (!(bsfc->args = av_strdup(arg))) { av_log(NULL, AV_LOG_FATAL, "Bitstream filter memory allocation failed\n"); exit_program(1); } bsfc_prev = bsfc; bsf = next; } MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st); if (codec_tag) { uint32_t tag = strtol(codec_tag, &next, 0); if (*next) tag = AV_RL32(codec_tag); ost->st->codecpar->codec_tag = ost->enc_ctx->codec_tag = tag; } MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st); if (qscale >= 0) { ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE; ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; } MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st); ost->disposition = av_strdup(ost->disposition); if (oc->oformat->flags & AVFMT_GLOBALHEADER) ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0); av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0); if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24) av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0); av_dict_copy(&ost->resample_opts, o->g->resample_opts, 0); ost->source_index = source_index; if (source_index >= 0) { ost->sync_ist = input_streams[source_index]; input_streams[source_index]->discard = 0; input_streams[source_index]->st->discard = input_streams[source_index]->user_set_discard; } ost->last_mux_dts = AV_NOPTS_VALUE; return ost; }
1threat
sharedpreferences stringset value how to remove in android studio.? : i want to be able to do this to the code,I am new to programing please help.i have uncheck the checkbox(per item) to remove it .i am using to sharedpreferences with HashSet concept one page to another page pass to arraylist value,what i do what is my mistake some one help me. my code is: adapterpage.java public static final String MY_PREFS_NAME = ""; @Override public void onClick(View view) { boolean isChecked = mainHolder.chekenitem.isChecked(); // arr=getResources().getStringArray( mainHolder.txtenimgid.getText().toString()); // boolean isChecked = mainHolder.chekenitem.isChecked(); int i; String itemId1 = mainHolder.txtenimgid.getText().toString(); SharedPreferences prefs=view.getContext().getSharedPreferences(MY_PREFS_NAME,Context.MODE_PRIVATE); SharedPreferences.Editor edit=prefs.edit(); Set<String> set = new HashSet<String>(); try { if (isChecked) { addmembers.add(itemId1); for (j = 0; j < addmembers.size(); j++) { set.addAll(addmembers); edit.putStringSet("yourKey", set); edit.commit(); Toast.makeText(view.getContext(), "Clicked on Checkbox addmembers[pos] : " + addmembers.get(j) + " Item Id is " + itemId1 , Toast.LENGTH_LONG).show(); } // editor.putString("key_name",itemId ); // editor.apply(); // } } else { for(int k=0;k<=addmembers.size();k++){ if(addmembers.get(k).equals(itemId1)){ // set.remove(addmembers); addmembers.remove(k); edit.remove(addmembers.get(k)); edit.commit(); break; } }
0debug
static BlockDriverAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, unsigned long int req, void *buf, BlockDriverCompletionFunc *cb, void *opaque) { IscsiLun *iscsilun = bs->opaque; struct iscsi_context *iscsi = iscsilun->iscsi; struct iscsi_data data; IscsiAIOCB *acb; assert(req == SG_IO); acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque); acb->iscsilun = iscsilun; acb->canceled = 0; acb->bh = NULL; acb->status = -EINPROGRESS; acb->buf = NULL; acb->ioh = buf; acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s", iscsi_get_error(iscsi)); qemu_aio_release(acb); return NULL; } memset(acb->task, 0, sizeof(struct scsi_task)); switch (acb->ioh->dxfer_direction) { case SG_DXFER_TO_DEV: acb->task->xfer_dir = SCSI_XFER_WRITE; break; case SG_DXFER_FROM_DEV: acb->task->xfer_dir = SCSI_XFER_READ; break; default: acb->task->xfer_dir = SCSI_XFER_NONE; break; } acb->task->cdb_size = acb->ioh->cmd_len; memcpy(&acb->task->cdb[0], acb->ioh->cmdp, acb->ioh->cmd_len); acb->task->expxferlen = acb->ioh->dxfer_len; data.size = 0; if (acb->task->xfer_dir == SCSI_XFER_WRITE) { if (acb->ioh->iovec_count == 0) { data.data = acb->ioh->dxferp; data.size = acb->ioh->dxfer_len; } else { #if defined(LIBISCSI_FEATURE_IOVECTOR) scsi_task_set_iov_out(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); #else struct iovec *iov = (struct iovec *)acb->ioh->dxferp; acb->buf = g_malloc(acb->ioh->dxfer_len); data.data = acb->buf; data.size = iov_to_buf(iov, acb->ioh->iovec_count, 0, acb->buf, acb->ioh->dxfer_len); #endif } } if (iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task, iscsi_aio_ioctl_cb, (data.size > 0) ? &data : NULL, acb) != 0) { scsi_free_scsi_task(acb->task); qemu_aio_release(acb); return NULL; } if (acb->task->xfer_dir == SCSI_XFER_READ) { if (acb->ioh->iovec_count == 0) { scsi_task_add_data_in_buffer(acb->task, acb->ioh->dxfer_len, acb->ioh->dxferp); } else { #if defined(LIBISCSI_FEATURE_IOVECTOR) scsi_task_set_iov_in(acb->task, (struct scsi_iovec *) acb->ioh->dxferp, acb->ioh->iovec_count); #else int i; for (i = 0; i < acb->ioh->iovec_count; i++) { struct iovec *iov = (struct iovec *)acb->ioh->dxferp; scsi_task_add_data_in_buffer(acb->task, iov[i].iov_len, iov[i].iov_base); } #endif } } iscsi_set_events(iscsilun); return &acb->common; }
1threat
static inline void gen_op_addl_A0_seg(DisasContext *s, int reg) { tcg_gen_ld_tl(cpu_tmp0, cpu_env, offsetof(CPUX86State, segs[reg].base)); if (CODE64(s)) { tcg_gen_ext32u_tl(cpu_A0, cpu_A0); tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_tmp0); } else { tcg_gen_add_tl(cpu_A0, cpu_A0, cpu_tmp0); tcg_gen_ext32u_tl(cpu_A0, cpu_A0); } }
1threat
gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb, int search_pc) { DisasContext ctx; target_ulong pc_start; uint16_t *gen_opc_end; CPUBreakpoint *bp; int j, lj = -1; int num_insns; int max_insns; if (search_pc && loglevel) fprintf (logfile, "search pc %d\n", search_pc); pc_start = tb->pc; gen_opc_end = gen_opc_buf + OPC_MAX_SIZE - 16; ctx.pc = pc_start; ctx.saved_pc = -1; ctx.tb = tb; ctx.bstate = BS_NONE; ctx.hflags = (uint32_t)tb->flags; restore_cpu_state(env, &ctx); if (env->user_mode_only) ctx.mem_idx = MIPS_HFLAG_UM; else ctx.mem_idx = ctx.hflags & MIPS_HFLAG_KSU; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) max_insns = CF_COUNT_MASK; #ifdef DEBUG_DISAS if (loglevel & CPU_LOG_TB_CPU) { fprintf(logfile, "------------------------------------------------\n"); cpu_dump_state(env, logfile, fprintf, 0); } #endif #ifdef MIPS_DEBUG_DISAS if (loglevel & CPU_LOG_TB_IN_ASM) fprintf(logfile, "\ntb %p idx %d hflags %04x\n", tb, ctx.mem_idx, ctx.hflags); #endif gen_icount_start(); while (ctx.bstate == BS_NONE) { if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { TAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == ctx.pc) { save_cpu_state(&ctx, 1); ctx.bstate = BS_BRANCH; gen_helper_0i(raise_exception, EXCP_DEBUG); ctx.pc += 4; goto done_generating; } } } if (search_pc) { j = gen_opc_ptr - gen_opc_buf; if (lj < j) { lj++; while (lj < j) gen_opc_instr_start[lj++] = 0; } gen_opc_pc[lj] = ctx.pc; gen_opc_hflags[lj] = ctx.hflags & MIPS_HFLAG_BMASK; gen_opc_instr_start[lj] = 1; gen_opc_icount[lj] = num_insns; } if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) gen_io_start(); ctx.opcode = ldl_code(ctx.pc); decode_opc(env, &ctx); ctx.pc += 4; num_insns++; if (env->singlestep_enabled) break; if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) break; if (gen_opc_ptr >= gen_opc_end) break; if (num_insns >= max_insns) break; #if defined (MIPS_SINGLE_STEP) break; #endif } if (tb->cflags & CF_LAST_IO) gen_io_end(); if (env->singlestep_enabled) { save_cpu_state(&ctx, ctx.bstate == BS_NONE); gen_helper_0i(raise_exception, EXCP_DEBUG); } else { switch (ctx.bstate) { case BS_STOP: gen_helper_interrupt_restart(); gen_goto_tb(&ctx, 0, ctx.pc); break; case BS_NONE: save_cpu_state(&ctx, 0); gen_goto_tb(&ctx, 0, ctx.pc); break; case BS_EXCP: gen_helper_interrupt_restart(); tcg_gen_exit_tb(0); break; case BS_BRANCH: default: break; } } done_generating: gen_icount_end(tb, num_insns); *gen_opc_ptr = INDEX_op_end; if (search_pc) { j = gen_opc_ptr - gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; } else { tb->size = ctx.pc - pc_start; tb->icount = num_insns; } #ifdef DEBUG_DISAS #if defined MIPS_DEBUG_DISAS if (loglevel & CPU_LOG_TB_IN_ASM) fprintf(logfile, "\n"); #endif if (loglevel & CPU_LOG_TB_IN_ASM) { fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start)); target_disas(logfile, pc_start, ctx.pc - pc_start, 0); fprintf(logfile, "\n"); } if (loglevel & CPU_LOG_TB_CPU) { fprintf(logfile, "---------------- %d %08x\n", ctx.bstate, ctx.hflags); } #endif }
1threat
Laravel shared cookie detection issue in domain and subdomain : <p>I am working on Laravel 5.4.30.</p> <p>Imagine that we have a domain <code>example.com</code> and a subdomain of <code>dev.example.com</code>. The main domain is for master branch and the dev subdomain is for develop branch. We have cookie notice system that will be hidden after clicking on <code>Hide Cookie Notice</code> button. This works by setting a cookie forever. We have set the <code>SESSION_DOMAIN</code> configs to each domain for each environment.</p> <p>For main domain:</p> <pre><code>SESSION_DOMAIN=example.com </code></pre> <p>For dev subdomain:</p> <pre><code>SESSION_DOMAIN=dev.example.com </code></pre> <p>Now the issue comes from here. If we go to the <code>example.com</code> and click on hiding the cookie notice, a cookie will be set forever for main domain. After that we go to the <code>dev.example.com</code> and do the same. So a cookie will be set for subdomain as well. But this cookie has been set after previous one. (The order is important) Now if we refresh the subdomain, we will see that notice again! (not hidden) The browser has read the main cookie because of <code>.example.com</code> set in <code>domain</code> parameter of cookie in the browser, so every subdomain will be affected. But the view still shows the notice because it cannot read any cookie for hiding.</p> <p>Anyway I don't want to share that cookie across all subdomains. How can I achieve that? I think I should add a prefix for cookie name. But I don't know how to do it, that laravel automatically adds prefix to cookie name.</p> <p>Any solutions?</p>
0debug
How to find out the magic number for the .pyc header in Python 3 : <p>Python bytecode (.pyc) files have a header that starts with a magic number that changes between Python versions. How can I (programmatically) find out that number for the current Python version in order to generate a valid header? I'm currently hard-coding the one for Python 3.7.1, but that means I now depend on a specific Python version.</p> <p><a href="https://stackoverflow.com/a/8628185/149392">This answer</a> does exactly what I want using <code>py_compile.MAGIC</code>, but that does not seem to exist anymore in Python 3. How can I do the equivalent in Python 3?</p> <p>Here's an example of what I'm trying to do:</p> <pre><code>import dis import marshal PYC_HEADER = b'\x42\x0d\x0d\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' def f(): print('Hello World') with open('test.pyc', 'wb') as pyc: pyc.write(PYC_HEADER) marshal.dump(dis.Bytecode(f).codeobj, pyc) </code></pre> <p>This should create a file <code>test.pyc</code>, which can then be run, using the same Python interpreter as the script, and should print "Hello World!". And it does, but only when using Python 3.7. I'm looking for a way that generates the header for whichever version of Python 3 is used to run the script, rather than hard-coding 3.7.</p> <p>For context:</p> <p>I'm compiling a simple programming language to different bytecode formats (LLVM, Java bytecode, Web Assembly and now Python bytecode) as part of a planned tutorial series on compiler construction.</p> <p>I can generate the Python bytecode using <a href="https://github.com/zachariahreed/byteasm" rel="noreferrer">the byteasm library</a>, which gives me a function as a result. But in order to write the contents to a <code>.pyc</code> file, I need a valid header. By hard-coding the header, the code will only work if the people following the tutorial are running the same version of Python 3 as I am (3.7) or they'd have to manually find out the magic number for their version.</p>
0debug
Android Library Module vs Feature Module : <p>The latest update of Android Studio 3.0 allows creation of several module types. One of the new types is 'Feature Module' but I can't find details about it</p> <p>What is the difference between the existing Android Library Module and the Feature Module and why should I use the latter?</p> <p>The only difference I can see is that a Feature module defines an Application in the manifest. Can/should these Features be used as standalone apps? In what way do they differ from the actual Application module in that case?</p>
0debug
Android studio methods separator : <p>How to add line separator afer every method.</p> <p>like this:</p> <p><a href="https://i.stack.imgur.com/gp0Kr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gp0Kr.png" alt="Line separator android studio"></a></p>
0debug
Does my Java code for the Josephus problem work? : Here's some Java code I made for homework on the Josephus problem. I believe it doesn't work, but I want to make sure. If it's broken, I want to see if it can be fixed. If it can't be fixed because it is flawed by design, then please tell me so. Thank you. ``` public Int Josephus problem(int num4){ int reducer = 1; int c = 1; while (num4 > reducer+1){ num4 -= reducer; reducer += c++; } num4 = 1 + (num4-1)*2; return num4; } ``` I want to use this because it is for homework and so original work is worth more than better code. That's why I don't want to use the Bit shifting solution. I didn't think of it myself.
0debug
static abi_ulong copy_elf_strings(int argc,char ** argv, void **page, abi_ulong p) { char *tmp, *tmp1, *pag = NULL; int len, offset = 0; if (!p) { return 0; } while (argc-- > 0) { tmp = argv[argc]; if (!tmp) { fprintf(stderr, "VFS: argc is wrong"); exit(-1); } tmp1 = tmp; while (*tmp++); len = tmp - tmp1; if (p < len) { return 0; } while (len) { --p; --tmp; --len; if (--offset < 0) { offset = p % TARGET_PAGE_SIZE; pag = (char *)page[p/TARGET_PAGE_SIZE]; if (!pag) { pag = (char *)malloc(TARGET_PAGE_SIZE); memset(pag, 0, TARGET_PAGE_SIZE); page[p/TARGET_PAGE_SIZE] = pag; if (!pag) return 0; } } if (len == 0 || offset == 0) { *(pag + offset) = *tmp; } else { int bytes_to_copy = (len > offset) ? offset : len; tmp -= bytes_to_copy; p -= bytes_to_copy; offset -= bytes_to_copy; len -= bytes_to_copy; memcpy_fromfs(pag + offset, tmp, bytes_to_copy + 1); } } } return p; }
1threat
How to detect merged cells in excel with openpyxl : <p>I'm trying to read data from excel sheet that contains merged cells. When reading merged cells with openpyxl the first merged cell contain the value and the rest of the cells are empty.</p> <p>I would like to know about each cell if it merge and how many cells are merged but I couldn't find any function that do so. The sheet have empty others cells, so I can't use that.</p> <p>Will appreciate any help, I prefer openpyxl module but other modules can work,too.</p> <p>Thank you all! </p>
0debug
Form submitting but mysql query not properly functioning : <p>The following code gives a signup form that i created but unfortunately though it works the mysql query fails and returns the error message unsuccessfull signup! how can i correct this?</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;!-- Theme Made By www.w3schools.com - No Copyright --&gt; &lt;title&gt;Arsiri Textile &lt;/title&gt; &lt;meta charset="utf-8"&gt; &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;!-- Theme Made By www.w3schools.com - No Copyright --&gt; &lt;title&gt;Arsiri Textile &lt;/title&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"&gt; &lt;link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css"&gt; &lt;link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css"&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" type="text/css" href="css/basic.css"&gt; &lt;style&gt; &lt;/style&gt; &lt;/head&gt; &lt;body id="myPage" data-spy="scroll" data-target=".navbar" data-offset="60"&gt; &lt;div class="header" style="height:60px;background:#330d00;width:1350px"&gt; &lt;a class="navbar-brand" href="#myPage"&gt;ARSIRI TEXTILE |&lt;/a&gt; &lt;ul class="nav navbar-nav navbar-left"&gt; &lt;/ul&gt; &lt;ul class="nav navbar-nav navbar-right"&gt; &lt;li&gt;&lt;a href="#"&gt;About Us&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Contact Us&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Login&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt; Signup&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="image" style="height:530px; width:1350px" &gt; &lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt; &lt;link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="panel panel-default"&gt; &lt;div class="panel-heading" style="background:#330d00;"&gt; &lt;h3 class="panel-title"&gt;Customer Registration&lt;/h3&gt;&lt;br&gt; &lt;/div&gt; &lt;div class="panel-body" &gt; &lt;form class="form-horizontal" role="form" action="signupaction.php" method="post" &gt; &lt;div class="form-group"&gt; &lt;label for="name" class="col-sm-2 control-label"&gt;First Name&lt;/label&gt; &lt;div class="col-sm-10" style="width:300px"&gt; &lt;input type="text" class="form-control" id="name" name="firstname" required&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="name" class="col-sm-2 control-label"&gt;Last Name&lt;/label&gt; &lt;div class="col-sm-10" style="width:300px"&gt; &lt;input type="text" class="form-control" id="name" name="lastname" required&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="Address" class="col-sm-2 control-label"&gt;Address&lt;/label&gt; &lt;div class="col-sm-10" style="width:300px"&gt; &lt;textarea class="form-control" class="form-control" name="address"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="name" class="col-sm-2 control-label"&gt;Contact No.&lt;/label&gt; &lt;div class="col-sm-10" style="width:300px"&gt; &lt;input type="text" maxlength="10" class="form-control" id="name" name="contactno" required&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="name" class="col-sm-2 control-label"&gt;E-Mail&lt;/label&gt; &lt;div class="col-sm-10" style="width:300px"&gt; &lt;input type="email" class="form-control" id="name" name="emailaddress" required&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="password" class="col-sm-2 control-label"&gt;Password&lt;/label&gt; &lt;div class="col-sm-10" style="width:300px"&gt; &lt;input type="password" class="form-control" id="pass" name="password" required&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="password" class="col-sm-2 control-label"&gt;Confirm password &lt;/label&gt; &lt;div class="col-sm-10" style="width:300px"&gt; &lt;input type="password" class="form-control" id="confirmpass" name="cpassword" required&gt;&lt;br&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="panel-footer" style="overflow:hidden;text-align:left;"&gt; &lt;div class="col-sm-offset-2 col-sm-10"&gt; &lt;input class="btn btn-success btn-sm" type=submit name=submit value=Submit &gt; &lt;input class="btn btn-success btn-sm" type=reset name=reset value=Cancel&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/div&gt; &lt;div class="footer " style="background:#330d00; height:60px ;width:1350px "&gt; &lt;p align="center" &gt; Asiri all rights reserved&lt;/p&gt; &lt;/div&gt; </code></pre> <p>The relevant php script(ignupaction.php) for the above html form is as follows</p> <pre><code>&lt;?php //importing db.php in the includes folder require("includes/db.php"); $fname=$_POST["firstname"]; $lname=$_POST["lastname"]; $address=$_POST["address"]; $contact=$_POST["contactno"]; $email=$_POST["emailaddress"]; $password=$_POST["password"]; $cpassword=$_POST["cpassword"]; $sql="INSERT INTO `signup` VALUES ('$fname','$lname','$address','$contact','$email','$password',$cpassword')"; $result=mysqli_query($db,$sql); if(!$result){ echo "Unsuccessful signup"; } else{ echo "Successful signup"; } ?&gt; </code></pre> <p>when the form is submitted it returns unsuccessful signup! how can i correect this?</p>
0debug
In a Oracle Schema I want to know how many Tables, Procedures, Functions are there? How to find? : <p>In a Oracle Schema I want to know how many Tables, Procedures, Functions are there? How to find?</p>
0debug
Angular2 material dialog self close : <p>I used angular2 material <code>MdDialog</code> to show a form.</p> <p>When user submits the form, a request is sent to the backend and if the request is successful, I need to close the dialog. If backend request failed, I need to keep the dialog open.</p> <p>I can close the dialog by using a button like below.</p> <pre><code>&lt;button md-raised-button md-dialog-close&gt;Cancel&lt;/button&gt; </code></pre> <p>But, in this case, I only need to close the dialog only if the backend request is successful, so I need a way to programmatically close the dialog.</p> <p>The component which is shown inside the dialog doesn't have the dialog ref, and I don't know any other way to self close the dialog from the component.</p> <p>Is there any way I an close the dialog from within the component inside the dialog?</p>
0debug
Access Perl Environment (Shell) Variables In Windows - $ENV Not Working : ## THE ISSUE ## I found out how to use windows environment variables (e.g., `%AppData%`, `%HomePath%`, `%SystemRoot%`, etc.) in this SO post: http://stackoverflow.com/questions/36312891/getting-the-path-of-appdata-in-perl-script Here is the code snippet that was chosen as a working, correct answer: #!/usr/bin/perl use warnings; use strict; my $localConfPath = $ENV{localappdata}; my $appdata = $ENV{appdata}; print $localConfPath; #will print the app path - C:\users\xxx\AppData\local print $appdata; #prints - C:\users\xxx\AppData\Roaming However, this is not working on my machine in my code for some reason. My scripts work without the shebang (#!) line so I tried the script both with and without it, to no avail. ## MY SETUP ## I'm using the Perl that comes with GitBash, if that makes a difference. ## WHAT I'VE TRIED ALREADY ## I tried a simple perl command line execution: perl -e 'print %ENV{AppData}'; Didn't work. I also tried the following alternatives: perl -e 'print %ENV{APPDATA}'; perl -e 'print %ENV{appdata}'; No go. Here's the error I get (the same for all 3 versions): > syntax error at -e line 1, near "%ENV{AppData" > Execution of -e aborted due to compilation errors. I even tried to use the code from the SO post I mentioned in it's own file. That code doesn't work either. With the code from the post I get this error: > $ perl > /c/Users/User1/Desktop/ehCode_testingWindowsEnvironmentVariables_01.pl > Use of uninitialized value in print at > /c/Users/User1/Desktop/ehCode_testingWindowsEnvironmentVariables_01.pl > line 7. Use of uninitialized value in print at > /c/Users/User1/Desktop/ehCode_testingWindowsEnvironmentVariables_01.pl > line 8. The lines in question then are these: <!-- language: lang-perl --> print $localConfPath; #will print the app path - C:\users\xxx\AppData\local print $appdata; #prints - C:\users\xxx\AppData\Roaming I don't see why they shouldn't work. I've checked Perl Monks, Perl Maven, Stack Overflow, and other popular Perl resources, to no avail. Even Active State did not have the answer. Any help is appreciated.
0debug
How to add days to a date in Angular2? : <p>I simply want to create a date that is 3 days from now for use in a typescript angular component.</p> <p>I have looked at <a href="https://github.com/urish/angular2-moment" rel="noreferrer">Angular2 moment</a> but this seems only to relate to pipes. Although I did see <a href="https://stackoverflow.com/questions/35159079/is-it-possible-to-use-pipe-in-the-code-in-angular-2">this article</a> about using pipes in code, looks a bit hacky...</p> <p>Maybe I'm missing something as this should be really simple?!</p> <p>Thanks</p>
0debug
static void omap_ulpd_pm_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; int64_t now, ticks; int div, mult; static const int bypass_div[4] = { 1, 2, 4, 4 }; uint16_t diff; if (size != 2) { return omap_badwidth_write16(opaque, addr, value); } switch (addr) { case 0x00: case 0x04: case 0x08: case 0x0c: case 0x14: case 0x40: OMAP_RO_REG(addr); break; case 0x10: if ((s->ulpd_pm_regs[addr >> 2] ^ value) & 1) { now = qemu_get_clock_ns(vm_clock); if (value & 1) s->ulpd_gauge_start = now; else { now -= s->ulpd_gauge_start; ticks = muldiv64(now, 32768, get_ticks_per_sec()); s->ulpd_pm_regs[0x00 >> 2] = (ticks >> 0) & 0xffff; s->ulpd_pm_regs[0x04 >> 2] = (ticks >> 16) & 0xffff; if (ticks >> 32) s->ulpd_pm_regs[0x14 >> 2] |= 1 << 2; ticks = muldiv64(now, 12000000, get_ticks_per_sec()); s->ulpd_pm_regs[0x08 >> 2] = (ticks >> 0) & 0xffff; s->ulpd_pm_regs[0x0c >> 2] = (ticks >> 16) & 0xffff; if (ticks >> 32) s->ulpd_pm_regs[0x14 >> 2] |= 1 << 1; s->ulpd_pm_regs[0x14 >> 2] |= 1 << 0; qemu_irq_raise(qdev_get_gpio_in(s->ih[1], OMAP_INT_GAUGE_32K)); } } s->ulpd_pm_regs[addr >> 2] = value; break; case 0x18: case 0x1c: case 0x20: case 0x28: case 0x2c: OMAP_BAD_REG(addr); case 0x24: case 0x38: case 0x48: case 0x50: s->ulpd_pm_regs[addr >> 2] = value; break; case 0x30: diff = s->ulpd_pm_regs[addr >> 2] ^ value; s->ulpd_pm_regs[addr >> 2] = value & 0x3f; omap_ulpd_clk_update(s, diff, value); break; case 0x34: diff = s->ulpd_pm_regs[addr >> 2] ^ value; s->ulpd_pm_regs[addr >> 2] = value & 0x1f; omap_ulpd_req_update(s, diff, value); break; case 0x3c: diff = s->ulpd_pm_regs[addr >> 2] & value; s->ulpd_pm_regs[addr >> 2] = value & 0x2fff; if (diff & (0x3ff << 2)) { if (value & (1 << 4)) { div = ((value >> 5) & 3) + 1; mult = MIN((value >> 7) & 0x1f, 1); } else { div = bypass_div[((value >> 2) & 3)]; mult = 1; } omap_clk_setrate(omap_findclk(s, "dpll4"), div, mult); } s->ulpd_pm_regs[addr >> 2] = (s->ulpd_pm_regs[addr >> 2] & 0xfffe) | ((s->ulpd_pm_regs[addr >> 2] >> 4) & 1); s->ulpd_pm_regs[addr >> 2] |= 2; break; case 0x4c: diff = s->ulpd_pm_regs[addr >> 2] & value; s->ulpd_pm_regs[addr >> 2] = value & 0xf; if (diff & (1 << 0)) omap_clk_reparent(omap_findclk(s, "ck_48m"), omap_findclk(s, (value & (1 << 0)) ? "apll" : "dpll4")); break; default: OMAP_BAD_REG(addr); } }
1threat
How to create multiple language site when load data from database? : <p>Normal, I usually define like this to create multiple languages for my site.</p> <p>Like this:</p> <pre><code>en-en.php define("HOMEPAGE", "Home Page"); </code></pre> <hr> <pre><code>vi-vi.php define("HOMEPAGE", "Trang chủ"); </code></pre> <p>Current, I load this menu from my database.</p> <p>Has anything to create multiple language sites when load data from the database?</p> <p>Thank you very much.</p>
0debug
How to calculate Min Max of Map<Strib,float> : [enter image description here][1] How to find Min max of Keys of a Map<String,float> [1]: https://i.stack.imgur.com/mbQ09.png
0debug
How to release a Scala library to Maven Central using sbt? : <p>I have an open source Scala project using SBT and I would like to release my library to Maven. How do I do it?</p>
0debug
static int fmod_init_out (HWVoiceOut *hw, audsettings_t *as) { int bits16, mode, channel; FMODVoiceOut *fmd = (FMODVoiceOut *) hw; audsettings_t obt_as = *as; mode = aud_to_fmodfmt (as->fmt, as->nchannels == 2 ? 1 : 0); fmd->fmod_sample = FSOUND_Sample_Alloc ( FSOUND_FREE, conf.nb_samples, mode, as->freq, 255, 128, 255 ); if (!fmd->fmod_sample) { fmod_logerr2 ("DAC", "Failed to allocate FMOD sample\n"); return -1; } channel = FSOUND_PlaySoundEx (FSOUND_FREE, fmd->fmod_sample, 0, 1); if (channel < 0) { fmod_logerr2 ("DAC", "Failed to start playing sound\n"); FSOUND_Sample_Free (fmd->fmod_sample); return -1; } fmd->channel = channel; obt_as.endianness = 0; audio_pcm_init_info (&hw->info, &obt_as); bits16 = (mode & FSOUND_16BITS) != 0; hw->samples = conf.nb_samples; return 0; }
1threat
static void *qemu_tcg_cpu_thread_fn(void *arg) { CPUState *cpu = arg; rcu_register_thread(); qemu_mutex_lock_iothread(); qemu_thread_get_self(cpu->thread); CPU_FOREACH(cpu) { cpu->thread_id = qemu_get_thread_id(); cpu->created = true; cpu->can_do_io = 1; } qemu_cond_signal(&qemu_cpu_cond); while (first_cpu->stopped) { qemu_cond_wait(first_cpu->halt_cond, &qemu_global_mutex); CPU_FOREACH(cpu) { qemu_wait_io_event_common(cpu); } } start_tcg_kick_timer(); cpu = first_cpu; cpu->exit_request = 1; while (1) { qemu_account_warp_timer(); if (!cpu) { cpu = first_cpu; } while (cpu && !cpu->queued_work_first && !cpu->exit_request) { atomic_mb_set(&tcg_current_rr_cpu, cpu); qemu_clock_enable(QEMU_CLOCK_VIRTUAL, (cpu->singlestep_enabled & SSTEP_NOTIMER) == 0); if (cpu_can_run(cpu)) { int r; r = tcg_cpu_exec(cpu); if (r == EXCP_DEBUG) { cpu_handle_guest_debug(cpu); break; } } else if (cpu->stop || cpu->stopped) { if (cpu->unplug) { cpu = CPU_NEXT(cpu); } break; } cpu = CPU_NEXT(cpu); } atomic_set(&tcg_current_rr_cpu, NULL); if (cpu && cpu->exit_request) { atomic_mb_set(&cpu->exit_request, 0); } handle_icount_deadline(); qemu_tcg_wait_io_event(QTAILQ_FIRST(&cpus)); deal_with_unplugged_cpus(); } return NULL; }
1threat
I can't parce JSON by JQuery : I need to send some data to JQuery by JSON. There is my code below: PHP: $name = "test"; $answer = array("code" => 1, "name" => $name); echo json_encode($answer); Js: console.log(data); var response = JSON.parse(data); Console says: {"code":1,"name":"test"} VM635:2 Uncaught SyntaxError: Unexpected token  in JSON at position 2 at JSON.parse (<anonymous>) at Object.onAjaxSuccess [as success] (auth.js:32) at u (jquery.js:2) at Object.fireWith [as resolveWith] (jquery.js:2) at k (jquery.js:2) at XMLHttpRequest.<anonymous> (jquery.js:2) Help me :O
0debug
Why I am getting "System.Web.Mvc.SelectListItem" in my DropDownList? : <p>I believe I have bound my data correctly, but I can't seem to get my text property for each SelectListItem to show properly.</p> <p>My model:</p> <pre><code>public class Licenses { public SelectList LicenseNames { get; set; } public string SelectedLicenseName { get; set; } } </code></pre> <p>Controller: </p> <pre><code>[HttpGet] public ActionResult License() { try { DataTable LicsTable = BW.SQLServer.Table("GetLicenses", ConfigurationManager.ConnectionStrings["ProfressionalActivitiesConnection"].ToString()); ProfessionalActivities.Models.Licenses model = new ProfessionalActivities.Models.Licenses(); model.LicenseNames = new SelectList(LicsTable.AsEnumerable().Select(row =&gt; new SelectListItem { Value = row["Description"].ToString(), Text = "test" })); return PartialView("_AddLicense", model); } catch (Exception ex) { var t = ex; return PartialView("_AddLicense"); } } </code></pre> <p>View:</p> <pre><code>@Html.DropDownList("LicenseNames", new SelectList(Model.LicenseNames, "Value", "Text", Model.LicenseNames.SelectedValue), new { htmlAttributes = new { @class = "form-control focusMe" } }) </code></pre>
0debug
import math def area_tetrahedron(side): area = math.sqrt(3)*(side*side) return area
0debug
jQuery id^= not working? : <p>Hi I'm trying to simulate a click on multiple buttons which all start with the same id values. I did not make this site I'm trying to make a script so users don't have to press every button. Selecting the individual id works but when I try to use id^= it does not:</p> <pre><code>$(id='UnsubscribeItemBtn485527146') &lt;a href=​"javascript:​UnsubscribeItem( '485527146', '255710' )​;​" id=​"UnsubscribeItemBtn485527146" class=​"btn_grey_black btn_medium"&gt;​…​&lt;/a&gt; $(id^='UnsubscribeItemBtn') 0 </code></pre> <p>Can anyone shed some light on this? If I'm being really stupid go easy I'm new to this! ​</p>
0debug
vba - section of indices of empty cells in a row : In a *first step*, I am trying to identify the **indices** of the **empty cells** in a **row** in an excel workbook. In a *second step*, I want to use these indices to delete certain **columns** in **another** excel workbook. How can one do so? Here I found some related info http://stackoverflow.com/questions/7876340/deleting-empty-rows-in-excel-using-vba Why I want to do this: I am importing worksheets from closed excel workbooks into an open workbook. When doing so, I only import the data and not the column names (because these are messy and not appropriate for importing later on in R: defined by three rows and some of these cells their rows are merged). The problem is that there are empty columns inserted between parts of the data in the closed excel workbooks. I cannot simply delete the columns with no values afterwards, because it can well be that there are columns with no values but that had a column label in the original workbook.
0debug
static int http_connect(URLContext *h, const char *path, const char *hoststr, const char *auth, int *new_location) { HTTPContext *s = h->priv_data; int post, err, ch; char line[1024], *q; char *auth_b64; int auth_b64_len = strlen(auth)* 4 / 3 + 12; int64_t off = s->off; post = h->flags & URL_WRONLY; auth_b64 = av_malloc(auth_b64_len); av_base64_encode(auth_b64, auth_b64_len, auth, strlen(auth)); snprintf(s->buffer, sizeof(s->buffer), "%s %s HTTP/1.1\r\n" "User-Agent: %s\r\n" "Accept: * s->buf_ptr = s->buffer; s->buf_end = s->buffer; s->line_count = 0; s->off = 0; s->filesize = -1; if (post) { return 0; } q = line; for(;;) { ch = http_getc(s); if (ch < 0) return AVERROR(EIO); if (ch == '\n') { if (q > line && q[-1] == '\r') q--; *q = '\0'; #ifdef DEBUG printf("header='%s'\n", line); #endif err = process_line(h, line, s->line_count, new_location); if (err < 0) return err; if (err == 0) break; s->line_count++; q = line; } else { if ((q - line) < sizeof(line) - 1) *q++ = ch; } } return (off == s->off) ? 0 : -1; }
1threat
Javascript help. stuck : <pre><code>var msg = 'Santi Valle'; for(var x = -2; x &lt; (msg.length - 4); x++) { if (msg.length == 5) { for(var i = 0; i &lt; 3; i++) { console.log(i); } } else { for(var i = msg.length; i &gt; (msg.length - 1); i--) { console.log(i); } } } </code></pre> <p>Not sure what i;m doing incorrectly. i'm supposed to predict the outcome. is it undefined?</p>
0debug
On hover on the parent div, Change the color of all the child div as well as parent background color : <p>I need to change the button color and text color on hover on the parent div.</p> <p>I am getting the output and on hover, I have to change the color.</p> <p><a href="https://i.stack.imgur.com/GUbzh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GUbzh.png" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/dWmlX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dWmlX.png" alt="enter image description here"></a></p> <p>Would you help me out? <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.Set { background-color: #fff; padding: 35px; box-sizing: border-box; min-height: 450px; z-index: 2; position: relative; width: 300px; border: 1px solid #ccc; } .btn { padding: 10px 30px; font-size: 16px; } .btn_bg { background-color: #000; color: #fff; } .Set:hover { background-color: #000; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="Set"&gt; &lt;h2 class="textMe"&gt;adasdsad asdas d&lt;/h2&gt; &lt;div class="bigtextMe"&gt; &lt;p&gt;asdsa asdsd asd asd sd sd sd &lt;/p&gt; &lt;a href="" class="btn btn_bg"&gt;njkndkajnsdkja&lt;/a&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
0debug
static void estimate_timings_from_bit_rate(AVFormatContext *ic) { int64_t filesize, duration; int i; AVStream *st; if (ic->bit_rate <= 0) { int bit_rate = 0; for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; if (st->codec->bit_rate > 0) { if (INT_MAX - st->codec->bit_rate > bit_rate) { bit_rate = 0; break; } bit_rate += st->codec->bit_rate; } } ic->bit_rate = bit_rate; } if (ic->duration == AV_NOPTS_VALUE && ic->bit_rate != 0) { filesize = ic->pb ? avio_size(ic->pb) : 0; if (filesize > 0) { for(i = 0; i < ic->nb_streams; i++) { st = ic->streams[i]; duration= av_rescale(8*filesize, st->time_base.den, ic->bit_rate*(int64_t)st->time_base.num); if (st->duration == AV_NOPTS_VALUE) st->duration = duration; } } } }
1threat
How to write very complex SQL in a clean and maintainable way? : <p>I'm in the database migration project.</p> <p>I have to write very complex SQL in a maintainable way. The previous query is almost spaghetti.</p> <p>I wanna make a view in the database but I have no authority. </p> <p>So what I am thinking about is making a bridged database that is from the query result of the database. </p> <p>After that, I made views in the bridged database. </p> <p>is it inefficient? or is there any nice way to deal with a complex database queries?</p>
0debug
C++ vector implementation? : While watching a tutorial the speaker used *int deca['f' + '9' + 2 ] = {0};* I've never seen this on any other c++ tutorial and they didn't explain what it meant, and when I tried to implement it on my computer an error showed up. As reference they were in a Linux environment.
0debug
HOW TO LIMIT ACCOUNT FOR ONLY 1 WEEK ACCESS : I want to make a subscribtion web simulation for my school task. But I dont know to limit my user account for only 1 week or maybe 1 month. I tried to search the problem in the internet but I didn't find it What I'm expected is to make my users have limited time account for just 1 week, so after 1 week my users would like to pay again for another week.
0debug
how to identify records based on most recent scan : Using SQL 2012 mgnt studio. I need to identify 'JobNumber' if any of the 'item_code_1' was scanned within last 2 hours only. 'item_code_1' contains 'JobNumber' day # and sequence number. table1 JobNumber |Item_code_1 |Scanned| 12345 |12345_01_01 |Y | 12345 |12345_01_02 |Y | 12345 |12345_01_03 |Y | 1234567 |1234567_01_01 |Y | 1234567 |1234567_01_02 |Y | 1234567 |1234567_01_03 |Y | Table2 (CURRENT TIME = 2016-02-08 16:52:32.547) Scanned_date_time |Item_Code_1 | 2016-02-08 16:52:32.547 |12345_01_01 | 2016-02-08 16:52:32.547 |12345_01_02 | 2016-02-08 16:52:32.547 |12345_01_03 | 2016-02-08 **13**:52:32.547 |1234567_01_01| 2016-02-08 **13**:52:32.547 |1234567_01_02| 2016-02-08 **13**:52:32.547 |1234567_01_03| see in this case, JobNumber 123456 item_code_1 were scanned more than 2 hours ago. I only want to see the JobNumber if it's (at least 1)item_code_1 were scanned within last two hours based on Scanned_date_time
0debug
What is the method variable? in C# : <p>I use C#.</p> <p>When I defined <code>Hoge</code> method below,</p> <pre><code>void Hoge(bool isBar){} </code></pre> <p>I get the Hoge method like below</p> <pre><code>var methodName = this.Hoge as Action&lt;bool&gt;).Method.Name; </code></pre> <p>However, I can't understand what does <code>this.Hoge</code> type. Because, it can assign and casting.</p> <p>but, it can't give me method name directly. <code>this.Hoge.Method.Name;</code></p> <p>and, it also error. <code>typeof(this.Hoge)</code></p> <p>what is method variable exactly?</p>
0debug
Using Tesseract for handwriting recognition : <p>I was just wondering how accurate can tesseract be for handwriting recognition if used with capital letters all in their own little boxes in a form.</p> <p>I know you can train it to recognise your own handwriting somewhat but the problem in my case is I need to use it across multiple handwritings. Can anyone point me in the right direction? </p> <p>Thanks a lot. </p>
0debug
Use of studying different algorithm mechanism for sorting when STL does it crisply : <p>I mean, what is the use of studying different sorting algorithms when it can be done with the help of a single line in c++ using STL? Is it just for the sake of knowing (or any other reason)?</p>
0debug
how to autoclick this `button` ? : <button data-ratparam="all" data-ratid="fixed_checkout" data-ratevent="pv,appear" class="cart-button checkout new-cart-button"><span class="normal"></span></button> here is the element I cut from chrome I am new to web dev and I wonder if this is a button at all ? I wanna auto click this button and used event visual but nothing appeard on the web . Dont know what to do . many thanks
0debug
static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) { struct tcphdr *ptcp, *stcp; int res; trace_colo_compare_main("compare tcp"); ptcp = (struct tcphdr *)ppkt->transport_header; stcp = (struct tcphdr *)spkt->transport_header; if (ntohs(ppkt->ip->ip_off) & IP_DF) { spkt->ip->ip_id = ppkt->ip->ip_id; spkt->ip->ip_sum = ppkt->ip->ip_sum; } if (ptcp->th_off > 5) { ptrdiff_t tcp_offset; tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data + (ptcp->th_off * 4) - ppkt->vnet_hdr_len; res = colo_packet_compare_common(ppkt, spkt, tcp_offset); } else if (ptcp->th_sum == stcp->th_sum) { res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN); } else { res = -1; } if (res != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) { char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20]; strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src)); strcpy(pri_ip_dst, inet_ntoa(ppkt->ip->ip_dst)); strcpy(sec_ip_src, inet_ntoa(spkt->ip->ip_src)); strcpy(sec_ip_dst, inet_ntoa(spkt->ip->ip_dst)); trace_colo_compare_ip_info(ppkt->size, pri_ip_src, pri_ip_dst, spkt->size, sec_ip_src, sec_ip_dst); trace_colo_compare_tcp_info("pri tcp packet", ntohl(ptcp->th_seq), ntohl(ptcp->th_ack), res, ptcp->th_flags, ppkt->size); trace_colo_compare_tcp_info("sec tcp packet", ntohl(stcp->th_seq), ntohl(stcp->th_ack), res, stcp->th_flags, spkt->size); qemu_hexdump((char *)ppkt->data, stderr, "colo-compare ppkt", ppkt->size); qemu_hexdump((char *)spkt->data, stderr, "colo-compare spkt", spkt->size); } return res; }
1threat
CSS line inside a container : <p>Imagine having a box</p> <pre><code>a b ---------- | | | | c----------d </code></pre> <p>The box have point a,b,c and d. I need to have a line from point b to point c, and I will have my data lets say <code>100%</code> in point a and point d.</p> <p>is this possible? I tried to look using <code>fr</code> but I still have the problem of drawing a line</p>
0debug