problem
stringlengths
26
131k
labels
class label
2 classes
static void compute_default_clut(AVSubtitleRect *rect, int w, int h) { uint8_t list[256] = {0}; uint8_t list_inv[256]; int counttab[256] = {0}; int count, i, x, y; #define V(x,y) rect->data[0][(x) + (y)*rect->linesize[0]] for (y = 0; y<h; y++) { for (x = 0; x<w; x++) { int v = V(x,y) + 1; int vl = x ? V(x-1,y) + 1 : 0; int vr = x+1<w ? V(x+1,y) + 1 : 0; int vt = y ? V(x,y-1) + 1 : 0; int vb = y+1<h ? V(x,y+1) + 1 : 0; counttab[v-1] += !!((v!=vl) + (v!=vr) + (v!=vt) + (v!=vb)); } } #define L(x,y) list[ rect->data[0][(x) + (y)*rect->linesize[0]] ] for (i = 0; i<256; i++) { int scoretab[256] = {0}; int bestscore = 0; int bestv = 0; for (y = 0; y<h; y++) { for (x = 0; x<w; x++) { int v = rect->data[0][x + y*rect->linesize[0]]; int l_m = list[v]; int l_l = x ? L(x-1, y) : 1; int l_r = x+1<w ? L(x+1, y) : 1; int l_t = y ? L(x, y-1) : 1; int l_b = y+1<h ? L(x, y+1) : 1; int score; if (l_m) continue; scoretab[v] += l_l + l_r + l_t + l_b; score = 1024LL*scoretab[v] / counttab[v]; if (score > bestscore) { bestscore = score; bestv = v; } } } if (!bestscore) break; list [ bestv ] = 1; list_inv[ i ] = bestv; } count = FFMAX(i - 1, 1); for (i--; i>=0; i--) { int v = i*255/count; AV_WN32(rect->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v)); } }
1threat
static void vnc_display_close(DisplayState *ds) { VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display; if (!vs) return; if (vs->display) { g_free(vs->display); vs->display = NULL; } if (vs->lsock != -1) { qemu_set_fd_handler2(vs->lsock, NULL, NULL, NULL, NULL); close(vs->lsock); vs->lsock = -1; } #ifdef CONFIG_VNC_WS g_free(vs->ws_display); vs->ws_display = NULL; if (vs->lwebsock != -1) { qemu_set_fd_handler2(vs->lwebsock, NULL, NULL, NULL, NULL); close(vs->lwebsock); vs->lwebsock = -1; } #endif vs->auth = VNC_AUTH_INVALID; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; vs->tls.x509verify = 0; #endif }
1threat
How to make Jupyter Notebook to run on GPU? : <p>In Google Collab you can choose your notebook to run on cpu or gpu environment. Now I have a laptop with NVDIA Cuda Compatible GPU 1050, and latest anaconda. How to have similiar feature to the collab one where I can simply make my python to run on GPU?</p>
0debug
Custom Facebook Login button iOS : <p>I've just integrated the Facebook iOS SDK with my app, and the login works great. That said, the SDK doesnt seem to give me the option to customize my login button (it provides me with that ugly default button in the middle of the screen). I'm using Storyboards with my app - how can I go about hooking up my own button to their provided code? I've seen some older answers posted to Stack, but the FB documentation has since changed :/</p> <p><strong>Viewcontroller.m</strong></p> <pre><code> FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init]; loginButton.center = self.view.center; [self.view addSubview:loginButton]; </code></pre>
0debug
static inline void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst, long dstWidth, const uint8_t *src, int srcW, int xInc) { int32_t *filterPos = c->hLumFilterPos; int16_t *filter = c->hLumFilter; int canMMX2BeUsed = c->canMMX2BeUsed; void *mmx2FilterCode= c->lumMmx2FilterCode; int i; #if defined(PIC) DECLARE_ALIGNED(8, uint64_t, ebxsave); #endif __asm__ volatile( #if defined(PIC) "mov %%"REG_b", %5 \n\t" #endif "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "mov %2, %%"REG_d" \n\t" "mov %3, %%"REG_b" \n\t" "xor %%"REG_a", %%"REG_a" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" #if ARCH_X86_64 #define CALL_MMX2_FILTER_CODE \ "movl (%%"REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\ "add %%"REG_S", %%"REG_c" \n\t"\ "add %%"REG_a", %%"REG_D" \n\t"\ "xor %%"REG_a", %%"REG_a" \n\t"\ #else #define CALL_MMX2_FILTER_CODE \ "movl (%%"REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\ "add %%"REG_a", %%"REG_D" \n\t"\ "xor %%"REG_a", %%"REG_a" \n\t"\ #endif CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE #if defined(PIC) "mov %5, %%"REG_b" \n\t" #endif :: "m" (src), "m" (dst), "m" (filter), "m" (filterPos), "m" (mmx2FilterCode) #if defined(PIC) ,"m" (ebxsave) #endif : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D #if !defined(PIC) ,"%"REG_b #endif ); for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128; }
1threat
hi and cheers my broS : in c# how can i repeat a code that i write in a form key down event each time i press that key i mean i want to re run that code each time i press the key i think this can be so simple for u cause i am beginner thanks this code is what i already tried if (e.KeyCode == Keys.Down) { textBox1.TabStop = true; dataGridView1.Focus(); label1.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); }
0debug
Firestore - How to decrement integer value atomically in database? : <p>Firestore has recently launched a new feature to increment and decrement the integer values atomically.</p> <p>I can increment the integer value using</p> <p>For instance, <code>FieldValue.increment(50)</code></p> <p>But how to decrement ?</p> <p>I tried using <code>FieldValue.decrement(50)</code> But there is no method like decrement in FieldValue.</p> <p>It's not working.</p> <p><a href="https://firebase.googleblog.com/2019/03/increment-server-side-cloud-firestore.html?linkId=65365800&amp;m=1" rel="noreferrer">https://firebase.googleblog.com/2019/03/increment-server-side-cloud-firestore.html?linkId=65365800&amp;m=1</a></p>
0debug
static int init_input_stream(int ist_index, char *error, int error_len) { int i; InputStream *ist = input_streams[ist_index]; if (ist->decoding_needed) { AVCodec *codec = ist->dec; if (!codec) { snprintf(error, error_len, "Decoder (codec id %d) not found for input stream #%d:%d", ist->st->codec->codec_id, ist->file_index, ist->st->index); return AVERROR(EINVAL); } for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; if (ost->source_index == ist_index) { update_sample_fmt(ist->st->codec, codec, ost->st->codec); break; } } if (codec->type == AVMEDIA_TYPE_VIDEO && codec->capabilities & CODEC_CAP_DR1) { ist->st->codec->get_buffer = codec_get_buffer; ist->st->codec->release_buffer = codec_release_buffer; ist->st->codec->opaque = &ist->buffer_pool; } if (!av_dict_get(ist->opts, "threads", NULL, 0)) av_dict_set(&ist->opts, "threads", "auto", 0); if (avcodec_open2(ist->st->codec, codec, &ist->opts) < 0) { snprintf(error, error_len, "Error while opening decoder for input stream #%d:%d", ist->file_index, ist->st->index); return AVERROR(EINVAL); } assert_codec_experimental(ist->st->codec, 0); assert_avoptions(ist->opts); } ist->last_dts = ist->st->avg_frame_rate.num ? - ist->st->codec->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0; ist->next_dts = AV_NOPTS_VALUE; init_pts_correction(&ist->pts_ctx); ist->is_start = 1; return 0; }
1threat
Validating start and end date in codeigniter start date < end date : these are use in view page pls add the java script to validate this date i am using code igniter <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Mfg. date </label> <div class="col-md-6 col-sm-6 col-xs-12 form-group has-feedback"> <input type="date" class="form-control" id="startDate" name="mfg_date" value=""> </div> </div> <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Exp. Date </label> <div class="col-md-6 col-sm-6 col-xs-12 form-group has-feedback"> <input type="date" class="form-control" id="endDate" name="exp_date" value=""> </div> </div> <input type="hidden" name="action" value="add_medicines"/> <button type="submit" class="btn btn-success" />Add</button> <!-- end snippet -->
0debug
facing issue in session with the upgrade of my Application to Spring 4.1.9 and Hibernate 4.3.11 : facing issue in session with the upgrade of my Application to Spring 4.1.9 and Hibernate 4.3.11..Logs are below:[org.springframework.orm.hibernate4.HibernateTemplate] - <Could not retrieve pre-bound Hibernate session> org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:134) at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014) at org.springframework.orm.hibernate4.HibernateTemplate.doExecute(HibernateTemplate.java:325) at org.springframework.orm.hibernate4.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:308) at org.springframework.orm.hibernate4.HibernateTemplate.findByCriteria(HibernateTemplate.java:1011) at org.springframework.orm.hibernate4.HibernateTemplate.findByCriteria(HibernateTemplate.java:1003)
0debug
Whats the point of running Laravel with the command 'php artisan serve'? : <p>I dont seem to understand why we need to run a Laravel app with <code>php artisan serve</code> vs just running it with <strong>Apache</strong> or <strong>nginx</strong>. I know that under development, we use artisan to fire up the site and after deployment to a server, you use the webserver to load up the site.</p> <p>Whats the use of running the app in artisan in the first place?</p>
0debug
static int replaygain_export(AVStream *st, const uint8_t *track_gain, const uint8_t *track_peak, const uint8_t *album_gain, const uint8_t *album_peak) { AVPacketSideData *sd, *tmp; AVReplayGain *replaygain; uint8_t *data; int32_t tg, ag; uint32_t tp, ap; tg = parse_gain(track_gain); ag = parse_gain(album_gain); tp = parse_peak(track_peak); ap = parse_peak(album_peak); if (tg == INT32_MIN && ag == INT32_MIN) return 0; replaygain = av_mallocz(sizeof(*replaygain)); if (!replaygain) return AVERROR(ENOMEM); tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp)); if (!tmp) { av_freep(&replaygain); return AVERROR(ENOMEM); } st->side_data = tmp; st->nb_side_data++; sd = &st->side_data[st->nb_side_data - 1]; sd->type = AV_PKT_DATA_REPLAYGAIN; sd->data = (uint8_t*)replaygain; sd->size = sizeof(*replaygain); replaygain->track_gain = tg; replaygain->track_peak = tp; replaygain->album_gain = ag; replaygain->album_peak = ap; return 0; }
1threat
static void cdrom_pio_impl(int nblocks) { QPCIDevice *dev; void *bmdma_base, *ide_base; FILE *fh; int patt_blocks = MAX(16, nblocks); size_t patt_len = ATAPI_BLOCK_SIZE * patt_blocks; char *pattern = g_malloc(patt_len); size_t rxsize = ATAPI_BLOCK_SIZE * nblocks; uint16_t *rx = g_malloc0(rxsize); int i, j; uint8_t data; uint16_t limit; generate_pattern(pattern, patt_len, ATAPI_BLOCK_SIZE); fh = fopen(tmp_path, "w+"); fwrite(pattern, ATAPI_BLOCK_SIZE, patt_blocks, fh); fclose(fh); ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 " "-device ide-cd,drive=sr0,bus=ide.0", tmp_path); dev = get_pci_device(&bmdma_base, &ide_base); qtest_irq_intercept_in(global_qtest, "ioapic"); qpci_io_writeb(dev, ide_base + reg_device, 0); qpci_io_writeb(dev, ide_base + reg_lba_middle, BYTE_COUNT_LIMIT & 0xFF); qpci_io_writeb(dev, ide_base + reg_lba_high, (BYTE_COUNT_LIMIT >> 8 & 0xFF)); qpci_io_writeb(dev, ide_base + reg_command, CMD_PACKET); nsleep(400); data = ide_wait_clear(BSY); assert_bit_set(data, DRQ | DRDY); assert_bit_clear(data, ERR | DF | BSY); send_scsi_cdb_read10(dev, ide_base, 0, nblocks); g_assert(!(rxsize & 1)); limit = BYTE_COUNT_LIMIT & ~1; for (i = 0; i < DIV_ROUND_UP(rxsize, limit); i++) { size_t offset = i * (limit / 2); size_t rem = (rxsize / 2) - offset; ide_wait_intr(IDE_PRIMARY_IRQ); data = ide_wait_clear(BSY); assert_bit_set(data, DRQ | DRDY); assert_bit_clear(data, ERR | DF | BSY); for (j = 0; j < MIN((limit / 2), rem); j++) { rx[offset + j] = cpu_to_le16(qpci_io_readw(dev, ide_base + reg_data)); } } ide_wait_intr(IDE_PRIMARY_IRQ); data = ide_wait_clear(DRQ); assert_bit_set(data, DRDY); assert_bit_clear(data, DRQ | ERR | DF | BSY); g_assert_cmpint(memcmp(pattern, rx, rxsize), ==, 0); g_free(pattern); g_free(rx); test_bmdma_teardown(); }
1threat
static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, int buf_size, AVCodecContext *avctx) { HEVCParserContext *ctx = s->priv_data; HEVCContext *h = &ctx->h; GetBitContext *gb; SliceHeader *sh = &h->sh; HEVCParamSets *ps = &h->ps; HEVCSEIContext *sei = &h->sei; int is_global = buf == avctx->extradata; int i, ret; if (!h->HEVClc) h->HEVClc = av_mallocz(sizeof(HEVCLocalContext)); if (!h->HEVClc) return AVERROR(ENOMEM); gb = &h->HEVClc->gb; s->pict_type = AV_PICTURE_TYPE_I; s->key_frame = 0; s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN; h->avctx = avctx; ff_hevc_reset_sei(sei); ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, 0, 0, AV_CODEC_ID_HEVC, 1); if (ret < 0) return ret; for (i = 0; i < ctx->pkt.nb_nals; i++) { H2645NAL *nal = &ctx->pkt.nals[i]; int num = 0, den = 0; h->nal_unit_type = nal->type; h->temporal_id = nal->temporal_id; *gb = nal->gb; switch (h->nal_unit_type) { case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(gb, avctx, ps); break; case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(gb, avctx, ps, 1); break; case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(gb, avctx, ps); break; case HEVC_NAL_SEI_PREFIX: case HEVC_NAL_SEI_SUFFIX: ff_hevc_decode_nal_sei(gb, avctx, sei, ps, h->nal_unit_type); break; case HEVC_NAL_TRAIL_N: case HEVC_NAL_TRAIL_R: case HEVC_NAL_TSA_N: case HEVC_NAL_TSA_R: case HEVC_NAL_STSA_N: case HEVC_NAL_STSA_R: case HEVC_NAL_RADL_N: case HEVC_NAL_RADL_R: case HEVC_NAL_RASL_N: case HEVC_NAL_RASL_R: case HEVC_NAL_BLA_W_LP: case HEVC_NAL_BLA_W_RADL: case HEVC_NAL_BLA_N_LP: case HEVC_NAL_IDR_W_RADL: case HEVC_NAL_IDR_N_LP: case HEVC_NAL_CRA_NUT: if (is_global) { av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", h->nal_unit_type); return AVERROR_INVALIDDATA; } sh->first_slice_in_pic_flag = get_bits1(gb); s->picture_structure = h->sei.picture_timing.picture_struct; s->field_order = h->sei.picture_timing.picture_struct; if (IS_IRAP(h)) { s->key_frame = 1; sh->no_output_of_prior_pics_flag = get_bits1(gb); } sh->pps_id = get_ue_golomb(gb); if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) { av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); return AVERROR_INVALIDDATA; } ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data; if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) { av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id); return AVERROR_INVALIDDATA; } if (ps->sps != (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data) { ps->sps = (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data; ps->vps = (HEVCVPS*)ps->vps_list[ps->sps->vps_id]->data; } s->coded_width = ps->sps->width; s->coded_height = ps->sps->height; s->width = ps->sps->output_width; s->height = ps->sps->output_height; s->format = ps->sps->pix_fmt; avctx->profile = ps->sps->ptl.general_ptl.profile_idc; avctx->level = ps->sps->ptl.general_ptl.level_idc; if (ps->vps->vps_timing_info_present_flag) { num = ps->vps->vps_num_units_in_tick; den = ps->vps->vps_time_scale; } else if (ps->sps->vui.vui_timing_info_present_flag) { num = ps->sps->vui.vui_num_units_in_tick; den = ps->sps->vui.vui_time_scale; } if (num != 0 && den != 0) av_reduce(&avctx->framerate.den, &avctx->framerate.num, num, den, 1 << 30); if (!sh->first_slice_in_pic_flag) { int slice_address_length; if (ps->pps->dependent_slice_segments_enabled_flag) sh->dependent_slice_segment_flag = get_bits1(gb); else sh->dependent_slice_segment_flag = 0; slice_address_length = av_ceil_log2_c(ps->sps->ctb_width * ps->sps->ctb_height); sh->slice_segment_addr = get_bitsz(gb, slice_address_length); if (sh->slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) { av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n", sh->slice_segment_addr); return AVERROR_INVALIDDATA; } } else sh->dependent_slice_segment_flag = 0; if (sh->dependent_slice_segment_flag) break; for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++) skip_bits(gb, 1); sh->slice_type = get_ue_golomb(gb); if (!(sh->slice_type == HEVC_SLICE_I || sh->slice_type == HEVC_SLICE_P || sh->slice_type == HEVC_SLICE_B)) { av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n", sh->slice_type); return AVERROR_INVALIDDATA; } s->pict_type = sh->slice_type == HEVC_SLICE_B ? AV_PICTURE_TYPE_B : sh->slice_type == HEVC_SLICE_P ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; if (ps->pps->output_flag_present_flag) sh->pic_output_flag = get_bits1(gb); if (ps->sps->separate_colour_plane_flag) sh->colour_plane_id = get_bits(gb, 2); if (!IS_IDR(h)) { sh->pic_order_cnt_lsb = get_bits(gb, ps->sps->log2_max_poc_lsb); s->output_picture_number = h->poc = ff_hevc_compute_poc(h->ps.sps, h->pocTid0, sh->pic_order_cnt_lsb, h->nal_unit_type); } else s->output_picture_number = h->poc = 0; if (h->temporal_id == 0 && h->nal_unit_type != HEVC_NAL_TRAIL_N && h->nal_unit_type != HEVC_NAL_TSA_N && h->nal_unit_type != HEVC_NAL_STSA_N && h->nal_unit_type != HEVC_NAL_RADL_N && h->nal_unit_type != HEVC_NAL_RASL_N && h->nal_unit_type != HEVC_NAL_RADL_R && h->nal_unit_type != HEVC_NAL_RASL_R) h->pocTid0 = h->poc; return 0; } } if (!is_global) av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit\n"); return -1; }
1threat
Unable to Finish connecting to SonarQube server : <p>This is going to sound like a ridiculous question, but using the SonarLint Eclipse plugin (v3.2.0) on the latest Eclipse (Oxygen), I am unable to add a new SonarQube server connection. </p> <p>I am working behind a company firewall, but that doesnt appear to be an issue. I am following the steps <a href="http://www.sonarlint.org/eclipse/index.html" rel="noreferrer">here</a> and am able to successfully connect to our internal SonarQube instance, provide my credentials, but it is just on the final step, that the 'Finish' button does not seem to do anything, see screen below:</p> <p><a href="https://i.stack.imgur.com/9BLeH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9BLeH.png" alt="enter image description here"></a></p> <p>I appreciate there is probably some background processes need to run in order for this Finish to actually finish :) But this doesnt appear to be doing anything...Anyone else experience this issue?</p> <p>Any before people ask, I've restarted Eclipse/laptop, uninstalled and reinstalled SonarLint plugin etc.</p> <p>Thanks in advance!</p>
0debug
static void test_io_channel(bool async, SocketAddress *listen_addr, SocketAddress *connect_addr, bool passFD) { QIOChannel *src, *dst; QIOChannelTest *test; if (async) { test_io_channel_setup_async(listen_addr, connect_addr, &src, &dst); g_assert(!passFD || qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN)); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, true, src, dst); qio_channel_test_validate(test); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); test_io_channel_setup_async(listen_addr, connect_addr, &src, &dst); g_assert(!passFD || qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN)); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, false, src, dst); qio_channel_test_validate(test); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); } else { test_io_channel_setup_sync(listen_addr, connect_addr, &src, &dst); g_assert(!passFD || qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN)); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, true, src, dst); qio_channel_test_validate(test); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); test_io_channel_setup_sync(listen_addr, connect_addr, &src, &dst); g_assert(!passFD || qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN)); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, false, src, dst); qio_channel_test_validate(test); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); } }
1threat
How to set onclick listener in xamarin? : <p>I'm quite new to C# and Xamarin and have been trying to implement a bottom sheet element and don't know how to correctly do it. I am using <a href="https://github.com/fabionuno/Cocosw.BottomSheet-Xamarin.Android" rel="noreferrer">Cocosw.BottomSheet-Xamarin.Android</a> library.</p> <p>Here is my code:</p> <pre><code>Cocosw.BottomSheetActions.BottomSheet.Builder b = new Cocosw.BottomSheetActions.BottomSheet.Builder (this); b.Title ("New"); b.Sheet (Resource.Layout.menu_bottom_sheet) </code></pre> <p>Now i think i should use <code>b.Listener(...)</code>, but it requires an interface <code>IDialogInterfaceOnClickListener</code> as a paramater and i don't know how to do it in C# correctly.</p> <p>In Java i could write </p> <pre><code>button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click } }); </code></pre> <p>I tried doing this:</p> <pre><code>class BottomSheetActions : IDialogInterfaceOnClickListener { public void OnClick (IDialogInterface dialog, int which) { Console.WriteLine ("Hello fox"); } public IntPtr Handle { get; } public void Dispose() { } } </code></pre> <p>and then this:</p> <pre><code>b.Listener (new BottomSheetActions()); </code></pre> <p>But it didnt work.</p>
0debug
Display the difference of excel columns with PowerShell : I would like to get the difference in the columns in as a table but I only can do a comparison with two columns and it doesn't display all the columns. I need to see in which column the cell is not present in the fisrt column. the script: $x = Import-Csv .\test1.csv -Delimiter ';' Compare-Object -ReferenceObject $x.ComputerName -DifferenceObject $x.OtherComputerName the file: ComputerName OtherComputerName OtherComputer AndAgain infra-1 infra-852 infra-2 infra-99 infra-98 infra-85 infra-44 infra-23 infra-5 infra-8 infra-1 infra-10 infra-2 infra-55 infra-8 infra-70 infra-62 infra-5 infra-852 infra-5
0debug
static inline void gen_op_fcmped(int fccno, TCGv_i64 r_rs1, TCGv_i64 r_rs2) { gen_helper_fcmped(cpu_env, r_rs1, r_rs2); }
1threat
How to open activity (incoming voip call) in Android 10 : <p>In Android 10 there apply new restrictions for apps. We can no longer start an activity from background. While this may be fine for the majority of apps, it's a killing blow for voip-apps that need to show an incoming call after a push notification arrived.</p> <p>According to this <a href="https://developer.android.com/guide/components/activities/background-starts" rel="noreferrer">https://developer.android.com/guide/components/activities/background-starts</a> there is a list of conditions that can be met to still allow opening an activity, but tbh I do not understand that fully (non-english-native here).</p> <p><em>What I definitely know, is:</em></p> <ul> <li><p>I do not have any running activity, task, backstack and the like</p></li> <li><p>The app is NOT EVEN RUNNING</p></li> </ul> <p><em>What I need to achieve:</em></p> <ul> <li>The FCM service of the app receives a push from our server and shall present the incoming call screen (over lock screen and all - just as it did with android 9 and below)</li> </ul> <p>What can I do to open an activity for an incoming voip call in android 10? Over the lockscreen and all, just as a normal user would expect from a PHONE app.</p> <p>Thanks in advance for any hints.</p>
0debug
void migrate_fd_error(MigrationState *s, const Error *error) { trace_migrate_fd_error(error ? error_get_pretty(error) : ""); assert(s->to_dst_file == NULL); migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_FAILED); if (!s->error) { s->error = error_copy(error); } notifier_list_notify(&migration_state_notifiers, s); }
1threat
How to declare collection name and model name in mongoose : <p>I have 3 kind of records,</p> <pre><code>1)Categories, 2)Topics and 3)Articles </code></pre> <p>In my mongodb, i have only 1 colection named 'categories' in which i stroe the above 3 types of documents.</p> <p>For these 3 modules,i wrote 3 models(one each) in such a way like below,</p> <pre><code>mongoose.model('categories', CategorySchema); mongoose.model('categories', TopicSchema) mongoose.model('categories', ArticlesSchema) </code></pre> <p>like....mongoose.model('collection_name', Schema_name)</p> <p>but when i run my code ,it throws error that </p> <pre><code>Cannot overwrite `categories` model once compiled. </code></pre> <p>If i change the above models like this,</p> <pre><code>mongoose.model('category','categories', CategorySchema); mongoose.model('topics','categories', TopicSchema) mongoose.model('articles','categories', ArticlesSchema) </code></pre> <p>It is creating 2 collections named topics and articles which i dont want. This is my issue right now,can anyone suggest me help.....Thanks....</p>
0debug
Identity asp.net core 3.0 - IdentityDbContext not found : <p>My app broke with the 3.0 release of .NET core with reference errors for <code>IdentityDbContext</code>. I'm looking through documentation for Identity on core 3.0 but it implies that IdentityDbContext should be there. It's the only error I'm getting with a couple <code>DbContext</code> errors.</p> <p>I have a pretty simple API, no MVC views, just a data server that gives back JSON objects. It's based on Identity so it has the users and roles and claims. And it's starting to take advantage of that. My main DbContext extends <code>IdentityDbContext&lt;ApplicationUser&gt;</code> but after switching target platform to 3.0 after the upgrade, it says it doesn't exist and gives me compile errors. Has anyone run into this? Am I missing something? The migration and breaking changes pages don't seem to have anything addressing my issue.</p> <p>DbContext looks like this:</p> <pre class="lang-cs prettyprint-override"><code>using System; using Microsoft.AspNetCore.Identity; //using Microsoft.AspNetCore.Identity.EntityFrameworkCore; &lt;- this no longer works either using Microsoft.EntityFrameworkCore; //&lt;- this I had to download as a package using App.Constants; using App.Models.Identity; namespace App.Models { public class AppContext : IdentityDbContext&lt;ApplicationUser&gt; //&lt;- error is right here { ... my models } } </code></pre>
0debug
Python : Get all Ints from inside Class Instance : I want to get all int types of a unknown class instance If I have the following class class myclass: g_goodies = 0 g_stringer = "bob" mylist = [] def __init__(self,goodies): self.g_goodies = goodies for x in range(0,10): self.mylist.append(0) And I have tried .. def get_ints(self,inobject): a = inspect.getmembers(inobject) b = len(a) print 'a:',a,' b:',b print 'a type:',type(a),' b type:',type(b) for x in range(0,b-1): c = type(a[x]) print c print "Hello World!\n" mc = myclass(10) pa = printanything() print pa.get_ints(mc) which gives me. $python main.py Hello World! a: [('__doc__', None), ('__init__', <bound method myclass.__init__ of <__main__.myclass instance at 0x7f34ee9e80e0>>), ('__module__', '__main__'), ('g_goodies', 10), ('g_stringer', 'bob'), ('mylist', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])] b: 6 a type: <type 'list'> b type: <type 'int'> <type 'tuple'> <type 'tuple'> <type 'tuple'> <type 'tuple'> <type 'tuple'> None So I simply want to be able to extract all the type <ints> in a class instance, all the type <string> in a class object etc.. The class is not known at run time.
0debug
static inline int decode_scalar(GetBitContext *gb, int k, int limit, int readsamplesize){ int x = get_unary_0_9(gb); if (x > 8) { x = get_bits(gb, readsamplesize); } else { if (k >= limit) k = limit; if (k != 1) { int extrabits = show_bits(gb, k); x = (x << k) - x; if (extrabits > 1) { x += extrabits - 1; skip_bits(gb, k); } else skip_bits(gb, k - 1); } } return x; }
1threat
Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path" : <p>i run CentOS in VirtualBox on physical Windows7. Now in centOS i have Docker and i need to run </p> <pre><code>docker-machine create --driver virtualbox host1 </code></pre> <p>but i get error</p> <pre><code>Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path" </code></pre> <p>so do i need to install VirtualBox once again and in the CentOS? If yes, how can i do that?</p> <p>thanks lot</p>
0debug
av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse) { int n = 1 << nbits; int i; s->nbits = nbits; s->inverse = inverse; ff_init_ff_cos_tabs(nbits+2); s->costab = ff_cos_tabs[nbits+2]; s->csc2 = av_malloc(n/2 * sizeof(FFTSample)); if (ff_rdft_init(&s->rdft, nbits, inverse == DCT_III) < 0) { av_free(s->csc2); return -1; } for (i = 0; i < n/2; i++) s->csc2[i] = 0.5 / sin((M_PI / (2*n) * (2*i + 1))); switch(inverse) { case DCT_I : s->dct_calc = ff_dct_calc_I_c; break; case DCT_II : s->dct_calc = ff_dct_calc_II_c ; break; case DCT_III: s->dct_calc = ff_dct_calc_III_c; break; case DST_I : s->dct_calc = ff_dst_calc_I_c; break; } if (inverse == DCT_II && nbits == 5) s->dct_calc = dct32_func; s->dct32 = dct32; if (HAVE_MMX) ff_dct_init_mmx(s); return 0; }
1threat
HTML Hide input/post name : <p>Im looking to hide a post request name from the user, So they cannot post to a URL.</p> <p>For example, Im looking for something that will avoid users checking the post request name and sending something to bypass the restrictions to insert into a database.</p>
0debug
Which channel do I use in Flutter SDK? : <p>There was an announcement of Preview 1 at " <a href="https://medium.com/flutter-io/flutter-release-preview-1-943a9b6ee65a" rel="noreferrer">Announcing Flutter Release Preview 1 – Flutter – Medium</a>"</p> <p>Download the latest beta release of the Flutter SDK In the document. <a href="https://flutter.io/setup-macos/" rel="noreferrer">Get Started: Install on macOS - Flutter</a></p> <p>Latest beta release version is 0.5.1. It's updated 2 months ago...</p> <pre><code>$ flutter upgrade Flutter 0.5.1 • channel beta • https://github.com/flutter/flutter.git Framework • revision c7ea3ca377 (9 weeks ago) • 2018-05-29 21:07:33 +0200 Engine • revision 1ed25ca7b7 Tools • Dart 2.0.0-dev.58.0.flutter-f981f09760 </code></pre> <p>Latest master release version is 0.5.8-pre.163.</p> <pre><code>$ flutter channel master $ flutter upgrade Flutter 0.5.8-pre.163 • channel master • https://github.com/flutter/flutter.git Framework • revision 29410abbe7 (2 days ago) • 2018-07-27 22:10:39 -0700 Engine • revision 72a38a6b13 Tools • Dart 2.0.0-dev.69.3.flutter-937ee2e8ca </code></pre> <p><strong>Which channel do I use in Flutter SDK?</strong></p>
0debug
AWS Lambda vs Heroku: what are the key differences? : <p>I searched online but can't find a good answer to what the key differences are between AWS Lambda vs Heroku. I can for example write Node JS but when should I use Lambda and when Heroku?</p>
0debug
static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, const int *const_args) { int c; switch (opc) { case INDEX_op_exit_tb: tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_I0, args[0]); tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I7) | INSN_IMM13(8)); tcg_out32(s, RESTORE | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_G0) | INSN_RS2(TCG_REG_G0)); break; case INDEX_op_goto_tb: if (s->tb_jmp_offset) { if (ABS(args[0] - (unsigned long)s->code_ptr) == (ABS(args[0] - (unsigned long)s->code_ptr) & 0x1fffff)) { tcg_out32(s, BA | INSN_OFF22(args[0] - (unsigned long)s->code_ptr)); } else { tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_I5, args[0]); tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) | INSN_RS2(TCG_REG_G0)); } s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; } else { tcg_out_ld_ptr(s, TCG_REG_I5, (tcg_target_long)(s->tb_next + args[0])); tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) | INSN_RS2(TCG_REG_G0)); } tcg_out_nop(s); s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf; break; case INDEX_op_call: if (const_args[0]) { tcg_out32(s, CALL | ((((tcg_target_ulong)args[0] - (tcg_target_ulong)s->code_ptr) >> 2) & 0x3fffffff)); tcg_out_nop(s); } else { tcg_out_ld_ptr(s, TCG_REG_O7, (tcg_target_long)(s->tb_next + args[0])); tcg_out32(s, JMPL | INSN_RD(TCG_REG_O7) | INSN_RS1(TCG_REG_O7) | INSN_RS2(TCG_REG_G0)); tcg_out_nop(s); } break; case INDEX_op_jmp: fprintf(stderr, "unimplemented jmp\n"); break; case INDEX_op_br: fprintf(stderr, "unimplemented br\n"); break; case INDEX_op_movi_i32: tcg_out_movi(s, TCG_TYPE_I32, args[0], (uint32_t)args[1]); break; #if defined(__sparc_v9__) && !defined(__sparc_v8plus__) #define OP_32_64(x) \ glue(glue(case INDEX_op_, x), _i32:) \ glue(glue(case INDEX_op_, x), _i64:) #else #define OP_32_64(x) \ glue(glue(case INDEX_op_, x), _i32:) #endif OP_32_64(ld8u); tcg_out_ldst(s, args[0], args[1], args[2], LDUB); break; OP_32_64(ld8s); tcg_out_ldst(s, args[0], args[1], args[2], LDSB); break; OP_32_64(ld16u); tcg_out_ldst(s, args[0], args[1], args[2], LDUH); break; OP_32_64(ld16s); tcg_out_ldst(s, args[0], args[1], args[2], LDSH); break; case INDEX_op_ld_i32: #if defined(__sparc_v9__) && !defined(__sparc_v8plus__) case INDEX_op_ld32u_i64: #endif tcg_out_ldst(s, args[0], args[1], args[2], LDUW); break; OP_32_64(st8); tcg_out_ldst(s, args[0], args[1], args[2], STB); break; OP_32_64(st16); tcg_out_ldst(s, args[0], args[1], args[2], STH); break; case INDEX_op_st_i32: #if defined(__sparc_v9__) && !defined(__sparc_v8plus__) case INDEX_op_st32_i64: #endif tcg_out_ldst(s, args[0], args[1], args[2], STW); break; OP_32_64(add); c = ARITH_ADD; goto gen_arith32; OP_32_64(sub); c = ARITH_SUB; goto gen_arith32; OP_32_64(and); c = ARITH_AND; goto gen_arith32; OP_32_64(or); c = ARITH_OR; goto gen_arith32; OP_32_64(xor); c = ARITH_XOR; goto gen_arith32; case INDEX_op_shl_i32: c = SHIFT_SLL; goto gen_arith32; case INDEX_op_shr_i32: c = SHIFT_SRL; goto gen_arith32; case INDEX_op_sar_i32: c = SHIFT_SRA; goto gen_arith32; case INDEX_op_mul_i32: c = ARITH_UMUL; goto gen_arith32; case INDEX_op_div2_i32: #if defined(__sparc_v9__) || defined(__sparc_v8plus__) c = ARITH_SDIVX; goto gen_arith32; #else tcg_out_sety(s, 0); c = ARITH_SDIV; goto gen_arith32; #endif case INDEX_op_divu2_i32: #if defined(__sparc_v9__) || defined(__sparc_v8plus__) c = ARITH_UDIVX; goto gen_arith32; #else tcg_out_sety(s, 0); c = ARITH_UDIV; goto gen_arith32; #endif case INDEX_op_brcond_i32: fprintf(stderr, "unimplemented brcond\n"); break; case INDEX_op_qemu_ld8u: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_ld8s: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_ld16u: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_ld16s: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_ld32u: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_ld32s: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_st8: fprintf(stderr, "unimplemented qst\n"); break; case INDEX_op_qemu_st16: fprintf(stderr, "unimplemented qst\n"); break; case INDEX_op_qemu_st32: fprintf(stderr, "unimplemented qst\n"); break; #if defined(__sparc_v9__) && !defined(__sparc_v8plus__) case INDEX_op_movi_i64: tcg_out_movi(s, TCG_TYPE_I64, args[0], args[1]); break; case INDEX_op_ld32s_i64: tcg_out_ldst(s, args[0], args[1], args[2], LDSW); break; case INDEX_op_ld_i64: tcg_out_ldst(s, args[0], args[1], args[2], LDX); break; case INDEX_op_st_i64: tcg_out_ldst(s, args[0], args[1], args[2], STX); break; case INDEX_op_shl_i64: c = SHIFT_SLLX; goto gen_arith32; case INDEX_op_shr_i64: c = SHIFT_SRLX; goto gen_arith32; case INDEX_op_sar_i64: c = SHIFT_SRAX; goto gen_arith32; case INDEX_op_mul_i64: c = ARITH_MULX; goto gen_arith32; case INDEX_op_div2_i64: c = ARITH_SDIVX; goto gen_arith32; case INDEX_op_divu2_i64: c = ARITH_UDIVX; goto gen_arith32; case INDEX_op_brcond_i64: fprintf(stderr, "unimplemented brcond\n"); break; case INDEX_op_qemu_ld64: fprintf(stderr, "unimplemented qld\n"); break; case INDEX_op_qemu_st64: fprintf(stderr, "unimplemented qst\n"); break; #endif gen_arith32: if (const_args[2]) { tcg_out_arithi(s, args[0], args[1], args[2], c); } else { tcg_out_arith(s, args[0], args[1], args[2], c); } break; default: fprintf(stderr, "unknown opcode 0x%x\n", opc); tcg_abort(); } }
1threat
I'm trying to get the length of my non list : I have this data I'm saving the player but I have one problem when I want to get the length of the "levels". I want to know how many levels there are with script so I don't need to keep changing an int variable and I'm also automating the process where the level gets added so I need to know how many levels there are. PlayerData = new SetupData { // Level Data Levels = new Levels { Level1 = new Level { Name = "First Level", Progress = 0, Completed = false }, Level2 = new Level { Name = "Second Level", Progress = 0, Completed = false }, }, // Character Data Player = new Player { SelectedColor = 0, Berries = 0 } }; The problem is that this isn't a list or anything so I can't use `.Length`
0debug
static void gen_mullwo(DisasContext *ctx) { TCGv_i32 t0 = tcg_temp_new_i32(); TCGv_i32 t1 = tcg_temp_new_i32(); tcg_gen_trunc_tl_i32(t0, cpu_gpr[rA(ctx->opcode)]); tcg_gen_trunc_tl_i32(t1, cpu_gpr[rB(ctx->opcode)]); tcg_gen_muls2_i32(t0, t1, t0, t1); #if defined(TARGET_PPC64) tcg_gen_concat_i32_i64(cpu_gpr[rD(ctx->opcode)], t0, t1); #else tcg_gen_mov_i32(cpu_gpr[rD(ctx->opcode)], t0); #endif tcg_gen_sari_i32(t0, t0, 31); tcg_gen_setcond_i32(TCG_COND_NE, t0, t0, t1); tcg_gen_extu_i32_tl(cpu_ov, t0); tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov); tcg_temp_free_i32(t0); tcg_temp_free_i32(t1); if (unlikely(Rc(ctx->opcode) != 0)) gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
1threat
App is crash at runtime. I also attacher the Code for the main activity and Logcat for the better underestanding : package com.example.make; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.widget.TextView; import com.google.firebase.firestore.DocumentChange; import com.google.firebase.firestore.EventListener; import com.google.firebase.firestore.FirebaseFirestore; import com.google.firebase.firestore.FirebaseFirestoreException; import com.google.firebase.firestore.QuerySnapshot; import java.util.ArrayList; import java.util.List; import javax.annotation.Nullable; import io.opencensus.tags.Tag; public class MainActivity extends AppCompatActivity { private static final String Tag = "Firelog"; private List<Users> usersList; private UsersListAdapter usersListAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RecyclerView mMainList = findViewById(R.id.main_list); usersList = new ArrayList<>(); usersListAdapter = new UsersListAdapter(usersList); mMainList.setLayoutManager(new LinearLayoutManager(MainActivity.this)); mMainList.setAdapter(usersListAdapter); TextView mName = findViewById(R.id.item_name); TextView mStatus = findViewById(R.id.item_status); try { FirebaseFirestore db = FirebaseFirestore.getInstance(); db.collection("Users").addSnapshotListener(new EventListener<QuerySnapshot>() { @Override public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) { if (e != null) { Log.d(Tag, "Error : " + e.getMessage(), new NullPointerException()); for (DocumentChange doc : queryDocumentSnapshots.getDocumentChanges()) { if (doc.getType() == DocumentChange.Type.ADDED) { doc.getDocument().getReference().collection("Users").addSnapshotListener(new EventListener<QuerySnapshot>() { @Override public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) { if (e != null) { Log.d("", "Error :" + e.getMessage(), new NullPointerException()); } for (DocumentChange doc : queryDocumentSnapshots.getDocumentChanges()) { if (doc.getType() == DocumentChange.Type.ADDED) { Log.d("USer Name :", doc.getDocument().getId()); } } } }); Users users = doc.getDocument().toObject(Users.class); usersList.add(users); usersListAdapter.notifyDataSetChanged(); } } } } }); } catch (NullPointerException error) { mName.setText(error.getMessage()); } } } Whenever i run that app than the gradle build is done successfully but the app won't be able to run it crash at run time. I searched lot on internet but not found solution so i put that problem here and below in the logcat of this app. 12-03 13:59:30.576 26036-26036/com.example.make E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.make, PID: 26036 java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.google.firebase.firestore.QuerySnapshot.getDocumentChanges()' on a null object reference at com.example.make.MainActivity$1.onEvent(MainActivity.java:65) at com.example.make.MainActivity$1.onEvent(MainActivity.java:56) at com.google.firebase.firestore.Query.lambda$addSnapshotListenerInternal$2(com.google.firebase:firebase-firestore@@17.1.3:885) at com.google.firebase.firestore.Query$$Lambda$3.onEvent(com.google.firebase:firebase-firestore@@17.1.3) at com.google.firebase.firestore.util.ExecutorEventListener.lambda$onEvent$0(com.google.firebase:firebase-firestore@@17.1.3:42) at com.google.firebase.firestore.util.ExecutorEventListener$$Lambda$1.run(com.google.firebase:firebase-firestore@@17.1.3) at android.os.Handler.handleCallback(Handler.java:754) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:163) at android.app.ActivityThread.main(ActivityThread.java:6383) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794) According to the logcat i also put the try catch block to catch the nullpointer exception but it not work.I am also new to android and firestore.
0debug
Simple Array Map Issue - JavaScript : <p>I am having a simple problem with my Javascript program. The problem is when I try to map the lengths of nested arrays, the last array is being excluded.</p> <pre><code>// the length doesnt matter, its N number of arrays var exampleArray = [ [nested array], ..., [nested array] ]; function findArrayLengths() { var arrayLengths = exampleArray.map(function(x) { return x.length; }); return arrayLengths; } </code></pre> <p>My question is, is there something obvious I'm missing. Or should this code not in theory produce a new array that contains the lengths of all the nested arrays?</p>
0debug
Access 'Internal' classes with C# interactive : <p>Using the C# interactive console in VS2015, i want to access properties and classes marked as <code>internal</code>. Usually, this is done by adding the InternalsVisibleAttribute to the project in question. Ive tried adding csc.exe as a 'friend' assembly, but i still have the access problems.</p> <ol> <li>Is this the correct approach to access internal class members via the C# interactive console?</li> <li>If it is, what dll/exe do i need to make the internals visible to?</li> </ol>
0debug
int pcm_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { AVStream *st; int block_align, byte_rate; int64_t pos; st = s->streams[0]; block_align = st->codec->block_align ? st->codec->block_align : (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3; byte_rate = st->codec->bit_rate ? st->codec->bit_rate >> 3 : block_align * st->codec->sample_rate; if (block_align <= 0 || byte_rate <= 0) return -1; pos = av_rescale_rnd(timestamp * byte_rate, st->time_base.num, st->time_base.den * (int64_t)block_align, (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP); pos *= block_align; st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num); url_fseek(s->pb, pos + s->data_offset, SEEK_SET); return 0; }
1threat
affichage des caractere en arabe php? : le probleme est l'affichage du langue arabe en php avec le francais et l'anglais ça marche bien mais en arabe il affiche seulement les ??? this is a code ` <?php // connexion $host="****"; $user="****"; $password="****"; $dbname="****"; $con=mysqli_connect($host,$user,$password,$dbname); $lang = trim($_GET['lang']); mysql_query("SET CHARACTER SET utf8"); mysql_query("SET NAMES 'utf8'"); $sql="SELECT title,image,rating,releaseYear,id,pays,language FROM user WHERE language='$lang' and pays='$rtt ' ORDER BY `user`.`id` DESC" ; $result=mysqli_query($con,$sql); if($result) { while($row=mysqli_fetch_array($result)) { $flag[]=array('title'=>utf8_encode($row['title']),'image'=>$row['image'],'rating'=>utf8_encode($row['rating']),'releaseYear'=>$row['releaseYear'],'id'=>$row['id']); } print_r(json_encode($flag, JSON_UNESCAPED_UNICODE)); } mysqli_close($con); ?>` this is a image [enter image description here][1] [1]: https://i.stack.imgur.com/EwyqQ.png
0debug
static av_cold int a64multi_encode_init(AVCodecContext *avctx) { A64Context *c = avctx->priv_data; int a; av_lfg_init(&c->randctx, 1); if (avctx->global_quality < 1) { c->mc_lifetime = 4; } else { c->mc_lifetime = avctx->global_quality /= FF_QP2LAMBDA; } av_log(avctx, AV_LOG_INFO, "charset lifetime set to %d frame(s)\n", c->mc_lifetime); c->mc_frame_counter = 0; c->mc_use_5col = avctx->codec->id == AV_CODEC_ID_A64_MULTI5; c->mc_pal_size = 4 + c->mc_use_5col; for (a = 0; a < c->mc_pal_size; a++) { c->mc_luma_vals[a]=a64_palette[mc_colors[a]][0] * 0.30 + a64_palette[mc_colors[a]][1] * 0.59 + a64_palette[mc_colors[a]][2] * 0.11; } if (!(c->mc_meta_charset = av_malloc(32000 * c->mc_lifetime * sizeof(int))) || !(c->mc_best_cb = av_malloc(CHARSET_CHARS * 32 * sizeof(int))) || !(c->mc_charmap = av_mallocz(1000 * c->mc_lifetime * sizeof(int))) || !(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t))) || !(c->mc_charset = av_malloc(0x800 * (INTERLACED+1) * sizeof(uint8_t)))) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate buffer memory.\n"); return AVERROR(ENOMEM); } if (!(avctx->extradata = av_mallocz(8 * 4 + FF_INPUT_BUFFER_PADDING_SIZE))) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate memory for extradata.\n"); return AVERROR(ENOMEM); } avctx->extradata_size = 8 * 4; AV_WB32(avctx->extradata, c->mc_lifetime); AV_WB32(avctx->extradata + 16, INTERLACED); avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) { a64multi_close_encoder(avctx); return AVERROR(ENOMEM); } avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; if (!avctx->codec_tag) avctx->codec_tag = AV_RL32("a64m"); c->next_pts = AV_NOPTS_VALUE; return 0; }
1threat
docker unauthorized: authentication required - upon push with successful login : <p>While pushing the docker image (after successful login) from my host I am getting "unauthorized: authentication required". </p> <p>Details below.</p> <pre><code>-bash-4.2# docker login --username=asamba --email=anand.sambamoorthy@gmail.com WARNING: login credentials saved in /root/.docker/config.json *Login Succeeded* -bash-4.2# -bash-4.2# docker push asamba/docker-whale Do you really want to push to public registry? [y/n]: y The push refers to a repository [docker.io/asamba/docker-whale] (len: 0) faa2fa357a0e: Preparing unauthorized: authentication required </code></pre> <ul> <li>Docker version: 1.9.1 (both client and server)</li> <li><a href="http://hub.docker.com">http://hub.docker.com</a> has the repo created as well (asamba/docker-whale). </li> </ul> <p>The /var/log/messages shows 403, I dont know if this docker. See below.</p> <pre><code>Apr 16 11:39:03 localhost journal: time="2016-04-16T11:39:03.884872524Z" level=info msg="{Action=push, Username=asamba, LoginUID=1001, PID=2125}" Apr 16 11:39:03 localhost journal: time="2016-04-16T11:39:03.884988574Z" level=error msg="Handler for POST /v1.21/images/asamba/docker-whale/push returned error: Error: Status 403 trying to push repository asamba/docker-whale to official registry: needs to be forced" Apr 16 11:39:03 localhost journal: time="2016-04-16T11:39:03.885013241Z" level=error msg="HTTP Error" err="Error: Status 403 trying to push repository asamba/docker-whale to official registry: needs to be forced" statusCode=403 Apr 16 11:39:05 localhost journal: time="2016-04-16T11:39:05.420188969Z" level=info msg="{Action=push, Username=asamba, LoginUID=1001, PID=2125}" Apr 16 11:39:06 localhost kernel: XFS (dm-4): Mounting V4 Filesystem Apr 16 11:39:06 localhost kernel: XFS (dm-4): Ending clean mount Apr 16 11:39:07 localhost kernel: XFS (dm-4): Unmounting Filesystem </code></pre> <p>Any help is appreciated, please let me know if you need further info. I did the push with -f as well. No luck!</p>
0debug
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TM2Context * const l = avctx->priv_data; AVFrame * const p= (AVFrame*)&l->pic; int i, skip, t; uint8_t *swbuf; swbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); if(!swbuf){ av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); return -1; } p->reference = 1; p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if(avctx->reget_buffer(avctx, p) < 0){ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); av_free(swbuf); return -1; } l->dsp.bswap_buf((uint32_t*)swbuf, (const uint32_t*)buf, buf_size >> 2); skip = tm2_read_header(l, swbuf); if(skip == -1){ av_free(swbuf); return -1; } for(i = 0; i < TM2_NUM_STREAMS; i++){ t = tm2_read_stream(l, swbuf + skip, tm2_stream_order[i]); if(t == -1){ av_free(swbuf); return -1; } skip += t; } p->key_frame = tm2_decode_blocks(l, p); if(p->key_frame) p->pict_type = FF_I_TYPE; else p->pict_type = FF_P_TYPE; l->cur = !l->cur; *data_size = sizeof(AVFrame); *(AVFrame*)data = l->pic; av_free(swbuf); return buf_size; }
1threat
How to stop npm serve : <p>I've build React Apps:</p> <pre><code>npm run build </code></pre> <p>and installed globally serve package:</p> <pre><code>npm install -g serve </code></pre> <p>and run it:</p> <pre><code>serve -s build </code></pre> <p>How do I stop it?</p> <p>I've tried <code>serve help</code> but it doesn't show any stop option</p> <blockquote> <p>Options:</p> <pre><code>-a, --auth Serve behind basic auth -c, --cache Time in milliseconds for caching files in the browser -n, --clipless Don't copy address to clipboard (disabled by default) -C, --cors Setup * CORS headers to allow requests from any origin (disabled by default) -h, --help Output usage information -i, --ignore Files and directories to ignore -o, --open Open local address in browser (disabled by default) -p, --port &lt;n&gt; Port to listen on (defaults to 5000) -S, --silent Don't log anything to the console -s, --single Serve single page applications (sets `-c` to 1 day) -u, --unzipped Disable GZIP compression -v, --version Output the version number </code></pre> </blockquote>
0debug
SQL Server - add/cumulative for last 3 days : <p>Table 1</p> <p>Amount</p> <pre><code>10 20 25 40 50 60 70 80 90 100 110 120 130 </code></pre> <p>Write an sql query to get output as</p> <pre><code> 07/11/2018 10 07/12/2018 20 07/13/2018 25 55 07/14/2018 40 85 07/15/2018 50 115 07/16/2018 60 150 07/17/2018 70 180 07/18/2018 80 210 07/19/2018 90 240 07/20/2018 100 270 07/21/2018 110 300 07/22/2018 120 330 07/23/2018 130 360 </code></pre> <p>So I want to add the last 3 days amount values and get the sum.</p>
0debug
In javascript, can I use the modulus operator (%) on variables instead of integers? : <p>I'm working on a Euler problem and am trying to build a function that checks a number to see if its a prime. I get error messages about the line:</p> <pre><code>if (a)%(b)==0{ </code></pre> <p>Is my syntax wrong or is it impossible to use % on a variable rather on an integer?</p> <pre><code>var x = Math.sqrt(600851475143); var y = Math.round(x); y++; console.log(y); //find all of the prime numbers up to the square root number. Put them in an array. //Check each ascending number against the prime numbers in the array to see if %=0 var primes = [2,3]; var a =(3); while (a&lt;y){ a++; isPrime(a) } function isPrime(arr){ for (var i = 0; i &lt; arr.length; i++){ var b = primes[i]; //next line is a problem if (a)%(b)==0{ break }else{ primes.push(a); } } } </code></pre>
0debug
How long would Apple support Swift 2.2? : <p>I am in a middle of a big project and we are 60% on the progress.</p> <p>We are using XCode 7.3.1 with Swift 2.2 for our project and the estimated finished time is in 5 months</p> <p>How long would Apple support this? </p>
0debug
Add prefix to all Spring Boot actuator endpoints : <p>Is there an easy way to add a prefix to all the Actuator endpoints? </p> <pre><code>/env -&gt; /secure/env /health -&gt; /secure/health /info -&gt; /secure/info ... </code></pre>
0debug
UIUserNotificationSettings deprecated in iOS 10 : <p>I am looking for the alternate way of implementing UIUserNotificationSettings in iOS 10. </p> <p>Apple documentation has given the below framework for the further usage. UNNotificationSettings in the link <a href="https://developer.apple.com/reference/usernotifications/unnotificationsettings">here</a>.</p> <p>Is there any one who can help me with the sample code to implement the below using the UNNotificationSettings instead of UIUserNotificationSettings</p> <pre><code>let notificationSettings = UIUserNotificationSettings( forTypes: [.Badge, .Sound, .Alert], categories: nil) application.registerUserNotificationSettings(notificationSettings) </code></pre>
0debug
static PullupField *make_field_queue(PullupContext *s, int len) { PullupField *head, *f; f = head = av_mallocz(sizeof(*head)); if (!f) return NULL; if (alloc_metrics(s, f) < 0) { av_free(f); return NULL; } for (; len > 0; len--) { f->next = av_mallocz(sizeof(*f->next)); if (!f->next) { free_field_queue(head, &f); return NULL; } f->next->prev = f; f = f->next; if (alloc_metrics(s, f) < 0) { free_field_queue(head, &f); return NULL; } } f->next = head; head->prev = f; return head; }
1threat
What means the comma in matplotlib? - python : <p>I can't understand the logic behind the 3rd line:</p> <pre><code>fig = plt.figure() fig.suptitle("No axes in this figure", fontsize=12) fig, ax_lst = plt.subplots(2, 2) </code></pre> <p>1st line: Plot the empty figure.</p> <p>2nd line: Title.</p> <p>3rd line: Put the graphs in the figure, but how? What's the logic? What means the comma there? (I know that <code>a+b=11</code> if <code>a,b=1+1,2+2+3</code></p>
0debug
Format function in sql 2010 : Is there any way to have the result of this function in SQL Server 2010: select FORMAT(256,'0000000#')
0debug
static void blend_frames_c(BLEND_FUNC_PARAMS) { int line, pixel; for (line = 0; line < height; line++) { for (pixel = 0; pixel < width; pixel++) { dst[pixel] = ((src1[pixel] * factor1) + (src2[pixel] * factor2) + 128) >> 8; } src1 += src1_linesize; src2 += src2_linesize; dst += dst_linesize; } }
1threat
How do i call the self.timer's changing value and indicate it at the label.text the ViewDidLoad's : i'm making a UILabel that indicates the value of the self.timer. This is the code. The problem is that i can't indicate the timeFormatter.stringFromDate(date_SSS) in the label.text. Actually i also have a scrollView and a pageControl to scroll the label horizontally. But the main problem is at the UILabel and the self.timer. How can i import UIKit class ViewController: UIViewController { private var label: UILabel! private var timer: NSTimer! let intArray: String = ["12:00:00", "12:50:00", "15:30:00", "16:40:00"] let index = 0 override func viewDidLoad() { let timeFormatter = NSDateFormatter() timeFormatter.dateFormat = "HH:mm:ss" self.timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "update:", userInfo: nil, repeats: true) self.timer.fire() for (var i = 0; i < intArray.count; i++) { let label: UILabel = UILabel(frame: CGRectMake(CGFloat(index) * 50,100,150,200) label.cornerRadius = 20 label.text = timeFormatter.stringFromDate(date_SSS) view.addSubView(label) } } func dateFromString(date:String) -> NSDate? { let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)! calendar.locale = NSLocale(localeIdentifier: "en_US_POSIX") calendar.timeZone = NSTimeZone(abbreviation: "JST")! let begin = date.startIndex guard let hour = Int(date.substringWithRange(begin..<begin.advancedBy(2))), let minute = Int(date.substringWithRange(begin.advancedBy(3)..<begin.advancedBy(5))), let second = Int(date.substringWithRange(begin.advancedBy(6)..<begin.advancedBy(8))) else{ return nil } return calendar.dateBySettingHour(hour, minute: minute, second: second, ofDate: NSDate(), options: []) } func update(timer: NSTimer) { let timeFormatter: NSDateFormatter = NSDateFormatter() timeFormatter.timeZone = NSTimeZone(name: "GMT") timeFormatter.dateFormat = "HH:mm:ss" let time = dateFromString(intArray[i]) let remain = time!.timeIntervalSinceDate(NSDate()) let date_SSS = NSDate(timeIntervalSince1970: remain) } }
0debug
Insert td in blank : I am new to programming but I am stuck with a project in Angularjs, it is the simple task of adding a blank row without any data to an html table so that you can notice the separation of the group by the Quality field and, therefore, See it in a more orderly way. When the quality data changes, the row must be inserted to separate the following information. It is understood?[enter image description here][1] View HTML [1]: https://i.stack.imgur.com/VAPib.png I have drawn a red line where I want to insert the new rows. [2]: https://i.stack.imgur.com/6yhJy.png
0debug
Check if a specific string contains any lower/uppercase : <p>Is there a way to check if a <strong>specific</strong> string contains any lower/upper case ?</p> <p>E.G :</p> <pre><code>String myStr = "test"; if (myStr.contains("test") { // I would like this condition to check the spell of "test", weather it is written like "Test" or "teSt" etc... //Do stuff } </code></pre> <p>With this syntax, it works only for the exact same string. How could I make my condition for anyform of "test", like : "Test", "tEst", "tesT" etc... ?</p>
0debug
I am new in flutter i want pass data like user details name,address,moible number,email to another screen can you tell me how to do this : <p>i want to pass some data from one screen to another scrren</p> <ol> <li>first nanme</li> <li>lastname</li> <li>email</li> <li>address</li> </ol>
0debug
static int check_refcounts_l2(BlockDriverState *bs, uint16_t *refcount_table, int refcount_table_size, int64_t l2_offset, int check_copied) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table, offset; int i, l2_size, nb_csectors, refcount; int errors = 0; l2_size = s->l2_size * sizeof(uint64_t); l2_table = qemu_malloc(l2_size); if (bdrv_pread(s->hd, l2_offset, l2_table, l2_size) != l2_size) goto fail; for(i = 0; i < s->l2_size; i++) { offset = be64_to_cpu(l2_table[i]); if (offset != 0) { if (offset & QCOW_OFLAG_COMPRESSED) { if (offset & QCOW_OFLAG_COPIED) { fprintf(stderr, "ERROR: cluster %" PRId64 ": " "copied flag must never be set for compressed " "clusters\n", offset >> s->cluster_bits); offset &= ~QCOW_OFLAG_COPIED; nb_csectors = ((offset >> s->csize_shift) & s->csize_mask) + 1; offset &= s->cluster_offset_mask; errors += inc_refcounts(bs, refcount_table, refcount_table_size, offset & ~511, nb_csectors * 512); } else { if (check_copied) { uint64_t entry = offset; offset &= ~QCOW_OFLAG_COPIED; refcount = get_refcount(bs, offset >> s->cluster_bits); if ((refcount == 1) != ((entry & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "ERROR OFLAG_COPIED: offset=%" PRIx64 " refcount=%d\n", entry, refcount); offset &= ~QCOW_OFLAG_COPIED; errors += inc_refcounts(bs, refcount_table, refcount_table_size, offset, s->cluster_size); qemu_free(l2_table); return errors; fail: fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n"); qemu_free(l2_table); return -EIO;
1threat
static int vio_make_devnode(VIOsPAPRDevice *dev, void *fdt) { VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)qdev_get_info(&dev->qdev); int vdevice_off, node_off, ret; char *dt_name; vdevice_off = fdt_path_offset(fdt, "/vdevice"); if (vdevice_off < 0) { return vdevice_off; } dt_name = vio_format_dev_name(dev); if (!dt_name) { return -ENOMEM; } node_off = fdt_add_subnode(fdt, vdevice_off, dt_name); free(dt_name); if (node_off < 0) { return node_off; } ret = fdt_setprop_cell(fdt, node_off, "reg", dev->reg); if (ret < 0) { return ret; } if (info->dt_type) { ret = fdt_setprop_string(fdt, node_off, "device_type", info->dt_type); if (ret < 0) { return ret; } } if (info->dt_compatible) { ret = fdt_setprop_string(fdt, node_off, "compatible", info->dt_compatible); if (ret < 0) { return ret; } } if (dev->qirq) { uint32_t ints_prop[] = {cpu_to_be32(dev->vio_irq_num), 0}; ret = fdt_setprop(fdt, node_off, "interrupts", ints_prop, sizeof(ints_prop)); if (ret < 0) { return ret; } } if (dev->rtce_window_size) { uint32_t dma_prop[] = {cpu_to_be32(dev->reg), 0, 0, 0, cpu_to_be32(dev->rtce_window_size)}; ret = fdt_setprop_cell(fdt, node_off, "ibm,#dma-address-cells", 2); if (ret < 0) { return ret; } ret = fdt_setprop_cell(fdt, node_off, "ibm,#dma-size-cells", 2); if (ret < 0) { return ret; } ret = fdt_setprop(fdt, node_off, "ibm,my-dma-window", dma_prop, sizeof(dma_prop)); if (ret < 0) { return ret; } } if (info->devnode) { ret = (info->devnode)(dev, fdt, node_off); if (ret < 0) { return ret; } } return node_off; }
1threat
Sequel Pro and MySQL connection failed : <p>I just installed mysql on mac from Homebrew </p> <pre><code>brew install mysql mysql -V mysql Ver 8.0.11 for osx10.13 on x86_64 (Homebrew) </code></pre> <p>from terminal it works and I can login to mysql but from Sequel Pro it says</p> <p><a href="https://i.stack.imgur.com/CIJGy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CIJGy.png" alt="enter image description here"></a></p> <blockquote> <p>Unable to connect to host 127.0.0.1, or the request timed out.</p> <p>Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).</p> <p>MySQL said: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2): image not found</p> </blockquote> <p>can't figure out what I am missing</p>
0debug
How can I use Swift 2.3 in XCode 8 Playgrounds? : <p>I have my playground project written in Swift 2.2 and I want take advantage of timeline visuals and try new debug features introduced in Xcode 8 beta. By default, Xcode 8 beta is using Swift 3 in Playgrounds and I cannot find a way to change that. Updating my code to Swift 3 is not an option unfortunately, because my code will be compiled on server with Swift 2.2 environment.</p>
0debug
static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); RawVideoContext *context = avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int need_copy = !avpkt->buf || context->is_2_4_bpp || context->is_yuv2; int res; AVFrame *frame = data; AVPicture *picture = data; frame->pict_type = AV_PICTURE_TYPE_I; frame->key_frame = 1; frame->reordered_opaque = avctx->reordered_opaque; frame->pkt_pts = avctx->internal->pkt->pts; if (buf_size < context->frame_size - (avctx->pix_fmt == AV_PIX_FMT_PAL8 ? AVPALETTE_SIZE : 0)) return -1; if (need_copy) frame->buf[0] = av_buffer_alloc(context->frame_size); else frame->buf[0] = av_buffer_ref(avpkt->buf); if (!frame->buf[0]) return AVERROR(ENOMEM); if (context->is_2_4_bpp) { int i; uint8_t *dst = frame->buf[0]->data; buf_size = context->frame_size - AVPALETTE_SIZE; if (avctx->bits_per_coded_sample == 4) { for (i = 0; 2 * i + 1 < buf_size; i++) { dst[2 * i + 0] = buf[i] >> 4; dst[2 * i + 1] = buf[i] & 15; } } else { for (i = 0; 4 * i + 3 < buf_size; i++) { dst[4 * i + 0] = buf[i] >> 6; dst[4 * i + 1] = buf[i] >> 4 & 3; dst[4 * i + 2] = buf[i] >> 2 & 3; dst[4 * i + 3] = buf[i] & 3; } } buf = dst; } else if (need_copy) { memcpy(frame->buf[0]->data, buf, FFMIN(buf_size, context->frame_size)); buf = frame->buf[0]->data; } if (avctx->codec_tag == MKTAG('A', 'V', '1', 'x') || avctx->codec_tag == MKTAG('A', 'V', 'u', 'p')) buf += buf_size - context->frame_size; if ((res = avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height)) < 0) return res; if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); if (pal) { av_buffer_unref(&context->palette); context->palette = av_buffer_alloc(AVPALETTE_SIZE); if (!context->palette) return AVERROR(ENOMEM); memcpy(context->palette->data, pal, AVPALETTE_SIZE); frame->palette_has_changed = 1; } } if ((avctx->pix_fmt == AV_PIX_FMT_PAL8 && buf_size < context->frame_size) || (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)) { frame->buf[1] = av_buffer_ref(context->palette); if (!frame->buf[1]) return AVERROR(ENOMEM); frame->data[1] = frame->buf[1]->data; } if (avctx->pix_fmt == AV_PIX_FMT_BGR24 && ((frame->linesize[0] + 3) & ~3) * avctx->height <= buf_size) frame->linesize[0] = (frame->linesize[0] + 3) & ~3; if (context->flip) flip(avctx, picture); if (avctx->codec_tag == MKTAG('Y', 'V', '1', '2') || avctx->codec_tag == MKTAG('Y', 'V', '1', '6') || avctx->codec_tag == MKTAG('Y', 'V', '2', '4') || avctx->codec_tag == MKTAG('Y', 'V', 'U', '9')) FFSWAP(uint8_t *, picture->data[1], picture->data[2]); if (avctx->codec_tag == AV_RL32("yuv2") && avctx->pix_fmt == AV_PIX_FMT_YUYV422) { int x, y; uint8_t *line = picture->data[0]; for (y = 0; y < avctx->height; y++) { for (x = 0; x < avctx->width; x++) line[2 * x + 1] ^= 0x80; line += picture->linesize[0]; } } *got_frame = 1; return buf_size; }
1threat
def check_subset(list1,list2): return all(map(list1.__contains__,list2))
0debug
Electron app with database : <p>I'm creating a web app for ticket reservation. The only problem is the database. I don't want to tell my client to install XAMPP or set a database, etc. </p> <p>Is there any way to package the app with the database? </p>
0debug
static int mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size, UINT8 *buf, int buf_size) { MJpegDecodeContext *s = avctx->priv_data; UINT8 *buf_end, *buf_ptr, *buf_start; int len, code, input_size, i; AVPicture *picture = data; unsigned int start_code; *data_size = 0; if (buf_size == 0) return 0; buf_ptr = buf; buf_end = buf + buf_size; while (buf_ptr < buf_end) { buf_start = buf_ptr; code = find_marker(&buf_ptr, buf_end, &s->header_state); len = buf_ptr - buf_start; if (len + (s->buf_ptr - s->buffer) > s->buffer_size) { s->buf_ptr = s->buffer; if (code > 0) s->start_code = code; } else { memcpy(s->buf_ptr, buf_start, len); s->buf_ptr += len; if (code == 0 || code == 0xff) { s->buf_ptr--; } else if (code > 0) { input_size = s->buf_ptr - s->buffer; start_code = s->start_code; s->buf_ptr = s->buffer; s->start_code = code; dprintf("marker=%x\n", start_code); switch(start_code) { case SOI: break; case DQT: mjpeg_decode_dqt(s, s->buffer, input_size); break; case DHT: mjpeg_decode_dht(s, s->buffer, input_size); break; case SOF0: mjpeg_decode_sof0(s, s->buffer, input_size); break; case SOS: mjpeg_decode_sos(s, s->buffer, input_size); if (s->start_code == EOI) { int l; if (s->interlaced) { s->bottom_field ^= 1; if (s->bottom_field) goto the_end; } for(i=0;i<3;i++) { picture->data[i] = s->current_picture[i]; l = s->linesize[i]; if (s->interlaced) l >>= 1; picture->linesize[i] = l; } *data_size = sizeof(AVPicture); avctx->height = s->height; if (s->interlaced) avctx->height *= 2; avctx->width = s->width; switch((s->h_count[0] << 4) | s->v_count[0]) { case 0x11: avctx->pix_fmt = PIX_FMT_YUV444P; break; case 0x21: avctx->pix_fmt = PIX_FMT_YUV422P; break; default: case 0x22: avctx->pix_fmt = PIX_FMT_YUV420P; break; } avctx->quality = 3; goto the_end; } break; } } } } the_end: return buf_ptr - buf; }
1threat
How to manually lazy load a module? : <p>I've tried loading modules without router using <a href="https://angular.io/docs/ts/latest/api/core/index/SystemJsNgModuleLoader-class.html"><code>SystemJsNgModuleLoader</code></a>, but couldn't get it to work:</p> <pre><code>this.loader.load(url).then(console.info); </code></pre> <p>I'm getting <code>Cannot find module xxx</code> for whatever string I use for URL (aboslute/relative urls/paths... tried many options). I looked through Router source code and couldn't find anything other then this <code>SystemJsNgModuleLoader</code>. I'm not even sure I should be using this...</p> <hr> <p>This question was asked just yesterday at <code>ng-europe 2016</code> conference - Miško &amp; Matias answered:</p> <blockquote> <p><strong>Miško Hevery:</strong> One just has to <em>get hold of the module</em>, from there you can get the hold of component factory and you can dynamically load component factory anywhere you want in the application. This is exactly what the router does internally. So it's quite strait forward for you to do that as well.</p> <p><strong>Matias Niemelä</strong> The only special thing to note is that on the [Ng]Module there's something called <code>entryComponents</code> and that identifies components that could be lazy loaded - that's the entry into that component set. So when you have modules that are lazy loaded, please put <em>the stuff</em> into <code>entryComponents</code>.</p> </blockquote> <p>...but it's not that strait forward without examples and poor docs on the subject (; </p> <p>Anyone knows how to load modules manually, without using <code>Route.loadChildren</code>? How to <em>get hold of the module</em> and what exactly is <em>the stuff</em> that should go into <code>entryComponents</code> (I read <a href="https://angular.io/docs/ts/latest/cookbook/ngmodule-faq.html#!#q-entry-component-defined">FAQ</a>, but can't try without actually loading module)?</p>
0debug
1004 error when trying to insert formula with "vlookup" : <p>I am new to vba (actually started yesterday) so please excuse my ignorance on details I should include in my question.</p> <p>I am trying to use a macro to insert a formula containing "vlookup" into a cell in excel. However, if I try to run the macro, I get an error "1004 - application defined or object defined error"</p> <p>The line that causes the issue:</p> <pre><code>Worksheets("Berechnungen").Cells(19, 10).Formula = "=VLOOKUP(R3C1;R9C1:R12C1;16;FALSE)" </code></pre> <p>I tried different formulas like</p> <pre><code>Worksheets("Berechnungen").Cells(19, 10).Formula = "=SUM(R3C4:R3C5)" </code></pre> <p>that all worked like a charm.</p> <p>I am using Microsoft Office 365 ProPlus, version 1708 in German language.</p> <p>Please let me know if you require any additional information!</p> <p>Thanks for your help!</p>
0debug
how to solve this segmentation fault : i try to make a char matrix for a tic tak toe game i allocated memory for it but i can't access it , it shows me a segmentation fault i can't figure out why #include <stdio.h> #include <stdlib.h> //fonction to make a char matrix void make_board (char** board){ board = malloc(sizeof(char*)*3); for(int i=0;i<3;i++){ board[i] = malloc(sizeof(char)*3); } for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ board[i][j]='x'; } } } //main fonction int main (){ char ** board; make_board(board); printf("%c\n",**board);/*when i try to access it it show me a segmentation fault*/
0debug
shouldAutorotate() function in Xcode 8 beta 4 : <p>I updated Xcode 8 beta 3 to Xcode 8 beta 4 and I am actually correcting some bugs due to swift changement.</p> <p>Function :</p> <pre><code> override func shouldAutorotate() -&gt; Bool { return false } </code></pre> <p>Print an error and Xcode told me that this function is not override. It's mean that the function does not exist anymore.</p> <pre><code>override var shouldAutorotate </code></pre> <p>This var has just get properties so I can't change the value by this way.</p> <p>So how can I work with autorotate now ?</p> <p>Thanks !</p>
0debug
static void bmdma_irq(void *opaque, int n, int level) { BMDMAState *bm = opaque; if (!level) { qemu_set_irq(bm->irq, level); return; } if (bm) { bm->status |= BM_STATUS_INT; } qemu_set_irq(bm->irq, level); }
1threat
python wand.image is not recognized : <p>I installed Imagemagic (both 32 and 64 bits versions were tried) and then used pip to install wand, I also set the Magick_Home env. variable to imagemagic address but when I run </p> <blockquote> <p><code>Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "c:\Anaconda2\lib\site-packages\wand\image.py", line 20, in &lt;module&gt; from .api import MagickPixelPacket, libc, libmagick, library File "c:\Anaconda2\lib\site-packages\wand\api.py", line 205, in &lt;module&gt; 'Try to install:\n ' + msg) ImportError: MagickWand shared library not found. You probably had not installed ImageMagick library. Try to install: http://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-windows</code></p> </blockquote>
0debug
how to convert keys values map to slice of int : <p>i'm trying to convert key-value map to slice of 2 value, for example :</p> <pre><code>slices := make(map[int64]int64) slices[int64(521)] = int64(4) slices[int64(528)] = int64(8) // how do i convert that to become // [[521, 4], [528, 8]] </code></pre> <p>i'm thinking about each all those key-value then create slice for that, but is there any simple code to do that ?</p>
0debug
Roslyn compiler optimizing away function call multiplication with zero : <p>Yesterday I found this strange behavior in my C# code:</p> <pre><code>Stack&lt;long&gt; s = new Stack&lt;long&gt;(); s.Push(1); // stack contains [1] s.Push(2); // stack contains [1|2] s.Push(3); // stack contains [1|2|3] s.Push(s.Pop() * 0); // stack should contain [1|2|0] Console.WriteLine(string.Join("|", s.Reverse())); </code></pre> <p>I assumed the program would print <code>1|2|0</code> but in fact it printed <code>1|2|3|0</code>.</p> <p>Looking at the generated IL code (via ILSpy) you can see that <code>s.Pop() * 0</code> is optimized to simply <code>0</code>:</p> <pre><code>// ... IL_0022: ldloc.0 IL_0023: ldc.i4.0 IL_0024: conv.i8 IL_0025: callvirt instance void class [System]System.Collections.Generic.Stack`1&lt;int64&gt;::Push(!0) // ... </code></pre> <p><em>ILSpy decompilation</em>:</p> <pre><code>Stack&lt;long&gt; s = new Stack&lt;long&gt;(); s.Push(1L); s.Push(2L); s.Push(3L); s.Push(0L); // &lt;- the offending line Console.WriteLine(string.Join&lt;long&gt;("|", s.Reverse&lt;long&gt;())); </code></pre> <p>First I tested this initially under Windows 7 with Visual Studio 2015 Update 3 with both Release mode (<code>/optimize</code>) and Debug mode and with various target frameworks (4.0, 4.5, 4.6 and 4.6.1). In all 8 cases the result was the same (<code>1|2|3|0</code>).</p> <p>Then I tested it under Windows 7 with Visual Studio 2013 Update 5 (again with all the combinations of Release/Debug mode and target framework). To my surprise the statement is here <em>not</em> optimized away and yields the expected result <code>1|2|0</code>.</p> <p>So I can conclude that this behavior is neither dependent on <code>/optimize</code> nor the target framework flag but rather on the used compiler version.</p> <p>Out of interest I wrote a similar code in C++ and compiled it with the current gcc version. Here a function call multiplied with zero is not optimized away and the function is properly executed.</p> <p>I think such an optimization would only be valid if <code>stack.Pop()</code> were a pure function (which it definitely isn't). But I'm hesitant to call this a bug, I assume it's just a feature unknown to me?</p> <p>Is this "feature" anywhere documented and is there an (easy) way to disable this optimization?</p>
0debug
AWS elastic search error "[Errno 8] nodename nor servname provided, or not known." : <p>I created one AWS elasticsearch instance. I want to access it using a python script. I specified my AWS configuration (access key, secret key, region). I am using below code to access the AWS ES instance:</p> <pre><code>from elasticsearch import Elasticsearch, RequestsHttpConnection from requests_aws4auth import AWS4Auth AWS_ACCESS_KEY = '**************' AWS_SECRET_KEY = '*****************' region = 'us-east-1' service = 'es' awsauth = AWS4Auth(AWS_ACCESS_KEY, AWS_SECRET_KEY, region, service) host = 'https://kbckjsdkcdn.us-east-1.es.amazonaws.com' # For example, my-test-domain.us-east-1.es.amazonaws.com es = Elasticsearch( hosts = [{'host': host, 'port': 443}], http_auth = awsauth, use_ssl = True, verify_certs = True, connection_class = RequestsHttpConnection ) print es.info() </code></pre> <p>When I am running the above code, I am getting following error:</p> <pre><code>elasticsearch.exceptions.ConnectionError: ConnectionError(HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //search-opendata-2xd6pwilq5sv4ahomcuaiyxmqe.us-east-1.es.amazonaws.com:443/ (Caused by NewConnectionError('&lt;urllib3.connection.VerifiedHTTPSConnection object at 0x10ee72310&gt;: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))) caused by: ConnectionError(HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //search-opendata-2xd6pwilq5sv4ahomcuaiyxmqe.us-east-1.es.amazonaws.com:443/ (Caused by NewConnectionError('&lt;urllib3.connection.VerifiedHTTPSConnection object at 0x10ee72310&gt;: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))) </code></pre> <p>How can I resolve this error?</p> <p>Thanks</p>
0debug
static void vnc_write_u16(VncState *vs, uint16_t value) { uint8_t buf[2]; buf[0] = (value >> 8) & 0xFF; buf[1] = value & 0xFF; vnc_write(vs, buf, 2); }
1threat
Exception occurs during processing of wait and notify in java? : I was looking at a producer-consumer example with wait and notify, even though it works some times it gives exception. Not able to figure out where the problem is. Exception in thread "Thread-5" java.util.NoSuchElementException at java.util.LinkedList.removeFirst(Unknown Source) at com.bhatsac.workshop.producerconsumer.ProdNConsumer.consumer(ProdNConsumer.java:55) at com.bhatsac.workshop.producerconsumer.ProdConsumerInvoker.lambda$5(ProdConsumerInvoker.java:35) at java.lang.Thread.run(Unknown Source) Below is the code block import java.util.LinkedList; import java.util.concurrent.atomic.AtomicInteger; public class ProdNConsumer { LinkedList<Integer> list = new LinkedList<Integer>(); private int LIMIT = 1; private volatile boolean shutdown = false; private AtomicInteger counter=new AtomicInteger(0); private Object lock=new Object(); public void produce() { while (true) { synchronized(lock){ System.out.println("In producer :)"+ list.size()); if(this.list.size()==this.LIMIT){ try { System.out.println("In waiting state producer"); lock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } System.out.println("Produced by thread= "+ Thread.currentThread().getName()); list.add(counter.getAndIncrement()); System.out.println("Going to sleep for a while"); lock.notifyAll(); } try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public void consumer() { while (true) { synchronized(lock){ System.out.println("In consumer :)"); if(list.size()==0){ try { System.out.println("In waiting state consumer"); lock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } System.out.println("consumed by thread="+ Thread.currentThread().getName()); list.removeFirst(); lock.notifyAll(); } try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } public class ProdConsumerInvoker { public static void main(String[] args) { ProdNConsumer pc= new ProdNConsumer(); Thread tc1=new Thread(()->{ pc.consumer(); }); new Thread(()->{ pc.produce(); }).start(); new Thread(()->{ pc.produce(); }).start(); Thread tp1=new Thread(()->{ pc.produce(); }); new Thread(()->{ pc.consumer(); }).start(); new Thread(()->{ pc.consumer(); }).start(); tp1.start(); tc1.start(); } }
0debug
How do I assine an adress to each item in the list? : I'm trying to create a binary search however I get the error 'list indices must be integers, not str' with the line 'i == alist[i]'. Please could you help me fix the problem. Heres the whole code. def bsort(alist, i): left = 0 right = len(alist)-1 i == alist[i] [mid] = (left + right)//2 if alist[mid] < i : left = [mid] + 1 elif alis[mid] > i : right = [mid] + 1 elif alist[mid] == i : print ("word found at", i ) elif left > right: print ("Not Found!") i = input("Enter a search >") alist = ["rat","cat","bat","sat","spat"] bsort(alist, i) Thank you.
0debug
Top margin pulls top element : <p>Container is pulled down when inner element puts top margin so white section appear at the top of page. How can i prevent that white section ? </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.container { background: red; height: 500px; } .inner { margin-top: 100px; height: 50px; background: yellow; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>Why there is white section in here ?? &lt;div class="container"&gt; &lt;div class="inner"&gt;&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
0debug
static ssize_t vnc_client_write_tls(gnutls_session_t *session, const uint8_t *data, size_t datalen) { ssize_t ret = gnutls_write(*session, data, datalen); if (ret < 0) { if (ret == GNUTLS_E_AGAIN) { errno = EAGAIN; } else { errno = EIO; } ret = -1; } return ret; }
1threat
How to change text color of picker view in swift? : <p>Been trying to find an answer but can't find a genuine answer. Thanks in advance. -Tom</p>
0debug
void avcodec_get_context_defaults(AVCodecContext *s){ memset(s, 0, sizeof(AVCodecContext)); s->av_class= &av_codec_context_class; s->bit_rate= 800*1000; s->bit_rate_tolerance= s->bit_rate*10; s->qmin= 2; s->qmax= 31; s->mb_qmin= 2; s->mb_qmax= 31; s->rc_eq= "tex^qComp"; s->qcompress= 0.5; s->max_qdiff= 3; s->b_quant_factor=1.25; s->b_quant_offset=1.25; s->i_quant_factor=-0.8; s->i_quant_offset=0.0; s->error_concealment= 3; s->error_resilience= 1; s->workaround_bugs= FF_BUG_AUTODETECT; s->frame_rate_base= 1; s->frame_rate = 25; s->gop_size= 50; s->me_method= ME_EPZS; s->get_buffer= avcodec_default_get_buffer; s->release_buffer= avcodec_default_release_buffer; s->get_format= avcodec_default_get_format; s->execute= avcodec_default_execute; s->thread_count=1; s->me_subpel_quality=8; s->lmin= FF_QP2LAMBDA * s->qmin; s->lmax= FF_QP2LAMBDA * s->qmax; s->sample_aspect_ratio= (AVRational){0,1}; s->ildct_cmp= FF_CMP_VSAD; s->profile= FF_PROFILE_UNKNOWN; s->level= FF_LEVEL_UNKNOWN; s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS; s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS; s->palctrl = NULL; s->reget_buffer= avcodec_default_reget_buffer; }
1threat
How do I make a div tag display if I have it hidden on CSS using Javascript? : <p>In CSS I have a div tag that is like a comment section, but I want it hidden until the user clicks on the comment image. How do I make the div display when the user clicks on it using JavaScript?</p> <p><strong>HTML</strong>:</p> <pre><code>&lt;div class = "comments"&gt; &lt;img onclick = "commentBar()" src = "comment.png" /&gt; &lt;/div&gt; </code></pre> <p><strong>CSS:</strong></p> <pre><code>.comments{ width: 200px; height: 200px; background-color: blue; display: none; } </code></pre> <p>How do I make the div tag re-appear when I click on the image?</p>
0debug
Why does the std::copy_if signature not constrain the predicate type : <p>Imagine we have the following situation: </p> <pre><code>struct A { int i; }; struct B { A a; int other_things; }; bool predicate( const A&amp; a) { return a.i &gt; 123; } bool predicate( const B&amp; b) { return predicate(b.a); } int main() { std::vector&lt; A &gt; a_source; std::vector&lt; B &gt; b_source; std::vector&lt; A &gt; a_target; std::vector&lt; B &gt; b_target; std::copy_if(a_source.begin(), a_source.end(), std::back_inserter( a_target ), predicate); std::copy_if(b_source.begin(), b_source.end(), std::back_inserter( b_target ), predicate); return 0; } </code></pre> <p>Both the call to <code>std::copy_if</code> generate a compile error, because the correct overload of <code>predicate()</code> function cannot be infered by the compiler since the <code>std::copy_if</code> template signature accepts any type of predicate:</p> <pre><code>template&lt;typename _IIter, typename _OIter, typename _Predicate&gt; _OIter copy_if( // etc... </code></pre> <p>I found the overload resolution working if I wrap the <code>std::copy_if</code> call into a more constrained template function:</p> <pre><code>template&lt;typename _IIter, typename _OIter, typename _Predicate = bool( const typename std::iterator_traits&lt;_IIter&gt;::value_type&amp; ) &gt; void copy_if( _IIter source_begin, _IIter source_end, _OIter target, _Predicate pred) { std::copy_if( source_begin, source_end, target, pred ); } </code></pre> <p>My question is: why in the STL is it not already constrained like this? From what I've seen, if the <code>_Predicate</code> type is not a function that returns <code>bool</code> and accepts the iterated input type, it is going to generate a compiler error anyway. So why not putting this constrain already in the signature, so that overload resolution can work?</p>
0debug
Comparing Apache Livy with spark-jobserver : <p>I know Apache Livy is the rest interface for interacting with spark from anywhere. So what is the benefits of using Apache Livy instead of spark-jobserver. What are the drawbacks of spark-jobserver for which Livy is used as an alternative. And I couldn't find much on this on the internet. Can you please help me to get clarity on this.</p> <p>Thanks,</p>
0debug
Why this code is incorrect?(Set) : <p><strong>this has error ㅠㅠ</strong> error</p> <p>error!!<em>emphasized text</em> dkdkd</p> <pre><code>import java.util.*; public class SetExam { public static void main(String[] args) { Set&lt;String&gt;set = new HashSet&lt;String&gt;(); set.add("a"); set.add("b"); Iterator&lt;String&gt; iter = set.iterator(); While(iter.hasNext()){ //this point it's error String str = iter.next(); System.out.println(str); } } </code></pre> <p>while ~~ this has error why is it incorrect?</p>
0debug
Can you omit the return type in main function? : <p>Are there some special rules with respect to the declaration of the <code>main</code> function?</p> <p>According to <a href="http://ideone.com/eEoa8n">ideone</a> this is legal C++:</p> <pre><code>main() // As opposed to int main() { return 0; } </code></pre> <p>On the other hand, normal functions do not seem to have the privilege to avoid the return type:</p> <pre><code>f(){} int main() { return 0; } </code></pre> <p>Gives the error:</p> <blockquote> <p>prog.cpp:1:3: error: ISO C++ forbids declaration of 'f' with no type [-fpermissive] f(){} ^</p> </blockquote> <p>Is the <code>main</code> function special in this case?</p>
0debug
Adding Strings to a list from textfield : im triying to add "players" to a list (observablelist) throug a textfield input. @FXML void ingresar_tabla(){ String jugador = t_ingresarjudaror.getText(); Jugador juga = new Jugador(jugador); lista_Jugadores = FXCollections.observableArrayList(); lista_Jugadores.add(juga); juga.setNombre(jugador); colJugador.setCellValueFactory(new PropertyValueFactory<>("nombre")); t_tabla.setItems(lista_Jugadores); t_tabla.refresh(); System.out.println(lista_Jugadores); } problem is that eveytime i enter a new name in the textfield, the list keep only the last value, forgeting the rest. How can i keep all the records? i dont want to use a DB (i have the same system with db and it works good). SORRY MY ENGLISH!
0debug
Elements in an array will not change c++ : <pre><code> void Remove(int x)//x is the number that i want to remove { for(int i=0;i&lt;CAPACITY;i++)//loop is to find the first case of x { if(x==data[i])//if x is in data { cout&lt;&lt;data[i]&lt;&lt;endl;//for debugging data[i]==0; //change x to 0 cout&lt;&lt;data[i]&lt;&lt;endl; } } } </code></pre> <p>when i cout to see if it works the number that i wanted to delete is still there. Here is the output before i run it when x=15:<br> 12,15,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 <br> I used cout to see if there was a problem with the condition however it runs if x is in the array. Here is the output after, even if x is in the array:<br> 12,15,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</p>
0debug
Sending songlist containing track no, title, artist, album, genre and duration over socket? : I want to send these songs details to another phone over socket. Please tell me the approach.
0debug
Vectorisation of for loop with multiple conditions : <pre><code>dummies = matrix(c(0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0), nrow=6, ncol=6) colnames(dummies) &lt;- c("a","b", "c", "d", "e", "f") </code></pre> <p>I have a matrix with dummies</p> <pre><code>&gt; dummies a b c d e f [1,] 0 0 0 0 1 0 [2,] 0 0 1 0 0 0 [3,] 1 0 0 0 0 0 [4,] 0 0 0 0 0 1 [5,] 0 1 0 0 0 0 [6,] 0 0 0 1 0 0 </code></pre> <p>I know that my dummies are related in that line 1 is grouped with 2, 3 with 4, and 5 with 6. I want to split each dummy code(1) between those in the same group on the same line as above:</p> <pre><code>&gt; dummies a b c d e f [1,] 0.0 0.0 -0.5 0.0 0.5 0.0 [2,] 0.0 0.0 0.5 0.0 -0.5 0.0 [3,] 0.5 0.0 0.0 0.0 0.0 -0.5 [4,] -0.5 0.0 0.0 0.0 0.0 0.5 [5,] 0.0 0.5 0.0 -0.5 0.0 0.0 [6,] 0.0 -0.5 0.0 0.5 0.0 0.0 </code></pre> <p>To achieve this, I do the following:</p> <pre><code>dummies &lt;- ifelse(dummies==1, 0.5, 0) for (i in 1:nrow(dummies)){ column = which(dummies[i,] %in% 0.5) if (i %% 2 != 0) { dummies[i+1, column] &lt;- -0.5 } else { dummies[i-1, column] &lt;- -0.5 } } </code></pre> <p>My question is whether I could achieve this with vectorised code. I cannot figure out how to use <code>ifelse</code> in this case because I cannot combine it with the line indexing to find the <code>0.5</code> on each line. </p>
0debug
void qemu_update_position(QEMUFile *f, size_t size) { f->pos += size; }
1threat
static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, AVDictionary *opts, AVDictionary *opts2, int *is_http) { HLSContext *c = s->priv_data; AVDictionary *tmp = NULL; const char *proto_name = NULL; int ret; av_dict_copy(&tmp, opts, 0); av_dict_copy(&tmp, opts2, 0); if (av_strstart(url, "crypto", NULL)) { if (url[6] == '+' || url[6] == ':') proto_name = avio_find_protocol_name(url + 7); } if (!proto_name) proto_name = avio_find_protocol_name(url); if (!proto_name) return AVERROR_INVALIDDATA; if (!av_strstart(proto_name, "http", NULL) && !av_strstart(proto_name, "file", NULL)) return AVERROR_INVALIDDATA; if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] == ':') ; else if (av_strstart(url, "crypto", NULL) && !strncmp(proto_name, url + 7, strlen(proto_name)) && url[7 + strlen(proto_name)] == ':') ; else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5)) return AVERROR_INVALIDDATA; ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp); if (ret >= 0) { char *new_cookies = NULL; if (!(s->flags & AVFMT_FLAG_CUSTOM_IO)) av_opt_get(*pb, "cookies", AV_OPT_SEARCH_CHILDREN, (uint8_t**)&new_cookies); if (new_cookies) { av_free(c->cookies); c->cookies = new_cookies; } av_dict_set(&opts, "cookies", c->cookies, 0); } av_dict_free(&tmp); if (is_http) *is_http = av_strstart(proto_name, "http", NULL); return ret; }
1threat
IntelliJ annotate vs git blame : <p>I am using IntelliJ's annotate feature to see in the editor who last changed a line in a file. </p> <p>Now I am using JGit to read the same annotations and they differ. For me it seems that Intellij checks that a line has not been changed between commits and still uses the old commit message. JGit does not see it and so makes an other message. </p> <p>Can anybody confirm that the behavior of JGit blame and IntelliJ differs? Whats the reason and how can I force IntelliJ to behave the same like JGit? Maybe IntelliJ ignores whitespace changes?</p> <p>I am using IntelliJ 15.0.1 and JGit 4.1.1</p>
0debug
static void qemu_aio_complete(void *opaque, int ret) { struct ioreq *ioreq = opaque; if (ret != 0) { xen_be_printf(&ioreq->blkdev->xendev, 0, "%s I/O error\n", ioreq->req.operation == BLKIF_OP_READ ? "read" : "write"); ioreq->aio_errors++; } ioreq->aio_inflight--; if (ioreq->presync) { ioreq->presync = 0; ioreq_runio_qemu_aio(ioreq); return; } if (ioreq->aio_inflight > 0) { return; } if (ioreq->postsync) { ioreq->postsync = 0; ioreq->aio_inflight++; blk_aio_flush(ioreq->blkdev->blk, qemu_aio_complete, ioreq); return; } ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY; ioreq_unmap(ioreq); ioreq_finish(ioreq); switch (ioreq->req.operation) { case BLKIF_OP_WRITE: case BLKIF_OP_FLUSH_DISKCACHE: if (!ioreq->req.nr_segments) { break; } case BLKIF_OP_READ: block_acct_done(blk_get_stats(ioreq->blkdev->blk), &ioreq->acct); break; case BLKIF_OP_DISCARD: default: break; } qemu_bh_schedule(ioreq->blkdev->bh); }
1threat
Fragment not getting replaced on click : <p>I have an <code>Activity</code> which consists of a <code>Fragment</code>. The <code>Fragment</code> has two ViewGroups (LinearLayouts),which I want to use like buttons to change the layout of that very <code>Fragment</code>. </p> <p>I am facing two problems in this:<br> 1. The two LinearLayouts don't give any visual touch-feedback (ripple animation) even when <code>clickable="true"</code> and <code>android:background="?attr/selectableItemBackground"</code> is set.<br> 2. The <code>Fragment</code> doesn't get replaced by a new <code>Fragment</code> even though <code>onClickListener</code> for the two <code>LinearLayout</code> works (checked using a <code>Snackbar</code>).<br> 3. In the statement <code>fragmentManager.beginTransaction().add(R.id.fragment_linearlayout,sb_qa_defaultFragment).commit();</code>, I read on SO that the first argument of add should not be the id of the <code>fragment</code> itself but the <code>container</code> of the <code>fragment</code>. Is it true ? Because I got the same behaviour setting id of the <code>fragment</code> or its <code>container</code> as the first argument.</p> <p><strong>MainActivity</strong></p> <pre><code>public class sb_question extends AppCompatActivity{ private LinearLayout typeAnswerLL, recordAnswerLL ; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sb_question_new); final FragmentManager fragmentManager = getSupportFragmentManager(); SB_QA_defaultFragment sb_qa_defaultFragment = new SB_QA_defaultFragment(); final SB_TextAnswerFragment sb_textAnswerFragment = new SB_TextAnswerFragment(); fragmentManager.beginTransaction().add(R.id.fragment_linearlayout,sb_qa_defaultFragment).commit(); typeAnswerLL = (LinearLayout) findViewById(R.id.type_answer_linearlayout); typeAnswerLL.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // THIS STATEMENT BELOW DOESN'T WORK AND DOES NOTHING fragmentManager.beginTransaction().replace(R.id.fragment_linearlayout, sb_textAnswerFragment).commit(); // Snackbar snackbar = Snackbar.make(view, "Type Answer", Snackbar.LENGTH_SHORT); // snackbar.show(); } }); recordAnswerLL = (LinearLayout) findViewById(R.id.record_answer_linearlayout); recordAnswerLL.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar snackbar = Snackbar.make(view, "Record Answer", Snackbar.LENGTH_SHORT); snackbar.show(); } }); } </code></pre> <p><strong>Layout of MainActivity</strong> </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;android.support.v7.widget.Toolbar android:id="@+id/sb_ques_toolbar" android:elevation="4dp" android:background="@android:color/background_dark" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"&gt; &lt;TextView android:layout_gravity="center_horizontal" android:textStyle="bold" android:textSize="18sp" android:id="@+id/sb_ques_toolbar_title" android:textColor="@android:color/white" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/android.support.v7.widget.Toolbar&gt; &lt;LinearLayout android:orientation="vertical" android:padding="@dimen/activity_horizontal_margin" android:background="@android:color/black" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;LinearLayout android:orientation="vertical" android:layout_weight="0.7" android:layout_width="match_parent" android:layout_height="0dp"&gt; &lt;TextView android:padding="@dimen/activity_horizontal_margin" android:textColor="@android:color/black" android:background="@android:color/white" android:id="@+id/sb_ques_text" android:minHeight="70dp" android:layout_width="match_parent" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:id="@+id/fragment_linearlayout" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="0dp"&gt; &lt;fragment android:id="@+id/text_record_fragment" android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.example.yankee.cw.SB_QA_defaultFragment"&gt; &lt;/fragment&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:gravity="center|bottom" android:layout_width="match_parent" android:layout_height="wrap_content"&gt; &lt;Button android:padding="@dimen/activity_horizontal_margin" android:textAllCaps="true" android:text="Save &amp;amp; Exit" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" /&gt; &lt;Button android:padding="@dimen/activity_horizontal_margin" android:textAllCaps="true" android:text="Skip Question" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>If it helps, here is the XML Layout of the <code>Fragment</code> I set as default when the <code>Activity</code> is launched <a href="https://gist.github.com/gamebusterz/6486078d40450bb1011df973961008ee" rel="nofollow noreferrer">sb_qa_default_layout.xml</a> and its <a href="https://gist.github.com/gamebusterz/454a11298822404fb5c897ae2d0bc41a" rel="nofollow noreferrer">Java code</a><br> Same for the <code>Fragment</code> which will replace the default <code>Fragment</code> on clicking the <code>LinearLayout</code> on the default <code>Fragment</code>. <a href="https://gist.github.com/gamebusterz/d6ef5b77d84a58483ecf61351d2481d9" rel="nofollow noreferrer">Layout</a> and its <a href="https://gist.github.com/gamebusterz/fdb6273ffcdb342579774da981d5a2f9" rel="nofollow noreferrer">Java Code</a> </p> <p>Thanks in advance.</p>
0debug
Using Rails-UJS in JS modules (Rails 6 with webpacker) : <p>i just switched to Rails 6 (6.0.0.rc1) which uses the <a href="https://github.com/rails/webpacker" rel="noreferrer">Webpacker</a> gem by default for Javascript assets together with Rails-UJS. I want to use Rails UJS in some of my modules in order to submit forms from a function with:</p> <pre><code>const form = document.querySelector("form") Rails.fire(form, "submit") </code></pre> <p>In former Rails versions with Webpacker installed, the <code>Rails</code> reference seemed to be "globally" available in my modules, but now i get this when calling <code>Rails.fire</code>…</p> <pre><code>ReferenceError: Rails is not defined </code></pre> <p><strong>How can i make <code>Rails</code> from <code>@rails/ujs</code> available to a specific or to all of my modules?</strong></p> <p>Below my setup…</p> <p><em>app/javascript/controllers/form_controller.js</em></p> <pre><code>import { Controller } from "stimulus" export default class extends Controller { // ... submit() { const form = this.element Rails.fire(form, "submit") } // ... } </code></pre> <p><em>app/javascript/controllers.js</em></p> <pre><code>// Load all the controllers within this directory and all subdirectories. // Controller files must be named *_controller.js. import { Application } from "stimulus" import { definitionsFromContext } from "stimulus/webpack-helpers" const application = Application.start() const context = require.context("controllers", true, /_controller\.js$/) application.load(definitionsFromContext(context)) </code></pre> <p><em>app/javascript/packs/application.js</em></p> <pre><code>require("@rails/ujs").start() import "controllers" </code></pre> <p>Thanks!</p>
0debug
Overriding a void function with a single-expression function : How do you override a function returning `void` or `Unit`, with a [single-expression function][1] whose expression returns some non-`Unit` type? [1]: https://kotlinlang.org/docs/reference/functions.html#single-expression-functions
0debug
static void close(AVCodecParserContext *s) { H264Context *h = s->priv_data; ParseContext *pc = &h->s.parse_context; av_free(pc->buffer); }
1threat
static void simple_dict(void) { int i; struct { const char *encoded; LiteralQObject decoded; } test_cases[] = { { .encoded = "{\"foo\": 42, \"bar\": \"hello world\"}", .decoded = QLIT_QDICT(((LiteralQDictEntry[]){ { "foo", QLIT_QINT(42) }, { "bar", QLIT_QSTR("hello world") }, { } })), }, { .encoded = "{}", .decoded = QLIT_QDICT(((LiteralQDictEntry[]){ { } })), }, { .encoded = "{\"foo\": 43}", .decoded = QLIT_QDICT(((LiteralQDictEntry[]){ { "foo", QLIT_QINT(43) }, { } })), }, { } }; for (i = 0; test_cases[i].encoded; i++) { QObject *obj; QString *str; obj = qobject_from_json(test_cases[i].encoded); g_assert(obj != NULL); g_assert(qobject_type(obj) == QTYPE_QDICT); g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1); str = qobject_to_json(obj); qobject_decref(obj); obj = qobject_from_json(qstring_get_str(str)); g_assert(obj != NULL); g_assert(qobject_type(obj) == QTYPE_QDICT); g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1); qobject_decref(obj); QDECREF(str); } }
1threat
PHP - Escaping doesn't work for me? : <p>I've been trying to do JSON in string, but I have to escape double quotes.. Here's the line <code>{\"assetid":".$assetid.", "floatvalue\":".$floatvalue.\"},</code></p>
0debug
void qmp_ringbuf_write(const char *device, const char *data, bool has_format, enum DataFormat format, Error **errp) { CharDriverState *chr; const uint8_t *write_data; int ret; gsize write_count; chr = qemu_chr_find(device); if (!chr) { error_setg(errp, "Device '%s' not found", device); return; } if (!chr_is_ringbuf(chr)) { error_setg(errp,"%s is not a ringbuf device", device); return; } if (has_format && (format == DATA_FORMAT_BASE64)) { write_data = g_base64_decode(data, &write_count); } else { write_data = (uint8_t *)data; write_count = strlen(data); } ret = ringbuf_chr_write(chr, write_data, write_count); if (write_data != (uint8_t *)data) { g_free((void *)write_data); } if (ret < 0) { error_setg(errp, "Failed to write to device %s", device); return; } }
1threat
adb.exe spawning many process instances : <p>I'm new to developing for Android and have been tasked with helping the development of some React Native based Android application. I have a working setup in which an emulated Android device can run this application. However, when starting the emulator, the process <code>adb.exe</code> repeatedly gets spawned in the background at a rate of about 1 process per second. These processes seemingly take no/very little memory (144K according to the Task Manager), but over time, this still adds up to a massive list of processes (nearing 3000 at the time of writing) taking up quite a bit of memory (which is already scarce thanks to a fairly heavy development toolchain).</p> <p>Closing the emulator does not automatically terminate these processes. The only way I have found so far that works is by using <code>taskkill /IM /F</code>.</p> <p>Is this expected behaviour? If not, how could I begin with tracking down the reasons for behaviour.</p>
0debug