problem
stringlengths
26
131k
labels
class label
2 classes
Mockito verify other function gets called with right parameter,when we call some function. : If i have 2 functions. Function1 which calls function2. I need to write test case for them. I am using mockito. Trait. [Just a mimic of the stuff][1] [1]: http://i.stack.imgur.com/PhJeO.png
0debug
AWS - Can't detaching network interfaces - You are not allowed to manage 'ela-attach' attachments : <p>I did the AWS mysfits tutorial and I thought the cleanup would be as simple as deleting the Cloud Formation stack. However, items failed to delete so I am trying to clean them up manually to assist the Cloud Formation stack deletion.</p> <p>I keep getting an error when trying to Detach the network interfaces (I am logged into the root account):</p> <p>Error detaching network interfaces:</p> <blockquote> <pre><code>eni-0047gfhfgh8ab0e: You are not allowed to manage 'ela-attach' attachments. eni-0f4a46hgfha757e: You are not allowed to manage 'ela-attach' attachments. </code></pre> </blockquote> <p>I am unable to delete my VPC without these being deleted.</p> <p>The stack as a whole is failing to delete because of the following: The following resource(s) failed to delete: [InternetGateway, PublicSubnetTwo, VPC, GatewayAttachement, PublicSubnetOne].</p>
0debug
int do_store_msr (CPUPPCState *env, target_ulong value) { int enter_pm; value &= env->msr_mask; if (((value >> MSR_IR) & 1) != msr_ir || ((value >> MSR_DR) & 1) != msr_dr) { tlb_flush(env, 1); env->interrupt_request |= CPU_INTERRUPT_EXITTB; } #if !defined (CONFIG_USER_ONLY) if (unlikely((env->flags & POWERPC_FLAG_TGPR) && ((value >> MSR_TGPR) & 1) != msr_tgpr)) { swap_gpr_tgpr(env); } if (unlikely((value >> MSR_EP) & 1) != msr_ep) { env->excp_prefix = ((value >> MSR_EP) & 1) * 0xFFF00000; } #endif #if defined (TARGET_PPC64) msr_sf = (value >> MSR_SF) & 1; msr_isf = (value >> MSR_ISF) & 1; msr_hv = (value >> MSR_HV) & 1; #endif msr_ucle = (value >> MSR_UCLE) & 1; msr_vr = (value >> MSR_VR) & 1; msr_ap = (value >> MSR_AP) & 1; msr_sa = (value >> MSR_SA) & 1; msr_key = (value >> MSR_KEY) & 1; msr_pow = (value >> MSR_POW) & 1; msr_tgpr = (value >> MSR_TGPR) & 1; msr_ile = (value >> MSR_ILE) & 1; msr_ee = (value >> MSR_EE) & 1; msr_pr = (value >> MSR_PR) & 1; msr_fp = (value >> MSR_FP) & 1; msr_me = (value >> MSR_ME) & 1; msr_fe0 = (value >> MSR_FE0) & 1; msr_se = (value >> MSR_SE) & 1; msr_be = (value >> MSR_BE) & 1; msr_fe1 = (value >> MSR_FE1) & 1; msr_al = (value >> MSR_AL) & 1; msr_ip = (value >> MSR_IP) & 1; msr_ir = (value >> MSR_IR) & 1; msr_dr = (value >> MSR_DR) & 1; msr_pe = (value >> MSR_PE) & 1; msr_px = (value >> MSR_PX) & 1; msr_ri = (value >> MSR_RI) & 1; msr_le = (value >> MSR_LE) & 1; do_compute_hflags(env); enter_pm = 0; switch (env->excp_model) { case POWERPC_EXCP_603: case POWERPC_EXCP_603E: case POWERPC_EXCP_G2: if (msr_pow == 1 && (env->spr[SPR_HID0] & 0x00C00000) != 0) enter_pm = 1; break; case POWERPC_EXCP_604: if (msr_pow == 1) enter_pm = 1; break; case POWERPC_EXCP_7x0: if (msr_pow == 1 && (env->spr[SPR_HID0] & 0x00E00000) != 0) enter_pm = 1; break; default: break; } return enter_pm; }
1threat
Python Data-Scraping Differentiation - millions vs. ones : <p>I'm currently scraping some tables on the internet where numbers are posted in varying numerical formats:</p> <pre><code>Animal - Left in Wild Tigers - 18 Deer - 18m Pigs - 180000 </code></pre> <p>I've managed to strip the m away from the number, but I am wondering if/how I could use a if statement to allow some manipulation to ensure I document the number accurately:</p> <pre><code>if animal.strip("m") == animal.strip("m"): left_in_wild = left_in_wild * 1000000 </code></pre> <p><em>Obviously that code does not work, but it is a rough thought</em> of how I'm thinking about getting around this. If anyone can has anything they think can be helpful let me know.</p> <p>Thank you!</p>
0debug
int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags) { BlockDriverState *bs; int ret; bs = bdrv_new(""); if (!bs) return -ENOMEM; ret = bdrv_open2(bs, filename, flags | BDRV_O_FILE, NULL); if (ret < 0) { bdrv_delete(bs); return ret; } bs->growable = 1; *pbs = bs; return 0; }
1threat
static void decode_vui(HEVCContext *s, HEVCSPS *sps) { VUI *vui = &sps->vui; GetBitContext *gb = &s->HEVClc->gb; GetBitContext backup; int sar_present, alt = 0; av_log(s->avctx, AV_LOG_DEBUG, "Decoding VUI\n"); sar_present = get_bits1(gb); if (sar_present) { uint8_t sar_idx = get_bits(gb, 8); if (sar_idx < FF_ARRAY_ELEMS(vui_sar)) vui->sar = vui_sar[sar_idx]; else if (sar_idx == 255) { vui->sar.num = get_bits(gb, 16); vui->sar.den = get_bits(gb, 16); } else av_log(s->avctx, AV_LOG_WARNING, "Unknown SAR index: %u.\n", sar_idx); } vui->overscan_info_present_flag = get_bits1(gb); if (vui->overscan_info_present_flag) vui->overscan_appropriate_flag = get_bits1(gb); vui->video_signal_type_present_flag = get_bits1(gb); if (vui->video_signal_type_present_flag) { vui->video_format = get_bits(gb, 3); vui->video_full_range_flag = get_bits1(gb); vui->colour_description_present_flag = get_bits1(gb); if (vui->video_full_range_flag && sps->pix_fmt == AV_PIX_FMT_YUV420P) sps->pix_fmt = AV_PIX_FMT_YUVJ420P; if (vui->colour_description_present_flag) { vui->colour_primaries = get_bits(gb, 8); vui->transfer_characteristic = get_bits(gb, 8); vui->matrix_coeffs = get_bits(gb, 8); if (vui->colour_primaries >= AVCOL_PRI_NB) vui->colour_primaries = AVCOL_PRI_UNSPECIFIED; if (vui->transfer_characteristic >= AVCOL_TRC_NB) vui->transfer_characteristic = AVCOL_TRC_UNSPECIFIED; if (vui->matrix_coeffs >= AVCOL_SPC_NB) vui->matrix_coeffs = AVCOL_SPC_UNSPECIFIED; } } vui->chroma_loc_info_present_flag = get_bits1(gb); if (vui->chroma_loc_info_present_flag) { vui->chroma_sample_loc_type_top_field = get_ue_golomb_long(gb); vui->chroma_sample_loc_type_bottom_field = get_ue_golomb_long(gb); } vui->neutra_chroma_indication_flag = get_bits1(gb); vui->field_seq_flag = get_bits1(gb); vui->frame_field_info_present_flag = get_bits1(gb); vui->default_display_window_flag = get_bits1(gb); if( get_bits_left(gb) >= 66) memcpy(&backup, gb, sizeof(backup)); if (vui->default_display_window_flag) { vui->def_disp_win.left_offset = get_ue_golomb_long(gb) * 2; vui->def_disp_win.right_offset = get_ue_golomb_long(gb) * 2; vui->def_disp_win.top_offset = get_ue_golomb_long(gb) * 2; vui->def_disp_win.bottom_offset = get_ue_golomb_long(gb) * 2; if (s->apply_defdispwin && s->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) { av_log(s->avctx, AV_LOG_DEBUG, "discarding vui default display window, " "original values are l:%u r:%u t:%u b:%u\n", vui->def_disp_win.left_offset, vui->def_disp_win.right_offset, vui->def_disp_win.top_offset, vui->def_disp_win.bottom_offset); vui->def_disp_win.left_offset = vui->def_disp_win.right_offset = vui->def_disp_win.top_offset = vui->def_disp_win.bottom_offset = 0; } } vui->vui_timing_info_present_flag = get_bits1(gb); if (vui->vui_timing_info_present_flag) { if( get_bits_left(gb) < 66) { av_log(s->avctx, AV_LOG_WARNING, "Strange VUI timing information, retrying...\n"); vui->default_display_window_flag = 0; memset(&vui->def_disp_win, 0, sizeof(vui->def_disp_win)); memcpy(gb, &backup, sizeof(backup)); alt = 1; } vui->vui_num_units_in_tick = get_bits_long(gb, 32); vui->vui_time_scale = get_bits_long(gb, 32); if (alt) { av_log(s->avctx, AV_LOG_INFO, "Retry got %i/%i fps\n", vui->vui_time_scale, vui->vui_num_units_in_tick); } vui->vui_poc_proportional_to_timing_flag = get_bits1(gb); if (vui->vui_poc_proportional_to_timing_flag) vui->vui_num_ticks_poc_diff_one_minus1 = get_ue_golomb_long(gb); vui->vui_hrd_parameters_present_flag = get_bits1(gb); if (vui->vui_hrd_parameters_present_flag) decode_hrd(s, 1, sps->max_sub_layers); } vui->bitstream_restriction_flag = get_bits1(gb); if (vui->bitstream_restriction_flag) { vui->tiles_fixed_structure_flag = get_bits1(gb); vui->motion_vectors_over_pic_boundaries_flag = get_bits1(gb); vui->restricted_ref_pic_lists_flag = get_bits1(gb); vui->min_spatial_segmentation_idc = get_ue_golomb_long(gb); vui->max_bytes_per_pic_denom = get_ue_golomb_long(gb); vui->max_bits_per_min_cu_denom = get_ue_golomb_long(gb); vui->log2_max_mv_length_horizontal = get_ue_golomb_long(gb); vui->log2_max_mv_length_vertical = get_ue_golomb_long(gb); } }
1threat
How to define a float array in C : I am working a debian 7, using gcc. I initialize a test vector as follows: float test_vec[] = {4.31,3.33,1.58,0.75,7.82,1.85,0.45,0.11,0.98,3.45}; The sizeof() function applied to this vector returns 40. I use a for() to printf each element and most of them are zero or very large positive/negative numbers. How I should define the test_vector in order to get the right size?
0debug
document.getElementById('input').innerHTML = user_input;
1threat
Choose IP when sending mail in php : <p>My server has 2 IPs.</p> <p>Whenever I send an email in php using <code>mail()</code> the IP used to send the email is IP A. However, I'd like to use IP B.</p> <p>Is this possible?</p> <p>If yes, is this possible using <code>mail()</code> ?</p> <p>If yes, how?</p>
0debug
Logging stdout with python3 and uWSGI : <p>I have a python 2 flask app running behind uWSGI, which is managed by supervisord. Logs are being written to sys.stdout by the flask app. These logs are then picked up by uWSGI and written to file by supervisord. uWSGI logs are written to /dev/stderr. See the supervisord conf below.</p> <pre><code>[program:uwsgi] command = uwsgi --ini /etc/uwsgi.conf --master directory = /app autostart = true autorestart = true stdout_logfile = /var/log/myapplication/application.log stdout_logfile_maxbytes = 50000000 stdout_logfile_backups = 3 stderr_logfile = /dev/stderr stderr_logfile_maxbytes = 0 stopsignal = INT </code></pre> <p>This works great! I have nicely separated application logs and uWSGI logs.</p> <p>I've now upgraded to python 3. This has all gone fine, except the application logs are now ending up in uWSGI's stderr, mixed in with the uWSGI logs.</p> <p>I've trawled the uWSGI docks, and have not been able to find a reason for this change between python 2 and python 3.</p> <p>I've tried redirecting when defining the socket, like is suggested here <a href="http://lists.unbit.it/pipermail/uwsgi/2016-February/008383.html" rel="noreferrer">http://lists.unbit.it/pipermail/uwsgi/2016-February/008383.html</a> but that just redirects everything (application and uWSGI logs) to <code>/dev/null</code>.</p> <p>I also found this <a href="http://lists.unbit.it/pipermail/uwsgi/2016-January/008353.html" rel="noreferrer">http://lists.unbit.it/pipermail/uwsgi/2016-January/008353.html</a> but could't find anything about pyimport-shared.</p> <p>Does anyone know what might be going on?</p> <p>My uWSGI conf is here if it help.</p> <pre><code>[uwsgi] uid = www-data gid = www-data module = application:application socket = /run/uwsgi.sock single-interpreter = true enable-threads = true buffer-size = 16384 processes = 4 </code></pre> <p>Thanks</p>
0debug
static int decode_group3_2d_line(AVCodecContext *avctx, GetBitContext *gb, int width, int *runs, const int *runend, const int *ref) { int mode = 0, offs = 0, run = 0, saved_run = 0, t; int run_off = *ref++; int *run_start = runs; runend--; while(offs < width){ int cmode = get_vlc2(gb, ccitt_group3_2d_vlc.table, 9, 1); if(cmode == -1){ av_log(avctx, AV_LOG_ERROR, "Incorrect mode VLC\n"); return -1; } if(runs != run_start)while(run_off <= offs){ run_off += *ref++; run_off += *ref++; } if(!cmode){ run_off += *ref++; run = run_off - offs; run_off += *ref++; offs += run; if(offs > width){ av_log(avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return -1; } saved_run += run; }else if(cmode == 1){ int k; for(k = 0; k < 2; k++){ run = 0; for(;;){ t = get_vlc2(gb, ccitt_vlc[mode].table, 9, 2); if(t == -1){ av_log(avctx, AV_LOG_ERROR, "Incorrect code\n"); return -1; } run += t; if(t < 64) break; } *runs++ = run + saved_run; if(runs >= runend){ av_log(avctx, AV_LOG_ERROR, "Run overrun\n"); return -1; } saved_run = 0; offs += run; if(offs > width){ av_log(avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return -1; } mode = !mode; } }else if(cmode == 9 || cmode == 10){ av_log(avctx, AV_LOG_ERROR, "Special modes are not supported (yet)\n"); return -1; }else{ run = run_off - offs + (cmode - 5); if(cmode >= 5) run_off += *ref++; else run_off -= *--ref; offs += run; if(offs > width){ av_log(avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return -1; } *runs++ = run + saved_run; if(runs >= runend){ av_log(avctx, AV_LOG_ERROR, "Run overrun\n"); return -1; } saved_run = 0; mode = !mode; } } *runs++ = saved_run; *runs++ = 0; return 0; }
1threat
static void init_blk_migration_it(void *opaque, BlockDriverState *bs) { Monitor *mon = opaque; BlkMigDevState *bmds; int64_t sectors; if (!bdrv_is_read_only(bs)) { sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; if (sectors <= 0) { return; } bmds = g_malloc0(sizeof(BlkMigDevState)); bmds->bs = bs; bmds->bulk_completed = 0; bmds->total_sectors = sectors; bmds->completed_sectors = 0; bmds->shared_base = block_mig_state.shared_base; alloc_aio_bitmap(bmds); drive_get_ref(drive_get_by_blockdev(bs)); bdrv_set_in_use(bs, 1); block_mig_state.total_sector_sum += sectors; if (bmds->shared_base) { monitor_printf(mon, "Start migration for %s with shared base " "image\n", bs->device_name); } else { monitor_printf(mon, "Start full migration for %s\n", bs->device_name); } QSIMPLEQ_INSERT_TAIL(&block_mig_state.bmds_list, bmds, entry); } }
1threat
In Regular expression on linux, * refer to : <p>I'am having a doubt about * in linux system. In Regular expression on linux, “*” refer to </p> <p>I have options to it: A)It matches the previous element zero or one time. B)It matches the previous element one or more times C)It matches the previous element zero or more times D)It matches the previous element more than once.</p>
0debug
Run a link 100 times using Perl : The problem I met is that I need to run one link (I cannot be specific that link exactly, this link is doing request and looks like http://link.com/?name=name&password=password& and etc) And I need to run this link 100 times in a row. I can not do this manually using browser - this tooks much time. Is there any option to run (just run, like you put link in browser and press enter) this link 100 times in a row using Perl scripting? I have not met before with the Perl and therefore asking the help directly. As I google before some information and make a little script, but seems like I missing something in my knowledge: #!/usr/bin/perl -w use LWP::Simple; my $uri = 'http://my link here'; my $content = get $uri; Could you please advice to me how I can finish this script?
0debug
static int rtp_new_av_stream(HTTPContext *c, int stream_index, struct sockaddr_in *dest_addr, HTTPContext *rtsp_c) { AVFormatContext *ctx; AVStream *st; char *ipaddr; URLContext *h = NULL; uint8_t *dummy_buf; int max_packet_size; ctx = avformat_alloc_context(); if (!ctx) return -1; ctx->oformat = av_guess_format("rtp", NULL, NULL); st = av_mallocz(sizeof(AVStream)); if (!st) goto fail; ctx->nb_streams = 1; ctx->streams[0] = st; if (!c->stream->feed || c->stream->feed == c->stream) memcpy(st, c->stream->streams[stream_index], sizeof(AVStream)); else memcpy(st, c->stream->feed->streams[c->stream->feed_streams[stream_index]], sizeof(AVStream)); st->priv_data = NULL; ipaddr = inet_ntoa(dest_addr->sin_addr); switch(c->rtp_protocol) { case RTSP_LOWER_TRANSPORT_UDP: case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: if (c->stream->is_multicast) { int ttl; ttl = c->stream->multicast_ttl; if (!ttl) ttl = 16; snprintf(ctx->filename, sizeof(ctx->filename), "rtp: ipaddr, ntohs(dest_addr->sin_port), ttl); } else { snprintf(ctx->filename, sizeof(ctx->filename), "rtp: } if (url_open(&h, ctx->filename, URL_WRONLY) < 0) goto fail; c->rtp_handles[stream_index] = h; max_packet_size = url_get_max_packet_size(h); break; case RTSP_LOWER_TRANSPORT_TCP: c->rtsp_c = rtsp_c; max_packet_size = RTSP_TCP_MAX_PACKET_SIZE; break; default: goto fail; } http_log("%s:%d - - \"PLAY %s/streamid=%d %s\"\n", ipaddr, ntohs(dest_addr->sin_port), c->stream->filename, stream_index, c->protocol); if (url_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) { goto fail; } av_set_parameters(ctx, NULL); if (av_write_header(ctx) < 0) { fail: if (h) url_close(h); av_free(ctx); return -1; } avio_close_dyn_buf(ctx->pb, &dummy_buf); av_free(dummy_buf); c->rtp_ctx[stream_index] = ctx; return 0; }
1threat
static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf, Error **errp) { struct glfs *glfs; int ret; int old_errno; GlusterServerList *server; glfs = glfs_new(gconf->volume); if (!glfs) { goto out; } for (server = gconf->server; server; server = server->next) { if (server->value->type == GLUSTER_TRANSPORT_UNIX) { ret = glfs_set_volfile_server(glfs, GlusterTransport_lookup[server->value->type], server->value->u.q_unix.path, 0); } else { ret = glfs_set_volfile_server(glfs, GlusterTransport_lookup[server->value->type], server->value->u.tcp.host, atoi(server->value->u.tcp.port)); } if (ret < 0) { goto out; } } ret = glfs_set_logging(glfs, "-", gconf->debug_level); if (ret < 0) { goto out; } ret = glfs_init(glfs); if (ret) { error_setg(errp, "Gluster connection for volume %s, path %s failed" " to connect", gconf->volume, gconf->path); for (server = gconf->server; server; server = server->next) { if (server->value->type == GLUSTER_TRANSPORT_UNIX) { error_append_hint(errp, "hint: failed on socket %s ", server->value->u.q_unix.path); } else { error_append_hint(errp, "hint: failed on host %s and port %s ", server->value->u.tcp.host, server->value->u.tcp.port); } } error_append_hint(errp, "Please refer to gluster logs for more info\n"); if (errno == 0) { errno = EINVAL; } goto out; } return glfs; out: if (glfs) { old_errno = errno; glfs_fini(glfs); errno = old_errno; } return NULL; }
1threat
static int vp9_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, const uint8_t *data, int size) { VP9Context *s = avctx->priv_data; int ret, tile_row, tile_col, i, ref = -1, row, col; ptrdiff_t yoff = 0, uvoff = 0; ret = decode_frame_header(avctx, data, size, &ref); if (ret < 0) { return ret; } else if (!ret) { if (!s->refs[ref]->buf[0]) { av_log(avctx, AV_LOG_ERROR, "Requested reference %d not available\n", ref); return AVERROR_INVALIDDATA; } ret = av_frame_ref(frame, s->refs[ref]); if (ret < 0) return ret; *got_frame = 1; return 0; } data += ret; size -= ret; s->cur_frame = frame; av_frame_unref(s->cur_frame); if ((ret = ff_get_buffer(avctx, s->cur_frame, s->refreshrefmask ? AV_GET_BUFFER_FLAG_REF : 0)) < 0) return ret; s->cur_frame->key_frame = s->keyframe; s->cur_frame->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; memset(s->above_partition_ctx, 0, s->cols); memset(s->above_skip_ctx, 0, s->cols); if (s->keyframe || s->intraonly) memset(s->above_mode_ctx, DC_PRED, s->cols * 2); else memset(s->above_mode_ctx, NEARESTMV, s->cols); memset(s->above_y_nnz_ctx, 0, s->sb_cols * 16); memset(s->above_uv_nnz_ctx[0], 0, s->sb_cols * 8); memset(s->above_uv_nnz_ctx[1], 0, s->sb_cols * 8); memset(s->above_segpred_ctx, 0, s->cols); for (tile_row = 0; tile_row < s->tiling.tile_rows; tile_row++) { set_tile_offset(&s->tiling.tile_row_start, &s->tiling.tile_row_end, tile_row, s->tiling.log2_tile_rows, s->sb_rows); for (tile_col = 0; tile_col < s->tiling.tile_cols; tile_col++) { int64_t tile_size; if (tile_col == s->tiling.tile_cols - 1 && tile_row == s->tiling.tile_rows - 1) { tile_size = size; } else { tile_size = AV_RB32(data); data += 4; size -= 4; } if (tile_size > size) return AVERROR_INVALIDDATA; ff_vp56_init_range_decoder(&s->c_b[tile_col], data, tile_size); if (vp56_rac_get_prob_branchy(&s->c_b[tile_col], 128)) return AVERROR_INVALIDDATA; data += tile_size; size -= tile_size; } for (row = s->tiling.tile_row_start; row < s->tiling.tile_row_end; row += 8, yoff += s->cur_frame->linesize[0] * 64, uvoff += s->cur_frame->linesize[1] * 32) { VP9Filter *lflvl = s->lflvl; ptrdiff_t yoff2 = yoff, uvoff2 = uvoff; for (tile_col = 0; tile_col < s->tiling.tile_cols; tile_col++) { set_tile_offset(&s->tiling.tile_col_start, &s->tiling.tile_col_end, tile_col, s->tiling.log2_tile_cols, s->sb_cols); memset(s->left_partition_ctx, 0, 8); memset(s->left_skip_ctx, 0, 8); if (s->keyframe || s->intraonly) memset(s->left_mode_ctx, DC_PRED, 16); else memset(s->left_mode_ctx, NEARESTMV, 8); memset(s->left_y_nnz_ctx, 0, 16); memset(s->left_uv_nnz_ctx, 0, 16); memset(s->left_segpred_ctx, 0, 8); memcpy(&s->c, &s->c_b[tile_col], sizeof(s->c)); for (col = s->tiling.tile_col_start; col < s->tiling.tile_col_end; col += 8, yoff2 += 64, uvoff2 += 32, lflvl++) { memset(lflvl->mask, 0, sizeof(lflvl->mask)); if ((ret = decode_subblock(avctx, row, col, lflvl, yoff2, uvoff2, BL_64X64)) < 0) return ret; } memcpy(&s->c_b[tile_col], &s->c, sizeof(s->c)); } if (row + 8 < s->rows) { memcpy(s->intra_pred_data[0], s->cur_frame->data[0] + yoff + 63 * s->cur_frame->linesize[0], 8 * s->cols); memcpy(s->intra_pred_data[1], s->cur_frame->data[1] + uvoff + 31 * s->cur_frame->linesize[1], 4 * s->cols); memcpy(s->intra_pred_data[2], s->cur_frame->data[2] + uvoff + 31 * s->cur_frame->linesize[2], 4 * s->cols); } if (s->filter.level) { yoff2 = yoff; uvoff2 = uvoff; lflvl = s->lflvl; for (col = 0; col < s->cols; col += 8, yoff2 += 64, uvoff2 += 32, lflvl++) loopfilter_subblock(avctx, lflvl, row, col, yoff2, uvoff2); } } } if (s->refreshctx) { if (s->parallelmode) { memcpy(s->prob_ctx[s->framectxid].coef, s->prob.coef, sizeof(s->prob.coef)); s->prob_ctx[s->framectxid].p = s->prob.p; } else { ff_vp9_adapt_probs(s); } } FFSWAP(VP9MVRefPair *, s->mv[0], s->mv[1]); for (i = 0; i < 8; i++) if (s->refreshrefmask & (1 << i)) { av_frame_unref(s->refs[i]); ret = av_frame_ref(s->refs[i], s->cur_frame); if (ret < 0) return ret; } if (s->invisible) av_frame_unref(s->cur_frame); else *got_frame = 1; return 0; }
1threat
Computer Vision - Image Fundamentals : <p>I have recently got hooked up on <code>Deep Learning in Computer Vision</code> and i was wondering if any of you could recommend some resources on Image Fundamentals so i understand how Images work and <code>Image Preprocessing</code>. Also if you guys have any good resources on <code>Deep Learning in Computer Vision</code> that would be great too. Thank you in advance!</p>
0debug
get all substring between two repeated string in python : <p>I have the following :</p> <pre><code>-----BEGIN CERTIFICATE----- MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCBMIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCBMIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- AgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCBMIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB -----END CERTIFICATE----- </code></pre> <p>I want to get all three string between -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- and then store them in variables in python. How do I do that in python ?</p>
0debug
static void disable_logging(void) { ga_disable_logging(ga_state); }
1threat
The code,following the line " new ClassReader(classfileBuffer)" is unreachable : I want to add monitor code into some class,so i use the java agent and asm4 to manipulate the byte code. The core code as followed: public class MyClassFileTransformer implements ClassFileTransformer { @Override public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { if (className.startsWith("com/dgl/asm/SleepClass")) { ClassReader reader = new ClassReader(classfileBuffer); System.out.println("1231231231312"); ClassWriter cw = new ClassWriter(reader,0); ClassVisitor adpter = new AddTimerClassAdpter(Opcodes.ASM4, cw); reader.accept(adpter, 0); return cw.toByteArray(); } return classfileBuffer; } } However,the code ,after "ClassReader reader = new ClassReader(classfileBuffer)",is always unreachable.After the "new ClassReader(classfileBuffer)" be executed,the program jumps to the main method directly without any exception! what should I do? Any idea?
0debug
Show user-friendly error page instead of exception in Flutter : <p>Is it possible to make <strong>global error handling</strong> that will <strong>show user-friendly error page instead of showing red exception</strong>?</p> <p>I already made error handling (<a href="https://flutter.io/docs/cookbook/maintenance/error-reporting" rel="noreferrer">here</a>) that will report exception to the backend but what I really would like to achieve is to hide red exception and show something a little bit frendlier.</p> <p>I searched everywhere and I found literally nothing. I'm sorry that I don't have any code to show because I have no idea how to start.</p>
0debug
i am not able to run creating custom arrayadaptor : i have to use this coed to get three strings and one integer to create text view in list view using custom array adaptor and customclass // Word.java for data structure package com.shyam.android.tamillanguagelearningapp; /** * Created by MANI on 12/8/2016. */ // it caontains two tralatio words as // declaration of the class public class Word { /** english translation*/ // state of word class private String mEnglishTranslation; /** tamil translation*/ private String mTamilTranslation; /** tamil number*/ private String mTamilNumber; /** english number*/ private int mEnglishNumber; // constrauctor to tke two words public Word(String englishTranslation,String tamilTranslation ,String tamilNumber,int englishNumber){ mEnglishTranslation = englishTranslation; mTamilTranslation = tamilTranslation; mTamilNumber = tamilNumber; mEnglishNumber = englishNumber; } // methods of the class public String getmEnglishTranslation(){ return mEnglishTranslation; } public String getmTamilTranslation(){ return mTamilTranslation; } public String getmTamilNumber(){ return mTamilNumber; } public int getmEnglishNumber(){ return mEnglishNumber; } } end**** //custome array adaptor file package com.shyam.android.tamillanguagelearningapp; import android.app.Activity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; import java.util.ArrayList; /** * Created by MANI on 12/8/2016. */ public class WordAdapter extends ArrayAdapter<Word> { /** * This is our own custom constructor (it doesn't mirror a superclass constructor). * The context is used to inflate the layout file, and the list is the data we want * to populate into the lists. * //* @param context The current context. Used to inflate the layout file. //* @param words A List of AndroidFlavor objects to display in a list */ public WordAdapter(Activity context, ArrayList<Word> words) { // Here, we initialize the ArrayAdapter's internal storage for the context and the list. // the second argument is used when the ArrayAdapter is populating a single TextView. // Because this is a custom adapter for two TextViews and an ImageView, the adapter is not // going to use this second argument, so it can be any value. Here, we used 0. super(context, 0, words); } @Override public View getView(int position, View convertView, ViewGroup parent) { // Check if the existing view is being reused, otherwise inflate the view View listItemView = convertView; if(listItemView == null) { listItemView = LayoutInflater.from(getContext()).inflate( R.layout.list_item, parent, false); } // Get the {@link AndroidFlavor} object located at this position in the list Word currentWord = getItem(position); // Find the TextView in the list_item.xml layout with the ID version_name TextView tamilTextView = (TextView) listItemView.findViewById(R.id.tamil_text_view); // Get the version name from the current AndroidFlavor object and // set this text on the name TextView tamilTextView.setText(currentWord.getmTamilTranslation()); // Find the TextView in the list_item.xml layout with the ID version_number TextView englsihTextView = (TextView) listItemView.findViewById(R.id.english_text_view); // Get the version number from the current AndroidFlavor object and // set this text on the number TextView englsihTextView.setText(currentWord.getmEnglishTranslation()); // Find the TextView in the list_item.xml layout with the ID version_number TextView tamilNumber = (TextView) listItemView.findViewById(R.id.tamil_number_text_view); // Get the version number from the current AndroidFlavor object and // set this text on the number TextView tamilNumber.setText(currentWord.getmTamilNumber()); // Find the TextView in the list_item.xml layout with the ID version_number TextView englishNumber = (TextView) listItemView.findViewById(R.id.english_number_text_view); // Get the version number from the current AndroidFlavor object and // set this text on the number TextView englishNumber.setText(currentWord.getmEnglishNumber()); // Find the ImageView in the list_item.xml layout with the ID list_item_icon // ImageView iconView = (ImageView) listItemView.findViewById(R.id.list_item_icon); // Get the image resource ID from the current AndroidFlavor object and // set the image to iconView // iconView.setImageResource(currentAndroidFlavor.getImageResourceId()); // Return the whole list item layout (containing 2 TextViews and an ImageView) // so that it can be shown in the ListView return listItemView; } } ** end of file /// activity file package com.shyam.android.tamillanguagelearningapp; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.ListView; import java.util.ArrayList; public class NumbersActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.word_list); // createing string array to store words //String[] words = new String[10]; // storing data // words[0 ]= "One"; // words[1]= "Two"; // words[2]= "Three"; // words[3]= "Four"; // words[4]= "Five"; // words[5]= "Six"; // words[6]= "Seven"; // words[7]= "Eight"; // words[8]= "Nine"; // words[9]= "Ten"; // Log.v("NumbersActivity","the number in place of words 0 is = " + words[0]); //Log.v("NumbersActivity","the number in place of words 1 is = " + words[1]); // create an arrary list ArrayList<Word> words = new ArrayList<Word>(); // add data to array lsit // words.add("One"); words.add(new Word("Zero","சுழியம்","௦",0)); words.add(new Word("One","ஒன்று","௧",1)); words.add(new Word("Two","இரண்டு","௨",2)); words.add(new Word("Three","மூன்று","௩",3)); words.add(new Word("Four","நான்கு","௪",4)); words.add(new Word("Five","ஐந்து","௫",5)); words.add(new Word("Six","ஆறு","௬",6)); words.add(new Word("Seven","ஏழு","௭",7)); words.add(new Word("Eight","எட்டு","௮",8)); words.add(new Word("Nine","ஒன்பது","௯",9)); words.add(new Word("Ten","பத்து","௰",10)); //words.add("Two"); // words.add("Three"); //words.add("Four"); //words.add("Five"); // words.add("Six"); // words.add("Seven"); // words.add("Eight"); // words.add("Nine"); // words.add("Ten"); // Log.v("NumbersActivity"," The number in place of words 0 is = " + words.get(0)); // Log.v("NumbersActivity"," The number in place of words 6 is = " + words.get(5)); //Log.v("NumbersActivity"," The number in place of words 10 is = " + words.get(9)); // /creating thre view child and add data and displaing it and adding to the paretn // LinearLayout rootView = (LinearLayout)findViewById(R.id.rootView); //TextView wordview = new TextView(this); //wordview.setText(words.get(0)); // rootView.addView(wordview); //using loops to do the above code // int index = 0; // while (index<words.size()){ // create anew lik text view that display the wordview //and the view as a child to the rootview // TextView wordview = new TextView(this); //wordview.setText(words.get(index)); // rootView.addView(wordview); //update the counter variable // index = index + 1; // using for loop to do the above code //for(int index = 0 ; index < words.size(); index ++){ // create the text view //TextView wordview = new TextView(this); //set the text to be word at the current index // wordview.setText(words.get(index)); // add theis textview as another child tothe root view of this layout //rootView.addView(wordview); //} WordAdapter adapter = new WordAdapter(this,words); ListView listView =(ListView) findViewById(R.id.list); listView.setAdapter(adapter); }
0debug
Value that occurs consecutively most no of times in array : The following code is in java lang:<br> int[] array = {1,2,2,3,3,3,2,2,1}; int k = 2; What i need to do is find the value (in this case 3), that occurs consecutively more than k times. There can be only one value that occurs>k and if no such value exists, print -1. Explanation: <br>1 occurs only 1 time consecutively. <br>2 occurs 2 times but its not>k.<br> 3 occurs 3 times, which is>k. Since, there can be only one possible answer, you can stop searching for answer in further values and print 3.<br> The time limit for code is 0.25s
0debug
Tic Tak Toe game logic using Artificial Intelligence using JAVA : <p>I want to develop a logic for tic-tak-toe game using JAVA language(Standalone program only, no UI). Concept is, game will play between human and machine(Artificial Intelligence). can you please guide me.</p> <p>Thanks in advance :)</p> <p>Regards, Subaan</p>
0debug
bool has_help_option(const char *param) { size_t buflen = strlen(param) + 1; char *buf = g_malloc(buflen); const char *p = param; bool result = false; while (*p) { p = get_opt_value(buf, buflen, p); if (*p) { p++; } if (is_help_option(buf)) { result = true; goto out; } } out: free(buf); return result; }
1threat
Regex strip some content : <p>I have code which contains 3 or more [iframe] shortcode, and I only want to keep one with specific url (specific.com in this example)</p> <pre><code> $content = '[iframe src="https://specific.com/player/embed_player.php?vid=123"][/iframe]&lt;strong&gt;Dailymotion.com&lt;/strong&gt;&lt;br /&gt;[iframe src="//dailymotion.com/embed/video/k4oXSHJdKT8QsBrqBI5?logo=0&amp;amp;info=0&amp;amp;hideInfos=1"][/iframe]&lt;strong&gt;Some Website&lt;/strong&gt;&lt;br /&gt;[iframe src="//site.com/embed/video/123"][/iframe]'; </code></pre> <p>The content data sequence of [iframe] shortcodes can be different, however I want the following output only..</p> <pre><code> [iframe src="https://specific.com/player/embed_player.php?vid=123"][/iframe] </code></pre>
0debug
function that return function itself, causing ld returned 1 exit status, please looking : //enter a unsigned int, reverse it and see if its' still in range, if it is, print the reverse number, if not, print your number is out of range #include<stdio.h> #include<stdlib.h> #include<limits.h> unsigned int reversePrint(unsigned int x); int main(){ unsigned int a = UINT_MAX; printf("int max is %u\n", a); unsigned int x =0; while(scanf("%u",&x) != EOF){ unsigned int y = reversePrint(x); if( y < 0xffffffff ){ printf("%u\n",y); }else{ printf("out of range of unsigned int"); } getchar(); } } unsigned int reversePrint(unsigned int x){ unsigned int j =10; if(x<j) return x; else{ printf("%u", x%j); x = x /j; return reversePrintf( x ); **// something is wrong here by calling function itself } }
0debug
How to Add Changing Variable Element to ArrayList in Java : <p>I have a need create an ArrayList to collect positions of some points.</p> <pre><code>ArrayList&lt;int[]&gt; collection = new ArrayList&lt;int[]&gt; ; //the position has 2 coordinations. int[] location = new int[2] //add first position a,b location[0] = a; location[1] = b; collection.add(location); //add second position c,d location[0] = c; location[1] = d; collection.add(location); </code></pre> <p>When I try to display the collection, all the elements inside are exactly the same as the last one was added (in this case: [c,d])</p> <p>How do I add the element to my ArrayList properly in this case ? Thank you very much</p>
0debug
How to convert a JSON file to CSV in pandas python , where JSON file format is different and getting value error : Hi I have received a JSON file with below format, please let me know how do i parse this JSOn file and convert them to CSV JSON file format {'Sections': [{'MC': [[{'IsMandatory': False, 'LD': None, 'propNameValuepair': [{'PropertyType': 0, 'columnSize': 0, 'isEnabled': False, 'isStructured': False, 'isUpdated': False, 'propDisplayName': 'CC', 'propName': 'u4_c_c', 'propValue': 'Bottle', 'selectedComponent': None, 'tcProperty': None}, {'PropertyType': 0, 'columnSize': 0, 'isEnabled': False, 'isStructured': False, 'isUpdated': False, 'propDisplayName': 'Com Com', 'propName': 'u4_com_com', 'propValue': 'Multi-layer', 'selectedComponent': None, 'tcProperty': None}, Code import json with open('a.json') as data_file: data = json.load(data_file) import pandas as pd df = pd.concat([pd.DataFrame(x) for x in data], ignore_index=False) print(df) Error: ValueError: DataFrame constructor not properly called!
0debug
Equivalent to get_contents_to_file in boto3 : <p>In boto3, is there an equivalent of <a href="http://boto.cloudhackers.com/en/latest/ref/s3.html#boto.s3.key.Key.get_contents_to_file" rel="noreferrer"><code>get_contents_to_file</code></a>, that copies the contents of an object to a file handle?</p> <p>In boto, if I have an S3 object <code>key</code>, I can copy the contents to a temporary file with:</p> <pre><code>from tempfile import TemporaryFile key = code_that_gets_key() with TemporaryFile() as tmp_file: key.get_contents_to_file(key, tmpfile) </code></pre> <p>I haven't found an equivalent in boto3. </p> <p>I have been able to replace usage of <a href="http://boto.cloudhackers.com/en/latest/ref/s3.html#boto.s3.key.Key.get_contents_to_filename" rel="noreferrer"><code>get_contents_to_filename</code></a> with <a href="http://boto3.readthedocs.org/en/latest/reference/services/s3.html?highlight=download_file#S3.Object.download_file" rel="noreferrer"><code>download_file</code></a>. However, that covers the case where I provide the filename. In this case, I want to provide the file handle as the argument.</p> <p>Currently, I can get the code to work in boto3 by iterating over the body as follows:</p> <pre><code>with TemporaryFile() as tmp_file: body = key.get()['Body'] for chunk in iter(lambda: body.read(4096), b''): filehandle.write(chunk) </code></pre> <p>Is there a better way to do this in boto3?</p>
0debug
static inline void RENAME(yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, long width, long height, long lumStride, long chromStride, long srcStride) { long y; const long chromWidth= width>>1; for(y=0; y<height; y+=2) { #ifdef HAVE_MMX asm volatile( "xor %%"REG_a", %%"REG_a" \n\t" "pcmpeqw %%mm7, %%mm7 \n\t" "psrlw $8, %%mm7 \n\t" ASMALIGN(4) "1: \n\t" PREFETCH" 64(%0, %%"REG_a", 4) \n\t" "movq (%0, %%"REG_a", 4), %%mm0 \n\t" "movq 8(%0, %%"REG_a", 4), %%mm1\n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "psrlw $8, %%mm0 \n\t" "psrlw $8, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "pand %%mm7, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm2, (%1, %%"REG_a", 2)\n\t" "movq 16(%0, %%"REG_a", 4), %%mm1\n\t" "movq 24(%0, %%"REG_a", 4), %%mm2\n\t" "movq %%mm1, %%mm3 \n\t" "movq %%mm2, %%mm4 \n\t" "psrlw $8, %%mm1 \n\t" "psrlw $8, %%mm2 \n\t" "pand %%mm7, %%mm3 \n\t" "pand %%mm7, %%mm4 \n\t" "packuswb %%mm2, %%mm1 \n\t" "packuswb %%mm4, %%mm3 \n\t" MOVNTQ" %%mm3, 8(%1, %%"REG_a", 2)\n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "psrlw $8, %%mm0 \n\t" "psrlw $8, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "pand %%mm7, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm0, (%3, %%"REG_a") \n\t" MOVNTQ" %%mm2, (%2, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" "cmp %4, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth) : "memory", "%"REG_a ); ydst += lumStride; src += srcStride; asm volatile( "xor %%"REG_a", %%"REG_a" \n\t" ASMALIGN(4) "1: \n\t" PREFETCH" 64(%0, %%"REG_a", 4) \n\t" "movq (%0, %%"REG_a", 4), %%mm0 \n\t" "movq 8(%0, %%"REG_a", 4), %%mm1\n\t" "movq 16(%0, %%"REG_a", 4), %%mm2\n\t" "movq 24(%0, %%"REG_a", 4), %%mm3\n\t" "pand %%mm7, %%mm0 \n\t" "pand %%mm7, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "pand %%mm7, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm0, (%1, %%"REG_a", 2)\n\t" MOVNTQ" %%mm2, 8(%1, %%"REG_a", 2)\n\t" "add $8, %%"REG_a" \n\t" "cmp %4, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth) : "memory", "%"REG_a ); #else long i; for(i=0; i<chromWidth; i++) { ydst[2*i+0] = src[4*i+0]; udst[i] = src[4*i+1]; ydst[2*i+1] = src[4*i+2]; vdst[i] = src[4*i+3]; } ydst += lumStride; src += srcStride; for(i=0; i<chromWidth; i++) { ydst[2*i+0] = src[4*i+0]; ydst[2*i+1] = src[4*i+2]; } #endif udst += chromStride; vdst += chromStride; ydst += lumStride; src += srcStride; } #ifdef HAVE_MMX asm volatile( EMMS" \n\t" SFENCE" \n\t" :::"memory"); #endif }
1threat
static void add_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels, int line_size) { int i; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; for(i=0;i<2;i++) { pixels[0] = cm[pixels[0] + block[0]]; pixels[1] = cm[pixels[1] + block[1]]; pixels += line_size; block += 8; } }
1threat
Sort Javascript array based on a substring in the array element : <pre><code>var arr = ["This is three", "This is four", "This is one", "This is two", ...]; </code></pre> <p>If I have an array like the one shown above, and I need to sort the array based on the substring value in the strings - i.e one, two, three.., What is the best approach to the problem? </p> <p>My final result should be </p> <pre><code>var sortedArr = ["This is one", "This is two", "This is three", "This is four", ...]; </code></pre>
0debug
How do I make long "IF statement" in python? : So I am trying to make a long if statement where it asks you for a sign up or login, but when I get to the login part there is a syntax error.Any tips? ``` registration = input("Do you have a registration") if registration == "No": name = input("Type your name: ") surname = input("Type your surname: ") userp1 = name[0]+ surname.capitalize() print(userp1) password = input("Enter your password\n") userInput = input("Type your login details\n") if userInput == userp1: userInput = input("Password?\n") if userInput== password: print("Welocome") change = input("Do you want to change your username?") if change == "No": print("You logged in as" , userp1) else: userp1 = input("What would your new username be?") print("You logged in as",userp1) else: print("Login") ```
0debug
Why would one write a C++ lambda with a name so it can be called from somewhere? : <p>Why would one write a C++ lambda with a name so it can be called from somewhere? Would that not defeat the very purpose of a lambda? Is it better to write a function instead there? If not, why? Would a function instead have any disadvantages?</p>
0debug
static int scsi_generic_initfn(SCSIDevice *s) { int rc; int sg_version; struct sg_scsi_id scsiid; if (!s->conf.bs) { error_report("drive property not set"); return -1; } if (bdrv_get_on_error(s->conf.bs, 0) != BLOCKDEV_ON_ERROR_ENOSPC) { error_report("Device doesn't support drive option werror"); return -1; } if (bdrv_get_on_error(s->conf.bs, 1) != BLOCKDEV_ON_ERROR_REPORT) { error_report("Device doesn't support drive option rerror"); return -1; } rc = bdrv_ioctl(s->conf.bs, SG_GET_VERSION_NUM, &sg_version); if (rc < 0) { error_report("cannot get SG_IO version number: %s. " "Is this a SCSI device?", strerror(-rc)); return -1; } if (sg_version < 30000) { error_report("scsi generic interface too old"); return -1; } if (bdrv_ioctl(s->conf.bs, SG_GET_SCSI_ID, &scsiid)) { error_report("SG_GET_SCSI_ID ioctl failed"); return -1; } s->type = scsiid.scsi_type; DPRINTF("device type %d\n", s->type); if (s->type == TYPE_DISK || s->type == TYPE_ROM) { add_boot_device_path(s->conf.bootindex, &s->qdev, NULL); } switch (s->type) { case TYPE_TAPE: s->blocksize = get_stream_blocksize(s->conf.bs); if (s->blocksize == -1) { s->blocksize = 0; } break; case TYPE_ROM: case TYPE_WORM: s->blocksize = 2048; break; default: s->blocksize = 512; break; } DPRINTF("block size %d\n", s->blocksize); return 0; }
1threat
Device File Explorer option missing in Flutter Android Studio : <p>I want to view the database files in my adb device but the option of device file explorer is missing in android studio when flutter project is opened. But the same is visible when i open android module or simply an android project.I want to view the device files in flutter project itself</p>
0debug
Display specific data from sql database : I have a database called 'members' with a table called 'users'. The users table has an 'id' column that auto-increments every time a new user is added. I want to fetch the id of the logged in user and display that singular row of data. This is my login code: <?php session_start(); // Connect to server and select databse. mysql_connect("localhost", "root", "")or die("cannot connect"); mysql_select_db("members")or die("cannot select DB"); // username and password sent from form $prepreemail=$_POST['email']; $prepremypassword=$_POST['mypassword']; $preemail = stripslashes($prepreemail); $premypassword = stripslashes($prepremypassword); $email = mysql_real_escape_string($preemail); $mypassword = mysql_real_escape_string($premypassword); $sql="SELECT * FROM users WHERE email='$email' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" header ("location:home.html"); } else { header ("location:sign_in.php"); } ?> This is my sign up code <?php session_start(); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("members", $con); $sql="INSERT INTO users (name, email, address, dob, password) VALUES ('$_POST[name]','$_POST[email]','$_POST[address]','$_POST[dob]','$_POST[mypassword]')"; if (!mysql_query($sql,$con)) die('Error: ' . mysql_error()); $_SESSION['userID'] = "SELECT id from users"; { header ("Location: sign_in.php"); exit; } mysql_close($con) ?> And this is my display user details code: <?php session_start(); // Create connection $conn = new mysqli("localhost", "root", "", "members"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $userID = $_SESSION['userID']; $sql = "SELECT name, email, address, dob FROM users WHERE `users`.`id`=$userID"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<table><tr><th>Name</th><th>Email</th><th>Address</th><th>DOB</th></tr>"; // output data of each row while($row = $result->fetch_assoc()) { echo "<tr><td>".$row["name"]."</td><td>".$row["email"]."</td><td>".$row["address"]."</td><td>".$row["dob"]."</td></tr>"; } echo "</table>"; } else { echo "<p>No Details</p><style>p{color: #336699; font-size: 20pt; font-family: Gulim; font-weight: bold; align: center; padding: 10px; position: absolute; top: 250; left: 600; z-index: 2; border-spacing: 0px;}</style> "; } $conn->close(); ?> For some reason it is not working, someone please help!
0debug
Holding onto a MTLTexture from a CVImageBuffer causes stuttering : <p>I'm creating a <code>MTLTexture</code> from <code>CVImageBuffer</code>s (from camera and players) using <code>CVMetalTextureCacheCreateTextureFromImage</code> to get a <code>CVMetalTexture</code> and then <code>CVMetalTextureGetTexture</code> to get the <code>MTLTexture</code>.</p> <p>The problem I'm seeing is that when I later render the texture using Metal, I occasionally see video frames rendered out of order (visually it stutters back and forth in time), presumably because CoreVideo is modifying the underlying <code>CVImageBuffer</code> storage and the <code>MTLTexture</code> is just pointing there.</p> <p>Is there any way to make CoreVideo not touch that buffer and use another one from its pool until I release the <code>MTLTexture</code> object?</p> <p>My current workaround is blitting the texture using a <code>MTLBlitCommandEncoder</code> but since I just need to hold on to the texture for ~30 milliseconds that seems unnecessary.</p>
0debug
Create Image Dynamically / CSS to Canvas? : <p>I would like to create an image dynamically in Javascript that needs to fit two requirements.</p> <ol> <li>It needs a colored background (say #fff) and be of a specific size (say 800x300)</li> <li>I need to be able to then place another image on it and position it (hopefully with CSS-esque type rules like width:150px; height:80px; left: 30px; top:30px; transform: rotate(7deg);" etc etc.</li> </ol> <p>Is there a library you're aware of that does that sort of function?</p>
0debug
iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) { IscsiLun *iscsilun = bs->opaque; struct iscsi_context *iscsi = iscsilun->iscsi; IscsiAIOCB *acb; size_t qemu_read_size; int i; uint64_t lba; uint32_t num_sectors; qemu_read_size = BDRV_SECTOR_SIZE * (size_t)nb_sectors; acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque); trace_iscsi_aio_readv(iscsi, sector_num, nb_sectors, opaque, acb); acb->iscsilun = iscsilun; acb->qiov = qiov; acb->canceled = 0; acb->bh = NULL; acb->status = -EINPROGRESS; acb->read_size = qemu_read_size; acb->buf = NULL; acb->read_offset = 0; if (iscsilun->block_size > BDRV_SECTOR_SIZE) { uint64_t bdrv_offset = BDRV_SECTOR_SIZE * sector_num; acb->read_offset = bdrv_offset % iscsilun->block_size; } num_sectors = (qemu_read_size + iscsilun->block_size + acb->read_offset - 1) / iscsilun->block_size; acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi READ16 " "command. %s", iscsi_get_error(iscsi)); qemu_aio_release(acb); return NULL; } memset(acb->task, 0, sizeof(struct scsi_task)); acb->task->xfer_dir = SCSI_XFER_READ; lba = sector_qemu2lun(sector_num, iscsilun); acb->task->expxferlen = qemu_read_size; switch (iscsilun->type) { case TYPE_DISK: acb->task->cdb_size = 16; acb->task->cdb[0] = 0x88; *(uint32_t *)&acb->task->cdb[2] = htonl(lba >> 32); *(uint32_t *)&acb->task->cdb[6] = htonl(lba & 0xffffffff); *(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors); break; default: acb->task->cdb_size = 10; acb->task->cdb[0] = 0x28; *(uint32_t *)&acb->task->cdb[2] = htonl(lba); *(uint16_t *)&acb->task->cdb[7] = htons(num_sectors); break; } if (iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task, iscsi_aio_read16_cb, NULL, acb) != 0) { scsi_free_scsi_task(acb->task); qemu_aio_release(acb); return NULL; } for (i = 0; i < acb->qiov->niov; i++) { scsi_task_add_data_in_buffer(acb->task, acb->qiov->iov[i].iov_len, acb->qiov->iov[i].iov_base); } iscsi_set_events(iscsilun); return &acb->common; }
1threat
div positioning / nested divs : <p>Assuming I wanted to have a in a div picture on the left side of the screen and descriptions or any other group of text on in another div the right side.</p> <p>What is the benefit of wrapping both in a third container div, rather than just using the <code>inline-block</code> display to put them side by side?</p>
0debug
getting function name in java script : <p>I am new to javascript.Is it possible to <code>getName</code> of a function within function itself?</p> <pre><code>function test(){ //how can i get current function name here. } </code></pre>
0debug
static av_always_inline int normal_limit(uint8_t *p, ptrdiff_t stride, int E, int I) { LOAD_PIXELS return simple_limit(p, stride, E) && FFABS(p3 - p2) <= I && FFABS(p2 - p1) <= I && FFABS(p1 - p0) <= I && FFABS(q3 - q2) <= I && FFABS(q2 - q1) <= I && FFABS(q1 - q0) <= I; }
1threat
nodemon ''mocha' is not recognized as an internal or external command, operable program or batch file : <p>Running a <a href="https://github.com/StephenGrider/MongoCasts/tree/030-finding-particular" rel="noreferrer">test</a> for a nodejs project on windows 10 with the line in package.json as:</p> <pre><code>"test": "nodemon --exec 'mocha -R min'" </code></pre> <p>I get:</p> <pre><code>&gt; nodemon --exec 'mocha -R min' [nodemon] 1.11.0 [nodemon] to restart at any time, enter `rs` [nodemon] watching: *.* [nodemon] starting `'mocha -R min'` ''mocha' is not recognized as an internal or external command, operable program or batch file. [nodemon] app crashed - waiting for file changes before starting... rs [nodemon] starting `'mocha -R min'` ''mocha' is not recognized as an internal or external command, operable program or batch file. [nodemon] app crashed - waiting for file changes before starting... </code></pre>
0debug
How can we test the alert and text inside is displaying using Cypress.io Js automation framework? : <p>How can we test the alert and text inside is displaying using Cypress.io Js automation framework? I am unable to figure out the relevant example in Cypress documentation, please advise.</p> <pre><code>describe('Test an alert and the text displaying', function() { it('Verify alert and its text content', function(){ cy.visit('http://www.seleniumeasy.com/test/javascript-alert-box-demo.html') cy.get('button').contains('Click me!').click() cy.on ('window:alert', 'I am an alert box!') }) }) </code></pre>
0debug
onRowdatabound not giving labal value in asp.net : I am creating the dynamic grid and adding textbox and label in row dynamically on some button click and bind some data from database to textbox and label.i want to change the label text color and textbox read only for condition depend on database.i have used onRowDataBound event of gridview but not getting any value in textbox and label for row.can any one help me to solve this issue.how can i achieve this.Thanks
0debug
static void write_mainheader(NUTContext *nut, AVIOContext *bc) { int i, j, tmp_pts, tmp_flags, tmp_stream, tmp_mul, tmp_size, tmp_fields, tmp_head_idx; int64_t tmp_match; ff_put_v(bc, nut->version); if (nut->version > 3) ff_put_v(bc, nut->minor_version); ff_put_v(bc, nut->avf->nb_streams); ff_put_v(bc, nut->max_distance); ff_put_v(bc, nut->time_base_count); for (i = 0; i < nut->time_base_count; i++) { ff_put_v(bc, nut->time_base[i].num); ff_put_v(bc, nut->time_base[i].den); } tmp_pts = 0; tmp_mul = 1; tmp_stream = 0; tmp_match = 1 - (1LL << 62); tmp_head_idx = 0; for (i = 0; i < 256; ) { tmp_fields = 0; tmp_size = 0; if (tmp_pts != nut->frame_code[i].pts_delta ) tmp_fields = 1; if (tmp_mul != nut->frame_code[i].size_mul ) tmp_fields = 2; if (tmp_stream != nut->frame_code[i].stream_id ) tmp_fields = 3; if (tmp_size != nut->frame_code[i].size_lsb ) tmp_fields = 4; if (tmp_head_idx != nut->frame_code[i].header_idx) tmp_fields = 8; tmp_pts = nut->frame_code[i].pts_delta; tmp_flags = nut->frame_code[i].flags; tmp_stream = nut->frame_code[i].stream_id; tmp_mul = nut->frame_code[i].size_mul; tmp_size = nut->frame_code[i].size_lsb; tmp_head_idx = nut->frame_code[i].header_idx; for (j = 0; i < 256; j++, i++) { if (i == 'N') { j--; continue; } if (nut->frame_code[i].pts_delta != tmp_pts || nut->frame_code[i].flags != tmp_flags || nut->frame_code[i].stream_id != tmp_stream || nut->frame_code[i].size_mul != tmp_mul || nut->frame_code[i].size_lsb != tmp_size + j || nut->frame_code[i].header_idx != tmp_head_idx) break; } if (j != tmp_mul - tmp_size) tmp_fields = 6; ff_put_v(bc, tmp_flags); ff_put_v(bc, tmp_fields); if (tmp_fields > 0) put_s(bc, tmp_pts); if (tmp_fields > 1) ff_put_v(bc, tmp_mul); if (tmp_fields > 2) ff_put_v(bc, tmp_stream); if (tmp_fields > 3) ff_put_v(bc, tmp_size); if (tmp_fields > 4) ff_put_v(bc, 0 ); if (tmp_fields > 5) ff_put_v(bc, j); if (tmp_fields > 6) ff_put_v(bc, tmp_match); if (tmp_fields > 7) ff_put_v(bc, tmp_head_idx); } ff_put_v(bc, nut->header_count - 1); for (i = 1; i < nut->header_count; i++) { ff_put_v(bc, nut->header_len[i]); avio_write(bc, nut->header[i], nut->header_len[i]); } if (nut->version > NUT_STABLE_VERSION) ff_put_v(bc, nut->flags); }
1threat
void avformat_close_input(AVFormatContext **ps) { AVFormatContext *s = *ps; AVIOContext *pb = (s->iformat->flags & AVFMT_NOFILE) || (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb; flush_packet_queue(s); if (s->iformat->read_close) s->iformat->read_close(s); avformat_free_context(s); *ps = NULL; if (pb) avio_close(pb); }
1threat
static void coroutine_fn v9fs_open(void *opaque) { int flags; int32_t fid; int32_t mode; V9fsQID qid; int iounit = 0; ssize_t err = 0; size_t offset = 7; struct stat stbuf; V9fsFidState *fidp; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; if (s->proto_version == V9FS_PROTO_2000L) { err = pdu_unmarshal(pdu, offset, "dd", &fid, &mode); } else { uint8_t modebyte; err = pdu_unmarshal(pdu, offset, "db", &fid, &modebyte); mode = modebyte; } if (err < 0) { goto out_nofid; } trace_v9fs_open(pdu->tag, pdu->id, fid, mode); fidp = get_fid(pdu, fid); if (fidp == NULL) { err = -ENOENT; goto out_nofid; } BUG_ON(fidp->fid_type != P9_FID_NONE); err = v9fs_co_lstat(pdu, &fidp->path, &stbuf); if (err < 0) { goto out; } stat_to_qid(&stbuf, &qid); if (S_ISDIR(stbuf.st_mode)) { err = v9fs_co_opendir(pdu, fidp); if (err < 0) { goto out; } fidp->fid_type = P9_FID_DIR; err = pdu_marshal(pdu, offset, "Qd", &qid, 0); if (err < 0) { goto out; } err += offset; } else { if (s->proto_version == V9FS_PROTO_2000L) { flags = get_dotl_openflags(s, mode); } else { flags = omode_to_uflags(mode); } if (is_ro_export(&s->ctx)) { if (mode & O_WRONLY || mode & O_RDWR || mode & O_APPEND || mode & O_TRUNC) { err = -EROFS; goto out; } } err = v9fs_co_open(pdu, fidp, flags); if (err < 0) { goto out; } fidp->fid_type = P9_FID_FILE; fidp->open_flags = flags; if (flags & O_EXCL) { fidp->flags |= FID_NON_RECLAIMABLE; } iounit = get_iounit(pdu, &fidp->path); err = pdu_marshal(pdu, offset, "Qd", &qid, iounit); if (err < 0) { goto out; } err += offset; } trace_v9fs_open_return(pdu->tag, pdu->id, qid.type, qid.version, qid.path, iounit); out: put_fid(pdu, fidp); out_nofid: pdu_complete(pdu, err); }
1threat
Required date in a specific format : I am new to VBA please address some one for the below issue date_example=10/18/2018 Range("C5") = Format(date_example, "YY-mmmm") Out put :18-Oct But I am looking for out put like Oct-18. Another requirement is no of working days in that month and start date and end date of the month need help in this regards.
0debug
def find_Points(l1,r1,l2,r2): x = min(l1,l2) if (l1 != l2) else -1 y = max(r1,r2) if (r1 != r2) else -1 return (x,y)
0debug
Array ( [0] => Array ( [email] => abcd@gmail.com [fname] => sachin ) ) : how can i access each value such as email ,fname. and am trying to access it like echo $resultData2[0]->email; what am doing wrong?
0debug
static void do_video_out(AVFormatContext *s, OutputStream *ost, InputStream *ist, AVFrame *in_picture) { int nb_frames, i, ret, format_video_sync; AVFrame *final_picture; AVCodecContext *enc; double sync_ipts; double duration = 0; int frame_size = 0; float quality = same_quant ? in_picture->quality : ost->st->codec->global_quality; enc = ost->st->codec; if (ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE) { duration = FFMAX(av_q2d(ist->st->time_base), av_q2d(ist->st->codec->time_base)); if(ist->st->avg_frame_rate.num) duration= FFMAX(duration, 1/av_q2d(ist->st->avg_frame_rate)); duration /= av_q2d(enc->time_base); } sync_ipts = get_sync_ipts(ost, in_picture->pts) / av_q2d(enc->time_base); nb_frames = 1; format_video_sync = video_sync_method; if (format_video_sync == VSYNC_AUTO) format_video_sync = (s->oformat->flags & AVFMT_VARIABLE_FPS) ? ((s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : 1; if (format_video_sync != VSYNC_PASSTHROUGH && format_video_sync != VSYNC_DROP) { double vdelta = sync_ipts - ost->sync_opts + duration; if (vdelta < -1.1) nb_frames = 0; else if (format_video_sync == VSYNC_VFR) { if (vdelta <= -0.6) { nb_frames = 0; } else if (vdelta > 0.6) ost->sync_opts = lrintf(sync_ipts); } else if (vdelta > 1.1) nb_frames = lrintf(vdelta); if (nb_frames == 0) { ++nb_frames_drop; av_log(NULL, AV_LOG_VERBOSE, "*** drop!\n"); } else if (nb_frames > 1) { nb_frames_dup += nb_frames - 1; av_log(NULL, AV_LOG_VERBOSE, "*** %d dup!\n", nb_frames - 1); } } else ost->sync_opts = lrintf(sync_ipts); nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number); if (nb_frames <= 0) return; do_video_resample(ost, ist, in_picture, &final_picture); for (i = 0; i < nb_frames; i++) { AVPacket pkt; av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; if (s->oformat->flags & AVFMT_RAWPICTURE && enc->codec->id == CODEC_ID_RAWVIDEO) { enc->coded_frame->interlaced_frame = in_picture->interlaced_frame; enc->coded_frame->top_field_first = in_picture->top_field_first; pkt.data = (uint8_t *)final_picture; pkt.size = sizeof(AVPicture); pkt.pts = av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base); pkt.flags |= AV_PKT_FLAG_KEY; write_frame(s, &pkt, ost); } else { int got_packet; AVFrame big_picture; big_picture = *final_picture; big_picture.interlaced_frame = in_picture->interlaced_frame; if (ost->st->codec->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)) { if (ost->top_field_first == -1) big_picture.top_field_first = in_picture->top_field_first; else big_picture.top_field_first = !!ost->top_field_first; } big_picture.quality = quality; if (!enc->me_threshold) big_picture.pict_type = 0; big_picture.pts = ost->sync_opts; if (ost->forced_kf_index < ost->forced_kf_count && big_picture.pts >= ost->forced_kf_pts[ost->forced_kf_index]) { big_picture.pict_type = AV_PICTURE_TYPE_I; ost->forced_kf_index++; } ret = avcodec_encode_video2(enc, &pkt, &big_picture, &got_packet); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n"); exit_program(1); } if (got_packet) { if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & CODEC_CAP_DELAY)) pkt.pts = ost->sync_opts; if (pkt.pts != AV_NOPTS_VALUE) pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base); if (pkt.dts != AV_NOPTS_VALUE) pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base); if (debug_ts) { av_log(NULL, AV_LOG_INFO, "encoder -> type:video " "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n", av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base), av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base)); } if (format_video_sync == VSYNC_DROP) pkt.pts = pkt.dts = AV_NOPTS_VALUE; write_frame(s, &pkt, ost); frame_size = pkt.size; video_size += pkt.size; if (ost->logfile && enc->stats_out) { fprintf(ost->logfile, "%s", enc->stats_out); } } } ost->sync_opts++; ost->frame_number++; } if (vstats_filename && frame_size) do_video_stats(output_files[ost->file_index].ctx, ost, frame_size); }
1threat
How to assert that a constexpr if else clause never happen? : <p>I want to raise a compile time error when non of the constexpr if conditions is true eg:</p> <pre><code>if constexpr(condition1){ ... } else if constexpr (condition2) { .... } else if constexpr (condition3) { .... } else { // I want the else clause never taken. But I heard the code below is not allowed static_assert(false); } // I'd rather not repeat the conditions again like this: static_assert(condition1 || condition2 || condition3); </code></pre>
0debug
how to build a model for computer vision without using pre trained models : <p>I am a total rookie in computer vision. I am looking to build a model without using pre-trained models for coco dataset or any open-source image datasets. Any articles or references to build such models would be appreciated. I would like to build this model from scratch and make no suggestions on pre-existing trained models or Api are irrelevant to this question. and thanks in advance for any suggestions. the programming language of preference for this project is python</p>
0debug
Need help on LINQ Query C# : I am new to LINQ, I wrote a following code using C#, but I need to rewrite using LINQ, so could you please let me know , how can I rewrite the same. Basicaly I want to achive for all the 0th position in the array I need to set NULL value for the few property. Here - OrganizationList is an array. if (OrganizationList.Count > 0) { if (OrganizationList[0].OrganizationLevel == 0) { OrganizationList[0].NetworkParticipation = null; OrganizationList[0].ApprovalPolicyID = null; OrganizationList[0].LastUpdateDate = null; } }
0debug
What is =~ operator in elixir : <p>From the <a href="https://elixir-lang.org/getting-started/sigils.html" rel="noreferrer">documentation</a> I understand how <code>=~</code> operator works to match regex, but I don't understand the general use of this operator. </p> <p>For example, what does <code>"foo" =~ "foo"</code> mean? How is it different from <code>"foo" == "foo"</code>?</p>
0debug
Push notification deos not work in swift 3.0 : intial we import the import UserNotifications framework and we intialize the delegate mehtod in appdelegate.swift class if #available(iOS 10.0, *){ UNUserNotificationCenter.current().delegate = self let center = UNUserNotificationCenter.current() center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in if (granted) { UIApplication.shared.registerForRemoteNotifications() } else{ //Do stuff if unsuccessful... } // Enable or disable features based on authorization. } }
0debug
Django: GenericForeignKey and unique_together : <p>In the application I'm working on I'm trying to share access tokens within a company. Example: a local office can use the headquarter's tokens to post something on their Facebook page.</p> <pre><code>class AccessToken(models.Model): """Abstract class for Access tokens.""" owner = models.ForeignKey('publish.Publisher') socialMediaChannel = models.IntegerField( choices=socialMediaChannelList, null=False, blank=False ) lastUpdate = models.DateField(auto_now=True) class Meta: abstract = True </code></pre> <p>Since Facebook, Twitter and other social media sites handle access tokens in their own way I made and abstract class AccessToken. Each site gets its own class e.g. </p> <pre><code>class FacebookAccessToken(AccessToken): # class stuff </code></pre> <p>After doing some reading I found out that I must use a <code>GenericForeignKey</code> to point to classes that inherit <code>AccessToken</code>. I made the following class:</p> <pre><code>class ShareAccessToken(models.Model): """Share access tokens with other publishers.""" sharedWith = models.ForeignKey('publish.Publisher') sharedBy = models.ForeignKey(User) # for foreignkey to abstract model's children contentType = models.ForeignKey(ContentType) objectId = models.PositiveIntegerField() contentObject = GenericForeignKey('contentType', 'objectId') class Meta: unique_together = (('contentObject', 'sharedWith')) </code></pre> <p>When I run the django test server I get the following error:</p> <blockquote> <p>core.ShareAccessToken: (models.E016) 'unique_together' refers to field 'contentObject' which is not local to model 'ShareAccessToken'. HINT: This issue may be caused by multi-table inheritance.</p> </blockquote> <p>I don't understand why I get this error, first time using <code>GenericForeignKey</code>. What am I doing wrong?</p> <p>If there is a smarter way to share the access tokens I would love to hear about it.</p>
0debug
Multiple Case Expressions ruby : I have two fields field1 and field2. I need to do a case on both the fields and switch it into corresponding when outputs case field1 when "val1" puts field1 when "val2" puts field2 end case field2 when "val1" puts field1 when "val2" puts field2 end So, how can i implement something like above in a single case statement something like this case field1,field2 when "val1" puts field1 when "val2" puts field2 end will any monkey patching help?? any help are apreciated.. thanks
0debug
WINDOWS API: GetCurrentThread(); in C : <p>I just started my college "adventures", and one of them is subject called operating systems. I must admit that the subject is the most boring ever. Last week, we got our first homework, and i do not know what to do as this is the first time ever i come up with Windows API functions or this topic in general. The task is very simple, we need to write very basic code in C that shows how does GetCurrentThread() work!!!???? I tried looking for solution online, but I could not find anything and our professor is not doing anything to help us. I found the use of functions like GetCurrentThreadID() but that is not what i need. Can somebody write simple program ( 20-30 lines of code ) which contains the use of this function (in C)?</p>
0debug
Python is not recognized as internal or external command : <p>even though i have added the path variable i am unable to run the command </p> <p>cmd <a href="https://i.stack.imgur.com/lfi7U.png" rel="nofollow noreferrer">1</a></p> <p>path variable <a href="https://i.stack.imgur.com/daf87.png" rel="nofollow noreferrer">2</a></p>
0debug
Samples or live demo of Amazon Polly? : <p>I'm considering using Amazon Polly's Text-To-Speech (TTS) but want to evaluate how natural it really sounds with arbitrary examples (not the ones carefully curated by Amazon marketing folks).</p> <p>All I've found is a <a href="https://www.youtube.com/watch?v=AtGaVrkkD38" rel="noreferrer">very limited youtube video</a> (just a few seconds in each of the languages)</p>
0debug
static int process_frame(FFFrameSync *fs) { AVFilterContext *ctx = fs->parent; LUT2Context *s = fs->opaque; AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out, *srcx, *srcy; int ret; if ((ret = ff_framesync2_get_frame(&s->fs, 0, &srcx, 0)) < 0 || (ret = ff_framesync2_get_frame(&s->fs, 1, &srcy, 0)) < 0) return ret; if (ctx->is_disabled) { out = av_frame_clone(srcx); if (!out) return AVERROR(ENOMEM); } else { out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) return AVERROR(ENOMEM); av_frame_copy_props(out, srcx); s->lut2(s, out, srcx, srcy); } out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base); return ff_filter_frame(outlink, out); }
1threat
static void usage(void) { const struct qemu_argument *arginfo; int maxarglen; int maxenvlen; printf("usage: qemu-" TARGET_ARCH " [options] program [arguments...]\n" "Linux CPU emulator (compiled for " TARGET_ARCH " emulation)\n" "\n" "Options and associated environment variables:\n" "\n"); maxarglen = maxenvlen = 0; for (arginfo = arg_table; arginfo->handle_opt != NULL; arginfo++) { if (strlen(arginfo->env) > maxenvlen) { maxenvlen = strlen(arginfo->env); } if (strlen(arginfo->argv) > maxarglen) { maxarglen = strlen(arginfo->argv); } } printf("%-*s%-*sDescription\n", maxarglen+3, "Argument", maxenvlen+1, "Env-variable"); for (arginfo = arg_table; arginfo->handle_opt != NULL; arginfo++) { if (arginfo->has_arg) { printf("-%s %-*s %-*s %s\n", arginfo->argv, (int)(maxarglen-strlen(arginfo->argv)), arginfo->example, maxenvlen, arginfo->env, arginfo->help); } else { printf("-%-*s %-*s %s\n", maxarglen+1, arginfo->argv, maxenvlen, arginfo->env, arginfo->help); } } printf("\n" "Defaults:\n" "QEMU_LD_PREFIX = %s\n" "QEMU_STACK_SIZE = %ld byte\n", interp_prefix, guest_stack_size); printf("\n" "You can use -E and -U options or the QEMU_SET_ENV and\n" "QEMU_UNSET_ENV environment variables to set and unset\n" "environment variables for the target process.\n" "It is possible to provide several variables by separating them\n" "by commas in getsubopt(3) style. Additionally it is possible to\n" "provide the -E and -U options multiple times.\n" "The following lines are equivalent:\n" " -E var1=val2 -E var2=val2 -U LD_PRELOAD -U LD_DEBUG\n" " -E var1=val2,var2=val2 -U LD_PRELOAD,LD_DEBUG\n" " QEMU_SET_ENV=var1=val2,var2=val2 QEMU_UNSET_ENV=LD_PRELOAD,LD_DEBUG\n" "Note that if you provide several changes to a single variable\n" "the last change will stay in effect.\n"); exit(1); }
1threat
static int write_payload_3270(EmulatedCcw3270Device *dev, uint8_t cmd) { Terminal3270 *t = TERMINAL_3270(dev); int retval = 0; int count = ccw_dstream_avail(get_cds(t)); assert(count <= (OUTPUT_BUFFER_SIZE - 3) / 2); if (!t->handshake_done) { if (!(t->outv[0] == IAC && t->outv[1] != IAC)) { return 0; } } if (!qemu_chr_fe_backend_connected(&t->chr)) { return count; } t->outv[0] = cmd; ccw_dstream_read_buf(get_cds(t), &t->outv[1], count); t->out_len = count + 1; t->out_len = insert_IAC_escape_char(t->outv, t->out_len); t->outv[t->out_len++] = IAC; t->outv[t->out_len++] = IAC_EOR; retval = qemu_chr_fe_write_all(&t->chr, t->outv, t->out_len); return (retval <= 0) ? 0 : (retval - 3); }
1threat
React Native project, index.ios.js or index.android.js not generated : <p>I started with React-Native today. And I am following a web tutorial.</p> <p>Did all the installations correctly on my Windows machine:</p> <ul> <li>Java Jdk </li> <li>Android Studio </li> <li>Node/NPM </li> <li>Yarn</li> </ul> <p>then installed react-native </p> <pre><code>npm install -g react-native-cli </code></pre> <p>finally a hello world project</p> <pre><code>react-native init albums </code></pre> <p>I am not getting any errors. My app runs (basically loads up) on my Android phone perfectly. </p> <p>The app.js is bit conditional on platform choice:</p> <pre><code> /** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { Platform, StyleSheet, Text, View } from 'react-native'; const instructions = Platform.select({ ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu', android: 'Double tap R on your keyboard to reload,\n' + 'Shake or press menu button for dev menu', }); export default class App extends Component&lt;{}&gt; { render() { return ( &lt;View style={styles.container}&gt; &lt;Text style={styles.welcome}&gt; Welcome to React Native! &lt;/Text&gt; &lt;Text style={styles.instructions}&gt; To get started, edit App.js &lt;/Text&gt; &lt;Text style={styles.instructions}&gt; {instructions} &lt;/Text&gt; &lt;/View&gt; ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, }); </code></pre> <p>I just want to know if this is normal to not get those files generated. Shall I create those 2 index files? Or the latest react-native does not need 2 separate files? (The tutorial I am following is of Jan 2017)</p> <p><a href="https://i.stack.imgur.com/YXEdH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YXEdH.png" alt="The Project structure"></a></p>
0debug
Diaplaying table using HTML : I want to display the below contents in table format using HTML. Can you please quickly help to display this content using HTML. please find below sample table contents. Name Count X1 6 X2 3
0debug
static const AVClass *ff_avio_child_class_next(const AVClass *prev) { return prev ? NULL : &ffurl_context_class; }
1threat
static void xen_io_add(MemoryListener *listener, MemoryRegionSection *section) { XenIOState *state = container_of(listener, XenIOState, io_listener); memory_region_ref(section->mr); xen_map_io_section(xen_xc, xen_domid, state->ioservid, section); }
1threat
Shopping cart help PHP : Unique user : <p>I have one unresolved issue. I have a shopping cart on my local website.</p> <p>Any type of user can make a order. With registered - it's ok, understandable. But what i can do, if user is not authorized, has disabled cookies and javascript? How should i make unique 'quest' user? I thought about IP addr, but it can be dynamic or You can visit web site through proxy, so that is not a solution?</p> <p>Any ideas?</p>
0debug
Not able to create a Firebase (Google)project after deleting the existing ones : <p><a href="https://i.stack.imgur.com/HE8w7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HE8w7.png" alt="Check below error, when trying to create a new project"></a> I want to use Firebase Analytics. I had a existing project. But after deleting it I am not able to create a new project. Getting error saying maximum limit reached, when i dont even have single running project.</p>
0debug
static av_always_inline void fill_filter_caches_inter(const H264Context *h, H264SliceContext *sl, int mb_type, int top_xy, int left_xy[LEFT_MBS], int top_type, int left_type[LEFT_MBS], int mb_xy, int list) { int b_stride = h->b_stride; int16_t(*mv_dst)[2] = &sl->mv_cache[list][scan8[0]]; int8_t *ref_cache = &sl->ref_cache[list][scan8[0]]; if (IS_INTER(mb_type) || IS_DIRECT(mb_type)) { if (USES_LIST(top_type, list)) { const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride; const int b8_xy = 4 * top_xy + 2; int (*ref2frm)[64] = sl->ref2frm[h->slice_table[top_xy] & (MAX_SLICES - 1)][0] + (MB_MBAFF(sl) ? 20 : 2); AV_COPY128(mv_dst - 1 * 8, h->cur_pic.motion_val[list][b_xy + 0]); ref_cache[0 - 1 * 8] = ref_cache[1 - 1 * 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 0]]; ref_cache[2 - 1 * 8] = ref_cache[3 - 1 * 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 1]]; } else { AV_ZERO128(mv_dst - 1 * 8); AV_WN32A(&ref_cache[0 - 1 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u); } if (!IS_INTERLACED(mb_type ^ left_type[LTOP])) { if (USES_LIST(left_type[LTOP], list)) { const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3; const int b8_xy = 4 * left_xy[LTOP] + 1; int (*ref2frm)[64] = sl->ref2frm[h->slice_table[left_xy[LTOP]] & (MAX_SLICES - 1)][0] + (MB_MBAFF(sl) ? 20 : 2); AV_COPY32(mv_dst - 1 + 0, h->cur_pic.motion_val[list][b_xy + b_stride * 0]); AV_COPY32(mv_dst - 1 + 8, h->cur_pic.motion_val[list][b_xy + b_stride * 1]); AV_COPY32(mv_dst - 1 + 16, h->cur_pic.motion_val[list][b_xy + b_stride * 2]); AV_COPY32(mv_dst - 1 + 24, h->cur_pic.motion_val[list][b_xy + b_stride * 3]); ref_cache[-1 + 0] = ref_cache[-1 + 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 2 * 0]]; ref_cache[-1 + 16] = ref_cache[-1 + 24] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 2 * 1]]; } else { AV_ZERO32(mv_dst - 1 + 0); AV_ZERO32(mv_dst - 1 + 8); AV_ZERO32(mv_dst - 1 + 16); AV_ZERO32(mv_dst - 1 + 24); ref_cache[-1 + 0] = ref_cache[-1 + 8] = ref_cache[-1 + 16] = ref_cache[-1 + 24] = LIST_NOT_USED; } } } if (!USES_LIST(mb_type, list)) { fill_rectangle(mv_dst, 4, 4, 8, pack16to32(0, 0), 4); AV_WN32A(&ref_cache[0 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u); AV_WN32A(&ref_cache[1 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u); AV_WN32A(&ref_cache[2 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u); AV_WN32A(&ref_cache[3 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u); return; } { int8_t *ref = &h->cur_pic.ref_index[list][4 * mb_xy]; int (*ref2frm)[64] = sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][0] + (MB_MBAFF(sl) ? 20 : 2); uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]], ref2frm[list][ref[1]]) & 0x00FF00FF) * 0x0101; uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]], ref2frm[list][ref[3]]) & 0x00FF00FF) * 0x0101; AV_WN32A(&ref_cache[0 * 8], ref01); AV_WN32A(&ref_cache[1 * 8], ref01); AV_WN32A(&ref_cache[2 * 8], ref23); AV_WN32A(&ref_cache[3 * 8], ref23); } { int16_t(*mv_src)[2] = &h->cur_pic.motion_val[list][4 * sl->mb_x + 4 * sl->mb_y * b_stride]; AV_COPY128(mv_dst + 8 * 0, mv_src + 0 * b_stride); AV_COPY128(mv_dst + 8 * 1, mv_src + 1 * b_stride); AV_COPY128(mv_dst + 8 * 2, mv_src + 2 * b_stride); AV_COPY128(mv_dst + 8 * 3, mv_src + 3 * b_stride); } }
1threat
static void group_exponents(AC3EncodeContext *s) { int blk, ch, i; int group_size, nb_groups, bit_count; uint8_t *p; int delta0, delta1, delta2; int exp0, exp1; bit_count = 0; for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { AC3Block *block = &s->blocks[blk]; for (ch = 0; ch < s->channels; ch++) { if (s->exp_strategy[ch][blk] == EXP_REUSE) continue; group_size = s->exp_strategy[ch][blk] + (s->exp_strategy[ch][blk] == EXP_D45); nb_groups = exponent_group_tab[s->exp_strategy[ch][blk]-1][s->nb_coefs[ch]]; bit_count += 4 + (nb_groups * 7); p = block->exp[ch]; exp1 = *p++; block->grouped_exp[ch][0] = exp1; for (i = 1; i <= nb_groups; i++) { exp0 = exp1; exp1 = p[0]; p += group_size; delta0 = exp1 - exp0 + 2; exp0 = exp1; exp1 = p[0]; p += group_size; delta1 = exp1 - exp0 + 2; exp0 = exp1; exp1 = p[0]; p += group_size; delta2 = exp1 - exp0 + 2; block->grouped_exp[ch][i] = ((delta0 * 5 + delta1) * 5) + delta2; } } } s->exponent_bits = bit_count; }
1threat
How to disable camera microphone on AVCapture device input : <p>I am setting a microphone on a <code>AVCaptureSession</code> and I am in need of a switch for the mic. How should I proceed with this? Do I really need to the <code>captureSession?.removeInput(microphone)</code>, or is there an easies way?</p> <pre><code>let microphone = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeAudio) do { let micInput = try AVCaptureDeviceInput(device: microphone) if captureSession.canAddInput(micInput) { captureSession.addInput(micInput) } } catch { print("Error setting device audio input: \(error)") return false } </code></pre>
0debug
int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) { unsigned int i, head, max; hwaddr desc_pa = vq->vring.desc; VirtIODevice *vdev = vq->vdev; if (!virtqueue_num_heads(vq, vq->last_avail_idx)) return 0; elem->out_num = elem->in_num = 0; max = vq->vring.num; i = head = virtqueue_get_head(vq, vq->last_avail_idx++); if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_avail_event(vq, vq->last_avail_idx); } if (vring_desc_flags(vdev, desc_pa, i) & VRING_DESC_F_INDIRECT) { if (vring_desc_len(vdev, desc_pa, i) % sizeof(VRingDesc)) { error_report("Invalid size for indirect buffer table"); exit(1); } max = vring_desc_len(vdev, desc_pa, i) / sizeof(VRingDesc); desc_pa = vring_desc_addr(vdev, desc_pa, i); i = 0; } do { struct iovec *sg; if (vring_desc_flags(vdev, desc_pa, i) & VRING_DESC_F_WRITE) { if (elem->in_num >= ARRAY_SIZE(elem->in_sg)) { error_report("Too many write descriptors in indirect table"); exit(1); } elem->in_addr[elem->in_num] = vring_desc_addr(vdev, desc_pa, i); sg = &elem->in_sg[elem->in_num++]; } else { if (elem->out_num >= ARRAY_SIZE(elem->out_sg)) { error_report("Too many read descriptors in indirect table"); exit(1); } elem->out_addr[elem->out_num] = vring_desc_addr(vdev, desc_pa, i); sg = &elem->out_sg[elem->out_num++]; } sg->iov_len = vring_desc_len(vdev, desc_pa, i); if ((elem->in_num + elem->out_num) > max) { error_report("Looped descriptor"); exit(1); } } while ((i = virtqueue_next_desc(vdev, desc_pa, i, max)) != max); virtqueue_map(elem); elem->index = head; vq->inuse++; trace_virtqueue_pop(vq, elem, elem->in_num, elem->out_num); return elem->in_num + elem->out_num; }
1threat
New debug icon "Step F9" in Chrome Dev Tools : <p>So what does this actualy do?</p> <p><a href="https://i.stack.imgur.com/lh01n.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/lh01n.jpg" alt="enter image description here"></a></p> <p>I searched trough the release notes of the Chrome Dev Tools and couldn't find a trace of it. None of the tutorials out there don't mention it either so I'm guessing it's new.</p> <p>Experimenting with some code I seems to behave the same as "Step Into" and couldn't find a difference.</p>
0debug
How to train TensorFlow network using a generator to produce inputs? : <p>The TensorFlow <a href="https://www.tensorflow.org/versions/r0.10/how_tos/reading_data/index.html" rel="noreferrer">docs</a> describe a bunch of ways to read data using TFRecordReader, TextLineReader, QueueRunner etc and queues.</p> <p>What I would like to do is much, much simpler: I have a python generator function that produces an infinite sequence of training data as (X, y) tuples (both are numpy arrays, and the first dimension is the batch size). I just want to train a network using that data as inputs. </p> <p>Is there a simple self-contained example of training a TensorFlow network using a generator which produces the data? (along the lines of the MNIST or CIFAR examples)</p>
0debug
C# read output from another application : I am not developer but i have to create small application. Here is the scenario We have an existing financial application. When application complete calculation it will pass few parameters. My C# application needs to read these parameters(financial application output parameters).If primary application (financial application) doesn't pass parameter then C# application ask to input these parameters(input in textboxs). can anyone help me how i can read these parameters in my C# windows form application. Thanks
0debug
How to compare JTable with file : I have two tables one inventory and another invoice. My inventory is connected to a .dat file which writes and reads it data from the file. I want to compare my invoice table with the elements of the inventory which is stored in the file if match is not it prompts the user to add this item to your inventory.
0debug
python padding formatting alternative? : <p>Is there a custom way of padding lines of text in python, I am using the escape characters "\t", but I wonder if there is an alternative. for example</p> <pre><code>print('My Name is:') print('Rambo') print('Mambo') </code></pre> <p>Output:</p> <pre><code>.My Name is: .....Rambo ..Mambo </code></pre>
0debug
void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size) { int qp_y = get_qPy_pred(s, xC, yC, xBase, yBase, log2_cb_size); if (s->HEVClc->tu.cu_qp_delta != 0) { int off = s->sps->qp_bd_offset; s->HEVClc->qp_y = ((qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off) % (52 + off)) - off; } else s->HEVClc->qp_y = qp_y; }
1threat
Docker: Reverse Engineering of an Image : <p>When we use Docker it's very easy push and pull image in a public repository in our <code>https://hub.docker.com</code> but this repository it's free only for public image(only one can be private).</p> <p>Currently it's possible to execute a reverse engineering of a public image in repository and read the source code of project ?</p>
0debug
Is there any difference in Oracle provider for Entity Framework between standard & enterprise? : <p><a href="https://i.stack.imgur.com/neI1I.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/neI1I.jpg" alt="enter image description here"></a></p> <p>I find myself in a position to work on Oracle Express for a project. Just curious will it continue to work with given provider in enterprise edition?</p> <p>Is there any difference in Oracle provider for Entity Framework between Oracle Express &amp; Enterprise Edition 12c?</p>
0debug
How to Fix This Erorr ((Exception)) in C#? : ERROR: Activated Event Time Duration Thread Exception: Exception thrown: 'System.TypeInitializationException' in EntityFramework.dll ("The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception."). Exception thrown: 'System.TypeInitializationException' in EntityFramework.dll ("The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.") 0.08s [6420] <No Name>
0debug
Cannot run PlusDomains example in AppMaker : I am trying to run this example code in AppMaker: https://developers.google.com/apps-script/advanced/plus-domains#creating_a_post However, I keep getting this: GoogleJsonResponseException: Access to the Google+ Domains API is not allowed as the user has consented to incompatible scopes. Has anybody else managed to get this working? Thanks, Scott
0debug
CharDriverState *qemu_chr_open_opts(QemuOpts *opts, void (*init)(struct CharDriverState *s)) { CharDriverState *chr; int i; if (qemu_opts_id(opts) == NULL) { fprintf(stderr, "chardev: no id specified\n"); for (i = 0; i < ARRAY_SIZE(backend_table); i++) { if (strcmp(backend_table[i].name, qemu_opt_get(opts, "backend")) == 0) break; if (i == ARRAY_SIZE(backend_table)) { fprintf(stderr, "chardev: backend \"%s\" not found\n", qemu_opt_get(opts, "backend")); chr = backend_table[i].open(opts); if (!chr) { fprintf(stderr, "chardev: opening backend \"%s\" failed\n", qemu_opt_get(opts, "backend")); if (!chr->filename) chr->filename = qemu_strdup(qemu_opt_get(opts, "backend")); chr->init = init; QTAILQ_INSERT_TAIL(&chardevs, chr, next); if (qemu_opt_get_bool(opts, "mux", 0)) { CharDriverState *base = chr; int len = strlen(qemu_opts_id(opts)) + 6; base->label = qemu_malloc(len); snprintf(base->label, len, "%s-base", qemu_opts_id(opts)); chr = qemu_chr_open_mux(base); chr->filename = base->filename; QTAILQ_INSERT_TAIL(&chardevs, chr, next); chr->label = qemu_strdup(qemu_opts_id(opts)); return chr;
1threat
Import numpy on pycharm : <p>I'm trying to import numpy on Pycharm.</p> <p>Using the Pycharm terminal and Miniconda I've launched the command:</p> <pre><code>conda install numpy </code></pre> <p>And this was the output</p> <pre><code>Fetching package metadata: .... Solving package specifications: .................... # All requested packages already installed. # packages in environment at C:\Users\...\Miniconda3: # numpy 1.10.4 py35_0 </code></pre> <p>So I run my project but the terminal said</p> <pre><code>ImportError: No module named 'numpy' </code></pre> <p>On my project bar I can see two different folders, the one with my project and another one with the external libraries.</p> <p>Under External libraries -> Extendend definitions there is a numpy folder so I guess that the installation goes well.</p> <p>Can you please help me ?</p>
0debug
Firebase addvalueevent listner consuming memory if data is in large amount : Thanks in advance. global.getDatabaseReference().child(ApplicationConstants.TOPIC_DB).child(Util.getSelectedBoard(context)).child(Util.getSelectedClass(context)).child(Util.getSelectedLanguagePackage(context)).child("CategoryId_1").child(subject).child(ApplicationConstants.TOPICS).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { try { topicContentArrayList = new ArrayList<>(); HashMap<String, HashMap<String, String>> modelHashMap = null; int pos =0; for (DataSnapshot single_ : dataSnapshot.getChildren()) { modelHashMap = new HashMap<>(); HashMap<String, String> innerTopicNode = (HashMap<String, String>) single_.getValue(); innerTopicNode.put("mastery", "0"); innerTopicNode.put("enabled", innerTopicNode.get("Display")); innerTopicNode.put("currentLevel", "1"); innerTopicNode.put("flag", "Done"); innerTopicNode.put("score", "0"); modelHashMap.put(pos + "", innerTopicNode); pos++; topicContentArrayList.add(modelHashMap); } } catch (Exception e) { e.printStackTrace(); } } @Override public void onCancelled(DatabaseError databaseError) { Util.dismissdataDialog(); } }); Here is the memory error Background partial concurrent mark sweep GC freed 277003(9MB) It is blocking the UI and I'm unable to perform click action for some time. Please Help me to get out from this issue.
0debug
Is it necessary to add permissions in an android app? : <p>Is it necessary to add permissions in an android app ? And if yes, then why ? And if we don't put, then what will happen ?</p> <p>Are the permissions added only to show them while installing the APK file ?</p>
0debug
static int rtp_write_header(AVFormatContext *s1) { RTPMuxContext *s = s1->priv_data; int max_packet_size, n; AVStream *st; if (s1->nb_streams != 1) return -1; st = s1->streams[0]; if (!is_supported(st->codec->codec_id)) { av_log(s1, AV_LOG_ERROR, "Unsupported codec %x\n", st->codec->codec_id); return -1; } if (s->payload_type < 0) s->payload_type = ff_rtp_get_payload_type(s1, st->codec); s->base_timestamp = av_get_random_seed(); s->timestamp = s->base_timestamp; s->cur_timestamp = 0; s->ssrc = av_get_random_seed(); s->first_packet = 1; s->first_rtcp_ntp_time = ff_ntp_time(); if (s1->start_time_realtime) s->first_rtcp_ntp_time = (s1->start_time_realtime / 1000) * 1000 + NTP_OFFSET_US; max_packet_size = s1->pb->max_packet_size; if (max_packet_size <= 12) return AVERROR(EIO); s->buf = av_malloc(max_packet_size); if (s->buf == NULL) { return AVERROR(ENOMEM); } s->max_payload_size = max_packet_size - 12; s->max_frames_per_packet = 0; if (s1->max_delay) { if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if (st->codec->frame_size == 0) { av_log(s1, AV_LOG_ERROR, "Cannot respect max delay: frame size = 0\n"); } else { s->max_frames_per_packet = av_rescale_rnd(s1->max_delay, st->codec->sample_rate, AV_TIME_BASE * st->codec->frame_size, AV_ROUND_DOWN); } } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { s->max_frames_per_packet = av_rescale_q(s1->max_delay, (AVRational){1, 1000000}, st->codec->time_base); } } avpriv_set_pts_info(st, 32, 1, 90000); switch(st->codec->codec_id) { case CODEC_ID_MP2: case CODEC_ID_MP3: s->buf_ptr = s->buf + 4; break; case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG2VIDEO: break; case CODEC_ID_MPEG2TS: n = s->max_payload_size / TS_PACKET_SIZE; if (n < 1) n = 1; s->max_payload_size = n * TS_PACKET_SIZE; s->buf_ptr = s->buf; break; case CODEC_ID_H264: if (st->codec->extradata_size > 4 && st->codec->extradata[0] == 1) { s->nal_length_size = (st->codec->extradata[4] & 0x03) + 1; } break; case CODEC_ID_VORBIS: case CODEC_ID_THEORA: if (!s->max_frames_per_packet) s->max_frames_per_packet = 15; s->max_frames_per_packet = av_clip(s->max_frames_per_packet, 1, 15); s->max_payload_size -= 6; s->num_frames = 0; goto defaultcase; case CODEC_ID_VP8: av_log(s1, AV_LOG_ERROR, "RTP VP8 payload implementation is " "incompatible with the latest spec drafts.\n"); break; case CODEC_ID_ADPCM_G722: avpriv_set_pts_info(st, 32, 1, 8000); break; case CODEC_ID_AMR_NB: case CODEC_ID_AMR_WB: if (!s->max_frames_per_packet) s->max_frames_per_packet = 12; if (st->codec->codec_id == CODEC_ID_AMR_NB) n = 31; else n = 61; if (1 + s->max_frames_per_packet + n > s->max_payload_size) { av_log(s1, AV_LOG_ERROR, "RTP max payload size too small for AMR\n"); return -1; } if (st->codec->channels != 1) { av_log(s1, AV_LOG_ERROR, "Only mono is supported\n"); return -1; } case CODEC_ID_AAC: s->num_frames = 0; default: defaultcase: if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate); } s->buf_ptr = s->buf; break; } return 0; }
1threat
Is there any Plugin available for VueJs in Netbeans 8.2 : <p>Netbeans 8.x intellisense doesn't identify VueJS tags. Is there any Plugin available for VueJs syntax highlighting or autofill support in Netbeans 8.x? If not, are there any work arounds?</p>
0debug
Javascript change the value of a key : <p>I have some data that looks like this:</p> <pre><code>obj = { pref: { language: 'English', } }; </code></pre> <p>I want to change the value of <code>language to 'Spanish'</code></p>
0debug
How do I make a .jar file with a .jar file? : <p>I'm creating a program that makes "candy".jars and I need to make this "candy".jar with a creator.jar file. The idea is you run the creator.jar file and you can adjust settings inside of it in order to make another "candy".jar. The problem is: I don't know if this is possible, and all of my research (i.e. google search) has come up blank.</p> <p>Q. Is is possible to make a .jar file with another .jar file?</p>
0debug
static void mv88w8618_pic_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { mv88w8618_pic_state *s = opaque; switch (offset) { case MP_PIC_ENABLE_SET: s->enabled |= value; break; case MP_PIC_ENABLE_CLR: s->enabled &= ~value; s->level &= ~value; break; } mv88w8618_pic_update(s); }
1threat
why my python cannot read files on my desktop : I'm new here and in python. There are 2 questions I'd like to ask: 1) I'm reading a .dat file on my desktop into my spider, but it shows No such file or directory: 'C:\\Desktop\\movies.dat', but if I put the file into the default folder, 'C:\\Users\\User\\.spyder-py3\\movies.dat', it can read the file successfully. I thought that python3 can file the path in the quotes no matter if it is a default folder or not. 2) I've been reading some python books and in every beginning of each book, there is a chaper introducing Ipython and Jupyter orsomething like that, I don't quite understand what's the difference between, like, Anaconda, Spider, Jupyter notebook and Ipython. I'm currently using Spider and wondering what's the difference. Great thanks if anythong can help!
0debug
Could someone please help me here? : I am new to android and doing some basic activities on android studio. I have the following code which will redirect from LoginActivity to Navigation activity after successful login. **LoginActivity.java code below:-** if (cancel) { // There was an error; don't attempt login and focus the first // form field with an error. focusView.requestFocus(); } else { // Show a progress spinner, and kick off a background task to // perform the user login attempt. showProgress(true); mAuthTask = new UserLoginTask(email, password); mAuthTask.execute((Void) null); if(loginPassed) { Intent intent = new Intent(this, com.example.jjefry.myapplication.NavigationActivity.class); intent.putExtra(EXTRA_MESSAGE, "Jefry"); startActivity(intent); } } ***loginPassed*** variable is set to true if the credentials are correct else it will be false. If I remove ***if*** condition in the above program if will redirect to NavigationActivity properly but with ***if*** condition in place, it will simple close the application. Not sure where am I going wrong, please help me with this.
0debug
BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BlockDriverState *target, int64_t speed, MirrorSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap, bool compress, BlockdevOnError on_source_error, BlockdevOnError on_target_error, int creation_flags, BlockCompletionFunc *cb, void *opaque, BlockJobTxn *txn, Error **errp) { int64_t len; BlockDriverInfo bdi; BackupBlockJob *job = NULL; int ret; assert(bs); assert(target); if (bs == target) { error_setg(errp, "Source and target cannot be the same"); return NULL; } if (!bdrv_is_inserted(bs)) { error_setg(errp, "Device is not inserted: %s", bdrv_get_device_name(bs)); return NULL; } if (!bdrv_is_inserted(target)) { error_setg(errp, "Device is not inserted: %s", bdrv_get_device_name(target)); return NULL; } if (compress && target->drv->bdrv_co_pwritev_compressed == NULL) { error_setg(errp, "Compression is not supported for this drive %s", bdrv_get_device_name(target)); return NULL; } if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp)) { return NULL; } if (bdrv_op_is_blocked(target, BLOCK_OP_TYPE_BACKUP_TARGET, errp)) { return NULL; } if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) { if (!sync_bitmap) { error_setg(errp, "must provide a valid bitmap name for " "\"incremental\" sync mode"); return NULL; } if (bdrv_dirty_bitmap_create_successor(bs, sync_bitmap, errp) < 0) { return NULL; } } else if (sync_bitmap) { error_setg(errp, "a sync_bitmap was provided to backup_run, " "but received an incompatible sync_mode (%s)", MirrorSyncMode_lookup[sync_mode]); return NULL; } len = bdrv_getlength(bs); if (len < 0) { error_setg_errno(errp, -len, "unable to get length for '%s'", bdrv_get_device_name(bs)); goto error; } job = block_job_create(job_id, &backup_job_driver, bs, BLK_PERM_CONSISTENT_READ, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED | BLK_PERM_GRAPH_MOD, speed, creation_flags, cb, opaque, errp); if (!job) { goto error; } job->target = blk_new(BLK_PERM_WRITE, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED | BLK_PERM_GRAPH_MOD); ret = blk_insert_bs(job->target, target, errp); if (ret < 0) { goto error; } job->on_source_error = on_source_error; job->on_target_error = on_target_error; job->sync_mode = sync_mode; job->sync_bitmap = sync_mode == MIRROR_SYNC_MODE_INCREMENTAL ? sync_bitmap : NULL; job->compress = compress; ret = bdrv_get_info(target, &bdi); if (ret == -ENOTSUP && !target->backing) { error_report("WARNING: The target block device doesn't provide " "information about the block size and it doesn't have a " "backing file. The default block size of %u bytes is " "used. If the actual block size of the target exceeds " "this default, the backup may be unusable", BACKUP_CLUSTER_SIZE_DEFAULT); job->cluster_size = BACKUP_CLUSTER_SIZE_DEFAULT; } else if (ret < 0 && !target->backing) { error_setg_errno(errp, -ret, "Couldn't determine the cluster size of the target image, " "which has no backing file"); error_append_hint(errp, "Aborting, since this may create an unusable destination image\n"); goto error; } else if (ret < 0 && target->backing) { job->cluster_size = BACKUP_CLUSTER_SIZE_DEFAULT; } else { job->cluster_size = MAX(BACKUP_CLUSTER_SIZE_DEFAULT, bdi.cluster_size); } block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL, &error_abort); job->common.len = len; block_job_txn_add_job(txn, &job->common); return &job->common; error: if (sync_bitmap) { bdrv_reclaim_dirty_bitmap(bs, sync_bitmap, NULL); } if (job) { backup_clean(&job->common); block_job_early_fail(&job->common); } return NULL; }
1threat