problem
stringlengths
26
131k
labels
class label
2 classes
What is an array, what is the difference between array and objects and when and why use an array? : <p>Hello I have a few questions: Why is an array? Why is the difference between array and object? Why and when I need to use an array? Thanks for helping :);)</p>
0debug
How to decode base64 in python3 : <p>I have a base64 encrypt code, and I can't decode in python3.5</p> <pre><code>import base64 code = "YWRtaW46MjAyY2I5NjJhYzU5MDc1Yjk2NGIwNzE1MmQyMzRiNzA" # Unencrypt is 202cb962ac59075b964b07152d234b70 base64.b64decode(code) </code></pre> <p>Result:</p> <pre><code>binascii.Error: Incorrect padding </code></pre> <p>But same website(<a href="http://www.base64decode.org" rel="noreferrer">base64decode</a>) can decode it, </p> <p>Please anybody can tell me why, and how to use python3.5 decode it?</p> <p>Thanks</p>
0debug
how to create a function to get sum of Colors given in this array.....expected output=('RED'=>21,'GREEN=>'..etc) in php : ' $sales = array ( 'FIRST'=> array('RED'=> array(9,3),'GREEN'=> array(4,5,8,2)), 'SECOND'=> array('RED'=> array(3,5,5,2),'YELLOW'=> array(4,2,5)), 'THIRD'=> array('BLUE'=> array(1,2,4),'RED'=> array(9,4,6)), 'FOUR'=> array('BLUE'=> array(2,3,3,5),'BLACK'=> array(4,5,8,9)));'
0debug
void gen_intermediate_code(CPUState *cs, TranslationBlock * tb) { CPUSPARCState *env = cs->env_ptr; target_ulong pc_start, last_pc; DisasContext dc1, *dc = &dc1; int num_insns; int max_insns; unsigned int insn; memset(dc, 0, sizeof(DisasContext)); dc->tb = tb; pc_start = tb->pc; dc->pc = pc_start; last_pc = dc->pc; dc->npc = (target_ulong) tb->cs_base; dc->cc_op = CC_OP_DYNAMIC; dc->mem_idx = tb->flags & TB_FLAG_MMU_MASK; dc->def = &env->def; dc->fpu_enabled = tb_fpu_enabled(tb->flags); dc->address_mask_32bit = tb_am_enabled(tb->flags); dc->singlestep = (cs->singlestep_enabled || singlestep); #ifndef CONFIG_USER_ONLY dc->supervisor = (tb->flags & TB_FLAG_SUPER) != 0; #endif #ifdef TARGET_SPARC64 dc->fprs_dirty = 0; dc->asi = (tb->flags >> TB_FLAG_ASI_SHIFT) & 0xff; #ifndef CONFIG_USER_ONLY dc->hypervisor = (tb->flags & TB_FLAG_HYPER) != 0; #endif #endif num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } if (max_insns > TCG_MAX_INSNS) { max_insns = TCG_MAX_INSNS; } gen_tb_start(tb); do { if (dc->npc & JUMP_PC) { assert(dc->jump_pc[1] == dc->pc + 4); tcg_gen_insn_start(dc->pc, dc->jump_pc[0] | JUMP_PC); } else { tcg_gen_insn_start(dc->pc, dc->npc); } num_insns++; last_pc = dc->pc; if (unlikely(cpu_breakpoint_test(cs, dc->pc, BP_ANY))) { if (dc->pc != pc_start) { save_state(dc); } gen_helper_debug(cpu_env); tcg_gen_exit_tb(0); dc->is_br = 1; goto exit_gen_loop; } if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } insn = cpu_ldl_code(env, dc->pc); disas_sparc_insn(dc, insn); if (dc->is_br) break; if (dc->pc != (last_pc + 4)) break; if ((dc->pc & (TARGET_PAGE_SIZE - 1)) == 0) break; if (dc->singlestep) { break; } } while (!tcg_op_buf_full() && (dc->pc - pc_start) < (TARGET_PAGE_SIZE - 32) && num_insns < max_insns); exit_gen_loop: if (tb->cflags & CF_LAST_IO) { gen_io_end(); } if (!dc->is_br) { if (dc->pc != DYNAMIC_PC && (dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) { gen_goto_tb(dc, 0, dc->pc, dc->npc); } else { if (dc->pc != DYNAMIC_PC) { tcg_gen_movi_tl(cpu_pc, dc->pc); } save_npc(dc); tcg_gen_exit_tb(0); } } gen_tb_end(tb, num_insns); tb->size = last_pc + 4 - pc_start; tb->icount = num_insns; #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("--------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(cs, pc_start, last_pc + 4 - pc_start, 0); qemu_log("\n"); qemu_log_unlock(); } #endif }
1threat
static int encode_plane(AVCodecContext *avctx, uint8_t *src, uint8_t *dst, int step, int stride, int width, int height, PutByteContext *pb) { UtvideoContext *c = avctx->priv_data; uint8_t lengths[256]; uint32_t counts[256] = { 0 }; HuffEntry he[256]; uint32_t offset = 0, slice_len = 0; int i, sstart, send = 0; int symbol; switch (c->frame_pred) { case PRED_NONE: for (i = 0; i < c->slices; i++) { sstart = send; send = height * (i + 1) / c->slices; write_plane(src + sstart * stride, dst + sstart * width, step, stride, width, send - sstart); } break; case PRED_LEFT: for (i = 0; i < c->slices; i++) { sstart = send; send = height * (i + 1) / c->slices; left_predict(src + sstart * stride, dst + sstart * width, step, stride, width, send - sstart); } break; case PRED_MEDIAN: for (i = 0; i < c->slices; i++) { sstart = send; send = height * (i + 1) / c->slices; median_predict(src + sstart * stride, dst + sstart * width, step, stride, width, send - sstart); } break; default: av_log(avctx, AV_LOG_ERROR, "Unknown prediction mode: %d\n", c->frame_pred); return AVERROR_OPTION_NOT_FOUND; } count_usage(dst, width, height, counts); for (symbol = 0; symbol < 256; symbol++) { if (counts[symbol]) { if (counts[symbol] == width * height) { for (i = 0; i < 256; i++) { if (i == symbol) bytestream2_put_byte(pb, 0); else bytestream2_put_byte(pb, 0xFF); } for (i = 0; i < c->slices; i++) bytestream2_put_le32(pb, 0); return 0; } break; } } calculate_code_lengths(lengths, counts); for (i = 0; i < 256; i++) { bytestream2_put_byte(pb, lengths[i]); he[i].len = lengths[i]; he[i].sym = i; } calculate_codes(he); send = 0; for (i = 0; i < c->slices; i++) { sstart = send; send = height * (i + 1) / c->slices; offset += write_huff_codes(dst + sstart * width, c->slice_bits, width * (send - sstart), width, send - sstart, he) >> 3; slice_len = offset - slice_len; c->dsp.bswap_buf((uint32_t *) c->slice_bits, (uint32_t *) c->slice_bits, slice_len >> 2); bytestream2_put_le32(pb, offset); bytestream2_seek_p(pb, 4 * (c->slices - i - 1) + offset - slice_len, SEEK_CUR); bytestream2_put_buffer(pb, c->slice_bits, slice_len); bytestream2_seek_p(pb, -4 * (c->slices - i - 1) - offset, SEEK_CUR); slice_len = offset; } bytestream2_seek_p(pb, offset, SEEK_CUR); return 0; }
1threat
long vnc_client_write_sasl(VncState *vs) { long ret; VNC_DEBUG("Write SASL: Pending output %p size %zd offset %zd " "Encoded: %p size %d offset %d\n", vs->output.buffer, vs->output.capacity, vs->output.offset, vs->sasl.encoded, vs->sasl.encodedLength, vs->sasl.encodedOffset); if (!vs->sasl.encoded) { int err; err = sasl_encode(vs->sasl.conn, (char *)vs->output.buffer, vs->output.offset, (const char **)&vs->sasl.encoded, &vs->sasl.encodedLength); if (err != SASL_OK) return vnc_client_io_error(vs, -1, NULL); vs->sasl.encodedRawLength = vs->output.offset; vs->sasl.encodedOffset = 0; ret = vnc_client_write_buf(vs, vs->sasl.encoded + vs->sasl.encodedOffset, vs->sasl.encodedLength - vs->sasl.encodedOffset); if (!ret) return 0; vs->sasl.encodedOffset += ret; if (vs->sasl.encodedOffset == vs->sasl.encodedLength) { vs->output.offset -= vs->sasl.encodedRawLength; vs->sasl.encoded = NULL; vs->sasl.encodedOffset = vs->sasl.encodedLength = 0; if (vs->output.offset == 0) { if (vs->ioc_tag) { g_source_remove(vs->ioc_tag); vs->ioc_tag = qio_channel_add_watch( vs->ioc, G_IO_IN, vnc_client_io, vs, NULL); return ret;
1threat
VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf) { VirtIOSCSI *s; static int virtio_scsi_id; size_t sz; int i; sz = sizeof(VirtIOSCSI) + proxyconf->num_queues * sizeof(VirtQueue *); s = (VirtIOSCSI *)virtio_common_init("virtio-scsi", VIRTIO_ID_SCSI, sizeof(VirtIOSCSIConfig), sz); s->qdev = dev; s->conf = proxyconf; s->vdev.get_config = virtio_scsi_get_config; s->vdev.set_config = virtio_scsi_set_config; s->vdev.get_features = virtio_scsi_get_features; s->vdev.reset = virtio_scsi_reset; s->ctrl_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_ctrl); s->event_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE, NULL); for (i = 0; i < s->conf->num_queues; i++) { s->cmd_vqs[i] = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_cmd); } scsi_bus_new(&s->bus, dev, &virtio_scsi_scsi_info); if (!dev->hotplugged) { scsi_bus_legacy_handle_cmdline(&s->bus); } register_savevm(dev, "virtio-scsi", virtio_scsi_id++, 1, virtio_scsi_save, virtio_scsi_load, s); return &s->vdev; }
1threat
void ff_check_pixfmt_descriptors(void){ int i, j; for (i=0; i<FF_ARRAY_ELEMS(av_pix_fmt_descriptors); i++) { const AVPixFmtDescriptor *d = &av_pix_fmt_descriptors[i]; uint8_t fill[4][8+6+3] = {{0}}; uint8_t *data[4] = {fill[0], fill[1], fill[2], fill[3]}; int linesize[4] = {0,0,0,0}; uint16_t tmp[2]; if (!d->name && !d->nb_components && !d->log2_chroma_w && !d->log2_chroma_h && !d->flags) continue; av_assert0(d->log2_chroma_w <= 3); av_assert0(d->log2_chroma_h <= 3); av_assert0(d->nb_components <= 4); av_assert0(d->name && d->name[0]); av_assert0((d->nb_components==4 || d->nb_components==2) == !!(d->flags & AV_PIX_FMT_FLAG_ALPHA)); av_assert2(av_get_pix_fmt(d->name) == i); for (j=0; j<FF_ARRAY_ELEMS(d->comp); j++) { const AVComponentDescriptor *c = &d->comp[j]; if(j>=d->nb_components) { av_assert0(!c->plane && !c->step_minus1 && !c->offset_plus1 && !c->shift && !c->depth_minus1); continue; } if (d->flags & AV_PIX_FMT_FLAG_BITSTREAM) { av_assert0(c->step_minus1 >= c->depth_minus1); } else { av_assert0(8*(c->step_minus1+1) >= c->depth_minus1+1); } av_read_image_line(tmp, (void*)data, linesize, d, 0, 0, j, 2, 0); if (!strncmp(d->name, "bayer_", 6)) continue; av_assert0(tmp[0] == 0 && tmp[1] == 0); tmp[0] = tmp[1] = (1<<(c->depth_minus1 + 1)) - 1; av_write_image_line(tmp, data, linesize, d, 0, 0, j, 2); } } }
1threat
int cpu_ppc_handle_mmu_fault (CPUState *env, target_ulong address, int rw, int mmu_idx, int is_softmmu) { mmu_ctx_t ctx; int access_type; int ret = 0; if (rw == 2) { rw = 0; access_type = ACCESS_CODE; } else { access_type = env->access_type; } ret = get_physical_address(env, &ctx, address, rw, access_type); if (ret == 0) { ret = tlb_set_page_exec(env, address & TARGET_PAGE_MASK, ctx.raddr & TARGET_PAGE_MASK, ctx.prot, mmu_idx, is_softmmu); } else if (ret < 0) { LOG_MMU_STATE(env); if (access_type == ACCESS_CODE) { switch (ret) { case -1: switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: env->exception_index = POWERPC_EXCP_IFTLB; env->error_code = 1 << 18; env->spr[SPR_IMISS] = address; env->spr[SPR_ICMP] = 0x80000000 | ctx.ptem; goto tlb_miss; case POWERPC_MMU_SOFT_74xx: env->exception_index = POWERPC_EXCP_IFTLB; goto tlb_miss_74xx; case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_SOFT_4xx_Z: env->exception_index = POWERPC_EXCP_ITLB; env->error_code = 0; env->spr[SPR_40x_DEAR] = address; env->spr[SPR_40x_ESR] = 0x00000000; break; case POWERPC_MMU_32B: case POWERPC_MMU_601: #if defined(TARGET_PPC64) case POWERPC_MMU_620: case POWERPC_MMU_64B: #endif env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x40000000; break; case POWERPC_MMU_BOOKE: cpu_abort(env, "BookE MMU model is not implemented\n"); return -1; case POWERPC_MMU_BOOKE_FSL: cpu_abort(env, "BookE FSL MMU model is not implemented\n"); return -1; case POWERPC_MMU_MPC8xx: cpu_abort(env, "MPC8xx MMU model is not implemented\n"); break; case POWERPC_MMU_REAL: cpu_abort(env, "PowerPC in real mode should never raise " "any MMU exceptions\n"); return -1; default: cpu_abort(env, "Unknown or invalid MMU model\n"); return -1; } break; case -2: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x08000000; break; case -3: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; case -4: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; #if defined(TARGET_PPC64) case -5: if (env->mmu_model == POWERPC_MMU_620) { env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x40000000; } else { env->exception_index = POWERPC_EXCP_ISEG; env->error_code = 0; } break; #endif } } else { switch (ret) { case -1: switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: if (rw == 1) { env->exception_index = POWERPC_EXCP_DSTLB; env->error_code = 1 << 16; } else { env->exception_index = POWERPC_EXCP_DLTLB; env->error_code = 0; } env->spr[SPR_DMISS] = address; env->spr[SPR_DCMP] = 0x80000000 | ctx.ptem; tlb_miss: env->error_code |= ctx.key << 19; env->spr[SPR_HASH1] = ctx.pg_addr[0]; env->spr[SPR_HASH2] = ctx.pg_addr[1]; break; case POWERPC_MMU_SOFT_74xx: if (rw == 1) { env->exception_index = POWERPC_EXCP_DSTLB; } else { env->exception_index = POWERPC_EXCP_DLTLB; } tlb_miss_74xx: env->error_code = ctx.key << 19; env->spr[SPR_TLBMISS] = (address & ~((target_ulong)0x3)) | ((env->last_way + 1) & (env->nb_ways - 1)); env->spr[SPR_PTEHI] = 0x80000000 | ctx.ptem; break; case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_SOFT_4xx_Z: env->exception_index = POWERPC_EXCP_DTLB; env->error_code = 0; env->spr[SPR_40x_DEAR] = address; if (rw) env->spr[SPR_40x_ESR] = 0x00800000; else env->spr[SPR_40x_ESR] = 0x00000000; break; case POWERPC_MMU_32B: case POWERPC_MMU_601: #if defined(TARGET_PPC64) case POWERPC_MMU_620: case POWERPC_MMU_64B: #endif env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x42000000; else env->spr[SPR_DSISR] = 0x40000000; break; case POWERPC_MMU_MPC8xx: cpu_abort(env, "MPC8xx MMU model is not implemented\n"); break; case POWERPC_MMU_BOOKE: cpu_abort(env, "BookE MMU model is not implemented\n"); return -1; case POWERPC_MMU_BOOKE_FSL: cpu_abort(env, "BookE FSL MMU model is not implemented\n"); return -1; case POWERPC_MMU_REAL: cpu_abort(env, "PowerPC in real mode should never raise " "any MMU exceptions\n"); return -1; default: cpu_abort(env, "Unknown or invalid MMU model\n"); return -1; } break; case -2: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x0A000000; else env->spr[SPR_DSISR] = 0x08000000; break; case -4: switch (access_type) { case ACCESS_FLOAT: env->exception_index = POWERPC_EXCP_ALIGN; env->error_code = POWERPC_EXCP_ALIGN_FP; env->spr[SPR_DAR] = address; break; case ACCESS_RES: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x06000000; else env->spr[SPR_DSISR] = 0x04000000; break; case ACCESS_EXT: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x06100000; else env->spr[SPR_DSISR] = 0x04100000; break; default: printf("DSI: invalid exception (%d)\n", ret); env->exception_index = POWERPC_EXCP_PROGRAM; env->error_code = POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL; env->spr[SPR_DAR] = address; break; } break; #if defined(TARGET_PPC64) case -5: if (env->mmu_model == POWERPC_MMU_620) { env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x42000000; else env->spr[SPR_DSISR] = 0x40000000; } else { env->exception_index = POWERPC_EXCP_DSEG; env->error_code = 0; env->spr[SPR_DAR] = address; } break; #endif } } #if 0 printf("%s: set exception to %d %02x\n", __func__, env->exception, env->error_code); #endif ret = 1; } return ret; }
1threat
creating a linux terminal css style pre tag for showcasing unix commands : What I am trying to do is create a pre tag that will look like a bash terminal - black background and white letter, mono spaced font. <pre class="bash"> -bash-3.2$ groups unixuser feegroup figroup fogroup fumgroup </pre> I can't believe that I am like the only person to try and do this on the interwebs. pre.bash { background-color: black; color: white; font-size: medium ; font-family: Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace; display: inline; } I suppose if I were better at HTML CSS I could show you the result in this page - but if you run it you will see that the background color only extend the length of the content in the <pre> tag. So this does not look like a bash terminal. I need a box which will be a long as the longest line in the <pre> content.
0debug
static void decode_opc (CPUState *env, DisasContext *ctx, int *is_branch) { int32_t offset; int rs, rt, rd, sa; uint32_t op, op1, op2; int16_t imm; if (ctx->pc & 0x3) { env->CP0_BadVAddr = ctx->pc; generate_exception(ctx, EXCP_AdEL); return; } if ((ctx->hflags & MIPS_HFLAG_BMASK_BASE) == MIPS_HFLAG_BL) { int l1 = gen_new_label(); MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", ctx->pc + 4); tcg_gen_brcondi_tl(TCG_COND_NE, bcond, 0, l1); tcg_gen_movi_i32(hflags, ctx->hflags & ~MIPS_HFLAG_BMASK); gen_goto_tb(ctx, 1, ctx->pc + 4); gen_set_label(l1); } if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP))) tcg_gen_debug_insn_start(ctx->pc); op = MASK_OP_MAJOR(ctx->opcode); rs = (ctx->opcode >> 21) & 0x1f; rt = (ctx->opcode >> 16) & 0x1f; rd = (ctx->opcode >> 11) & 0x1f; sa = (ctx->opcode >> 6) & 0x1f; imm = (int16_t)ctx->opcode; switch (op) { case OPC_SPECIAL: op1 = MASK_SPECIAL(ctx->opcode); switch (op1) { case OPC_SLL: case OPC_SRA: gen_shift_imm(env, ctx, op1, rd, rt, sa); break; case OPC_SRL: switch ((ctx->opcode >> 21) & 0x1f) { case 1: if (env->insn_flags & ISA_MIPS32R2) { op1 = OPC_ROTR; } case 0: gen_shift_imm(env, ctx, op1, rd, rt, sa); break; default: generate_exception(ctx, EXCP_RI); break; } break; case OPC_MOVN: case OPC_MOVZ: check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32 | INSN_LOONGSON2E | INSN_LOONGSON2F); gen_cond_move(env, op1, rd, rs, rt); break; case OPC_ADD ... OPC_SUBU: gen_arith(env, ctx, op1, rd, rs, rt); break; case OPC_SLLV: case OPC_SRAV: gen_shift(env, ctx, op1, rd, rs, rt); break; case OPC_SRLV: switch ((ctx->opcode >> 6) & 0x1f) { case 1: if (env->insn_flags & ISA_MIPS32R2) { op1 = OPC_ROTRV; } case 0: gen_shift(env, ctx, op1, rd, rs, rt); break; default: generate_exception(ctx, EXCP_RI); break; } break; case OPC_SLT: case OPC_SLTU: gen_slt(env, op1, rd, rs, rt); break; case OPC_AND: case OPC_OR: case OPC_NOR: case OPC_XOR: gen_logic(env, op1, rd, rs, rt); break; case OPC_MULT ... OPC_DIVU: if (sa) { check_insn(env, ctx, INSN_VR54XX); op1 = MASK_MUL_VR54XX(ctx->opcode); gen_mul_vr54xx(ctx, op1, rd, rs, rt); } else gen_muldiv(ctx, op1, rs, rt); break; case OPC_JR ... OPC_JALR: gen_compute_branch(ctx, op1, 4, rs, rd, sa); *is_branch = 1; break; case OPC_TGE ... OPC_TEQ: case OPC_TNE: gen_trap(ctx, op1, rs, rt, -1); break; case OPC_MFHI: case OPC_MFLO: gen_HILO(ctx, op1, rd); break; case OPC_MTHI: case OPC_MTLO: gen_HILO(ctx, op1, rs); break; case OPC_PMON: #ifdef MIPS_STRICT_STANDARD MIPS_INVAL("PMON / selsl"); generate_exception(ctx, EXCP_RI); #else gen_helper_0i(pmon, sa); #endif break; case OPC_SYSCALL: generate_exception(ctx, EXCP_SYSCALL); ctx->bstate = BS_STOP; break; case OPC_BREAK: generate_exception(ctx, EXCP_BREAK); break; case OPC_SPIM: #ifdef MIPS_STRICT_STANDARD MIPS_INVAL("SPIM"); generate_exception(ctx, EXCP_RI); #else MIPS_INVAL("spim (unofficial)"); generate_exception(ctx, EXCP_RI); #endif break; case OPC_SYNC: break; case OPC_MOVCI: check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); if (env->CP0_Config1 & (1 << CP0C1_FP)) { check_cp1_enabled(ctx); gen_movci(ctx, rd, rs, (ctx->opcode >> 18) & 0x7, (ctx->opcode >> 16) & 1); } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; #if defined(TARGET_MIPS64) case OPC_DSLL: case OPC_DSRA: case OPC_DSLL32: case OPC_DSRA32: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_shift_imm(env, ctx, op1, rd, rt, sa); break; case OPC_DSRL: switch ((ctx->opcode >> 21) & 0x1f) { case 1: if (env->insn_flags & ISA_MIPS32R2) { op1 = OPC_DROTR; } case 0: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_shift_imm(env, ctx, op1, rd, rt, sa); break; default: generate_exception(ctx, EXCP_RI); break; } break; case OPC_DSRL32: switch ((ctx->opcode >> 21) & 0x1f) { case 1: if (env->insn_flags & ISA_MIPS32R2) { op1 = OPC_DROTR32; } case 0: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_shift_imm(env, ctx, op1, rd, rt, sa); break; default: generate_exception(ctx, EXCP_RI); break; } break; case OPC_DADD ... OPC_DSUBU: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_arith(env, ctx, op1, rd, rs, rt); break; case OPC_DSLLV: case OPC_DSRAV: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_shift(env, ctx, op1, rd, rs, rt); break; case OPC_DSRLV: switch ((ctx->opcode >> 6) & 0x1f) { case 1: if (env->insn_flags & ISA_MIPS32R2) { op1 = OPC_DROTRV; } case 0: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_shift(env, ctx, op1, rd, rs, rt); break; default: generate_exception(ctx, EXCP_RI); break; } break; case OPC_DMULT ... OPC_DDIVU: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_muldiv(ctx, op1, rs, rt); break; #endif default: MIPS_INVAL("special"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_SPECIAL2: op1 = MASK_SPECIAL2(ctx->opcode); switch (op1) { case OPC_MADD ... OPC_MADDU: case OPC_MSUB ... OPC_MSUBU: check_insn(env, ctx, ISA_MIPS32); gen_muldiv(ctx, op1, rs, rt); break; case OPC_MUL: gen_arith(env, ctx, op1, rd, rs, rt); break; case OPC_CLO: case OPC_CLZ: check_insn(env, ctx, ISA_MIPS32); gen_cl(ctx, op1, rd, rs); break; case OPC_SDBBP: check_insn(env, ctx, ISA_MIPS32); if (!(ctx->hflags & MIPS_HFLAG_DM)) { generate_exception(ctx, EXCP_DBp); } else { generate_exception(ctx, EXCP_DBp); } break; case OPC_DIV_G_2F: case OPC_DIVU_G_2F: case OPC_MULT_G_2F: case OPC_MULTU_G_2F: case OPC_MOD_G_2F: case OPC_MODU_G_2F: check_insn(env, ctx, INSN_LOONGSON2F); gen_loongson_integer(ctx, op1, rd, rs, rt); break; #if defined(TARGET_MIPS64) case OPC_DCLO: case OPC_DCLZ: check_insn(env, ctx, ISA_MIPS64); check_mips_64(ctx); gen_cl(ctx, op1, rd, rs); break; case OPC_DMULT_G_2F: case OPC_DMULTU_G_2F: case OPC_DDIV_G_2F: case OPC_DDIVU_G_2F: case OPC_DMOD_G_2F: case OPC_DMODU_G_2F: check_insn(env, ctx, INSN_LOONGSON2F); gen_loongson_integer(ctx, op1, rd, rs, rt); break; #endif default: MIPS_INVAL("special2"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_SPECIAL3: op1 = MASK_SPECIAL3(ctx->opcode); switch (op1) { case OPC_EXT: case OPC_INS: check_insn(env, ctx, ISA_MIPS32R2); gen_bitops(ctx, op1, rt, rs, sa, rd); break; case OPC_BSHFL: check_insn(env, ctx, ISA_MIPS32R2); op2 = MASK_BSHFL(ctx->opcode); gen_bshfl(ctx, op2, rt, rd); break; case OPC_RDHWR: gen_rdhwr(env, ctx, rt, rd); break; case OPC_FORK: check_insn(env, ctx, ASE_MT); { TCGv t0 = tcg_temp_new(); TCGv t1 = tcg_temp_new(); gen_load_gpr(t0, rt); gen_load_gpr(t1, rs); gen_helper_fork(t0, t1); tcg_temp_free(t0); tcg_temp_free(t1); } break; case OPC_YIELD: check_insn(env, ctx, ASE_MT); { TCGv t0 = tcg_temp_new(); save_cpu_state(ctx, 1); gen_load_gpr(t0, rs); gen_helper_yield(t0, t0); gen_store_gpr(t0, rd); tcg_temp_free(t0); } break; case OPC_DIV_G_2E ... OPC_DIVU_G_2E: case OPC_MULT_G_2E ... OPC_MULTU_G_2E: case OPC_MOD_G_2E ... OPC_MODU_G_2E: check_insn(env, ctx, INSN_LOONGSON2E); gen_loongson_integer(ctx, op1, rd, rs, rt); break; #if defined(TARGET_MIPS64) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS: check_insn(env, ctx, ISA_MIPS64R2); check_mips_64(ctx); gen_bitops(ctx, op1, rt, rs, sa, rd); break; case OPC_DBSHFL: check_insn(env, ctx, ISA_MIPS64R2); check_mips_64(ctx); op2 = MASK_DBSHFL(ctx->opcode); gen_bshfl(ctx, op2, rt, rd); break; case OPC_DDIV_G_2E ... OPC_DDIVU_G_2E: case OPC_DMULT_G_2E ... OPC_DMULTU_G_2E: case OPC_DMOD_G_2E ... OPC_DMODU_G_2E: check_insn(env, ctx, INSN_LOONGSON2E); gen_loongson_integer(ctx, op1, rd, rs, rt); break; #endif default: MIPS_INVAL("special3"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_REGIMM: op1 = MASK_REGIMM(ctx->opcode); switch (op1) { case OPC_BLTZ ... OPC_BGEZL: case OPC_BLTZAL ... OPC_BGEZALL: gen_compute_branch(ctx, op1, 4, rs, -1, imm << 2); *is_branch = 1; break; case OPC_TGEI ... OPC_TEQI: case OPC_TNEI: gen_trap(ctx, op1, rs, -1, imm); break; case OPC_SYNCI: check_insn(env, ctx, ISA_MIPS32R2); break; default: MIPS_INVAL("regimm"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_CP0: check_cp0_enabled(ctx); op1 = MASK_CP0(ctx->opcode); switch (op1) { case OPC_MFC0: case OPC_MTC0: case OPC_MFTR: case OPC_MTTR: #if defined(TARGET_MIPS64) case OPC_DMFC0: case OPC_DMTC0: #endif #ifndef CONFIG_USER_ONLY gen_cp0(env, ctx, op1, rt, rd); #endif break; case OPC_C0_FIRST ... OPC_C0_LAST: #ifndef CONFIG_USER_ONLY gen_cp0(env, ctx, MASK_C0(ctx->opcode), rt, rd); #endif break; case OPC_MFMC0: #ifndef CONFIG_USER_ONLY { TCGv t0 = tcg_temp_new(); op2 = MASK_MFMC0(ctx->opcode); switch (op2) { case OPC_DMT: check_insn(env, ctx, ASE_MT); gen_helper_dmt(t0, t0); gen_store_gpr(t0, rt); break; case OPC_EMT: check_insn(env, ctx, ASE_MT); gen_helper_emt(t0, t0); gen_store_gpr(t0, rt); break; case OPC_DVPE: check_insn(env, ctx, ASE_MT); gen_helper_dvpe(t0, t0); gen_store_gpr(t0, rt); break; case OPC_EVPE: check_insn(env, ctx, ASE_MT); gen_helper_evpe(t0, t0); gen_store_gpr(t0, rt); break; case OPC_DI: check_insn(env, ctx, ISA_MIPS32R2); save_cpu_state(ctx, 1); gen_helper_di(t0); gen_store_gpr(t0, rt); ctx->bstate = BS_STOP; break; case OPC_EI: check_insn(env, ctx, ISA_MIPS32R2); save_cpu_state(ctx, 1); gen_helper_ei(t0); gen_store_gpr(t0, rt); ctx->bstate = BS_STOP; break; default: MIPS_INVAL("mfmc0"); generate_exception(ctx, EXCP_RI); break; } tcg_temp_free(t0); } #endif break; case OPC_RDPGPR: check_insn(env, ctx, ISA_MIPS32R2); gen_load_srsgpr(rt, rd); break; case OPC_WRPGPR: check_insn(env, ctx, ISA_MIPS32R2); gen_store_srsgpr(rt, rd); break; default: MIPS_INVAL("cp0"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_ADDI: case OPC_ADDIU: gen_arith_imm(env, ctx, op, rt, rs, imm); break; case OPC_SLTI: case OPC_SLTIU: gen_slt_imm(env, op, rt, rs, imm); break; case OPC_ANDI: case OPC_LUI: case OPC_ORI: case OPC_XORI: gen_logic_imm(env, op, rt, rs, imm); break; case OPC_J ... OPC_JAL: offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2; gen_compute_branch(ctx, op, 4, rs, rt, offset); *is_branch = 1; break; case OPC_BEQ ... OPC_BGTZ: case OPC_BEQL ... OPC_BGTZL: gen_compute_branch(ctx, op, 4, rs, rt, imm << 2); *is_branch = 1; break; case OPC_LB ... OPC_LWR: case OPC_LL: gen_ld(env, ctx, op, rt, rs, imm); break; case OPC_SB ... OPC_SW: case OPC_SWR: gen_st(ctx, op, rt, rs, imm); break; case OPC_SC: gen_st_cond(ctx, op, rt, rs, imm); break; case OPC_CACHE: check_insn(env, ctx, ISA_MIPS3 | ISA_MIPS32); break; case OPC_PREF: check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); break; case OPC_LWC1: case OPC_LDC1: case OPC_SWC1: case OPC_SDC1: gen_cop1_ldst(env, ctx, op, rt, rs, imm); break; case OPC_CP1: if (env->CP0_Config1 & (1 << CP0C1_FP)) { check_cp1_enabled(ctx); op1 = MASK_CP1(ctx->opcode); switch (op1) { case OPC_MFHC1: case OPC_MTHC1: check_insn(env, ctx, ISA_MIPS32R2); case OPC_MFC1: case OPC_CFC1: case OPC_MTC1: case OPC_CTC1: gen_cp1(ctx, op1, rt, rd); break; #if defined(TARGET_MIPS64) case OPC_DMFC1: case OPC_DMTC1: check_insn(env, ctx, ISA_MIPS3); gen_cp1(ctx, op1, rt, rd); break; #endif case OPC_BC1ANY2: case OPC_BC1ANY4: check_cop1x(ctx); check_insn(env, ctx, ASE_MIPS3D); case OPC_BC1: gen_compute_branch1(env, ctx, MASK_BC1(ctx->opcode), (rt >> 2) & 0x7, imm << 2); *is_branch = 1; break; case OPC_S_FMT: case OPC_D_FMT: case OPC_W_FMT: case OPC_L_FMT: case OPC_PS_FMT: gen_farith(ctx, ctx->opcode & FOP(0x3f, 0x1f), rt, rd, sa, (imm >> 8) & 0x7); break; default: MIPS_INVAL("cp1"); generate_exception (ctx, EXCP_RI); break; } } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; case OPC_LWC2: case OPC_LDC2: case OPC_SWC2: case OPC_SDC2: case OPC_CP2: generate_exception_err(ctx, EXCP_CpU, 2); break; case OPC_CP3: if (env->CP0_Config1 & (1 << CP0C1_FP)) { check_cp1_enabled(ctx); op1 = MASK_CP3(ctx->opcode); switch (op1) { case OPC_LWXC1: case OPC_LDXC1: case OPC_LUXC1: case OPC_SWXC1: case OPC_SDXC1: case OPC_SUXC1: gen_flt3_ldst(ctx, op1, sa, rd, rs, rt); break; case OPC_PREFX: break; case OPC_ALNV_PS: case OPC_MADD_S: case OPC_MADD_D: case OPC_MADD_PS: case OPC_MSUB_S: case OPC_MSUB_D: case OPC_MSUB_PS: case OPC_NMADD_S: case OPC_NMADD_D: case OPC_NMADD_PS: case OPC_NMSUB_S: case OPC_NMSUB_D: case OPC_NMSUB_PS: gen_flt3_arith(ctx, op1, sa, rs, rd, rt); break; default: MIPS_INVAL("cp3"); generate_exception (ctx, EXCP_RI); break; } } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; #if defined(TARGET_MIPS64) case OPC_LWU: case OPC_LDL ... OPC_LDR: case OPC_LLD: case OPC_LD: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_ld(env, ctx, op, rt, rs, imm); break; case OPC_SDL ... OPC_SDR: case OPC_SD: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_st(ctx, op, rt, rs, imm); break; case OPC_SCD: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_st_cond(ctx, op, rt, rs, imm); break; case OPC_DADDI: case OPC_DADDIU: check_insn(env, ctx, ISA_MIPS3); check_mips_64(ctx); gen_arith_imm(env, ctx, op, rt, rs, imm); break; #endif case OPC_JALX: check_insn(env, ctx, ASE_MIPS16 | ASE_MICROMIPS); offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2; gen_compute_branch(ctx, op, 4, rs, rt, offset); *is_branch = 1; break; case OPC_MDMX: check_insn(env, ctx, ASE_MDMX); default: MIPS_INVAL("major opcode"); generate_exception(ctx, EXCP_RI); break; } }
1threat
int ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts) { if (ctb_addr_ts == s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) { int ret = cabac_init_decoder(s); if (ret < 0) return ret; if (s->sh.dependent_slice_segment_flag == 0 || (s->ps.pps->tiles_enabled_flag && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1])) cabac_init_state(s); if (!s->sh.first_slice_in_pic_flag && s->ps.pps->entropy_coding_sync_enabled_flag) { if (ctb_addr_ts % s->ps.sps->ctb_width == 0) { if (s->ps.sps->ctb_width == 1) cabac_init_state(s); else if (s->sh.dependent_slice_segment_flag == 1) load_states(s); } } } else { if (s->ps.pps->tiles_enabled_flag && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]) { if (s->threads_number == 1) cabac_reinit(s->HEVClc); else { int ret = cabac_init_decoder(s); if (ret < 0) return ret; } cabac_init_state(s); } if (s->ps.pps->entropy_coding_sync_enabled_flag) { if (ctb_addr_ts % s->ps.sps->ctb_width == 0) { get_cabac_terminate(&s->HEVClc->cc); if (s->threads_number == 1) cabac_reinit(s->HEVClc); else { int ret = cabac_init_decoder(s); if (ret < 0) return ret; } if (s->ps.sps->ctb_width == 1) cabac_init_state(s); else load_states(s); } } } return 0; }
1threat
Kotlin calling non final function in constructor works : <p>In Kotlin, it warns you when calling an abstract function in a constructor, citing the following problematic code:</p> <pre><code>abstract class Base { var code = calculate() abstract fun calculate(): Int } class Derived(private val x: Int) : Base() { override fun calculate(): Int = x } fun main(args: Array&lt;String&gt;) { val i = Derived(42).code // Expected: 42, actual: 0 println(i) } </code></pre> <p>And the output makes sense because when <code>calculate</code> is called, <code>x</code> hasn't been initialized yet.</p> <p>This is something I had never considered when writing java, as I have used this pattern without any issues:</p> <pre><code>class Base { private int area; Base(Room room) { area = extractArea(room); } abstract int extractArea(Room room); } class Derived_A extends Base { Derived_A(Room room) { super(room); } @Override public int extractArea(Room room) { // Extract area A from room } } class Derived_B extends Base { Derived_B(Room room) { super(room); } @Override public int extractArea(Room room) { // Extract area B from room } } </code></pre> <p>And this has worked fine because the overriden <code>extractArea</code> functions don't rely on any uninitialized data, but they are unique to each respective derived <code>class</code> (hence the need to be abstract). This also works in kotlin, but it still gives the warning.</p> <p>So is this poor practice in java/kotlin? If so, how can I improve it? And is it possible to implement in kotlin without being warned about using non-final functions in constructors?</p> <p>A potential solution is to move the line <code>area = extractArea()</code> to each derived constructor, but this doesn't seem ideal since it's just repeated code that should be part of the super class.</p>
0debug
Pyhton - Numpy array, number of time satisfying a condition : I have a numpy array as follow: a = [1 4 2 6 4 4 6 2 7 6 2 8 9 3 6 3 4 4 5 8] and a constant number `b=6` I am searching for a number `c` which is defined by the number of occurrence that `a` is more than 2 times consecutively inferior to `b`? So in this example it `c=3`
0debug
What does putting curly brackets around a variale when initializing it does exactly? : <p>Example : </p> <pre><code>const {http} = require('http'); </code></pre> <p>I have seen something about "destructing" and have read some resources about that, but I am still very confused about what it actually does.</p>
0debug
How to switch from Second form to Main form but not create new Main form? : I know how to switch form to form, but problem is when switch from Second form to main form. It always create a new Main form. How to avoid this? (If not my app will replace a lots of Ram). Bad English!
0debug
static void v9fs_unlinkat(void *opaque) { int err = 0; V9fsString name; int32_t dfid, flags; size_t offset = 7; V9fsPath path; V9fsFidState *dfidp; V9fsPDU *pdu = opaque; v9fs_string_init(&name); err = pdu_unmarshal(pdu, offset, "dsd", &dfid, &name, &flags); if (err < 0) { dfidp = get_fid(pdu, dfid); if (dfidp == NULL) { err = -EINVAL; v9fs_path_init(&path); err = v9fs_co_name_to_path(pdu, &dfidp->path, name.data, &path); if (err < 0) { goto out_err; err = v9fs_mark_fids_unreclaim(pdu, &path); if (err < 0) { goto out_err; err = v9fs_co_unlinkat(pdu, &dfidp->path, &name, flags); if (!err) { err = offset; out_err: put_fid(pdu, dfidp); v9fs_path_free(&path); out_nofid: pdu_complete(pdu, err); v9fs_string_free(&name);
1threat
What is the best platform/solution to develop an app for iOS, Android, and Blackberry? : <p>I will be making a database that is offline and online and wondered what I could use to develop apps for Apple's iOS, Android, and Blackberry all in one sweep. I know Xamarin does iOS and Android, but not too sure how well it will be on Blackberry? Are there any other solutions or ideas to nudge me in the right direction. Thank you.</p>
0debug
int kvm_arch_init_vcpu(CPUState *env) { struct { struct kvm_cpuid2 cpuid; struct kvm_cpuid_entry2 entries[100]; } __attribute__((packed)) cpuid_data; uint32_t limit, i, j, cpuid_i; uint32_t unused; struct kvm_cpuid_entry2 *c; uint32_t signature[3]; env->cpuid_features &= kvm_arch_get_supported_cpuid(env, 1, 0, R_EDX); i = env->cpuid_ext_features & CPUID_EXT_HYPERVISOR; env->cpuid_ext_features &= kvm_arch_get_supported_cpuid(env, 1, 0, R_ECX); env->cpuid_ext_features |= i; env->cpuid_ext2_features &= kvm_arch_get_supported_cpuid(env, 0x80000001, 0, R_EDX); env->cpuid_ext3_features &= kvm_arch_get_supported_cpuid(env, 0x80000001, 0, R_ECX); env->cpuid_svm_features &= kvm_arch_get_supported_cpuid(env, 0x8000000A, 0, R_EDX); cpuid_i = 0; memcpy(signature, "KVMKVMKVM\0\0\0", 12); c = &cpuid_data.entries[cpuid_i++]; memset(c, 0, sizeof(*c)); c->function = KVM_CPUID_SIGNATURE; c->eax = 0; c->ebx = signature[0]; c->ecx = signature[1]; c->edx = signature[2]; c = &cpuid_data.entries[cpuid_i++]; memset(c, 0, sizeof(*c)); c->function = KVM_CPUID_FEATURES; c->eax = env->cpuid_kvm_features & kvm_arch_get_supported_cpuid(env, KVM_CPUID_FEATURES, 0, R_EAX); has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF); cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused); for (i = 0; i <= limit; i++) { c = &cpuid_data.entries[cpuid_i++]; switch (i) { case 2: { int times; c->function = i; c->flags = KVM_CPUID_FLAG_STATEFUL_FUNC | KVM_CPUID_FLAG_STATE_READ_NEXT; cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx); times = c->eax & 0xff; for (j = 1; j < times; ++j) { c = &cpuid_data.entries[cpuid_i++]; c->function = i; c->flags = KVM_CPUID_FLAG_STATEFUL_FUNC; cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx); } break; } case 4: case 0xb: case 0xd: for (j = 0; ; j++) { c->function = i; c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX; c->index = j; cpu_x86_cpuid(env, i, j, &c->eax, &c->ebx, &c->ecx, &c->edx); if (i == 4 && c->eax == 0) { break; } if (i == 0xb && !(c->ecx & 0xff00)) { break; } if (i == 0xd && c->eax == 0) { break; } c = &cpuid_data.entries[cpuid_i++]; } break; default: c->function = i; c->flags = 0; cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx); break; } } cpu_x86_cpuid(env, 0x80000000, 0, &limit, &unused, &unused, &unused); for (i = 0x80000000; i <= limit; i++) { c = &cpuid_data.entries[cpuid_i++]; c->function = i; c->flags = 0; cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx); } if (env->cpuid_xlevel2 > 0) { env->cpuid_ext4_features &= kvm_arch_get_supported_cpuid(env, 0xC0000001, 0, R_EDX); cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused); for (i = 0xC0000000; i <= limit; i++) { c = &cpuid_data.entries[cpuid_i++]; c->function = i; c->flags = 0; cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx); } } cpuid_data.cpuid.nent = cpuid_i; if (((env->cpuid_version >> 8)&0xF) >= 6 && (env->cpuid_features&(CPUID_MCE|CPUID_MCA)) == (CPUID_MCE|CPUID_MCA) && kvm_check_extension(env->kvm_state, KVM_CAP_MCE) > 0) { uint64_t mcg_cap; int banks; int ret; ret = kvm_get_mce_cap_supported(env->kvm_state, &mcg_cap, &banks); if (ret < 0) { fprintf(stderr, "kvm_get_mce_cap_supported: %s", strerror(-ret)); return ret; } if (banks > MCE_BANKS_DEF) { banks = MCE_BANKS_DEF; } mcg_cap &= MCE_CAP_DEF; mcg_cap |= banks; ret = kvm_vcpu_ioctl(env, KVM_X86_SETUP_MCE, &mcg_cap); if (ret < 0) { fprintf(stderr, "KVM_X86_SETUP_MCE: %s", strerror(-ret)); return ret; } env->mcg_cap = mcg_cap; } qemu_add_vm_change_state_handler(cpu_update_state, env); return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data); }
1threat
static inline void idct4col_add(uint8_t *dest, int line_size, const DCTELEM *col) { int c0, c1, c2, c3, a0, a1, a2, a3; const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; a0 = col[8*0]; a1 = col[8*1]; a2 = col[8*2]; a3 = col[8*3]; c0 = (a0 + a2)*C3 + (1 << (C_SHIFT - 1)); c2 = (a0 - a2)*C3 + (1 << (C_SHIFT - 1)); c1 = a1 * C1 + a3 * C2; c3 = a1 * C2 - a3 * C1; dest[0] = cm[dest[0] + ((c0 + c1) >> C_SHIFT)]; dest += line_size; dest[0] = cm[dest[0] + ((c2 + c3) >> C_SHIFT)]; dest += line_size; dest[0] = cm[dest[0] + ((c2 - c3) >> C_SHIFT)]; dest += line_size; dest[0] = cm[dest[0] + ((c0 - c1) >> C_SHIFT)]; }
1threat
void ff_generate_sliding_window_mmcos(H264Context *h) { MpegEncContext * const s = &h->s; assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count); h->mmco_index= 0; if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count && !(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->reference)) { h->mmco[0].opcode= MMCO_SHORT2UNUSED; h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num; h->mmco_index= 1; if (FIELD_PICTURE) { h->mmco[0].short_pic_num *= 2; h->mmco[1].opcode= MMCO_SHORT2UNUSED; h->mmco[1].short_pic_num= h->mmco[0].short_pic_num + 1; h->mmco_index= 2; } } }
1threat
From left/right to center transition with buttons : <p>I want my buttons on my page to go from the left/right to the center when the page loads. Is there a way I can do it? I wanna make the first one from left, second from right, etc. I'm thinking of using tags for each button- #button1, #button2 etc- and using CSS to make the animations, but don't know how. Can anyone help? (If you know a JS way that works too, but I don't know too much JS or CSS as of now. I know more CSS than JS so CSS if preferred)</p>
0debug
Check if the key value exists in hashmap : <p>I have HashMap where key is bird specie and value is number of perceptions. Here is my code:</p> <pre><code>public class Program { public static void main(String[] args) { HashMap&lt;String, Integer&gt; species = new HashMap&lt;&gt;(); Scanner reader = new Scanner(System.in); species.put("hawk (buteo jamaicensis)", 2); species.put("eagle (aquila chrysaetos)", 4); species.put("sparrow (passeridae)", 5); System.out.println("What specie?"); //output "chicken" String specie = reader.nextLine(); for (HashMap.Entry&lt;String, Integer&gt; entry: species.entrySet()) { if (entry.getKey().contains(specie)) { System.out.println(entry.getKey()+" : "+entry.getValue()+" perceptions"); } else { System.out.println("Not in database!"); } } } </code></pre> <p>}</p> <p>How I can check if the specie exists in hashmap? For example if the specie output is "chicken" and it's not in database, then the program should print "Not in database!". Now the output is:</p> <pre><code>Not in database! Not in database! Not in database! </code></pre> <p>And my goal output is:</p> <pre><code>Not in database! </code></pre>
0debug
void qemu_console_copy(QemuConsole *con, int src_x, int src_y, int dst_x, int dst_y, int w, int h) { assert(con->console_type == GRAPHIC_CONSOLE); dpy_gfx_copy(con, src_x, src_y, dst_x, dst_y, w, h); }
1threat
static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth) { AVCodecContext *acodec, *vcodec; FLVContext *flv = s->priv_data; AVIOContext *ioc; AMFDataType amf_type; char str_val[256]; double num_val; num_val = 0; ioc = s->pb; amf_type = avio_r8(ioc); switch (amf_type) { case AMF_DATA_TYPE_NUMBER: num_val = av_int2double(avio_rb64(ioc)); break; case AMF_DATA_TYPE_BOOL: num_val = avio_r8(ioc); break; case AMF_DATA_TYPE_STRING: if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0) return -1; break; case AMF_DATA_TYPE_OBJECT: if ((vstream || astream) && key && !strcmp(KEYFRAMES_TAG, key) && depth == 1) if (parse_keyframes_index(s, ioc, vstream ? vstream : astream, max_pos) < 0) return -1; while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; if (avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_NULL: case AMF_DATA_TYPE_UNDEFINED: case AMF_DATA_TYPE_UNSUPPORTED: break; case AMF_DATA_TYPE_MIXEDARRAY: avio_skip(ioc, 4); while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) if (amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; if (avio_r8(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_ARRAY: { unsigned int arraylen, i; arraylen = avio_rb32(ioc); for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) if (amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0) return -1; } break; case AMF_DATA_TYPE_DATE: avio_skip(ioc, 8 + 2); break; default: return -1; } if (depth == 1 && key) { acodec = astream ? astream->codec : NULL; vcodec = vstream ? vstream->codec : NULL; if (amf_type == AMF_DATA_TYPE_NUMBER || amf_type == AMF_DATA_TYPE_BOOL) { if (!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE; else if (!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0)) vcodec->bit_rate = num_val * 1024.0; else if (!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0)) acodec->bit_rate = num_val * 1024.0; else if (!strcmp(key, "datastream")) { AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA); if (!st) return AVERROR(ENOMEM); st->codec->codec_id = AV_CODEC_ID_TEXT; } else if (flv->trust_metadata) { if (!strcmp(key, "videocodecid") && vcodec) { flv_set_video_codec(s, vstream, num_val, 0); } else if (!strcmp(key, "audiocodecid") && acodec) { int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET; flv_set_audio_codec(s, astream, acodec, id); } else if (!strcmp(key, "audiosamplerate") && acodec) { acodec->sample_rate = num_val; } else if (!strcmp(key, "audiosamplesize") && acodec) { acodec->bits_per_coded_sample = num_val; } else if (!strcmp(key, "stereo") && acodec) { acodec->channels = num_val + 1; acodec->channel_layout = acodec->channels == 2 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; } else if (!strcmp(key, "width") && vcodec) { vcodec->width = num_val; } else if (!strcmp(key, "height") && vcodec) { vcodec->height = num_val; } } } if (!strcmp(key, "duration") || !strcmp(key, "filesize") || !strcmp(key, "width") || !strcmp(key, "height") || !strcmp(key, "videodatarate") || !strcmp(key, "framerate") || !strcmp(key, "videocodecid") || !strcmp(key, "audiodatarate") || !strcmp(key, "audiosamplerate") || !strcmp(key, "audiosamplesize") || !strcmp(key, "stereo") || !strcmp(key, "audiocodecid") || !strcmp(key, "datastream")) return 0; if (amf_type == AMF_DATA_TYPE_BOOL) { av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val)); av_dict_set(&s->metadata, key, str_val, 0); } else if (amf_type == AMF_DATA_TYPE_NUMBER) { snprintf(str_val, sizeof(str_val), "%.f", num_val); av_dict_set(&s->metadata, key, str_val, 0); } else if (amf_type == AMF_DATA_TYPE_STRING) av_dict_set(&s->metadata, key, str_val, 0); } return 0; }
1threat
How can you retrieve XML parser on "click" on an SVG? : I have an SVG of the United States, and once you click on a specific state, the USA SVG fades out, and a separate SVG of the state clicked will appear (an enlarged version of the state). Each state has counties in it, with their own paths and id's. I have some testing XML parser that are supposed to go with each specific state. I'm trying to get it so once you click on a counties path, the specific XML data will alert you with the specific counties info. Here is my XML sample of just Los Angeles: var parser, xmlDoc; var xml = "<Opportunities> <Opportunity> <State>CA</State> <County>Los Angeles</County> <TotalChildrenUnassigned>186</TotalChildrenUnassigned> </Opportunity> </Opportunities>"; The SVG of California is too big, so here is just the path of Los Angeles: <path style="font-size:12px;fill:#d0d0d0;fill-rule:nonzero;stroke:#000000;stroke- width:1;stroke-linecap:butt;stroke-linejoin:bevel;stroke- miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:none" d="m 361.25368,643.31194 -3.25507,-0.14099 -2.06586,-2.85131 -0.276,-0.49114 -1.00654,-3.58799 -0.91321,-6.41202 1.15265,0.43201 5.99874,11.719 0.4952,1.19145 -0.12992,0.14099 m -2.21199,-39.92283 -0.1827,-0.15004 -0.0365,-0.42292 0.0365,-0.0818 0.19888,0.0592 2.23634,0.84132 2.5042,2.25557 2.02936,1.82357 1.53823,1.4552 1.97659,4.58847 0.16237,0.47293 0.10965,0.98228 -0.19888,0.53207 -0.60472,0.39561 -0.0365,0.0182 h -0.34904 l -5.26817,-2.78765 -0.34904,-0.35016 -3.76647,-9.63169 m 55.39297,-67.34899 -2.78427,13.52435 -1.29472,7.81269 -0.97409,6.63939 -0.38556,2.8695 -2.81269,6.82132 -2.43114,4.55207 -0.97002,1.80538 -3.03995,1.6553 -1.09586,1.50068 -0.0731,0.40927 0.19886,0.92317 0.34906,0.55478 -5.74305,-1.47795 -0.49515,-0.12281 -1.9563,-0.14098 -4.61065,4.44295 -2.34188,3.30152 -1.11613,2.21008 -3.25508,0.4957 -3.42145,-0.0818 -1.57477,-0.69576 -0.78334,-0.49569 -3.05619,-2.2101 -0.54791,-0.50933 -0.32877,-2.06912 0.30846,-0.36834 0.99031,-0.82313 0.5114,-0.12282 0.2557,-0.59119 0.27192,-1.47793 -0.32469,-2.70579 -0.20293,-1.31424 -0.10954,-0.73671 -0.23542,-1.51886 -0.42209,-1.84631 -0.58852,-1.77808 -0.0528,-0.12736 -0.0731,-0.18645 -0.0202,-0.0365 -0.45457,-1.00502 -0.0932,-0.14095 -0.34501,-0.55481 -0.11352,-0.1819 -0.12572,-0.12735 -0.73463,-0.77763 -1.05932,-0.46841 -4.18858,-0.98681 -3.29158,-0.49113 -1.73713,0.16366 -6.47768,-3.21965 0.54794,-1.64167 4.17234,-2.0282 3.36466,-1.57799 5.04899,1.39611 2.56104,-4.57483 0.27599,-2.14644 -3.96939,-31.38255 -0.18271,-1.70077 51.03801,13.3652" id="Los Angeles" inkscape:connector-curvature="0" /> Using jQuery or JavaScript, how can I make it so once I click on a specific county, the specific "TotalChildrenUnassigned" data alerts? Let me know if there is any more information I can give to help, thanks.
0debug
static void restart_co_req(void *opaque) { Coroutine *co = opaque; qemu_coroutine_enter(co, NULL); }
1threat
PHP code not able to run in Android App : - I have created an app in which there is a login page (login.php).This consists of the form - The other script i have created is loginScript.php - When i try to run the code, login.php,it does runs in the webview of app but when hit "sign in" button, the action calls the loginScript.php but it does not runs instead whole scripts displayed. > Kindly suggest what should i do to run the php script in the app (Internet is active)
0debug
How to make non selectable embed custom format in quilljs : <p>I would like to create a custom embed format which can be styled but it's text cannot be changed. My use case is pretty similar to the hashtag case. I want to have an external button that will add an hashtag to the current selected range on the editor. But after doing this i want the hashtag to behave as a "block" so that the user cannot go there and change its text.</p> <p>The only way i could accomplish this was by saying that the format's node is contenteditable=false but i'm not sure i'm going the right way as i'm having some issues with this approach, mainly:</p> <p>If the hashtag is the last thing on the editor i cannot move past it (with arrows or cursor) Double clicking it to select should select the whole thing (and not individual words) (for styling) If the cursor is immediately behind the hashtag, pressing right and writing will write inside the hashtag You can check a codepen i made while experimenting with this:</p> <pre><code> Quill.import('blots/embed'); class QuillHashtag extends Embed { static create(value) { let node = super.create(value); node.innerHTML = `&lt;span contenteditable=false&gt;#${value}&lt;/span&gt;`; return node; } } QuillHashtag.blotName = 'hashtag'; QuillHashtag.className = 'quill-hashtag'; QuillHashtag.tagName = 'span'; </code></pre> <p>Here's the full codepen: <a href="http://codepen.io/emanuelbsilva/pen/Zpmmzv">http://codepen.io/emanuelbsilva/pen/Zpmmzv</a></p> <p>If you guys can give me any tips on how can i accomplish this i would be glad.</p> <p>Thanks.</p>
0debug
static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { FlacEncodeContext *s; int frame_bytes, out_bytes, ret; s = avctx->priv_data; if (!frame) { s->max_framesize = s->max_encoded_framesize; av_md5_final(s->md5ctx, s->md5sum); write_streaminfo(s, avctx->extradata); return 0; } if (frame->nb_samples < s->frame.blocksize) { s->max_framesize = ff_flac_get_max_frame_size(frame->nb_samples, s->channels, avctx->bits_per_raw_sample); } init_frame(s, frame->nb_samples); copy_samples(s, frame->data[0]); channel_decorrelation(s); remove_wasted_bits(s); frame_bytes = encode_frame(s); if (frame_bytes < 0 || frame_bytes > s->max_framesize) { s->frame.verbatim_only = 1; frame_bytes = encode_frame(s); if (frame_bytes < 0) { av_log(avctx, AV_LOG_ERROR, "Bad frame count\n"); return frame_bytes; } } if ((ret = ff_alloc_packet2(avctx, avpkt, frame_bytes))) return ret; out_bytes = write_frame(s, avpkt); s->frame_count++; s->sample_count += frame->nb_samples; if ((ret = update_md5_sum(s, frame->data[0])) < 0) { av_log(avctx, AV_LOG_ERROR, "Error updating MD5 checksum\n"); return ret; } if (out_bytes > s->max_encoded_framesize) s->max_encoded_framesize = out_bytes; if (out_bytes < s->min_framesize) s->min_framesize = out_bytes; avpkt->pts = frame->pts; avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); avpkt->size = out_bytes; *got_packet_ptr = 1; return 0; }
1threat
R how to remove first row of duplicate values from a big column : <p>in R I have a file (df) consisting in 2 very big columns, A and B (aprox. 1000000 elements each). I know I have many duplicate values in A. I know how to remove the duplicates (remove second rows of each duplicate):</p> <pre><code>df1 = df[!duplicated(df$A), ] </code></pre> <p>but I would like to remove the first rows in the duplicate and keep the second rows. For instance, in the following example, I would like to remove 71 T and keep 71 C, NOT the other way around:</p> <pre><code>A B 4 A 8 C 21 T 71 T 71 C 74 C 75 G 78 C 86 T </code></pre> <p>Thanks very much in advance</p>
0debug
c nested makros Verschachtelte Makros : a problem occurred to me. Somebody might show me how to remove the "@". I am writing c for a uc and I am lazy; so I want to solve easy problems whit makros, e.g. switching on a led. I managed to do something like that: //Begin of c code #include <stdio.h> #define BIT_STD_SET(PORT, BITNUM) ((PORT) |= (1<<(BITNUM))) #define BIT_STD_CLE(PORT, BITNUM) ((PORT) &= ~(1<<(BITNUM))) #define BIT_STD_TOG(PORT, BITNUM) ((PORT) ^= (1<<(BITNUM))) #define LEDPORT_0 C #define LEDPAD_0 3 /*Blau*/ #define LEDPORT_1 D #define LEDPAD_1 4 /*GelbWeis*/ #define PO(n) LEDPORT_##n #define POR(n) PORT@PO(n) #define PA(n) LEDPAD_##n #define PAD(n) PA(n) #define LEDAN(n) BIT_STD_SET(POR(n),PAD(n)) #define f(a,b) a##b #define g(a) #a #define h(a) g(a) int main() { printf("%s\n",h(LEDAN(0))); printf("%s\n",h(LEDAN(1))); printf("\n"); printf("%s\n",h(LEDAN(1))); printf("\n"); printf("%s\n",h(POR(0))); printf("%s\n",h(POR(1))); printf("%s\n",h(f(0,1))); printf("%s\n",g(f(0,1))); return 0; } //End of c code p@d:~/$ gcc ./mak.c and got p@d:~/$ ./a.out Answer: ((PORT@C) |= (1<<(3))) ((PORT@D) |= (1<<(4))) ((PORT@D) |= (1<<(4))) PORT@C PORT@D 01 f(0,1) the "@" should be removed. unfortunately, I do not know how. I have read some manuals, but I do not know how to express my self. Thanks a lot. @admins to mark code via 4 spaces is a bad and time consuming way
0debug
Cannot apply BigDecimal to constructor : <p><strong>I have object like:</strong></p> <pre><code>import java.math.BigDecimal; public class Obj { BigDecimal Sal; int EMPID; public Obj(BigDecimal Sal, int EMPID) { this.Sal= Sal; this.EMPID= EMPID; } } </code></pre> <p>Now I wanna create Instance of Obj with constructor call.</p> <pre><code>Obj a = new Obj(45,34); // getting error here </code></pre> <p>Tried this also: <code>Obj a = new Obj( (BigDecimal) 45,34);</code> </p> <p>Error: </p> <blockquote> <p>Obj (java.math.BigDecimal, int) in Obj cannot be applied to (int, int)</p> </blockquote> <p> </p>
0debug
Dynamically hiding a section on Wordpress pages : <p>I have a floating social bar on my website www.fashionsuggest.in </p> <p>I only need this social bar on my wordpress posts and would like to to be removed from all pages.</p> <p>There are only 5 or 6 pages in total. Can someone please suggest a solution to hide the floating social bar on these pages?</p> <p><a href="https://i.stack.imgur.com/y9KXR.jpg" rel="nofollow noreferrer">Please refer the attachment to see a screenshot of the social bar</a></p>
0debug
Get string md5 in Swift 5 : <p>In Swift 4 we could use</p> <pre><code>var md5: String? { guard let data = self.data(using: .utf8) else { return nil } let hash = data.withUnsafeBytes { (bytes: UnsafePointer&lt;Data&gt;) -&gt; [UInt8] in var hash: [UInt8] = [UInt8](repeating: 0, count: Int(CC_MD5_DIGEST_LENGTH)) CC_MD5(bytes, CC_LONG(data.count), &amp;hash) return hash } return hash.map { String(format: "%02x", $0) }.joined() } </code></pre> <p>But in Swift 5 <code>withUnsafeBytes</code> uses <code>UnsafeRawBufferPointer</code> instead of <code>UnsafePointer</code>. How to change md5 function?</p>
0debug
Mock external dependency that returns a Future of list : <p>I have a class which have external dependency that returns future of lists. How to mock the external dependency? </p> <pre><code> public void meth() { //some stuff Future&lt;List&lt;String&gt;&gt; f1 = obj.methNew("anyString") //some stuff } when(obj.methNew(anyString()).thenReturn("how to intialise some data here, like list of names") </code></pre>
0debug
static void decode_component(DiracContext *s, int comp) { AVCodecContext *avctx = s->avctx; SubBand *bands[3*MAX_DWT_LEVELS+1]; enum dirac_subband orientation; int level, num_bands = 0; for (level = 0; level < s->wavelet_depth; level++) { for (orientation = !!level; orientation < 4; orientation++) { SubBand *b = &s->plane[comp].band[level][orientation]; bands[num_bands++] = b; align_get_bits(&s->gb); b->length = svq3_get_ue_golomb(&s->gb); if (b->length) { b->quant = svq3_get_ue_golomb(&s->gb); align_get_bits(&s->gb); b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8; b->length = FFMIN(b->length, get_bits_left(&s->gb)/8); skip_bits_long(&s->gb, b->length*8); } } if (s->is_arith) avctx->execute(avctx, decode_subband_arith, &s->plane[comp].band[level][!!level], NULL, 4-!!level, sizeof(SubBand)); } if (!s->is_arith) avctx->execute(avctx, decode_subband_golomb, bands, NULL, num_bands, sizeof(SubBand*)); }
1threat
how do I detect and make clickable links in a UILabel NOT using UITextView : <p>I am building a chat app and for performance reasons I need to use UILabel's instead of UITextView's to display the chat messages. I have previously used TextView's but with data detection on the scrolling is very slow and choppy.</p> <p>The problem is there is currently no link/phone/address etc... detection for UILabels. </p> <p>How can I know where a link or phone number exists in a string, and then highlight and make it clickable within a UILabel?</p> <p>I have read many articles on how to add attributes for links to do just that but they have all been links which you know the range or substring of.</p> <p>I would like to take any string and find out whether is contains links and where those links are and then add the tapGestureRecognizer to the label and perform actions based on where the tap occurred. </p> <p>I have tried to incorporate an external library (TTTAttributedLabel) but I'm using swift and found the documentation for swift to be limited. I did manage to import the library but the links are not being automatically detected. </p>
0debug
Regular expression for a string upto 30 characters long of letters, numbers, and/or spaces C# .Net : <p>Regular expression for validating a string up to 30 characters long of letters, numbers and/or spaces in C# .Net</p> <p>Thank You </p>
0debug
static void init_proc_620 (CPUPPCState *env) { gen_spr_ne_601(env); gen_spr_620(env); gen_tbl(env); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); gen_low_BATs(env); gen_high_BATs(env); init_excp_620(env); env->dcache_line_size = 64; env->icache_line_size = 64; }
1threat
Trying to retreive Favicons from a dynamic URL : Im trying to retrieve favicons from random URL's in a feed that are called up from a ~~~Link~~~ Variable dynamically. (I.E. Apon page load ~~~link~~~ = https://www.website.com/2018/09/30/world/etc... > Retrieve favicon, and display favicon as a img in html. What would be an easy way to go about this? Ive tried a few methods but have had no success so far. Any help would be greatly appreciated.
0debug
How to check store procedure gives null or not in mvc c# : I have a store procedure named GetLastRecordId() in ms sql which gives me last record id in controller of mvc project.But the problem is that when there is no data in table it shows me result like below so I cant check with null. [image of result when there is no data in table][1] [1]: https://i.stack.imgur.com/tep5k.png
0debug
Animating changes in a SliverList : <p>I currently have a <code>SliverList</code> whose items are loaded dynamically. The issue is that once these items are loaded, the <code>SliverList</code> updates without animating the changes, making the transition between loading &amp; loaded <em>very</em> jarring.</p> <p>I see that <code>AnimatedList</code> exists but it isn't a sliver so I can't place it directly in a <code>CustomScrollView</code>.</p>
0debug
Retrofit and OkHttp basic authentication : <p>I am trying to add basic authentication (username and password) to a Retrofit OkHttp client. This is the code I have so far:</p> <pre><code>private static Retrofit createMMSATService(String baseUrl, String user, String pass) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(baseUrl) .client(client) .addConverterFactory(GsonConverterFactory.create()) .build(); return retrofit; } </code></pre> <p>I am using Retrofit 2.2 and <a href="https://futurestud.io/tutorials/android-basic-authentication-with-retrofit" rel="noreferrer">this tutorial</a> suggests using <code>AuthenticationInterceptor</code>, but this class is not available. Where is the correct place to add the credentials? Do I have to add them to my interceptor, client or Retrofit object? And how do I do that?</p>
0debug
static void tcg_out_insn_3401(TCGContext *s, AArch64Insn insn, TCGType ext, TCGReg rd, TCGReg rn, uint64_t aimm) { if (aimm > 0xfff) { assert((aimm & 0xfff) == 0); aimm >>= 12; assert(aimm <= 0xfff); aimm |= 1 << 12; } tcg_out32(s, insn | ext << 31 | aimm << 10 | rn << 5 | rd); }
1threat
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamples) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; ShowWavesContext *showwaves = ctx->priv; const int nb_samples = insamples->audio->nb_samples; AVFilterBufferRef *outpicref = showwaves->outpicref; int linesize = outpicref ? outpicref->linesize[0] : 0; int16_t *p = (int16_t *)insamples->data[0]; int nb_channels = av_get_channel_layout_nb_channels(insamples->audio->channel_layout); int i, j, h; const int n = showwaves->n; const int x = 255 / (nb_channels * n); for (i = 0; i < nb_samples; i++) { if (!outpicref) { showwaves->outpicref = outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN, outlink->w, outlink->h); if (!outpicref) return AVERROR(ENOMEM); outpicref->video->w = outlink->w; outpicref->video->h = outlink->h; outpicref->pts = insamples->pts + av_rescale_q((p - (int16_t *)insamples->data[0]) / nb_channels, (AVRational){ 1, inlink->sample_rate }, outlink->time_base); linesize = outpicref->linesize[0]; memset(outpicref->data[0], 0, showwaves->h*linesize); } for (j = 0; j < nb_channels; j++) { h = showwaves->h/2 - av_rescale(*p++, showwaves->h/2, MAX_INT16); if (h >= 0 && h < outlink->h) *(outpicref->data[0] + showwaves->buf_idx + h * linesize) += x; } showwaves->sample_count_mod++; if (showwaves->sample_count_mod == n) { showwaves->sample_count_mod = 0; showwaves->buf_idx++; } if (showwaves->buf_idx == showwaves->w) push_frame(outlink); } avfilter_unref_buffer(insamples); return 0; }
1threat
Why did not work jQuery button in this code : <p><a href="https://i.imgur.com/WtzTa3g.png" rel="nofollow noreferrer">https://i.imgur.com/WtzTa3g.png</a> </p> <p>what is my mistake ? why this click function is did not work ? i made this function without each loop, then that function working properly, but why did not work this place ? </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt; NG - REPEAT &lt;/title&gt; &lt;script src="https://code.jquery.com/jquery-3.4.1.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;table border="1"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;NAME&lt;/th&gt; &lt;th&gt;VERSION&lt;/th&gt; &lt;th&gt;PRICE&lt;/th&gt; &lt;th&gt;ACTION&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody class="tr"&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;script&gt; $(document).ready(function() { $.ajax({ url:'data.json', dataType:'json', success: function(data) { console.log(data); $.each(data.product, function(name, value) { var result = '&lt;tr&gt;&lt;td&gt;'+name+'&lt;/td&gt;&lt;td&gt;'+value.name+'&lt;/td&gt; &lt;td&gt;'+value.version+'&lt;/td&gt; &lt;td&gt;'+value.price+'&lt;/td&gt;&lt;td&gt;&lt;button id="btn"&gt;Load&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;'; $(".tr").append(result); }); } }); $("button").click(function(){ alert("hi"); }); }); &lt;/script&gt; &lt;/body&gt; </code></pre> <p></p>
0debug
Find a pattern into a string without space : <p>I'm looking for a way to find and extract the string matching a pattern in a string without a space :</p> <pre><code>string regexpattern = @"[A-Z]{4}\d{4}$"; // ex : BERF4787 string stringWithoutSpace = "stringsampleBERF4787withpattern"; string stringMatchPattern = ??? //I want to get BEFR4787 in this variable </code></pre>
0debug
Hello, I an application developer php site : I an application developer php site. My topic is to retrieve the data on the site (https://www.agriconomie.com/assortiment-de-pouples-beta-double-spire/p210645) (this is a single page) existing and display them. I started and I am currently stuck. I have retrieved the desired values (from articles the article name, price as well as other values below) in 3 different tables using the pregmatch function of php. It remains for me to display them in a table with 2 dimensions. The table will have in the first line the article name and the price. The rest of the lines will contain the titles followed by the values.This is my php code: <?php $debut="https://www.agriconomie.com"; $txt = file_get_contents('https://www.agriconomie.com/pieces-agricoles/tracteur/attelage---relevage/pc2902'); /*ici c'est pour Lire la page html*/ $results = array(); // $test = preg_match_all('#<a href="(.*?)">#', $txt, $names_array); $test = preg_match_all('#<a href="(.+)" class="(.+)" title="(.+)"#', $txt, $names_array); /*recupéré les liens du site en particuliers le text qui se situe entre griffe "" du href*/ for($i = 0; $i < count($names_array[1]); $i++) { $j=$i; $debut="https://www.agriconomie.com".$names_array[1][$i]; $adresse =$debut; /* echo $adresse ; ?> <br /> <?php */ $page = file_get_contents ($adresse); /* preg_match_all ('#<h3 class="product-name">(.+)</h3>#', $page, $names_array5); */ preg_match_all ('#(<dd>(.+)</dd>)#', $page, $names_array2); preg_match_all ('#<span><i class="icon-chevron-right"></i>(.*?)</span>#', $page, $names_array3); preg_match_all ('#<p class="price" itemprop="price" content="(.*?)">#', $page, $names_array4); echo "<center>"; echo "<table class='table table-bordered table-striped table-condensed'>"; /* for($j = 0; $j < count($names_array5[1]); $j++) { $NOM = $names_array5[1][$j]; echo 'Nom ='.$NOM ; } */ for($j = 0; $j < count($names_array4[1]); $j++) { $price = $names_array4[1][$j]; echo 'Prix ='.$price.'$' ; } for($i = 0; $i < count($names_array3[1]); $i++) { for($j= 0; $j < count($names_array2[1]); $j++){ $descriptif = $names_array2[1][$i]; } $intitule = $names_array3[1][$i]; echo "<tr><td>".$intitule." </td> <td> ".$descriptif." </td> </tr> "; } } echo "</table>"; echo "</center>"; ?> Please help me.
0debug
JAVA linked list delete node NullPointerException : <p>I was working on this code to take in a target String and search the linked list for the target and delete all instances of it. I feel like I have most of the logic down but I am getting a NullPointerException and was needing some help. here is the code:</p> <pre><code>public class LinkedStringLog implements StringLog { private LLStringNode head; private int numOfEntries; public LinkedStringLog() {//constructor head = null; numOfEntries = 0; } public void delete(String target){//deletes all entries of target LLStringNode current = head; LLStringNode prev = head; for (int i = 0; i &lt; numOfEntries; i++) { prev = current; current = current.getNext(); if (target.equals(current.getValue())){ prev.setNext(current.getNext()); current.setNext(null); numOfEntries--; } } </code></pre> <p>}</p>
0debug
static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, unsigned int max_pos, int depth) { AVCodecContext *acodec, *vcodec; ByteIOContext *ioc; AMFDataType amf_type; char str_val[256]; double num_val; num_val = 0; ioc = s->pb; amf_type = get_byte(ioc); switch(amf_type) { case AMF_DATA_TYPE_NUMBER: num_val = av_int2dbl(get_be64(ioc)); break; case AMF_DATA_TYPE_BOOL: num_val = get_byte(ioc); break; case AMF_DATA_TYPE_STRING: if(amf_get_string(ioc, str_val, sizeof(str_val)) < 0) return -1; break; case AMF_DATA_TYPE_OBJECT: { unsigned int keylen; while(url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) { url_fskip(ioc, keylen); if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0) return -1; } if(get_byte(ioc) != AMF_END_OF_OBJECT) return -1; } break; case AMF_DATA_TYPE_NULL: case AMF_DATA_TYPE_UNDEFINED: case AMF_DATA_TYPE_UNSUPPORTED: break; case AMF_DATA_TYPE_MIXEDARRAY: url_fskip(ioc, 4); while(url_ftell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) { if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0) return -1; } if(get_byte(ioc) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_ARRAY: { unsigned int arraylen, i; arraylen = get_be32(ioc); for(i = 0; i < arraylen && url_ftell(ioc) < max_pos - 1; i++) { if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0) return -1; } } break; case AMF_DATA_TYPE_DATE: url_fskip(ioc, 8 + 2); break; default: return -1; } if(depth == 1 && key) { acodec = astream ? astream->codec : NULL; vcodec = vstream ? vstream->codec : NULL; if(amf_type == AMF_DATA_TYPE_BOOL) { if(!strcmp(key, "stereo") && acodec) acodec->channels = num_val > 0 ? 2 : 1; } else if(amf_type == AMF_DATA_TYPE_NUMBER) { if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE; else if(!strcmp(key, "audiocodecid") && acodec) flv_set_audio_codec(s, astream, (int)num_val << FLV_AUDIO_CODECID_OFFSET); else if(!strcmp(key, "videocodecid") && vcodec) flv_set_video_codec(s, vstream, (int)num_val); else if(!strcmp(key, "audiosamplesize") && acodec && num_val >= 0) { acodec->bits_per_sample = num_val; if(num_val == 8 && (acodec->codec_id == CODEC_ID_PCM_S16BE || acodec->codec_id == CODEC_ID_PCM_S16LE)) acodec->codec_id = CODEC_ID_PCM_S8; } else if(!strcmp(key, "audiosamplerate") && acodec && num_val >= 0) { if (!acodec->sample_rate) { switch((int)num_val) { case 44000: acodec->sample_rate = 44100 ; break; case 22000: acodec->sample_rate = 22050 ; break; case 11000: acodec->sample_rate = 11025 ; break; case 5000 : acodec->sample_rate = 5512 ; break; default : acodec->sample_rate = num_val; } } } } } return 0; }
1threat
Is this possible to predict the lottery numbers (not the most accurate)? : <p>I am looking for the machine learning correct approach for predicting the lottery numbers, not the most accurate answer but at least we have some predicted output. I am implementing the regression based and neural network models for this. Is their any specific approach which follows this?</p>
0debug
Native component for "RCTFBLoginButton" does not exist : <p>im posting here because ive done like 12hours searching and trying things to resolve my issue , but just cant find the solution.</p> <p>Here is a screen of my errors: <a href="https://i.stack.imgur.com/HgqsK.png" rel="noreferrer">React native debugger</a></p> <p>I have followed the facebook developers step for IOS, followed instruction of FBSDK github, i've linked libraries...</p> <p>still have errors..</p> <p>Hope someone will help me out </p> <p>Regards.</p>
0debug
Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE), expecting end of file in C:\xampp\htdocs\demology\errors.php on line 11 : <p>//I get the above error when I try to run my registeration page</p> <pre><code>&lt;div&gt; &lt;?php foreach ($errors as $error): ?&gt; &lt;p&gt; &lt;?php echo $error; ?&gt;&lt;/p&gt; &lt;?php endforeach; ?&gt; &lt;/div&gt; </code></pre>
0debug
How do I modify retrieved field from varbinary to formatted string in CakePHP 3? : I'm storing UUID data as varbinary(16) in MySQL tables. This is NOT a primary key. When I read this field, I'd like to have it converted to the standard 36-character string (binary to hex with hyphens inserted) in PHP. In CakePHP 2.x I would have used the afterFind() callback. The CakePHP 3.x documentation says to [use Map/Reduce][1], but that would mean locating every find() in the code. It seems like I should be able to accomplish this in the model, perhaps as a CakePHP 3 Behavior. The table looks like this: create table `books` ( `id` int(10) unsigned not null auto_increment, `my_uuid` varbinary(16) not null, `created` timestamp not null default current_timestamp on update current_timestamp, primary key (`id`), ) engine=InnoDB; Note that I'm only asking about reading from the database. Insert and update are working fine. I'd like to convert from binary to string on read, and I think I should be doing that in the Model layer (table/entity). [1]: https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#map-reduce
0debug
How to connect to remote Redis server? : <p>I have URL and PORT of remote Redis server. I am able to write into Redis from Scala. However I want to connect to remote Redis via terminal using <code>redis-server</code> or something similar in order to make several call of <code>hget</code>, <code>get</code>, etc. (I can do it with my locally installed Redis without any problem).</p>
0debug
How does recaptcha 3 know I'm using selenium/chromedriver? : <p>I'm curious how Recaptcha v3 works. Specifically the browser fingerprinting.</p> <p>When I launch a instance of chrome through selenium/chromedriver and test against ReCaptcha 3 (<a href="https://recaptcha-demo.appspot.com/recaptcha-v3-request-scores.php" rel="noreferrer">https://recaptcha-demo.appspot.com/recaptcha-v3-request-scores.php</a>) I always get a score of 0.1 when using selenium/chromedriver. </p> <p>When using incognito with a normal instance I get 0.3.</p> <p>I've beaten other detection systems by injecting JS and modifying the web driver object and recompiling webdriver from source and modifying the $cdc_ variables. </p> <p>I can see what looks like some obfuscated POST back to the server so I'm going to start digging there.</p> <p>I just wanted to check if anyone was willing to share any advice or experience with this first about what it may be looking for to determine if I'm running selenium/chromedriver?</p>
0debug
Sql Data Type for a specific string : i have a string format like : <p> ++++++++++++++++++++++++++++<br/> Sender ==> "Testsender"<br/> Subject ==> "testsubject"<br/> Content ==> "test Content ..."<br/> ++++++++++++++++++++++++++++++<br/> ++++++++++++++++++++++++++++<br/> Sender ==> "Testsender"<br/> Subject ==> "testsubject"<br/> Content ==> "test Content ..."<br/> ++++++++++++++++++++++++++++++<br/> ++++++++++++++++++++++++++++<br/> Sender ==> "Testsender"<br/> Subject ==> "testsubject"<br/> Content ==> "test Content ..."<br/> ++++++++++++++++++++++++++++++<br/> ++++++++++++++++++++++++++++<br/> Sender ==> "Testsender"<br/> Subject ==> "testsubject"<br/> Content ==> "test Content ..."<br/> ++++++++++++++++++++++++++++++<br/> might be alot of ligns like those , <<p>My question is wich data type i should store those lignes (i think Maximum will be 100 Lignes) in a `SQL Database` have a nice day !
0debug
Empty class size in python : <p>I just trying to know the rationale behind the empty class size in python, In C++ as everyone knows the size of empty class will always shows 1 byte(as far as i have seen) this let the run time to create unique object,and i trying to find out what size of empty class in python:</p> <pre><code>class Empty:pass # i hope this will create empty class </code></pre> <p>and when i do </p> <pre><code>import sys print ("show",sys.getsizeof(Empty)) # i get 1016 </code></pre> <p>I wonder why the <code>Empty</code> takes this much 1016(bytes)? and also does the value(1016) it returns is this a standard value that never change(mostly) like C++?, Do we expect any zero base class optimization from python interpreter?Is there any way we can reduce the size of am Empty(just for curiosity sake)?</p>
0debug
how can I replace the value with the key in dictionary in python? : <p>I want the function inverse to return this output:</p> <pre><code>{3: ['I', 'love'], 2: ['python']} </code></pre> <p>the function will replace the key and the value, but if there's the same value twice, it'll be one key. how can I do that? // here's the code:</p> <pre><code>def inverse(dict1): def main(): dict1 = {'I': 3, 'love': 3, 'python': 2} print(inverse(dict1)) if __name__ == "__main__": main() </code></pre>
0debug
I can't 'npm run releasae', that show errno 1 : when I use ``npm run release`` to release my project, i get error: ------------------------------------------------------------------ > [email protected] release /home/nick/code/ops_order_system/ops_order/fesrc > gulp release assert.js:42 throw new errors.AssertionError({ ^ AssertionError [ERR_ASSERTION]: Task function must be specified at Gulp.set [as _setTask] (/home/nick/code/ops_order_system/ops_order/fesrc/node_modules/undertaker/lib/set-task.js:10:3) at Gulp.task (/home/nick/code/ops_order_system/ops_order/fesrc/node_modules/undertaker/lib/task.js:13:8) at Object.<anonymous> (/home/nick/code/ops_order_system/ops_order/fesrc/gulpfile.js:36:6) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) at Module.require (module.js:597:17) at require (internal/module.js:11:18) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] release: `gulp release` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] release script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /home/nick/.npm/_logs/2018-11-16T06_59_44_162Z-debug.log then I cat the file ```/home/nick/.npm/_logs/2018-11-16T06_59_44_162Z-debug.log```: ------------------------------------------------------------------------ 0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'release' ] 2 info using [email protected] 3 info using [email protected] 4 verbose run-script [ 'prerelease', 'release', 'postrelease' ] 5 info lifecycle [email protected]~prerelease: [email protected] 6 info lifecycle [email protected]~release: [email protected] 7 verbose lifecycle [email protected]~release: unsafe-perm in lifecycle true 8 verbose lifecycle [email protected]~release: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/nick/code/ops_order_system/ops_order/fesrc/node_modules/.bin:/home/nick/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin 9 verbose lifecycle [email protected]~release: CWD: /home/nick/code/ops_order_system/ops_order/fesrc 10 silly lifecycle [email protected]~release: Args: [ '-c', 'gulp release' ] 11 silly lifecycle [email protected]~release: Returned: code: 1 signal: null 12 info lifecycle [email protected]~release: Failed to exec release script 13 verbose stack Error: [email protected] release: `gulp release` 13 verbose stack Exit status 1 13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16) 13 verbose stack at emitTwo (events.js:126:13) 13 verbose stack at EventEmitter.emit (events.js:214:7) 13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at emitTwo (events.js:126:13) 13 verbose stack at ChildProcess.emit (events.js:214:7) 13 verbose stack at maybeClose (internal/child_process.js:915:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) 14 verbose pkgid [email protected] 15 verbose cwd /home/nick/code/ops_order_system/ops_order/fesrc 16 verbose Linux 4.15.0-36-generic 17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "release" 18 verbose node v8.12.0 19 verbose npm v6.4.1 20 error code ELIFECYCLE 21 error errno 1 22 error [email protected] release: `gulp release` 22 error Exit status 1 23 error Failed at the [email protected] release script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ] and I try 'gulp release', it got error: --------------------------------------- assert.js:42 throw new errors.AssertionError({ ^ AssertionError [ERR_ASSERTION]: Task function must be specified at Gulp.set [as _setTask] (/home/nick/code/ops_order_system/ops_order/fesrc/node_modules/undertaker/lib/se t-task.js:10:3) at Gulp.task (/home/nick/code/ops_order_system/ops_order/fesrc/node_modules/undertaker/lib/ta sk.js:13:8) at Object.<anonymous> (/home/nick/code/ops_order_system/ops_order/fesrc/gulpfile.js:36:6) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) at Module.require (module.js:597:17) at require (internal/module.js:11:18) The version is ----------------- node: v8.12.0 npm: 6.4.1 gulp: CLI version 2.0.1 Local version 4.0.0 I try many ways to solve this error, but no one is work. I really want to know how to solve this problem! before I ask this question, I have tried ```npm cache clear --force rm -rf node_modules npm install```,it not work for me, too. I also used root to run these command above, but it not work.
0debug
static void extract_mpeg4_header(AVFormatContext *infile) { int mpeg4_count, i, size; AVPacket pkt; AVStream *st; const uint8_t *p; mpeg4_count = 0; for(i=0;i<infile->nb_streams;i++) { st = infile->streams[i]; if (st->codec.codec_id == CODEC_ID_MPEG4 && st->codec.extradata_size == 0) { mpeg4_count++; } } if (!mpeg4_count) return; printf("MPEG4 without extra data: trying to find header\n"); while (mpeg4_count > 0) { if (av_read_packet(infile, &pkt) < 0) break; st = infile->streams[pkt.stream_index]; if (st->codec.codec_id == CODEC_ID_MPEG4 && st->codec.extradata_size == 0) { av_freep(&st->codec.extradata); p = pkt.data; while (p < pkt.data + pkt.size - 4) { if (p[0] == 0x00 && p[1] == 0x00 && p[2] == 0x01 && p[3] == 0xb6) { size = p - pkt.data; st->codec.extradata = av_malloc(size); st->codec.extradata_size = size; memcpy(st->codec.extradata, pkt.data, size); break; } p++; } mpeg4_count--; } av_free_packet(&pkt); } }
1threat
static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp) { uint16_t nodenr; uint16List *cpus = NULL; if (node->has_nodeid) { nodenr = node->nodeid; } else { nodenr = nb_numa_nodes; } if (nodenr >= MAX_NODES) { error_setg(errp, "Max number of NUMA nodes reached: %" PRIu16 "", nodenr); return; } if (numa_info[nodenr].present) { error_setg(errp, "Duplicate NUMA nodeid: %" PRIu16, nodenr); return; } for (cpus = node->cpus; cpus; cpus = cpus->next) { if (cpus->value >= MAX_CPUMASK_BITS) { error_setg(errp, "CPU number %" PRIu16 " is bigger than %d", cpus->value, MAX_CPUMASK_BITS - 1); return; } bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1); } if (node->has_mem && node->has_memdev) { error_setg(errp, "qemu: cannot specify both mem= and memdev="); return; } if (have_memdevs == -1) { have_memdevs = node->has_memdev; } if (node->has_memdev != have_memdevs) { error_setg(errp, "qemu: memdev option must be specified for either " "all or no nodes"); return; } if (node->has_mem) { uint64_t mem_size = node->mem; const char *mem_str = qemu_opt_get(opts, "mem"); if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) { mem_size <<= 20; } numa_info[nodenr].node_mem = mem_size; } if (node->has_memdev) { Object *o; o = object_resolve_path_type(node->memdev, TYPE_MEMORY_BACKEND, NULL); if (!o) { error_setg(errp, "memdev=%s is ambiguous", node->memdev); return; } object_ref(o); numa_info[nodenr].node_mem = object_property_get_int(o, "size", NULL); numa_info[nodenr].node_memdev = MEMORY_BACKEND(o); } numa_info[nodenr].present = true; max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1); }
1threat
static void ff_jref_idct1_put(uint8_t *dest, int line_size, DCTELEM *block) { uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; dest[0] = cm[(block[0] + 4)>>3]; }
1threat
How do to execute function just once in void loop? : simplify i want to make counter to execute subrutine if digital read get toogle value. Can you help master, please :D > ## Code # > > int lastState = 1; > > void setup() { Serial.begin(115200); } > > void loop() { > > int currentState = digitalRead(D5); if (currentState == 1){ > > if (currentState = !lastState){ > aFunction(); > } > > lastState = !lastState;} > Serial.println ("Still running loop"); delay (2000); } > > void aFunction(){ Serial.println("in a function"); }
0debug
If condiction with two different diferent values for same variable : I have to allow upload of two different types of image dimension image can either be of width 370 or 602 how can i check it using if image width `370 or 602` with if statement. If image width are correct then it is okay otherwise i delete the file. below code always fails even as either if dimension doesnt match. how can i make below to allow either dimension using System; public class Program { public static void Main() { Console.WriteLine("Hello World"); int imgW = 370; // assuming image width is 370 if (imgW != 370 || imgW != 602) { Console.WriteLine("One"); } else { Console.WriteLine("Two"); } } }
0debug
alert('Hello ' + user_input);
1threat
sed how I can replace csv only IF line contain string? : <p>I have a csv like this</p> <pre> titlemmmm;fff;ggg mmmm;fff;ggg mmmm;fff;ggg </pre> <p>I need to replace for obtain this</p> <pre> titlemmmm*fff*ggg mmmm;fff;ggg mmmm;fff;ggg </pre> <p>how I could do this </p> <p>Please help me</p>
0debug
Building Gradle porject fail : while Building my project when it reach (Task mergeReleaseAssets) i get this erorr com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/content/res/TypedArryUtils; See the Console for details ----i don't know what cause this my jdk8u-131 i tried 8u161 and i don't know about SDK maybe its api level cuz my phone api level 27 Oreo and its not on unity and i did't Download Android 8.0 (Oreo) on SDK and i'm not using In-App PURCHASING just normal ads from unity and for GoggleMobileAds i download it but i did't use it on project cuz it hurt my head and i used normal ads from unity this is the error on console ` CommandInvokationFailure: Gradle build failed. C:/Program Files/Java/jdk1.8.0_131\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease" stderr[ FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':transformClassesWithDexForRelease'. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/content/res/TypedArrayUtils; * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED in 34s ] stdout[ The setTestClassesDir(File) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the setTestClassesDirs(FileCollection) method instead. The getTestClassesDir() method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the getTestClassesDirs() method instead. The ConfigurableReport.setDestination(Object) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the method ConfigurableReport.setDestination(File) instead. :preBuild UP-TO-DATE :preReleaseBuild UP-TO-DATE :checkReleaseManifest :preDebugBuild UP-TO-DATE :prepareAdmoblibReleaseLibrary :prepareAppcompatV72610Library :prepareComAndroidSupportSupportCompat2520Library :prepareComAndroidSupportSupportCoreUi2520Library :prepareComAndroidSupportSupportCoreUtils2520Library :prepareComAndroidSupportSupportFragment2520Library :prepareComAndroidSupportSupportMediaCompat2520Library :prepareComAndroidSupportSupportV42520Library :prepareComGoogleAndroidGmsPlayServicesAds1180Library :prepareComGoogleAndroidGmsPlayServicesAdsLicense1180Library :prepareComGoogleAndroidGmsPlayServicesAdsLite1180Library :prepareComGoogleAndroidGmsPlayServicesAdsLiteLicense1180Library :prepareComGoogleAndroidGmsPlayServicesBasement1180Library :prepareComGoogleAndroidGmsPlayServicesBasementLicense1180Library :prepareComGoogleAndroidGmsPlayServicesGass1180Library :prepareComGoogleAndroidGmsPlayServicesGassLicense1180Library :preparePlayServicesAds1180Library :preparePlayServicesAdsLite1180Library :preparePlayServicesBasement1180Library :preparePlayServicesGass1180Library :prepareSupportCompat2610Library :prepareSupportV42610Library :prepareUnityAdapter2100Library :prepareUnityAdsLibrary :prepareUnityAdsSdk21Library :GoogleMobileAdsPlugin:preBuild UP-TO-DATE :GoogleMobileAdsPlugin:preReleaseBuild UP-TO-DATE :GoogleMobileAdsPlugin:checkReleaseManifest :GoogleMobileAdsPlugin:prepareReleaseDependencies :GoogleMobileAdsPlugin:compileReleaseAidl :GoogleMobileAdsPlugin:compileReleaseNdk NO-SOURCE :GoogleMobileAdsPlugin:compileLint :GoogleMobileAdsPlugin:copyReleaseLint NO-SOURCE :GoogleMobileAdsPlugin:mergeReleaseShaders :GoogleMobileAdsPlugin:compileReleaseShaders :GoogleMobileAdsPlugin:generateReleaseAssets :GoogleMobileAdsPlugin:mergeReleaseAssets :GoogleMobileAdsPlugin:mergeReleaseProguardFiles UP-TO-DATE :GoogleMobileAdsPlugin:packageReleaseRenderscript NO-SOURCE :GoogleMobileAdsPlugin:compileReleaseRenderscript :GoogleMobileAdsPlugin:generateReleaseResValues :GoogleMobileAdsPlugin:generateReleaseResources :GoogleMobileAdsPlugin:packageReleaseResources :GoogleMobileAdsPlugin:processReleaseManifest :GoogleMobileAdsPlugin:generateReleaseBuildConfig :GoogleMobileAdsPlugin:processReleaseResources :GoogleMobileAdsPlugin:generateReleaseSources :GoogleMobileAdsPlugin:incrementalReleaseJavaCompilationSafeguard :GoogleMobileAdsPlugin:javaPreCompileRelease :GoogleMobileAdsPlugin:compileReleaseJavaWithJavac :GoogleMobileAdsPlugin:processReleaseJavaRes NO-SOURCE :GoogleMobileAdsPlugin:transformResourcesWithMergeJavaResForRelease :GoogleMobileAdsPlugin:transformClassesAndResourcesWithSyncLibJarsForRelease :GoogleMobileAdsPlugin:mergeReleaseJniLibFolders :GoogleMobileAdsPlugin:transformNativeLibsWithMergeJniLibsForRelease :GoogleMobileAdsPlugin:transformNativeLibsWithStripDebugSymbolForRelease :GoogleMobileAdsPlugin:transformNativeLibsWithSyncJniLibsForRelease :GoogleMobileAdsPlugin:bundleRelease :prepareReleaseDependencies :compileReleaseAidl UP-TO-DATE :compileReleaseRenderscript UP-TO-DATE :generateReleaseBuildConfig UP-TO-DATE :generateReleaseResValues UP-TO-DATE :generateReleaseResources UP-TO-DATE :mergeReleaseResources UP-TO-DATE :processReleaseManifest :processReleaseResources :generateReleaseSources :incrementalReleaseJavaCompilationSafeguard UP-TO-DATE :javaPreCompileRelease :compileReleaseJavaWithJavac UP-TO-DATE :compileReleaseNdk NO-SOURCE :compileReleaseSources UP-TO-DATE :lintVitalRelease :mergeReleaseShaders UP-TO-DATE :compileReleaseShaders UP-TO-DATE :generateReleaseAssets UP-TO-DATE :mergeReleaseAssets :transformClassesWithDexForRelease FAILED 66 actionable tasks: 56 executed, 10 up-to-date ] exit code: 1 UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error) UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress) Rethrow as GradleInvokationException: Gradle build failed UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress) UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()`
0debug
Data type conversion error: ValueError: Cannot convert non-finite values (NA or inf) to integer : <p>I've the following dataframe</p> <pre><code>df1 = df[['tripduration','starttime','stoptime','start station name','end station name','bikeid','usertype','birth year','gender']] print(df1.head(2)) </code></pre> <p>which prints the following</p> <pre><code>tripduration starttime stoptime start station name \ 0 364 2017-09-01 00:02:01 2017-09-01 00:08:05 Exchange Place 1 357 2017-09-01 00:08:12 2017-09-01 00:14:09 Warren St end station name bikeid usertype birth year gender 0 Marin Light Rail 29670 Subscriber 1989.0 1 1 Newport Pkwy 26163 Subscriber 1980.0 1 </code></pre> <p>I am using the following code to convert "birth year" column type from float to int.</p> <pre><code>df1[['birth year']] = df1[['birth year']].astype(int) print df1.head(2) </code></pre> <p>But I get the following error. How to fix this?</p> <pre><code>ValueErrorTraceback (most recent call last) &lt;ipython-input-25-0fe766e4d4a7&gt; in &lt;module&gt;() ----&gt; 1 df1[['birth year']] = df1[['birth year']].astype(int) 2 print df1.head(2) 3 __zeppelin__._displayhook() /usr/miniconda2/lib/python2.7/site-packages/pandas/util/_decorators.pyc in wrapper(*args, **kwargs) 116 else: 117 kwargs[new_arg_name] = new_arg_value --&gt; 118 return func(*args, **kwargs) 119 return wrapper 120 return _deprecate_kwarg /usr/miniconda2/lib/python2.7/site-packages/pandas/core/generic.pyc in astype(self, dtype, copy, errors, **kwargs) 4002 # else, only a single dtype is given 4003 new_data = self._data.astype(dtype=dtype, copy=copy, errors=errors, -&gt; 4004 **kwargs) 4005 return self._constructor(new_data).__finalize__(self) 4006 /usr/miniconda2/lib/python2.7/site-packages/pandas/core/internals.pyc in astype(self, dtype, **kwargs) 3460 3461 def astype(self, dtype, **kwargs): -&gt; 3462 return self.apply('astype', dtype=dtype, **kwargs) 3463 3464 def convert(self, **kwargs): /usr/miniconda2/lib/python2.7/site-packages/pandas/core/internals.pyc in apply(self, f, axes, filter, do_integrity_check, consolidate, **kwargs) 3327 3328 kwargs['mgr'] = self -&gt; 3329 applied = getattr(b, f)(**kwargs) 3330 result_blocks = _extend_blocks(applied, result_blocks) 3331 /usr/miniconda2/lib/python2.7/site-packages/pandas/core/internals.pyc in astype(self, dtype, copy, errors, values, **kwargs) 542 def astype(self, dtype, copy=False, errors='raise', values=None, **kwargs): 543 return self._astype(dtype, copy=copy, errors=errors, values=values, --&gt; 544 **kwargs) 545 546 def _astype(self, dtype, copy=False, errors='raise', values=None, /usr/miniconda2/lib/python2.7/site-packages/pandas/core/internals.pyc in _astype(self, dtype, copy, errors, values, klass, mgr, **kwargs) 623 624 # _astype_nansafe works fine with 1-d only --&gt; 625 values = astype_nansafe(values.ravel(), dtype, copy=True) 626 values = values.reshape(self.shape) 627 /usr/miniconda2/lib/python2.7/site-packages/pandas/core/dtypes/cast.pyc in astype_nansafe(arr, dtype, copy) 685 686 if not np.isfinite(arr).all(): --&gt; 687 raise ValueError('Cannot convert non-finite values (NA or inf) to ' 688 'integer') 689 ValueError: Cannot convert non-finite values (NA or inf) to integer </code></pre>
0debug
How to check to see if my variable contains a string : <p>In my c# program, I'm reading in lines from a text file and want to check to see if the line that I read in contains the string "EHRS" and if it does, I want to put that line into an array and if not, I want to read in the next line. When I run this, I get an error that tells me that an unhandled exception of type 'System.NullReferenceException' occurred at the line where I use the contains function.</p> <p>Here's what I have:</p> <pre><code>string[] concArray = new string[numLinesConcYr]; using (var sr = new StreamReader(mydocpath + @"\concYrLines.txt")) { for (int i = 0; i &lt; numLinesConcYr; i++) { concYrLine = sr.ReadLine(); if (concYrLine.Contains("EHRS") == true) { concArray[i] = concYrLine; } else { concYrLine = sr.ReadLine(); } } } </code></pre>
0debug
Haveing trouble getting rid of the extra space to the right of my content : <p>I am using a bootstrap 3 grid on my website and I am having trouble with getting rid of this extra space thats to the right of all my content. Allowing the bottom scrollbar to be visible and move. I dont want to hide the scrollbar I know How to do that. I simply just want to fit the content to the page so that there isnt reason for the bottom scrollbar to display. Just want to make my content fit to the page. So I can continue redesigning..... </p> <p>www.Trillumonopoly.com/index2.html</p>
0debug
.net core Console application strongly typed Configuration : <p>On an .NET Core Console app, I'm trying to map settings from a custom appsettings.json file into a custom configuration class.</p> <p>I've looked at several resources online but was not able to get the .Bind extension method work (i think it works on asp.net apps or previous version of .Net Core as most of the examples show that).</p> <p>Here is the code:</p> <pre><code> static void Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); //this is a custom configuration object Configuration settings = new Configuration(); //Bind the result of GetSection to the Configuration object //unable to use .Bind extension configuration.GetSection("MySection");//.Bind(settings); //I can map each item from MySection manually like this settings.APIBaseUrl = configuration.GetSection("MySection")["APIBaseUrl"]; //what I wish to accomplish is to map the section to my Configuration object //But this gives me the error: //IConfigurationSection does not contain the definition for Bind //is there any work around for this for Console apps //or do i have to map each item manually? settings = configuration.GetSection("MySection").Bind(settings); //I'm able to get the result when calling individual keys Console.WriteLine($"Key1 = {configuration["MySection:Key1"]}"); Console.WriteLine("Hello World!"); } </code></pre> <p>Is there any approach to auto map the results from GetSection("MySection") to a custom object? This is for Console Application running on .NET Core 1.1</p> <p>Thanks!</p>
0debug
Exclude Java package from dependency jar : <p>I want to use jar from third party vendor. But in this jar I have old version of Java package <code>org.osgi.framework</code> I need to find some way to exclude the package from the main project. Something like this:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;com.ibm&lt;/groupId&gt; &lt;artifactId&gt;com.ibm.ws.admin.client&lt;/artifactId&gt; &lt;version&gt;8.5.0&lt;/version&gt; &lt;exclusions&gt; &lt;exclusion&gt;org.osgi.framework&lt;/exclusion&gt; &lt;/exclusions&gt; &lt;type&gt;jar&lt;/type&gt; &lt;/dependency&gt; </code></pre> <p>Can you recommend some solution?</p>
0debug
static void openpic_save(QEMUFile* f, void *opaque) { OpenPICState *opp = (OpenPICState *)opaque; unsigned int i; qemu_put_be32s(f, &opp->glbc); qemu_put_be32s(f, &opp->veni); qemu_put_be32s(f, &opp->pint); qemu_put_be32s(f, &opp->spve); qemu_put_be32s(f, &opp->tifr); for (i = 0; i < opp->max_irq; i++) { qemu_put_be32s(f, &opp->src[i].ipvp); qemu_put_be32s(f, &opp->src[i].ide); qemu_put_sbe32s(f, &opp->src[i].last_cpu); qemu_put_sbe32s(f, &opp->src[i].pending); } qemu_put_be32s(f, &opp->nb_cpus); for (i = 0; i < opp->nb_cpus; i++) { qemu_put_be32s(f, &opp->dst[i].pctp); qemu_put_be32s(f, &opp->dst[i].pcsr); openpic_save_IRQ_queue(f, &opp->dst[i].raised); openpic_save_IRQ_queue(f, &opp->dst[i].servicing); } for (i = 0; i < MAX_TMR; i++) { qemu_put_be32s(f, &opp->timers[i].ticc); qemu_put_be32s(f, &opp->timers[i].tibc); } }
1threat
I need my search icon into search bar : So I am trying to have a search icon only in my nav bar which is up there, but I want a search bar to drop down when the search icon is clicked on I don't know what I'm doing with this code lol <ul class="nav navbar-nav navbar-right"> <li class="dropdown"> <a href="#navs" class="dropdown-toggle" data-toggle="dropdown"> <span style="color:white" class="glyphicon glyphicon-search"></span></a> <ul class="dropdown-menu" role="menu"> <li> <input type="hidden" name="cx" /> <input type="hidden" name="ie" value="UTF-8" /> <input type="text" name="q" size="25" /> <input type="submit" name="sa" value="Search" /> </form> </li> </ul> </li> </ul> </div> </div>
0debug
How to run python code in hostgator every 30 minutes? : <p>I have hostgator shared plan. Need to put a python file in the web-host and make it run every 30 minutes.</p> <p>It is a long script, but please use a simple code instead to explain for example: a=1 a=a+1</p>
0debug
inline static int push_frame(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; AVFilterLink *inlink = ctx->inputs[0]; ShowWavesContext *showwaves = outlink->src->priv; int nb_channels = inlink->channels; int ret, i; if ((ret = ff_filter_frame(outlink, showwaves->outpicref)) >= 0) showwaves->req_fullfilled = 1; showwaves->outpicref = NULL; showwaves->buf_idx = 0; for (i = 0; i <= nb_channels; i++) showwaves->buf_idy[i] = 0; return ret; }
1threat
AVFilterFormats *avfilter_make_all_channel_layouts(void) { static int64_t chlayouts[] = { AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_4POINT0, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0, AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_5POINT1, AV_CH_LAYOUT_5POINT1_BACK, AV_CH_LAYOUT_5POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, AV_CH_LAYOUT_7POINT1, AV_CH_LAYOUT_7POINT1_WIDE, AV_CH_LAYOUT_7POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, -1, }; return avfilter_make_format64_list(chlayouts); }
1threat
Argument mismatch in python constructor : <p>I have written a python class whose constructor takes two lists as arguments.</p> <pre><code>class nn: def __init__(layer_dimensions=[],activations=[]): self.parameters = {} self.cache = [] self.activations= [] initialize_parameters(layer_dimensions) initialize_activations(activations) net = nn(list([2,15,2]),list(['relu','sigmoid'])) </code></pre> <p>On trying to pass two lists as arguments in the constructor I get the following error:</p> <pre><code>TypeError: __init__() takes from 0 to 2 positional arguments but 3 were given </code></pre> <p>The error states that 3 arguments have been passed but its quite obvious that I've passed only 2.</p>
0debug
Android app . fetching data from database : <p>I am a new Android app developer and need some help. I want to develop a simple login app just for understanding the working. Using sqlite we can create tables and insert records in our application , but how to keep the table centralised for username and password so that all the users can access the same table from the app for login instead of creating the database on your device. Please help with some tips or any links which will help me clearify my doubts. Thanks in advance.</p>
0debug
static void decode_422_bitstream(HYuvContext *s, int count) { int i; count /= 2; if (count >= (get_bits_left(&s->gb)) / (31 * 4)) { for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) { READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1); READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2); } } else { for (i = 0; i < count; i++) { READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1); READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2); } } }
1threat
How to replace all spaces present in a string with underscore using javascript? : <p>I have a string with spaces separating words. I want to replace all the spaces in the string with underscore. Please tell me any small code for that because my solution is taking too much space. Example : 'Divyanshu Singh Divyanshu Singh' output : 'Divyanshu_singh_Divyanshu_Singh'</p>
0debug
Wiring and injected NLog into a .Net Core console application : <p>I created a consumer/job that I will have running as a process on linux written in C#. </p> <p>The process will:</p> <ol> <li>Read a message from RabbitMQ </li> <li>Make changes to the database </li> <li>Log any errors</li> </ol> <p>All the documentation on nlog about .net core are on aspnet core. When I try to get an <code>ILogger</code> implementation, it returns null.</p> <p>Here is an except of wiring and usage:</p> <pre><code>static void ConfigureServices() { string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); var builder = new ConfigurationBuilder() .SetBasePath(Path.Combine(AppContext.BaseDirectory)) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{environment}.json", optional: true); var services = new ServiceCollection(); Configuration = builder.Build(); [...] services.AddLogging(); ServiceProvider = services.BuildServiceProvider(); var loggerFactory = ServiceProvider.GetService&lt;ILoggerFactory&gt;(); loggerFactory.AddNLog(); } static void Main(string[] args) { ConfigureServices(); var logger = ServiceProvider.GetService&lt;NLog.ILogger&gt;(); logger.Debug("Logging"); [...] } </code></pre> <p>Do not be confused with the environment variable <code>ASPNETCORE_ENVIRONMENT</code>; it is used solely to determine which <code>appsettings.json</code> to use.</p> <p>I've based my code on this <a href="https://github.com/NLog/NLog.Extensions.Logging/issues/111" rel="noreferrer">issue report</a>.</p> <p>Finally, these are the packages I currently have installed.</p> <pre><code>&lt;ItemGroup&gt; &lt;PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" /&gt; &lt;PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.2" /&gt; &lt;PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="1.1.2" /&gt; &lt;PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.2" /&gt; &lt;PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" /&gt; &lt;PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.2" /&gt; &lt;PackageReference Include="NLog" Version="5.0.0-beta09" /&gt; &lt;PackageReference Include="NLog.Extensions.Logging" Version="1.0.0-rtm-beta5" /&gt; &lt;PackageReference Include="Npgsql" Version="3.2.4.1" /&gt; &lt;PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="1.1.0" /&gt; &lt;/ItemGroup&gt; </code></pre>
0debug
Kotlin call function only if all arguments are not null : <p>Is there a way in kotlin to prevent function call if all (or some) arguments are null? For example Having function:</p> <pre><code>fun test(a: Int, b: Int) { /* function body here */ } </code></pre> <p>I would like to prevent null checks in case when arguments are <code>null</code>. For example, for arguments:</p> <pre><code>val a: Int? = null val b: Int? = null </code></pre> <p>I would like to replace:</p> <pre><code>a?.let { b?.let { test(a, b) } } </code></pre> <p>with:</p> <pre><code>test(a, b) </code></pre> <p>I imagine that function definition syntax could look something like this:</p> <pre><code>fun test(@PreventNullCall a: Int, @PreventNullCall b: Int) </code></pre> <p>And that would be equivalent to:</p> <pre><code>fun test(a: Int?, b: Int?) { if(a == null) { return } if(b == null) { return } // function body here } </code></pre> <p>Is something like that (or similar) possible to reduce caller (and possibly function author) redundant code?</p>
0debug
static void FUNC(put_hevc_qpel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, int denom, int wx0, int wx1, int ox0, int ox1, intptr_t mx, intptr_t my, int width) { int x, y; pixel *src = (pixel*)_src; ptrdiff_t srcstride = _srcstride / sizeof(pixel); pixel *dst = (pixel *)_dst; ptrdiff_t dststride = _dststride / sizeof(pixel); const int8_t *filter = ff_hevc_qpel_filters[mx - 1]; int shift = 14 + 1 - BIT_DEPTH; int log2Wd = denom + shift - 1; ox0 = ox0 * (1 << (BIT_DEPTH - 8)); ox1 = ox1 * (1 << (BIT_DEPTH - 8)); for (y = 0; y < height; y++) { for (x = 0; x < width; x++) dst[x] = av_clip_pixel(((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 + ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1)); src += srcstride; dst += dststride; src2 += MAX_PB_SIZE; } }
1threat
Python - How do I fix this speed varible writing back to file? : I've been writing a program, I've run into an error. My current code is: import tkinter as tk speed = 80 def onKeyPress(event, value): global speed text.delete("%s-1c" % 'insert', 'insert') text.insert('end', 'Current Speed: %s\n\n' % (speed, )) with open("speed.txt", "r+") as p: speed = p.read() speed = int(speed) speed = min(max(speed+value, 0), 100) with open("speed.txt", "r+") as p: p.writelines(str(speed)) print(speed) if speed == 100: text.insert('end', 'You have reached the speed limit') if speed == 0: text.insert('end', 'You can not go any slower') speed = 80 root = tk.Tk() root.geometry('300x200') text = tk.Text(root, background='black', foreground='white', font=('Comic Sans MS', 12)) text.pack() # Individual key bindings root.bind('<KeyPress-w>', lambda e: onKeyPress(e, 1)) root.bind('<KeyPress-s>', lambda e: onKeyPress(e, -1)) # root.mainloop() I believe speed = min.... is causing the error? However do you guys have any idea?
0debug
Installing docker on azure virtual machine windows 10 : <p>I am getting an error upon installing docker on azure virtual machine.</p> <p><a href="https://i.stack.imgur.com/SKZI0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SKZI0.png" alt="enter image description here"></a></p> <p>m/c configuration: azure vm, windows 10 enterprise, Intel 2.4 GHz, 7 GB RAM, 64-bit operating system, x64-based processor. I went through a few blogs and they asked me to enable nested virtualization on azure vm as follows.</p> <blockquote> <p>Set-VMProcessor -VMName MobyLinuxVM -ExposeVirtualizationExtensions $true</p> </blockquote> <p>But this also didn't help and the virtual m/c MobyLinuxVM failed to start. I have installed Hyper-V and Container components from windows features. But the error shows "because one of the Hyper-V components is not running" whereas all the components of Hyper-V are running. I checked the task manager performance tab and I don't see the virtualization option there. I can't modify the virtualization settings in the BIOS as I am installing docker on an Azure VM. Also I tried disabling the windows firewall but that didn't help. So how to run docker on azure virtual m/c windows 10 enterprise.</p>
0debug
I am New In asp.net I just make a login page and i want to show user info name Adress etc when i successfuly login : > ## This is controller code for Login ##> This is User Login Controller code where I authenticating user EmailID and password when > user login redirected to Home Controller where i want to show user > info > > > > > [HttpPost] > > [ValidateAntiForgeryToken] > > public ActionResult Login(UserLogin login, string ReturnUrl = "") > > { > > string message = ""; > > using (LoginEntities dc = new LoginEntities()) > > { > > var v = dc.Users.Where(a => a.EmailID == login.EmailID).FirstOrDefault(); > > var n = dc.Users.Where(a => a.Password == login.Password).FirstOrDefault(); > > if (v != null || n != null ) > > { > > if (string.Compare(Crypto.Hash(login.Password), v.Password) == 0) > > { > > int timeout = login.RememberME ? 525600 : 20; > > var ticket = new FormsAuthenticationTicket(login.EmailID,login.RememberME,timeout); > > string encrypted = FormsAuthentication.Encrypt(ticket); > > var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted); > > cookie.Expires = DateTime.Now.AddMinutes(timeout); > > cookie.HttpOnly = true; > > Response.Cookies.Add(cookie); > > > > if (Url.IsLocalUrl(ReturnUrl)) > > { > > return Redirect(ReturnUrl); > > > > } > > else > > { > > return RedirectToAction("Index", "Home"); > > } > > > > } > > else > > { > > message = "Invalid Credential Provided"; > > } > > } > > else > > { > > message = "Invalid Credential Provided"; > > } > > > > > > } > > ViewBag.Message = message; > > return View(); > > } > > > > > ##Home Contrler and index action where i redirect when i login##> This is Home COntroller Where I redirected After Loging successfully > pleas some one give a code for home controlller and index action where > i can Get Id of user That login and and and tell me how to show that > in view > > > > public class HomeController : Controller > > { > > LoginEntities db = new LoginEntities(); > > // GET: Home > > [Authorize] > > public ActionResult Index() > > { > > if (Session.Contents.Count == 0) > > { > > RedirectToAction("Login", "User"); > > } > > > > > > return View(); > > } > > }
0debug
How to Run private class method.in same class in java : Can figure why it won't allow me to run the displaymainMethod because its private even though i know i can run it from from same class. is there a way to do this without using reflective API. import java.util.*; public class LoginPrototype { public static void main(String[] args) { ArrayList<Credentials> allUsers = new ArrayList<Credentials>(); displayMainMenu mainMenu = new displayMenu(); } private void displayMainMenu() { int input; do { System.out.println("Menu Options"); System.out.println("[1] Login"); System.out.println("[2] Register"); System.out.println("[0] Quit");//5 Displaying Main Menu Options Scanner sc = new Scanner(System.in); input = sc.nextInt(); if (input > 2) { System.out.println("Please enter a value of [0] - [2]"); } else if (input == 1){ System.out.println("Login"); } else if (input == 2){ System.out.println("Register"); } else if (input == 0){ System.out.println("Thank you. bye."); } }while(input >= 2); } }
0debug
Multiple images inside one container : <p>So, here is the problem, I <strong>need to do</strong> some <strong>development</strong> and for that I need following packages:</p> <ol> <li>MongoDb</li> <li>NodeJs</li> <li>Nginx</li> <li>RabbitMq</li> <li>Redis</li> </ol> <p>One option is that <strong>I take a Ubuntu image</strong>, <strong>create a container</strong> and start installing them one by one and done, start my server, and expose the ports.</p> <p>But this can easily be done in a virtual box also, and it will not going to use the power of Docker. So for that I have to start building my own image with these packages. Now here is the question if I start writing my Dockerfile and if place the commands to download the Node js (and others) inside of it, this again becomes the same thing like virtualization.</p> <p>What I need is that I <strong>start from Ubuntu</strong> and keep on <strong>adding</strong> the <strong>references</strong> of <strong>MongoDb, NodeJs, RabbitMq, Nginx and Redis</strong> inside the <strong>Dockerfile</strong> and finally expose the respective ports out. </p> <p>Here are the queries I have:</p> <ol> <li>Is this possible? Like adding the refrences of other images inside the Dockerfile when you are starting FROM one base image.</li> <li>If yes then how?</li> <li>Also is this the correct practice or not?</li> <li>How to do these kind of things in Docker ?</li> </ol> <p>Thanks in advance.</p>
0debug
How do I compare three Boolean values when the comparisons are long? : I am trying to set up a condition check for my code. However, the code has become long and complex. I need a simpler version of the code that can easily do the job. I have tried to compare three boolean values separated by brackets such that I only compare two values. if ((((userState[0][0]&&userState[0][1])&&(userState[0][2])))||(((userState[1][0]&&userState[1][1])&&(userState[1][2])))||(((userState[2][0]&&userState[2][1])&&(userState[2][2])))||(((userState[0][0]&&userState[1][0])&&(userState[2][0])))||(((userState[0][1]&&userState[2][1])&&(userState[1][1])))||(((userState[0][2]&&userState[2][2])&&(userState[1][2])))||(((userState[0][0]&&userState[2][2])&&(userState[1][1])))||(((userState[1][2]&&userState[1][1])&&(userState[2][0]))))
0debug
how to access database stored in array, specially particular rows and column : I am using laraval5.1 . i have stored by database table in array. Now i dont know how to access that array by rows or column.. how to get get particular data from array which is required by me from array. please tell me how to do that. $silver_plans = array(); $silver_plans = DB::select('select * from ins_gold '); // print_r($silver_plans[0]); // print_r($silver_plans['0']['age_band']); this is code which is applied by me. i tried to access 'age_column'.
0debug
Android TV RecyclerView focus interaction : <p>I'm currently using a regular <code>RecyclerView</code> with <code>GridLayoutManager</code>with different <code>spanCount</code> depeding on the <code>viewType</code> for an Android TV app. All is working decent but I have 2 issues:</p> <ol> <li>If you long press the dpad down to scroll fast between the items sometimes the focus is lost to a view that isn't a child of the RecyclerView.</li> <li>How can I tell the <code>RecyclerView</code> to keep the current focused view in the center of the grid?</li> </ol> <p>It seems that the issues listed are fixed by using the <code>VerticalGridView</code> from <code>LeanBack</code> library but the <code>LayoutManger</code> that it uses is internal and doesn't support <code>spanCount</code>.</p>
0debug
static int vhost_verify_ring_mappings(struct vhost_dev *dev, uint64_t start_addr, uint64_t size) { int i; for (i = 0; i < dev->nvqs; ++i) { struct vhost_virtqueue *vq = dev->vqs + i; hwaddr l; void *p; if (!ranges_overlap(start_addr, size, vq->ring_phys, vq->ring_size)) { continue; } l = vq->ring_size; p = cpu_physical_memory_map(vq->ring_phys, &l, 1); if (!p || l != vq->ring_size) { fprintf(stderr, "Unable to map ring buffer for ring %d\n", i); return -ENOMEM; } if (p != vq->ring) { fprintf(stderr, "Ring buffer relocated for ring %d\n", i); return -EBUSY; } cpu_physical_memory_unmap(p, l, 0, 0); } return 0; }
1threat
How to call a function in python when using it's name as string? : I am trying to read lines from my data and and output both the `forward` and `reverse` orientation by passing my list to a function. To solve what I am trying to do, I have to pipe the `function-name as string`. I am making a mock test below that replicates my original problem in a simple way. my_str = 'abcdef\nijklmn\nstuv\n' my_str = my_str.rstrip('\n').split('\n') for lines in my_str: print(lines) line_list = list(lines) # I want to read both forward and reverse orientation using a function "(def orient_my_str():" # the reason to pass this into another function is because I have lots of data crunching to do in each orientation (not shown here). # but, below process typically resolves what I am trying to achieve line_rev = orient_my_str(line_list, orientation='reversed') line_fwd = orient_my_str(line_list, orientation='') print('list in reverse orientation :', line_rev) print('list in forward orientation :', line_fwd) print() def orient_my_str(line, orientation): my_output = '' for item in eval(orientation)(line): my_output += item print(my_output) return my_output # But, this only works for reverse orientation. I know the issue is with passing "eval('')(line)" but was hoping it would work. I tried to fix my code using ideas from these links, https://stackoverflow.com/questions/4131864/use-a-string-to-call-function-in-python https://stackoverflow.com/questions/3061/calling-a-function-of-a-module-by-using-its-name-a-string https://stackoverflow.com/questions/4431216/python-function-call-with-variable but I cannot seem to work it out.
0debug
static void parse_error(JSONParserContext *ctxt, QObject *token, const char *msg, ...) { fprintf(stderr, "parse error: %s\n", msg); }
1threat
Cannot run downloaded project on Android Studio : <p>I just downloaded an android project that I paid for but i cannot run the app on android studio. How do I run the project on android studio?</p>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
API's to use with java to have fun with : <p>so I've been coding in java for the past 2 years, mainly making mods for Minecraft. Recently though I started making discord bots, and I've never really done anything with Java outside of Minecraft, and was using JDA(Java Discord API), and i realized how fun it was. I was wondering if any of you guys knew of some API's i could use to do some cool stuff with :D</p>
0debug