problem
stringlengths
26
131k
labels
class label
2 classes
TypeError: get_weather() takes no arguments (1 given) : <p>I'm taking an online course with StackSkills for Python and have copied the code exactly as given in the lecture - we're making a weather app using Flask. I keep getting this message: TypeError: get_weather() takes no arguments (1 given)</p> <p>The Python Page <a href="https://i.stack.imgur.com/84aRm.png" rel="nofollow noreferrer">1</a></p> <p>The HTML Page <a href="https://i.stack.imgur.com/9E5Dx.png" rel="nofollow noreferrer">2</a></p> <p>Any suggestions? Thank you in advance! </p>
0debug
int av_reallocp_array(void *ptr, size_t nmemb, size_t size) { void **ptrptr = ptr; *ptrptr = av_realloc_f(*ptrptr, nmemb, size); if (!*ptrptr && !(nmemb && size)) return AVERROR(ENOMEM); return 0; }
1threat
How to pass text from textarea to reflect or show in another page, without losing the formatting? : <p>I am making an application using javascript (no JQuery) and php. I have a textarea form -which applies - space formatting. But when I send the values from this textarea to another page using PHP post command ..the spacing is gone. How can I reflect the content of the textarea along with spacing?</p>
0debug
How can I re-sort records for my text file? : <p>Morning guys,</p> <p>I have a text file like this (original.txt):</p> <pre><code>AAAA BBBB CCCC DDDD EEEE FFFF </code></pre> <p>I need a file like this (result.txt):</p> <pre><code>AAAA BBBB CCCC DDDD EEEE FFFF </code></pre> <p>Could you please help me with that by batch?</p> <p>Thanks,</p>
0debug
static unsigned int dec_subs_r(DisasContext *dc) { TCGv t0; int size = memsize_z(dc); DIS(fprintf (logfile, "subs.%c $r%u, $r%u\n", memsize_char(size), dc->op1, dc->op2)); cris_cc_mask(dc, CC_MASK_NZVC); t0 = tcg_temp_new(TCG_TYPE_TL); t_gen_sext(t0, cpu_R[dc->op1], size); cris_alu(dc, CC_OP_SUB, cpu_R[dc->op2], cpu_R[dc->op2], t0, 4); tcg_temp_free(t0); return 2; }
1threat
static int blk_connect(struct XenDevice *xendev) { struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); int pers, index, qflags; bool readonly = true; if (blkdev->directiosafe) { qflags = BDRV_O_NOCACHE | BDRV_O_NATIVE_AIO; } else { qflags = BDRV_O_CACHE_WB; } if (strcmp(blkdev->mode, "w") == 0) { qflags |= BDRV_O_RDWR; readonly = false; } index = (blkdev->xendev.dev - 202 * 256) / 16; blkdev->dinfo = drive_get(IF_XEN, 0, index); if (!blkdev->dinfo) { xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n"); blkdev->bs = bdrv_new(blkdev->dev); if (blkdev->bs) { Error *local_err = NULL; BlockDriver *drv = bdrv_find_whitelisted_format(blkdev->fileproto, readonly); if (bdrv_open(&blkdev->bs, blkdev->filename, NULL, NULL, qflags, drv, &local_err) != 0) { xen_be_printf(&blkdev->xendev, 0, "error: %s\n", error_get_pretty(local_err)); error_free(local_err); bdrv_unref(blkdev->bs); blkdev->bs = NULL; } } if (!blkdev->bs) { return -1; } } else { xen_be_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n"); blkdev->bs = blkdev->dinfo->bdrv; if (bdrv_is_read_only(blkdev->bs) && !readonly) { xen_be_printf(&blkdev->xendev, 0, "Unexpected read-only drive"); blkdev->bs = NULL; return -1; } bdrv_ref(blkdev->bs); } bdrv_attach_dev_nofail(blkdev->bs, blkdev); blkdev->file_size = bdrv_getlength(blkdev->bs); if (blkdev->file_size < 0) { xen_be_printf(&blkdev->xendev, 1, "bdrv_getlength: %d (%s) | drv %s\n", (int)blkdev->file_size, strerror(-blkdev->file_size), bdrv_get_format_name(blkdev->bs) ?: "-"); blkdev->file_size = 0; } xen_be_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\"," " size %" PRId64 " (%" PRId64 " MB)\n", blkdev->type, blkdev->fileproto, blkdev->filename, blkdev->file_size, blkdev->file_size >> 20); xenstore_write_be_int(&blkdev->xendev, "sector-size", blkdev->file_blk); xenstore_write_be_int64(&blkdev->xendev, "sectors", blkdev->file_size / blkdev->file_blk); if (xenstore_read_fe_int(&blkdev->xendev, "ring-ref", &blkdev->ring_ref) == -1) { return -1; } if (xenstore_read_fe_int(&blkdev->xendev, "event-channel", &blkdev->xendev.remote_port) == -1) { return -1; } if (xenstore_read_fe_int(&blkdev->xendev, "feature-persistent", &pers)) { blkdev->feature_persistent = FALSE; } else { blkdev->feature_persistent = !!pers; } blkdev->protocol = BLKIF_PROTOCOL_NATIVE; if (blkdev->xendev.protocol) { if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_32) == 0) { blkdev->protocol = BLKIF_PROTOCOL_X86_32; } if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_64) == 0) { blkdev->protocol = BLKIF_PROTOCOL_X86_64; } } blkdev->sring = xc_gnttab_map_grant_ref(blkdev->xendev.gnttabdev, blkdev->xendev.dom, blkdev->ring_ref, PROT_READ | PROT_WRITE); if (!blkdev->sring) { return -1; } blkdev->cnt_map++; switch (blkdev->protocol) { case BLKIF_PROTOCOL_NATIVE: { blkif_sring_t *sring_native = blkdev->sring; BACK_RING_INIT(&blkdev->rings.native, sring_native, XC_PAGE_SIZE); break; } case BLKIF_PROTOCOL_X86_32: { blkif_x86_32_sring_t *sring_x86_32 = blkdev->sring; BACK_RING_INIT(&blkdev->rings.x86_32_part, sring_x86_32, XC_PAGE_SIZE); break; } case BLKIF_PROTOCOL_X86_64: { blkif_x86_64_sring_t *sring_x86_64 = blkdev->sring; BACK_RING_INIT(&blkdev->rings.x86_64_part, sring_x86_64, XC_PAGE_SIZE); break; } } if (blkdev->feature_persistent) { blkdev->max_grants = max_requests * BLKIF_MAX_SEGMENTS_PER_REQUEST; blkdev->persistent_gnts = g_tree_new_full((GCompareDataFunc)int_cmp, NULL, NULL, (GDestroyNotify)destroy_grant); blkdev->persistent_gnt_count = 0; } xen_be_bind_evtchn(&blkdev->xendev); xen_be_printf(&blkdev->xendev, 1, "ok: proto %s, ring-ref %d, " "remote port %d, local port %d\n", blkdev->xendev.protocol, blkdev->ring_ref, blkdev->xendev.remote_port, blkdev->xendev.local_port); return 0; }
1threat
static void mcf_fec_cleanup(NetClientState *nc) { mcf_fec_state *s = qemu_get_nic_opaque(nc); g_free(s); }
1threat
Searching and sorting java : So i am trying to solve this following question in java for practice as I am a beginneer and trying to strengthen my java skills. Here is the question... __________________________________________________ According to our suggested 16 week course schedule, this programming project should be completed no later than the Monday of Week 13. It is worth 8 per cent of your final grade. Please refer to your Assignment Instructions document on your Home Page for details on the submission of your work. Your overall course assessment information is found in your Course Guide. 1. The Shell sort is a variation of the bubble sort. Instead of comparing adjacent values, the Shell sort adapts a concept from the binary search to determine a ‘gap’ across which values are compared before any swap takes place. In the first pass, the gap is half the size of the array. For each subsequent pass, the gap size is cut in half. For the final pass(es), the gap size is 1, so it would be the same as a bubble sort. The passes continue until no swaps occur. Below is the same set of values as per the bubble sort example in Chapter 18 (p.681), showing the first pass: 9 6 8 12 3 1 7 ‐‐ size of array is 7, so gap would be 3 9 6 8 12 3 1 7 ‐‐ 9 and 12 are already in order, so no ^---------^ 9 6 8 12 3 1 7 ‐‐ 6 and 3 are not in order, so swap ^---------^ 9 3 8 12 6 1 7 ‐‐ 8 and 1 are not in order, so swap ^---------^ 9 3 1 12 6 8 7 ‐‐ 12 and 7 are not in order, so swap ^---------^ 9 3 8 7 6 1 12 ‐‐ end of pass 1  __________________________________ I dont want anyone to give me the direct code but would appreciate a opinion on how to tackle the question as I am having a hard time getting it started. Please keep in mind that I am a begineer so know really advanced methods! Thanks for your time
0debug
static int init_tile(Jpeg2000DecoderContext *s, int tileno) { int compno; int tilex = tileno % s->numXtiles; int tiley = tileno / s->numXtiles; Jpeg2000Tile *tile = s->tile + tileno; if (!tile->comp) return AVERROR(ENOMEM); tile->coord[0][0] = av_clip(tilex * s->tile_width + s->tile_offset_x, s->image_offset_x, s->width); tile->coord[0][1] = av_clip((tilex + 1) * s->tile_width + s->tile_offset_x, s->image_offset_x, s->width); tile->coord[1][0] = av_clip(tiley * s->tile_height + s->tile_offset_y, s->image_offset_y, s->height); tile->coord[1][1] = av_clip((tiley + 1) * s->tile_height + s->tile_offset_y, s->image_offset_y, s->height); for (compno = 0; compno < s->ncomponents; compno++) { Jpeg2000Component *comp = tile->comp + compno; Jpeg2000CodingStyle *codsty = tile->codsty + compno; Jpeg2000QuantStyle *qntsty = tile->qntsty + compno; int ret; comp->coord_o[0][0] = tile->coord[0][0]; comp->coord_o[0][1] = tile->coord[0][1]; comp->coord_o[1][0] = tile->coord[1][0]; comp->coord_o[1][1] = tile->coord[1][1]; if (compno) { comp->coord_o[0][0] /= s->cdx[compno]; comp->coord_o[0][1] /= s->cdx[compno]; comp->coord_o[1][0] /= s->cdy[compno]; comp->coord_o[1][1] /= s->cdy[compno]; } comp->coord[0][0] = ff_jpeg2000_ceildivpow2(comp->coord_o[0][0], s->reduction_factor); comp->coord[0][1] = ff_jpeg2000_ceildivpow2(comp->coord_o[0][1], s->reduction_factor); comp->coord[1][0] = ff_jpeg2000_ceildivpow2(comp->coord_o[1][0], s->reduction_factor); comp->coord[1][1] = ff_jpeg2000_ceildivpow2(comp->coord_o[1][1], s->reduction_factor); if (ret = ff_jpeg2000_init_component(comp, codsty, qntsty, s->cbps[compno], s->cdx[compno], s->cdy[compno], s->avctx)) return ret; } return 0; }
1threat
How to use down symbol to display list of users : How to design and code this in swift(IOS) AND xcode.If we tap on down button it should display items and vicecersa[enter image description here][1] [1]: https://i.stack.imgur.com/WGfwR.png
0debug
static void disas_xtensa_insn(DisasContext *dc) { #define HAS_OPTION(opt) do { \ if (!option_enabled(dc, opt)) { \ qemu_log("Option %d is not enabled %s:%d\n", \ (opt), __FILE__, __LINE__); \ goto invalid_opcode; \ } \ } while (0) #ifdef TARGET_WORDS_BIGENDIAN #define OP0 (((b0) & 0xf0) >> 4) #define OP1 (((b2) & 0xf0) >> 4) #define OP2 ((b2) & 0xf) #define RRR_R ((b1) & 0xf) #define RRR_S (((b1) & 0xf0) >> 4) #define RRR_T ((b0) & 0xf) #else #define OP0 (((b0) & 0xf)) #define OP1 (((b2) & 0xf)) #define OP2 (((b2) & 0xf0) >> 4) #define RRR_R (((b1) & 0xf0) >> 4) #define RRR_S (((b1) & 0xf)) #define RRR_T (((b0) & 0xf0) >> 4) #endif #define RRRN_R RRR_R #define RRRN_S RRR_S #define RRRN_T RRR_T #define RRI8_R RRR_R #define RRI8_S RRR_S #define RRI8_T RRR_T #define RRI8_IMM8 (b2) #define RRI8_IMM8_SE ((((b2) & 0x80) ? 0xffffff00 : 0) | RRI8_IMM8) #ifdef TARGET_WORDS_BIGENDIAN #define RI16_IMM16 (((b1) << 8) | (b2)) #else #define RI16_IMM16 (((b2) << 8) | (b1)) #endif #ifdef TARGET_WORDS_BIGENDIAN #define CALL_N (((b0) & 0xc) >> 2) #define CALL_OFFSET ((((b0) & 0x3) << 16) | ((b1) << 8) | (b2)) #else #define CALL_N (((b0) & 0x30) >> 4) #define CALL_OFFSET ((((b0) & 0xc0) >> 6) | ((b1) << 2) | ((b2) << 10)) #endif #define CALL_OFFSET_SE \ (((CALL_OFFSET & 0x20000) ? 0xfffc0000 : 0) | CALL_OFFSET) #define CALLX_N CALL_N #ifdef TARGET_WORDS_BIGENDIAN #define CALLX_M ((b0) & 0x3) #else #define CALLX_M (((b0) & 0xc0) >> 6) #endif #define CALLX_S RRR_S #define BRI12_M CALLX_M #define BRI12_S RRR_S #ifdef TARGET_WORDS_BIGENDIAN #define BRI12_IMM12 ((((b1) & 0xf) << 8) | (b2)) #else #define BRI12_IMM12 ((((b1) & 0xf0) >> 4) | ((b2) << 4)) #endif #define BRI12_IMM12_SE (((BRI12_IMM12 & 0x800) ? 0xfffff000 : 0) | BRI12_IMM12) #define BRI8_M BRI12_M #define BRI8_R RRI8_R #define BRI8_S RRI8_S #define BRI8_IMM8 RRI8_IMM8 #define BRI8_IMM8_SE RRI8_IMM8_SE #define RSR_SR (b1) uint8_t b0 = ldub_code(dc->pc); uint8_t b1 = ldub_code(dc->pc + 1); uint8_t b2 = ldub_code(dc->pc + 2); static const uint32_t B4CONST[] = { 0xffffffff, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256 }; static const uint32_t B4CONSTU[] = { 32768, 65536, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256 }; if (OP0 >= 8) { dc->next_pc = dc->pc + 2; HAS_OPTION(XTENSA_OPTION_CODE_DENSITY); } else { dc->next_pc = dc->pc + 3; } switch (OP0) { case 0: switch (OP1) { case 0: switch (OP2) { case 0: if ((RRR_R & 0xc) == 0x8) { HAS_OPTION(XTENSA_OPTION_BOOLEAN); } switch (RRR_R) { case 0: switch (CALLX_M) { case 0: break; case 1: break; case 2: switch (CALLX_N) { case 0: case 2: gen_jump(dc, cpu_R[CALLX_S]); break; case 1: HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER); break; case 3: break; } break; case 3: switch (CALLX_N) { case 0: { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_mov_i32(tmp, cpu_R[CALLX_S]); tcg_gen_movi_i32(cpu_R[0], dc->next_pc); gen_jump(dc, tmp); tcg_temp_free(tmp); } break; case 1: case 2: case 3: HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER); break; } break; } break; case 1: HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER); break; case 2: break; case 3: break; } break; case 1: tcg_gen_and_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]); break; case 2: tcg_gen_or_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]); break; case 3: tcg_gen_xor_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]); break; case 4: switch (RRR_R) { case 0: gen_right_shift_sar(dc, cpu_R[RRR_S]); break; case 1: gen_left_shift_sar(dc, cpu_R[RRR_S]); break; case 2: { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_shli_i32(tmp, cpu_R[RRR_S], 3); gen_right_shift_sar(dc, tmp); tcg_temp_free(tmp); } break; case 3: { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_shli_i32(tmp, cpu_R[RRR_S], 3); gen_left_shift_sar(dc, tmp); tcg_temp_free(tmp); } break; case 4: { TCGv_i32 tmp = tcg_const_i32( RRR_S | ((RRR_T & 1) << 4)); gen_right_shift_sar(dc, tmp); tcg_temp_free(tmp); } break; case 6: break; case 7: break; case 8: HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER); break; case 14: HAS_OPTION(XTENSA_OPTION_MISC_OP); gen_helper_nsa(cpu_R[RRR_T], cpu_R[RRR_S]); break; case 15: HAS_OPTION(XTENSA_OPTION_MISC_OP); gen_helper_nsau(cpu_R[RRR_T], cpu_R[RRR_S]); break; default: break; } break; case 5: break; case 6: switch (RRR_S) { case 0: tcg_gen_neg_i32(cpu_R[RRR_R], cpu_R[RRR_T]); break; case 1: { int label = gen_new_label(); tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_T]); tcg_gen_brcondi_i32( TCG_COND_GE, cpu_R[RRR_R], 0, label); tcg_gen_neg_i32(cpu_R[RRR_R], cpu_R[RRR_T]); gen_set_label(label); } break; default: break; } break; case 7: break; case 8: tcg_gen_add_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]); break; case 9: case 10: case 11: { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_shli_i32(tmp, cpu_R[RRR_S], OP2 - 8); tcg_gen_add_i32(cpu_R[RRR_R], tmp, cpu_R[RRR_T]); tcg_temp_free(tmp); } break; case 12: tcg_gen_sub_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_R[RRR_T]); break; case 13: case 14: case 15: { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_shli_i32(tmp, cpu_R[RRR_S], OP2 - 12); tcg_gen_sub_i32(cpu_R[RRR_R], tmp, cpu_R[RRR_T]); tcg_temp_free(tmp); } break; } break; case 1: switch (OP2) { case 0: case 1: tcg_gen_shli_i32(cpu_R[RRR_R], cpu_R[RRR_S], 32 - (RRR_T | ((OP2 & 1) << 4))); break; case 2: case 3: tcg_gen_sari_i32(cpu_R[RRR_R], cpu_R[RRR_T], RRR_S | ((OP2 & 1) << 4)); break; case 4: tcg_gen_shri_i32(cpu_R[RRR_R], cpu_R[RRR_T], RRR_S); break; case 6: { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_mov_i32(tmp, cpu_R[RRR_T]); gen_rsr(dc, cpu_R[RRR_T], RSR_SR); gen_wsr(dc, RSR_SR, tmp); tcg_temp_free(tmp); } break; #define gen_shift_reg(cmd, reg) do { \ TCGv_i64 tmp = tcg_temp_new_i64(); \ tcg_gen_extu_i32_i64(tmp, reg); \ tcg_gen_##cmd##_i64(v, v, tmp); \ tcg_gen_trunc_i64_i32(cpu_R[RRR_R], v); \ tcg_temp_free_i64(v); \ tcg_temp_free_i64(tmp); \ } while (0) #define gen_shift(cmd) gen_shift_reg(cmd, cpu_SR[SAR]) case 8: { TCGv_i64 v = tcg_temp_new_i64(); tcg_gen_concat_i32_i64(v, cpu_R[RRR_T], cpu_R[RRR_S]); gen_shift(shr); } break; case 9: if (dc->sar_5bit) { tcg_gen_shr_i32(cpu_R[RRR_R], cpu_R[RRR_T], cpu_SR[SAR]); } else { TCGv_i64 v = tcg_temp_new_i64(); tcg_gen_extu_i32_i64(v, cpu_R[RRR_T]); gen_shift(shr); } break; case 10: if (dc->sar_m32_5bit) { tcg_gen_shl_i32(cpu_R[RRR_R], cpu_R[RRR_S], dc->sar_m32); } else { TCGv_i64 v = tcg_temp_new_i64(); TCGv_i32 s = tcg_const_i32(32); tcg_gen_sub_i32(s, s, cpu_SR[SAR]); tcg_gen_andi_i32(s, s, 0x3f); tcg_gen_extu_i32_i64(v, cpu_R[RRR_S]); gen_shift_reg(shl, s); tcg_temp_free(s); } break; case 11: if (dc->sar_5bit) { tcg_gen_sar_i32(cpu_R[RRR_R], cpu_R[RRR_T], cpu_SR[SAR]); } else { TCGv_i64 v = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(v, cpu_R[RRR_T]); gen_shift(sar); } break; #undef gen_shift #undef gen_shift_reg case 12: HAS_OPTION(XTENSA_OPTION_16_BIT_IMUL); { TCGv_i32 v1 = tcg_temp_new_i32(); TCGv_i32 v2 = tcg_temp_new_i32(); tcg_gen_ext16u_i32(v1, cpu_R[RRR_S]); tcg_gen_ext16u_i32(v2, cpu_R[RRR_T]); tcg_gen_mul_i32(cpu_R[RRR_R], v1, v2); tcg_temp_free(v2); tcg_temp_free(v1); } break; case 13: HAS_OPTION(XTENSA_OPTION_16_BIT_IMUL); { TCGv_i32 v1 = tcg_temp_new_i32(); TCGv_i32 v2 = tcg_temp_new_i32(); tcg_gen_ext16s_i32(v1, cpu_R[RRR_S]); tcg_gen_ext16s_i32(v2, cpu_R[RRR_T]); tcg_gen_mul_i32(cpu_R[RRR_R], v1, v2); tcg_temp_free(v2); tcg_temp_free(v1); } break; default: break; } break; case 2: break; case 3: switch (OP2) { case 0: gen_rsr(dc, cpu_R[RRR_T], RSR_SR); break; case 1: gen_wsr(dc, RSR_SR, cpu_R[RRR_T]); break; case 2: HAS_OPTION(XTENSA_OPTION_MISC_OP); { int shift = 24 - RRR_T; if (shift == 24) { tcg_gen_ext8s_i32(cpu_R[RRR_R], cpu_R[RRR_S]); } else if (shift == 16) { tcg_gen_ext16s_i32(cpu_R[RRR_R], cpu_R[RRR_S]); } else { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_shli_i32(tmp, cpu_R[RRR_S], shift); tcg_gen_sari_i32(cpu_R[RRR_R], tmp, shift); tcg_temp_free(tmp); } } break; case 3: HAS_OPTION(XTENSA_OPTION_MISC_OP); { TCGv_i32 tmp1 = tcg_temp_new_i32(); TCGv_i32 tmp2 = tcg_temp_new_i32(); int label = gen_new_label(); tcg_gen_sari_i32(tmp1, cpu_R[RRR_S], 24 - RRR_T); tcg_gen_xor_i32(tmp2, tmp1, cpu_R[RRR_S]); tcg_gen_andi_i32(tmp2, tmp2, 0xffffffff << (RRR_T + 7)); tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]); tcg_gen_brcondi_i32(TCG_COND_EQ, tmp2, 0, label); tcg_gen_sari_i32(tmp1, cpu_R[RRR_S], 31); tcg_gen_xori_i32(cpu_R[RRR_R], tmp1, 0xffffffff >> (25 - RRR_T)); gen_set_label(label); tcg_temp_free(tmp1); tcg_temp_free(tmp2); } break; case 4: case 5: case 6: case 7: HAS_OPTION(XTENSA_OPTION_MISC_OP); { static const TCGCond cond[] = { TCG_COND_LE, TCG_COND_GE, TCG_COND_LEU, TCG_COND_GEU }; int label = gen_new_label(); if (RRR_R != RRR_T) { tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]); tcg_gen_brcond_i32(cond[OP2 - 4], cpu_R[RRR_S], cpu_R[RRR_T], label); tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_T]); } else { tcg_gen_brcond_i32(cond[OP2 - 4], cpu_R[RRR_T], cpu_R[RRR_S], label); tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]); } gen_set_label(label); } break; case 8: case 9: case 10: case 11: { static const TCGCond cond[] = { TCG_COND_NE, TCG_COND_EQ, TCG_COND_GE, TCG_COND_LT }; int label = gen_new_label(); tcg_gen_brcondi_i32(cond[OP2 - 8], cpu_R[RRR_T], 0, label); tcg_gen_mov_i32(cpu_R[RRR_R], cpu_R[RRR_S]); gen_set_label(label); } break; case 12: HAS_OPTION(XTENSA_OPTION_BOOLEAN); break; case 13: HAS_OPTION(XTENSA_OPTION_BOOLEAN); break; case 14: { int st = (RRR_S << 4) + RRR_T; if (uregnames[st]) { tcg_gen_mov_i32(cpu_R[RRR_R], cpu_UR[st]); } else { qemu_log("RUR %d not implemented, ", st); } } break; case 15: { if (uregnames[RSR_SR]) { tcg_gen_mov_i32(cpu_UR[RSR_SR], cpu_R[RRR_T]); } else { qemu_log("WUR %d not implemented, ", RSR_SR); } } break; } break; case 4: case 5: { int shiftimm = RRR_S | (OP1 << 4); int maskimm = (1 << (OP2 + 1)) - 1; TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_shri_i32(tmp, cpu_R[RRR_T], shiftimm); tcg_gen_andi_i32(cpu_R[RRR_R], tmp, maskimm); tcg_temp_free(tmp); } break; case 6: break; case 7: break; case 8: HAS_OPTION(XTENSA_OPTION_COPROCESSOR); break; case 9: break; case 10: HAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR); break; case 11: HAS_OPTION(XTENSA_OPTION_FP_COPROCESSOR); break; default: break; } break; case 1: { TCGv_i32 tmp = tcg_const_i32( (0xfffc0000 | (RI16_IMM16 << 2)) + ((dc->pc + 3) & ~3)); tcg_gen_qemu_ld32u(cpu_R[RRR_T], tmp, 0); tcg_temp_free(tmp); } break; case 2: #define gen_load_store(type, shift) do { \ TCGv_i32 addr = tcg_temp_new_i32(); \ tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << shift); \ tcg_gen_qemu_##type(cpu_R[RRI8_T], addr, 0); \ tcg_temp_free(addr); \ } while (0) switch (RRI8_R) { case 0: gen_load_store(ld8u, 0); break; case 1: gen_load_store(ld16u, 1); break; case 2: gen_load_store(ld32u, 2); break; case 4: gen_load_store(st8, 0); break; case 5: gen_load_store(st16, 1); break; case 6: gen_load_store(st32, 2); break; case 7: break; case 9: gen_load_store(ld16s, 1); break; case 10: tcg_gen_movi_i32(cpu_R[RRI8_T], RRI8_IMM8 | (RRI8_S << 8) | ((RRI8_S & 0x8) ? 0xfffff000 : 0)); break; case 11: HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO); gen_load_store(ld32u, 2); break; case 12: tcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE); break; case 13: tcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE << 8); break; case 14: HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO); { int label = gen_new_label(); TCGv_i32 tmp = tcg_temp_local_new_i32(); TCGv_i32 addr = tcg_temp_local_new_i32(); tcg_gen_mov_i32(tmp, cpu_R[RRI8_T]); tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << 2); tcg_gen_qemu_ld32u(cpu_R[RRI8_T], addr, 0); tcg_gen_brcond_i32(TCG_COND_NE, cpu_R[RRI8_T], cpu_SR[SCOMPARE1], label); tcg_gen_qemu_st32(tmp, addr, 0); gen_set_label(label); tcg_temp_free(addr); tcg_temp_free(tmp); } break; case 15: HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO); gen_load_store(st32, 2); break; default: break; } break; #undef gen_load_store case 3: HAS_OPTION(XTENSA_OPTION_COPROCESSOR); break; case 4: HAS_OPTION(XTENSA_OPTION_MAC16); break; case 5: switch (CALL_N) { case 0: tcg_gen_movi_i32(cpu_R[0], dc->next_pc); gen_jumpi(dc, (dc->pc & ~3) + (CALL_OFFSET_SE << 2) + 4, 0); break; case 1: case 2: case 3: HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER); break; } break; case 6: switch (CALL_N) { case 0: gen_jumpi(dc, dc->pc + 4 + CALL_OFFSET_SE, 0); break; case 1: { static const TCGCond cond[] = { TCG_COND_EQ, TCG_COND_NE, TCG_COND_LT, TCG_COND_GE, }; gen_brcondi(dc, cond[BRI12_M & 3], cpu_R[BRI12_S], 0, 4 + BRI12_IMM12_SE); } break; case 2: { static const TCGCond cond[] = { TCG_COND_EQ, TCG_COND_NE, TCG_COND_LT, TCG_COND_GE, }; gen_brcondi(dc, cond[BRI8_M & 3], cpu_R[BRI8_S], B4CONST[BRI8_R], 4 + BRI8_IMM8_SE); } break; case 3: switch (BRI8_M) { case 0: HAS_OPTION(XTENSA_OPTION_WINDOWED_REGISTER); break; case 1: switch (BRI8_R) { case 0: HAS_OPTION(XTENSA_OPTION_BOOLEAN); break; case 1: HAS_OPTION(XTENSA_OPTION_BOOLEAN); break; case 8: break; case 9: break; case 10: break; default: break; } break; case 2: case 3: gen_brcondi(dc, BRI8_M == 2 ? TCG_COND_LTU : TCG_COND_GEU, cpu_R[BRI8_S], B4CONSTU[BRI8_R], 4 + BRI8_IMM8_SE); break; } break; } break; case 7: { TCGCond eq_ne = (RRI8_R & 8) ? TCG_COND_NE : TCG_COND_EQ; switch (RRI8_R & 7) { case 0: { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_and_i32(tmp, cpu_R[RRI8_S], cpu_R[RRI8_T]); gen_brcondi(dc, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE); tcg_temp_free(tmp); } break; case 1: case 2: case 3: { static const TCGCond cond[] = { [1] = TCG_COND_EQ, [2] = TCG_COND_LT, [3] = TCG_COND_LTU, [9] = TCG_COND_NE, [10] = TCG_COND_GE, [11] = TCG_COND_GEU, }; gen_brcond(dc, cond[RRI8_R], cpu_R[RRI8_S], cpu_R[RRI8_T], 4 + RRI8_IMM8_SE); } break; case 4: { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_and_i32(tmp, cpu_R[RRI8_S], cpu_R[RRI8_T]); gen_brcond(dc, eq_ne, tmp, cpu_R[RRI8_T], 4 + RRI8_IMM8_SE); tcg_temp_free(tmp); } break; case 5: { TCGv_i32 bit = tcg_const_i32(1); TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_andi_i32(tmp, cpu_R[RRI8_T], 0x1f); tcg_gen_shl_i32(bit, bit, tmp); tcg_gen_and_i32(tmp, cpu_R[RRI8_S], bit); gen_brcondi(dc, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE); tcg_temp_free(tmp); tcg_temp_free(bit); } break; case 6: case 7: { TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_andi_i32(tmp, cpu_R[RRI8_S], 1 << (((RRI8_R & 1) << 4) | RRI8_T)); gen_brcondi(dc, eq_ne, tmp, 0, 4 + RRI8_IMM8_SE); tcg_temp_free(tmp); } break; } } break; #define gen_narrow_load_store(type) do { \ TCGv_i32 addr = tcg_temp_new_i32(); \ tcg_gen_addi_i32(addr, cpu_R[RRRN_S], RRRN_R << 2); \ tcg_gen_qemu_##type(cpu_R[RRRN_T], addr, 0); \ tcg_temp_free(addr); \ } while (0) case 8: gen_narrow_load_store(ld32u); break; case 9: gen_narrow_load_store(st32); break; #undef gen_narrow_load_store case 10: tcg_gen_add_i32(cpu_R[RRRN_R], cpu_R[RRRN_S], cpu_R[RRRN_T]); break; case 11: tcg_gen_addi_i32(cpu_R[RRRN_R], cpu_R[RRRN_S], RRRN_T ? RRRN_T : -1); break; case 12: if (RRRN_T < 8) { tcg_gen_movi_i32(cpu_R[RRRN_S], RRRN_R | (RRRN_T << 4) | ((RRRN_T & 6) == 6 ? 0xffffff80 : 0)); } else { TCGCond eq_ne = (RRRN_T & 4) ? TCG_COND_NE : TCG_COND_EQ; gen_brcondi(dc, eq_ne, cpu_R[RRRN_S], 0, 4 + (RRRN_R | ((RRRN_T & 3) << 4))); } break; case 13: switch (RRRN_R) { case 0: tcg_gen_mov_i32(cpu_R[RRRN_T], cpu_R[RRRN_S]); break; case 15: switch (RRRN_T) { case 0: gen_jump(dc, cpu_R[0]); break; case 1: break; case 2: break; case 3: break; case 6: break; default: break; } break; default: break; } break; default: break; } dc->pc = dc->next_pc; return; invalid_opcode: qemu_log("INVALID(pc = %08x)\n", dc->pc); dc->pc = dc->next_pc; #undef HAS_OPTION }
1threat
Trying to write Python code to count the number of different vowels in a string? : <p>I've literally just started learning to code so very inexperienced, and I probably haven't done this the best way - I'm trying to write code in Python that will count the number of DIFFERENT vowels in a string (i.e. if the input was 'Hello my name is Simon' the output should be '4' as the string contains a, e, i and o)</p> <pre><code>a="a" A="A" e="e" E="E" i="i" I="I" o="o" O="O" u="u" U="U" num_of_diff_vowels=0 print("This program will count the number of vowels in your string") ans = input("Enter string here:") if a or A in ans: num_of_diff_vowels=num_of_diff_vowels+1 if e or E in ans: num_of_diff_vowels=num_of_diff_vowels+1 if o or O in ans: num_of_diff_vowels=num_of_diff_vowels+1 if i or I in ans: num_of_diff_vowels=num_of_diff_vowels+1 if u or U in ans: num_of_diff_vowels=num_of_diff_vowels+1 print(num_of_diff_vowels) </code></pre> <p>So far with this code all I'm getting in the output is '5'... Any ideas of how to refine this and actually make it work?</p>
0debug
static int flush_packet(AVFormatContext *ctx, int stream_index, int64_t pts, int64_t dts, int64_t scr, int trailer_size) { MpegMuxContext *s = ctx->priv_data; StreamInfo *stream = ctx->streams[stream_index]->priv_data; uint8_t *buf_ptr; int size, payload_size, startcode, id, stuffing_size, i, header_len; int packet_size; uint8_t buffer[128]; int zero_trail_bytes = 0; int pad_packet_bytes = 0; int pes_flags; int general_pack = 0; int nb_frames; id = stream->id; #if 0 printf("packet ID=%2x PTS=%0.3f\n", id, pts / 90000.0); #endif buf_ptr = buffer; if ((s->packet_number % s->pack_header_freq) == 0 || s->last_scr != scr) { size = put_pack_header(ctx, buf_ptr, scr); buf_ptr += size; s->last_scr= scr; if (s->is_vcd) { if (stream->packet_number==0) { size = put_system_header(ctx, buf_ptr, id); buf_ptr += size; } } else if (s->is_dvd) { if (stream->align_iframe || s->packet_number == 0){ int PES_bytes_to_fill = s->packet_size - size - 10; if (pts != AV_NOPTS_VALUE) { if (dts != pts) PES_bytes_to_fill -= 5 + 5; else PES_bytes_to_fill -= 5; } if (stream->bytes_to_iframe == 0 || s->packet_number == 0) { size = put_system_header(ctx, buf_ptr, 0); buf_ptr += size; size = buf_ptr - buffer; put_buffer(ctx->pb, buffer, size); put_be32(ctx->pb, PRIVATE_STREAM_2); put_be16(ctx->pb, 0x03d4); put_byte(ctx->pb, 0x00); for (i = 0; i < 979; i++) put_byte(ctx->pb, 0x00); put_be32(ctx->pb, PRIVATE_STREAM_2); put_be16(ctx->pb, 0x03fa); put_byte(ctx->pb, 0x01); for (i = 0; i < 1017; i++) put_byte(ctx->pb, 0x00); memset(buffer, 0, 128); buf_ptr = buffer; s->packet_number++; stream->align_iframe = 0; scr += s->packet_size*90000LL / (s->mux_rate*50LL); size = put_pack_header(ctx, buf_ptr, scr); s->last_scr= scr; buf_ptr += size; } else if (stream->bytes_to_iframe < PES_bytes_to_fill) { pad_packet_bytes = PES_bytes_to_fill - stream->bytes_to_iframe; } } } else { if ((s->packet_number % s->system_header_freq) == 0) { size = put_system_header(ctx, buf_ptr, 0); buf_ptr += size; } } } size = buf_ptr - buffer; put_buffer(ctx->pb, buffer, size); packet_size = s->packet_size - size; if (s->is_vcd && id == AUDIO_ID) zero_trail_bytes += 20; if ((s->is_vcd && stream->packet_number==0) || (s->is_svcd && s->packet_number==0)) { if (s->is_svcd) general_pack = 1; pad_packet_bytes = packet_size - zero_trail_bytes; } packet_size -= pad_packet_bytes + zero_trail_bytes; if (packet_size > 0) { packet_size -= 6; if (s->is_mpeg2) { header_len = 3; if (stream->packet_number==0) header_len += 3; header_len += 1; } else { header_len = 0; } if (pts != AV_NOPTS_VALUE) { if (dts != pts) header_len += 5 + 5; else header_len += 5; } else { if (!s->is_mpeg2) header_len++; } payload_size = packet_size - header_len; if (id < 0xc0) { startcode = PRIVATE_STREAM_1; payload_size -= 1; if (id >= 0x40) { payload_size -= 3; if (id >= 0xa0) payload_size -= 3; } } else { startcode = 0x100 + id; } stuffing_size = payload_size - av_fifo_size(&stream->fifo); if(payload_size <= trailer_size && pts != AV_NOPTS_VALUE){ int timestamp_len=0; if(dts != pts) timestamp_len += 5; if(pts != AV_NOPTS_VALUE) timestamp_len += s->is_mpeg2 ? 5 : 4; pts=dts= AV_NOPTS_VALUE; header_len -= timestamp_len; if (s->is_dvd && stream->align_iframe) { pad_packet_bytes += timestamp_len; packet_size -= timestamp_len; } else { payload_size += timestamp_len; } stuffing_size += timestamp_len; if(payload_size > trailer_size) stuffing_size += payload_size - trailer_size; } if (pad_packet_bytes > 0 && pad_packet_bytes <= 7) { packet_size += pad_packet_bytes; payload_size += pad_packet_bytes; if (stuffing_size < 0) { stuffing_size = pad_packet_bytes; } else { stuffing_size += pad_packet_bytes; } pad_packet_bytes = 0; } if (stuffing_size < 0) stuffing_size = 0; if (stuffing_size > 16) { pad_packet_bytes += stuffing_size; packet_size -= stuffing_size; payload_size -= stuffing_size; stuffing_size = 0; } nb_frames= get_nb_frames(ctx, stream, payload_size - stuffing_size); put_be32(ctx->pb, startcode); put_be16(ctx->pb, packet_size); if (!s->is_mpeg2) for(i=0;i<stuffing_size;i++) put_byte(ctx->pb, 0xff); if (s->is_mpeg2) { put_byte(ctx->pb, 0x80); pes_flags=0; if (pts != AV_NOPTS_VALUE) { pes_flags |= 0x80; if (dts != pts) pes_flags |= 0x40; } if (stream->packet_number == 0) pes_flags |= 0x01; put_byte(ctx->pb, pes_flags); put_byte(ctx->pb, header_len - 3 + stuffing_size); if (pes_flags & 0x80) put_timestamp(ctx->pb, (pes_flags & 0x40) ? 0x03 : 0x02, pts); if (pes_flags & 0x40) put_timestamp(ctx->pb, 0x01, dts); if (pes_flags & 0x01) { put_byte(ctx->pb, 0x10); if (id == AUDIO_ID) put_be16(ctx->pb, 0x4000 | stream->max_buffer_size/128); else put_be16(ctx->pb, 0x6000 | stream->max_buffer_size/1024); } } else { if (pts != AV_NOPTS_VALUE) { if (dts != pts) { put_timestamp(ctx->pb, 0x03, pts); put_timestamp(ctx->pb, 0x01, dts); } else { put_timestamp(ctx->pb, 0x02, pts); } } else { put_byte(ctx->pb, 0x0f); } } if (s->is_mpeg2) { put_byte(ctx->pb, 0xff); for(i=0;i<stuffing_size;i++) put_byte(ctx->pb, 0xff); } if (startcode == PRIVATE_STREAM_1) { put_byte(ctx->pb, id); if (id >= 0xa0) { put_byte(ctx->pb, 7); put_be16(ctx->pb, 4); put_byte(ctx->pb, stream->lpcm_header[0]); put_byte(ctx->pb, stream->lpcm_header[1]); put_byte(ctx->pb, stream->lpcm_header[2]); } else if (id >= 0x40) { put_byte(ctx->pb, nb_frames); put_be16(ctx->pb, trailer_size+1); } } if(av_fifo_generic_read(&stream->fifo, payload_size - stuffing_size, &put_buffer, ctx->pb) < 0) return -1; stream->bytes_to_iframe -= payload_size - stuffing_size; }else{ payload_size= stuffing_size= 0; } if (pad_packet_bytes > 0) put_padding_packet(ctx,ctx->pb, pad_packet_bytes); for(i=0;i<zero_trail_bytes;i++) put_byte(ctx->pb, 0x00); put_flush_packet(ctx->pb); s->packet_number++; if (!general_pack) stream->packet_number++; return payload_size - stuffing_size; }
1threat
Type or namespace definition, or end-of-file expected: : <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Trade_Entry_Application { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { notionalEntry.Focus(); } private void textBox6_TextChanged(object sender, EventArgs e) { } private void textBox5_TextChanged(object sender, EventArgs e) { } private void label6_Click(object sender, EventArgs e) { } private void label5_Click(object sender, EventArgs e) { if (rateType.Text == "Fixed Rate") { rateType.Text = "Floating Rate"; } else { rateType.Text = "Fixed Rate"; } } private void button1_Click(object sender, EventArgs e) { decimal floatEntryInt = Convert.ToDecimal(floatEntry.Text); decimal notionalEntryDec = Convert.ToDecimal(notionalEntry.Text); decimal output = notionalEntryDec * floatEntryInt; string outputstr = Convert.ToString(output).ToString(); resultBox.Text = output.ToString(); } private void notionalEntry_TextChanged(object sender, EventArgs e) { decimal notionalEntryDec = Convert.ToDecimal(notionalEntry.Text); if (notionalEntry.Text.EndsWith("m")) { decimal output = notionalEntryDec * 1000000; } } } } } </code></pre> <p>Having problems with the code as i am getting this error Severity Code Description Project File Line Suppression State Error CS1022 Type or namespace definition, or end-of-file expected Trade Entry Application C:\Users\spruc\Desktop\Trade Entry Application\Trade Entry Application\Trade Entry Application\Form1.cs 71 Active I am a newbie in c# ): what i am trying to do is replace what is in the text box when you type 1m it will replace it with 10000000 and when you type 1k it will replace it with 1000 Thanks</p>
0debug
int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id) { BlockDriver *drv = bs->drv; if (!drv) return -ENOMEDIUM; if (drv->bdrv_snapshot_delete) return drv->bdrv_snapshot_delete(bs, snapshot_id); if (bs->file) return bdrv_snapshot_delete(bs->file, snapshot_id); return -ENOTSUP; }
1threat
void ide_drive_get(DriveInfo **hd, int max_bus) { int i; if (drive_get_max_bus(IF_IDE) >= max_bus) { fprintf(stderr, "qemu: too many IDE bus: %d\n", max_bus); exit(1); } for(i = 0; i < max_bus * MAX_IDE_DEVS; i++) { hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); } }
1threat
static av_cold int dirac_decode_init(AVCodecContext *avctx) { DiracContext *s = avctx->priv_data; int i; s->avctx = avctx; s->frame_number = -1; if (avctx->flags&CODEC_FLAG_EMU_EDGE) { av_log(avctx, AV_LOG_ERROR, "Edge emulation not supported!\n"); return AVERROR_PATCHWELCOME; } ff_dsputil_init(&s->dsp, avctx); ff_diracdsp_init(&s->diracdsp); for (i = 0; i < MAX_FRAMES; i++) s->all_frames[i].avframe = av_frame_alloc(); return 0; }
1threat
static int http_prepare_data(HTTPContext *c, long cur_time) { int i; switch(c->state) { case HTTPSTATE_SEND_DATA_HEADER: memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx)); pstrcpy(c->fmt_ctx.author, sizeof(c->fmt_ctx.author), c->stream->author); pstrcpy(c->fmt_ctx.comment, sizeof(c->fmt_ctx.comment), c->stream->comment); pstrcpy(c->fmt_ctx.copyright, sizeof(c->fmt_ctx.copyright), c->stream->copyright); pstrcpy(c->fmt_ctx.title, sizeof(c->fmt_ctx.title), c->stream->title); if (c->stream->feed) { c->fmt_ctx.oformat = c->stream->fmt; c->fmt_ctx.nb_streams = c->stream->nb_streams; for(i=0;i<c->fmt_ctx.nb_streams;i++) { AVStream *st; st = av_mallocz(sizeof(AVStream)); c->fmt_ctx.streams[i] = st; if (c->stream->feed == c->stream) memcpy(st, c->stream->streams[i], sizeof(AVStream)); else memcpy(st, c->stream->feed->streams[c->stream->feed_streams[i]], sizeof(AVStream)); st->codec.frame_number = 0; } c->got_key_frame = 0; } else { c->fmt_ctx.oformat = c->stream->fmt; c->fmt_ctx.nb_streams = c->fmt_in->nb_streams; for(i=0;i<c->fmt_ctx.nb_streams;i++) { AVStream *st; st = av_mallocz(sizeof(AVStream)); c->fmt_ctx.streams[i] = st; memcpy(st, c->fmt_in->streams[i], sizeof(AVStream)); st->codec.frame_number = 0; } c->got_key_frame = 0; } init_put_byte(&c->fmt_ctx.pb, c->pbuffer, c->pbuffer_size, 1, c, NULL, http_write_packet, NULL); c->fmt_ctx.pb.is_streamed = 1; av_write_header(&c->fmt_ctx); c->state = HTTPSTATE_SEND_DATA; c->last_packet_sent = 0; break; case HTTPSTATE_SEND_DATA: #if 0 fifo_total_size = http_fifo_write_count - c->last_http_fifo_write_count; if (fifo_total_size >= ((3 * FIFO_MAX_SIZE) / 4)) { c->rptr = http_fifo.wptr; c->got_key_frame = 0; } start_rptr = c->rptr; if (fifo_read(&http_fifo, (UINT8 *)&hdr, sizeof(hdr), &c->rptr) < 0) return 0; payload_size = ntohs(hdr.payload_size); payload = av_malloc(payload_size); if (fifo_read(&http_fifo, payload, payload_size, &c->rptr) < 0) { av_free(payload); c->rptr = start_rptr; return 0; } c->last_http_fifo_write_count = http_fifo_write_count - fifo_size(&http_fifo, c->rptr); if (c->stream->stream_type != STREAM_TYPE_MASTER) { ret = 0; for(i=0;i<c->fmt_ctx.nb_streams;i++) { AVStream *st = c->fmt_ctx.streams[i]; if (test_header(&hdr, &st->codec)) { if (st->codec.key_frame) c->got_key_frame |= 1 << i; if (c->got_key_frame & (1 << i)) { ret = c->fmt_ctx.format->write_packet(&c->fmt_ctx, i, payload, payload_size); } break; } } if (ret) { c->state = HTTPSTATE_SEND_DATA_TRAILER; } } else { char *q; q = c->buffer; memcpy(q, &hdr, sizeof(hdr)); q += sizeof(hdr); memcpy(q, payload, payload_size); q += payload_size; c->buffer_ptr = c->buffer; c->buffer_end = q; } av_free(payload); #endif { AVPacket pkt; if (c->stream->feed) { ffm_set_write_index(c->fmt_in, c->stream->feed->feed_write_index, c->stream->feed->feed_size); } if (c->stream->max_time && c->stream->max_time + c->start_time - cur_time < 0) { c->state = HTTPSTATE_SEND_DATA_TRAILER; } else if (av_read_packet(c->fmt_in, &pkt) < 0) { if (c->stream->feed && c->stream->feed->feed_opened) { c->state = HTTPSTATE_WAIT_FEED; return 1; } else { c->state = HTTPSTATE_SEND_DATA_TRAILER; } } else { if (c->stream->feed) { if (c->switch_pending) { c->switch_pending = 0; for(i=0;i<c->stream->nb_streams;i++) { if (c->switch_feed_streams[i] == pkt.stream_index) { if (pkt.flags & PKT_FLAG_KEY) { do_switch_stream(c, i); } } if (c->switch_feed_streams[i] >= 0) { c->switch_pending = 1; } } } for(i=0;i<c->stream->nb_streams;i++) { if (c->feed_streams[i] == pkt.stream_index) { pkt.stream_index = i; if (pkt.flags & PKT_FLAG_KEY) { c->got_key_frame |= 1 << i; } if (!c->stream->send_on_key || ((c->got_key_frame + 1) >> c->stream->nb_streams)) { goto send_it; } } } } else { AVCodecContext *codec; send_it: codec = &c->fmt_ctx.streams[pkt.stream_index]->codec; codec->key_frame = ((pkt.flags & PKT_FLAG_KEY) != 0); #ifdef PJSG if (codec->codec_type == CODEC_TYPE_AUDIO) { codec->frame_size = (codec->sample_rate * pkt.duration + 500000) / 1000000; } #endif if (av_write_packet(&c->fmt_ctx, &pkt, 0)) c->state = HTTPSTATE_SEND_DATA_TRAILER; codec->frame_number++; } av_free_packet(&pkt); } } break; default: case HTTPSTATE_SEND_DATA_TRAILER: if (c->last_packet_sent) return -1; av_write_trailer(&c->fmt_ctx); c->last_packet_sent = 1; break; } return 0; }
1threat
static int64_t ffm_seek1(AVFormatContext *s, int64_t pos1) { FFMContext *ffm = s->priv_data; AVIOContext *pb = s->pb; int64_t pos; pos = FFMIN(pos1, ffm->file_size - FFM_PACKET_SIZE); pos = FFMAX(pos, FFM_PACKET_SIZE); av_dlog(s, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos); return avio_seek(pb, pos, SEEK_SET); }
1threat
Why in principle an in-place-modifying method should return None : <p>A language design question.</p> <p>Taking Python as example.</p> <p>Quoting a <a href="https://stackoverflow.com/questions/22442378/what-is-the-difference-between-sortedlist-vs-list-sort#comment81703173_22442440">comment</a> in an answer to a question concerning the difference between <code>list.sort()</code> and <code>sorted()</code>:</p> <blockquote> <p>In general, when a python function returns None, it is a sign, that the operations are done in place, that's why, when you want to print list.sort() it returns None.</p> </blockquote> <p>I am wondering the reason for the language-design principle that an in-place-modifying method should return <code>None</code>. Just for curiosity, say, why cannot <code>list.sort()</code> (and other in-place-modifying functions/methods) return itself?</p> <p>A possbile argument is that doing so avoids creating a copy and could be faster. However, copying a list in Python only creates a reference and shouldn't be much expensive.</p> <p>Another argument could be <code>list.sort()</code>, from its literal meaning, shouldn't be an object. Then what about having another method that both modifies list in place and returns a copy -- call it <code>list.sorted()</code>? I guess having such a method will facilitate certain usage.</p>
0debug
target_ulong helper_dmt(target_ulong arg1) { arg1 = 0; return arg1; }
1threat
Axios: chaining multiple API requests : <p>I need to chain a few API requests from the Google Maps API, and I'm trying to do it with Axios.</p> <p>Here is the first request, which is in componentWillMount()</p> <pre><code>axios.get('https://maps.googleapis.com/maps/api/geocode/json?&amp;address=' + this.props.p1) .then(response =&gt; this.setState({ p1Location: response.data })) } </code></pre> <p>Here is the second request:</p> <pre><code>axios.get('https://maps.googleapis.com/maps/api/geocode/json?&amp;address=' + this.props.p2) .then(response =&gt; this.setState({ p2Location: response.data })) </code></pre> <p>Then we have a third request, which is dependent on the first two being completed:</p> <pre><code>axios.get('https://maps.googleapis.com/maps/api/directions/json?origin=place_id:' + this.state.p1Location.results.place_id + '&amp;destination=place_id:' + this.state.p2Location.results.place_id + '&amp;key=' + 'API-KEY-HIDDEN') .then(response =&gt; this.setState({ route: response.data })) </code></pre> <p>How can I chain these three calls so that the third happens after the first two?</p>
0debug
Angular 6 Auth0 - global not defined : <p>Ive upgraded my app from angular 5 to angular 6. i get the following error now.</p> <pre><code>Uncaught ReferenceError: global is not defined at Object../node_modules/auth0-lock/lib/utils/cdn_utils.js (cdn_utils.js:13) </code></pre> <blockquote> <p>"angular2-jwt": "^0.2.3", "auth0-js": "^9.5.1", "auth0-lock": "^11.6.1",</p> </blockquote>
0debug
What are the best option for a pager when building on Rails? : <p>I am building an education app and I want a pager that uses the buttons "previous" and "next" to go back and forth on the lessons I created.</p> <p>Many Google results show me to use the kaminari gem but kaminiari seems to be more on the pagination(like pages 1, 2, 3...) side rather than the pager that I am looking for.</p> <p>What gem or tool would be the best in my situation?</p>
0debug
how to validate a url in inside paragraph using Regex : i am using the following regex to validate the url: /^(?:(?:https?|ftp):\/\/)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/ but unable to validate the url inside a pragrapg using this like: Many students define paragraphs in terms of length: a paragraph is a group of at least five sentences, a paragraph is half a page long, etc. In reality, though, the u [www.example.com][1] and and coherence of ideas among sentences is what constitutes a paragraph. here it unable to dedect example.com can someone provide me regex to validate url in such case. [1]: https://www.example.com
0debug
Why aren't my onclick events working? : <p>Here is a snippet of my code on <a href="https://jsfiddle.net/dreami/jy69s6r3/2/" rel="nofollow">jsfiddle</a>.</p> <p>I want the "+ Create Forum" button to show the form, "Cancel" button to reset the form and hide it, and if you want to see the form, delete "style="display: none".</p> <p>I used a lot of examples out of w3schools and I have tried to use all its examples of writing a show and hide, one of the resets worked but it was a onclick="this.reset()" which wasn't what I wanted because I wanted it to hide too.</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;button class="btn btn-default" type="submit" id="createform"&gt;+ Create Forum&lt;/button&gt; &lt;div class="form-group" id="createForum"&gt; &lt;form action="forums.php" method="get" id="forumForm" style="display: none"&gt; &lt;label&gt;Forum name:&lt;/label&gt; &lt;input type="text" class="form-control" id="forumName"&gt; &lt;label&gt;Description:&lt;/label&gt; &lt;textarea class="form-control" rows="5" id="description"&gt;&lt;/textarea&gt; &lt;button class="btn btn-danger" type="submit" name="create"&gt;Crear&lt;/button&gt; &lt;input type="button" value="Reset Form" onclick="clearing()"&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; &lt;script type="text/javascript"&gt; $("#createform").click(function() { $("#forumForm").show(); }); function clearing() { document.getElementById("forumForm").reset(); } &lt;/script&gt; </code></pre>
0debug
static void crs_replace_with_free_ranges(GPtrArray *ranges, uint64_t start, uint64_t end) { GPtrArray *free_ranges = g_ptr_array_new_with_free_func(crs_range_free); uint64_t free_base = start; int i; g_ptr_array_sort(ranges, crs_range_compare); for (i = 0; i < ranges->len; i++) { CrsRangeEntry *used = g_ptr_array_index(ranges, i); if (free_base < used->base) { crs_range_insert(free_ranges, free_base, used->base - 1); } free_base = used->limit + 1; } if (free_base < end) { crs_range_insert(free_ranges, free_base, end); } g_ptr_array_set_size(ranges, 0); for (i = 0; i < free_ranges->len; i++) { g_ptr_array_add(ranges, g_ptr_array_index(free_ranges, i)); } g_ptr_array_free(free_ranges, false); }
1threat
uint32_t gic_acknowledge_irq(GICState *s, int cpu) { int ret, irq, src; int cm = 1 << cpu; irq = s->current_pending[cpu]; if (irq == 1023 || GIC_GET_PRIORITY(irq, cpu) >= s->running_priority[cpu]) { DPRINTF("ACK no pending IRQ\n"); return 1023; } s->last_active[irq][cpu] = s->running_irq[cpu]; if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) { GIC_CLEAR_PENDING(irq, GIC_TEST_MODEL(irq) ? ALL_CPU_MASK : cm); ret = irq; } else { if (irq < GIC_NR_SGIS) { assert(s->sgi_pending[irq][cpu] != 0); src = ctz32(s->sgi_pending[irq][cpu]); s->sgi_pending[irq][cpu] &= ~(1 << src); if (s->sgi_pending[irq][cpu] == 0) { GIC_CLEAR_PENDING(irq, GIC_TEST_MODEL(irq) ? ALL_CPU_MASK : cm); } ret = irq | ((src & 0x7) << 10); } else { GIC_CLEAR_PENDING(irq, GIC_TEST_MODEL(irq) ? ALL_CPU_MASK : cm); ret = irq; } } gic_set_running_irq(s, cpu, irq); DPRINTF("ACK %d\n", irq); return ret; }
1threat
My C Compiler blew up , when i tried changing some address values , please tell me why? : Have a look at my code : #include <stdio.h> #include <limits.h> int main (int argc, const char *argv[]) { typedef unsigned char byte; byte *pointer; byte b1=1; byte b2=2; int i1 =4; int i2 =0x12345678; byte b3=5; byte b4=6; byte b5=7; byte b6=9; //pointer = &b6; pointer = (byte*)&i2; printf("pointer has value %p\n", pointer); printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; *pointer = 255; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; *pointer = 45; printf("the byte it points to contains %x\n", *pointer); pointer = pointer + 1; *pointer = 34; printf("the byte it points to contains %x\n", *pointer); //printf("How big is int in this machine? %d\n", INT_MAX); //insert code here ... printf (" b1 (%p) = %x\n", &b1, b1); printf (" b2 (%p) = %x\n", &b2, b2); printf (" i1 (%p) = %d\n", &i1, i1); printf (" i2 (%p) = %x\n", &i2, i2); printf (" b3 (%p) = %x\n", &b3, b3); printf (" b4 (%p) = %x\n", &b4, b4); printf (" b5 (%p) = %x\n", &b5, b5); printf (" b6 (%p) = %x\n", &b6, b6); return 0; } The line saying ***pointer = 255;** , maybe 40th line , the compiler blows , or the code stops working , saying this [if I make , *pointer = 255 or *pointer = 254][1] [and if I set any other values except this , my program works well i.e. *pointer = 4556 or *pointer = 45 ][2] [1]: http://i.stack.imgur.com/DMRtm.jpg [2]: http://i.stack.imgur.com/h2DAh.jpg Or in case of any other arbitrary values as well , it runs without any blow . Please tell me about this behaviour of addresses. *Source : Prof. Richard Buckland , I'm exploring all these due to his guidance.*
0debug
static void filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) { MpegEncContext * const s = &h->s; int mb_y_firstrow = s->picture_structure == PICT_BOTTOM_FIELD; int mb_xy, mb_type; int qp, qp0, qp1, qpc, qpc0, qpc1, qp_thresh; mb_xy = h->mb_xy; if(mb_x==0 || mb_y==mb_y_firstrow || !s->dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff || !(s->flags2 & CODEC_FLAG2_FAST) || (h->deblocking_filter == 2 && (h->slice_table[mb_xy] != h->slice_table[h->top_mb_xy] || h->slice_table[mb_xy] != h->slice_table[mb_xy - 1]))) { filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize); return; } assert(!FRAME_MBAFF); mb_type = s->current_picture.mb_type[mb_xy]; qp = s->current_picture.qscale_table[mb_xy]; qp0 = s->current_picture.qscale_table[mb_xy-1]; qp1 = s->current_picture.qscale_table[h->top_mb_xy]; qpc = get_chroma_qp( h, 0, qp ); qpc0 = get_chroma_qp( h, 0, qp0 ); qpc1 = get_chroma_qp( h, 0, qp1 ); qp0 = (qp + qp0 + 1) >> 1; qp1 = (qp + qp1 + 1) >> 1; qpc0 = (qpc + qpc0 + 1) >> 1; qpc1 = (qpc + qpc1 + 1) >> 1; qp_thresh = 15 - h->slice_alpha_c0_offset; if(qp <= qp_thresh && qp0 <= qp_thresh && qp1 <= qp_thresh && qpc <= qp_thresh && qpc0 <= qp_thresh && qpc1 <= qp_thresh) return; if( IS_INTRA(mb_type) ) { int16_t bS4[4] = {4,4,4,4}; int16_t bS3[4] = {3,3,3,3}; int16_t *bSH = FIELD_PICTURE ? bS3 : bS4; if( IS_8x8DCT(mb_type) ) { filter_mb_edgev( h, &img_y[4*0], linesize, bS4, qp0 ); filter_mb_edgev( h, &img_y[4*2], linesize, bS3, qp ); filter_mb_edgeh( h, &img_y[4*0*linesize], linesize, bSH, qp1 ); filter_mb_edgeh( h, &img_y[4*2*linesize], linesize, bS3, qp ); } else { filter_mb_edgev( h, &img_y[4*0], linesize, bS4, qp0 ); filter_mb_edgev( h, &img_y[4*1], linesize, bS3, qp ); filter_mb_edgev( h, &img_y[4*2], linesize, bS3, qp ); filter_mb_edgev( h, &img_y[4*3], linesize, bS3, qp ); filter_mb_edgeh( h, &img_y[4*0*linesize], linesize, bSH, qp1 ); filter_mb_edgeh( h, &img_y[4*1*linesize], linesize, bS3, qp ); filter_mb_edgeh( h, &img_y[4*2*linesize], linesize, bS3, qp ); filter_mb_edgeh( h, &img_y[4*3*linesize], linesize, bS3, qp ); } filter_mb_edgecv( h, &img_cb[2*0], uvlinesize, bS4, qpc0 ); filter_mb_edgecv( h, &img_cb[2*2], uvlinesize, bS3, qpc ); filter_mb_edgecv( h, &img_cr[2*0], uvlinesize, bS4, qpc0 ); filter_mb_edgecv( h, &img_cr[2*2], uvlinesize, bS3, qpc ); filter_mb_edgech( h, &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1 ); filter_mb_edgech( h, &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc ); filter_mb_edgech( h, &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1 ); filter_mb_edgech( h, &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc ); return; } else { DECLARE_ALIGNED_8(int16_t, bS[2][4][4]); uint64_t (*bSv)[4] = (uint64_t(*)[4])bS; int edges; if( IS_8x8DCT(mb_type) && (h->cbp&7) == 7 ) { edges = 4; bSv[0][0] = bSv[0][2] = bSv[1][0] = bSv[1][2] = 0x0002000200020002ULL; } else { int mask_edge1 = (mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16)) ? 3 : (mb_type & MB_TYPE_16x8) ? 1 : 0; int mask_edge0 = (mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16)) && (s->current_picture.mb_type[mb_xy-1] & (MB_TYPE_16x16 | MB_TYPE_8x16)) ? 3 : 0; int step = IS_8x8DCT(mb_type) ? 2 : 1; edges = (mb_type & MB_TYPE_16x16) && !(h->cbp & 15) ? 1 : 4; s->dsp.h264_loop_filter_strength( bS, h->non_zero_count_cache, h->ref_cache, h->mv_cache, (h->slice_type_nos == FF_B_TYPE), edges, step, mask_edge0, mask_edge1, FIELD_PICTURE); } if( IS_INTRA(s->current_picture.mb_type[mb_xy-1]) ) bSv[0][0] = 0x0004000400040004ULL; if( IS_INTRA(s->current_picture.mb_type[h->top_mb_xy]) ) bSv[1][0] = FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL; #define FILTER(hv,dir,edge)\ if(bSv[dir][edge]) {\ filter_mb_edge##hv( h, &img_y[4*edge*(dir?linesize:1)], linesize, bS[dir][edge], edge ? qp : qp##dir );\ if(!(edge&1)) {\ filter_mb_edgec##hv( h, &img_cb[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir );\ filter_mb_edgec##hv( h, &img_cr[2*edge*(dir?uvlinesize:1)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir );\ }\ } if( edges == 1 ) { FILTER(v,0,0); FILTER(h,1,0); } else if( IS_8x8DCT(mb_type) ) { FILTER(v,0,0); FILTER(v,0,2); FILTER(h,1,0); FILTER(h,1,2); } else { FILTER(v,0,0); FILTER(v,0,1); FILTER(v,0,2); FILTER(v,0,3); FILTER(h,1,0); FILTER(h,1,1); FILTER(h,1,2); FILTER(h,1,3); } #undef FILTER } }
1threat
Inheritance vs. Delegation : <p>The code below shows how method m() can be reused by inheritance. How works for delegation? Thanks!</p> <pre><code> class A{ int m(); } class B extends A{} B b =new B() b.m(); </code></pre>
0debug
void object_property_set_link(Object *obj, Object *value, const char *name, Error **errp) { object_property_set_str(obj, object_get_canonical_path(value), name, errp); }
1threat
Difference between NULL, 0 ,False and ''? : <p>What is the exact difference between <code>null</code>, <code>0</code>, <code>false</code>, and an empty string in PHP? Is <code>null</code> similar to <code>None</code> in python?</p>
0debug
How to calculate exact average using arrays in Java : <p>Regardless of what I try, the program outputs the average as the integer "4" when the average should be "4.78". I have tried changing the integers to doubles, but to no avail. </p> <p>The rest of the program works as intended, though. It is supposed to print how many times each value in the text files appears by putting an asterisk next to it and it is supposed to indicate when a number is larger than the average by having a ">" appear next to it in the output.</p> <pre><code>import java.io.File; import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String args[]) throws IOException { int i = 0, count = 0, sum = 0; Scanner file = new Scanner(new File("input3.txt")); int[] frequency = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int[] arr = new int[50]; int current_num; while (file.hasNext()) { current_num = file.nextInt(); sum += current_num; arr[i++] = current_num; count++; frequency[current_num]++; } int average = sum / count; for(i=0; i&lt;arr.length; i++){ if(arr[i] &gt; average){ System.out.print(arr[i] + " &gt; " ); } else{ System.out.print(arr[i] + " "); } if(i%5==4){ System.out.println(); } } System.out.println("\n***** Frequency Graph *****\n"); for(i=0; i&lt;frequency.length; i++){ System.out.print(i + " = "); for(int j=0; j&lt;frequency[i]; j++){ System.out.print("*"); } System.out.println(); } System.out.println("\nAverage of the numbers in the text file is : " + average); } } </code></pre> <p>The numbers in the "input3.txt" file are: </p> <pre><code>5 8 8 1 5 0 6 6 5 3 4 0 6 8 5 4 9 5 8 0 4 7 4 2 0 9 8 3 5 5 5 7 5 7 1 4 4 0 7 4 8 4 2 4 9 8 8 2 3 4 </code></pre> <p>Any help would be appreciated!</p>
0debug
Cannot avoid the error marks on md elements of Angualar material in visual studio 2013 : [Project Image][1][enter image description here][2] Cannot avoid the error marks on md elements of Angualr material in visual studio 2013 [1]: https://i.stack.imgur.com/eNaH9.jpg [2]: https://i.stack.imgur.com/XXWTv.jpg
0debug
Typeclasses and overloading, what is the connection? : <p>I am currently trying to wrap my head around typeclasses and instances and I don't quite understand the point of them yet. I have two questions on the matter so far:</p> <p>1) Why is it necessary to have a type class in a function signature when the function uses some function from that type class. Example:</p> <pre><code>f :: (Eq a) =&gt; a -&gt; a -&gt; Bool f a b = a == b </code></pre> <p>Why put <code>(Eq a)</code> in the signature. If <code>==</code> is not defined for <code>a</code> then why not just throw the error when encountering <code>a == b</code>? What is the point in having to declare the type class ahead?</p> <p>2) How are type classes and function overloading related?</p> <p>It is not possible to do this:</p> <pre><code>data A = A data B = B f :: A -&gt; A f a = a f :: B -&gt; B f b = b </code></pre> <p>But it is possible to do this:</p> <pre><code>data A = A data B = B class F a where f :: a -&gt; a instance F A where f a = a instance F B where f b = b </code></pre> <p>What is up with that? Why can't I have two functions with the same name but operating on different types... Coming from C++ I find that very strange. But I probably have wrong conceptions about what these things really are. but once I wrap them in these type class instance thingies I can.</p> <p>Feel free to hurl category or type theoretical words at me as well, as I am learning about these subjects in parallel to learning Haskell and I suspect there is a theoretical basis in these for how Haskell does things here.</p>
0debug
static int metasound_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx, const uint8_t *buf, int buf_size) { TwinVQFrameData *bits = &tctx->bits; const TwinVQModeTab *mtab = tctx->mtab; int channels = tctx->avctx->channels; int sub; GetBitContext gb; int i, j, k; if (buf_size * 8 < avctx->bit_rate * mtab->size / avctx->sample_rate) { av_log(avctx, AV_LOG_ERROR, "Frame too small (%d bytes). Truncated file?\n", buf_size); return AVERROR(EINVAL); } init_get_bits(&gb, buf, buf_size * 8); bits->window_type = get_bits(&gb, TWINVQ_WINDOW_TYPE_BITS); if (bits->window_type > 8) { av_log(avctx, AV_LOG_ERROR, "Invalid window type, broken sample?\n"); return AVERROR_INVALIDDATA; } bits->ftype = ff_twinvq_wtype_to_ftype_table[tctx->bits.window_type]; sub = mtab->fmode[bits->ftype].sub; if (bits->ftype != TWINVQ_FT_SHORT) get_bits(&gb, 2); read_cb_data(tctx, &gb, bits->main_coeffs, bits->ftype); for (i = 0; i < channels; i++) for (j = 0; j < sub; j++) for (k = 0; k < mtab->fmode[bits->ftype].bark_n_coef; k++) bits->bark1[i][j][k] = get_bits(&gb, mtab->fmode[bits->ftype].bark_n_bit); for (i = 0; i < channels; i++) for (j = 0; j < sub; j++) bits->bark_use_hist[i][j] = get_bits1(&gb); if (bits->ftype == TWINVQ_FT_LONG) { for (i = 0; i < channels; i++) bits->gain_bits[i] = get_bits(&gb, TWINVQ_GAIN_BITS); } else { for (i = 0; i < channels; i++) { bits->gain_bits[i] = get_bits(&gb, TWINVQ_GAIN_BITS); for (j = 0; j < sub; j++) bits->sub_gain_bits[i * sub + j] = get_bits(&gb, TWINVQ_SUB_GAIN_BITS); } } for (i = 0; i < channels; i++) { bits->lpc_hist_idx[i] = get_bits(&gb, mtab->lsp_bit0); bits->lpc_idx1[i] = get_bits(&gb, mtab->lsp_bit1); for (j = 0; j < mtab->lsp_split; j++) bits->lpc_idx2[i][j] = get_bits(&gb, mtab->lsp_bit2); } if (bits->ftype == TWINVQ_FT_LONG) { read_cb_data(tctx, &gb, bits->ppc_coeffs, 3); for (i = 0; i < channels; i++) { bits->p_coef[i] = get_bits(&gb, mtab->ppc_period_bit); bits->g_coef[i] = get_bits(&gb, mtab->pgain_bit); } } return 0; }
1threat
def all_Bits_Set_In_The_Given_Range(n,l,r): num = (((1 << r) - 1) ^ ((1 << (l - 1)) - 1)) new_num = n & num if (new_num == 0): return True return False
0debug
event_thread(void *arg) { unsigned char atr[MAX_ATR_LEN]; int atr_len = MAX_ATR_LEN; VEvent *event = NULL; unsigned int reader_id; while (1) { const char *reader_name; event = vevent_wait_next_vevent(); if (event == NULL) { break; } reader_id = vreader_get_id(event->reader); if (reader_id == VSCARD_UNDEFINED_READER_ID && event->type != VEVENT_READER_INSERT) { qemu_mutex_lock(&pending_reader_lock); if (!pending_reader || (pending_reader != event->reader)) { qemu_mutex_unlock(&pending_reader_lock); vevent_delete(event); continue; } while (pending_reader != NULL) { qemu_cond_wait(&pending_reader_condition, &pending_reader_lock); } qemu_mutex_unlock(&pending_reader_lock); reader_id = vreader_get_id(event->reader); if (reader_id == VSCARD_UNDEFINED_READER_ID) { vevent_delete(event); continue; } } switch (event->type) { case VEVENT_READER_INSERT: qemu_mutex_lock(&pending_reader_lock); while (pending_reader != NULL) { qemu_cond_wait(&pending_reader_condition, &pending_reader_lock); } pending_reader = vreader_reference(event->reader); qemu_mutex_unlock(&pending_reader_lock); reader_name = vreader_get_name(event->reader); if (verbose > 10) { printf(" READER INSERT: %s\n", reader_name); } send_msg(VSC_ReaderAdd, reader_id, NULL, 0 ); break; case VEVENT_READER_REMOVE: if (verbose > 10) { printf(" READER REMOVE: %u\n", reader_id); } send_msg(VSC_ReaderRemove, reader_id, NULL, 0); break; case VEVENT_CARD_INSERT: atr_len = MAX_ATR_LEN; vreader_power_on(event->reader, atr, &atr_len); if (verbose > 10) { printf(" CARD INSERT %u: ", reader_id); print_byte_array(atr, atr_len); } send_msg(VSC_ATR, reader_id, atr, atr_len); break; case VEVENT_CARD_REMOVE: if (verbose > 10) { printf(" CARD REMOVE %u:\n", reader_id); } send_msg(VSC_CardRemove, reader_id, NULL, 0); break; default: break; } vevent_delete(event); } return NULL; }
1threat
code to find the largest number in the array but it only showing the first number as the largest. someone please let me know why : <pre><code> #include &lt;iostream&gt; using namespace std; int findLargest() { int arg[25],largest,size,i,j; cout&lt;&lt;"enter the size of array"&lt;&lt;endl; cin&gt;&gt;size; cout&lt;&lt;"enter the numbers"&lt;&lt;endl; for(i; i&lt;size; i++) { cin&gt;&gt;arg[i]; } for(j=1; j&lt;size; j++) { largest=arg[0]; if(arg[0]&lt;arg[j]) { largest==arg[j]; } } cout&lt;&lt;"The largest number is : "&lt;&lt;largest; } int main() { findLargest(); return 0;} </code></pre> <p>whats wrong with this? wrote this code to find the largest number in the array but it only shows the first number in the array as the largest</p>
0debug
Android studio layout design issue : I have a problem in the layout design in android studio, in android studio I set 720x1280 in the design preview option. Its the first image. But when i build the apk and install it in the device, the same activity looks like the second image. Its like it's cut. I need that in the first image, the blank space "expands" because i need to put the title long across in the second screen. The sentence is "Ingrese fecha de vencimiento" but only shows "Ingrese fecha de" . How can i fix this? [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/hRluY.png
0debug
Error defining a function : <p>My task is to make o a function named count_nucleotides which takes to string, one word and a letter and counts the appearance number of the letter. For example:</p> <p>count_nucleotides('ATCGGC', 'G') and gives 2</p> <p>count_nucleotides('ATCTA', 'G') and gives 0</p> <p>My code until now is below:</p> <pre><code>def count_nucleotides(dna, nucleotide): count = 0 num = nucleotide for char in dna: if char = num: count = count +1 return count </code></pre> <p>It returns a message: expected an intended block</p> <p>I am new at python proggramming so if someone could explain instead of asking question such as where define this or that, i would be grateful. This is my first task so excuse me for what you see!</p>
0debug
static int milkymist_minimac2_init(SysBusDevice *sbd) { DeviceState *dev = DEVICE(sbd); MilkymistMinimac2State *s = MILKYMIST_MINIMAC2(dev); size_t buffers_size = TARGET_PAGE_ALIGN(3 * MINIMAC2_BUFFER_SIZE); sysbus_init_irq(sbd, &s->rx_irq); sysbus_init_irq(sbd, &s->tx_irq); memory_region_init_io(&s->regs_region, OBJECT(dev), &minimac2_ops, s, "milkymist-minimac2", R_MAX * 4); sysbus_init_mmio(sbd, &s->regs_region); memory_region_init_ram(&s->buffers, OBJECT(dev), "milkymist-minimac2.buffers", buffers_size, &error_abort); vmstate_register_ram_global(&s->buffers); s->rx0_buf = memory_region_get_ram_ptr(&s->buffers); s->rx1_buf = s->rx0_buf + MINIMAC2_BUFFER_SIZE; s->tx_buf = s->rx1_buf + MINIMAC2_BUFFER_SIZE; sysbus_init_mmio(sbd, &s->buffers); qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic = qemu_new_nic(&net_milkymist_minimac2_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); return 0; }
1threat
void op_flush_icache_all(void) { CALL_FROM_TB1(tb_flush, env); RETURN(); }
1threat
I have built a regex but there is an issue : <p>I have this regex as follows </p> <pre><code>/^\S(?=.*[a-z])(?=.*[A-Z])(?=.{8,})(?=.*[0-9])\S </code></pre> <p>it does most of what's its suppose to do such as must be eight characters long have at least one uppercase character one lowercase and one number however the problem is that it accepts any special characters at the end of the string even it passes the other validation i can't have this can someone modify this regex that it keeps the same functionality mentioned before but does not accept any special characters at all. Oh this is for php and javascript i use this both for client side and server side validation of a password any clues as to where the regex fails is greatly appreciated.</p>
0debug
static unsigned hpte_page_shift(const struct ppc_one_seg_page_size *sps, uint64_t pte0, uint64_t pte1) { int i; if (!(pte0 & HPTE64_V_LARGE)) { if (sps->page_shift != 12) { return 0; } return 12; } for (i = 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) { const struct ppc_one_page_size *ps = &sps->enc[i]; uint64_t mask; if (!ps->page_shift) { break; } if (ps->page_shift == 12) { continue; } mask = ((1ULL << ps->page_shift) - 1) & HPTE64_R_RPN; if ((pte1 & mask) == (ps->pte_enc << HPTE64_R_RPN_SHIFT)) { return ps->page_shift; } } return 0; }
1threat
void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, uint8_t *data, uint32_t len) { int arch = !!(key & FW_CFG_ARCH_LOCAL); key &= FW_CFG_ENTRY_MASK; assert(key < FW_CFG_MAX_ENTRY); s->entries[arch][key].data = data; s->entries[arch][key].len = len; }
1threat
File Saveas xls to xlsx : I have an excel file in the **C** disk named **C:\Book1.xls** How can I saveas **C:\Book1.xls** to **C:\Book2.xlsx** ? Is it possible to use **System.IO.File.SaveAs** class?
0debug
how to extract number sets in parentheses from google sheet : How to extract and split this set of numbers (314.81+10.00)+0.00 to each column expected result: [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/QHkjZ.png
0debug
I want to filter rows by the content of their cells, with multiple words : <p>I have a table with this look <a href="https://i.stack.imgur.com/fAaYS.png" rel="nofollow noreferrer">enter image description here</a></p> <p>I want to filter all the rows that in the column Cellular have the word membrane. But when I do this I get only the rows that have the word membrane alone, and not any other word. Help</p>
0debug
Converting Java string to Date : <p>I need to convert a java string in a date format to a new date format to send it to my sql-server. Currently, my Java date is <code>Jul 17 2018 14:22:58</code>, and I need it to look like <code>2018-07-17 14:22:58</code>. So I created this:</p> <pre><code>String oldTime = "Jul 17 2018 14:22:58"; SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD HH:MM:SS"); Date formattedDate = sdf.parse(oldTime); </code></pre> <p>I am getting errors that my oldTime is unparseable. Did I do this wrong?</p>
0debug
R: return first value that exceeds 0.8 within groups : data<-data.frame(c(A,A,A,A,B,B,B,C,C,C),c(0.2,0.78,0.82,0,1,0.1,0.81,1,0.8,0.92,1)) Hello! I would like to choose only first 80% within each group (A,B). Means I cannot use ordinary <. Any ideas?
0debug
given a role ARN, you want to find out which stack and region created the role? : Can anyone please provide cli command to get stack name and region of a role created through it
0debug
The application bundle does not contain a valid identifier : <p>I try to run my project but i get the following error "The application bundle does not contain a valid identifier."</p> <p>here my info.plist</p> <p><a href="https://i.stack.imgur.com/p1jC9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/p1jC9.png" alt="enter image description here"></a></p> <p>I followed other answer on the question. I don't have any "Ressources" folder inside my project.</p> <p>Thanks for your help</p>
0debug
Python: how to merge two dataframes with different size? : <p>I have two dataframes, <code>df</code> and <code>df1</code>. The first one contains all the information about all the possible combination of a dataset while the second one is just a subset without the information.</p> <pre><code>df x y distance 0 1 4 0 2 3 0 3 2 1 2 2 1 3 5 2 3 1 df1 x y 1 3 2 3 2 3 </code></pre> <p>I would like to merge <code>df</code> and <code>df1</code> in order to have the following:</p> <pre><code>df1 x y distance 1 3 5 2 3 1 2 3 1 </code></pre>
0debug
"import torch" giving error "from torch._C import *, DLL load failed: The specified module could not be found" : <p>I am currently using Python 3.5.5 on Anaconda and I am unable to import torch. It is giving me the following error in Spyder: </p> <pre><code>Python 3.5.5 |Anaconda, Inc.| (default, Mar 12 2018, 17:44:09) [MSC v.1900 64 bit (AMD64)] Type "copyright", "credits" or "license" for more information. IPython 6.2.1 -- An enhanced Interactive Python. import torch Traceback (most recent call last): File "&lt;ipython-input-1-eb42ca6e4af3&gt;", line 1, in &lt;module&gt; import torch File "C:\Users\trish\Anaconda3\envs\virtual_platform\lib\site- packages\torch\__init__.py", line 76, in &lt;module&gt; from torch._C import * ImportError: DLL load failed: The specified module could not be found. </code></pre> <p>Many suggestions on the internet say that the working directory should not be the same directory that the torch package is in, however I've manually set my working directory to C:/Users/trish/Downloads, and I am getting the same error. </p> <p>Also I've already tried the following: reinstalling Anaconda and all packages from scratch, and I've ensured there is no duplicate "torch" folder in my directory. </p> <p>Pls help! Thank you!</p>
0debug
How do I flatten a tensor in pytorch? : <p>Given a tensor of multiple dimensions, how do I flatten it so that it has a single dimension?</p> <p>Eg:</p> <pre><code>&gt;&gt;&gt; t = torch.rand([2, 3, 5]) &gt;&gt;&gt; t.shape torch.Size([2, 3, 5]) </code></pre> <p>How do I flatten it to have shape:</p> <pre><code>torch.Size([30]) </code></pre>
0debug
void OPPROTO op_store_msr (void) { do_store_msr(env, T0); RETURN(); }
1threat
static void coroutine_fn v9fs_flush(void *opaque) { ssize_t err; int16_t tag; size_t offset = 7; V9fsPDU *cancel_pdu; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; err = pdu_unmarshal(pdu, offset, "w", &tag); if (err < 0) { pdu_complete(pdu, err); return; } trace_v9fs_flush(pdu->tag, pdu->id, tag); QLIST_FOREACH(cancel_pdu, &s->active_list, next) { if (cancel_pdu->tag == tag) { break; } } if (cancel_pdu) { cancel_pdu->cancelled = 1; qemu_co_queue_wait(&cancel_pdu->complete, NULL); cancel_pdu->cancelled = 0; pdu_free(cancel_pdu); } pdu_complete(pdu, 7); }
1threat
static void imdct36(int *out, int *buf, int *in, int *win) { int i, j, t0, t1, t2, t3, s0, s1, s2, s3; int tmp[18], *tmp1, *in1; for(i=17;i>=1;i--) in[i] += in[i-1]; for(i=17;i>=3;i-=2) in[i] += in[i-2]; for(j=0;j<2;j++) { tmp1 = tmp + j; in1 = in + j; #if 0 int64_t t0, t1, t2, t3; t2 = in1[2*4] + in1[2*8] - in1[2*2]; t3 = (in1[2*0] + (int64_t)(in1[2*6]>>1))<<32; t1 = in1[2*0] - in1[2*6]; tmp1[ 6] = t1 - (t2>>1); tmp1[16] = t1 + t2; t0 = MUL64(2*(in1[2*2] + in1[2*4]), C2); t1 = MUL64( in1[2*4] - in1[2*8] , -2*C8); t2 = MUL64(2*(in1[2*2] + in1[2*8]), -C4); tmp1[10] = (t3 - t0 - t2) >> 32; tmp1[ 2] = (t3 + t0 + t1) >> 32; tmp1[14] = (t3 + t2 - t1) >> 32; tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3); t2 = MUL64(2*(in1[2*1] + in1[2*5]), C1); t3 = MUL64( in1[2*5] - in1[2*7] , -2*C7); t0 = MUL64(2*in1[2*3], C3); t1 = MUL64(2*(in1[2*1] + in1[2*7]), -C5); tmp1[ 0] = (t2 + t3 + t0) >> 32; tmp1[12] = (t2 + t1 - t0) >> 32; tmp1[ 8] = (t3 - t1 - t0) >> 32; #else t2 = in1[2*4] + in1[2*8] - in1[2*2]; t3 = in1[2*0] + (in1[2*6]>>1); t1 = in1[2*0] - in1[2*6]; tmp1[ 6] = t1 - (t2>>1); tmp1[16] = t1 + t2; t0 = MULH(2*(in1[2*2] + in1[2*4]), C2); t1 = MULH( in1[2*4] - in1[2*8] , -2*C8); t2 = MULH(2*(in1[2*2] + in1[2*8]), -C4); tmp1[10] = t3 - t0 - t2; tmp1[ 2] = t3 + t0 + t1; tmp1[14] = t3 + t2 - t1; tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3); t2 = MULH(2*(in1[2*1] + in1[2*5]), C1); t3 = MULH( in1[2*5] - in1[2*7] , -2*C7); t0 = MULH(2*in1[2*3], C3); t1 = MULH(2*(in1[2*1] + in1[2*7]), -C5); tmp1[ 0] = t2 + t3 + t0; tmp1[12] = t2 + t1 - t0; tmp1[ 8] = t3 - t1 - t0; #endif } i = 0; for(j=0;j<4;j++) { t0 = tmp[i]; t1 = tmp[i + 2]; s0 = t1 + t0; s2 = t1 - t0; t2 = tmp[i + 1]; t3 = tmp[i + 3]; s1 = MULL(t3 + t2, icos36[j]); s3 = MULL(t3 - t2, icos36[8 - j]); t0 = (s0 + s1) << 5; t1 = (s0 - s1) << 5; out[(9 + j)*SBLIMIT] = MULH(t1, win[9 + j]) + buf[9 + j]; out[(8 - j)*SBLIMIT] = MULH(t1, win[8 - j]) + buf[8 - j]; buf[9 + j] = MULH(t0, win[18 + 9 + j]); buf[8 - j] = MULH(t0, win[18 + 8 - j]); t0 = (s2 + s3) << 5; t1 = (s2 - s3) << 5; out[(9 + 8 - j)*SBLIMIT] = MULH(t1, win[9 + 8 - j]) + buf[9 + 8 - j]; out[( j)*SBLIMIT] = MULH(t1, win[ j]) + buf[ j]; buf[9 + 8 - j] = MULH(t0, win[18 + 9 + 8 - j]); buf[ + j] = MULH(t0, win[18 + j]); i += 4; } s0 = tmp[16]; s1 = MULL(tmp[17], icos36[4]); t0 = (s0 + s1) << 5; t1 = (s0 - s1) << 5; out[(9 + 4)*SBLIMIT] = MULH(t1, win[9 + 4]) + buf[9 + 4]; out[(8 - 4)*SBLIMIT] = MULH(t1, win[8 - 4]) + buf[8 - 4]; buf[9 + 4] = MULH(t0, win[18 + 9 + 4]); buf[8 - 4] = MULH(t0, win[18 + 8 - 4]); }
1threat
document.write('<script src="evil.js"></script>');
1threat
How can read from some files and write content of them with different form into files with same names : <p>I have some files with names f_1to2.txt, f_1to3.txt, f_2to1.txt, f_2to3.txt, ..., f_99to100.txt. I want to do something with the contents of these files and then write these changed files with the same names into another folder. How can I do it? thanks a lot.</p>
0debug
How To Run Exported Jar Without Having Assets Next To It : <p>I created a game using LibGDX and I'm trying to figure out how to run a jar without having the images and such within the same folder as it. How do I make it so the jar itself is self sufficient and has the assets contained within it?</p>
0debug
static void omap_pwt_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { struct omap_pwt_s *s = (struct omap_pwt_s *) opaque; int offset = addr & OMAP_MPUI_REG_MASK; if (size != 1) { omap_badwidth_write8(opaque, addr, value); return; } switch (offset) { case 0x00: s->frc = value & 0x3f; break; case 0x04: if ((value ^ s->vrc) & 1) { if (value & 1) printf("%s: %iHz buzz on\n", __FUNCTION__, (int) ((omap_clk_getrate(s->clk) >> 3) / ((s->gcr & 2) ? 1 : 154) / (2 << (value & 3)) * ((value & (1 << 2)) ? 101 : 107) * ((value & (1 << 3)) ? 49 : 55) * ((value & (1 << 4)) ? 50 : 63) * ((value & (1 << 5)) ? 80 : 127) / (107 * 55 * 63 * 127))); else printf("%s: silence!\n", __FUNCTION__); } s->vrc = value & 0x7f; break; case 0x08: s->gcr = value & 3; break; default: OMAP_BAD_REG(addr); return; } }
1threat
static void event_test_emit(test_QAPIEvent event, QDict *d, Error **errp) { QObject *obj; QDict *t; int64_t s, ms; obj = qdict_get(d, "timestamp"); g_assert(obj); t = qobject_to_qdict(obj); g_assert(t); obj = qdict_get(t, "seconds"); g_assert(obj && qobject_type(obj) == QTYPE_QINT); s = qint_get_int(qobject_to_qint(obj)); obj = qdict_get(t, "microseconds"); g_assert(obj && qobject_type(obj) == QTYPE_QINT); ms = qint_get_int(qobject_to_qint(obj)); if (s == -1) { g_assert(ms == -1); } else { g_assert(ms >= 0 && ms <= 999999); } g_assert(qdict_size(t) == 2); qdict_del(d, "timestamp"); g_assert(qdict_cmp_simple(d, test_event_data->expect)); }
1threat
'choco' command not recognized when run as administrator on Windows : <p>I installed Chocolatey as per the instructions on the website (<a href="https://chocolatey.org/install" rel="noreferrer">https://chocolatey.org/install</a>).</p> <p>The 'choco' command works fine when I run it normally on cmd but returns the following error when run as administrator:</p> <pre><code>C:\WINDOWS\system32&gt;choco install -y wget 7zip.commandline 'choco' is not recognized as an internal or external command, operable program or batch file. </code></pre> <p>The install <code>choco install -y wget 7zip.commandline</code> fails if not run as administrator.</p> <p>How do I fix 'not recognized' error in admin cmd?</p>
0debug
static always_inline void gen_op_neg (DisasContext *ctx, TCGv ret, TCGv arg1, int ov_check) { int l1, l2; l1 = gen_new_label(); l2 = gen_new_label(); #if defined(TARGET_PPC64) if (ctx->sf_mode) { tcg_gen_brcondi_tl(TCG_COND_EQ, arg1, INT64_MIN, l1); } else { TCGv t0 = tcg_temp_new(TCG_TYPE_TL); tcg_gen_ext32s_tl(t0, arg1); tcg_gen_brcondi_tl(TCG_COND_EQ, t0, INT32_MIN, l1); } #else tcg_gen_brcondi_tl(TCG_COND_EQ, arg1, INT32_MIN, l1); #endif tcg_gen_neg_tl(ret, arg1); if (ov_check) { tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_OV)); } tcg_gen_br(l2); gen_set_label(l1); tcg_gen_mov_tl(ret, arg1); if (ov_check) { tcg_gen_ori_tl(cpu_xer, cpu_xer, (1 << XER_OV) | (1 << XER_SO)); } gen_set_label(l2); if (unlikely(Rc(ctx->opcode) != 0)) gen_set_Rc0(ctx, ret); }
1threat
docker service replicas remain 0/1 : <p>I am trying out docker swarm with 1.12 on my Mac. I started 3 VirtualBox VMs, created a swarm cluster of 3 all fine.</p> <pre><code>docker@redis1:~$ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 2h1m8equ5w5beetbq3go56ebl redis3 Ready Active 8xubu8g7pzjvo34qdtqxeqjlj redis2 Ready Active Reachable cbi0lyekxmp0o09j5hx48u7vm * redis1 Ready Active Leader </code></pre> <p>However, when I create a service, I see no errors yet replicas always displays 0/1:</p> <pre><code>docker@redis1:~$ docker service create --replicas 1 --name hello ubuntu:latest /bin/bash 76kvrcvnz6kdhsmzmug6jgnjv docker@redis1:~$ docker service ls ID NAME REPLICAS IMAGE COMMAND 76kvrcvnz6kd hello 0/1 ubuntu:latest /bin/bash docker@redis1:~$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES </code></pre> <p>What could be the problem? Where do I look for logs? Thanks!</p>
0debug
What do the function arguments in STATIC_ROOT = os.path.join(BASE_DIR, 'static') mean? : Django newbie here. I'm on Django 2.1 and was taking tutorials when I saw this line in the settings.py file. What exactly does this line mean? What does os.path.join do?
0debug
Java android: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $ : I'm trying to parse a JSON file that looks like this: [ {"character": "㐭", "definition": "blabla", "pinyin": ["lin"]}, // some more {"character": "㐱", "definition": "blabla", "pinyin": ["zhen"]} ] Which is situated in res/raw/dictionary.json folder. But I get the Exception <code>Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $</code>. I'm getting data like this: InputStream is = getResources().openRawResource(R.id.dictionary); Writer writer = new StringWriter(); char[] buffer = new char[1024]; try { Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); int n; while((n = reader.read(buffer)) != -1) { writer.write(buffer, 0, n); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); finish(); // For now just finishing activity, gonna add handling later } catch (IOException e) { e.printStackTrace(); finish(); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(); finish(); } } String json = writer.toString(); First I thought error appeared because of the way I'm using to parse json, but when I commented out and then deleted all mechanism of parsing, it still showed me this error. Seems like it happens when android loads resources, but I'm not sure. I tried modifying json to following: { "characters": [ {"character": "㐭", "definition": "blabla", "pinyin": ["lin"]}, // some more {"character": "㐱", "definition": "blabla", "pinyin": ["zhen"]} ] } But that didn't help either. What can be wrong here?
0debug
Docker Bridge Conflicts with Host Network : <p>Docker seems to be creating a bridge after a container starts running that then conflicts with my host network. This is not the default bridge docker0, but rather another bridge that is created after a container has started. I am able to configure the default bridge according to the older user guide link <a href="https://docs.docker.com/v17.09/engine/userguide/networking/default_network/custom-docker0/" rel="noreferrer">https://docs.docker.com/v17.09/engine/userguide/networking/default_network/custom-docker0/</a>, however, I do not know how to configure this other bridge so it does not conflict with 172.17. </p> <p>This current issue is then that my container cannot access other systems on the host network when this bridge becomes active.</p> <p>Any ideas?</p> <p>Version of docker:</p> <pre><code>Version 18.03.1-ce-mac65 (24312) </code></pre> <p>This is the bridge that gets created. Sometimes it is not 172.17, but sometimes it is.</p> <pre><code>br-f7b50f41d024 Link encap:Ethernet HWaddr 02:42:7D:1B:05:A3 inet addr:172.17.0.1 Bcast:172.17.255.255 Mask:255.255.0.0 </code></pre>
0debug
static int tak_read_header(AVFormatContext *s) { TAKDemuxContext *tc = s->priv_data; AVIOContext *pb = s->pb; GetBitContext gb; AVStream *st; uint8_t *buffer = NULL; int ret; st = avformat_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = AV_CODEC_ID_TAK; st->need_parsing = AVSTREAM_PARSE_FULL_RAW; tc->mlast_frame = 0; if (avio_rl32(pb) != MKTAG('t', 'B', 'a', 'K')) { avio_seek(pb, -4, SEEK_CUR); return 0; } while (!url_feof(pb)) { enum TAKMetaDataType type; int size; type = avio_r8(pb) & 0x7f; size = avio_rl24(pb); switch (type) { case TAK_METADATA_STREAMINFO: case TAK_METADATA_LAST_FRAME: case TAK_METADATA_ENCODER: if (size <= 3) return AVERROR_INVALIDDATA; buffer = av_malloc(size - 3 + FF_INPUT_BUFFER_PADDING_SIZE); if (!buffer) return AVERROR(ENOMEM); ffio_init_checksum(pb, tak_check_crc, 0xCE04B7U); if (avio_read(pb, buffer, size - 3) != size - 3) { av_freep(&buffer); return AVERROR(EIO); } if (ffio_get_checksum(s->pb) != avio_rb24(pb)) { av_log(s, AV_LOG_ERROR, "%d metadata block CRC error.\n", type); if (s->error_recognition & AV_EF_EXPLODE) { av_freep(&buffer); return AVERROR_INVALIDDATA; } } init_get_bits8(&gb, buffer, size - 3); break; case TAK_METADATA_MD5: { uint8_t md5[16]; int i; if (size != 19) return AVERROR_INVALIDDATA; ffio_init_checksum(pb, tak_check_crc, 0xCE04B7U); avio_read(pb, md5, 16); if (ffio_get_checksum(s->pb) != avio_rb24(pb)) { av_log(s, AV_LOG_ERROR, "MD5 metadata block CRC error.\n"); if (s->error_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } av_log(s, AV_LOG_VERBOSE, "MD5="); for (i = 0; i < 16; i++) av_log(s, AV_LOG_VERBOSE, "%02x", md5[i]); av_log(s, AV_LOG_VERBOSE, "\n"); break; } case TAK_METADATA_END: { int64_t curpos = avio_tell(pb); if (pb->seekable) { ff_ape_parse_tag(s); avio_seek(pb, curpos, SEEK_SET); } tc->data_end += curpos; return 0; } default: ret = avio_skip(pb, size); if (ret < 0) return ret; } if (type == TAK_METADATA_STREAMINFO) { TAKStreamInfo ti; avpriv_tak_parse_streaminfo(&gb, &ti); if (ti.samples > 0) st->duration = ti.samples; st->codec->bits_per_coded_sample = ti.bps; if (ti.ch_layout) st->codec->channel_layout = ti.ch_layout; st->codec->sample_rate = ti.sample_rate; st->codec->channels = ti.channels; st->start_time = 0; avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); st->codec->extradata = buffer; st->codec->extradata_size = size - 3; buffer = NULL; } else if (type == TAK_METADATA_LAST_FRAME) { if (size != 11) return AVERROR_INVALIDDATA; tc->mlast_frame = 1; tc->data_end = get_bits64(&gb, TAK_LAST_FRAME_POS_BITS) + get_bits(&gb, TAK_LAST_FRAME_SIZE_BITS); av_freep(&buffer); } else if (type == TAK_METADATA_ENCODER) { av_log(s, AV_LOG_VERBOSE, "encoder version: %0X\n", get_bits_long(&gb, TAK_ENCODER_VERSION_BITS)); av_freep(&buffer); } } return AVERROR_EOF; }
1threat
CSS Center curved figure : <p>Is there a way to draw the following figure just with pure CSS? <a href="https://i.stack.imgur.com/UDjI7.jpg" rel="nofollow noreferrer">figure</a></p>
0debug
static int url_connect(struct playlist *pls, AVDictionary *opts, AVDictionary *opts2) { AVDictionary *tmp = NULL; int ret; av_dict_copy(&tmp, opts, 0); av_dict_copy(&tmp, opts2, 0); av_opt_set_dict(pls->input, &tmp); if ((ret = ffurl_connect(pls->input, NULL)) < 0) { ffurl_close(pls->input); pls->input = NULL; } av_dict_free(&tmp); return ret; }
1threat
how to use Sql IN Statement with list of Items selected from treeviewlist? : how to join string values from "For Next Loop" into one single string Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim accid As String Dim iLast As Integer iLast = trv.Nodes.Count Dim p As Integer = 0 For p = 0 To iLast - 1 If TrV.Nodes(p).Checked = True Then accid = Strings.Left(TrV.Nodes(p).Text, 9) MsgBox(accid) End If Next End Sub this give me seperate output of string "accid" i want this output = "accid1,accid2,accid3" thanks for supporting
0debug
I have a table like below i want the latest entry to be displayed.Please let me know i you need any other details : [The Query which iam using now is below ][1] [The raw output s as this image shows][2] The data is what i get now but i want the latest entry for uid 3,15,33 The reason why i have done the below is and ua.user_activity_uid=(select max(ua0.user_activity_uid) from user_activity ua0) ksl_user_activity table has a primary key user_activity_id which has the meximum value for the latest entry but iam not getting any data when i include this in my Query i also tried and ua.user_activity_uid=(select ua0.user_activity_uid from user_activity ua0 order by ua0.user_activity_uid desc limit 1) which is also not working .Please help me out [1]: https://i.stack.imgur.com/hzFTn.png [2]: https://i.stack.imgur.com/I2L5t.png
0debug
char *av_base64_encode(uint8_t * src, int len) { static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; char *ret, *dst; unsigned i_bits = 0; int i_shift = 0; int bytes_remaining = len; if (len < UINT_MAX / 4) { ret = dst = av_malloc(len * 4 / 3 + 12); } else return NULL; if (len) { while (bytes_remaining) { i_bits = (i_bits << 8) + *src++; bytes_remaining--; i_shift += 8; do { *dst++ = b64[(i_bits << 6 >> i_shift) & 0x3f]; i_shift -= 6; } while (i_shift > 6 || (bytes_remaining == 0 && i_shift > 0)); } while ((dst - ret) & 3) *dst++ = '='; } *dst = '\0'; return ret; }
1threat
Given a list of positive and negative numbers. What is an elegant solution to tell which is closest to zero? : <p>Say you have a list of numbers:</p> <pre><code>var list = [4, -12, 18, 1, -3]; </code></pre> <p>What is a more elegant solution to finding the value closest to zero without nesting a whole lot of if/else statements?</p>
0debug
PHP: How do I limit the amount of results in an array : <p>I am pulling trends out of the Twitter API. I end up with an array with 42 items. I can print the elements I want just fine, however I would like to limit the amount of elements to just 5 instead of 42.</p> <p>Here's a screenshot of the data returned:</p> <p><a href="https://i.stack.imgur.com/BY1Uk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BY1Uk.png" alt="enter image description here"></a></p> <p>Here's my foreach loop that grabs the element I want (name):</p> <pre><code>foreach ($string[0]['trends'] as $trend) { echo $trend['name']."&lt;br /&gt;"; } </code></pre> <p>How do I print only the first 5 elements ([name])?</p>
0debug
def remove_Occ(s,ch): for i in range(len(s)): if (s[i] == ch): s = s[0 : i] + s[i + 1:] break for i in range(len(s) - 1,-1,-1): if (s[i] == ch): s = s[0 : i] + s[i + 1:] break return s
0debug
I am creating unity game in C#. i am struggling a liitle bit to add a script that moves the object of the game from side to side : i am struggling a little bit to add a script that moves the object of the game from side to side I want to create a function to move the object of the game from left to right and to avoid collision of other objects public AudioManager2 audiomanager; public GameManager gamemanager; private float xposition; public GameObject character; public Sprite[] characters; public bool teleporting=false; private int n; void Start(){ ZPlayerPrefs.Initialize("group123", "happyapplications2016"); teleporting = false; n = ZPlayerPrefs.GetInt ("CHARACTER"); Debug.Log (n.ToString ()); character.GetComponent<SpriteRenderer>().sprite = characters [n]; } void OnTriggerEnter2D(Collider2D other) { //On circle touching the car, it will play scoreUp audio & send message to gamecontroller to add score . if(other.gameObject.tag == "Point"){ Destroy(other.gameObject); audiomanager.PlayPoint (); ScoreManager.Score++; } //On cube touching the car, it will send message to gamecontroller to end the game. if(other.gameObject.tag == "Obstacle"){ Destroy(other.gameObject); audiomanager.PlayGameOver (); ScoreManager.lives--; this.gameObject.SetActive (false); } if(other.gameObject.tag == "Gear"){ Destroy(other.gameObject); audiomanager.PlayPoint (); ScoreManager.gearsno++; } //If touches the floor, reposition it to top if(other.gameObject.tag == "Floor"){ this.gameObject.transform.position=new Vector3(this.transform.position.x,5.3f,0); } //Teleportation to left if (other.gameObject.tag == "BridgeLeft") { teleporting = true; xposition = this.GetComponent<Transform> ().position.x; float newpos = xposition - 2.1f; this.GetComponent<Transform> ().transform.DOMoveX (newpos, 1.6f); if (this.gameObject.tag == "Car1") GameController.Car1CurrentPosition = GameController.Car1CurrentPosition - 3; else if(this.gameObject.tag=="Car2") GameController.Car2CurrentPosition = GameController.Car2CurrentPosition - 3; StartCoroutine (ChangeTeleportation (1.6f));
0debug
static void integratorcm_init(int memsz, uint32_t flash_offset) { int iomemtype; integratorcm_state *s; s = (integratorcm_state *)qemu_mallocz(sizeof(integratorcm_state)); s->cm_osc = 0x01000048; s->cm_auxosc = 0x0007feff; s->cm_sdram = 0x00011122; if (memsz >= 256) { integrator_spd[31] = 64; s->cm_sdram |= 0x10; } else if (memsz >= 128) { integrator_spd[31] = 32; s->cm_sdram |= 0x0c; } else if (memsz >= 64) { integrator_spd[31] = 16; s->cm_sdram |= 0x08; } else if (memsz >= 32) { integrator_spd[31] = 4; s->cm_sdram |= 0x04; } else { integrator_spd[31] = 2; } memcpy(integrator_spd + 73, "QEMU-MEMORY", 11); s->cm_init = 0x00000112; s->flash_offset = flash_offset; iomemtype = cpu_register_io_memory(0, integratorcm_readfn, integratorcm_writefn, s); cpu_register_physical_memory(0x10000000, 0x007fffff, iomemtype); integratorcm_do_remap(s, 1); }
1threat
Downloading a file from google cloud storage inside a folder : <p>I've got a python script that gets a list of files that have been uploaded to a google cloud storage bucket, and attempts to retrieve the data as a string.</p> <p>The code is simply: </p> <pre><code>file = open(base_dir + "/" + path, 'wb') data = Blob(path, bucket).download_as_string() file.write(data) </code></pre> <p>My issue is that the data I've uploaded is stored inside folders in the bucket, so the path would be something like:</p> <pre><code>folder/innerfolder/file.jpg </code></pre> <p>When the google library attempts to download the file, it gets it in the form of a GET request, which turns the above path into:</p> <pre><code>https://www.googleapis.com/storage/v1/b/bucket/o/folder%2Finnerfolder%2Ffile.jpg </code></pre> <p>Is there any way to stop this happening / download the file though this way? Cheers.</p>
0debug
Way to break out of an inner For loop in Swift : <p>Is there a simple way to break out of an inner For loop, i.e. a Fro loop within another For loop? Without having to set additional flags for example</p>
0debug
Year Field in Django : <p>I want my users to enter their birth year. I don't want them to type the same in the form rather select the year from available options. I known that I can do something like this in my model if I needed to date instead of year:</p> <pre><code>class MyModel(models.Model): birthday = models.DateField(null=True, blank=True) </code></pre> <p>I can do this in forms to let the user choose date from datepicker.</p> <pre><code> birthday = forms.fields.DateField(widget=forms.widgets.DateInput(attrs={'type': 'date'})) </code></pre> <p>For year, I can use a <code>CharField/IntegerField</code> with <code>choices</code> similar to what has been done in this <a href="https://stackoverflow.com/a/24656072/8414030">SO</a> answer. </p> <pre><code>import datetime YEAR_CHOICES = [(r,r) for r in range(1984, datetime.date.today().year+1)] year = models.IntegerField(_('year'), choices=YEAR_CHOICES, default=datetime.datetime.now().year) </code></pre> <p>The problem, however, is that change of current year from say, 2018 to 2019, will not change the available options.</p> <p>Can you help or provide hints to achieve what I want to do?</p>
0debug
static void xen_domain_watcher(void) { int qemu_running = 1; int fd[2], i, n, rc; char byte; pipe(fd); if (fork() != 0) return; n = getdtablesize(); for (i = 3; i < n; i++) { if (i == fd[0]) continue; if (i == xen_xc) continue; close(i); } signal(SIGINT, SIG_IGN); signal(SIGTERM, SIG_IGN); while (qemu_running) { rc = read(fd[0], &byte, 1); switch (rc) { case -1: if (errno == EINTR) continue; qemu_log("%s: Huh? read error: %s\n", __FUNCTION__, strerror(errno)); qemu_running = 0; break; case 0: qemu_running = 0; break; default: qemu_log("%s: Huh? data on the watch pipe?\n", __FUNCTION__); break; } } qemu_log("%s: destroy domain %d\n", __FUNCTION__, xen_domid); xc_domain_destroy(xen_xc, xen_domid); _exit(0); }
1threat
static uint32_t bitband_readw(void *opaque, target_phys_addr_t offset) { uint32_t addr; uint16_t mask; uint16_t v; addr = bitband_addr(opaque, offset) & ~1; mask = (1 << ((offset >> 2) & 15)); mask = tswap16(mask); cpu_physical_memory_read(addr, (uint8_t *)&v, 2); return (v & mask) != 0; }
1threat
android studio admob banner doesn't work : <p>I am working on simple android app that contain Admob banner, but when I run the app I get this message:</p> <pre><code>unfortunately the app has stopped </code></pre> <p>here is my code:</p> <p>xml layout: </p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context="com.ajater.mj.vaccalc.MainActivity" xmlns:ads="http://schemas.android.com/apk/libs/com.google.ads"&gt; &lt;com.google.ads.AdView xmlns:ads="http://schemas.android.com/apk/libs/com.google.ads" android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:loadAdOnCreate="true" ads:adSize="BANNER" ads:adUnitId="------------------" /&gt; &lt;/android.support.design.widget.CoordinatorLayout&gt; </code></pre> <p>mainactivity</p> <pre><code> AdView adView = (AdView)findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); adView.loadAd(adRequest); </code></pre> <p>AndroidManifest</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my.app.name"&gt; &lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt; </code></pre>
0debug
Is this a violation of strict aliasing rules? : <p>According to the standard — <em>an aggregate or union type that includes one of the aforementioned types among its elements or nonstatic data members (including, recursively, an element or non-static data member of a subaggregate or contained union)</em>, this is allowed:</p> <pre class="lang-cpp prettyprint-override"><code>struct foo { float x; }; void bar(foo*); float values[9]; bar(reinterpret_cast&lt;foo*&gt;(&amp;values)); </code></pre> <p>However, I am not sure whether the following example also honors this rule:</p> <pre class="lang-cpp prettyprint-override"><code>struct foo { float x; float y; float z; }; void bar(foo*); float values[9]; assert((sizeof(values) / sizeof(float)) % 3 == 0); // sanity check bar(reinterpret_cast&lt;foo*&gt;(&amp;values)); </code></pre>
0debug
static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque) { BdrvCoGetBlockStatusData *data = opaque; data->ret = bdrv_co_get_block_status_above(data->bs, data->base, data->sector_num, data->nb_sectors, data->pnum); data->done = true; }
1threat
int avpriv_vsnprintf(char *restrict s, size_t n, const char *restrict fmt, va_list ap) { int ret; if (n == 0) return 0; else if (n > INT_MAX) return AVERROR(EINVAL); memset(s, 0, n); ret = vsnprintf(s, n - 1, fmt, ap); if (ret == -1) ret = n; return ret; }
1threat
How to grep all the njmbers in a file : Cat test 1 0 2 Operator 3 Cat test ¦ grep [0-9] >> 1 The test file contains the baove values. When i grep the test file using grep [0-9] it gives only 1 as output.. How to grep all the numbers in the test file
0debug
BottomSheetDialog remains hidden after dismiss by dragging down : <p>I am pretty curious about the behavior of the <code>BottomSheetDialog</code> when it is dismissed : when the user draggs it down to hide it, it will remain hidden, even if <code>bottomSheetDialog#show()</code> is called after. This only happens when it is dragged down, not when the user touches outside or when <code>bottomSheetDialog#dismiss()</code> is called programatically. </p> <p>It is really annoying because I have a pretty big <code>bottomSheetDialog</code> with a recyclerview inside, and I have to create a new one every time I want to show the <code>bottomSheetDialog</code>.</p> <p>So instead of just doing this : </p> <pre><code>if(bottomSheetDialog != null){ bottomSheetDialog.show(); else{ createNewBottomSheetDialog(); } </code></pre> <p>I have to create one every time. </p> <p>Am I missing something or is it the normal behavior ? (Btw I use <code>appcompat-v7:23.2.1</code>)</p>
0debug
comment in bash script processed by slurm : <p>I am using <code>slurm</code> on a cluster to run jobs and submit a script that looks like below with <code>sbatch</code>:</p> <pre><code>#!/usr/bin/env bash #SBATCH -o slurm.sh.out #SBATCH -p defq #SBATCH --mail-type=ALL #SBATCH --mail-user=my.email@something.com echo "hello" </code></pre> <p>Can I somehow comment out a <code>#SBATCH</code> line, e.g. the <code>#SBATCH --mail-user=my.email@something.com</code> in this script? Since the <code>slurm</code> instructions are bash comments themselves I would not know how to achieve this.</p>
0debug
static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask, bool exception) { sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); sPAPREventLogEntry *entry = NULL; if ((event_mask & EVENT_MASK_EPOW) == 0) { return NULL; } QTAILQ_FOREACH(entry, &spapr->pending_events, next) { if (entry->exception != exception) { continue; } if (entry->log_type == RTAS_LOG_TYPE_EPOW || entry->log_type == RTAS_LOG_TYPE_HOTPLUG) { break; } } if (entry) { QTAILQ_REMOVE(&spapr->pending_events, entry, next); } return entry; }
1threat
void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, int unused, int size) { if (is_exec) helper_raise_exception(EXCP_IBE); else helper_raise_exception(EXCP_DBE); }
1threat
How do I call git diff on the same file between 2 different local branches? : <p>Is there a way to check the difference between the working directory in my current branch against the working directory of another branch in a specific file? For example, if I'm working in branch A on file 1, I want to compare the difference with file 1 on branch B.</p>
0debug
operations in methods dont get saved to my variable : This is my first time using stackoverflow. IDK if i am doing it right. So anyways, i am trying to make calculator on Java. I am not sure how to explain my problem. operations in methods dont get saved. when i try to add number, it doesnt apply to last state of it. it applies to first number i gave. can you help me? ``` import java.util.Scanner; public class gelismishesap { public static void toplam(int k) {Scanner a = new Scanner(System.in); System.out.print(k + " + "); for(int i = 0; i<1; i++) { int b = a.nextInt(); k += b; System.out.println(k); } } public static void cikarma(int k) { Scanner a = new Scanner(System.in); System.out.print(k + " - "); for(int i = 0; i<1; i++) { int b = a.nextInt(); k -= b; System.out.println(k); } } public static void carpma(int k) { Scanner a = new Scanner(System.in); System.out.print(k + " x "); for(int i = 0; i<1; i++) { int b = a.nextInt(); k *= b; System.out.println(k); } } public static void bolme(int k) { Scanner a = new Scanner(System.in); System.out.print(k + " / "); for(int i = 0; i<1; i++) { int b = a.nextInt(); k /= b; System.out.println(k); } } public static void main(String[] args) { Scanner a = new Scanner(System.in); System.out.print("Sayı girin: "); int anasayi = a.nextInt(); System.out.println(anasayi); while(true) { String b = a.nextLine(); if(b.equals("q")) { break; } if(b.equals("a")) { toplam(anasayi); } if(b.equals("b")) { cikarma(anasayi); } if(b.equals("c")) { carpma(anasayi); } if(b.equals("d")) { bolme(anasayi); } } } } ```
0debug
Optional property class in typescript : <p>I'm new in typescript and I want to know what is the utility of optional property class in typescript? And what is the difference between:</p> <pre><code>a?: number; a: number | undefined; </code></pre>
0debug
int pci_piix3_xen_ide_unplug(DeviceState *dev) { PCIIDEState *pci_ide; DriveInfo *di; int i; IDEDevice *idedev; pci_ide = PCI_IDE(dev); for (i = 0; i < 4; i++) { di = drive_get_by_index(IF_IDE, i); if (di != NULL && !di->media_cd) { BlockBackend *blk = blk_by_legacy_dinfo(di); DeviceState *ds = blk_get_attached_dev(blk); blk_drain(blk); blk_flush(blk); if (ds) { blk_detach_dev(blk, ds); } pci_ide->bus[di->bus].ifs[di->unit].blk = NULL; if (!(i % 2)) { idedev = pci_ide->bus[di->bus].master; } else { idedev = pci_ide->bus[di->bus].slave; } idedev->conf.blk = NULL; monitor_remove_blk(blk); blk_unref(blk); } } qdev_reset_all(DEVICE(dev)); return 0; }
1threat