problem
stringlengths
26
131k
labels
class label
2 classes
static void chs_filter_band_data(DCAXllDecoder *s, DCAXllChSet *c, int band) { DCAXllBand *b = &c->bands[band]; int nsamples = s->nframesamples; int i, j, k; for (i = 0; i < c->nchannels; i++) { int32_t *buf = b->msb_sample_buffer[i]; int order = b->adapt_pred_order[i]; if (order > 0) { int coeff[DCA_XLL_ADAPT_PRED_ORDER_MAX]; for (j = 0; j < order; j++) { int rc = b->adapt_refl_coeff[i][j]; for (k = 0; k < (j + 1) / 2; k++) { int tmp1 = coeff[ k ]; int tmp2 = coeff[j - k - 1]; coeff[ k ] = tmp1 + mul16(rc, tmp2); coeff[j - k - 1] = tmp2 + mul16(rc, tmp1); } coeff[j] = rc; } for (j = 0; j < nsamples - order; j++) { int64_t err = 0; for (k = 0; k < order; k++) err += (int64_t)buf[j + k] * coeff[order - k - 1]; buf[j + k] -= (SUINT)clip23(norm16(err)); } } else { for (j = 0; j < b->fixed_pred_order[i]; j++) for (k = 1; k < nsamples; k++) buf[k] += buf[k - 1]; } } if (b->decor_enabled) { int32_t *tmp[DCA_XLL_CHANNELS_MAX]; for (i = 0; i < c->nchannels / 2; i++) { int coeff = b->decor_coeff[i]; if (coeff) { s->dcadsp->decor(b->msb_sample_buffer[i * 2 + 1], b->msb_sample_buffer[i * 2 ], coeff, nsamples); } } for (i = 0; i < c->nchannels; i++) tmp[i] = b->msb_sample_buffer[i]; for (i = 0; i < c->nchannels; i++) b->msb_sample_buffer[b->orig_order[i]] = tmp[i]; } if (c->nfreqbands == 1) for (i = 0; i < c->nchannels; i++) s->output_samples[c->ch_remap[i]] = b->msb_sample_buffer[i]; }
1threat
void tcg_target_qemu_prologue(TCGContext *s) { tcg_out32(s, (COND_AL << 28) | 0x092d4e00); tcg_out_bx(s, COND_AL, TCG_REG_R0); tb_ret_addr = s->code_ptr; tcg_out32(s, (COND_AL << 28) | 0x08bd8e00); }
1threat
CloudFormation doesn't deploy to API gateway stages on update : <p>When I run CloudFormation <code>deploy</code> using a template with API Gateway resources, the first time I run it, it creates and deploys to stages. The subsequent times I run it, it updates the resources but doesn't deploy to stages.</p> <p>Is that behaviour as intended? If yes, how'd I get it to deploy to stages whenever it updates?</p> <p>(Terraform mentions a similar issue: <a href="https://github.com/hashicorp/terraform/issues/6613" rel="noreferrer">https://github.com/hashicorp/terraform/issues/6613</a>)</p>
0debug
How do I consume this windows dll method from golang : I am trying to use the following method which is present in kernel32.dll [MSDN Entry - GetPhysicallyInstalledSystemMemory][1] it requires a single argument of the type [PULONGLONG][2] but I have no idea how to map this into a golang variable. Here is my current attempt which results in "err: The parameter is incorrect". Can anyone explain how to do this? (I would be interested if anyone knows of any good examples/tuts on working with .dll in golang). Thanks in advance package main import ( "fmt" "syscall" ) var memory uintptr func main() { kernel32 := syscall.NewLazyDLL("kernel32.dll") getPhysicallyInstalledSystemMemoryProc := kernel32.NewProc("GetPhysicallyInstalledSystemMemory") ret, _, err := getPhysicallyInstalledSystemMemoryProc.Call(uintptr(memory)) fmt.Printf("GetPhysicallyInstalledSystemMemory, return: %+v\n", ret) fmt.Printf("GetPhysicallyInstalledSystemMemory, memory: %d\n", memory) fmt.Printf("GetPhysicallyInstalledSystemMemory, err: %s\n", err) } [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/cc300158(v=vs.85).aspx [2]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx#PULONGLONG
0debug
SQL PrepareStatement using 'IN' : I would like to know how I can return a result set from a query as a map. This is my query where 'nameCodesString' is a list of strings: try (PreparedStatement stmt = conn .prepareStatement("select n.CODE, l.VALUE" + " from TNAME n join TPROPERTIES l on n.UIDPK = l.OBJECT_UID" + " where n.CODE IN (" + nameCodesString + ")")) { try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { log.info("rs {}",rs); nameCode = rs.getString(1); displayName = rs.getString(2); Person.add(new PersonDTO(nameCode, displayName, "")); } } } The result should be a code and a value. I am not sure how I can do this all in one connection to the database. Thanks
0debug
What is BetterJsPop error on chrome? : <p>I am getting this error on Chrome with my React.js app. But on Mozilla it is working just fine. Does anybody know what it means or what is this error referring to?</p> <pre><code>VM1407:20 Uncaught TypeError: Cannot redefine property: BetterJsPop at Function.defineProperty (&lt;anonymous&gt;) at inject (&lt;anonymous&gt;:20:10) at &lt;anonymous&gt;:510:11 at &lt;anonymous&gt;:511:11 </code></pre>
0debug
static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size) { VP56RangeCoder *c = &s->c; int parse_filter_info = 0; int coeff_offset = 0; int vrt_shift = 0; int sub_version; int rows, cols; int res = 0; int ret; int separated_coeff = buf[0] & 1; s->frames[VP56_FRAME_CURRENT]->key_frame = !(buf[0] & 0x80); ff_vp56_init_dequant(s, (buf[0] >> 1) & 0x3F); if (s->frames[VP56_FRAME_CURRENT]->key_frame) { sub_version = buf[1] >> 3; if (sub_version > 8) return AVERROR_INVALIDDATA; s->filter_header = buf[1] & 0x06; if (buf[1] & 1) { avpriv_report_missing_feature(s->avctx, "Interlacing"); return AVERROR_PATCHWELCOME; } if (separated_coeff || !s->filter_header) { coeff_offset = AV_RB16(buf+2) - 2; buf += 2; buf_size -= 2; } rows = buf[2]; cols = buf[3]; if (!rows || !cols) { av_log(s->avctx, AV_LOG_ERROR, "Invalid size %dx%d\n", cols << 4, rows << 4); return AVERROR_INVALIDDATA; } if (!s->macroblocks || 16*cols != s->avctx->coded_width || 16*rows != s->avctx->coded_height) { if (s->avctx->extradata_size == 0 && FFALIGN(s->avctx->width, 16) == 16 * cols && FFALIGN(s->avctx->height, 16) == 16 * rows) { s->avctx->coded_width = 16 * cols; s->avctx->coded_height = 16 * rows; } else { ret = ff_set_dimensions(s->avctx, 16 * cols, 16 * rows); if (ret < 0) return ret; if (s->avctx->extradata_size == 1) { s->avctx->width -= s->avctx->extradata[0] >> 4; s->avctx->height -= s->avctx->extradata[0] & 0x0F; } } res = VP56_SIZE_CHANGE; } ret = ff_vp56_init_range_decoder(c, buf+6, buf_size-6); if (ret < 0) return ret; vp56_rac_gets(c, 2); parse_filter_info = s->filter_header; if (sub_version < 8) vrt_shift = 5; s->sub_version = sub_version; s->golden_frame = 0; } else { if (!s->sub_version || !s->avctx->coded_width || !s->avctx->coded_height) return AVERROR_INVALIDDATA; if (separated_coeff || !s->filter_header) { coeff_offset = AV_RB16(buf+1) - 2; buf += 2; buf_size -= 2; } ret = ff_vp56_init_range_decoder(c, buf+1, buf_size-1); if (ret < 0) return ret; s->golden_frame = vp56_rac_get(c); if (s->filter_header) { s->deblock_filtering = vp56_rac_get(c); if (s->deblock_filtering) vp56_rac_get(c); if (s->sub_version > 7) parse_filter_info = vp56_rac_get(c); } } if (parse_filter_info) { if (vp56_rac_get(c)) { s->filter_mode = 2; s->sample_variance_threshold = vp56_rac_gets(c, 5) << vrt_shift; s->max_vector_length = 2 << vp56_rac_gets(c, 3); } else if (vp56_rac_get(c)) { s->filter_mode = 1; } else { s->filter_mode = 0; } if (s->sub_version > 7) s->filter_selection = vp56_rac_gets(c, 4); else s->filter_selection = 16; } s->use_huffman = vp56_rac_get(c); s->parse_coeff = vp6_parse_coeff; if (coeff_offset) { buf += coeff_offset; buf_size -= coeff_offset; if (buf_size < 0) { if (s->frames[VP56_FRAME_CURRENT]->key_frame) ff_set_dimensions(s->avctx, 0, 0); return AVERROR_INVALIDDATA; } if (s->use_huffman) { s->parse_coeff = vp6_parse_coeff_huffman; init_get_bits(&s->gb, buf, buf_size<<3); } else { ret = ff_vp56_init_range_decoder(&s->cc, buf, buf_size); if (ret < 0) return ret; s->ccp = &s->cc; } } else { s->ccp = &s->c; } return res; }
1threat
How does global error handling work in service workers? : <p>I found <a href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/onerror" rel="noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/onerror</a> which says:</p> <blockquote> <p>The onerror property of the ServiceWorkerContainer interface is an event handler fired whenever an error event occurs in the associated service workers.</p> </blockquote> <p>However I'm not able to get this working in Chrome (v51). In the scope of the main application, I ran the following code from the console:</p> <pre><code>navigator.serviceWorker.onerror = function(e) { console.log('some identifiable string' + e); }; </code></pre> <p>Then within the scope of the active service worker I triggered an arbitrary error:</p> <pre><code>f(); // f is undefined </code></pre> <p>The result was the usual "Uncaught ReferenceError: f is not defined(…)" error message but it was not logged through my global onerror handler.</p> <p>The MDN page says that this API has been supported in Chrome since v40, but <code>navigator.serviceWorker.onerror</code> is initially undefined which leads me to believe that it's unimplemented. Is anyone familiar with this?</p>
0debug
Could someone help me understand why this code actually works? : <p>I've been following the Laracasts "PHP Practitioner" series to help me get a basic understanding of PHP and at this point, my code works fine and doesn't return any errors, but I can't quite grasp how it actually works.</p> <p>If you've watched the series, in <a href="https://laracasts.com/series/php-for-beginners/episodes/20" rel="nofollow noreferrer">Episode 20</a>, in our QueryBuilder.php file, we create an insert method with 2 parameters "$table" and "$parameters". I get why "$table" works as we assign it to the 'users' table in the add-name.php file, but how does the text in the form get submitted to the database via the $parameters param? I'm not exactly following the logic so well and I just want to fully understand what's happening here. </p> <p>For those of you who haven't watched the series and have no idea what I'm talking about, we basically make a simple form with an input and a submit button and at this point, we are sending the info from the form into a DB. Here's the snippet from the QueryBuilder.php file:</p> <pre><code>public function insert($table, $parameters) { $sql = sprintf( 'INSERT INTO %s(%s) values (%s)', $table, implode(', ', array_keys($parameters)), ':' .implode(', :', array_keys($parameters)) ); try{ $statement = $this-&gt;pdo-&gt;prepare($sql); $statement-&gt;execute($parameters); } catch (Exception $e){ die($e-&gt;getMessage()); } } </code></pre> <p>and here's the add-name.php file:</p> <pre><code>&lt;?php $app['database']-&gt;insert('users', [ 'name' =&gt; $_POST['name'] ]); header('Location: /laracasts/PHP'); </code></pre>
0debug
Grab the first snippet of php code with RegEx : <p>I have several files with 2 php snippets nested with </p> <p><code>&lt;? php code code code ?&gt; &lt;? php code code code ?&gt;</code></p> <p>How can I just grab the first snippet including tags with RegEx?</p> <p>Thanks!</p>
0debug
How to check how many instances created for a type in c#? : <p>How can I check that number of instances created for a particular type and how much memory each instance occupied. Please give an example. </p>
0debug
static void mm_decode_inter(MmContext * s, int half_horiz, int half_vert, const uint8_t *buf, int buf_size) { const int data_ptr = 2 + AV_RL16(&buf[0]); int d, r, y; d = data_ptr; r = 2; y = 0; while(r < data_ptr) { int i, j; int length = buf[r] & 0x7f; int x = buf[r+1] + ((buf[r] & 0x80) << 1); r += 2; if (length==0) { y += x; continue; } for(i=0; i<length; i++) { for(j=0; j<8; j++) { int replace = (buf[r+i] >> (7-j)) & 1; if (replace) { int color = buf[d]; s->frame.data[0][y*s->frame.linesize[0] + x] = color; if (half_horiz) s->frame.data[0][y*s->frame.linesize[0] + x + 1] = color; if (half_vert) { s->frame.data[0][(y+1)*s->frame.linesize[0] + x] = color; if (half_horiz) s->frame.data[0][(y+1)*s->frame.linesize[0] + x + 1] = color; } d++; } x += 1 + half_horiz; } } r += length; y += 1 + half_vert; } }
1threat
static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs) { int extension = (ctx->opcode >> 6) & 0x3f; int minor = (ctx->opcode >> 12) & 0xf; uint32_t mips32_op; switch (extension) { case TEQ: mips32_op = OPC_TEQ; goto do_trap; case TGE: mips32_op = OPC_TGE; goto do_trap; case TGEU: mips32_op = OPC_TGEU; goto do_trap; case TLT: mips32_op = OPC_TLT; goto do_trap; case TLTU: mips32_op = OPC_TLTU; goto do_trap; case TNE: mips32_op = OPC_TNE; do_trap: gen_trap(ctx, mips32_op, rs, rt, -1); break; #ifndef CONFIG_USER_ONLY case MFC0: case MFC0 + 32: check_cp0_enabled(ctx); if (rt == 0) { break; } gen_mfc0(ctx, cpu_gpr[rt], rs, (ctx->opcode >> 11) & 0x7); break; case MTC0: case MTC0 + 32: check_cp0_enabled(ctx); { TCGv t0 = tcg_temp_new(); gen_load_gpr(t0, rt); gen_mtc0(ctx, t0, rs, (ctx->opcode >> 11) & 0x7); tcg_temp_free(t0); } break; #endif case 0x2a: switch (minor & 3) { case MADD_ACC: gen_muldiv(ctx, OPC_MADD, (ctx->opcode >> 14) & 3, rs, rt); break; case MADDU_ACC: gen_muldiv(ctx, OPC_MADDU, (ctx->opcode >> 14) & 3, rs, rt); break; case MSUB_ACC: gen_muldiv(ctx, OPC_MSUB, (ctx->opcode >> 14) & 3, rs, rt); break; case MSUBU_ACC: gen_muldiv(ctx, OPC_MSUBU, (ctx->opcode >> 14) & 3, rs, rt); break; default: goto pool32axf_invalid; } break; case 0x32: switch (minor & 3) { case MULT_ACC: gen_muldiv(ctx, OPC_MULT, (ctx->opcode >> 14) & 3, rs, rt); break; case MULTU_ACC: gen_muldiv(ctx, OPC_MULTU, (ctx->opcode >> 14) & 3, rs, rt); break; default: goto pool32axf_invalid; } break; case 0x2c: switch (minor) { case BITSWAP: check_insn(ctx, ISA_MIPS32R6); gen_bitswap(ctx, OPC_BITSWAP, rs, rt); break; case SEB: gen_bshfl(ctx, OPC_SEB, rs, rt); break; case SEH: gen_bshfl(ctx, OPC_SEH, rs, rt); break; case CLO: mips32_op = OPC_CLO; goto do_cl; case CLZ: mips32_op = OPC_CLZ; do_cl: check_insn(ctx, ISA_MIPS32); gen_cl(ctx, mips32_op, rt, rs); break; case RDHWR: gen_rdhwr(ctx, rt, rs); break; case WSBH: gen_bshfl(ctx, OPC_WSBH, rs, rt); break; case MULT: check_insn_opc_removed(ctx, ISA_MIPS32R6); mips32_op = OPC_MULT; goto do_mul; case MULTU: check_insn_opc_removed(ctx, ISA_MIPS32R6); mips32_op = OPC_MULTU; goto do_mul; case DIV: check_insn_opc_removed(ctx, ISA_MIPS32R6); mips32_op = OPC_DIV; goto do_div; case DIVU: check_insn_opc_removed(ctx, ISA_MIPS32R6); mips32_op = OPC_DIVU; goto do_div; do_div: check_insn(ctx, ISA_MIPS32); gen_muldiv(ctx, mips32_op, 0, rs, rt); break; case MADD: check_insn_opc_removed(ctx, ISA_MIPS32R6); mips32_op = OPC_MADD; goto do_mul; case MADDU: check_insn_opc_removed(ctx, ISA_MIPS32R6); mips32_op = OPC_MADDU; goto do_mul; case MSUB: check_insn_opc_removed(ctx, ISA_MIPS32R6); mips32_op = OPC_MSUB; goto do_mul; case MSUBU: check_insn_opc_removed(ctx, ISA_MIPS32R6); mips32_op = OPC_MSUBU; do_mul: check_insn(ctx, ISA_MIPS32); gen_muldiv(ctx, mips32_op, 0, rs, rt); break; default: goto pool32axf_invalid; } break; case 0x34: switch (minor) { case MFC2: case MTC2: case MFHC2: case MTHC2: case CFC2: case CTC2: generate_exception_err(ctx, EXCP_CpU, 2); break; default: goto pool32axf_invalid; } break; case 0x3c: switch (minor) { case JALR: case JALR_HB: if (ctx->insn_flags & ISA_MIPS32R6) { gen_compute_branch(ctx, OPC_JALR, 4, rs, rt, 0, 0); } else { gen_compute_branch(ctx, OPC_JALR, 4, rs, rt, 0, 4); ctx->hflags |= MIPS_HFLAG_BDS_STRICT; } break; case JALRS: case JALRS_HB: check_insn_opc_removed(ctx, ISA_MIPS32R6); gen_compute_branch(ctx, OPC_JALR, 4, rs, rt, 0, 2); ctx->hflags |= MIPS_HFLAG_BDS_STRICT; break; default: goto pool32axf_invalid; } break; case 0x05: switch (minor) { case RDPGPR: check_cp0_enabled(ctx); check_insn(ctx, ISA_MIPS32R2); gen_load_srsgpr(rs, rt); break; case WRPGPR: check_cp0_enabled(ctx); check_insn(ctx, ISA_MIPS32R2); gen_store_srsgpr(rs, rt); break; default: goto pool32axf_invalid; } break; #ifndef CONFIG_USER_ONLY case 0x0d: switch (minor) { case TLBP: mips32_op = OPC_TLBP; goto do_cp0; case TLBR: mips32_op = OPC_TLBR; goto do_cp0; case TLBWI: mips32_op = OPC_TLBWI; goto do_cp0; case TLBWR: mips32_op = OPC_TLBWR; goto do_cp0; case TLBINV: mips32_op = OPC_TLBINV; goto do_cp0; case TLBINVF: mips32_op = OPC_TLBINVF; goto do_cp0; case WAIT: mips32_op = OPC_WAIT; goto do_cp0; case DERET: mips32_op = OPC_DERET; goto do_cp0; case ERET: mips32_op = OPC_ERET; do_cp0: gen_cp0(env, ctx, mips32_op, rt, rs); break; default: goto pool32axf_invalid; } break; case 0x1d: switch (minor) { case DI: check_cp0_enabled(ctx); { TCGv t0 = tcg_temp_new(); save_cpu_state(ctx, 1); gen_helper_di(t0, cpu_env); gen_store_gpr(t0, rs); ctx->bstate = BS_STOP; tcg_temp_free(t0); } break; case EI: check_cp0_enabled(ctx); { TCGv t0 = tcg_temp_new(); save_cpu_state(ctx, 1); gen_helper_ei(t0, cpu_env); gen_store_gpr(t0, rs); ctx->bstate = BS_STOP; tcg_temp_free(t0); } break; default: goto pool32axf_invalid; } break; #endif case 0x2d: switch (minor) { case SYNC: break; case SYSCALL: generate_exception_end(ctx, EXCP_SYSCALL); break; case SDBBP: if (is_uhi(extract32(ctx->opcode, 16, 10))) { gen_helper_do_semihosting(cpu_env); } else { check_insn(ctx, ISA_MIPS32); if (ctx->hflags & MIPS_HFLAG_SBRI) { generate_exception_end(ctx, EXCP_RI); } else { generate_exception_end(ctx, EXCP_DBp); } } break; default: goto pool32axf_invalid; } break; case 0x01: switch (minor & 3) { case MFHI_ACC: gen_HILO(ctx, OPC_MFHI, minor >> 2, rs); break; case MFLO_ACC: gen_HILO(ctx, OPC_MFLO, minor >> 2, rs); break; case MTHI_ACC: gen_HILO(ctx, OPC_MTHI, minor >> 2, rs); break; case MTLO_ACC: gen_HILO(ctx, OPC_MTLO, minor >> 2, rs); break; default: goto pool32axf_invalid; } break; case 0x35: check_insn_opc_removed(ctx, ISA_MIPS32R6); switch (minor) { case MFHI32: gen_HILO(ctx, OPC_MFHI, 0, rs); break; case MFLO32: gen_HILO(ctx, OPC_MFLO, 0, rs); break; case MTHI32: gen_HILO(ctx, OPC_MTHI, 0, rs); break; case MTLO32: gen_HILO(ctx, OPC_MTLO, 0, rs); break; default: goto pool32axf_invalid; } break; default: pool32axf_invalid: MIPS_INVAL("pool32axf"); generate_exception_end(ctx, EXCP_RI); break; } }
1threat
static void float_to_int16_stride_altivec(int16_t *dst, const float *src, long len, int stride) { int i, j; vector signed short d, s; for (i = 0; i < len - 7; i += 8) { d = float_to_int16_one_altivec(src + i); for (j = 0; j < 8; j++) { s = vec_splat(d, j); vec_ste(s, 0, dst); dst += stride; } } }
1threat
Why docker is needed : <p>I googled and I understand , docker will create an application image with environment setup.</p> <p>Consider, I have an asp.net application which is already hosted in production. </p> <p>I see, I can add docker support to an existing asp.net application.</p> <p>How docker can help me with this, because I have already an environment setup on server. For an asp.net application all I needed mostly is a .net framework to be installed. Instead to install docker I could install .net framework?</p> <p>May be my understanding is wrong?</p>
0debug
Java, NullPointerException on a matrix of object : I know the answer may be stupid, but I can't find the solution. I am tring to use a matrix of object like this //static declaration (class attribute) static Litteral [] [] explicitsPropagations; ... //initialisation (sat and csp are declared) explicitsPropagations = new Litteral[csp.nbVar()][sat.nbVar()*2]; ... //affectation (NullPointerException), idClause, iEP, iX are correctly declared for (int i = 0 ; i < iX ; i++) explicitsPropagations[idClause][iEP[idClause]] = X[i]; Can someone see the problem ? Thanks.
0debug
Swift - Put Red Dot on iPhone App Icon : <p>Any ideas how to apply a red dot to the iPhone App icon - like the Mail or Messages' Icon with the number of unread messages in it?</p> <p><a href="https://i.stack.imgur.com/0uVii.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0uVii.png" alt="enter image description here"></a></p>
0debug
Visual basic help, I want to know how to avoid other "if" conditions if first "if" is true : Public Class Form1 Dim numAttempts As Double = 0 Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click Dim User As String = "ShaoHecc" Dim Password As String = "daedric123" Dim loginuser As String Dim loginpassword As String Dim wrong As String = False loginpassword = Val(txtpass.Text) loginuser = Val(txtuser.Text) txtpass.Text = loginpassword txtuser.Text = loginuser If txtuser.Text = User And txtpass.Text = Password Then MessageBox.Show("Access Granted!") ElseIf txtuser.Text = loginuser And txtpass.Text = loginpassword Then MessageBox.Show("Username and Password incorrect, " & numAttempts & " / 3 attempts left") End If If txtuser.Text = User = False Then MessageBox.Show("Username incorrect, you have " & numAttempts & " / 3 attempts left.") txtuser.Text = Nothing End If If txtpass.Text = Password = False Then MessageBox.Show("Password incorrect, you have " & numAttempts & " / 3 attempts left.") txtpass.Text = Nothing End If If numAttempts = 3 Then MessageBox.Show("Maxiumum number attempts reached, you have been denied access.") Application.Exit() Else numAttempts = numAttempts + 1 End If End Sub End Class I want to make my first if to stop at "Incorrect user and password", but it goes to the second and third if saying "incorrect user" and "incorrect password" after "incorrect user and password".
0debug
float32 helper_fxtos(CPUSPARCState *env, int64_t src) { float32 ret; clear_float_exceptions(env); ret = int64_to_float32(src, &env->fp_status); check_ieee_exceptions(env); return ret; }
1threat
Amazon Kinesis and guaranteed ordering : <p>Amazon claims their Kinesis streaming product guarantees record ordering.</p> <blockquote> <p>It provides ordering of records, as well as the ability to read and/or replay records in the same order (...)</p> </blockquote> <p>Kinesis is composed of Streams that are themselves composed of one or more Shards. Records are stored in these Shards. We can write consumer applications that connect to a Shard and read/replay records in the order they were stored.</p> <p>But can Kinesis guarantee, out of the box, ordering for the Stream itself without pushing ordering logic to the consumers? How can a consumer read records from multiple Shards of the same Stream, making sure the records are read in the same order they were added to the Stream?</p>
0debug
dshow_read_close(AVFormatContext *s) { struct dshow_ctx *ctx = s->priv_data; AVPacketList *pktl; if (ctx->control) { IMediaControl_Stop(ctx->control); IMediaControl_Release(ctx->control); } if (ctx->graph) { IEnumFilters *fenum; int r; r = IGraphBuilder_EnumFilters(ctx->graph, &fenum); if (r == S_OK) { IBaseFilter *f; IEnumFilters_Reset(fenum); while (IEnumFilters_Next(fenum, 1, &f, NULL) == S_OK) { if (IGraphBuilder_RemoveFilter(ctx->graph, f) == S_OK) IEnumFilters_Reset(fenum); IBaseFilter_Release(f); } IEnumFilters_Release(fenum); } IGraphBuilder_Release(ctx->graph); } if (ctx->capture_pin[VideoDevice]) libAVPin_Release(ctx->capture_pin[VideoDevice]); if (ctx->capture_pin[AudioDevice]) libAVPin_Release(ctx->capture_pin[AudioDevice]); if (ctx->capture_filter[VideoDevice]) libAVFilter_Release(ctx->capture_filter[VideoDevice]); if (ctx->capture_filter[AudioDevice]) libAVFilter_Release(ctx->capture_filter[AudioDevice]); if (ctx->device_pin[VideoDevice]) IPin_Release(ctx->device_pin[VideoDevice]); if (ctx->device_pin[AudioDevice]) IPin_Release(ctx->device_pin[AudioDevice]); if (ctx->device_filter[VideoDevice]) IBaseFilter_Release(ctx->device_filter[VideoDevice]); if (ctx->device_filter[AudioDevice]) IBaseFilter_Release(ctx->device_filter[AudioDevice]); if (ctx->device_name[0]) av_free(ctx->device_name[0]); if (ctx->device_name[1]) av_free(ctx->device_name[1]); if(ctx->mutex) CloseHandle(ctx->mutex); if(ctx->event) CloseHandle(ctx->event); pktl = ctx->pktl; while (pktl) { AVPacketList *next = pktl->next; av_destruct_packet(&pktl->pkt); av_free(pktl); pktl = next; } return 0; }
1threat
iOS 13 - UIPopoverPresentationController sourceview content visible in the arrow : <p>When I am displaying some view in UIPopoverPresentationController and presenting it as popover</p> <pre><code>popoverCon?.modalPresentationStyle = UIModalPresentationStyle.popover </code></pre> <p>the content have moved upward toward and a some part is being display in the arrow. </p> <p><a href="https://i.stack.imgur.com/HtQPI.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/HtQPI.jpg" alt="enter image description here"></a></p> <p>Further I had border around the popover</p> <pre><code>popoverCon?.view.layer.borderColor = .orange popoverCon?.view.layer.borderWidth = 1.0; popoverCon?.view.layer.cornerRadius = 10.0; popoverCon?.view.layer.masksToBounds = false; </code></pre> <p>it is not showing toward the part where arrow is but it displays a little of the border line in the tip of the arrow.</p> <p><a href="https://i.stack.imgur.com/Z7dQU.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Z7dQU.jpg" alt="enter image description here"></a></p> <p>This was working fine until iOS 12 but in iOS 13 this issue is coming. </p> <p>Any suggestions on how I can solve this?</p>
0debug
I get exception after pressing click() for "FindElemebtByID" : I get exception after pressing click() for "FindElemebtByID". I get the next exception: Error CS1061 'ReadOnlyCollection<WindowsElement>' does not contain a definition for 'Click' and no accessible extension method 'Click' accepting a first argument of type 'ReadOnlyCollection<WindowsElement>' could be found (are you missing a using directive or an assembly reference?) my code is: var EQ = DesktopSession.FindElementByName(@"C:\Users"); var EQWindowHandle = EQ.GetAttribute("NativeWindowHandle"); EQWindowHandle = (int.Parse(EQWindowHandle)).ToString("x");
0debug
valgrind mac os sierra 10.12.1 : <p>Is there any possible ways to install valgrind on new Mac OS? brew tell </p> <pre><code>brew install -HEAD valgrind valgrind: This formula either does not compile or function as expected on macOS versions newer than El Capitan due to an upstream incompatibility. Error: An unsatisfied requirement failed this build. valgrind ls -l valgrind: mmap-FIXED(0x0, 253952) failed in UME (load_segment1) with error 12 (Cannot allocate memory). </code></pre>
0debug
[Begginer][Python] Egregiously Simple IF statements NOT working : > Write a function integer_type that consumes a value of any type and produces "Even integer" if it is an even integer, "Odd integer" if it is an odd integer, and "Not an integer" otherwise. def integer_type(som): if type(som)==type(0): if som%2==0: return "Even integer" else: return "Odd integer" else: return "Not an integer" x= input() print(integer_type(x)) Everytime I run it it completely skips over if regardless of its an integer or a string and prints "Not an integer" I tried a different problem with elifs instead and its made no difference. I still obtain the very last "else" return for my print. > Write a function off_peak that consumes any type of data and determines if the time is eligible for off peak rates. Your function should produce one of the following outputs: "Off peak", "Peak", and "Not a time". Off-peak rates are based on 24-hour time, for values less than 9 or greater than 17. def off_peak(any): if type(any)==type(0) and any<9 and any>17: return "Off peak" elif type(any)==type(0) and 9<any<17 and 0<any<23: return "Peak" else: return "Not a time" x= input("Peak Dector:") print(off_peak(x)) any help would be greatly appreciated
0debug
Hide element for mobile only - Semantic UI : <p>I have problem with hiding image for mobile devices. I'm using Semantic UI framework. In documentation I found some classes: </p> <ol> <li>mobile only - will only display below 768px</li> <li>tablet only - will only display between 768px - 991px</li> <li>computer only - will always display 992px and above</li> </ol> <p>Just for example, I'm using "computer only" classes to hide image on tablets and mobile, but the result confused me. </p> <pre><code>&lt;div class="ui grid stackable"&gt; &lt;div class="row middle aligned"&gt; &lt;div class="nine wide column"&gt; &lt;h1 class="ui header blue"&gt;Default Header.&lt;/h1&gt; &lt;/div&gt; &lt;div class="seven wide computer only column"&gt; &lt;img class="ui image" src="http://icons.veryicon.com/png/System/iNiZe/niZe%20%20%20IMG.png" alt="" title=""&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><a href="http://jsfiddle.net/3xkrx/318/" rel="noreferrer">http://jsfiddle.net/3xkrx/318/</a></p>
0debug
Kotlin: How to extend the enum class with an extension function : <p>I'm trying to extend enum classes of type <code>String</code> with the following function but am unable to use it at the call site like so: </p> <pre><code>fun &lt;T: Enum&lt;String&gt;&gt; Class&lt;T&gt;.join(skipFirst: Int = 0, skipLast: Int = 0): String { return this.enumConstants .drop(skipFirst) .dropLast(skipLast) .map { e -&gt; e.name } .joinToString() } MyStringEnum.join(1, 1); </code></pre> <p>What am I doing wrong here?</p>
0debug
regex: check if two phone numbers differ at most by 1 number : <p>I have a dataset of phone numbers that I want to check against each other. Basically the regex should throw a match if two phone numbers are at most 1 digit apart. For example, we have the following phone numbers:</p> <ul> <li>+31612345678</li> <li>+31612245678</li> </ul> <p>These numbers are the same apart from position number 7 (first number has a 3 while the second number has a 2). As these phone number differ by 1 digit, the regex should throw a match. It stands to reason that the regex should also throw a match if the phone numbers are exactly the same. In the following case (see below), the regex should however not throw at match as the phone numbers differ by more than 1 digit:</p> <ul> <li>+31612345678</li> <li>+31611145678</li> </ul> <p>Does anyone have a good regex in mind? I am writing the regex using the re module in python. </p>
0debug
When to use Groups in Regular Expressions? : <p>I'm a newbie and learning more about regular expressions. I'm still unclear as to why we use groups. I used them in the below regular expression below:</p> <pre><code>(http:)\//(\w)+\.(\w)+\.(\w)+ </code></pre> <p>This will extract URL's, as in the below sentence:</p> <pre><code>This is http://www.google.com, this is http://www.yahoo.com. </code></pre> <p>I did use groups but I was very unsure as to why. I saw this explanation online but confused as to what it means:</p> <p>By placing part of a regular expression inside round brackets or parentheses, you can group that part of the regular expression together. This allows you to apply a quantifier to the entire group or to restrict alternation to part of the regex.</p> <p>So any simplified clarification of groups would be great. </p>
0debug
How do I fix this error : index was outside the bounds of the array : <p>We have to make a GUI based program for campus.We basically have to create a 2 player battle based game where users have to enter their stats and those stats were used to for the battle.There was no other user input.I managed to complete it but when I ran the program I received this error:</p> <p>Unhandled exception has occurred in your application .If you click Continue the application will ignore this error and attempt to continue . If you click Quit the application will close immediately Index was outside the bounds of the array </p> <p>My Code :</p> <pre><code> public Form1() { InitializeComponent(); } //Declaring Jaggered Array string[][] playerstat = new string[2][]; private void button1_Click(object sender, EventArgs e) { //Retrieving information from textboxes for player 1 string name1 = txtName1.Text; string htpt1 = txtHtPt1.Text; string attack1 = txtAttack1.Text; string def1 = txtDef1.Text; //Assigning Player1 Values playerstat[0] = new string[4] { name1, htpt1, attack1, def1 }; } private void panel4_Paint(object sender, PaintEventArgs e) { } private void button2_Click(object sender, EventArgs e) { //Retrieving information from textboxes for player 2 string name2 = txtName2.Text; string htpt2 = txtHtPt2.Text; string attack2 = txtAttack2.Text; string def2 = txtDef2.Text; //Assigning Player2 Values playerstat[1] = new string[4] { name2, htpt2, attack2, def2 }; } private void btnFight_Click(object sender, EventArgs e) { string p1name = playerstat[0][1]; string sp1hp = playerstat[0][2]; int p1hp = Int32.Parse(sp1hp); string sp1a = playerstat[0][3]; int p1a = Int32.Parse(sp1a); string sp1d = playerstat[0][4]; int p1d = Int32.Parse(sp1d); string p2name = playerstat[1][1]; string sp2hp = playerstat[1][2]; int p2hp = Int32.Parse(sp1hp); string sp2a = playerstat[1][3]; int p2a = Int32.Parse(sp1a); string sp2d = playerstat[1][4]; int p2d = Int32.Parse(sp1d); //Fighting Loop while(!(p1hp == 0) || !(p2hp == 0)) { p2hp = p1a - (p2hp + p2d); txtFOP.Text = p1name + " deals " + p1a + " damage to " + p2name + " who now has " + p2hp; p1hp = p2a - (p1hp + p1d); txtFOP.Text = p2name + " deals " + p2a + " damage to " + p1name + " who now has " + p1hp; } } } </code></pre> <p>}</p>
0debug
How to make web workers with TypeScript and webpack : <p>I'm having some issues with properly compiling my typescript when I attempt to use web workers. </p> <p>I have a worker defined like this: </p> <pre><code>onmessage = (event:MessageEvent) =&gt; { var files:FileList = event.data; for (var i = 0; i &lt; files.length; i++) { postMessage(files[i]); } }; </code></pre> <p>In another part of my application i'm using the webpack worker loader to load my worker like this: <code>let Worker = require('worker!../../../workers/uploader/main');</code></p> <p>I'm however having some issues with making the typescript declarations not yell at me when the application has to be transpiled. According to my research i have to add another standard lib to my tsconfig file to expose the global variables the worker need access to. These i have specified like so: </p> <pre><code>{ "compilerOptions": { "lib": [ "webworker", "es6", "dom" ] } } </code></pre> <p>Now, when i run webpack to have it build everything i get a bunch of errors like these: <code>C:/Users/hanse/Documents/Frontend/node_modules/typescript/lib/lib.webworker.d.ts:1195:13 Subsequent variable declarations must have the same type. Variable 'navigator' must be of type 'Navigator', but here has type 'WorkerNavigator'.</code></p> <p>So my question is: How do I specify so the webworker uses the lib.webworker.d.ts definitions and everything else follows the normal definitions?</p>
0debug
Erase all the numbers ai where 1 < i < n, in some order, such that the total cost is minimized : <p>I encountered this problem.But I could not come up with any solution except brute force.Please suggest some efficient algorithm. You are given a sequence of n numbers A = (a1, a2, ..., an). At one step, you can erase any number except for the leftmost and the rightmost ones. Erasing number ai costs ai−1 ∗ ai+1. Your goal is to erase all the numbers ai where 1 &lt; i &lt; n, in some order, such that the total cost is minimized. Give an algorithm to accomplish your goal, with O(n^3) time complexity.</p>
0debug
os.NetowrkOnMainThreadException service : <p>I read a few tutorials (one at tutorial point, and one at developer.android.com) and thought I was doing this correctly to avoid having this error <code>android.os.NetworkOnMainThreadException</code> However, I am still getting it despite having my network connection in the service started by calling startService (which happens when I click the start button in mainactivity, I didn't add the layout xml, but the onClick method has been set)</p> <p>I will try to paste relevant code here:</p> <h1>main activity</h1> <pre><code>public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } public void startService(View view) { startService(new Intent(getBaseContext(),MyService.class)); } public void stopService(View view) { stopService(new Intent(getBaseContext(), MyService.class)); } } </code></pre> <h1>Service</h1> <pre><code>public class MyService extends Service { @Override public IBinder onBind(Intent arg0) { return null; } /*@Override public void onCreate() { }*/ @Override public int onStartCommand(Intent intent, int flags, int startId) { Toast.makeText(this, "Service Started", Toast.LENGTH_SHORT).show(); KClient client = new KClient(8096); if(client.openConn("login","password")) { Toast.makeText(this,"Connected",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(this,"failed to connect",Toast.LENGTH_SHORT).show(); } return START_STICKY; } @Override public void onDestroy() { super.onDestroy(); Toast.makeText(this, "Service Destroyed", Toast.LENGTH_LONG).show(); } } </code></pre> <h1>manifest</h1> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.frizzled.MyService"&gt; &lt;application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"&gt; &lt;activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;service android:name=".MyService" /&gt; &lt;/application&gt; &lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;/manifest&gt; </code></pre>
0debug
Generate square from center point? : <p>I have coordinates of the center point of a square I would like to generate, the only bits of information I have is the location of the center point (example: 4,9) and the width/height (example: 10) of the square. I want to loop over every pixel of the square.</p> <p>Each block here represents a loop, the gold is the location of the "center" (I know it's off-center because it's an even number). <a href="https://i.imgur.com/U5Orrff.png" rel="nofollow noreferrer">http://i.imgur.com/U5Orrff.png</a></p> <p>The width will always be the same as the height and vice versa, however they can be any number from 1-25.</p>
0debug
static uint64_t vtd_context_cache_invalidate(IntelIOMMUState *s, uint64_t val) { uint64_t caig; uint64_t type = val & VTD_CCMD_CIRG_MASK; switch (type) { case VTD_CCMD_GLOBAL_INVL: VTD_DPRINTF(INV, "Global invalidation request"); caig = VTD_CCMD_GLOBAL_INVL_A; break; case VTD_CCMD_DOMAIN_INVL: VTD_DPRINTF(INV, "Domain-selective invalidation request"); caig = VTD_CCMD_DOMAIN_INVL_A; break; case VTD_CCMD_DEVICE_INVL: VTD_DPRINTF(INV, "Domain-selective invalidation request"); caig = VTD_CCMD_DEVICE_INVL_A; break; default: VTD_DPRINTF(GENERAL, "error: wrong context-cache invalidation granularity"); caig = 0; } return caig; }
1threat
int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, void *opaque) { if (monitor_ctrl_mode(mon)) { qerror_report(QERR_MISSING_PARAMETER, "password"); return -EINVAL; } else if (mon->rs) { readline_start(mon->rs, "Password: ", 1, readline_func, opaque); return 0; } else { monitor_printf(mon, "terminal does not support password prompting\n"); return -ENOTTY; } }
1threat
static void qmp_output_push_obj(QmpOutputVisitor *qov, QObject *value) { QStackEntry *e = g_malloc0(sizeof(*e)); assert(qov->root); assert(value); e->value = value; if (qobject_type(e->value) == QTYPE_QLIST) { e->is_list_head = true; } QTAILQ_INSERT_HEAD(&qov->stack, e, node); }
1threat
unresolved reference for render_template : <p>hey everyone I'm new to the world of python and I have a problem that I can't find the answer. I'm using paycharm and i've installed anaconda that contains Flask of corse. This is the code I wrote </p> <p><a href="http://i.stack.imgur.com/ELPoW.png" rel="nofollow">python code using paycharm</a></p> <p>The error I get is "unresolved reference 'render_template' ". I must mention that I already use anaconda"s interpretter.</p> <p>Any ideas please ?</p>
0debug
static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom) { AVStream *st = s->streams[1]; int av_unused tmp, tmp2; int samples, size; uint64_t pos = avio_tell(s->pb); unsigned dts; int ret; dts = avio_rb32(s->pb); st->codec->sample_rate = avio_rb32(s->pb); if (st->codec->sample_rate <= 0) { av_log(s, AV_LOG_ERROR, "Bad sample rate\n"); return AVERROR_INVALIDDATA; } samples = avio_rb32(s->pb); tmp = avio_rb32(s->pb); av_dlog(s, "packet num %d\n", tmp); tmp = avio_rb16(s->pb); av_dlog(s, "unknown %d\n", tmp); tmp = avio_r8(s->pb); tmp2 = avio_r8(s->pb); av_dlog(s, "version %d.%d\n", tmp, tmp2); tmp = avio_rb32(s->pb); av_dlog(s, "unknown %d\n", tmp); size = atom->size - 8 - (avio_tell(s->pb) - pos); if (size < 0) return -1; ret = av_get_packet(s->pb, pkt, size); if (ret < 0) { av_log(s, AV_LOG_ERROR, "error reading audio packet\n"); return ret; } pkt->stream_index = 1; pkt->dts = dts; pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate); av_dlog(s, "pkt dts %"PRId64" duration %d samples %d sample rate %d\n", pkt->dts, pkt->duration, samples, st->codec->sample_rate); return 0; }
1threat
Svelte Hot Reloading Issue : <p>Recently started playing with Svelte using the sveltejs template. Everything is working fine, however when I do any change in the files it doesn't hot reload the changes to the web browser, so I have to manually refresh the page to see the changes. Is there any option in the settings to enable that feature or is it not possible at this point?</p>
0debug
ASP.NET error NullReferenceException: Object reference not set to an instance of an object : <p>This is my first MVC project and I'm stuck. When I try to run my project, I'm getting NullReferenceException: 'Object reference not set to an instance of an object.' in my Index View at the foreach line. Any idea why and what I need to do to fix it.</p> <p>This configuration was also included all the configuration.</p> <p>.cshtml File is here: @model IEnumerable ===> foreach (var echipament in Model ) &lt;====== HERE IS THE ERROR This is the Controller class:</p> <pre><code> public ViewResult List() { var echipamente=_echipamentRepository.Echipamente; return View(echipamente); } } </code></pre> <p>Can you please help me to solve this error?</p>
0debug
Rewrite Nltk code to a function which can be used multiple time in python : How to rewrite the my code into a function which can called again **My code** stopwords=nltk.corpus.stopwords.words('english') user_defined_stop_words=['st','rd','kwun tong','kwai chung','kwun','tong'] new_stop_words=stopwords+user_defined_stop_words data['Clean_addr'] = data['Adj_Addr'].apply(lambda x: ' '.join([item.lower() for item in x.split()])) data['Clean_addr']=data['Clean_addr'].apply(lambda x:"".join([item.lower() for item in x if not item.isdigit()])) data['Clean_addr']=data['Clean_addr'].apply(lambda x:"".join([item.lower() for item in x if item not in string.punctuation])) data['Clean_addr'] = data['Clean_addr'].apply(lambda x: ' '.join([item.lower() for item in x.split() if item not in (new_stop_words)])) cv = CountVectorizer( max_features = 200,analyzer='word',ngram_range=(1, 3)) cv_addr = cv.fit_transform(data.pop('Clean_addr')) for i, col in enumerate(cv.get_feature_names()): data[col] = pd.SparseSeries(cv_addr[:, i].toarray().ravel(), fill_value=0) Any help appreiated.
0debug
Why are web apps going crazy with await / async nowadays? : <p>I come from a back end / thick client background, so maybe I'm missing something... but I recently looked at the source for an open source JWT token server and the authors went crazy with await / async. Like on every method and every line.</p> <p>I get what the pattern is for... to run long running tasks in a separate thread. In my thick client days, I would use it if a method might take a few seconds, so as not to block the GUI thread... but definitely not on a method that takes a few ms.</p> <p>Is this excessive use of await / async something you need for web dev or for something like Angular? This was in a JWT token server, so not even seeing what it has to do with any of those. It's just a REST end point.</p> <p>How is making every single line async going to improve performace? To me, it'll kill performance from spinning up all those threads, no?</p>
0debug
C++ Loops forever : <p>I wrote the following loop as a part of a program for my CS homework, however regardless of the input, the program keeps looping at this exact point. What am I doing wrong?</p> <pre><code>#include &lt;iostream&gt; using namespace std; char choice; do { cout &lt;&lt; "Type 'c' for characters or type 'n' for numbers: "; cin &gt;&gt; choice; }while (choice != 'c' || choice != 'n'); </code></pre>
0debug
Trigger workflow on Github push - Pipeline plugin - Multibranch configuration : <p>We are using the pipeline plugin with multibranch configuration for our CD. We have checked in the Jenkinsfile which works off git.</p> <pre><code>git url: "$url",credentialsId:'$credentials' </code></pre> <p>The job works fine, but does not auto trigger when a change is pushed to github. I have set up the GIT web hooks correctly. </p> <p>Interestingly, when I go into a branch of the multibranch job and I click "View Configuration", I see that the "Build when a change is pushed to Github" is unchecked. There is no way to check it since I can not modify the configuration of the job (since it takes from parent) and the same option is not there in parent. </p> <p>Any ideas how to fix this? </p>
0debug
How can i add 10000 users in for loop just take time less than 1 minute? : I have java assignment. The tagert is just only build a java app using eclipse IDE to `add.userAccount(String id, String name, String email)` in to a file. Note that i'm done this assignment because it's no difficult. But i have curious about optimization. Put that code into a loops(such as `for(int times = 0, time < 10000;time++) add.userAccount(String id, String name, String email);`) but i takes alot of time( 5 minutes). I use FileIntputStream and FileOutputStream. Is anyone here suggest me the way to optimize me problem???
0debug
static int client_migrate_info(Monitor *mon, const QDict *qdict, MonitorCompletion cb, void *opaque) { const char *protocol = qdict_get_str(qdict, "protocol"); const char *hostname = qdict_get_str(qdict, "hostname"); const char *subject = qdict_get_try_str(qdict, "cert-subject"); int port = qdict_get_try_int(qdict, "port", -1); int tls_port = qdict_get_try_int(qdict, "tls-port", -1); Error *err; int ret; if (strcmp(protocol, "spice") == 0) { if (!qemu_using_spice(&err)) { qerror_report_err(err); return -1; } if (port == -1 && tls_port == -1) { qerror_report(QERR_MISSING_PARAMETER, "port/tls-port"); return -1; } ret = qemu_spice_migrate_info(hostname, port, tls_port, subject, cb, opaque); if (ret != 0) { qerror_report(QERR_UNDEFINED_ERROR); return -1; } return 0; } qerror_report(QERR_INVALID_PARAMETER, "protocol"); return -1; }
1threat
main activity gets shite screen on launch android : I have created a app in which main activity its get white screen i am not getting it... whenever i launch app its only showing white screen and nothing to do it i am so confused plz help here is code main activity package com.example.admin.pcremote; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { ListView list; String[] menutitles; String[] menudescriptions; int images[]={R.drawable.mouse,R.drawable.keyboard,R.drawable.filemanager,R.drawable.media,R.drawable.power}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); Resources res = getResources(); menutitles=res.getStringArray(R.array.titles); menudescriptions=res.getStringArray(R.array.descriptions); list = (ListView) findViewById(R.id.listView); listadapter adptr=new listadapter(this,menutitles,images,menudescriptions); list.setAdapter(adptr); onclick(); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { Toast.makeText(MainActivity.this, "Setting", Toast.LENGTH_LONG).show(); return true; }else if (id == R.id.exit) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setMessage("Do You Want To Exit?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.setTitle("Exit!!"); alert.show(); return true; } return super.onOptionsItemSelected(item); } @SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); } activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start"> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" > <include layout="@layout/app_bar_main" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.design.widget.NavigationView> </android.support.v4.widget.DrawerLayout>
0debug
How to switch between hide and view password in Xamarin Android on button click? : private void _viewPassword_Click(object sender, EventArgs e) { EditText _editTextNew = FindViewById<EditText>(Resource.Id.editTxtPwd_signup); //_editTextNew.InputType = Android.Text.InputTypes.TextVariationPassword | Android.Text.InputTypes.ClassText; if (_editTextNew.InputType== Android.Text.InputTypes.TextVariationPassword) { _editTextNew.InputType = Android.Text.InputTypes.ClassText; _editTextNew.SetSelection(_editTextNew.Text.Length); } else if(_editTextNew.InputType == Android.Text.InputTypes.ClassText) { _editTextNew.InputType = Android.Text.InputTypes.TextVariationPassword; _editTextNew.SetSelection(_editTextNew.Text.Length); } } private void _viewPassword_Click(object sender, EventArgs e) { EditText _editTextNew = FindViewById<EditText>(Resource.Id.editTxtPwd_signup); //_editTextNew.InputType = Android.Text.InputTypes.TextVariationPassword | Android.Text.InputTypes.ClassText; if (_editTextNew.InputType== Android.Text.InputTypes.TextVariationPassword) { _editTextNew.InputType = Android.Text.InputTypes.ClassText; _editTextNew.SetSelection(_editTextNew.Text.Length); } else if(_editTextNew.InputType == Android.Text.InputTypes.ClassText) { _editTextNew.InputType = Android.Text.InputTypes.TextVariationPassword; _editTextNew.SetSelection(_editTextNew.Text.Length); } private void _viewPassword_Click(object sender, EventArgs e) { EditText _editTextNew = FindViewById<EditText>(Resource.Id.editTxtPwd_signup); //_editTextNew.InputType = Android.Text.InputTypes.TextVariationPassword | Android.Text.InputTypes.ClassText; if (_editTextNew.InputType== Android.Text.InputTypes.TextVariationPassword) { _editTextNew.InputType = Android.Text.InputTypes.ClassText; _editTextNew.SetSelection(_editTextNew.Text.Length); } else if(_editTextNew.InputType == Android.Text.InputTypes.ClassText) { _editTextNew.InputType = Android.Text.InputTypes.TextVariationPassword; _editTextNew.SetSelection(_editTextNew.Text.Length); } }
0debug
static int encode_apng(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { PNGEncContext *s = avctx->priv_data; int ret; int enc_row_size; size_t max_packet_size; APNGFctlChunk fctl_chunk; if (pict && avctx->codec_id == AV_CODEC_ID_APNG && s->color_type == PNG_COLOR_TYPE_PALETTE) { uint32_t checksum = ~av_crc(av_crc_get_table(AV_CRC_32_IEEE_LE), ~0U, pict->data[1], 256 * sizeof(uint32_t)); if (avctx->frame_number == 0) { s->palette_checksum = checksum; } else if (checksum != s->palette_checksum) { av_log(avctx, AV_LOG_ERROR, "Input contains more than one unique palette. APNG does not support multiple palettes.\n"); return -1; } } enc_row_size = deflateBound(&s->zstream, (avctx->width * s->bits_per_pixel + 7) >> 3); max_packet_size = AV_INPUT_BUFFER_MIN_SIZE + avctx->height * ( enc_row_size + (4 + 12) * (((int64_t)enc_row_size + IOBUF_SIZE - 1) / IOBUF_SIZE) ); if (max_packet_size > INT_MAX) return AVERROR(ENOMEM); if (avctx->frame_number == 0) { s->bytestream = avctx->extradata = av_malloc(FF_MIN_BUFFER_SIZE); if (!avctx->extradata) return AVERROR(ENOMEM); ret = encode_headers(avctx, pict); if (ret < 0) return ret; avctx->extradata_size = s->bytestream - avctx->extradata; s->last_frame_packet = av_malloc(max_packet_size); if (!s->last_frame_packet) return AVERROR(ENOMEM); } else if (s->last_frame) { ret = ff_alloc_packet2(avctx, pkt, max_packet_size, 0); if (ret < 0) return ret; memcpy(pkt->data, s->last_frame_packet, s->last_frame_packet_size); pkt->size = s->last_frame_packet_size; pkt->pts = pkt->dts = s->last_frame->pts; } if (pict) { s->bytestream_start = s->bytestream = s->last_frame_packet; s->bytestream_end = s->bytestream + max_packet_size; fctl_chunk.sequence_number = s->sequence_number; ++s->sequence_number; s->bytestream += 26 + 12; ret = apng_encode_frame(avctx, pict, &fctl_chunk, &s->last_frame_fctl); if (ret < 0) return ret; fctl_chunk.delay_num = 0; fctl_chunk.delay_den = 0; } else { s->last_frame_fctl.dispose_op = APNG_DISPOSE_OP_NONE; } if (s->last_frame) { uint8_t* last_fctl_chunk_start = pkt->data; uint8_t buf[26]; AV_WB32(buf + 0, s->last_frame_fctl.sequence_number); AV_WB32(buf + 4, s->last_frame_fctl.width); AV_WB32(buf + 8, s->last_frame_fctl.height); AV_WB32(buf + 12, s->last_frame_fctl.x_offset); AV_WB32(buf + 16, s->last_frame_fctl.y_offset); AV_WB16(buf + 20, s->last_frame_fctl.delay_num); AV_WB16(buf + 22, s->last_frame_fctl.delay_den); buf[24] = s->last_frame_fctl.dispose_op; buf[25] = s->last_frame_fctl.blend_op; png_write_chunk(&last_fctl_chunk_start, MKTAG('f', 'c', 'T', 'L'), buf, 26); *got_packet = 1; } if (pict) { if (!s->last_frame) { s->last_frame = av_frame_alloc(); if (!s->last_frame) return AVERROR(ENOMEM); } else if (s->last_frame_fctl.dispose_op != APNG_DISPOSE_OP_PREVIOUS) { if (!s->prev_frame) { s->prev_frame = av_frame_alloc(); if (!s->prev_frame) return AVERROR(ENOMEM); s->prev_frame->format = pict->format; s->prev_frame->width = pict->width; s->prev_frame->height = pict->height; if ((ret = av_frame_get_buffer(s->prev_frame, 32)) < 0) return ret; } memcpy(s->prev_frame->data[0], s->last_frame->data[0], s->last_frame->linesize[0] * s->last_frame->height); if (s->last_frame_fctl.dispose_op == APNG_DISPOSE_OP_BACKGROUND) { uint32_t y; uint8_t bpp = (s->bits_per_pixel + 7) >> 3; for (y = s->last_frame_fctl.y_offset; y < s->last_frame_fctl.y_offset + s->last_frame_fctl.height; ++y) { size_t row_start = s->last_frame->linesize[0] * y + bpp * s->last_frame_fctl.x_offset; memset(s->prev_frame->data[0] + row_start, 0, bpp * s->last_frame_fctl.width); } } } av_frame_unref(s->last_frame); ret = av_frame_ref(s->last_frame, (AVFrame*)pict); if (ret < 0) return ret; s->last_frame_fctl = fctl_chunk; s->last_frame_packet_size = s->bytestream - s->bytestream_start; } else { av_frame_free(&s->last_frame); } return 0; }
1threat
How to insert struct data to a file? : <p>I've been working on a records system, everything looks good but </p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;string&gt; #include &lt;stdlib.h&gt; using namespace std; struct students{ string studentID; string surname; string firstname; string birthdate; string sex; }; int main() { fstream collection; string filename; short choice; do{ int ctr=1; system("cls"); if(collection.is_open()){ cout&lt;&lt;"Active File: ["&lt;&lt;filename&lt;&lt;"]"&lt;&lt;endl; }else{ cout&lt;&lt;"Active File|: [None opened]"&lt;&lt;endl; } cout&lt;&lt;"[1] Create new file"&lt;&lt;endl; cout&lt;&lt;"[2] Open existing file"&lt;&lt;endl; cout&lt;&lt;"[3] Manage data"&lt;&lt;endl; cout&lt;&lt;"[4] Exit"&lt;&lt;endl; cout&lt;&lt;"Enter operation index: "; cin&gt;&gt;choice; switch(choice){ case 1: cout&lt;&lt;"Enter file name: "; cin&gt;&gt;filename; collection.open(filename, std::fstream::in | std::fstream::out | std::fstream::app); collection&lt;&lt;"------------------------------------------------------------------------------"&lt;&lt;endl; collection&lt;&lt;"Rec \t Student ID \t Surname \t Firstname \t Birthdate \t Sex \t"&lt;&lt;endl; collection&lt;&lt;"------------------------------------------------------------------------------"&lt;&lt;endl; collection.close(); collection.open(filename, std::fstream::in | std::fstream::out | std::fstream::app); break; case 2: cout&lt;&lt;"Enter file name: "; cin&gt;&gt;filename; collection.open(filename, std::fstream::in | std::fstream::out | std::fstream::app); break; case 3: string lines; char menu; students student[10]; do{ ifstream collection(filename, std::fstream::in | std::fstream::out | std::fstream::app); if(collection.is_open()){ cout&lt;&lt;"Active File: ["&lt;&lt;filename&lt;&lt;"]"; system("cls"); while(getline(collection,lines)){ cout&lt;&lt;lines&lt;&lt;endl; } } collection.close(); cout&lt;&lt;"[A]dd [E]dit [D]elete [S]ort [F]ilter Sa[V]e e[X]it"; cin&gt;&gt;menu; if(menu=='A'){ string lines2; collection.open(filename,ios::app); system("cls"); ifstream collection(filename, std::fstream::in | std::fstream::out | std::fstream::app); if(collection.is_open()){ while(getline(collection,lines)){ cout&lt;&lt;lines&lt;&lt;endl; } } cout&lt;&lt;endl&lt;&lt;"Adding data to "&lt;&lt;filename&lt;&lt;endl; cout&lt;&lt;"Student ID: "; cin&gt;&gt;student[ctr].studentID; cout&lt;&lt;"Surname: "; cin&gt;&gt;student[ctr].surname; cout&lt;&lt;"Firstname: "; cin&gt;&gt;student[ctr].firstname; cout&lt;&lt;"Birthdate: "; cin&gt;&gt;student[ctr].birthdate; cout&lt;&lt;"Sex: "; cin&gt;&gt;student[ctr].sex; </code></pre> <p>Why do I keep getting errors here?</p> <pre><code> //data insertion code heree collection.open(filename, std::fstream::in | std::fstream::out | std::fstream::app); collection&lt;&lt;ctr&lt;&lt;"\t"student[ctr].studentID&lt;&lt;"\t"student[ctr].surname&lt;&lt;"\t"student[ctr].firstname&lt;&lt;"\t"student[ctr].birthdate&lt;&lt;"\t"student[ctr].sex&lt;&lt;endl; collection.close(); ctr++; }else if(menu=='E'){ }else if(menu=='D'){ }else if(menu=='F'){ }else if(menu=='V'){ cout&lt;&lt;"Saving file..."&lt;&lt;endl; collection.close(); cout&lt;&lt;"File saved."&lt;&lt;endl; system("pause"); }else{ cout&lt;&lt;"Invalid input."&lt;&lt;endl; system("pause"); }; }while(menu!='X'); break; } }while(choice!=4); } </code></pre> <p>Why am I getting error: no match for 'operator&lt;&lt;' in 'collection &lt;&lt; ctr'| errors? The code worked on the early part of the system and it just didn't work.</p>
0debug
static int decode_cabac_mb_type( H264Context *h ) { MpegEncContext * const s = &h->s; if( h->slice_type == I_TYPE ) { return decode_cabac_intra_mb_type(h, 3, 1); } else if( h->slice_type == P_TYPE ) { if( get_cabac( &h->cabac, &h->cabac_state[14] ) == 0 ) { if( get_cabac( &h->cabac, &h->cabac_state[15] ) == 0 ) { return 3 * get_cabac( &h->cabac, &h->cabac_state[16] ); } else { return 2 - get_cabac( &h->cabac, &h->cabac_state[17] ); } } else { return decode_cabac_intra_mb_type(h, 17, 0) + 5; } } else if( h->slice_type == B_TYPE ) { const int mba_xy = h->left_mb_xy[0]; const int mbb_xy = h->top_mb_xy; int ctx = 0; int bits; if( h->slice_table[mba_xy] == h->slice_num && !IS_DIRECT( s->current_picture.mb_type[mba_xy] ) ) ctx++; if( h->slice_table[mbb_xy] == h->slice_num && !IS_DIRECT( s->current_picture.mb_type[mbb_xy] ) ) ctx++; if( !get_cabac( &h->cabac, &h->cabac_state[27+ctx] ) ) return 0; if( !get_cabac( &h->cabac, &h->cabac_state[27+3] ) ) { return 1 + get_cabac( &h->cabac, &h->cabac_state[27+5] ); } bits = get_cabac( &h->cabac, &h->cabac_state[27+4] ) << 3; bits|= get_cabac( &h->cabac, &h->cabac_state[27+5] ) << 2; bits|= get_cabac( &h->cabac, &h->cabac_state[27+5] ) << 1; bits|= get_cabac( &h->cabac, &h->cabac_state[27+5] ); if( bits < 8 ) return bits + 3; else if( bits == 13 ) { return decode_cabac_intra_mb_type(h, 32, 0) + 23; } else if( bits == 14 ) return 11; else if( bits == 15 ) return 22; bits= ( bits<<1 ) | get_cabac( &h->cabac, &h->cabac_state[27+5] ); return bits - 4; } else { return -1; } }
1threat
static void mvp_init (CPUMIPSState *env, const mips_def_t *def) { env->mvp = qemu_mallocz(sizeof(CPUMIPSMVPContext)); env->mvp->CP0_MVPConf0 = (1 << CP0MVPC0_M) | (1 << CP0MVPC0_TLBS) | (0 << CP0MVPC0_GS) | (1 << CP0MVPC0_PCP) | (1 << CP0MVPC0_TCA) | (0x0 << CP0MVPC0_PVPE) | (0x04 << CP0MVPC0_PTC); if (!env->user_mode_only) env->mvp->CP0_MVPConf0 |= (env->tlb->nb_tlb << CP0MVPC0_PTLBE); env->mvp->CP0_MVPConf1 = (1 << CP0MVPC1_CIM) | (1 << CP0MVPC1_CIF) | (0x0 << CP0MVPC1_PCX) | (0x0 << CP0MVPC1_PCP2) | (0x1 << CP0MVPC1_PCP1); }
1threat
How does Airflow's BranchPythonOperator work? : <p>I'm struggling to understand how BranchPythonOperator in Airflow works. I know it's primarily used for branching, but am confused by the documentation as to what to pass into a task and what I need to pass/expect from the task upstream. </p> <p>Given the simple example in the documentation <a href="https://airflow.incubator.apache.org/concepts.html#branching" rel="noreferrer">on this page</a> what would the source code look like for the upstream task called <code>run_this_first</code> and the 2 downstream ones that are branched? How exactly does Airflow know to run <code>branch_a</code> instead of <code>branch_b</code>? Where does the upstream task's` output get noticed/read?</p>
0debug
Why it throws null pointer exception when object is initialized to null and then trying to access class method? : <pre><code>public class Abc { public static void main(String args[]) { def obj=null; obj.method(); } } class Def { void method() { System.out.println("class def-&gt;&gt;&gt; method()"); } } </code></pre> <p>The output of this code is generating a NullPointerException and why?</p>
0debug
Go Programming (Golang) reusing Struct to reduce heap usage : Please explain what is happening in following code. The part I don't understand is the service struct. The service struct is a wrapper around the APIClient struct. When the NewAPIClient is called, it is embedding the service struct inside and copying onto itself. I cannot seem to wrap my head around this. Please advise and elaborate. Thank you. type APIClient struct { cfg *Configuration // Reuse a single struct instead of // allocating one for each service on the heap. common service // API Services AccountApi *AccountApiService ContractApi *ContractApiService FYIApi *FYIApiService IBCustApi *IBCustApiService MarketDataApi *MarketDataApiService OrderApi *OrderApiService PnLApi *PnLApiService PortfolioApi *PortfolioApiService PortfolioAnalystApi *PortfolioAnalystApiService ScannerApi *ScannerApiService SessionApi *SessionApiService TradesApi *TradesApiService } type service struct { client *APIClient } func NewAPIClient(cfg *Configuration) *APIClient { if cfg.HTTPClient == nil { cfg.HTTPClient = http.DefaultClient } c := &APIClient{} c.cfg = cfg c.common.client = c c.AccountApi = (*AccountApiService)(&c.common) c.ContractApi = (*ContractApiService)(&c.common) c.FYIApi = (*FYIApiService)(&c.common) c.IBCustApi = (*IBCustApiService)(&c.common) c.MarketDataApi = (*MarketDataApiService)(&c.common) c.OrderApi = (*OrderApiService)(&c.common) c.PnLApi = (*PnLApiService)(&c.common) c.PortfolioApi = (*PortfolioApiService)(&c.common) c.PortfolioAnalystApi = (*PortfolioAnalystApiService)(&c.common) c.ScannerApi = (*ScannerApiService)(&c.common) c.SessionApi = (*SessionApiService)(&c.common) c.TradesApi = (*TradesApiService)(&c.common) return c }
0debug
What is the equivalent of C's double pointers in C++? : <p>I am a C/C++ newbie, so sorry if my question seems straightforward. </p> <p>It has always been claimed that pointers in C++ are useless. See for example the answer from Konrad Rudolph here <a href="https://softwareengineering.stackexchange.com/questions/56935/why-are-pointers-not-recommended-when-coding-with-c">https://softwareengineering.stackexchange.com/questions/56935/why-are-pointers-not-recommended-when-coding-with-c</a></p> <p>Below I have an example for which I am wondering how can I replace the C code by a C++ code without using any pointers:</p> <pre><code> double *A; double **a; A=new(std::nothrow) double[4]; a=new(std::nothrow) double*[2]; for (unsigned int q=0, k=0; k &lt; 2; k++) { a[k]=A + q; q+=2; } delete[] A; delete[] a; </code></pre> <p>The programmer codes up as above because he/she needs the pointer <code>a</code> to point to the pointer <code>A</code> so that when modifying the variable to which <code>A</code> points, he/she does not to modify <code>a</code>.</p> <p>Sometimes, the programmer does a <code>for loop</code> with a[k] from k={0,1,2,3}, and sometimes he does a double <code>for loop</code> a[i][j] from i,j={0,1}.</p> <p>How can I replace this by a C++ code without using pointers? </p>
0debug
How to fix Sublime text highlighting for react-tutorial? : <p>I recently started the <a href="https://facebook.github.io/react/docs/tutorial.html" rel="noreferrer">official reactjs tutorial</a> and noticed that the sublime text highlighting is completely screwed.</p> <p><a href="https://i.stack.imgur.com/XlpVV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XlpVV.png" alt="enter image description here"></a></p> <p>How can i fix this?</p>
0debug
how can i stop payment when resource is too high at gcp : i registered my card and there's many cash in bank. i have been hacked once before so i lost my free 300$ credits all. so i'm worrying if i hacked, resource is used too much, then i have to pay money too much..? right? is there any solution to prevent about this issue? plz. thanks :) uhm about alert by write steps(stack overflow's), i tried to make limit line about resource usage.. but there's also the message that "we don't stop server when you even use this service" it looked like just service sending the message for user.
0debug
want to add multipules tables to a frame dynamicly : hi want to add a number of tables to my frame , depending on the out come of something so put this int x=17; int y=95; for(int i=0;i<5;i++) { table[i].setBounds(x+50,y+50, 525, 44); contentPane.add(table[i]); } but nothing happing any one has some sorte of idia
0debug
Kafka consumer exception and offset commits : <p>I've been trying to do some POC work for Spring Kafka. Specifically, I wanted to experiment with what are the best practices in terms of dealing with errors while consuming messages within Kafka. </p> <p>I am wondering if anyone is able to help with:</p> <ol> <li>Sharing best practices surrounding what Kafka consumers should do when there is a failure</li> <li>Help me understand how AckMode Record works, and how to prevent commits to the Kafka offset queue when an exception is thrown in the listener method. </li> </ol> <p>The code example for 2 is given below:</p> <p>Given that AckMode is set to RECORD, which according to the <a href="http://docs.spring.io/spring-kafka/reference/htmlsingle/#_reference" rel="noreferrer">documentation</a>:</p> <blockquote> <p>commit the offset when the listener returns after processing the record.</p> </blockquote> <p>I would have thought the the offset would not be incremented if the listener method threw an exception. However, this was not the case when I tested it using the code/config/command combination below. The offset still gets updated, and the next message continues to be processed.</p> <p>My config:</p> <pre><code> private Map&lt;String, Object&gt; producerConfigs() { Map&lt;String, Object&gt; props = new HashMap&lt;&gt;(); props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.0.1:9092"); props.put(ProducerConfig.RETRIES_CONFIG, 0); props.put(ProducerConfig.BATCH_SIZE_CONFIG, 16384); props.put(ProducerConfig.LINGER_MS_CONFIG, 1); props.put(ProducerConfig.BUFFER_MEMORY_CONFIG, 33554432); props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, IntegerSerializer.class); props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class); return props; } @Bean ConcurrentKafkaListenerContainerFactory&lt;Integer, String&gt; kafkaListenerContainerFactory() { ConcurrentKafkaListenerContainerFactory&lt;Integer, String&gt; factory = new ConcurrentKafkaListenerContainerFactory&lt;&gt;(); factory.setConsumerFactory(new DefaultKafkaConsumerFactory&lt;&gt;(consumerConfigs())); factory.getContainerProperties().setAckMode(AbstractMessageListenerContainer.AckMode.RECORD); return factory; } </code></pre> <p>My code:</p> <pre><code>@Component public class KafkaMessageListener{ @KafkaListener(topicPartitions = {@TopicPartition( topic = "my-replicated-topic", partitionOffsets = @PartitionOffset(partition = "0", initialOffset = "0", relativeToCurrent = "true"))}) public void onReplicatedTopicMessage(ConsumerRecord&lt;Integer, String&gt; data) throws InterruptedException { throw new RuntimeException("Oops!"); } </code></pre> <p>Command to verify offset:</p> <pre><code>bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group test-group </code></pre> <p>I'm using kafka_2.12-0.10.2.0 and org.springframework.kafka:spring-kafka:1.1.3.RELEASE</p>
0debug
Strikethrough selected text inside android EditText : Is it possible to set the selected style of EditText to strikethrough in Android. Can anybody show me sample code to do this?
0debug
Getting cron to run on php:7-fpm image : <p>I'm pretty new to docker. I've set up a dockerfile using the php:7-fpm image. As well as this image being used to run my site, I want to add a cron to be able to perform regular tasks.</p> <p>I've created a cron, put it in the correct folder, and running <code>docker exec -ti myimage_php_1 /bin/bash</code> then <code>cron</code> or if I <code>tail</code> the log file all works fine. But I can't get this to work when the container is created, I don't want to have to manually start the cron obviously.</p> <p>From what I understand, I need to use <code>CMD</code> or <code>ENTRYPOINT</code> to run the <code>cron</code> command on startup, but every time I do this it stops my site working due to me overriding the necessary <code>CMD/ENTRYPOINT</code> functionality of the original php:7-fpm image. Is there a way to trigger both the cron command and continue as before with the php:7-fpm <code>CMD/ENTRYPOINT</code>s?</p>
0debug
What happens if we don't software testing : <p>It is really simple question.</p> <p>However, really wondering.</p> <p>I think even we don't software testing,</p> <p>Program will work.</p> <p>So, What happens if we don't software testing?</p>
0debug
static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVQcow2State *s = bs->opaque; int offset_in_cluster; int ret; unsigned int cur_bytes; uint64_t cluster_offset; QEMUIOVector hd_qiov; uint64_t bytes_done = 0; uint8_t *cluster_data = NULL; QCowL2Meta *l2meta = NULL; trace_qcow2_writev_start_req(qemu_coroutine_self(), offset, bytes); qemu_iovec_init(&hd_qiov, qiov->niov); s->cluster_cache_offset = -1; qemu_co_mutex_lock(&s->lock); while (bytes != 0) { l2meta = NULL; trace_qcow2_writev_start_part(qemu_coroutine_self()); offset_in_cluster = offset_into_cluster(s, offset); cur_bytes = MIN(bytes, INT_MAX); if (bs->encrypted) { cur_bytes = MIN(cur_bytes, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size - offset_in_cluster); } ret = qcow2_alloc_cluster_offset(bs, offset, &cur_bytes, &cluster_offset, &l2meta); if (ret < 0) { goto fail; } assert((cluster_offset & 511) == 0); qemu_iovec_reset(&hd_qiov); qemu_iovec_concat(&hd_qiov, qiov, bytes_done, cur_bytes); if (bs->encrypted) { Error *err = NULL; assert(s->crypto); if (!cluster_data) { cluster_data = qemu_try_blockalign(bs->file->bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); if (cluster_data == NULL) { ret = -ENOMEM; goto fail; } } assert(hd_qiov.size <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); qemu_iovec_to_buf(&hd_qiov, 0, cluster_data, hd_qiov.size); if (qcrypto_block_encrypt(s->crypto, offset >> BDRV_SECTOR_BITS, cluster_data, cur_bytes, &err) < 0) { error_free(err); ret = -EIO; goto fail; } qemu_iovec_reset(&hd_qiov); qemu_iovec_add(&hd_qiov, cluster_data, cur_bytes); } ret = qcow2_pre_write_overlap_check(bs, 0, cluster_offset + offset_in_cluster, cur_bytes); if (ret < 0) { goto fail; } if (!merge_cow(offset, cur_bytes, &hd_qiov, l2meta)) { qemu_co_mutex_unlock(&s->lock); BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); trace_qcow2_writev_data(qemu_coroutine_self(), cluster_offset + offset_in_cluster); ret = bdrv_co_pwritev(bs->file, cluster_offset + offset_in_cluster, cur_bytes, &hd_qiov, 0); qemu_co_mutex_lock(&s->lock); if (ret < 0) { goto fail; } } while (l2meta != NULL) { QCowL2Meta *next; ret = qcow2_alloc_cluster_link_l2(bs, l2meta); if (ret < 0) { goto fail; } if (l2meta->nb_clusters != 0) { QLIST_REMOVE(l2meta, next_in_flight); } qemu_co_queue_restart_all(&l2meta->dependent_requests); next = l2meta->next; g_free(l2meta); l2meta = next; } bytes -= cur_bytes; offset += cur_bytes; bytes_done += cur_bytes; trace_qcow2_writev_done_part(qemu_coroutine_self(), cur_bytes); } ret = 0; fail: qemu_co_mutex_unlock(&s->lock); while (l2meta != NULL) { QCowL2Meta *next; if (l2meta->nb_clusters != 0) { QLIST_REMOVE(l2meta, next_in_flight); } qemu_co_queue_restart_all(&l2meta->dependent_requests); next = l2meta->next; g_free(l2meta); l2meta = next; } qemu_iovec_destroy(&hd_qiov); qemu_vfree(cluster_data); trace_qcow2_writev_done_req(qemu_coroutine_self(), ret); return ret; }
1threat
static void get_pointer(Object *obj, Visitor *v, Property *prop, const char *(*print)(void *ptr), const char *name, Error **errp) { DeviceState *dev = DEVICE(obj); void **ptr = qdev_get_prop_ptr(dev, prop); char *p; p = (char *) (*ptr ? print(*ptr) : ""); visit_type_str(v, &p, name, errp); }
1threat
How i can run this mysql query in SQL Server? : <p>Basically I need to run this query in SQL Server. I executed in MySQL and it works fine.</p> <pre><code>SET @startID:=29; update test set ID=@startID:=@startID+1; </code></pre> <p>Thanks</p>
0debug
PPC_OP(subfme) { T0 = ~T0 + xer_ca - 1; if (T0 != -1) xer_ca = 1; RETURN(); }
1threat
how to get selected row value on the next page using jquery?php : I want to get selected `row` id on the next page.I want when i clcik on `button` then selected row id show in next page.Remember next window tab will open. Here is my jquery function.Its getting `ID` in `value` var when i click on row but i don't know ho to get this id on next page.But i want that ,first i select row then i click on button then `id` show on next tab window.Thanks [![enter image description here][1]][1] [1]: http://i.stack.imgur.com/LoEvb.jpg and here is my `jQUERY` function : $("#maintable tr").click(function(){ //alert($(this).hasClass("selected")); if ($(this).hasClass("selected")){ $(this).removeClass("selected"); var value=$(this).find('td:first').html(); alert(value); }else{ $(this).addClass("selected").siblings().removeClass("selected"); } });
0debug
static int vpc_read(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { BDRVVPCState *s = bs->opaque; int ret; int64_t offset; int64_t sectors, sectors_per_block; VHDFooter *footer = (VHDFooter *) s->footer_buf; if (cpu_to_be32(footer->type) == VHD_FIXED) { return bdrv_read(bs->file, sector_num, buf, nb_sectors); } while (nb_sectors > 0) { offset = get_sector_offset(bs, sector_num, 0); sectors_per_block = s->block_size >> BDRV_SECTOR_BITS; sectors = sectors_per_block - (sector_num % sectors_per_block); if (sectors > nb_sectors) { sectors = nb_sectors; } if (offset == -1) { memset(buf, 0, sectors * BDRV_SECTOR_SIZE); } else { ret = bdrv_pread(bs->file, offset, buf, sectors * BDRV_SECTOR_SIZE); if (ret != sectors * BDRV_SECTOR_SIZE) { return -1; } } nb_sectors -= sectors; sector_num += sectors; buf += sectors * BDRV_SECTOR_SIZE; } return 0; }
1threat
void ff_put_h264_qpel4_mc10_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hz_qrt_4w_msa(src - 2, stride, dst, stride, 4, 0); }
1threat
Change the default button load more text to show all in WordPress Woocommerce : <p>i would like to Change the default button load more text in show all WordPress Woocommerce</p> <p>You can see the products with their title below: <a href="https://i.stack.imgur.com/isIyS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/isIyS.png" alt="enter image description here"></a></p> <p>Website link:</p> <p><a href="https://asiatic.endroid1.com/" rel="nofollow noreferrer">https://asiatic.endroid1.com/</a></p>
0debug
static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr) { uint8_t checksum; memset(sdt_table, 0, sizeof(*sdt_table)); ACPI_READ_TABLE_HEADER(&sdt_table->header, addr); sdt_table->aml_len = le32_to_cpu(sdt_table->header.length) - sizeof(AcpiTableHeader); sdt_table->aml = g_malloc0(sdt_table->aml_len); ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr); checksum = acpi_calc_checksum((uint8_t *)sdt_table, sizeof(AcpiTableHeader)) + acpi_calc_checksum((uint8_t *)sdt_table->aml, sdt_table->aml_len); g_assert(!checksum); }
1threat
int ff_v4l2_context_set_status(V4L2Context* ctx, int cmd) { int type = ctx->type; int ret; ret = ioctl(ctx_to_m2mctx(ctx)->fd, cmd, &type); if (ret < 0) return AVERROR(errno); ctx->streamon = (cmd == VIDIOC_STREAMON); return 0; }
1threat
static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *picture, int *got_packet) { int xerr, i, ret, user_packet = !!pkt->data; struct xvid_context *x = avctx->priv_data; AVFrame *p = avctx->coded_frame; int mb_width = (avctx->width + 15) / 16; int mb_height = (avctx->height + 15) / 16; char *tmp; xvid_enc_frame_t xvid_enc_frame = { 0 }; xvid_enc_stats_t xvid_enc_stats = { 0 }; if ((ret = ff_alloc_packet2(avctx, pkt, mb_width*mb_height*MAX_MB_BYTES + FF_MIN_BUFFER_SIZE)) < 0) return ret; xvid_enc_frame.version = XVID_VERSION; xvid_enc_stats.version = XVID_VERSION; xvid_enc_frame.bitstream = pkt->data; xvid_enc_frame.length = pkt->size; if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) { av_log(avctx, AV_LOG_ERROR, "Xvid: Color spaces other than 420P not supported\n"); return AVERROR(EINVAL); } xvid_enc_frame.input.csp = XVID_CSP_PLANAR; for (i = 0; i < 4; i++) { xvid_enc_frame.input.plane[i] = picture->data[i]; xvid_enc_frame.input.stride[i] = picture->linesize[i]; } xvid_enc_frame.vop_flags = x->vop_flags; xvid_enc_frame.vol_flags = x->vol_flags; xvid_enc_frame.motion = x->me_flags; xvid_enc_frame.type = picture->pict_type == AV_PICTURE_TYPE_I ? XVID_TYPE_IVOP : picture->pict_type == AV_PICTURE_TYPE_P ? XVID_TYPE_PVOP : picture->pict_type == AV_PICTURE_TYPE_B ? XVID_TYPE_BVOP : XVID_TYPE_AUTO; if (avctx->sample_aspect_ratio.num < 0 || avctx->sample_aspect_ratio.num > 255 || avctx->sample_aspect_ratio.den < 0 || avctx->sample_aspect_ratio.den > 255) { av_log(avctx, AV_LOG_WARNING, "Invalid pixel aspect ratio %i/%i, limit is 255/255 reducing\n", avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den); av_reduce(&avctx->sample_aspect_ratio.num, &avctx->sample_aspect_ratio.den, avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den, 255); } xvid_enc_frame.par = XVID_PAR_EXT; xvid_enc_frame.par_width = avctx->sample_aspect_ratio.num; xvid_enc_frame.par_height = avctx->sample_aspect_ratio.den; if (x->qscale) xvid_enc_frame.quant = picture->quality / FF_QP2LAMBDA; else xvid_enc_frame.quant = 0; xvid_enc_frame.quant_intra_matrix = x->intra_matrix; xvid_enc_frame.quant_inter_matrix = x->inter_matrix; xerr = xvid_encore(x->encoder_handle, XVID_ENC_ENCODE, &xvid_enc_frame, &xvid_enc_stats); avctx->stats_out = NULL; if (x->twopassbuffer) { tmp = x->old_twopassbuffer; x->old_twopassbuffer = x->twopassbuffer; x->twopassbuffer = tmp; x->twopassbuffer[0] = 0; if (x->old_twopassbuffer[0] != 0) { avctx->stats_out = x->old_twopassbuffer; } } if (xerr > 0) { *got_packet = 1; p->quality = xvid_enc_stats.quant * FF_QP2LAMBDA; if (xvid_enc_stats.type == XVID_TYPE_PVOP) p->pict_type = AV_PICTURE_TYPE_P; else if (xvid_enc_stats.type == XVID_TYPE_BVOP) p->pict_type = AV_PICTURE_TYPE_B; else if (xvid_enc_stats.type == XVID_TYPE_SVOP) p->pict_type = AV_PICTURE_TYPE_S; else p->pict_type = AV_PICTURE_TYPE_I; if (xvid_enc_frame.out_flags & XVID_KEYFRAME) { p->key_frame = 1; pkt->flags |= AV_PKT_FLAG_KEY; if (x->quicktime_format) return xvid_strip_vol_header(avctx, pkt, xvid_enc_stats.hlength, xerr); } else p->key_frame = 0; pkt->size = xerr; return 0; } else { if (!user_packet) av_free_packet(pkt); if (!xerr) return 0; av_log(avctx, AV_LOG_ERROR, "Xvid: Encoding Error Occurred: %i\n", xerr); return AVERROR_EXTERNAL; } }
1threat
hello guys i am new to c# programming but i was just try to store input from the file in grid view by c# : console application and display them in grid view row and columns but i want to skip some lines in text file then i want to start storing in grid view ....please help me out of this ? mycode is using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace projectyj1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("time", typeof(String)); dt.Columns.Add("active_power_avg", typeof(Int32)); dt.Columns.Add("active_power_max", typeof(Int32)); dt.Columns.Add("active_power_min", typeof(Int32)); using (StreamReader sr = new StreamReader(@"D:\Data\mean\yo1.txt")) { String line; while ((line = sr.ReadLine()) != null) { string[] parts = line.Split(';'); var row = dt.NewRow(); for (int i = 0; i < parts.Length; i++) { row[i] = parts[i]; } // important thing! dt.Rows.Add(row); } sr.Close(); } > Blockquote
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
How to intergrate JIRA with our own AngularJS application : I want to integrate JIRA with my own application. So that I can perform operation like, - Create a ticket - Delete a ticket
0debug
Where is _.pluck() in lodash version 4? : <p>What happened to <code>pluck()</code> in lodash version 4? What is a suitable replacement?</p> <p>This syntax <code>_.pluck(users, 'firstName');</code> is simple to me. Seems that <code>_.map(users, function(user) { return user.firstName; }</code> would do the trick but it's not nearly as neat.</p>
0debug
Is it possible to do static partial classes? : <p>I want to take a class I have and split it up into several little classes so it becomes easier to maintain and read. But this class that I try to split using <code>partial</code> is a static class.</p> <p>I saw in an example on Stackoverflow that this was possible to do but when I do it, it keeps telling me that I cannot derive from a static class as static classes must derive from object.</p> <p>So I have this setup:</p> <pre><code>public static class Facade { // A few general methods that other partial facades will use } public static partial class MachineFacade : Facade { // Methods that are specifically for Machine Queries in our Database } </code></pre> <p>Any pointers? I want the <code>Facade</code> class to be static so that I don't have to initialize it before use.</p>
0debug
How to use apollo-link-http with apollo-upload-client? : <p>Im trying to figure out how to use <a href="https://www.npmjs.com/package/apollo-link-http" rel="noreferrer">apollo-link-http</a> with <a href="https://github.com/jaydenseric/apollo-upload-client" rel="noreferrer">apollo-upload-client</a>.</p> <p>Both create a terminating link, but how could I use those 2 together? In my index.js I have like this, but it wont work because both links are terminating =></p> <pre><code>const uploadLink = createUploadLink({ uri: process.env.REACT_APP_GRAPHQL_URL }); const httpLink = new HttpLink({ uri: process.env.REACT_APP_GRAPHQL_URL }); const client = new ApolloClient({ link: ApolloLink.from([ authLink, logoutLink, stateLink, uploadLink, httpLink ]), cache, }); </code></pre> <p>Any help? I have not much experience with Apollo/Graphql, but I would like to use the file upload component.</p>
0debug
static void postprocess_chroma(AVFrame *frame, int w, int h, int depth) { uint16_t *dstu = (uint16_t *)frame->data[1]; uint16_t *dstv = (uint16_t *)frame->data[2]; int16_t *srcu = (int16_t *)frame->data[1]; int16_t *srcv = (int16_t *)frame->data[2]; ptrdiff_t strideu = frame->linesize[1] / 2; ptrdiff_t stridev = frame->linesize[2] / 2; const int add = 1 << (depth - 1); const int shift = 16 - depth; int i, j; for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { dstu[i] = (add + srcu[i]) << shift; dstv[i] = (add + srcv[i]) << shift; } dstu += strideu; dstv += stridev; srcu += strideu; srcv += stridev; } }
1threat
"if a=b elif a !=b" doesn't work : <p>I have a table (named table) made of Nbin lists, each one of them containing Nbin elements. Some of those elements are (long) arrays, all the other elements are single 0s. Then I made this short code:</p> <pre><code>a=1 b=1 Nbin=3 for a in range(1,Nbin+1): for b in range(1,Nbin+1): if np.all(table[a][b]!=0) and np.all(a = b): s2=11 print a,'-',b,s2 elif np.all(table[a][b]!=0) and np.all(a != b): s2=12 print a,'-',b,s2 </code></pre> <p>Basically, the output I am expecting (for Nbin=3) is:</p> <pre><code>1 - 1 11 1 - 2 12 1 - 3 12 2 - 2 11 2 - 3 12 3 - 3 11 </code></pre> <p>but what I get is:</p> <pre><code>1 - 1 11 1 - 2 11 1 - 3 11 2 - 2 11 2 - 3 11 3 - 3 11 </code></pre> <p>Where did I do wrong?</p>
0debug
Cropping the strings in a list : <p>I have a list which the super-cropped version looks like this:</p> <pre><code>b=['5:18:00', '5:19:00', '5:20:00', '5:21:00', '11:31:00', '11:32:00', '11:33:00', '0:01:00', '0:02:00', '0:03:00'] </code></pre> <p>I want to keep the hours, and eliminate the rest. </p> <p>Your help is appreciated. </p>
0debug
Php foreach loop syntax : <p>Trying to check a list. Need some help with the foreach loop. Can't seem to understand the documentation for it.</p> <pre><code> foreach ($i = 0; $i &lt;= $List; $i++) { foreach($ii = 0; $ii2 &lt;= $List 2; ii++) { } // something } </code></pre>
0debug
Dockerfile and docker-compose not updating with new instructions : <p>When I try to build a container using docker-compose like so </p> <pre><code>nginx: build: ./nginx ports: - "5000:80" </code></pre> <p>the COPY instructions isnt working when my Dockerfile simply looks like this</p> <pre><code>FROM nginx #Expose port 80 EXPOSE 80 COPY html /usr/share/nginx/test #Start nginx server RUN service nginx restart </code></pre> <p>What could be the problem?</p>
0debug
c++ how to write a loop based on user input help please : my question is, how do I run a loop based on the user input? example: I ask how many students does the user want to calculate the grade. if the user enters 2 students then I will ask the user to input grades for exams, homework, quiz etc... after the program calculate the first student grade, how do I run the loop again for the second student? I tried using a while loop but it just goes to infinite loop. what I did was: cout << "number of student you want to calculate grade for" << endl; cin >> student; while (student) { ... ... ... ... } when I run this it goes to infinite loop. help!!!!
0debug
static int ppce500_prep_device_tree(MachineState *machine, PPCE500Params *params, hwaddr addr, hwaddr initrd_base, hwaddr initrd_size) { DeviceTreeParams *p = g_new(DeviceTreeParams, 1); p->machine = machine; p->params = *params; p->addr = addr; p->initrd_base = initrd_base; p->initrd_size = initrd_size; qemu_register_reset(ppce500_reset_device_tree, p); return ppce500_load_device_tree(machine, params, addr, initrd_base, initrd_size, true); }
1threat
SIGSEGV crash in iOS (Objective c) : Incident Identifier: 64E7437E-C37F-425C-8582-18A14C43F95A CrashReporter Key: b90a1226375d6bce87d7c4fc6288d7951058aec4 Hardware Model: iPad2,1 Process: LolMess [428] Path: /private/var/mobile/Containers/Bundle/Application/B1A322EE-F140-49CB-B1D2-84601F0BE962/LolMess.app/LolMess Identifier: com.mobulous.LolMess Version: 1 (1.0) Code Type: ARM (Native) Parent Process: launchd [1] Date/Time: 2016-03-14 17:55:49.49 +0530 Launch Time: 2016-03-14 17:42:36.36 +0530 OS Version: iOS 9.2.1 (13D15) Report Version: 104 **Exception Type: EXC_BAD_ACCESS (SIGSEGV)** Exception Subtype: KERN_INVALID_ADDRESS at 0x0002c9f0 Triggered by Thread: 24 Filtered syslog: None found Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0: 0 libsystem_kernel.dylib 0x245c0c24 mach_msg_trap + 20 1 libsystem_kernel.dylib 0x245c0a28 mach_msg + 40 2 CoreFoundation 0x24903354 __CFRunLoopServiceMachPort + 136 3 CoreFoundation 0x249016dc __CFRunLoopRun + 1036 4 CoreFoundation 0x24854bf8 CFRunLoopRunSpecific + 520 5 CoreFoundation 0x248549e4 CFRunLoopRunInMode + 108 6 GraphicsServices 0x25aa0ac8 GSEventRunModal + 160 7 UIKit 0x28ae4ba0 UIApplicationMain + 144 8 LolMess 0x002171d0 main (main.m:15) 9 libdyld.dylib 0x24503872 start + 2 Thread 1 name: Dispatch queue: com.apple.libdispatch-manager Thread 1: 0 libsystem_kernel.dylib 0x245d6320 kevent_qos + 24 1 libdispatch.dylib 0x244ce098 _dispatch_mgr_invoke + 256 2 libdispatch.dylib 0x244cddf6 _dispatch_mgr_thread$VARIANT$mp + 38 Thread 22: 0 libsystem_kernel.dylib 0x245c0c74 semaphore_wait_trap + 8 1 LolMess 0x0078ea9e thread_encoding_proc + 510 2 libsystem_pthread.dylib 0x2467985a _pthread_body + 138 3 libsystem_pthread.dylib 0x246797ce _pthread_start + 110 4 libsystem_pthread.dylib 0x24677724 thread_start + 8 Thread 23: 0 libsystem_kernel.dylib 0x245c0c74 semaphore_wait_trap + 8 1 LolMess 0x0078efda thread_loopfilter + 54 2 libsystem_pthread.dylib 0x2467985a _pthread_body + 138 3 libsystem_pthread.dylib 0x246797ce _pthread_start + 110 4 libsystem_pthread.dylib 0x24677724 thread_start + 8 Thread 24 Crashed: 0 LolMess 0x00781380 vp8_copy_mem16x16_neon + 16 1 LolMess 0x0077f828 vp8_build_inter16x16_predictors_mb + 188 2 LolMess 0x0077fa76 vp8_build_inter_predictors_mb + 414 3 LolMess 0x007a9f00 vp8_decode_frame + 11088 4 LolMess 0x007ab088 vp8dx_receive_compressed_data + 276 5 LolMess 0x007a537e vp8_decode + 1114 6 LolMess 0x007776ae vpx_codec_decode + 62 7 LolMess 0x007363ca -[VPXDecoder decode:rawOutFrame:inFrameSize:frameInfo:] (VPXDecoder.m:105) 8 LolMess 0x006f93ea -[RTPVideoHandler getDecodedVideoFrame:frameInfo:forStream:withOptions:] (RTPVideoHandler.m:1145) 9 LolMess 0x006f95ba -[RTPVideoHandler getDecodedVideoFrame:] (RTPVideoHandler.m:1184) 10 LolMess 0x00603b20 -[SCVideoCallController run:] (SCVideoCallController.m:896) 11 Foundation 0x25159164 __NSThread__start__ + 1148 12 libsystem_pthread.dylib 0x2467985a _pthread_body + 138 13 libsystem_pthread.dylib 0x246797ce _pthread_start + 110 14 libsystem_pthread.dylib 0x24677724 thread_start + 8 Error Formulating Crash Report: Failed while requesting activity/breadcrumb diagnostics Using C2callSdk in app
0debug
void tlb_flush(CPUState *env, int flush_global) { int i; #if defined(DEBUG_TLB) printf("tlb_flush:\n"); #endif env->current_tb = NULL; for(i = 0; i < CPU_TLB_SIZE; i++) { env->tlb_table[0][i].addr_read = -1; env->tlb_table[0][i].addr_write = -1; env->tlb_table[0][i].addr_code = -1; env->tlb_table[1][i].addr_read = -1; env->tlb_table[1][i].addr_write = -1; env->tlb_table[1][i].addr_code = -1; #if (NB_MMU_MODES >= 3) env->tlb_table[2][i].addr_read = -1; env->tlb_table[2][i].addr_write = -1; env->tlb_table[2][i].addr_code = -1; #if (NB_MMU_MODES == 4) env->tlb_table[3][i].addr_read = -1; env->tlb_table[3][i].addr_write = -1; env->tlb_table[3][i].addr_code = -1; #endif #endif } memset (env->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof (void *)); #ifdef USE_KQEMU if (env->kqemu_enabled) { kqemu_flush(env, flush_global); } #endif tlb_flush_count++; }
1threat
Using Vue with django : <p>I've recently started on some social media web site using Django. Im using the default <strong>django</strong> template engine to fill my pages. But at this moment, I want to add <strong>javascript</strong> to make the site more dynamic. This means:</p> <ul> <li>The header and footer is the <strong>same on each page</strong>. The header should have a dropdown menu, a search form that searches when you're typing.</li> <li>My current django application has a <strong>base template</strong> that has the header and footer HTML, since every page should have this.</li> <li>The site consists of <strong>multiple pages</strong>, think of index page, profile page, register page. Each of these pages have some common but also a lot of different dynamic components. For example the register page should have form validation on the fly, but the profile page doesn't need this. The profile page should have a status feed with infinite scrolling.</li> </ul> <p>I want to use Vue to deal with the dynamic components, but I don't know how I should get started. The application should not be a SPA.</p> <ul> <li>How should I <strong>structure</strong> the Vue code?</li> <li>How should I <strong>bundle</strong> this. Using Gulp? Or maybe <a href="https://github.com/owais/django-webpack-loader" rel="noreferrer">django-webpack-loader</a>?</li> <li>I should still be able to use the Django template tags, for example I want to be able to use <code>{% url 'index' %}</code> in the dropdown menu.</li> </ul>
0debug
Non Ascii Unicod encode and Decode in java : How we can do non ascii unicode encoding in java input: abc ആന and output we need to get is abc \u0d06\u0d28 Note:- Ascii and space not converted to unicode characters all other characters will we encoded This conversion needed because Server doesnot support Non ascii characters hence we need to convert to simple understandable way.
0debug
static void write_video_frame(AVFormatContext *oc, AVStream *st) { int ret; static struct SwsContext *sws_ctx; AVCodecContext *c = st->codec; if (frame_count >= STREAM_NB_FRAMES) { } else { if (c->pix_fmt != AV_PIX_FMT_YUV420P) { if (!sws_ctx) { sws_ctx = sws_getContext(c->width, c->height, AV_PIX_FMT_YUV420P, c->width, c->height, c->pix_fmt, sws_flags, NULL, NULL, NULL); if (!sws_ctx) { fprintf(stderr, "Could not initialize the conversion context\n"); exit(1); } } fill_yuv_image(&src_picture, frame_count, c->width, c->height); sws_scale(sws_ctx, (const uint8_t * const *)src_picture.data, src_picture.linesize, 0, c->height, dst_picture.data, dst_picture.linesize); } else { fill_yuv_image(&dst_picture, frame_count, c->width, c->height); } } if (oc->oformat->flags & AVFMT_RAWPICTURE) { AVPacket pkt; av_init_packet(&pkt); pkt.flags |= AV_PKT_FLAG_KEY; pkt.stream_index = st->index; pkt.data = dst_picture.data[0]; pkt.size = sizeof(AVPicture); ret = av_interleaved_write_frame(oc, &pkt); } else { AVPacket pkt = { 0 }; int got_packet; av_init_packet(&pkt); frame->pts = frame_count; ret = avcodec_encode_video2(c, &pkt, frame, &got_packet); if (ret < 0) { fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret)); exit(1); } if (got_packet) { ret = write_frame(oc, &c->time_base, st, &pkt); } else { ret = 0; } } if (ret != 0) { fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret)); exit(1); } frame_count++; }
1threat
in my code there is an error how to solve it : <p>What's wrong with my code</p> <pre><code>&lt;?php session_start(); require_once('koneksi.php'); $username = $_POST['username']; $pass = $_POST['password']; $cekuser = mysqli_query($conn,"SELECT * FROM user WHERE username = '$username'"); $hasil = mysqli_fetch_array($cekuser); if(mysqli_num_rows($cekuser) == 0) { echo "&lt;div align='center'&gt;Username Belum Terdaftar! &lt;a href='login.php'&gt;Back&lt;/a&gt;&lt;/div&gt;; } else{ if($pass&lt;&gt;$hasil['$username]'){ echo "&lt;div align='center'&gt;Password Salah! &lt;a href='login.php'&gt;Back&lt;/a&gt;&lt;/div&gt;; } else{ $_SESSION['username']=$hasil['username']; header('location:index.php'); } } ?&gt; </code></pre> <p>I get an error message like this</p> <p>Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /storage/emulated/0/htdocs/proseslogin.php on line 11</p>
0debug
IntelliJ IDEA adding JDK 10: “The selected directory is not a valid home for JDK” : <p>I'm creating this question only because the duplicate questions I found were marked with <a href="https://stackoverflow.com/questions/21713414/intellij-idea-the-selected-directory-is-not-a-valid-home-for-jdk">Windows</a> and <a href="https://stackoverflow.com/questions/30116439/selected-directory-is-not-a-valid-home-for-jdk-intellij-idea-on-ubuntu/30116654">Ubuntu</a> respectively, whereas I am experiencing this issue on macOS</p> <p>I have IntelliJ Ultimate 2017.2 installed, with JDK 8 added, and want to add JDK 10. After downloading and installing Oracle's JDK 10, and attempting to add <code>/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home</code> as a new JDK to IntelliJ, I got the error message</p> <blockquote> <p>The selected directory is not a valid home for JDK</p> </blockquote> <p>despite the fact that the path and file permissions of this JDK 10 directory were seemingly all aligned with the JDK 8 ones.</p>
0debug
Need A Modulus Formula In Php : <p>I am creating a fee calculator and fee is calculated on based of capital. So I want a formula in php.</p> <p>if capital is &lt;=1000000 then fee is 1000 if capital is 1100000 - 2000000 fee is 2000 if capital is 2100000 - 3000000 fee is 3000 if capital is 3100000 - 4000000 fee is 4000 if capital is 4100000 - 5000000 fee is 5000 and so on so what i want is i want a formula that will give me a fee of 1000 per 10 Lakh </p>
0debug
static void set_dirty_tracking(void) { BlkMigDevState *bmds; QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE); } }
1threat
How to create organizational contact using MS Graph or Office 365 REST API : <p>Office 365 administration center allows to create <strong>organizational</strong> contacts which are shared with all users in organization.</p> <p>In MS Graph documentation API of this functionality is badly documented and located in BETA section. Moreover, there is no command to create such a contact: <a href="https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/orgcontact" rel="noreferrer">https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/orgcontact</a></p> <p>It looks like in Graph this functionality was not implemented. Using typical POST request to the /beta/contacts ends with an error response in Json structure: <code>Unsupported resource type 'Contact' for operation 'Create'.</code></p> <p>Note 1: I don't have any user logged in. My application uses service/daemon authentication.</p> <p>Is there any other way to create <strong>organizational</strong> contact?</p>
0debug
null response using Retrofit Library in android : Here is my JSONArray Response from Web service: [Show Image][1] [1]: https://i.stack.imgur.com/ncGxg.png And Class Java : public class Product { private int id,price,discount; private String name,image,description,discount_type,discount_exp; @SerializedName("products") private List<Product> products; public Product() { } } response is null
0debug
Display numbers from 0 to X vis versa : <p>i need your help in this puzzle: i want to take an input from the user as X and display numbers from 0 to X and from X to 0. the trick is to use only one variable. how could i solve this in java</p>
0debug