problem
stringlengths
26
131k
labels
class label
2 classes
int pit_get_mode(PITState *pit, int channel) { PITChannelState *s = &pit->channels[channel]; return s->mode; }
1threat
void ff_read_frame_flush(AVFormatContext *s) { AVStream *st; int i, j; flush_packet_queue(s); s->cur_st = NULL; for(i = 0; i < s->nb_streams; i++) { st = s->streams[i]; if (st->parser) { av_parser_close(st->parser); st->parser = NULL; av_free_packet(&st->cur_pkt); } st->last_IP_pts = AV_NOPTS_VALUE; st->cur_dts = AV_NOPTS_VALUE; st->reference_dts = AV_NOPTS_VALUE; st->cur_ptr = NULL; st->cur_len = 0; st->probe_packets = MAX_PROBE_PACKETS; for(j=0; j<MAX_REORDER_DELAY+1; j++) st->pts_buffer[j]= AV_NOPTS_VALUE; } }
1threat
av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) { int i, j; ff_check_alignment(); #if CONFIG_ENCODERS if (avctx->bits_per_raw_sample == 10) { c->fdct = ff_jpeg_fdct_islow_10; c->fdct248 = ff_fdct248_islow_10; } else { if(avctx->dct_algo==FF_DCT_FASTINT) { c->fdct = ff_fdct_ifast; c->fdct248 = ff_fdct_ifast248; } else if(avctx->dct_algo==FF_DCT_FAAN) { c->fdct = ff_faandct; c->fdct248 = ff_faandct248; } else { c->fdct = ff_jpeg_fdct_islow_8; c->fdct248 = ff_fdct248_islow_8; } } #endif if (avctx->bits_per_raw_sample == 10) { c->idct_put = ff_simple_idct_put_10; c->idct_add = ff_simple_idct_add_10; c->idct = ff_simple_idct_10; c->idct_permutation_type = FF_NO_IDCT_PERM; } else { if(avctx->idct_algo==FF_IDCT_INT){ c->idct_put= ff_jref_idct_put; c->idct_add= ff_jref_idct_add; c->idct = ff_j_rev_dct; c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; }else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER ) && avctx->idct_algo==FF_IDCT_VP3){ c->idct_put= ff_vp3_idct_put_c; c->idct_add= ff_vp3_idct_add_c; c->idct = ff_vp3_idct_c; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(avctx->idct_algo==FF_IDCT_WMV2){ c->idct_put= ff_wmv2_idct_put_c; c->idct_add= ff_wmv2_idct_add_c; c->idct = ff_wmv2_idct_c; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(avctx->idct_algo==FF_IDCT_FAAN){ c->idct_put= ff_faanidct_put; c->idct_add= ff_faanidct_add; c->idct = ff_faanidct; c->idct_permutation_type= FF_NO_IDCT_PERM; }else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) { c->idct_put= ff_ea_idct_put_c; c->idct_permutation_type= FF_NO_IDCT_PERM; }else{ c->idct_put = ff_simple_idct_put_8; c->idct_add = ff_simple_idct_add_8; c->idct = ff_simple_idct_8; c->idct_permutation_type= FF_NO_IDCT_PERM; } } c->diff_pixels = diff_pixels_c; c->put_pixels_clamped = ff_put_pixels_clamped_c; c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_c; c->add_pixels_clamped = ff_add_pixels_clamped_c; c->sum_abs_dctelem = sum_abs_dctelem_c; c->gmc1 = gmc1_c; c->gmc = ff_gmc_c; c->pix_sum = pix_sum_c; c->pix_norm1 = pix_norm1_c; c->fill_block_tab[0] = fill_block16_c; c->fill_block_tab[1] = fill_block8_c; c->pix_abs[0][0] = pix_abs16_c; c->pix_abs[0][1] = pix_abs16_x2_c; c->pix_abs[0][2] = pix_abs16_y2_c; c->pix_abs[0][3] = pix_abs16_xy2_c; c->pix_abs[1][0] = pix_abs8_c; c->pix_abs[1][1] = pix_abs8_x2_c; c->pix_abs[1][2] = pix_abs8_y2_c; c->pix_abs[1][3] = pix_abs8_xy2_c; c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c; c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c; c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c; c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c; c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c; c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c; c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c; c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c; c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c; c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c; c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c; c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c; c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c; c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c; c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c; c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c; c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c; c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c; #define dspfunc(PFX, IDX, NUM) \ c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \ c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \ c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \ c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \ c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \ c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \ c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \ c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \ c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \ c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \ c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \ c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \ c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \ c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \ c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \ c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c dspfunc(put_qpel, 0, 16); dspfunc(put_no_rnd_qpel, 0, 16); dspfunc(avg_qpel, 0, 16); dspfunc(put_qpel, 1, 8); dspfunc(put_no_rnd_qpel, 1, 8); dspfunc(avg_qpel, 1, 8); #undef dspfunc #if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER ff_mlp_init(c, avctx); #endif #if CONFIG_WMV2_DECODER || CONFIG_VC1_DECODER ff_intrax8dsp_init(c,avctx); #endif c->put_mspel_pixels_tab[0]= ff_put_pixels8x8_c; c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c; c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c; c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c; c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c; c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c; c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c; c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c; #define SET_CMP_FUNC(name) \ c->name[0]= name ## 16_c;\ c->name[1]= name ## 8x8_c; SET_CMP_FUNC(hadamard8_diff) c->hadamard8_diff[4]= hadamard8_intra16_c; c->hadamard8_diff[5]= hadamard8_intra8x8_c; SET_CMP_FUNC(dct_sad) SET_CMP_FUNC(dct_max) #if CONFIG_GPL SET_CMP_FUNC(dct264_sad) #endif c->sad[0]= pix_abs16_c; c->sad[1]= pix_abs8_c; c->sse[0]= sse16_c; c->sse[1]= sse8_c; c->sse[2]= sse4_c; SET_CMP_FUNC(quant_psnr) SET_CMP_FUNC(rd) SET_CMP_FUNC(bit) c->vsad[0]= vsad16_c; c->vsad[4]= vsad_intra16_c; c->vsad[5]= vsad_intra8_c; c->vsse[0]= vsse16_c; c->vsse[4]= vsse_intra16_c; c->vsse[5]= vsse_intra8_c; c->nsse[0]= nsse16_c; c->nsse[1]= nsse8_c; #if CONFIG_DWT ff_dsputil_init_dwt(c); #endif c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c; c->add_bytes= add_bytes_c; c->diff_bytes= diff_bytes_c; c->add_hfyu_median_prediction= add_hfyu_median_prediction_c; c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c; c->add_hfyu_left_prediction = add_hfyu_left_prediction_c; c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c; c->bswap_buf= bswap_buf; c->bswap16_buf = bswap16_buf; if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) { c->h263_h_loop_filter= h263_h_loop_filter_c; c->h263_v_loop_filter= h263_v_loop_filter_c; } if (CONFIG_VP3_DECODER) { c->vp3_h_loop_filter= ff_vp3_h_loop_filter_c; c->vp3_v_loop_filter= ff_vp3_v_loop_filter_c; c->vp3_idct_dc_add= ff_vp3_idct_dc_add_c; } c->h261_loop_filter= h261_loop_filter_c; c->try_8x8basis= try_8x8basis_c; c->add_8x8basis= add_8x8basis_c; #if CONFIG_VORBIS_DECODER c->vorbis_inverse_coupling = ff_vorbis_inverse_coupling; #endif #if CONFIG_AC3_DECODER c->ac3_downmix = ff_ac3_downmix_c; #endif c->vector_fmul_reverse = vector_fmul_reverse_c; c->vector_fmul_add = vector_fmul_add_c; c->vector_fmul_window = vector_fmul_window_c; c->vector_clipf = vector_clipf_c; c->scalarproduct_int16 = scalarproduct_int16_c; c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c; c->apply_window_int16 = apply_window_int16_c; c->vector_clip_int32 = vector_clip_int32_c; c->scalarproduct_float = scalarproduct_float_c; c->butterflies_float = butterflies_float_c; c->butterflies_float_interleave = butterflies_float_interleave_c; c->vector_fmul_scalar = vector_fmul_scalar_c; c->shrink[0]= av_image_copy_plane; c->shrink[1]= ff_shrink22; c->shrink[2]= ff_shrink44; c->shrink[3]= ff_shrink88; c->prefetch= just_return; memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab)); memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab)); #undef FUNC #undef FUNCC #define FUNC(f, depth) f ## _ ## depth #define FUNCC(f, depth) f ## _ ## depth ## _c #define dspfunc1(PFX, IDX, NUM, depth)\ c->PFX ## _pixels_tab[IDX][0] = FUNCC(PFX ## _pixels ## NUM , depth);\ c->PFX ## _pixels_tab[IDX][1] = FUNCC(PFX ## _pixels ## NUM ## _x2 , depth);\ c->PFX ## _pixels_tab[IDX][2] = FUNCC(PFX ## _pixels ## NUM ## _y2 , depth);\ c->PFX ## _pixels_tab[IDX][3] = FUNCC(PFX ## _pixels ## NUM ## _xy2, depth) #define dspfunc2(PFX, IDX, NUM, depth)\ c->PFX ## _pixels_tab[IDX][ 0] = FUNCC(PFX ## NUM ## _mc00, depth);\ c->PFX ## _pixels_tab[IDX][ 1] = FUNCC(PFX ## NUM ## _mc10, depth);\ c->PFX ## _pixels_tab[IDX][ 2] = FUNCC(PFX ## NUM ## _mc20, depth);\ c->PFX ## _pixels_tab[IDX][ 3] = FUNCC(PFX ## NUM ## _mc30, depth);\ c->PFX ## _pixels_tab[IDX][ 4] = FUNCC(PFX ## NUM ## _mc01, depth);\ c->PFX ## _pixels_tab[IDX][ 5] = FUNCC(PFX ## NUM ## _mc11, depth);\ c->PFX ## _pixels_tab[IDX][ 6] = FUNCC(PFX ## NUM ## _mc21, depth);\ c->PFX ## _pixels_tab[IDX][ 7] = FUNCC(PFX ## NUM ## _mc31, depth);\ c->PFX ## _pixels_tab[IDX][ 8] = FUNCC(PFX ## NUM ## _mc02, depth);\ c->PFX ## _pixels_tab[IDX][ 9] = FUNCC(PFX ## NUM ## _mc12, depth);\ c->PFX ## _pixels_tab[IDX][10] = FUNCC(PFX ## NUM ## _mc22, depth);\ c->PFX ## _pixels_tab[IDX][11] = FUNCC(PFX ## NUM ## _mc32, depth);\ c->PFX ## _pixels_tab[IDX][12] = FUNCC(PFX ## NUM ## _mc03, depth);\ c->PFX ## _pixels_tab[IDX][13] = FUNCC(PFX ## NUM ## _mc13, depth);\ c->PFX ## _pixels_tab[IDX][14] = FUNCC(PFX ## NUM ## _mc23, depth);\ c->PFX ## _pixels_tab[IDX][15] = FUNCC(PFX ## NUM ## _mc33, depth) #define BIT_DEPTH_FUNCS(depth, dct)\ c->get_pixels = FUNCC(get_pixels ## dct , depth);\ c->draw_edges = FUNCC(draw_edges , depth);\ c->emulated_edge_mc = FUNC (ff_emulated_edge_mc , depth);\ c->clear_block = FUNCC(clear_block ## dct , depth);\ c->clear_blocks = FUNCC(clear_blocks ## dct , depth);\ c->add_pixels8 = FUNCC(add_pixels8 ## dct , depth);\ c->add_pixels4 = FUNCC(add_pixels4 ## dct , depth);\ c->put_no_rnd_pixels_l2[0] = FUNCC(put_no_rnd_pixels16_l2, depth);\ c->put_no_rnd_pixels_l2[1] = FUNCC(put_no_rnd_pixels8_l2 , depth);\ \ c->put_h264_chroma_pixels_tab[0] = FUNCC(put_h264_chroma_mc8 , depth);\ c->put_h264_chroma_pixels_tab[1] = FUNCC(put_h264_chroma_mc4 , depth);\ c->put_h264_chroma_pixels_tab[2] = FUNCC(put_h264_chroma_mc2 , depth);\ c->avg_h264_chroma_pixels_tab[0] = FUNCC(avg_h264_chroma_mc8 , depth);\ c->avg_h264_chroma_pixels_tab[1] = FUNCC(avg_h264_chroma_mc4 , depth);\ c->avg_h264_chroma_pixels_tab[2] = FUNCC(avg_h264_chroma_mc2 , depth);\ \ dspfunc1(put , 0, 16, depth);\ dspfunc1(put , 1, 8, depth);\ dspfunc1(put , 2, 4, depth);\ dspfunc1(put , 3, 2, depth);\ dspfunc1(put_no_rnd, 0, 16, depth);\ dspfunc1(put_no_rnd, 1, 8, depth);\ dspfunc1(avg , 0, 16, depth);\ dspfunc1(avg , 1, 8, depth);\ dspfunc1(avg , 2, 4, depth);\ dspfunc1(avg , 3, 2, depth);\ dspfunc1(avg_no_rnd, 0, 16, depth);\ dspfunc1(avg_no_rnd, 1, 8, depth);\ \ dspfunc2(put_h264_qpel, 0, 16, depth);\ dspfunc2(put_h264_qpel, 1, 8, depth);\ dspfunc2(put_h264_qpel, 2, 4, depth);\ dspfunc2(put_h264_qpel, 3, 2, depth);\ dspfunc2(avg_h264_qpel, 0, 16, depth);\ dspfunc2(avg_h264_qpel, 1, 8, depth);\ dspfunc2(avg_h264_qpel, 2, 4, depth); switch (avctx->bits_per_raw_sample) { case 9: if (c->dct_bits == 32) { BIT_DEPTH_FUNCS(9, _32); } else { BIT_DEPTH_FUNCS(9, _16); } break; case 10: if (c->dct_bits == 32) { BIT_DEPTH_FUNCS(10, _32); } else { BIT_DEPTH_FUNCS(10, _16); } break; default: BIT_DEPTH_FUNCS(8, _16); break; } if (HAVE_MMX) ff_dsputil_init_mmx (c, avctx); if (ARCH_ARM) ff_dsputil_init_arm (c, avctx); if (HAVE_VIS) ff_dsputil_init_vis (c, avctx); if (ARCH_ALPHA) ff_dsputil_init_alpha (c, avctx); if (ARCH_PPC) ff_dsputil_init_ppc (c, avctx); if (HAVE_MMI) ff_dsputil_init_mmi (c, avctx); if (ARCH_SH4) ff_dsputil_init_sh4 (c, avctx); if (ARCH_BFIN) ff_dsputil_init_bfin (c, avctx); for (i = 0; i < 4; i++) { for (j = 0; j < 16; j++) { if(!c->put_2tap_qpel_pixels_tab[i][j]) c->put_2tap_qpel_pixels_tab[i][j] = c->put_h264_qpel_pixels_tab[i][j]; if(!c->avg_2tap_qpel_pixels_tab[i][j]) c->avg_2tap_qpel_pixels_tab[i][j] = c->avg_h264_qpel_pixels_tab[i][j]; } } ff_init_scantable_permutation(c->idct_permutation, c->idct_permutation_type); }
1threat
WebSocket server does not work with SSL : <p>I have a working chat application using websockets. I want to go one step further and enable encryption on my connections, however when I switch up the http server with a https one my connections start failing.</p> <p>I have generated a self-signed certificate that I use on all of my websites (under the same TLD, which implies it is a wildcard certificate). I can confirm it is a valid certificate, so the problem should not be there.</p> <p>This is what works (unencrypted)</p> <pre><code>var webSocketServer = require('websocket').server; var http = require('http'); var server = http.createServer(function() {}); server.listen(webSocketsServerPort, function () { log("system", "Server is listening on port " + webSocketsServerPort); }); var wsServer = new webSocketServer({ httpServer: server }); </code></pre> <p>Using this I can now connect to <code>ws://my.domain:port</code>. </p> <p>This is what does <strong>not</strong> work</p> <pre><code>var webSocketServer = require('websocket').server; var http = require('https'); var fs = require('fs'); var server = http.createServer({ key: fs.readFileSync("path/to/host.key"), cert: fs.readFileSync("path/to/host.pem") }); server.listen(webSocketsServerPort, function () { log("system", "Server is listening on port " + webSocketsServerPort); }); var wsServer = new webSocketServer({ httpServer: server }); </code></pre> <p>With this code the server starts as well, I see the log message "Server is listening.." but when I try to connect at <code>wss://my.domain:port</code> the connection can not be established.</p> <p>I have added an exception in my browser for the certificate because my client page and websocket server address are under the same tld and sub-domain.</p> <p>What could be the problem?</p>
0debug
How to solve the following mathematical operation on a given number? : <p>I have tried to write a code in python which will accept a number of any number of digits like abcde and will give the result as a-b+c-d+e.<strong><em>If the number is 5624 then result will be 5-6+2-4 ie -3</em></strong>.I would like to get the answer where my problem is and how to solve that problem modifying my code.</p> <p><strong>I would like the method I have approached to it. No other method to solve the same problem.</strong> </p> <pre><code>num=(input("enter a number")) l=len(num)-1 p=l num = int(num) q=num for x in range(0,l+1): q=q/10; r=q%10; a[p]=r p-=1 for y in range(0,l): if (y/2==0): sum=sum +a[y] else: sum=sum-a[y] print(sum) </code></pre> <p><strong><em>It is giving me error saying my list assignment index is going out of range.</em></strong></p>
0debug
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int size) { if (size < 0 || avpkt->size < 0 || size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { av_log(avctx, AV_LOG_ERROR, "Size %d invalid\n", size); return AVERROR(EINVAL); } if (avctx) { av_assert0(!avpkt->data || avpkt->data != avctx->internal->byte_buffer); if (!avpkt->data || avpkt->size < size) { av_fast_padded_malloc(&avctx->internal->byte_buffer, &avctx->internal->byte_buffer_size, size); avpkt->data = avctx->internal->byte_buffer; avpkt->size = avctx->internal->byte_buffer_size; avpkt->destruct = NULL; } } if (avpkt->data) { AVBufferRef *buf = avpkt->buf; #if FF_API_DESTRUCT_PACKET void *destruct = avpkt->destruct; #endif if (avpkt->size < size) { av_log(avctx, AV_LOG_ERROR, "User packet is too small (%d < %d)\n", avpkt->size, size); return AVERROR(EINVAL); } av_init_packet(avpkt); #if FF_API_DESTRUCT_PACKET avpkt->destruct = destruct; #endif avpkt->buf = buf; avpkt->size = size; return 0; } else { int ret = av_new_packet(avpkt, size); if (ret < 0) av_log(avctx, AV_LOG_ERROR, "Failed to allocate packet of size %d\n", size); return ret; } }
1threat
same logic used in java doesn't work in python : i'm a beginner and i've been practicing a little bit doing the exercises on this website : **http://www.w3resource.com/python-exercises/python-conditional-statements-and-loop-exercises.php** My question concerns exercise #19 where the following is asked : [enter image description here][1] I actually run the same logic mentioned bellow on Java and it worked ! i can't understand why it won't work in python :/ import os List = [0,1,2,3,4,5,6] for i in List: if i==0 or i==6: for j in range(1,5): print "*", print("") if i==3: for k in range(1,4): print "*", print("") else: print "*", print("") os.system("pause") THANK YOU ALL ! :) [1]: https://i.stack.imgur.com/CzvxM.png
0debug
static void qmp_chardev_open_udp(Chardev *chr, ChardevBackend *backend, bool *be_opened, Error **errp) { ChardevUdp *udp = backend->u.udp.data; QIOChannelSocket *sioc = qio_channel_socket_new(); char *name; UdpChardev *s = UDP_CHARDEV(chr); if (qio_channel_socket_dgram_sync(sioc, udp->local, udp->remote, errp) < 0) { object_unref(OBJECT(sioc)); return; } name = g_strdup_printf("chardev-udp-%s", chr->label); qio_channel_set_name(QIO_CHANNEL(sioc), name); g_free(name); s->ioc = QIO_CHANNEL(sioc); *be_opened = false; }
1threat
Can some suggest me how to pick uniq hash value with one more condition : Eg: h = [{:a=>"Hello", :b=>false}, {:a=>"Hello", :b=>true}, {:a=>"H1", :b=>false}] I want to get unique values based on key "a" and also the value of b should be true If I use `h.uniq {|hash| hash.values_at(:a)}` -> This will fetch the first uniq hash, where as I want the hash with b should be true [{:a=>"Hello", :b=>false}, {:a=>"H1", :b=>false}] I want this one as end result `[{:a=>"Hello", :b=>true}, {:a=>"H1", :b=>false}]` instead of `[{:a=>"Hello", :b=>false}, {:a=>"H1", :b=>false}]`.
0debug
How to change a placeholder in loop input? : This is my first question, Look at this form and tell me How to set a unique URL placeholder to every new URL input added by the function! Thanks <html> <input class="name" type='text' placeholder="First name" required> <input class="name" type='text' placeholder="Last name" required><br> <input type="email" placeholder="example@mail.com" required><br> <div id="url"> </div> <button id="bu">add Products urls</button> </html> <script> var url = document.getElementById('url'), counter = 1, but = document.getElementById('bu'); but.onclick = function () { 'use strict'; url.innerHTML += 'Product' + counter + ' <input type="url" placeholder="url"> <br>'; counter++; }; </script>
0debug
How to use UNPIVOT in Sql Server : I have a table 'StoreDetails' with the following data. ------------------------------- Store 1 2 3 ------------------------------- 101 138 282 220 102 96 212 123 105 37 78 60 109 59 97 87 ------------------------------- My required Output is.. --------------------------------- Store Week xCount --------------------------------- 101 1 138 102 1 96 105 1 37 109 1 59 101 2 282 102 2 212 105 2 78 109 2 97 101 3 220 102 3 123 105 3 60 109 3 87 --------------------------------- How can i get this result set using UNPIVOT ?
0debug
void ff_estimate_p_frame_motion(MpegEncContext * s, int mb_x, int mb_y) { MotionEstContext * const c= &s->me; uint8_t *pix, *ppix; int sum, mx, my, dmin; int varc; int vard; int P[10][2]; const int shift= 1+s->quarter_sample; int mb_type=0; Picture * const pic= &s->current_picture; init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0); assert(s->quarter_sample==0 || s->quarter_sample==1); assert(s->linesize == c->stride); assert(s->uvlinesize == c->uvstride); c->penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp); c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp); c->mb_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->mb_cmp); c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV; get_limits(s, 16*mb_x, 16*mb_y); c->skip=0; pix = c->src[0][0]; sum = s->dsp.pix_sum(pix, s->linesize); varc = s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500; pic->mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8; pic->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8; c->mb_var_sum_temp += (varc+128)>>8; if(c->avctx->me_threshold){ vard= check_input_motion(s, mb_x, mb_y, 1); if((vard+128)>>8 < c->avctx->me_threshold){ int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100); int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20; pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8; c->mc_mb_var_sum_temp += (vard+128)>>8; c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score); return; } if((vard+128)>>8 < c->avctx->mb_threshold) mb_type= s->mb_type[mb_x + mb_y*s->mb_stride]; } switch(s->me_method) { case ME_ZERO: default: no_motion_search(s, &mx, &my); mx-= mb_x*16; my-= mb_y*16; dmin = 0; break; case ME_X1: case ME_EPZS: { const int mot_stride = s->b8_stride; const int mot_xy = s->block_index[0]; P_LEFT[0] = s->current_picture.f.motion_val[0][mot_xy - 1][0]; P_LEFT[1] = s->current_picture.f.motion_val[0][mot_xy - 1][1]; if(P_LEFT[0] > (c->xmax<<shift)) P_LEFT[0] = (c->xmax<<shift); if(!s->first_slice_line) { P_TOP[0] = s->current_picture.f.motion_val[0][mot_xy - mot_stride ][0]; P_TOP[1] = s->current_picture.f.motion_val[0][mot_xy - mot_stride ][1]; P_TOPRIGHT[0] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + 2][0]; P_TOPRIGHT[1] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + 2][1]; if(P_TOP[1] > (c->ymax<<shift)) P_TOP[1] = (c->ymax<<shift); if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift); if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[1]= (c->ymax<<shift); P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]); P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]); if(s->out_format == FMT_H263){ c->pred_x = P_MEDIAN[0]; c->pred_y = P_MEDIAN[1]; }else { c->pred_x= P_LEFT[0]; c->pred_y= P_LEFT[1]; } }else{ c->pred_x= P_LEFT[0]; c->pred_y= P_LEFT[1]; } } dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, s->p_mv_table, (1<<16)>>shift, 0, 16); break; } ppix = c->ref[0][0] + (my * s->linesize) + mx; vard = s->dsp.sse[0](NULL, pix, ppix, s->linesize, 16); pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8; c->mc_mb_var_sum_temp += (vard+128)>>8; if(mb_type){ int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100); int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20; c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score); if(mb_type == CANDIDATE_MB_TYPE_INTER){ c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16); set_p_mv_tables(s, mx, my, 1); }else{ mx <<=shift; my <<=shift; } if(mb_type == CANDIDATE_MB_TYPE_INTER4V){ h263_mv4_search(s, mx, my, shift); set_p_mv_tables(s, mx, my, 0); } if(mb_type == CANDIDATE_MB_TYPE_INTER_I){ interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 1); } }else if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){ int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100); int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20; c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score); if (vard*2 + 200*256 > varc) mb_type|= CANDIDATE_MB_TYPE_INTRA; if (varc*2 + 200*256 > vard || s->qscale > 24){ mb_type|= CANDIDATE_MB_TYPE_INTER; c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16); if(s->flags&CODEC_FLAG_MV0) if(mx || my) mb_type |= CANDIDATE_MB_TYPE_SKIPPED; }else{ mx <<=shift; my <<=shift; } if((s->flags&CODEC_FLAG_4MV) && !c->skip && varc>50<<8 && vard>10<<8){ if(h263_mv4_search(s, mx, my, shift) < INT_MAX) mb_type|=CANDIDATE_MB_TYPE_INTER4V; set_p_mv_tables(s, mx, my, 0); }else set_p_mv_tables(s, mx, my, 1); if((s->flags&CODEC_FLAG_INTERLACED_ME) && !c->skip){ if(interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 0) < INT_MAX) mb_type |= CANDIDATE_MB_TYPE_INTER_I; } }else{ int intra_score, i; mb_type= CANDIDATE_MB_TYPE_INTER; dmin= c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16); if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip) dmin= ff_get_mb_score(s, mx, my, 0, 0, 0, 16, 1); if((s->flags&CODEC_FLAG_4MV) && !c->skip && varc>50<<8 && vard>10<<8){ int dmin4= h263_mv4_search(s, mx, my, shift); if(dmin4 < dmin){ mb_type= CANDIDATE_MB_TYPE_INTER4V; dmin=dmin4; } } if((s->flags&CODEC_FLAG_INTERLACED_ME) && !c->skip){ int dmin_i= interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 0); if(dmin_i < dmin){ mb_type = CANDIDATE_MB_TYPE_INTER_I; dmin= dmin_i; } } set_p_mv_tables(s, mx, my, mb_type!=CANDIDATE_MB_TYPE_INTER4V); if((c->avctx->mb_cmp&0xFF)==FF_CMP_SSE){ intra_score= varc - 500; }else{ int mean= (sum+128)>>8; mean*= 0x01010101; for(i=0; i<16; i++){ *(uint32_t*)(&c->scratchpad[i*s->linesize+ 0]) = mean; *(uint32_t*)(&c->scratchpad[i*s->linesize+ 4]) = mean; *(uint32_t*)(&c->scratchpad[i*s->linesize+ 8]) = mean; *(uint32_t*)(&c->scratchpad[i*s->linesize+12]) = mean; } intra_score= s->dsp.mb_cmp[0](s, c->scratchpad, pix, s->linesize, 16); } intra_score += c->mb_penalty_factor*16; if(intra_score < dmin){ mb_type= CANDIDATE_MB_TYPE_INTRA; s->current_picture.f.mb_type[mb_y*s->mb_stride + mb_x] = CANDIDATE_MB_TYPE_INTRA; }else s->current_picture.f.mb_type[mb_y*s->mb_stride + mb_x] = 0; { int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100); int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20; c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score); } } s->mb_type[mb_y*s->mb_stride + mb_x]= mb_type; }
1threat
How to override local connection string with azure connection string at runtime? : <p>I have written connection string in appsettings.json for .Net core project. My connection string is :</p> <pre><code> "ConnectionStrings": { "OT_DB_Connection": "Data Source=108.***.**.**;Initial Catalog=O*******s;User ID=O*******s;Password=O*********$" </code></pre> <p>},</p> <p>I am accessing this connection string in startup.cs file as shown below.</p> <pre><code>options.UseSqlServer(Configuration.GetConnectionString("OT_DB_Connection")); </code></pre> <p>Now i deployed this website on azure and i have separate database on azure and i want that my website will to connect to azure database at runtime by overriding the local connection string.</p> <p>Please suggest how i can achieve this.</p> <p>Thanks</p>
0debug
Unable to cast COM object of type 'CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass' : <p>I have 2 windows program.</p> <p>Program A : create with visual studio 2015 with crystal report SP18</p> <p>Program B : create with visual studio 2017 with crystal report SP22</p> <p>I have a computer with crystal report runtime SP 18.</p> <p>I run program A in that computer. Program A can create report. I run program B in that computer. Program B cannot create report. So, i upgrade the crystal report runtime to SP22. The result is Program B can create report.</p> <p>Now the problem is Program A cannot create report after the upgrade. The error is :</p> <pre><code>System.InvalidCastException: Unable to cast COM object of type 'CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass' to interface type 'CrystalDecisions.ReportAppServer.Controllers.ISCRReportSource'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{98CDE168-C1BF-4179-BE4C-F2CFA7CB8398}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr&amp; ppTarget, Boolean&amp; pfNeedsRelease) at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Refresh() at CrystalDecisions.ReportSource.EromReportSourceBase.Refresh(RequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.FormatEngine.Refresh(RequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.ReportDocument.Refresh() at CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(Object val, Type type) at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type) at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataTable dataTable) at Portal_Inkaso.frIndex.PerintahCetakTT() at Portal_Inkaso.frIndex.Perintah1() at Portal_Inkaso.frIndex.llbPerintah_LinkClicked(Object sender, LinkLabelLinkClickedEventArgs e) at System.Windows.Forms.LinkLabel.OnLinkClicked(LinkLabelLinkClickedEventArgs e) at System.Windows.Forms.LinkLabel.OnMouseUp(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message&amp; m) at System.Windows.Forms.Label.WndProc(Message&amp; m) at System.Windows.Forms.LinkLabel.WndProc(Message&amp; msg) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) </code></pre> <p>What should i do ? Downgrade crystall report runtime or what ?</p>
0debug
Include my css files with javascript : I upload a picture of my problem. The page insights always says, that my css files are slowing down my sites download. Whats the solution for this? How sould i add theese files with javascript, or async mode? My js files, like jquery also, are at the body closing tag at the page bottom. [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/kSANk.jpg
0debug
IE11 gives SCRIPT1002 error when defining class in javascript : <p>I have some trouble with IE11 and a static javascript class I wrote.</p> <p>The error I get is:</p> <blockquote> <p>SCRIPT1002: Syntax error rgmui.box.js (6,1)</p> </blockquote> <p>Which points to: </p> <pre><code>// =========================================== // RGMUI BOX // Static class class RgMuiBox { ^ </code></pre> <p>So I'm guessing I'm defining this class in the wrong way? What's the correct way of doing this?</p> <p>I found a post on SO that seems to point out that the issue is ES5 vs ES6 - and I figure IE11 doesn't support ES6?</p> <p>Just to be complete, this is what I have (simplified):</p> <pre><code>class RgMuiBox { static method1() { // .. code .. } } </code></pre> <p>Thanks!</p>
0debug
static void t_gen_cris_dstep(TCGv d, TCGv a, TCGv b) { int l1; l1 = gen_new_label(); tcg_gen_shli_tl(d, a, 1); tcg_gen_brcond_tl(TCG_COND_LTU, d, b, l1); tcg_gen_sub_tl(d, d, b); gen_set_label(l1); }
1threat
document.write('<script src="evil.js"></script>');
1threat
How do _Post an array with PHP PDO prepared statements : Goodday all I’m working on an app and get stuck with updating values in a mysql database. When i add the name attribute manually(value1) it works fine. But when i ‘_POST’ an array i get an error on the line beneath and i’m stucked here. $stmt = $conn->prepare<code>("UPDATE students SET value=value+{$_POST['value']}");</code> Error: Notice: Array to string conversion on line 8 Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'value' in 'field list' For execute: <code>$stmt->execute(array("value", $_POST['value']));</code><br><br> This is my HTML: <input class="input" id="id1" name="value[]" type="range"> <input class="input" id="id2" name="value[]" type="range"> <input class="input" id="id3" name="value[]" type="range"> </html> The columns in mysql database are value1, value2, value3 and so on. For send the form i use PHP PDO prepared statements. Thanks in advance.
0debug
static void blkverify_aio_cb(void *opaque, int ret) { BlkverifyAIOCB *acb = opaque; switch (++acb->done) { case 1: acb->ret = ret; break; case 2: if (acb->ret != ret) { blkverify_err(acb, "return value mismatch %d != %d", acb->ret, ret); } if (acb->verify) { acb->verify(acb); } aio_bh_schedule_oneshot(bdrv_get_aio_context(acb->common.bs), blkverify_aio_bh, acb); break; } }
1threat
LF_FUNC (h, luma, sse2) LF_IFUNC(h, luma_intra, sse2) LF_FUNC (v, luma, sse2) LF_IFUNC(v, luma_intra, sse2) #define H264_WEIGHT(W, H, OPT) \ void ff_h264_weight_ ## W ## x ## H ## _ ## OPT(uint8_t *dst, \ int stride, int log2_denom, int weight, int offset); #define H264_BIWEIGHT(W, H, OPT) \ void ff_h264_biweight_ ## W ## x ## H ## _ ## OPT(uint8_t *dst, \ uint8_t *src, int stride, int log2_denom, int weightd, \ int weights, int offset); #define H264_BIWEIGHT_MMX(W,H) \ H264_WEIGHT (W, H, mmx2) \ H264_BIWEIGHT(W, H, mmx2) #define H264_BIWEIGHT_MMX_SSE(W,H) \ H264_BIWEIGHT_MMX(W, H) \ H264_WEIGHT (W, H, sse2) \ H264_BIWEIGHT (W, H, sse2) \ H264_BIWEIGHT (W, H, ssse3) H264_BIWEIGHT_MMX_SSE(16, 16) H264_BIWEIGHT_MMX_SSE(16, 8) H264_BIWEIGHT_MMX_SSE( 8, 16) H264_BIWEIGHT_MMX_SSE( 8, 8) H264_BIWEIGHT_MMX_SSE( 8, 4) H264_BIWEIGHT_MMX ( 4, 8) H264_BIWEIGHT_MMX ( 4, 4) H264_BIWEIGHT_MMX ( 4, 2) void ff_h264dsp_init_x86(H264DSPContext *c) { int mm_flags = av_get_cpu_flags(); if (mm_flags & AV_CPU_FLAG_MMX) { c->h264_idct_dc_add= c->h264_idct_add= ff_h264_idct_add_mmx; c->h264_idct8_dc_add= c->h264_idct8_add= ff_h264_idct8_add_mmx; c->h264_idct_add16 = ff_h264_idct_add16_mmx; c->h264_idct8_add4 = ff_h264_idct8_add4_mmx; c->h264_idct_add8 = ff_h264_idct_add8_mmx; c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx; if (mm_flags & AV_CPU_FLAG_MMX2) { c->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2; c->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2; c->h264_idct_add16 = ff_h264_idct_add16_mmx2; c->h264_idct8_add4 = ff_h264_idct8_add4_mmx2; c->h264_idct_add8 = ff_h264_idct_add8_mmx2; c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx2; c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2; } if(mm_flags & AV_CPU_FLAG_SSE2){ c->h264_idct8_add = ff_h264_idct8_add_sse2; c->h264_idct8_add4= ff_h264_idct8_add4_sse2; } #if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX2){ c->h264_v_loop_filter_chroma= ff_x264_deblock_v_chroma_mmxext; c->h264_h_loop_filter_chroma= ff_x264_deblock_h_chroma_mmxext; c->h264_v_loop_filter_chroma_intra= ff_x264_deblock_v_chroma_intra_mmxext; c->h264_h_loop_filter_chroma_intra= ff_x264_deblock_h_chroma_intra_mmxext; #if ARCH_X86_32 c->h264_v_loop_filter_luma= ff_x264_deblock_v_luma_mmxext; c->h264_h_loop_filter_luma= ff_x264_deblock_h_luma_mmxext; c->h264_v_loop_filter_luma_intra = ff_x264_deblock_v_luma_intra_mmxext; c->h264_h_loop_filter_luma_intra = ff_x264_deblock_h_luma_intra_mmxext; #endif c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2; c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2; c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2; c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2; c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2; c->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2; c->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2; c->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2; c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2; c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2; c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2; c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2; c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2; c->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2; c->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2; c->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2; if (mm_flags&AV_CPU_FLAG_SSE2) { c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_sse2; c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_sse2; c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_sse2; c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_sse2; c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_sse2; c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_sse2; c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_sse2; c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_sse2; c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_sse2; c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_sse2; #if ARCH_X86_64 || !defined(__ICC) || __ICC > 1110 c->h264_v_loop_filter_luma = ff_x264_deblock_v_luma_sse2; c->h264_h_loop_filter_luma = ff_x264_deblock_h_luma_sse2; c->h264_v_loop_filter_luma_intra = ff_x264_deblock_v_luma_intra_sse2; c->h264_h_loop_filter_luma_intra = ff_x264_deblock_h_luma_intra_sse2; #endif c->h264_idct_add16 = ff_h264_idct_add16_sse2; c->h264_idct_add8 = ff_h264_idct_add8_sse2; c->h264_idct_add16intra = ff_h264_idct_add16intra_sse2; } if (mm_flags&AV_CPU_FLAG_SSSE3) { c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_ssse3; c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_ssse3; c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_ssse3; c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_ssse3; c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_ssse3; } } #endif } }
1threat
Visual Basic build error : I get 2 errors at line 70 and line 74 of making a keygenerator for XP Repair Pro6 when i finisherd every thing and built it it shows me these two errors 1. TextBox2.Text = Generate(Strings.LCase(TextBox1.Text), Strings.LCase(MD5("xprp6-K0Wc0kf3Wcm5g-FEe43f"))) 'MD5' is a type and cannot be used as an expression. 2. Public Shared Function MD5(ByVal InputStr As String) As String Statement is not valid in a namespace. Please help, thanks
0debug
Circular dependency injection angular 2 : <p>I've been struggling around injecting <code>services</code> into each other. The following blog <a href="http://misko.hevery.com/2008/08/01/circular-dependency-in-constructors-and-dependency-injection/" rel="noreferrer">Circular Dependency in constructors and Dependency Injection</a> is kind of confusing where it says </p> <blockquote> <p>One of the two objects is hiding another object C</p> </blockquote> <p>I get the following error while injecting Service class into each other</p> <blockquote> <p>Can't resolve all parameters for PayrollService: (SiteService, StorageService, SweetAlertService, ?)</p> </blockquote> <pre><code>//abstractmodal.service.ts @Injectable() export abstract class AbstractModel { abstract collection = []; constructor(private siteService: SiteService, private storageService: StorageService, private sweetalertService: SweetAlertService) {} setCollectionEmpty() { this.collection = []; } } //account-payable.service.ts @Injectable() export class AccountPayableService extends AbstractModel { public collection = []; constructor(private sS: SiteService,private stS: StorageService, private sws: SweetAlertService, private accpPoService: PayablePurchaseOrderService, private attachmentService: AttachmentService, private injectorService: InjectorService) { super(sS, stS, sws); } } //injector.service.ts @Injectable() export class InjectorService { constructor(private payrollService: PayrollService) {} cleanPayrollCollection() { this.payrollService.setCollectionEmpty(); } } //payroll.service.ts @Injectable() export class PayrollService extends AbstractModel { public collection = []; constructor(private sS: SiteService,private stS: StorageService, private sws: SweetAlertService, private accpService: AccountPayableService) { super(sS, stS, sws); } } </code></pre> <p>Your comments and answered will be appreciated a lot.</p> <p>Thanks</p>
0debug
How to convert batch to exe programmatically : <p>I want to know how I can convert a .bat file to a .exe file programmatically in Java, I'mm trying to make a Batch IDE.</p> <p>Thanks!</p>
0debug
Google apps script replyAll on existing thread without replyTo : [`google-apps-script`](https://stackoverflow.com/questions/tagged/google-apps-script) ## Scenario * Create a one script that can send a email as per user selection on google spread sheet. [![enter image description here][1]][1] * Subject line prefix : "Report : ", postfix : "Current Date". * When user going to send email first time in a day must send a new email. * If going to send second time check subject line if already exists then must be `replyAll` to that email. ## Created Script Link : [GitHub](https://gist.github.com/Jaydeep1434/c160c2302ca09663fc5d2f298f79f035) * This script create a menu `onOpen` "Send Mail". * So, when user can select some area from sheet and click on "Send Mail" button it calling `funShowAlert()` and send a email. ## Issue * If I add `replyTo` it will generate issue for `gmail`. * If I remove `replyTo` then, how do I perform `replyAll` from script ? > Question : anyway to perform `replyAll` without `replyTo` _OR_ I am doing something wrong with `replyTo` ? [1]: https://i.stack.imgur.com/sYe9r.png
0debug
How do I declare multiple maintainers in my Dockerfile? : <p>How can I best indicate that there are multiple authors/maintainers of a docker image built using a <code>Dockerfile</code>? If I include multiple separate <code>MAINTAINER</code> commands, only the last one seems to take effect.</p> <pre><code>MAINTAINER Me Myself "myself@example.com" MAINTAINER My Colleague "mycolleague@example.com" </code></pre> <p>Only <code>mycolleague</code> shows up in the output of <code>docker inspect</code>.</p> <p>Should I use a comma delimited list in a single <code>MAINTAINER</code> line? Is wanting to list two maintainers a boondoggle and I should just armwrestle my colleague to see whose email we put in the file?</p>
0debug
Best performance multiple Sort Order By in C# : i have one list around 1mil record with multiple columns name (Date, Name, Value, Id,.....) My question: What's the best solution for sort order by with multiple columns Example: list.orderbyDesc(name).thenBy(Name).thenby(Value).... Thanks everyone.
0debug
Using jq to fetch key value from json output : <p>I have a file that looks as below:</p> <pre><code>{ "repositories": [ { "id": "156c48fc-f208-43e8-a631-4d12deb89fa4", "namespace": "rhel12", "namespaceType": "organization", "name": "rhel6.6", "shortDescription": "", "visibility": "public" }, { "id": "f359b5d2-cb3a-4bb3-8aff-d879d51f1a04", "namespace": "rhel12", "namespaceType": "organization", "name": "rhel7", "shortDescription": "", "visibility": "public" } ] } </code></pre> <p>I want to get only name values with each of them in a new line so that I can use <code>while read -r line</code>. I need only </p> <pre><code>rhel6.6 rhel7 </code></pre> <p>I am using jq as follows which doesn't seem to work:</p> <pre><code>jq -r '.[].name' </code></pre> <p>Please suggest correct use of jq here</p>
0debug
static int local_set_mapped_file_attr(FsContext *ctx, const char *path, FsCred *credp) { FILE *fp; int ret = 0; char buf[ATTR_MAX]; char attr_path[PATH_MAX]; int uid = -1, gid = -1, mode = -1, rdev = -1; fp = local_fopen(local_mapped_attr_path(ctx, path, attr_path), "r"); if (!fp) { goto create_map_file; } memset(buf, 0, ATTR_MAX); while (fgets(buf, ATTR_MAX, fp)) { if (!strncmp(buf, "virtfs.uid", 10)) { uid = atoi(buf+11); } else if (!strncmp(buf, "virtfs.gid", 10)) { gid = atoi(buf+11); } else if (!strncmp(buf, "virtfs.mode", 11)) { mode = atoi(buf+12); } else if (!strncmp(buf, "virtfs.rdev", 11)) { rdev = atoi(buf+12); } memset(buf, 0, ATTR_MAX); } fclose(fp); goto update_map_file; create_map_file: ret = local_create_mapped_attr_dir(ctx, path); if (ret < 0) { goto err_out; } update_map_file: fp = local_fopen(attr_path, "w"); if (!fp) { ret = -1; goto err_out; } if (credp->fc_uid != -1) { uid = credp->fc_uid; } if (credp->fc_gid != -1) { gid = credp->fc_gid; } if (credp->fc_mode != -1) { mode = credp->fc_mode; } if (credp->fc_rdev != -1) { rdev = credp->fc_rdev; } if (uid != -1) { fprintf(fp, "virtfs.uid=%d\n", uid); } if (gid != -1) { fprintf(fp, "virtfs.gid=%d\n", gid); } if (mode != -1) { fprintf(fp, "virtfs.mode=%d\n", mode); } if (rdev != -1) { fprintf(fp, "virtfs.rdev=%d\n", rdev); } fclose(fp); err_out: return ret; }
1threat
document.getElementById('input').innerHTML = user_input;
1threat
How to Execute a SQL query while a Data Reader is opened ? : I'd like to know how can I execute a sql Query while a data reader is opened. code : using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Console.WriteLine(String.Format(" Id Bracelet :{0} | Id Client: {1} | First Name: {2} | Last Name: {3}", reader["IdBracelet"], reader["IdClient"], reader["FirstName"], reader["LastName"])); al.Add(reader["IdBracelet"]); } while (true){ Y.Function(); string strQueryInsert = "Insert into TableZ(xxx, xx, xxxx, xxxxx, xxxxxx) values (@xxx, @xx, @xxxx, @xxxxx, @xxxxxx)"; SqlCommand cmd = new SqlCommand(strQueryInsert, connection); cmd.Parameters.AddWithValue("@xxx", xxx); cmd.Parameters.AddWithValue("@xx", xx); cmd.Parameters.AddWithValue("@xxxx", xxxx); cmd.Parameters.AddWithValue("@xxxxx", xxxxx); cmd.Parameters.AddWithValue("@xxxxxx", xxxxxx); cmd.ExecuteNonQuery(); Thread.Sleep(5000); } } I get this error : System.InvalidOperationException: 'There is already an open DataReader associated with this Command which must be closed first.' I need the query to be executed within the reader because I store the values that the reader return in a List and then use those values. If anybody knows how to fix it , might be very helpful , thanks
0debug
AVFilter **av_filter_next(AVFilter **filter) { return filter ? ++filter : &registered_avfilters[0]; }
1threat
Opening ICS file with multiple events creates new calendar in Outlook : <p>I would like to be able to create an ICS file <strong>with multiple events</strong> that user will be able to import in their <strong>default</strong> Exchange Calendar. I need to support Outlook desktop client, Office 365 web interface and Apple iPhone Mail/Calendar. </p> <p>Note that issue only occurs with ICS files that contain multiple events. Single event ICS works as expected.</p> <p>Following multi-event ICS file:</p> <pre><code>BEGIN:VCALENDAR VERSION:2.0 PRODID:-//bobbin v0.1//NONSGML iCal Writer//EN CALSCALE:GREGORIAN METHOD:PUBLISH BEGIN:VEVENT DTSTART:20180327T080000Z DTEND:20180327T110000Z DTSTAMP:20091130T213238Z UID:1285935469767a7c7c1a9b3f0df8003a@yourserver.com CREATED:20091130T213238Z DESCRIPTION:Example event 1 LAST-MODIFIED:20091130T213238Z SEQUENCE:0 STATUS:CONFIRMED SUMMARY:Example event 1 TRANSP:OPAQUE END:VEVENT BEGIN:VEVENT DTSTART:20180328T120000Z DTEND:20180328T130000Z DTSTAMP:20091130T213238Z UID:1285935469767a7c7c1a9b3f0df8003b@yourserver.com CREATED:20091130T213238Z DESCRIPTION:Example event 2 LAST-MODIFIED:20091130T213238Z SEQUENCE:0 STATUS:CONFIRMED SUMMARY:Example event 2 TRANSP:OPAQUE END:VEVENT END:VCALENDAR </code></pre> <p>works fine in Office 365 web interface and Apple iPhone Mail/Calendar. However, when it is imported in Outlook 2016 it creates a new "Untitled" Calendar and puts events in it instead of default user calendar.</p> <p>This seems to be a known issue referenced previously on SO:</p> <p><a href="https://stackoverflow.com/questions/9212329/ical-import-creates-new-calendar-when-open-the-ics-file">ICal import creates new calendar When Open the ics file</a></p> <p><a href="https://stackoverflow.com/questions/21484689/have-ics-file-with-multiple-events-save-to-my-calendar-not-other-calendars">Have ICS file with multiple events save to my Calendar, not Other Calendars</a></p> <p>Answers range from "it cannot be done" to the opposite.</p> <p>One of the posts in the first link mentions removing <code>X-WR-CALNAME</code> from ICS fixes the problem. I never had this in ICS to begin with.</p> <p>Another post on the same page mentions that adding <code>X-WR-RELCALID:XXXXXX</code> fixes it. I tried putting it in and it makes no difference at all. I am not sure if value for X-WR-RELCALID should be set to something specific - I just set it to some GUID.</p> <p>If someone successfully resolved it - can you post an ICS sample and what version of Outlook did it work with?</p>
0debug
Why invalid syntax in line 5? : <p>Whats the syntax error in line 5?? I have tried everything already... Anybody knows?</p> <pre><code>print ("a. Dolar --&gt; Euro\nb. Euro --&gt; Dolar\n") opti = input("Pick an option: ") val = float(input("Enter value: ") if opti == "a": convr = 0.895 print (str(convr * val) + " Euros") elif opti == "b": convr = 1/0.895 print (str(convr * val) + " Dollars") else: print ("NOT ALLOWED!") </code></pre>
0debug
What is the location of the keystore file in Android Studio? : <p>I just recently found out the importance of backing up the keystore file in Android Studio. I have two apps published using this computer. Both times I simply used "Generate APK" in Android Studio Build drop down. I would really appreciate some instructions on where exactly can I find the keystore file that Android Studio used to sign those apks with and what else do I need to do to be able to publish updates to my apps from PC's other than this one. Thank you.</p>
0debug
sql 2012 - varchar to date : I am running views against a table that has dates stored as varchar(8) as DDMMYYYY, can someone please tell me how do I convert them to date format? Thanks
0debug
what is the difference between io.cucumber and info.cukes : <p>I am trying to integrate BDD using Cucumber. But I am really confused what is the difference between <strong>io.cucumber</strong> and <strong>info.cukes</strong> libraries. And which one to use and when.</p> <p>I tried to read and understand the github <a href="https://github.com/cucumber/cucumber-jvm" rel="noreferrer">README.md</a> file still can't make heads or tails.</p> <p>Still further I am not sure what is cucumber-jvm. Why do we need cucumber-junit (can't the standalone junit library suffice).</p> <p>Thanks in advance. Any help is much appreciated.</p>
0debug
I need to calculate each students average grade : <pre><code>/*This code creates two text files : Mokiniai.txt and Vidurkiai.txt In Mokiniai.txt there are stored each students grades, in Vidurkiai there should be calculated each students average grade*/ #include "stdafx.h" #include &lt;iostream&gt; #include &lt;fstream&gt; using namespace std; int main() { int n, k, isvisopazymiu, i, pazymiai; double vidurkis; //average grade ofstream myfile; myfile.open("Mokiniai.txt"); cout &lt;&lt; "parasykite kiek mokiniu yra" &lt;&lt; endl; cin &gt;&gt; n; //how many students myfile &lt;&lt; n &lt;&lt; endl; cout &lt;&lt; "parasykite kiek yra mokiniu pazymiu"; cin &gt;&gt; isvisopazymiu; // how many grades one student has for (k = 1; k &lt;= n; k++) { for (i = 1; i &lt;= isvisopazymiu; i++) { cout &lt;&lt; "Parasykite kokie yra mokiniu pazymiai "; cin &gt;&gt; pazymiai; // what are students grades myfile &lt;&lt; " " &lt;&lt; pazymiai; } myfile &lt;&lt; endl; } myfile.close(); myfile.open("Vidurkiai.txt"); //trying to calculate average students grades on different file for (k = 1; k &lt;= n; k++) { vidurkis = pazymiai / isvisopazymiu; //calculating students grades myfile &lt;&lt; k &lt;&lt; " " &lt;&lt; vidurkis &lt;&lt; endl; } myfile.close(); return 0; } </code></pre> <p>My problem is that: There is something wrong in vidurkiai.txt file, but I don't know what is wrong.</p> <p>For example: first students grades are : 7 8 9 7 8, and average grade should be 7,8, but after coding it, in vidurkiai.txt file it shows, that average grade is 1.</p>
0debug
static int virtio_pci_set_host_notifier(void *opaque, int n, bool assign) { VirtIOPCIProxy *proxy = opaque; VirtQueue *vq = virtio_get_queue(proxy->vdev, n); EventNotifier *notifier = virtio_queue_get_host_notifier(vq); int r; if (assign) { r = event_notifier_init(notifier, 1); if (r < 0) { return r; } r = kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier), proxy->addr + VIRTIO_PCI_QUEUE_NOTIFY, n, assign); if (r < 0) { event_notifier_cleanup(notifier); } } else { r = kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier), proxy->addr + VIRTIO_PCI_QUEUE_NOTIFY, n, assign); if (r < 0) { return r; } event_notifier_cleanup(notifier); } return r; }
1threat
How to get single record id in sql?i want to get single records id only : SELECT * FROM st_master_seed_crop_dtls m WHERE m.mast_sdcd_crop_category IN ('Notified Variety','comarket','Imported','Private Variety','Storage','Transgenic Variety') AND mast_sdcd_crop_category='Private Variety' GROUP BY m.mast_sdcd_license_id_fk HAVING COUNT(m.mast_sdcd_crop_category) <=1 [enter image description here][1] [1]: https://i.stack.imgur.com/lcCcM.png
0debug
void raise_irq_cpu_hotplug(void) { qemu_irq_raise(irq_cpu_hotplug); }
1threat
static uint32_t scoop_readb(void *opaque, target_phys_addr_t addr) { ScoopInfo *s = (ScoopInfo *) opaque; switch (addr) { case SCOOP_MCR: return s->mcr; case SCOOP_CDR: return s->cdr; case SCOOP_CSR: return s->status; case SCOOP_CPR: return s->power; case SCOOP_CCR: return s->ccr; case SCOOP_IRR_IRM: return s->irr; case SCOOP_IMR: return s->imr; case SCOOP_ISR: return s->isr; case SCOOP_GPCR: return s->gpio_dir; case SCOOP_GPWR: case SCOOP_GPRR: return s->gpio_level; default: zaurus_printf("Bad register offset " REG_FMT "\n", (unsigned long)addr); } return 0; }
1threat
How to remove duplicates from an unordered Immutable.List()? : <p>How would one remove duplicates from an unordered Immutable.List()? (without using toJS() or toArray())</p> <p>e.g.</p> <pre><code>Immutable.List.of("green", "blue","green","black", "blue") </code></pre>
0debug
static int dnxhd_decode_macroblock(const DNXHDContext *ctx, RowContext *row, AVFrame *frame, int x, int y) { int shift1 = ctx->bit_depth == 10; int dct_linesize_luma = frame->linesize[0]; int dct_linesize_chroma = frame->linesize[1]; uint8_t *dest_y, *dest_u, *dest_v; int dct_y_offset, dct_x_offset; int qscale, i, act; int interlaced_mb = 0; if (ctx->mbaff) { interlaced_mb = get_bits1(&row->gb); qscale = get_bits(&row->gb, 10); } else qscale = get_bits(&row->gb, 11); act = get_bits1(&row->gb); if (act) { static int warned = 0; if (!warned) { warned = 1; av_log(ctx->avctx, AV_LOG_ERROR, "Unsupported adaptive color transform, patch welcome.\n"); } } if (qscale != row->last_qscale) { for (i = 0; i < 64; i++) { row->luma_scale[i] = qscale * ctx->cid_table->luma_weight[i]; row->chroma_scale[i] = qscale * ctx->cid_table->chroma_weight[i]; } row->last_qscale = qscale; } for (i = 0; i < 8 + 4 * ctx->is_444; i++) { ctx->decode_dct_block(ctx, row, i); } if (frame->interlaced_frame) { dct_linesize_luma <<= 1; dct_linesize_chroma <<= 1; } dest_y = frame->data[0] + ((y * dct_linesize_luma) << 4) + (x << (4 + shift1)); dest_u = frame->data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444)); dest_v = frame->data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444)); if (frame->interlaced_frame && ctx->cur_field) { dest_y += frame->linesize[0]; dest_u += frame->linesize[1]; dest_v += frame->linesize[2]; } if (interlaced_mb) { dct_linesize_luma <<= 1; dct_linesize_chroma <<= 1; } dct_y_offset = interlaced_mb ? frame->linesize[0] : (dct_linesize_luma << 3); dct_x_offset = 8 << shift1; if (!ctx->is_444) { ctx->idsp.idct_put(dest_y, dct_linesize_luma, row->blocks[0]); ctx->idsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, row->blocks[1]); ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, row->blocks[4]); ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, row->blocks[5]); if (!(ctx->avctx->flags & AV_CODEC_FLAG_GRAY)) { dct_y_offset = interlaced_mb ? frame->linesize[1] : (dct_linesize_chroma << 3); ctx->idsp.idct_put(dest_u, dct_linesize_chroma, row->blocks[2]); ctx->idsp.idct_put(dest_v, dct_linesize_chroma, row->blocks[3]); ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, row->blocks[6]); ctx->idsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, row->blocks[7]); } } else { ctx->idsp.idct_put(dest_y, dct_linesize_luma, row->blocks[0]); ctx->idsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, row->blocks[1]); ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, row->blocks[6]); ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, row->blocks[7]); if (!(ctx->avctx->flags & AV_CODEC_FLAG_GRAY)) { dct_y_offset = interlaced_mb ? frame->linesize[1] : (dct_linesize_chroma << 3); ctx->idsp.idct_put(dest_u, dct_linesize_chroma, row->blocks[2]); ctx->idsp.idct_put(dest_u + dct_x_offset, dct_linesize_chroma, row->blocks[3]); ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, row->blocks[8]); ctx->idsp.idct_put(dest_u + dct_y_offset + dct_x_offset, dct_linesize_chroma, row->blocks[9]); ctx->idsp.idct_put(dest_v, dct_linesize_chroma, row->blocks[4]); ctx->idsp.idct_put(dest_v + dct_x_offset, dct_linesize_chroma, row->blocks[5]); ctx->idsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, row->blocks[10]); ctx->idsp.idct_put(dest_v + dct_y_offset + dct_x_offset, dct_linesize_chroma, row->blocks[11]); } } return 0; }
1threat
cron expression in AWS CloudWatch: How to run once a week : <p>In Amazon AWS CloudWatch it is possible to run a rule according to a schedule that is defined in a cron expression.</p> <p>The rules for this are outlined <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/ScheduledEvents.html" rel="noreferrer">here</a>.</p> <p>After some trying around, I wasn't able to compose an expression that will run <strong>once a week</strong> (e.g. at 4 pm on Sunday). The following attempts were rejected by CloudWatch with the message <code>Parameter ScheduleExpression is not valid..</code>.</p> <pre><code>0 16 * * SUN * 0 16 * * 6 * 0 16 * * SUN-SUN * 0 16 * * 6-6 * </code></pre>
0debug
static void qio_channel_websock_handshake_process(QIOChannelWebsock *ioc, char *buffer, Error **errp) { QIOChannelWebsockHTTPHeader hdrs[32]; size_t nhdrs = G_N_ELEMENTS(hdrs); const char *protocols = NULL, *version = NULL, *key = NULL, *host = NULL, *connection = NULL, *upgrade = NULL; nhdrs = qio_channel_websock_extract_headers(ioc, buffer, hdrs, nhdrs, errp); if (!nhdrs) { return; } protocols = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL); if (!protocols) { error_setg(errp, "Missing websocket protocol header data"); goto bad_request; } version = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_VERSION); if (!version) { error_setg(errp, "Missing websocket version header data"); goto bad_request; } key = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_KEY); if (!key) { error_setg(errp, "Missing websocket key header data"); goto bad_request; } host = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_HOST); if (!host) { error_setg(errp, "Missing websocket host header data"); goto bad_request; } connection = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_CONNECTION); if (!connection) { error_setg(errp, "Missing websocket connection header data"); goto bad_request; } upgrade = qio_channel_websock_find_header( hdrs, nhdrs, QIO_CHANNEL_WEBSOCK_HEADER_UPGRADE); if (!upgrade) { error_setg(errp, "Missing websocket upgrade header data"); goto bad_request; } if (!g_strrstr(protocols, QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY)) { error_setg(errp, "No '%s' protocol is supported by client '%s'", QIO_CHANNEL_WEBSOCK_PROTOCOL_BINARY, protocols); goto bad_request; } if (!g_str_equal(version, QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION)) { error_setg(errp, "Version '%s' is not supported by client '%s'", QIO_CHANNEL_WEBSOCK_SUPPORTED_VERSION, version); goto bad_request; } if (strlen(key) != QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN) { error_setg(errp, "Key length '%zu' was not as expected '%d'", strlen(key), QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN); goto bad_request; } if (!g_strrstr(connection, QIO_CHANNEL_WEBSOCK_CONNECTION_UPGRADE)) { error_setg(errp, "No connection upgrade requested '%s'", connection); goto bad_request; } if (!g_str_equal(upgrade, QIO_CHANNEL_WEBSOCK_UPGRADE_WEBSOCKET)) { error_setg(errp, "Incorrect upgrade method '%s'", upgrade); goto bad_request; } qio_channel_websock_handshake_send_res_ok(ioc, key, errp); return; bad_request: qio_channel_websock_handshake_send_res_err( ioc, QIO_CHANNEL_WEBSOCK_HANDSHAKE_RES_BAD_REQUEST); }
1threat
static void close_decoder(QSVContext *q) { QSVFrame *cur; if (q->session) MFXVideoDECODE_Close(q->session); while (q->async_fifo && av_fifo_size(q->async_fifo)) { QSVFrame *out_frame; mfxSyncPoint *sync; av_fifo_generic_read(q->async_fifo, &out_frame, sizeof(out_frame), NULL); av_fifo_generic_read(q->async_fifo, &sync, sizeof(sync), NULL); av_freep(&sync); } cur = q->work_frames; while (cur) { q->work_frames = cur->next; av_frame_free(&cur->frame); av_freep(&cur); cur = q->work_frames; } q->engine_ready = 0; q->reinit_pending = 0; }
1threat
Monitoring the asyncio event loop : <p>I am writing an application using python3 and am trying out asyncio for the first time. One issue I have encountered is that some of my coroutines block the event loop for longer than I like. I am trying to find something along the lines of top for the event loop that will show how much wall/cpu time is being spent running each of my coroutines. If there isn't anything already existing does anyone know of a way to add hooks to the event loop so that I can take measurements?</p> <p>I have tried using cProfile which gives some helpful output, but I am more interested in time spent blocking the event loop, rather than total execution time.</p>
0debug
How to Create a Sell Button Code In Visual Studio C# with MySql as database : Hi Im Using Visual Studio C# and Im Having conflict on how to create a sell button as well how can I get the total amount of product that had been sold here is my code try { if (txtID.Text != "" && txtCategory.Text != "" && txtName.Text != "" && txtQty.Text != "" && txtQty.Text != "" && PriceText.Text != "" && SuppNameText.Text != "") { con.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO Sold_Inventory (ProductName,Description,Category,Quantity_Sold,Price,TotalAmount,SuppliersName) VALUES(@ProductName,@Description,@Category,@Quantity,@Price,@Supplier)WHERE TotalAmount = @Quantity * @Price", con); cmd.Parameters.AddWithValue("@ProductName", txtID.Text); cmd.Parameters.AddWithValue("@Description", txtName.Text); cmd.Parameters.AddWithValue("@Category", txtCategory.Text); cmd.Parameters.AddWithValue("@Quantity", txtQty.Text); cmd.Parameters.AddWithValue("@Price", PriceText.Text); cmd.Parameters.AddWithValue("@Supplier", SuppNameText.Text); cmd.ExecuteNonQuery(); SqlCommand cmd1 = new SqlCommand("Update Quantity FROM Inventory SET Quantity = Quantity - @Quantity"); cmd1.Parameters.AddWithValue("@Quantity", txtQty.Text); cmd1.ExecuteNonQuery(); con.Close(); ClearTextbox(); btnSearch.Enabled = true; txtSearch.Enabled = true; groupBox4.Enabled = true; btnSubmit.Enabled = false; btnCancel.Enabled = false; ClearTextbox(); DisabledTextbox(); btnAdd.Enabled = true; RefreshDGV(this.dataGridView1); } else { MessageBox.Show("You left an empty field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); }
0debug
static void nbd_recv_coroutines_enter_all(BlockDriverState *bs) { NBDClientSession *s = nbd_get_client_session(bs); int i; for (i = 0; i < MAX_NBD_REQUESTS; i++) { if (s->recv_coroutine[i]) { qemu_coroutine_enter(s->recv_coroutine[i]); } } BDRV_POLL_WHILE(bs, s->read_reply_co); }
1threat
Equivalent of dynamic type "automatically adjusts font" setting for UIButton in Interface Builder? : <p>A UILabel has a <code>Dynamic Type: Automatically Adjusts Font</code> check-box in the Attributes Inspector in Interface Builder.</p> <p>Is there an equivalent in Interface Builder for automatically adjusting the font size of a UIButton, or does this have to be handled in code?</p> <p>I'm using Xcode 9.0 beta 6, targeting iOS 11.</p>
0debug
static int process_frame_obj(SANMVideoContext *ctx) { uint16_t codec, top, left, w, h; codec = bytestream2_get_le16u(&ctx->gb); left = bytestream2_get_le16u(&ctx->gb); top = bytestream2_get_le16u(&ctx->gb); w = bytestream2_get_le16u(&ctx->gb); h = bytestream2_get_le16u(&ctx->gb); if (ctx->width < left + w || ctx->height < top + h) { if (av_image_check_size(FFMAX(left + w, ctx->width), FFMAX(top + h, ctx->height), 0, ctx->avctx) < 0) avcodec_set_dimensions(ctx->avctx, FFMAX(left + w, ctx->width), FFMAX(top + h, ctx->height)); init_sizes(ctx, FFMAX(left + w, ctx->width), FFMAX(top + h, ctx->height)); if (init_buffers(ctx)) { av_log(ctx->avctx, AV_LOG_ERROR, "error resizing buffers\n"); return AVERROR(ENOMEM); bytestream2_skip(&ctx->gb, 4); av_dlog(ctx->avctx, "subcodec %d\n", codec); switch (codec) { case 1: case 3: return old_codec1(ctx, top, left, w, h); break; case 37: return old_codec37(ctx, top, left, w, h); break; case 47: return old_codec47(ctx, top, left, w, h); break; default: avpriv_request_sample(ctx->avctx, "unknown subcodec %d", codec); return AVERROR_PATCHWELCOME;
1threat
document.write('<script src="evil.js"></script>');
1threat
Why is this 'if' statement printing "Impossible"? : <pre><code>public class Experiment5 { private static int countChar(String string, char c) { int count = 0; for (int i = 0; i &lt; string.length(); i++) { if (string.charAt(i) == c) { count++; } } return count; } public static void main(String[] args) { Scanner scan = new Scanner(System.in); String input = scan.nextLine(); if (countChar(input, '_') &gt; 0){ if ((countChar(input, 'X') - countChar(input, '0') &gt;= 2) || (countChar(input, '0') - countChar(input, 'X') &gt;= 2) ) { System.out.println("Impossible"); return; } System.out.println("Game not finished"); } } </code></pre> <p>Input: <br> XO_OOX_X_ <br> <br> I believe that the result should be "Game not finished" because the difference between the counts of 'X' and 'O' is 0. <br> Then why is this returning "Impossible"? <br> <br> Thank you for your help.</p>
0debug
Structs with enums are different in C and C++, why? : <p>The task is to send data by I2C from Arduino to STM32.</p> <p>So I got Struct and Enums defined in Arduino using C++:</p> <pre class="lang-cpp prettyprint-override"><code>enum PhaseCommands { PHASE_COMMAND_TIMESYNC = 0x01, PHASE_COMMAND_SETPOWER = 0x02, PHASE_COMMAND_CALIBRATE = 0x03 }; enum PhaseTargets { PHASE_CONTROLLER = 0x01, // RESERVED = 0x02, PHASE_LOAD1 = 0x03, PHASE_LOAD2 = 0x04 }; struct saatProtoExec { PhaseTargets target; PhaseCommands commandName; uint32_t commandBody; } phaseCommand; uint8_t phaseCommandBufferSize = sizeof(phaseCommand); phaseCommand.target = PHASE_LOAD1; phaseCommand.commandName = PHASE_COMMAND_SETPOWER; phaseCommand.commandBody = (uint32_t)50; </code></pre> <p>On the other side I got the same defined using C:</p> <pre class="lang-c prettyprint-override"><code>typedef enum { COMMAND_TIMESYNC = 0x01, COMMAND_SETPOWER = 0x02, COMMAND_CALIBRATE = 0x03 } MasterCommands; typedef enum { CONTROLLER = 0x01, // RESERVED = 0x02, LOAD1 = 0x03, LOAD2 = 0x04 } Targets; struct saatProtoExec { Targets target; MasterCommands commandName; uint32_t commandBody; } execCommand; uint8_t execBufferSize = sizeof(execCommand); execCommand.target = LOAD1; execCommand.commandName = COMMAND_SETPOWER; execCommand.commandBody = 50; </code></pre> <p>And then I compare this Structs byte-by-byte:</p> <pre class="lang-none prettyprint-override"><code>===================== BYTE | C++ | C ===================== Byte 0 -&gt; 0x3 -&gt; 0x3 Byte 1 -&gt; 0x0 -&gt; 0x2 Byte 2 -&gt; 0x2 -&gt; 0x0 Byte 3 -&gt; 0x0 -&gt; 0x0 Byte 4 -&gt; 0x32 -&gt; 0x32 Byte 5 -&gt; 0x0 -&gt; 0x0 Byte 6 -&gt; 0x0 -&gt; 0x0 Byte 7 -&gt; 0x0 -&gt; 0x0 </code></pre> <p>So why bytes 1 and 2 are different?</p>
0debug
lambda expression as a parameter c# : I have a collection which I am looping using Parallel foreach. I would like to check each single item in the collection before I pass it on to the loop. I was trying to do something like this, but it gives an error. Any thoughts or suggestions? Parallel.ForEach(testCollection, (perform a check on each item in the collection) => DoSomething with the checked item) Thanks.
0debug
static inline void set_p_mv_tables(MpegEncContext * s, int mx, int my) { const int xy= s->mb_x + 1 + (s->mb_y + 1)*(s->mb_width + 2); s->p_mv_table[xy][0] = mx; s->p_mv_table[xy][1] = my; if(!(s->flags&CODEC_FLAG_4MV)){ int mot_xy= s->block_index[0]; s->motion_val[mot_xy ][0]= mx; s->motion_val[mot_xy ][1]= my; s->motion_val[mot_xy+1][0]= mx; s->motion_val[mot_xy+1][1]= my; mot_xy += s->block_wrap[0]; s->motion_val[mot_xy ][0]= mx; s->motion_val[mot_xy ][1]= my; s->motion_val[mot_xy+1][0]= mx; s->motion_val[mot_xy+1][1]= my; } }
1threat
Tar file to another directory while keeping the original filename : <p>I've been tasked to help automate some of our archiving process. I am only a beginner in Unix/Linux so I would appreciate some help. One of the request is to tar any files in folder1 and put the tar file into folder2.</p> <p>A single file is dropped in folder 1 every hour. The format is like this: ABC_TIMESTAMP.gz. (However, it may not always be "ABC", it could be BDC or similar).</p> <p>So basically, I need to tar /folder1/ABC_TIMESTAMP.gz to /folder2/ABC_TIMESTAMP.gz.tar.</p> <p>Then finally, delete the original file in folder1.</p>
0debug
JS global variable is not updating inside ajax : <p>This is my code:</p> <p>I based the window variable from <a href="https://stackoverflow.com/questions/5786851/define-global-variable-in-a-javascript-function">here</a></p> <pre><code>&lt;script&gt; $(window).on("load", function() { function myForeverFunc(){ window.global_time = "3"; $.ajax({ url: "index.php?action=showReminder", cache: false, success: function(data){ if(data &amp;&amp; data.charAt(0) === "1"){ window.global_time = "1"; }else{ console.log("test"); window.global_time = "2"; } } }); console.log(window.global_time); } setInterval(myForeverFunc, 60*1000); }); &lt;/script&gt; </code></pre> <p>This just displays "3" where it should have been updated to "2" in the else part of the ajax function.</p>
0debug
static int pci_unin_agp_init_device(SysBusDevice *dev) { UNINState *s; int pci_mem_config, pci_mem_data; s = FROM_SYSBUS(UNINState, dev); pci_mem_config = cpu_register_io_memory(pci_unin_config_read, pci_unin_config_write, s); pci_mem_data = cpu_register_io_memory(pci_unin_main_read, pci_unin_main_write, &s->host_state); sysbus_init_mmio(dev, 0x1000, pci_mem_config); sysbus_init_mmio(dev, 0x1000, pci_mem_data); return 0; }
1threat
void ram_control_load_hook(QEMUFile *f, uint64_t flags) { int ret = 0; if (f->ops->hook_ram_load) { ret = f->ops->hook_ram_load(f, f->opaque, flags); if (ret < 0) { qemu_file_set_error(f, ret); } } else { qemu_file_set_error(f, ret); } }
1threat
static void s390x_cpu_get_id(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { S390CPU *cpu = S390_CPU(obj); int64_t value = cpu->id; visit_type_int(v, name, &value, errp); }
1threat
QList *qobject_to_qlist(const QObject *obj) { if (qobject_type(obj) != QTYPE_QLIST) { return NULL; } return container_of(obj, QList, base); }
1threat
Xcode 9 - Add an App Store icon : <p>i saw this new requirement in itunes connect (next to the <code>App Store Icon</code>):</p> <p><a href="https://i.stack.imgur.com/ftg4W.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ftg4W.png" alt="enter image description here"></a></p> <p>As for now (Xcode 8.3.x) I have AppIcon assets next to the <code>App Icon Source</code></p> <p>Is this requirement means i need to change any thing? or only that from Xcode 9.x.x the <code>App Icon Source</code> and the <code>App store Icons</code> are coupled and there is no option to change the <code>App Store Icon</code> in iTunes connect?</p>
0debug
static void migration_bitmap_sync(void) { uint64_t num_dirty_pages_init = ram_list.dirty_pages; trace_migration_bitmap_sync_start(); memory_global_sync_dirty_bitmap(get_system_memory()); trace_migration_bitmap_sync_end(ram_list.dirty_pages - num_dirty_pages_init); }
1threat
What does a cookie with 1969 as the expiration date mean? : <p><a href="https://i.stack.imgur.com/l5b4I.png" rel="noreferrer"><img src="https://i.stack.imgur.com/l5b4I.png" alt="enter image description here"></a></p> <p>How can a cookie expire in 1969?</p> <p>What does this mean?</p> <p>Thanks,</p>
0debug
python regex to validate hidden filepath : Is there a way to check whether a given file path is hidden using python regex. filepath = "/home/ubuntu/.myfile.txt" if filepath matches with pattern: yes it is hidden file else: No
0debug
static int virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) { SCSIDevice *d = virtio_scsi_device_find(s, req->req.tmf.lun); SCSIRequest *r, *next; BusChild *kid; int target; int ret = 0; if (s->dataplane_started) { assert(blk_get_aio_context(d->conf.blk) == s->ctx); } req->resp.tmf.response = VIRTIO_SCSI_S_OK; virtio_tswap32s(VIRTIO_DEVICE(s), &req->req.tmf.subtype); switch (req->req.tmf.subtype) { case VIRTIO_SCSI_T_TMF_ABORT_TASK: case VIRTIO_SCSI_T_TMF_QUERY_TASK: if (!d) { goto fail; } if (d->lun != virtio_scsi_get_lun(req->req.tmf.lun)) { goto incorrect_lun; } QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) { VirtIOSCSIReq *cmd_req = r->hba_private; if (cmd_req && cmd_req->req.cmd.tag == req->req.tmf.tag) { break; } } if (r) { assert(r->hba_private); if (req->req.tmf.subtype == VIRTIO_SCSI_T_TMF_QUERY_TASK) { req->resp.tmf.response = VIRTIO_SCSI_S_FUNCTION_SUCCEEDED; } else { VirtIOSCSICancelNotifier *notifier; req->remaining = 1; notifier = g_new(VirtIOSCSICancelNotifier, 1); notifier->tmf_req = req; notifier->notifier.notify = virtio_scsi_cancel_notify; scsi_req_cancel_async(r, &notifier->notifier); ret = -EINPROGRESS; } } break; case VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET: if (!d) { goto fail; } if (d->lun != virtio_scsi_get_lun(req->req.tmf.lun)) { goto incorrect_lun; } s->resetting++; qdev_reset_all(&d->qdev); s->resetting--; break; case VIRTIO_SCSI_T_TMF_ABORT_TASK_SET: case VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET: case VIRTIO_SCSI_T_TMF_QUERY_TASK_SET: if (!d) { goto fail; } if (d->lun != virtio_scsi_get_lun(req->req.tmf.lun)) { goto incorrect_lun; } req->remaining = 1; QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) { if (r->hba_private) { if (req->req.tmf.subtype == VIRTIO_SCSI_T_TMF_QUERY_TASK_SET) { req->resp.tmf.response = VIRTIO_SCSI_S_FUNCTION_SUCCEEDED; break; } else { VirtIOSCSICancelNotifier *notifier; req->remaining++; notifier = g_new(VirtIOSCSICancelNotifier, 1); notifier->notifier.notify = virtio_scsi_cancel_notify; notifier->tmf_req = req; scsi_req_cancel_async(r, &notifier->notifier); } } } if (--req->remaining > 0) { ret = -EINPROGRESS; } break; case VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET: target = req->req.tmf.lun[1]; s->resetting++; QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { d = DO_UPCAST(SCSIDevice, qdev, kid->child); if (d->channel == 0 && d->id == target) { qdev_reset_all(&d->qdev); } } s->resetting--; break; case VIRTIO_SCSI_T_TMF_CLEAR_ACA: default: req->resp.tmf.response = VIRTIO_SCSI_S_FUNCTION_REJECTED; break; } return ret; incorrect_lun: req->resp.tmf.response = VIRTIO_SCSI_S_INCORRECT_LUN; return ret; fail: req->resp.tmf.response = VIRTIO_SCSI_S_BAD_TARGET; return ret; }
1threat
static void mpeg_decode_sequence_extension(Mpeg1Context *s1) { MpegEncContext *s = &s1->mpeg_enc_ctx; int horiz_size_ext, vert_size_ext; int bit_rate_ext; skip_bits(&s->gb, 1); s->avctx->profile = get_bits(&s->gb, 3); s->avctx->level = get_bits(&s->gb, 4); s->progressive_sequence = get_bits1(&s->gb); s->chroma_format = get_bits(&s->gb, 2); horiz_size_ext = get_bits(&s->gb, 2); vert_size_ext = get_bits(&s->gb, 2); s->width |= (horiz_size_ext << 12); s->height |= (vert_size_ext << 12); bit_rate_ext = get_bits(&s->gb, 12); s->bit_rate += (bit_rate_ext << 18) * 400; skip_bits1(&s->gb); s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10; s->low_delay = get_bits1(&s->gb); if (s->flags & CODEC_FLAG_LOW_DELAY) s->low_delay = 1; s1->frame_rate_ext.num = get_bits(&s->gb, 2) + 1; s1->frame_rate_ext.den = get_bits(&s->gb, 5) + 1; av_dlog(s->avctx, "sequence extension\n"); s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO; if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_DEBUG, "profile: %d, level: %d ps: %d cf:%d vbv buffer: %d, bitrate:%d\n", s->avctx->profile, s->avctx->level, s->progressive_sequence, s->chroma_format, s->avctx->rc_buffer_size, s->bit_rate); }
1threat
def dig_let(s): d=l=0 for c in s: if c.isdigit(): d=d+1 elif c.isalpha(): l=l+1 else: pass return (l,d)
0debug
linux. many file descriptors when call sys_clone : <p>am create 400 threads using clone with flags SIGCHLD | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_VM</p> <p>and $ losf | wc -l show me 600 000 opened descriptors after runnning</p> <p>what i need to do?</p>
0debug
Global const char pointer array in C/C++ : I have defined a const char pointer array in header file. Array contains multiple strings. Now I have to find a string at particular index. I don't know how should I access this array from another files. Please see my code: common.h extern const char *lookup_str[] = {"test Str0", "test Str1", "test Str2", "test Str3"}; file1.c int ret = 3; std::string r = lookup_str[ret]; Can I use this way in all my C files? Any suggestion/help is much appreciated. Thank you in advance !
0debug
Apply GZIP compression to a CSV in Python Pandas : <p>I am trying to write a dataframe to a gzipped csv in python pandas, using the following:</p> <pre><code>import pandas as pd import datetime import csv import gzip # Get data (with previous connection and script variables) df = pd.read_sql_query(script, conn) # Create today's date, to append to file todaysdatestring = str(datetime.datetime.today().strftime('%Y%m%d')) print todaysdatestring # Create csv with gzip compression df.to_csv('foo-%s.csv.gz' % todaysdatestring, sep='|', header=True, index=False, quoting=csv.QUOTE_ALL, compression='gzip', quotechar='"', doublequote=True, line_terminator='\n') </code></pre> <p>This just creates a csv called 'foo-YYYYMMDD.csv.gz', not an actual gzip archive.</p> <p>I've also tried adding this:</p> <pre><code>#Turn to_csv statement into a variable d = df.to_csv('foo-%s.csv.gz' % todaysdatestring, sep='|', header=True, index=False, quoting=csv.QUOTE_ALL, compression='gzip', quotechar='"', doublequote=True, line_terminator='\n') # Write above variable to gzip with gzip.open('foo-%s.csv.gz' % todaysdatestring, 'wb') as output: output.write(d) </code></pre> <p>Which fails as well. Any ideas? </p>
0debug
Css image positions : <p>I need help<a href="https://i.stack.imgur.com/yj04i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yj04i.png" alt="align.png"></a> to create image alignment like the one in the image.</p>
0debug
Different behaviour of Intl.NumberFormat in node and browser : <p>If I run this code in the browser and node I obtain two different results:</p> <pre class="lang-js prettyprint-override"><code>const moneyFormatter = new Intl.NumberFormat('it-IT', { style: 'currency', currency: 'EUR', minimumFractionDigits: 2 }); moneyFormatter.format(1); </code></pre> <p>Browser: <code>1,00 €</code></p> <p>Node: <code>€1.00</code></p>
0debug
Search and Replace a word within a word in Python. Replace() method not working : <p>How do I search and replace using built-in Python methods?</p> <p>For instance, with a string of appleorangegrapes (yes all of them joined), Replace "apple" with "mango".</p> <p>The .replace method only works if the words are evenly spaced out but not if they are combined as one. Is there a way around this?</p> <p>I searched the web but again the .replace method only gives me an example if they are spaced out.</p> <p>Thank you for looking at the problem!</p>
0debug
Is there a way to return true if the user allows location sharing and false if denied? : <p>I need a javascript function that returns true if the user is sharing the location in the site and return false if not.</p>
0debug
Regular Expression : I want a Regex for my mongoose schema to test if a username contains only letters, numbers and underscore, dash or dot. What I got so far is /[a-zA-Z0-9-_.]/ but somehow it lets pass everything.
0debug
Function "pwr()" is not working properly : <p>I'm new to C and was just making a function "pwr()" to raise a number to the power which are both specified in the program within the parenthesis. A blank screen appears or it just gives a value of 0 and 1 to "First Number" and "Second Number:" respectively.</p> <pre><code>#include&lt;stdio.h&gt; int pwr( int, int); int main(){ int num, numn; num == pwr(5,2); numn == pwr(2,5); printf("First Number:%d\n",num); printf("Second Number:%d\n", numn); return 0; } int pwr(int c,int pr) { int res = 1; int i=0; if(pr&lt;0){ printf("Imaginary\n"); return 0; } for(i=0;i=pr;i++){ res = res*c; } return res; } </code></pre> <p>Can someone tell me my mistake.</p>
0debug
my code on android studio seem to be working ok but getting this error while trying to run it : the code doesn't have any error but it says this while I try to run it"Error running activity the activity must be exported or contain an intent-filter"
0debug
How does adaptive pooling in pytorch work? : <p>Adaptive pooling is a great function, but how does it work? It seems to be inserting pads or shrinking/expanding kernel sizes in what seems like a pattered but fairly arbitrary way. The pytorch documentation I can find is not more descriptive than "put desired output size here." Does anyone know how this works or can point to where it's explained?</p> <p>Some test code on a 1x1x6 tensor, (1,2,3,4,5,6), with an adaptive output of size 8:</p> <pre><code>import torch import torch.nn as nn class TestNet(nn.Module): def __init__(self): super(TestNet, self).__init__() self.avgpool = nn.AdaptiveAvgPool1d(8) def forward(self,x): print(x) x = self.avgpool(x) print(x) return x def test(): x = torch.Tensor([[[1,2,3,4,5,6]]]) net = TestNet() y = net(x) return y test() </code></pre> <p>Output:</p> <pre><code>tensor([[[ 1., 2., 3., 4., 5., 6.]]]) tensor([[[ 1.0000, 1.5000, 2.5000, 3.0000, 4.0000, 4.5000, 5.5000, 6.0000]]]) </code></pre> <p>If it mirror pads by on the left and right (operating on (1,1,2,3,4,5,6,6)), and has a kernel of 2, then the outputs for all positions except for 4 and 5 make sense, except of course the output isn't the right size. Is it also padding the 3 and 4 internally? If so, it's operating on (1,1,2,3,3,4,4,5,6,6), which, if using a size 2 kernel, produces the wrong output size and would also miss a 3.5 output. Is it changing the size of the kernel?</p> <p>Am I missing something obvious about the way this works?</p>
0debug
unsigned int avpriv_toupper4(unsigned int x) { return av_toupper(x & 0xFF) + (av_toupper((x >> 8) & 0xFF) << 8) + (av_toupper((x >> 16) & 0xFF) << 16) + (av_toupper((x >> 24) & 0xFF) << 24); }
1threat
how can i do this using arraylist or array? : i am trying to add some string names to stars arraylist using addStar function in Star class. but i m encountering error like this; *The method add(Star) in the type arraylist<star> is not applicable for this arguments.* eclipse says to me the string parameter is not acceptable, so how can i do this? > import java.util.ArrayList; import java.util.Collection; > > public class Star { public static String name; public static > ArrayList<Star> stars=new ArrayList<>(); > > > public Star(String name) { this.name=name; } > > public static void addStar(String name) { stars.add(name); > > } }
0debug
cannot have return value : <p>I'am trying to make code to make array to multidimensional array. I made 12 size of array B and also made array[3][4]. If call function value(B,3,1), it supposed to return value of array[3][1] or B[10]. But my code doesn't work. I cannot have return value. Help me !!</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int value(int *A, int j, int k); void main(void){ int n = 12; int *B; B=(int*)malloc(sizeof(int)*n); int i; printf("12개의 정수를 차례로 입력하시오.\n"); for(i=0; i&lt;n ;i++ ){ fflush(stdout); scanf("%d",&amp;B[i]); } value(B,3,1); //printf("call\n"); } int value(int *A, int j, int k) { int i; int array[4][3]; for(i=0; i&lt;12; i++){ array[i/3][i%3]=A[i]; } for(i=0; i&lt;12; i++){ printf("%d ",array[i/3][i%3]); } return array[j][k]; } </code></pre>
0debug
static QObject *parse_keyword(JSONParserContext *ctxt) { QObject *token; const char *val; token = parser_context_pop_token(ctxt); assert(token && token_get_type(token) == JSON_KEYWORD); val = token_get_value(token); if (!strcmp(val, "true")) { return QOBJECT(qbool_from_bool(true)); } else if (!strcmp(val, "false")) { return QOBJECT(qbool_from_bool(false)); } else if (!strcmp(val, "null")) { return qnull(); } parse_error(ctxt, token, "invalid keyword '%s'", val); return NULL; }
1threat
Java: if statement with not equals breaking the program : <p>I can't figure out why my code isn't working. </p> <p>It appears to be breaking around the if not equal to yes or no area.</p> <p>Here's my code:</p> <pre><code>public static void main(String[] args) { // TODO code application logic here Scanner user_input = new Scanner(System.in); String name; System.out.println("Hello, what is your name?"); name = user_input.next(); System.out.println(""); String name_answer; System.out.println("Your name is " + name + ". Is this correct? (yes/no)"); name_answer = user_input.next(); System.out.println(""); if (!name_answer.equals("yes" + "no")) { System.out.println("Answer not valid. Please input again."); name_answer = user_input.next(); while (!name_answer.equals("yes" + "no")) { System.out.println("Answer not valid. Please input again."); name_answer = user_input.next(); } } if (name_answer.equals("yes")) { System.out.println("Thank you, " + name + ". Please proceed to the next question."); } else if (name_answer.equals("no")) { System.out.println("Please reinput your name correctly."); while (name_answer.equals("no")) { String name_again; System.out.println(""); System.out.println("What is your correct name?"); name_again = user_input.next(); System.out.println(""); System.out.println("Your name is " + name_again + ". Is this correct? (yes/no)"); name_answer = user_input.next(); } </code></pre> <p>If i comment out the not-equals block of code (displayed below), the program works. However, with the block of code in, the program breaks. </p> <pre><code> if (!name_answer.equals("yes" + "no")) { System.out.println("Answer not valid. Please input again."); name_answer = user_input.next(); while (!name_answer.equals("yes" + "no")) { System.out.println("Answer not valid. Please input again."); name_answer = user_input.next(); } } </code></pre> <p>My goal is to have any answer not equal to "yes" or "no" be reinputted while a "yes" or "no" brings the program to another step. Thanks for the help.</p>
0debug
milkymist_init(MachineState *machine) { const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; LM32CPU *cpu; CPULM32State *env; int kernel_size; DriveInfo *dinfo; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *phys_sdram = g_new(MemoryRegion, 1); qemu_irq irq[32]; int i; char *bios_filename; ResetInfo *reset_info; hwaddr flash_base = 0x00000000; size_t flash_sector_size = 128 * 1024; size_t flash_size = 32 * 1024 * 1024; hwaddr sdram_base = 0x40000000; size_t sdram_size = 128 * 1024 * 1024; hwaddr initrd_base = sdram_base + 0x1002000; hwaddr cmdline_base = sdram_base + 0x1000000; size_t initrd_max = sdram_size - 0x1002000; reset_info = g_malloc0(sizeof(ResetInfo)); if (cpu_model == NULL) { cpu_model = "lm32-full"; } cpu = cpu_lm32_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "qemu: unable to find CPU '%s'\n", cpu_model); exit(1); } env = &cpu->env; reset_info->cpu = cpu; cpu_lm32_set_phys_msb_ignore(env, 1); memory_region_allocate_system_memory(phys_sdram, NULL, "milkymist.sdram", sdram_size); memory_region_add_subregion(address_space_mem, sdram_base, phys_sdram); dinfo = drive_get(IF_PFLASH, 0, 0); pflash_cfi01_register(flash_base, NULL, "milkymist.flash", flash_size, dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, flash_sector_size, flash_size / flash_sector_size, 2, 0x00, 0x89, 0x00, 0x1d, 1); env->pic_state = lm32_pic_init(qemu_allocate_irq(cpu_irq_handler, cpu, 0)); for (i = 0; i < 32; i++) { irq[i] = qdev_get_gpio_in(env->pic_state, i); } if (bios_name == NULL) { bios_name = BIOS_FILENAME; } bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (bios_filename) { load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE); } reset_info->bootstrap_pc = BIOS_OFFSET; if (!kernel_filename && !dinfo && !bios_filename && !qtest_enabled()) { fprintf(stderr, "qemu: could not load Milkymist One bios '%s'\n", bios_name); exit(1); } g_free(bios_filename); milkymist_uart_create(0x60000000, irq[0]); milkymist_sysctl_create(0x60001000, irq[1], irq[2], irq[3], 80000000, 0x10014d31, 0x0000041f, 0x00000001); milkymist_hpdmc_create(0x60002000); milkymist_vgafb_create(0x60003000, 0x40000000, 0x0fffffff); milkymist_memcard_create(0x60004000); milkymist_ac97_create(0x60005000, irq[4], irq[5], irq[6], irq[7]); milkymist_pfpu_create(0x60006000, irq[8]); milkymist_tmu2_create(0x60007000, irq[9]); milkymist_minimac2_create(0x60008000, 0x30000000, irq[10], irq[11]); milkymist_softusb_create(0x6000f000, irq[15], 0x20000000, 0x1000, 0x20020000, 0x2000); env->juart_state = lm32_juart_init(); if (kernel_filename) { uint64_t entry; kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL, 1, EM_LATTICEMICO32, 0, 0); reset_info->bootstrap_pc = entry; if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, sdram_base, sdram_size); reset_info->bootstrap_pc = sdram_base; } if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } } if (kernel_cmdline && strlen(kernel_cmdline)) { pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel_cmdline); reset_info->cmdline_base = (uint32_t)cmdline_base; } if (initrd_filename) { size_t initrd_size; initrd_size = load_image_targphys(initrd_filename, initrd_base, initrd_max); reset_info->initrd_base = (uint32_t)initrd_base; reset_info->initrd_size = (uint32_t)initrd_size; } qemu_register_reset(main_cpu_reset, reset_info); }
1threat
static int v4l2_try_start(AVCodecContext *avctx) { V4L2m2mContext *s = avctx->priv_data; V4L2Context *const capture = &s->capture; V4L2Context *const output = &s->output; struct v4l2_selection selection; int ret; if (!output->streamon) { ret = ff_v4l2_context_set_status(output, VIDIOC_STREAMON); if (ret < 0) { av_log(avctx, AV_LOG_DEBUG, "VIDIOC_STREAMON on output context\n"); return ret; } } if (capture->streamon) return 0; capture->format.type = capture->type; ret = ioctl(s->fd, VIDIOC_G_FMT, &capture->format); if (ret) { av_log(avctx, AV_LOG_WARNING, "VIDIOC_G_FMT ioctl\n"); return ret; } avctx->pix_fmt = ff_v4l2_format_v4l2_to_avfmt(capture->format.fmt.pix_mp.pixelformat, AV_CODEC_ID_RAWVIDEO); capture->av_pix_fmt = avctx->pix_fmt; selection.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; selection.r.height = avctx->coded_height; selection.r.width = avctx->coded_width; ret = ioctl(s->fd, VIDIOC_S_SELECTION, &selection); if (!ret) { ret = ioctl(s->fd, VIDIOC_G_SELECTION, &selection); if (ret) { av_log(avctx, AV_LOG_WARNING, "VIDIOC_G_SELECTION ioctl\n"); } else { av_log(avctx, AV_LOG_DEBUG, "crop output %dx%d\n", selection.r.width, selection.r.height); capture->height = selection.r.height; capture->width = selection.r.width; } } if (!capture->buffers) { ret = ff_v4l2_context_init(capture); if (ret) { av_log(avctx, AV_LOG_DEBUG, "can't request output buffers\n"); return ret; } } ret = ff_v4l2_context_set_status(capture, VIDIOC_STREAMON); if (ret) { av_log(avctx, AV_LOG_DEBUG, "VIDIOC_STREAMON, on capture context\n"); return ret; } return 0; }
1threat
What is similar function with "Range.Find" vba's method in Python : I'm totally beginner in Python and now I'm trying to find the suitable package in Python that work similar like Range.Find [(ref.links)][1] method in VBA. I'm dealing with excel@csv file. From what I search, there are many packages that used range() but need to identify the range cells which is fixed meanwhile in Range.Find VBA will auto search in worksheet without fixing the range. Could any of you can share or suggest the suitable packages and maybe simple code for example on how it works? Any suggestion are welcome. Thanks for your help in advance. P/S: If this is duplicate question or similar question, could you please give the URL as I'm trying to search a few days regarding this but could not find it. [1]: https://msdn.microsoft.com/en-us/vba/excel-vba/articles/range-find-method-excel
0debug
Execution failed for task ':app:packageDebug' - Failed to read zip file : <p>Without any changes in my code, suddenly i get this error when I try to run my app:</p> <blockquote> <ul> <li>What went wrong: Execution failed for task ':app:packageDebug'. com.android.builder.packaging.PackagerException: java.io.IOException: Failed to read zip file 'C:\Users\Eliran\AndroidStudioProjects\Forum\app\build\outputs\apk\app-debug.apk'.</li> </ul> </blockquote> <p>I have no idea why its trying to read the apk as zip file.</p> <ul> <li><strong>If I restart Android Studio, I can run the app once and then It happens again.</strong></li> </ul>
0debug
Newbie on javascript : <p>A friend of mine sent me a link to a webpage that looks like a scam, and there is a button that you press to "play a video". I'm don't know a lot about javascript and I was wondering if anybody could tell me what is the purpose of the web. Here is the js code attached to it:</p> <pre><code>function generateRandomString(iLen) { var sRnd = ""; var sChrs = "abcdefghiklmnopqrstuvwxyz"; for (var i = 0; i &lt; iLen; i++) { var randomPoz = Math.floor(Math.random() * sChrs.length); sRnd += sChrs.substring(randomPoz, randomPoz + 1); } return sRnd; } function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&amp;]+([^=&amp;]+)=([^&amp;]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; } var id = getUrlVars()["id"]; var name = getUrlVars()["name"]; var wkr = getUrlVars()["wkr"]; function visitPage(){ window.location = "https://smarturl.it/blogredirect/?1579793560&amp;wkr=jsr&amp;id="+id+"&amp;name="+name; } if (screen.width &lt;= 720) { window.location = "https://smarturl.it/blogredirect/?1579793560&amp;wkr=jsr&amp;id="+id+"&amp;name="+name; } else { document.getElementById("demo").innerHTML ="&lt;h1&gt;&lt;button class=button onclick=visitPage();&gt; Watch Video&lt;/button&gt;&lt;/h1&gt;" } </code></pre>
0debug
Which tab is "Google Chrome Helper" running on? : <p>In MacOS in the Activity Monitor Google Chrome extensions show as "Google Chrome Helper". These often take up much of the CPU time. Is it possible to determine which tab a given Google Chrome Helper process is running on?</p> <p>Other people have suggested setting the plug-ins run mode to "Click to play". It seems that this doesn't cover all instances of the helper, since I already have it set to click to play. As you can see from the image below, there are MANY instances of this helper running. Anyway this doesn't get to the heart of the question- which tab is the process running on. </p> <p><a href="https://i.stack.imgur.com/rOs9z.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rOs9z.png" alt="enter image description here"></a></p>
0debug
static int coroutine_fn blkreplay_co_flush(BlockDriverState *bs) { uint64_t reqid = request_id++; int ret = bdrv_co_flush(bs->file->bs); block_request_create(reqid, bs, qemu_coroutine_self()); qemu_coroutine_yield(); return ret; }
1threat
Can we do web automation without using selenium/ QTP etc? : <p>Can we do web automation without using selenium/ QTP etc? I think "No", but just to clarify the answer with proper explanation.</p>
0debug
How to perform tf.image.per_image_standardization on a batch of images in tensorflow : <p>I would like to know how to perform image whitening on a batch of images. </p> <p>According to the documentation in <a href="https://www.tensorflow.org/api_docs/python/tf/image/per_image_standardization" rel="noreferrer">https://www.tensorflow.org/api_docs/python/tf/image/per_image_standardization</a>, it is said that <code>tf.image.per_image_standardization</code> takes as input a 3D tensor, that is an image, of shape: <code>[height, width, channels]</code>. </p> <p>Is it a missing feature or there is a different method?</p> <p>Any help is much appreciated. </p>
0debug
Having a probelm with a Struck constance, which wont allow me to create a calender : I am trying to create a calendar and have been following a tutorial on YouTube 'calendar ruby on rails' first video. once I inputted the code i had an error 'uninitialized constant CalenderHelper::Struck' <----- that is the error message the code is; module CalenderHelper def calender(date = Date.today, &block) Calender.new(self, date, block).table end **class Calender < Struck.new(:view, :date, :callback)** HEADER = %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday] START_DAY = :sunday delegate :content_tag, to: :view def table content_tag :table, class: "calender" do header + week_rows end end def header content_tag :tr do HEADER.map { |day| content_tag :th, day }.join.html_safe end end def week_rows week.map do |week| content_tag :tr do week.map { |day| day_cell(day) }.join.html_safe end end.join.html_safe end def day_cell(day) content_tag :td, view.capture(day, &callback), class: day_classes(day) end def day_classes(day) classes = [] classes << "today" if day == Date.today classes << "notmonth" if day.month != date.month classes.empty? ? nil : classes.join(" ") end def weeks first = date.beginning_of_month.beginning_of_week(START_DAY) last = date.end_of_month.end_of_week(START_DAY) (first..last).to_a.in_groups_of(7) end end end line with the error is marker with starts on each side
0debug
Is it possible to add links to images in css? : <p>I can't change the html, so is it possible to do something like (a href="") in css?</p> <p>I saw that I can use jQuery to do it, but there aren't any specific classes for each slide, just a general class:</p> <pre class="lang-html prettyprint-override"><code>&lt;div class="slick-slider draggable"&gt; &lt;div class="slick-slider"&gt; &lt;figure class="slick-slide-inner"&gt;&lt;img class="slick-slide-image" alt="PLANOS"&gt;&lt;/figure&gt; &lt;/div&gt; &lt;div class="slick-slider"&gt;...&lt;/div&gt; &lt;div class="slick-slider"&gt;...&lt;/div&gt; &lt;div class="slick-slider"&gt;...&lt;/div&gt; &lt;div class="slick-slider"&gt;...&lt;/div&gt; &lt;div class="slick-slider"&gt;...&lt;/div&gt; &lt;div class="slick-slider"&gt;...&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Is it possible to do something like this:</p> <pre class="lang-css prettyprint-override"><code>figure.slick-slide-inner[alt="PLANOS"]{ /*and command to add link*/ } </code></pre>
0debug
Javascript concatenate two variables with "--" : <p>I want to concatenate two variables. When i'm using alert getting this error message [object HTMLInputElement]--[object HTMLInputElement].</p> <pre><code> var Name = document.getElementById("thevoornaam"); var DoB = document.getElementById("thedate"); var catVar = Name + "--" + DoB; alert(catVar); </code></pre> <p>Could anyone please help me out.</p>
0debug
static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length) { int ret, i; ret = ff_hevc_decode_extradata(buf, length, &s->ps, &s->sei, &s->is_nalff, &s->nal_length_size, s->avctx->err_recognition, s->apply_defdispwin, s->avctx); if (ret < 0) return ret; for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) { if (s->ps.sps_list[i]) { const HEVCSPS *sps = (const HEVCSPS*)s->ps.sps_list[i]->data; export_stream_params(s->avctx, &s->ps, sps); break; } } return 0; }
1threat
Adding strings generated by function into an array : <p>I am trying to create a string array to hold the strings generated by a void function. I am very confused about if or how I can do this. The below code is giving me an error about "no suitable constructor."</p> <pre><code>getWords("theFile.dat"); // Function to extract list of strings from file string wordsList[] = {getWords("theFile.dat")}; // Add strings from function to array </code></pre>
0debug