problem
stringlengths
26
131k
labels
class label
2 classes
static const uint8_t *read_huffman_tables(FourXContext *f, const uint8_t * const buf) { int frequency[512] = { 0 }; uint8_t flag[512]; int up[512]; uint8_t len_tab[257]; int bits_tab[257]; int start, end; const uint8_t *ptr = buf; int j; memset(up, -1, sizeof(up)); start = *ptr++; end = *ptr++; for (;;) { int i; for (i = start; i <= end; i++) frequency[i] = *ptr++; start = *ptr++; if (start == 0) break; end = *ptr++; } frequency[256] = 1; while ((ptr - buf) & 3) ptr++; for (j = 257; j < 512; j++) { int min_freq[2] = { 256 * 256, 256 * 256 }; int smallest[2] = { 0, 0 }; int i; for (i = 0; i < j; i++) { if (frequency[i] == 0) continue; if (frequency[i] < min_freq[1]) { if (frequency[i] < min_freq[0]) { min_freq[1] = min_freq[0]; smallest[1] = smallest[0]; min_freq[0] = frequency[i]; smallest[0] = i; } else { min_freq[1] = frequency[i]; smallest[1] = i; } } } if (min_freq[1] == 256 * 256) break; frequency[j] = min_freq[0] + min_freq[1]; flag[smallest[0]] = 0; flag[smallest[1]] = 1; up[smallest[0]] = up[smallest[1]] = j; frequency[smallest[0]] = frequency[smallest[1]] = 0; } for (j = 0; j < 257; j++) { int node, len = 0, bits = 0; for (node = j; up[node] != -1; node = up[node]) { bits += flag[node] << len; len++; if (len > 31) av_log(f->avctx, AV_LOG_ERROR, "vlc length overflow\n"); } bits_tab[j] = bits; len_tab[j] = len; } if (init_vlc(&f->pre_vlc, ACDC_VLC_BITS, 257, len_tab, 1, 1, bits_tab, 4, 4, 0)) return NULL; return ptr; }
1threat
void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) { BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s->vdev))); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); VirtIOBlock *vblk = VIRTIO_BLK(s->vdev); VirtQueue *vq; int r; if (s->started || s->disabled) { return; } if (s->starting) { return; } s->starting = true; vq = virtio_get_queue(s->vdev, 0); if (!vring_setup(&s->vring, s->vdev, 0)) { goto fail_vring; } r = k->set_guest_notifiers(qbus->parent, 1, true); if (r != 0) { fprintf(stderr, "virtio-blk failed to set guest notifier (%d), " "ensure -enable-kvm is set\n", r); goto fail_guest_notifiers; } s->guest_notifier = virtio_queue_get_guest_notifier(vq); r = k->set_host_notifier(qbus->parent, 0, true); if (r != 0) { fprintf(stderr, "virtio-blk failed to set host notifier (%d)\n", r); goto fail_host_notifier; } s->host_notifier = *virtio_queue_get_host_notifier(vq); s->saved_complete_request = vblk->complete_request; vblk->complete_request = complete_request_vring; s->starting = false; s->started = true; trace_virtio_blk_data_plane_start(s); blk_set_aio_context(s->conf->conf.blk, s->ctx); event_notifier_set(virtio_queue_get_host_notifier(vq)); aio_context_acquire(s->ctx); aio_set_event_notifier(s->ctx, &s->host_notifier, true, handle_notify); aio_context_release(s->ctx); return; fail_host_notifier: k->set_guest_notifiers(qbus->parent, 1, false); fail_guest_notifiers: vring_teardown(&s->vring, s->vdev, 0); s->disabled = true; fail_vring: s->starting = false; }
1threat
string functions in sql server 2012 : I have a table like Emp( id,name) values(10,`RAMESH`) OUTPUT-RamesH HOW TO WRITE A QUERY
0debug
static int teletext_close_decoder(AVCodecContext *avctx) { TeletextContext *ctx = avctx->priv_data; av_dlog(avctx, "lines_total=%u\n", ctx->lines_processed); while (ctx->nb_pages) subtitle_rect_free(&ctx->pages[--ctx->nb_pages].sub_rect); av_freep(&ctx->pages); vbi_decoder_delete(ctx->vbi); ctx->vbi = NULL; ctx->pts = AV_NOPTS_VALUE; return 0; }
1threat
static void monitor_fdset_cleanup(MonFdset *mon_fdset) { MonFdsetFd *mon_fdset_fd; MonFdsetFd *mon_fdset_fd_next; QLIST_FOREACH_SAFE(mon_fdset_fd, &mon_fdset->fds, next, mon_fdset_fd_next) { if (mon_fdset_fd->removed || (QLIST_EMPTY(&mon_fdset->dup_fds) && mon_refcount == 0)) { close(mon_fdset_fd->fd); g_free(mon_fdset_fd->opaque); QLIST_REMOVE(mon_fdset_fd, next); g_free(mon_fdset_fd); } } if (QLIST_EMPTY(&mon_fdset->fds) && QLIST_EMPTY(&mon_fdset->dup_fds)) { QLIST_REMOVE(mon_fdset, next); g_free(mon_fdset); } }
1threat
How to download tcpdf php class library? : <p>How do I download tcpdf php class library for generating pdf in my web application ?</p>
0debug
can't get variables in function : <p>I have a translate system:</p> <p>/phps/languages.php</p> <pre><code>$root = $_SERVER['DOCUMENT_ROOT']; if($lang == "en-us"){ include_once("$root/site-languages/en-us.php"); // include en-us } </code></pre> <p>this function: /phps/date.php</p> <pre><code>function time_difference($date){ $root = $_SERVER['DOCUMENT_ROOT']; include_once("$root/phps/languages.php"); echo $language_include_variable; // it is empty </code></pre> <p>and my page.php that will call date.php and date calls languages.php.</p> <pre><code>$root = $_SERVER['DOCUMENT_ROOT']; include_once("$root/phps/date.php"); </code></pre> <p>The problem is the echo $language_include_variable is null. any ideas?</p>
0debug
What does <ClassName>.() mean in Kotlin? : <p>Not sure what this means but I came across this syntax in the kotlin html codebase. What does SCRIPT.() mean?</p> <p><a href="https://github.com/Kotlin/kotlinx.html/blob/master/shared/src/main/kotlin/generated/gen-tag-unions.kt#L143" rel="noreferrer">https://github.com/Kotlin/kotlinx.html/blob/master/shared/src/main/kotlin/generated/gen-tag-unions.kt#L143</a></p> <pre><code>fun FlowOrPhrasingOrMetaDataContent.script(type : String? = null, src : String? = null, block : SCRIPT.() -&gt; Unit = {}) : Unit = SCRIPT(attributesMapOf("type", type,"src", src), consumer).visit(block) </code></pre> <p>SCRIPT is a class - <a href="https://github.com/Kotlin/kotlinx.html/blob/master/shared/src/main/kotlin/generated/gen-tags-s.kt" rel="noreferrer">https://github.com/Kotlin/kotlinx.html/blob/master/shared/src/main/kotlin/generated/gen-tags-s.kt</a>. </p> <p>Or more generally, what does <code>&lt;ClassName&gt;.()</code> mean in Kotlin?</p>
0debug
is vs Equals() vs == in Pattern Matching : <p>Seems in C#7 we got a new pattern matching mechanic. <br/>As outlined in <a href="https://blogs.msdn.microsoft.com/seteplia/2017/10/16/dissecting-the-pattern-matching-in-c-7/" rel="nofollow noreferrer">this article</a> you can use the <code>is</code> keyword to check if a variable has a certain value.</p> <p>As far as I know before that <code>is</code> was used to check type, not content. <br/>So I am wondering - what are the advantages of using <code>is</code> in pattern matching, rather than <code>==</code> or <code>Equals()</code> when checking if a variable has a certain value?</p>
0debug
void spapr_drc_reset(sPAPRDRConnector *drc) { trace_spapr_drc_reset(spapr_drc_index(drc)); g_free(drc->ccs); drc->ccs = NULL; if (drc->awaiting_release) { spapr_drc_release(drc); } drc->awaiting_allocation = false; if (drc->dev) { drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED; if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI) { drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_USABLE; } drc->dr_indicator = SPAPR_DR_INDICATOR_ACTIVE; } else { drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED; if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI) { drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_UNUSABLE; } drc->dr_indicator = SPAPR_DR_INDICATOR_INACTIVE; } }
1threat
Deserialize property as a value to c# : <p>You can not undo the following json code for a class c # the property is not a name is an incremental code or identifier.</p> <p>server result.</p> <pre><code>{ "success": 0, "persona": { "1000": { "nombre": "Nombre 1", "apellido": "Apellido 1", "edad": 18 }, "1001": { "nombre": "Nombre 2", "apellido": "Apellido 2", "edad": 18 } } } </code></pre> <p>the server response could be converted to the next valid format.</p> <pre><code>{ "success": 0, "persona": [ { "id": "1000", "nombre": "Nombre 1", "apellido": "Apellido 1", "edad": 18 }, { "id": "1001", "nombre": "Nombre 2", "apellido": "Apellido 2", "edad": 18 } ] } </code></pre>
0debug
How to find the Username of the coputer in a batch file : this is what I need: @echo off title H1Z1 Launcher By Grim0 cd C:\Users\ **%ComputerName%** thats the part that I tried but it didnt worked... any options?
0debug
PCIBus *i440fx_init(const char *host_type, const char *pci_type, PCII440FXState **pi440fx_state, int *piix3_devfn, ISABus **isa_bus, qemu_irq *pic, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, ram_addr_t below_4g_mem_size, ram_addr_t above_4g_mem_size, MemoryRegion *pci_address_space, MemoryRegion *ram_memory) { DeviceState *dev; PCIBus *b; PCIDevice *d; PCIHostState *s; PIIX3State *piix3; PCII440FXState *f; unsigned i; I440FXState *i440fx; dev = qdev_create(NULL, host_type); s = PCI_HOST_BRIDGE(dev); b = pci_bus_new(dev, NULL, pci_address_space, address_space_io, 0, TYPE_PCI_BUS); s->bus = b; object_property_add_child(qdev_get_machine(), "i440fx", OBJECT(dev), NULL); qdev_init_nofail(dev); d = pci_create_simple(b, 0, pci_type); *pi440fx_state = I440FX_PCI_DEVICE(d); f = *pi440fx_state; f->system_memory = address_space_mem; f->pci_address_space = pci_address_space; f->ram_memory = ram_memory; i440fx = I440FX_PCI_HOST_BRIDGE(dev); i440fx->pci_hole.begin = below_4g_mem_size; i440fx->pci_hole.end = IO_APIC_DEFAULT_ADDRESS; pc_pci_as_mapping_init(OBJECT(f), f->system_memory, f->pci_address_space); memory_region_init_alias(&f->smram_region, OBJECT(d), "smram-region", f->pci_address_space, 0xa0000, 0x20000); memory_region_add_subregion_overlap(f->system_memory, 0xa0000, &f->smram_region, 1); memory_region_set_enabled(&f->smram_region, true); memory_region_init(&f->smram, OBJECT(d), "smram", 1ull << 32); memory_region_set_enabled(&f->smram, true); memory_region_init_alias(&f->low_smram, OBJECT(d), "smram-low", f->ram_memory, 0xa0000, 0x20000); memory_region_set_enabled(&f->low_smram, true); memory_region_add_subregion(&f->smram, 0xa0000, &f->low_smram); object_property_add_const_link(qdev_get_machine(), "smram", OBJECT(&f->smram), &error_abort); init_pam(dev, f->ram_memory, f->system_memory, f->pci_address_space, &f->pam_regions[0], PAM_BIOS_BASE, PAM_BIOS_SIZE); for (i = 0; i < 12; ++i) { init_pam(dev, f->ram_memory, f->system_memory, f->pci_address_space, &f->pam_regions[i+1], PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); } if (xen_enabled()) { PCIDevice *pci_dev = pci_create_simple_multifunction(b, -1, true, "PIIX3-xen"); piix3 = PIIX3_PCI_DEVICE(pci_dev); pci_bus_irqs(b, xen_piix3_set_irq, xen_pci_slot_get_pirq, piix3, XEN_PIIX_NUM_PIRQS); } else { PCIDevice *pci_dev = pci_create_simple_multifunction(b, -1, true, "PIIX3"); piix3 = PIIX3_PCI_DEVICE(pci_dev); pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3, PIIX_NUM_PIRQS); pci_bus_set_route_irq_fn(b, piix3_route_intx_pin_to_irq); } piix3->pic = pic; *isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0")); *piix3_devfn = piix3->dev.devfn; ram_size = ram_size / 8 / 1024 / 1024; if (ram_size > 255) { ram_size = 255; } d->config[I440FX_COREBOOT_RAM_SIZE] = ram_size; i440fx_update_memory_mappings(f); return b; }
1threat
How can I use lookup_windows.go in a project : I'm trying to use the following package in my project: https://github.com/golang/go/blob/master/src/os/user/lookup_windows.go But I cannot access the functions in lookup_windows.go, because the functions are not capitalized, right? How can I use this package in my project, e.g. the `listGoups` function? package main import ( "fmt" "log" "os/user" ) func main() { s := "some sid..." result, err := user.LookupGroupId(s) // Can access 'https://github.com/golang/go/blob/master/src/os/user/lookup.go' //result, err = user.listGroups(s) // Can't access 'https://github.com/golang/go/blob/master/src/os/user/lookup_windows.go' if err != nil { log.Fatal(err) } fmt.Println(result) }
0debug
static always_inline void gen_op_arith_add(DisasContext *ctx, TCGv ret, TCGv arg1, TCGv arg2, int add_ca, int compute_ca, int compute_ov) { TCGv t0, t1; if ((!compute_ca && !compute_ov) || (!TCGV_EQUAL(ret,arg1) && !TCGV_EQUAL(ret, arg2))) { t0 = ret; t0 = tcg_temp_local_new(); } if (add_ca) { t1 = tcg_temp_local_new(); tcg_gen_andi_tl(t1, cpu_xer, (1 << XER_CA)); tcg_gen_shri_tl(t1, t1, XER_CA); } if (compute_ca && compute_ov) { tcg_gen_andi_tl(cpu_xer, cpu_xer, ~((1 << XER_CA) | (1 << XER_OV))); } else if (compute_ca) { tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_CA)); } else if (compute_ov) { tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_OV)); } tcg_gen_add_tl(t0, arg1, arg2); if (compute_ca) { gen_op_arith_compute_ca(ctx, t0, arg1, 0); } if (add_ca) { tcg_gen_add_tl(t0, t0, t1); gen_op_arith_compute_ca(ctx, t0, t1, 0); tcg_temp_free(t1); } if (compute_ov) { gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 0); } if (unlikely(Rc(ctx->opcode) != 0)) gen_set_Rc0(ctx, t0); if (!TCGV_EQUAL(t0, ret)) { tcg_gen_mov_tl(ret, t0); tcg_temp_free(t0); } }
1threat
long do_sigreturn(CPUMIPSState *regs) { struct sigframe *frame; abi_ulong frame_addr; sigset_t blocked; target_sigset_t target_set; int i; #if defined(DEBUG_SIGNAL) fprintf(stderr, "do_sigreturn\n"); #endif frame_addr = regs->active_tc.gpr[29]; if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) goto badframe; for(i = 0; i < TARGET_NSIG_WORDS; i++) { if(__get_user(target_set.sig[i], &frame->sf_mask.sig[i])) goto badframe; } target_to_host_sigset_internal(&blocked, &target_set); sigprocmask(SIG_SETMASK, &blocked, NULL); if (restore_sigcontext(regs, &frame->sf_sc)) goto badframe; #if 0 __asm__ __volatile__( "move\t$29, %0\n\t" "j\tsyscall_exit" : :"r" (&regs)); #endif regs->active_tc.PC = regs->CP0_EPC; mips_set_hflags_isa_mode_from_pc(regs); regs->CP0_EPC = 0; return -TARGET_QEMU_ESIGRETURN; badframe: force_sig(TARGET_SIGSEGV); return 0; }
1threat
av_cold int ff_rate_control_init(MpegEncContext *s) { RateControlContext *rcc = &s->rc_context; int i, res; static const char * const const_names[] = { "PI", "E", "iTex", "pTex", "tex", "mv", "fCode", "iCount", "mcVar", "var", "isI", "isP", "isB", "avgQP", "qComp", #if 0 "lastIQP", "lastPQP", "lastBQP", "nextNonBQP", #endif "avgIITex", "avgPITex", "avgPPTex", "avgBPTex", "avgTex", NULL }; static double (* const func1[])(void *, double) = { (void *)bits2qp, (void *)qp2bits, NULL }; static const char * const func1_names[] = { "bits2qp", "qp2bits", NULL }; emms_c(); res = av_expr_parse(&rcc->rc_eq_eval, s->rc_eq ? s->rc_eq : "tex^qComp", const_names, func1_names, func1, NULL, NULL, 0, s->avctx); if (res < 0) { av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", s->rc_eq); return res; } for (i = 0; i < 5; i++) { rcc->pred[i].coeff = FF_QP2LAMBDA * 7.0; rcc->pred[i].count = 1.0; rcc->pred[i].decay = 0.4; rcc->i_cplx_sum [i] = rcc->p_cplx_sum [i] = rcc->mv_bits_sum[i] = rcc->qscale_sum [i] = rcc->frame_count[i] = 1; rcc->last_qscale_for[i] = FF_QP2LAMBDA * 5; } rcc->buffer_index = s->avctx->rc_initial_buffer_occupancy; if (s->avctx->flags & CODEC_FLAG_PASS2) { int i; char *p; p = s->avctx->stats_in; for (i = -1; p; i++) p = strchr(p + 1, ';'); i += s->max_b_frames; if (i <= 0 || i >= INT_MAX / sizeof(RateControlEntry)) return -1; rcc->entry = av_mallocz(i * sizeof(RateControlEntry)); rcc->num_entries = i; for (i = 0; i < rcc->num_entries; i++) { RateControlEntry *rce = &rcc->entry[i]; rce->pict_type = rce->new_pict_type = AV_PICTURE_TYPE_P; rce->qscale = rce->new_qscale = FF_QP2LAMBDA * 2; rce->misc_bits = s->mb_num + 10; rce->mb_var_sum = s->mb_num * 100; } p = s->avctx->stats_in; for (i = 0; i < rcc->num_entries - s->max_b_frames; i++) { RateControlEntry *rce; int picture_number; int e; char *next; next = strchr(p, ';'); if (next) { (*next) = 0; next++; } e = sscanf(p, " in:%d ", &picture_number); assert(picture_number >= 0); assert(picture_number < rcc->num_entries); rce = &rcc->entry[picture_number]; e += sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d", &rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits, &rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count, &rce->skip_count, &rce->header_bits); if (e != 14) { av_log(s->avctx, AV_LOG_ERROR, "statistics are damaged at line %d, parser out=%d\n", i, e); return -1; } p = next; } if (init_pass2(s) < 0) return -1; if ((s->avctx->flags & CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID) { #if CONFIG_LIBXVID return ff_xvid_rate_control_init(s); #else av_log(s->avctx, AV_LOG_ERROR, "Xvid ratecontrol requires libavcodec compiled with Xvid support.\n"); return -1; #endif } } if (!(s->avctx->flags & CODEC_FLAG_PASS2)) { rcc->short_term_qsum = 0.001; rcc->short_term_qcount = 0.001; rcc->pass1_rc_eq_output_sum = 0.001; rcc->pass1_wanted_bits = 0.001; if (s->avctx->qblur > 1.0) { av_log(s->avctx, AV_LOG_ERROR, "qblur too large\n"); return -1; } if (s->rc_initial_cplx) { for (i = 0; i < 60 * 30; i++) { double bits = s->rc_initial_cplx * (i / 10000.0 + 1.0) * s->mb_num; RateControlEntry rce; if (i % ((s->gop_size + 3) / 4) == 0) rce.pict_type = AV_PICTURE_TYPE_I; else if (i % (s->max_b_frames + 1)) rce.pict_type = AV_PICTURE_TYPE_B; else rce.pict_type = AV_PICTURE_TYPE_P; rce.new_pict_type = rce.pict_type; rce.mc_mb_var_sum = bits * s->mb_num / 100000; rce.mb_var_sum = s->mb_num; rce.qscale = FF_QP2LAMBDA * 2; rce.f_code = 2; rce.b_code = 1; rce.misc_bits = 1; if (s->pict_type == AV_PICTURE_TYPE_I) { rce.i_count = s->mb_num; rce.i_tex_bits = bits; rce.p_tex_bits = 0; rce.mv_bits = 0; } else { rce.i_count = 0; rce.i_tex_bits = 0; rce.p_tex_bits = bits * 0.9; rce.mv_bits = bits * 0.1; } rcc->i_cplx_sum[rce.pict_type] += rce.i_tex_bits * rce.qscale; rcc->p_cplx_sum[rce.pict_type] += rce.p_tex_bits * rce.qscale; rcc->mv_bits_sum[rce.pict_type] += rce.mv_bits; rcc->frame_count[rce.pict_type]++; get_qscale(s, &rce, rcc->pass1_wanted_bits / rcc->pass1_rc_eq_output_sum, i); rcc->pass1_wanted_bits += s->bit_rate / (1 / av_q2d(s->avctx->time_base)); } } } return 0; }
1threat
static uint32_t add_weights(uint32_t w1, uint32_t w2) { uint32_t max = (w1 & 0xFF) > (w2 & 0xFF) ? (w1 & 0xFF) : (w2 & 0xFF); return ((w1 & 0xFFFFFF00) + (w2 & 0xFFFFFF00)) | (1 + max); }
1threat
How to update dependency injection token value : <p>Angular dependency injection let you inject a string, function, or object using a token instead of a service class. </p> <p>I declare it in my module like this:</p> <pre><code>providers: [{ provide: MyValueToken, useValue: 'my title value'}] </code></pre> <p>and I use it like this:</p> <pre><code>constructor(@Inject(MyValueToken) my_value: string) { this.title = my_value; } </code></pre> <p>However, how can I update the value from the component and let other components get every time the new value? in other words, I want to simulate the functionality of using something like a <code>BehaviorSubject</code> to emit and receive values.</p> <p>If this is not possible then what is the use of those injection tokens values if they provide only static data as instead I can simply declare the static value in my component and use it directly.</p>
0debug
Given an n-element unsorted array ๐ด of ๐‘› integers and an integer x, rearranges the elements in ๐ด : (a) Given an n-element unsorted array ๐ด of ๐‘› integers and an integer x, rearranges the elements in ๐ด such that all elements less than or equal to x come before any elements larger than x. ( Note: Don't have to include integer x in the new array ) (b) What is the running time complexity of your algorithm? Explain your answer.
0debug
Memory leak using gridsearchcv : <p><strong>Problem:</strong> My situation appears to be a memory leak when running gridsearchcv. This happens when I run with 1 or 32 concurrent workers (n_jobs=-1). Previously I have run this loads of times with no trouble on ubuntu 16.04, but recently upgraded to 18.04 and did a ram upgrade.</p> <pre><code>import os import pickle from xgboost import XGBClassifier from sklearn.model_selection import GridSearchCV,StratifiedKFold,train_test_split from sklearn.calibration import CalibratedClassifierCV from sklearn.metrics import make_scorer,log_loss from horsebet import performance scorer = make_scorer(log_loss,greater_is_better=True) kfold = StratifiedKFold(n_splits=3) # import and split data input_vectors = pickle.load(open(os.path.join('horsebet','data','x_normalized'),'rb')) output_vector = pickle.load(open(os.path.join('horsebet','data','y'),'rb')).ravel() x_train,x_test,y_train,y_test = train_test_split(input_vectors,output_vector,test_size=0.2) # XGB model = XGBClassifier() param = { 'booster':['gbtree'], 'tree_method':['hist'], 'objective':['binary:logistic'], 'n_estimators':[100,500], 'min_child_weight': [.8,1], 'gamma': [1,3], 'subsample': [0.1,.4,1.0], 'colsample_bytree': [1.0], 'max_depth': [10,20], } jobs = 8 model = GridSearchCV(model,param_grid=param,cv=kfold,scoring=scorer,pre_dispatch=jobs*2,n_jobs=jobs,verbose=5).fit(x_train,y_train) </code></pre> <p><strong>Returns:</strong> UserWarning: A worker stopped while some jobs were given to the executor. This can be caused by a too short worker timeout or by a memory leak. "timeout or by a memory leak.", UserWarning</p> <p><strong>OR</strong></p> <p>TerminatedWorkerError: A worker process managed by the executor was unexpectedly terminated. This could be caused by a segmentation fault while calling the function or by an excessive memory usage causing the Operating System to kill the worker. The exit codes of the workers are {SIGKILL(-9)}</p>
0debug
delet the empty line in textbox and then count the lines in visual basic : [I want acode that when I press the button(delete empty line and count the lines) the programe weel delete every empty line in the textbox and count the line of textbox after deleting the empty lines ][1] [1]: http://i.stack.imgur.com/KveaE.png
0debug
How can i find a tag inside a document in Javascript : I want to find if the document(which is a html file) has "some" tag if so, i want to get all its attributes. i tried with var data = require('test.html'); if(data.toLowerCase().indexOf('sometag')){ console.log('yeaaah it exist'); } The problem is it always returns "true" whether the tag exists or not.
0debug
static int ratecontrol_1pass(SnowContext *s, AVFrame *pict) { uint32_t coef_sum= 0; int level, orientation, delta_qlog; for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &s->plane[0].band[level][orientation]; DWTELEM *buf= b->buf; const int w= b->width; const int h= b->height; const int stride= b->stride; const int qlog= clip(2*QROOT + b->qlog, 0, QROOT*16); const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT); const int qdiv= (1<<16)/qmul; int x, y; if(orientation==0) decorrelate(s, b, buf, stride, 1, 0); for(y=0; y<h; y++) for(x=0; x<w; x++) coef_sum+= abs(buf[x+y*stride]) * qdiv >> 16; if(orientation==0) correlate(s, b, buf, stride, 1, 0); } } coef_sum = (uint64_t)coef_sum * coef_sum >> 16; assert(coef_sum < INT_MAX); if(pict->pict_type == I_TYPE){ s->m.current_picture.mb_var_sum= coef_sum; s->m.current_picture.mc_mb_var_sum= 0; }else{ s->m.current_picture.mc_mb_var_sum= coef_sum; s->m.current_picture.mb_var_sum= 0; } pict->quality= ff_rate_estimate_qscale(&s->m, 1); if (pict->quality < 0) return -1; s->lambda= pict->quality * 3/2; delta_qlog= qscale2qlog(pict->quality) - s->qlog; s->qlog+= delta_qlog; return delta_qlog; }
1threat
mysql_fetch_array in PDO : <p>I changed my connection to PDO </p> <pre><code>$DB = new PDO("mysql:host=".DBHOSTINT.";charset=utf8mb4;dbname=".DBNAMEINT, DBUSERINT, DBPASSINT); </code></pre> <p>I have the following code in the old "mysql_query"</p> <pre><code>$result = mysql_query("SELECT * FROM menu "); while ($row = mysql_fetch_array($result)) { echo '&lt;div class="cuisine-detail"&gt;'. $row["text"]. '&lt;/div&gt;'; echo '&lt;/div&gt;'; } mysql_free_result($result); </code></pre> <p>How I can transform this to the PDO way :</p>
0debug
How do Pointer Arithmetic works after Pointer Casting? : int main() { short int a[4] = {1,1, [3] = 1}; int *p = (int*)a; printf("p: %p %d \n ", p, *p); printf("p+1: %p %d\n", (p +1), *(p+1)); } why does *p = 65537 and *(p+1) = 65536?
0debug
void opt_input_file(const char *filename) { AVFormatContext *ic; AVFormatParameters params, *ap = &params; int err, i, ret, rfps; memset(ap, 0, sizeof(*ap)); ap->sample_rate = audio_sample_rate; ap->channels = audio_channels; ap->frame_rate = frame_rate; ap->width = frame_width; ap->height = frame_height; err = av_open_input_file(&ic, filename, file_iformat, 0, ap); if (err < 0) { print_error(filename, err); exit(1); } ret = av_find_stream_info(ic); if (ret < 0) { fprintf(stderr, "%s: could not find codec parameters\n", filename); exit(1); } for(i=0;i<ic->nb_streams;i++) { AVCodecContext *enc = &ic->streams[i]->codec; switch(enc->codec_type) { case CODEC_TYPE_AUDIO: audio_channels = enc->channels; audio_sample_rate = enc->sample_rate; break; case CODEC_TYPE_VIDEO: frame_height = enc->height; frame_width = enc->width; rfps = ic->streams[i]->r_frame_rate; if (enc->frame_rate != rfps) { fprintf(stderr,"\nSeems that stream %d comes from film source: %2.2f->%2.2f\n", i, (float)enc->frame_rate / FRAME_RATE_BASE, (float)rfps / FRAME_RATE_BASE); } frame_rate = rfps; break; default: abort(); } } input_files[nb_input_files] = ic; dump_format(ic, nb_input_files, filename, 0); nb_input_files++; file_iformat = NULL; file_oformat = NULL; }
1threat
static void tcg_out_ld_abs(TCGContext *s, TCGType type, TCGReg dest, void *abs) { intptr_t addr = (intptr_t)abs; if ((facilities & FACILITY_GEN_INST_EXT) && !(addr & 1)) { ptrdiff_t disp = tcg_pcrel_diff(s, abs) >> 1; if (disp == (int32_t)disp) { if (type == TCG_TYPE_I32) { tcg_out_insn(s, RIL, LRL, dest, disp); } else { tcg_out_insn(s, RIL, LGRL, dest, disp); } return; } } tcg_out_movi(s, TCG_TYPE_PTR, dest, addr & ~0xffff); tcg_out_ld(s, type, dest, dest, addr & 0xffff); }
1threat
static int oss_open (int in, struct oss_params *req, struct oss_params *obt, int *pfd) { int fd; int mmmmssss; audio_buf_info abinfo; int fmt, freq, nchannels; const char *dspname = in ? conf.devpath_in : conf.devpath_out; const char *typ = in ? "ADC" : "DAC"; fd = open (dspname, (in ? O_RDONLY : O_WRONLY) | O_NONBLOCK); if (-1 == fd) { oss_logerr2 (errno, typ, "Failed to open `%s'\n", dspname); return -1; freq = req->freq; nchannels = req->nchannels; fmt = req->fmt; if (ioctl (fd, SNDCTL_DSP_SAMPLESIZE, &fmt)) { oss_logerr2 (errno, typ, "Failed to set sample size %d\n", req->fmt); if (ioctl (fd, SNDCTL_DSP_CHANNELS, &nchannels)) { oss_logerr2 (errno, typ, "Failed to set number of channels %d\n", req->nchannels); if (ioctl (fd, SNDCTL_DSP_SPEED, &freq)) { oss_logerr2 (errno, typ, "Failed to set frequency %d\n", req->freq); if (ioctl (fd, SNDCTL_DSP_NONBLOCK)) { oss_logerr2 (errno, typ, "Failed to set non-blocking mode\n"); mmmmssss = (req->nfrags << 16) | lsbindex (req->fragsize); if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &mmmmssss)) { oss_logerr2 (errno, typ, "Failed to set buffer length (%d, %d)\n", req->nfrags, req->fragsize); if (ioctl (fd, in ? SNDCTL_DSP_GETISPACE : SNDCTL_DSP_GETOSPACE, &abinfo)) { oss_logerr2 (errno, typ, "Failed to get buffer length\n"); obt->fmt = fmt; obt->nchannels = nchannels; obt->freq = freq; obt->nfrags = abinfo.fragstotal; obt->fragsize = abinfo.fragsize; *pfd = fd; #ifdef DEBUG_MISMATCHES if ((req->fmt != obt->fmt) || (req->nchannels != obt->nchannels) || (req->freq != obt->freq) || (req->fragsize != obt->fragsize) || (req->nfrags != obt->nfrags)) { dolog ("Audio parameters mismatch\n"); oss_dump_info (req, obt); #endif #ifdef DEBUG oss_dump_info (req, obt); #endif return 0; err: oss_anal_close (&fd); return -1;
1threat
React Router work on reload, but not when clicking on a link : <p>I have setup the React with <code>react-router</code> version 4. The routing works when I enter the URL directly on the browser, however when I click on the link, the URL changes on the browser (e.g <a href="http://localhost:8080/categories" rel="noreferrer">http://localhost:8080/categories</a>), but the content don't get updated (But if I do a refresh, it gets updated). </p> <p>Below is my setup:</p> <p>The <strong>Routes.js</strong> setup as follows:</p> <pre><code>import { Switch, Route } from 'react-router-dom'; import React from 'react'; // Components import Categories from './containers/videos/Categories'; import Videos from './containers/videos/Videos'; import Home from './components/Home'; const routes = () =&gt; ( &lt;Switch&gt; &lt;Route exact path="/" component={Home}/&gt; &lt;Route path="/videos" component={Videos}/&gt; &lt;Route path="/categories" component={Categories}/&gt; &lt;/Switch&gt; ); export default routes; </code></pre> <p>The link I use in <strong>Nav.js</strong> are as follows:</p> <pre><code>&lt;Link to="/videos"&gt;Videos&lt;/Link&gt; &lt;Link to="/categories"&gt;Categories&lt;/Link&gt; </code></pre> <p>The <strong>App.js</strong> is as follows:</p> <pre><code>import React from 'react'; import './app.scss'; import Routes from './../routes'; import Nav from './Nav'; class AppComponent extends React.Component { render() { return ( &lt;div className="index"&gt; &lt;Nav /&gt; &lt;div className="container"&gt; &lt;Routes /&gt; &lt;/div&gt; &lt;/div&gt; ); } } AppComponent.defaultProps = { }; export default AppComponent; </code></pre>
0debug
static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tracks, int num_tracks) { MatroskaMuxContext *mkv = s->priv_data; AVIOContext *dyn_cp, *pb = s->pb; ebml_master cues_element; int64_t currentpos; int i, j, ret; currentpos = avio_tell(pb); ret = start_ebml_master_crc32(pb, &dyn_cp, &cues_element, MATROSKA_ID_CUES, 0); if (ret < 0) return ret; for (i = 0; i < cues->num_entries; i++) { ebml_master cuepoint, track_positions; mkv_cuepoint *entry = &cues->entries[i]; uint64_t pts = entry->pts; int ctp_nb = 0; for (j = 0; j < num_tracks; j++) tracks[j].has_cue = 0; for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) { int tracknum = entry[j].stream_idx; av_assert0(tracknum>=0 && tracknum<num_tracks); if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) continue; tracks[tracknum].has_cue = 1; ctp_nb ++; } cuepoint = start_ebml_master(dyn_cp, MATROSKA_ID_POINTENTRY, MAX_CUEPOINT_SIZE(ctp_nb)); put_ebml_uint(dyn_cp, MATROSKA_ID_CUETIME, pts); for (j = 0; j < num_tracks; j++) tracks[j].has_cue = 0; for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) { int tracknum = entry[j].stream_idx; av_assert0(tracknum>=0 && tracknum<num_tracks); if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) continue; tracks[tracknum].has_cue = 1; track_positions = start_ebml_master(dyn_cp, MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE); put_ebml_uint(dyn_cp, MATROSKA_ID_CUETRACK , entry[j].tracknum ); put_ebml_uint(dyn_cp, MATROSKA_ID_CUECLUSTERPOSITION , entry[j].cluster_pos); put_ebml_uint(dyn_cp, MATROSKA_ID_CUERELATIVEPOSITION, entry[j].relative_pos); if (entry[j].duration != -1) put_ebml_uint(dyn_cp, MATROSKA_ID_CUEDURATION , entry[j].duration); end_ebml_master(dyn_cp, track_positions); } i += j - 1; end_ebml_master(dyn_cp, cuepoint); } end_ebml_master_crc32(pb, &dyn_cp, mkv, cues_element); return currentpos; }
1threat
document.write('<script src="evil.js"></script>');
1threat
static int parse_str(StringInputVisitor *siv, const char *name, Error **errp) { char *str = (char *) siv->string; long long start, end; Range *cur; char *endptr; if (siv->ranges) { return 0; } do { errno = 0; start = strtoll(str, &endptr, 0); if (errno == 0 && endptr > str) { if (*endptr == '\0') { cur = g_malloc0(sizeof(*cur)); cur->begin = start; cur->end = start + 1; siv->ranges = g_list_insert_sorted_merged(siv->ranges, cur, range_compare); cur = NULL; str = NULL; } else if (*endptr == '-') { str = endptr + 1; errno = 0; end = strtoll(str, &endptr, 0); if (errno == 0 && endptr > str && start <= end && (start > INT64_MAX - 65536 || end < start + 65536)) { if (*endptr == '\0') { cur = g_malloc0(sizeof(*cur)); cur->begin = start; cur->end = end + 1; siv->ranges = g_list_insert_sorted_merged(siv->ranges, cur, range_compare); cur = NULL; str = NULL; } else if (*endptr == ',') { str = endptr + 1; cur = g_malloc0(sizeof(*cur)); cur->begin = start; cur->end = end + 1; siv->ranges = g_list_insert_sorted_merged(siv->ranges, cur, range_compare); cur = NULL; } else { goto error; } } else { goto error; } } else if (*endptr == ',') { str = endptr + 1; cur = g_malloc0(sizeof(*cur)); cur->begin = start; cur->end = start + 1; siv->ranges = g_list_insert_sorted_merged(siv->ranges, cur, range_compare); cur = NULL; } else { goto error; } } else { goto error; } } while (str); return 0; error: g_list_foreach(siv->ranges, free_range, NULL); g_list_free(siv->ranges); siv->ranges = NULL; error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null", "an int64 value or range"); return -1; }
1threat
uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, uint32_t index, int reg) { struct kvm_cpuid2 *cpuid; int max; uint32_t ret = 0; uint32_t cpuid_1_edx; bool found = false; max = 1; while ((cpuid = try_get_cpuid(s, max)) == NULL) { max *= 2; } struct kvm_cpuid_entry2 *entry = cpuid_find_entry(cpuid, function, index); if (entry) { found = true; ret = cpuid_entry_get_reg(entry, reg); } if (reg == R_EDX) { switch (function) { case 1: ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA; break; case 0x80000001: cpuid_1_edx = kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX); ret |= cpuid_1_edx & CPUID_EXT2_AMD_ALIASES; break; } } g_free(cpuid); if ((function == KVM_CPUID_FEATURES) && !found) { ret = get_para_features(s); } return ret; }
1threat
Can I set listen URLs in appsettings.json in ASP.net Core 2.0 Preview? : <p>I'm creating an ASP.net Core 2.0 app to run on the .net Core 2.0 runtime, both currently in their Preview versions. However, I cannot figure out how to have Kestrel use something other than the default <code>http://localhost:5000</code> listen URL.</p> <p>Most documentation that I could Google talks about a <code>server.urls</code> setting, which seems to have been changed even in 1.0-preview to just be <code>urls</code>, however neither works (turning on Debug logging has Kestrel telling me that no listen endpoints are configured).</p> <p>A lot of documentation also talks about a <code>hosting.json</code> and that I can't use the default appsettings.json. However, if I compare the recommended approach of loading a new config, this looks pretty much exactly like what the new <a href="https://github.com/aspnet/MetaPackages/blob/f245512f6e68d65309b65528d479f32b34c67718/src/Microsoft.AspNetCore/WebHost.cs#L150" rel="noreferrer"><code>WebHost.CreateDefaultBuilder</code></a> method does, except that it loads appsettings.json.</p> <p>I currently don't understand how appsettings.json and <code>IConfigureOptions&lt;T&gt;</code> are related, if at all, so it's possible that my trouble stems from a lack of understanding of what <a href="https://github.com/aspnet/KestrelHttpServer/blob/7ceea5323aeb78c5c5a9b0f68f1e52d65073b16f/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/KestrelServerOptionsSetup.cs" rel="noreferrer"><code>KestrelServerOptionsSetup</code></a> actually does.</p>
0debug
how can i set error info for my home page. here is my code : if($evaluation_sheet_t3 == 0) { $error_eval = $error_eval.'Term 3,'; $error_eval = substr($error_eval,0,strlen($error_eval)-1); $error_info = "The ".$error_eval." evaluations are not completed."; $this->session->set_flashdata('error_info',$error_info); redirect(base_url().'teacher_manager/term_wise_sheet_data/'.$term_value.'/'.$class_name1.'/'.$subject_id,'refresh'); } above is my controller. plz help someone
0debug
iPython how to resize images ? : I am getting confused over all the different iPython datatypes. I wrote a face recognition algorithm in Matlab. I want to redo it it iPython. I am stuck trying to resize my images. How do I do that ? Can someone link me to the things that i need to read to understand the difference in the functions between matlab in ipython ? Like matlab got imresize but python got what ? **Is there something like import all_matlab_functions so i can ipython in matlab language ?** I cant believe im struggling so hard. Help ! My code below shows how stupid i am with ipython currently. %matplotlib inline import matplotlib.image as mpimg import glob import matplotlib.pyplot as plt image_list = [] for filename in glob.glob('<directory>.pgm'): im = mpimg.imread(filename) image_list.append(im) # read all image from PIL import Image haha = image_list[1].resize((10 10), resample=0) # try to resize image BUT FAIL
0debug
static void device_set_hotplugged(Object *obj, bool value, Error **err) { DeviceState *dev = DEVICE(obj); dev->hotplugged = value; }
1threat
static void monitor_handle_command(Monitor *mon, const char *cmdline) { const char *p, *pstart, *typestr; char *q; int c, nb_args, len, i, has_arg; const mon_cmd_t *cmd; char cmdname[256]; char buf[1024]; void *str_allocated[MAX_ARGS]; void *args[MAX_ARGS]; void (*handler_0)(Monitor *mon); void (*handler_1)(Monitor *mon, void *arg0); void (*handler_2)(Monitor *mon, void *arg0, void *arg1); void (*handler_3)(Monitor *mon, void *arg0, void *arg1, void *arg2); void (*handler_4)(Monitor *mon, void *arg0, void *arg1, void *arg2, void *arg3); void (*handler_5)(Monitor *mon, void *arg0, void *arg1, void *arg2, void *arg3, void *arg4); void (*handler_6)(Monitor *mon, void *arg0, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5); void (*handler_7)(Monitor *mon, void *arg0, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6); #ifdef DEBUG monitor_printf(mon, "command='%s'\n", cmdline); #endif p = cmdline; q = cmdname; while (qemu_isspace(*p)) p++; if (*p == '\0') return; pstart = p; while (*p != '\0' && *p != '/' && !qemu_isspace(*p)) p++; len = p - pstart; if (len > sizeof(cmdname) - 1) len = sizeof(cmdname) - 1; memcpy(cmdname, pstart, len); cmdname[len] = '\0'; for(cmd = mon_cmds; cmd->name != NULL; cmd++) { if (compare_cmd(cmdname, cmd->name)) goto found; } monitor_printf(mon, "unknown command: '%s'\n", cmdname); return; found: for(i = 0; i < MAX_ARGS; i++) str_allocated[i] = NULL; typestr = cmd->args_type; nb_args = 0; for(;;) { c = *typestr; if (c == '\0') break; typestr++; switch(c) { case 'F': case 'B': case 's': { int ret; char *str; while (qemu_isspace(*p)) p++; if (*typestr == '?') { typestr++; if (*p == '\0') { str = NULL; goto add_str; } } ret = get_str(buf, sizeof(buf), &p); if (ret < 0) { switch(c) { case 'F': monitor_printf(mon, "%s: filename expected\n", cmdname); break; case 'B': monitor_printf(mon, "%s: block device name expected\n", cmdname); break; default: monitor_printf(mon, "%s: string expected\n", cmdname); break; } goto fail; } str = qemu_malloc(strlen(buf) + 1); pstrcpy(str, sizeof(buf), buf); str_allocated[nb_args] = str; add_str: if (nb_args >= MAX_ARGS) { error_args: monitor_printf(mon, "%s: too many arguments\n", cmdname); goto fail; } args[nb_args++] = str; } break; case '/': { int count, format, size; while (qemu_isspace(*p)) p++; if (*p == '/') { p++; count = 1; if (qemu_isdigit(*p)) { count = 0; while (qemu_isdigit(*p)) { count = count * 10 + (*p - '0'); p++; } } size = -1; format = -1; for(;;) { switch(*p) { case 'o': case 'd': case 'u': case 'x': case 'i': case 'c': format = *p++; break; case 'b': size = 1; p++; break; case 'h': size = 2; p++; break; case 'w': size = 4; p++; break; case 'g': case 'L': size = 8; p++; break; default: goto next; } } next: if (*p != '\0' && !qemu_isspace(*p)) { monitor_printf(mon, "invalid char in format: '%c'\n", *p); goto fail; } if (format < 0) format = default_fmt_format; if (format != 'i') { if (size < 0) size = default_fmt_size; default_fmt_size = size; } default_fmt_format = format; } else { count = 1; format = default_fmt_format; if (format != 'i') { size = default_fmt_size; } else { size = -1; } } if (nb_args + 3 > MAX_ARGS) goto error_args; args[nb_args++] = (void*)(long)count; args[nb_args++] = (void*)(long)format; args[nb_args++] = (void*)(long)size; } break; case 'i': case 'l': { int64_t val; while (qemu_isspace(*p)) p++; if (*typestr == '?' || *typestr == '.') { if (*typestr == '?') { if (*p == '\0') has_arg = 0; else has_arg = 1; } else { if (*p == '.') { p++; while (qemu_isspace(*p)) p++; has_arg = 1; } else { has_arg = 0; } } typestr++; if (nb_args >= MAX_ARGS) goto error_args; args[nb_args++] = (void *)(long)has_arg; if (!has_arg) { if (nb_args >= MAX_ARGS) goto error_args; val = -1; goto add_num; } } if (get_expr(mon, &val, &p)) goto fail; add_num: if (c == 'i') { if (nb_args >= MAX_ARGS) goto error_args; args[nb_args++] = (void *)(long)val; } else { if ((nb_args + 1) >= MAX_ARGS) goto error_args; #if TARGET_PHYS_ADDR_BITS > 32 args[nb_args++] = (void *)(long)((val >> 32) & 0xffffffff); #else args[nb_args++] = (void *)0; #endif args[nb_args++] = (void *)(long)(val & 0xffffffff); } } break; case '-': { int has_option; c = *typestr++; if (c == '\0') goto bad_type; while (qemu_isspace(*p)) p++; has_option = 0; if (*p == '-') { p++; if (*p != c) { monitor_printf(mon, "%s: unsupported option -%c\n", cmdname, *p); goto fail; } p++; has_option = 1; } if (nb_args >= MAX_ARGS) goto error_args; args[nb_args++] = (void *)(long)has_option; } break; default: bad_type: monitor_printf(mon, "%s: unknown type '%c'\n", cmdname, c); goto fail; } } while (qemu_isspace(*p)) p++; if (*p != '\0') { monitor_printf(mon, "%s: extraneous characters at the end of line\n", cmdname); goto fail; } switch(nb_args) { case 0: handler_0 = cmd->handler; handler_0(mon); break; case 1: handler_1 = cmd->handler; handler_1(mon, args[0]); break; case 2: handler_2 = cmd->handler; handler_2(mon, args[0], args[1]); break; case 3: handler_3 = cmd->handler; handler_3(mon, args[0], args[1], args[2]); break; case 4: handler_4 = cmd->handler; handler_4(mon, args[0], args[1], args[2], args[3]); break; case 5: handler_5 = cmd->handler; handler_5(mon, args[0], args[1], args[2], args[3], args[4]); break; case 6: handler_6 = cmd->handler; handler_6(mon, args[0], args[1], args[2], args[3], args[4], args[5]); break; case 7: handler_7 = cmd->handler; handler_7(mon, args[0], args[1], args[2], args[3], args[4], args[5], args[6]); break; default: monitor_printf(mon, "unsupported number of arguments: %d\n", nb_args); goto fail; } fail: for(i = 0; i < MAX_ARGS; i++) qemu_free(str_allocated[i]); return; }
1threat
Is there a way to style elements based on flex-wrap state? : <p>Quite straight forward, is there a way to know whether an element has been wrapped because of <code>flex-wrap</code> and therefore style it differently?</p>
0debug
static int decode_dds1(GetByteContext *gb, uint8_t *frame, int width, int height) { const uint8_t *frame_start = frame; const uint8_t *frame_end = frame + width * height; int mask = 0x10000, bitbuf = 0; int i, v, offset, count, segments; segments = bytestream2_get_le16(gb); while (segments--) { if (bytestream2_get_bytes_left(gb) < 2) return AVERROR_INVALIDDATA; if (mask == 0x10000) { bitbuf = bytestream2_get_le16u(gb); mask = 1; } if (bitbuf & mask) { v = bytestream2_get_le16(gb); offset = (v & 0x1FFF) << 2; count = ((v >> 13) + 2) << 1; if (frame - frame_start < offset || frame_end - frame < count*2 + width) return AVERROR_INVALIDDATA; for (i = 0; i < count; i++) { frame[0] = frame[1] = frame[width] = frame[width + 1] = frame[-offset]; frame += 2; } } else if (bitbuf & (mask << 1)) { v = bytestream2_get_le16(gb)*2; if (frame - frame_end < v) return AVERROR_INVALIDDATA; frame += v; } else { if (frame_end - frame < width + 3) return AVERROR_INVALIDDATA; frame[0] = frame[1] = frame[width] = frame[width + 1] = bytestream2_get_byte(gb); frame += 2; frame[0] = frame[1] = frame[width] = frame[width + 1] = bytestream2_get_byte(gb); frame += 2; } mask <<= 2; } return 0; }
1threat
How get word from JSON : How could I get(("id"=) + 5 values) from JSON. JSON looks like: {"html":"<div class=\"\" ng-reflect-dragula=\"second-bag\"><!--bindings={\n \"ng-reflect-ng-for-of\": \"[object Object],[object Object\"\n}--><div id=\"1\" class=\"\" style=\"background-color: rgb(129, 205, 51) As result I wanna get "id=\1\"
0debug
Restore a mongo DB from a compose.io backup? : <p>If you download a compose.io backup of a mongodb instance and uncompress the .tar file you end up with <code>.ns</code> and extensions that are single digits. How do you restore the db from these?</p>
0debug
int rom_load_all(void) { target_phys_addr_t addr = 0; int memtype; Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { if (addr < rom->min) addr = rom->min; if (rom->max) { if (rom->align) { addr += (rom->align-1); addr &= ~(rom->align-1); } if (addr + rom->romsize > rom->max) { fprintf(stderr, "rom: out of memory (rom %s, " "addr 0x" TARGET_FMT_plx ", size 0x%zx, max 0x" TARGET_FMT_plx ")\n", rom->name, addr, rom->romsize, rom->max); return -1; } } else { if (addr != rom->min) { fprintf(stderr, "rom: requested regions overlap " "(rom %s. free=0x" TARGET_FMT_plx ", addr=0x" TARGET_FMT_plx ")\n", rom->name, addr, rom->min); return -1; } } rom->addr = addr; addr += rom->romsize; memtype = cpu_get_physical_page_desc(rom->addr) & (3 << IO_MEM_SHIFT); if (memtype == IO_MEM_ROM) rom->isrom = 1; } qemu_register_reset(rom_reset, NULL); roms_loaded = 1; return 0; }
1threat
How to add multiple conditions in one equality condition? : <p>I would like to know how to add multiple conditions in one equality condition. For example, how to specify multiple equalities for x here.<code>(x == (1 || 2 || 3))</code>. This is how I've tried but doesn't work.</p>
0debug
Migration: No DbContext was found in assembly : <p>Using VS Community 2017. I have tried to create initial migration with error message saying: </p> <blockquote> <p>Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\Add-Migration' for Entity Framework 6. No DbContext was found in assembly 'Test_Project'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.</p> </blockquote> <p>... code in my dbcontext:</p> <pre><code>protected override void OnModelCreating(DbModelBuilder mb) { base.OnModelCreating(mb); mb.Entity&lt;Stuff&gt;().ToTable("Stuff"); } public DbSet&lt;Stuff&gt; Stuff{ get; set; } </code></pre>
0debug
JSON to C# class issue : <p>I'm new to JSON and I'm trying to convert JSON data to C# class, but I always get errors when converting to C# entity class. Can someone tell me how to properly convert the following JSON data to C# class? Thank you very much! orz</p> <pre><code>[ { "place_id":121943890, "licence":"Data ยฉ OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright", "osm_type":"way", "osm_id":195289214, "boundingbox":["28.0650511","28.0769594","112.9936342","113.0111091"], "lat":"28.07081905", "lon":"113.002623874342", "display_name":"Changsha", "class":"amenity", "type":"university", "importance":0.11100000000000002, "icon":"https://nominatim.openstreetmap.org/images/mapicons/education_university.p.20.png", "geojson":{ "type":"Polygon", "coordinates":[ [ [112.9936342,28.0740059], [112.9957532,28.0699078], [112.9968442,28.0691153], [112.9970274,28.0689822], [113.0003451,28.0669209], [113.0012613,28.0650511], [113.0111091,28.0676428], [113.0096377,28.0717303], [113.0084561,28.0746411], [113.0074304,28.0769594], [113.0015116,28.0756923], [113.0011744,28.0756201], [112.9936342,28.0740059] ] ] } } ] </code></pre>
0debug
How to get indexes of groups in a match in regex in Python? : <p>I want to get indexes of a group in matches in regex. Notice image below:</p> <p><a href="https://i.stack.imgur.com/edFV8.jpg" rel="nofollow noreferrer">image link</a></p> <p>You can see it founded 3 matches. The left side shows Match's indexes and Group 1's indexes. I want to get Group 1's indexes in Python, How can i do it? There is a image below that shows what are Python's returns:</p> <p><a href="https://i.stack.imgur.com/Xg3BT.jpg" rel="nofollow noreferrer">failed Python code to get Group's indexes</a></p>
0debug
How do I defer shell completion to another command in bash and zsh? : <p>I am attempting to write a shell script utility that wraps other shell utilities into a single CLI and am trying to get shell completion to work in zsh and bash.</p> <p>For example, let's say the CLI is named <code>util</code>:</p> <pre><code>util aws [...args] #=&gt; runs aws util docker [...args] #=&gt; runs docker util terraform [...args] #=&gt; runs terraform </code></pre> <p>What I would like, ideally, is a way in zsh and bash completion to be able to say "complete this subcommand X like other command Y" independently from the implementation of the completion for the wrapped scripts.</p> <p>Something like:</p> <pre><code>compdef 'util aws'='aws' compdef 'util docker'='docker' compdef 'util terraform'='terraform' </code></pre> <p>A stretch goal would be to allow for completion of an arbitrary sub-command to a subcommand in another binary:</p> <pre><code>util aws [...args] #=&gt; completes against `aws` util ecr [...args] #=&gt; completes against `aws ecr` </code></pre> <p>Is any of this possible? I've been attempting to emulate the completion scripts of the individual binaries, however there is significant variation in how other completion scripts are written.</p>
0debug
static void tpm_display_backend_drivers(void) { int i; fprintf(stderr, "Supported TPM types (choose only one):\n"); for (i = 0; i < TPM_MAX_DRIVERS && be_drivers[i] != NULL; i++) { fprintf(stderr, "%12s %s\n", TpmType_lookup[be_drivers[i]->type], be_drivers[i]->desc()); } fprintf(stderr, "\n"); }
1threat
Index n dimensional array with (n-1) d array : <p>What is the most elegant way to access an n dimensional array with an (n-1) dimensional array along a given dimension as in the dummy example</p> <pre><code>a = np.random.random_sample((3,4,4)) b = np.random.random_sample((3,4,4)) idx = np.argmax(a, axis=0) </code></pre> <p>How can I access now with <code>idx a</code> to get the maxima in <code>a</code> as if I had used <code>a.max(axis=0)</code>? or how to retrieve the values specified by <code>idx</code> in <code>b</code>?</p> <p>I thought about using <code>np.meshgrid</code> but I think it is an overkill. Note that the dimension <code>axis</code> can be any usefull axis (0,1,2) and is not known in advance. Is there an elegant way to do this?</p>
0debug
void do_subfo (void) { T2 = T0; T0 = T1 - T0; if (likely(!(((~T2) ^ T1 ^ (-1)) & ((~T2) ^ T0) & (1 << 31)))) { xer_ov = 0; } else { xer_so = 1; xer_ov = 1; } RETURN(); }
1threat
HTML CSS Bootstrap difficulty : <p>Im currently developing a website as part of a project. I have a navigation bar at the top of my website that contains one of the buttons being a hover over dropdown. Beneath, i have a carousel i have inserted using a bootstrap. When i link the CSS bootstrap, it alters the css for the navigation bar, and the hover over dropdown no longer works. Is there anyway i can isolate the bootstrap CSS to only apply to the carousel. I don't have a bootstrap.css i just use link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css".</p>
0debug
QapiDeallocVisitor *qapi_dealloc_visitor_new(void) { QapiDeallocVisitor *v; v = g_malloc0(sizeof(*v)); v->visitor.type = VISITOR_DEALLOC; v->visitor.start_struct = qapi_dealloc_start_struct; v->visitor.end_struct = qapi_dealloc_end_struct; v->visitor.start_alternate = qapi_dealloc_start_alternate; v->visitor.end_alternate = qapi_dealloc_end_alternate; v->visitor.start_list = qapi_dealloc_start_list; v->visitor.next_list = qapi_dealloc_next_list; v->visitor.end_list = qapi_dealloc_end_list; v->visitor.type_int64 = qapi_dealloc_type_int64; v->visitor.type_uint64 = qapi_dealloc_type_uint64; v->visitor.type_bool = qapi_dealloc_type_bool; v->visitor.type_str = qapi_dealloc_type_str; v->visitor.type_number = qapi_dealloc_type_number; v->visitor.type_any = qapi_dealloc_type_anything; v->visitor.type_null = qapi_dealloc_type_null; return v; }
1threat
window.location.href = 'http://attack.com?user=' + user_input;
1threat
Is this ER Diagram of a Bank Account correct? : > โ€ข Each customer has a name, a permanent address, and a social security > number. โ€ข Each customer can have multiple phone numbers, and the same > phone number may be shared by multiple customers. โ€ข A customer can > own multiple accounts, but each account is owned by a single customer. > โ€ข Each account has an account number, a type (such as saving, > checking, etc.), and a balance โ€ข The bank issues an account statement > for each account and mails it to its account owner every month. As > time goes on, there will be multiple statements of the same account. > โ€ข Each statement has an issued date and a statement ID. All the > statements of the same account have different statement IDs, but two > different accounts could have statements with the same statement ID. > For example, it is possible that account A has a statement with ID > โ€˜123', while account B has another statement with the same ID '123'. [![enter image description here][1]][1] I have a few questions: (1) Can Min-Max notation be used in case of any relationships, or, just when there is an indication for that in the description? (2) Are my many-to-many relationships portrayed correctly here? (3) Could I properly portray the relationships among Account vs Account Statement vs StatementID? (4) As per my assumption, Is Account Statement really a weak entity and is `Has` really a weak relation that is dependent on Statement ID? Is issue-date a weak key? [1]: http://i.stack.imgur.com/pCyHQ.png
0debug
VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf) { V9fsState *s; int i, len; struct stat stat; FsTypeEntry *fse; s = (V9fsState *)virtio_common_init("virtio-9p", VIRTIO_ID_9P, sizeof(struct virtio_9p_config)+ MAX_TAG_LEN, sizeof(V9fsState)); QLIST_INIT(&s->free_list); for (i = 0; i < (MAX_REQ - 1); i++) { QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next); } s->vq = virtio_add_queue(&s->vdev, MAX_REQ, handle_9p_output); fse = get_fsdev_fsentry(conf->fsdev_id); if (!fse) { fprintf(stderr, "Virtio-9p device couldn't find fsdev " "with the id %s\n", conf->fsdev_id); exit(1); } if (!fse->path || !conf->tag) { fprintf(stderr, "fsdev with id %s needs path " "and Virtio-9p device needs mount_tag arguments\n", conf->fsdev_id); exit(1); } if (!strcmp(fse->security_model, "passthrough")) { s->ctx.fs_sm = SM_PASSTHROUGH; } else if (!strcmp(fse->security_model, "mapped")) { s->ctx.fs_sm = SM_MAPPED; } else { fprintf(stderr, "one of the following must be specified as the" "security option:\n\t security_model=passthrough \n\t " "security_model=mapped\n"); return NULL; } if (lstat(fse->path, &stat)) { fprintf(stderr, "share path %s does not exist\n", fse->path); exit(1); } else if (!S_ISDIR(stat.st_mode)) { fprintf(stderr, "share path %s is not a directory \n", fse->path); exit(1); } s->ctx.fs_root = qemu_strdup(fse->path); len = strlen(conf->tag); if (len > MAX_TAG_LEN) { len = MAX_TAG_LEN; } s->tag = qemu_malloc(len); memcpy(s->tag, conf->tag, len); s->tag_len = len; s->ctx.uid = -1; s->ops = fse->ops; s->vdev.get_features = virtio_9p_get_features; s->config_size = sizeof(struct virtio_9p_config) + s->tag_len; s->vdev.get_config = virtio_9p_get_config; return &s->vdev; }
1threat
static int elf_core_dump(int signr, const CPUArchState *env) { const CPUState *cpu = ENV_GET_CPU((CPUArchState *)env); const TaskState *ts = (const TaskState *)cpu->opaque; struct vm_area_struct *vma = NULL; char corefile[PATH_MAX]; struct elf_note_info info; struct elfhdr elf; struct elf_phdr phdr; struct rlimit dumpsize; struct mm_struct *mm = NULL; off_t offset = 0, data_offset = 0; int segs = 0; int fd = -1; init_note_info(&info); errno = 0; getrlimit(RLIMIT_CORE, &dumpsize); if (dumpsize.rlim_cur == 0) return 0; if (core_dump_filename(ts, corefile, sizeof (corefile)) < 0) return (-errno); if ((fd = open(corefile, O_WRONLY | O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) return (-errno); if ((mm = vma_init()) == NULL) goto out; walk_memory_regions(mm, vma_walker); segs = vma_get_mapping_count(mm); fill_elf_header(&elf, segs + 1, ELF_MACHINE, 0); if (dump_write(fd, &elf, sizeof (elf)) != 0) goto out; if (fill_note_info(&info, signr, env) < 0) goto out; offset += sizeof (elf); offset += (segs + 1) * sizeof (struct elf_phdr); fill_elf_note_phdr(&phdr, info.notes_size, offset); offset += info.notes_size; if (dump_write(fd, &phdr, sizeof (phdr)) != 0) goto out; data_offset = offset = roundup(offset, ELF_EXEC_PAGESIZE); for (vma = vma_first(mm); vma != NULL; vma = vma_next(vma)) { (void) memset(&phdr, 0, sizeof (phdr)); phdr.p_type = PT_LOAD; phdr.p_offset = offset; phdr.p_vaddr = vma->vma_start; phdr.p_paddr = 0; phdr.p_filesz = vma_dump_size(vma); offset += phdr.p_filesz; phdr.p_memsz = vma->vma_end - vma->vma_start; phdr.p_flags = vma->vma_flags & PROT_READ ? PF_R : 0; if (vma->vma_flags & PROT_WRITE) phdr.p_flags |= PF_W; if (vma->vma_flags & PROT_EXEC) phdr.p_flags |= PF_X; phdr.p_align = ELF_EXEC_PAGESIZE; bswap_phdr(&phdr, 1); dump_write(fd, &phdr, sizeof (phdr)); } if (write_note_info(&info, fd) < 0) goto out; if (lseek(fd, data_offset, SEEK_SET) != data_offset) goto out; for (vma = vma_first(mm); vma != NULL; vma = vma_next(vma)) { abi_ulong addr; abi_ulong end; end = vma->vma_start + vma_dump_size(vma); for (addr = vma->vma_start; addr < end; addr += TARGET_PAGE_SIZE) { char page[TARGET_PAGE_SIZE]; int error; error = copy_from_user(page, addr, sizeof (page)); if (error != 0) { (void) fprintf(stderr, "unable to dump " TARGET_ABI_FMT_lx "\n", addr); errno = -error; goto out; } if (dump_write(fd, page, TARGET_PAGE_SIZE) < 0) goto out; } } out: free_note_info(&info); if (mm != NULL) vma_delete(mm); (void) close(fd); if (errno != 0) return (-errno); return (0); }
1threat
How to use the KITTI 3D object detection methods in real-time autonomous driving methods, where we have only one calibration set? : I am working on real-time 3D object detection for an autonomous ground vehicle. The sensors that I use is a monocular camera and a VLP16 LiDAR. For calibration and sensor fusion, I used the Autoware camera-LiDAR calibration tool. Now, I want to use the KITTI 3D object detection methods to obtain the 3D bounding boxes on an image. However, each image and its corresponding velodyne point cloud in the KITTI dataset have their own calibration file. In autoware, I am getting only a single extrinsic calibration file for the whole setup. Also, the Autoware calibration parameters are different from the calibration parameters of the KITTI dataset. Can anyone help me in converting the autoware calibration parameters to that of the KITTI dataset, or is there any other method to achieve my goal?
0debug
Decrepit sha 256 : How I Decoded **hash('sha256', $login_password_for_login)** to original password **$login_password_for_login** $login_password_for_login = 12345 **Hash** gives me this 5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5 when I retrive it give me 12345
0debug
how to view view docx, xls, xlsx in browser using laravel ? : **I am using the below code. but still it's downloading the files instead of viewing.** public function viewFiles(StoreBusinessDevelopment $request, $file, $id){ $businessDevelopment = BusinessDevelopment::select('created_by', 'rfp_id') ->where('id', '=', $id) ->get(); $mimeType = File::mimeType(public_path('/uploads/'.$businessDevelopment[0]['created_by'].'/'.$businessDevelopment[0]['rfp_id'].'/'.$file)); return response()->file(public_path('/uploads/'.$businessDevelopment[0]['created_by'].'/'.$businessDevelopment[0]['rfp_id'].'/'.$file),[ 'Content-Type' => $mimeType ]); }
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
Notable differences between buildSchema and GraphQLSchema? : <p>Are there any notable differences between the two? Im interested in anything from runtime and startup performance to features and workflow differences. Documentation does a poor job on explaining the difference and when I should use one over the other.</p> <h1>Example in both versions:</h1> <h3>buildSchema</h3> <pre class="lang-js prettyprint-override"><code>const { graphql, buildSchema } = require('graphql'); const schema = buildSchema(` type Query { hello: String } `); const root = { hello: () =&gt; 'Hello world!' }; graphql(schema, '{ hello }', root).then((response) =&gt; { console.log(response); }); </code></pre> <h3>GraphQLSchema</h3> <pre class="lang-js prettyprint-override"><code>const { graphql, GraphQLSchema, GraphQLObjectType, GraphQLString } = require('graphql'); const schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'Query', fields: () =&gt; ({ hello: { type: GraphQLString, resolve: () =&gt; 'Hello world!' } }) }) }); graphql(schema, '{ hello }').then((response) =&gt; { console.log(response); }); </code></pre>
0debug
Need help figuring out what is wrong with my code! Thank you : 1. I want a result set that will show me the invoices grouped by the vendor. 2. I want a result set that will show me the vendors and the total amount they have been invoiced in order from least amount invoiced to most amount invoiced. 3. I want a result set that shows the vendors and the total amount they have been invoiced that have a total amount greater than $2000.00. Select * from Invoices group by VendorID; Select Vendors.VendorID,Vendors.VendorName,sum(Invoices.InvoiceTotal) from Vendors inner join Invoices on Vendors.VendorID = Invoices.VendorID group by Vendors.VendorID order by sum(Invoices.InvoiceTotal); Select Vendors.VendorID,Vendors.VendorName,sum(Invoices.InvoiceTotal) from Vendors inner join Invoices on Vendors.VendorID = Invoices.VendorID group by Vendors.VendorID having sum(Invoices.InvoiceTotal) > 2000; **This code gives me the same error:** Msg 8120, Level 16, State 1, Line 2 Column 'Invoices.InvoiceID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. Msg 8120, Level 16, State 1, Line 4 Column 'Vendors.VendorName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. Msg 8120, Level 16, State 1, Line 8 Column 'Vendors.VendorName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
0debug
void memory_region_add_subregion(MemoryRegion *mr, hwaddr offset, MemoryRegion *subregion) { subregion->may_overlap = false; subregion->priority = 0; memory_region_add_subregion_common(mr, offset, subregion); }
1threat
static inline void vring_used_write(VirtQueue *vq, VRingUsedElem *uelem, int i) { VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches); hwaddr pa = offsetof(VRingUsed, ring[i]); virtio_tswap32s(vq->vdev, &uelem->id); virtio_tswap32s(vq->vdev, &uelem->len); address_space_write_cached(&caches->used, pa, uelem, sizeof(VRingUsedElem)); address_space_cache_invalidate(&caches->used, pa, sizeof(VRingUsedElem)); }
1threat
Converting A Non-Vuetify Element To Vuetify : <p>I am using a 3rd party payment processor that inserts text inputs into my form. The rest of my form is styled with vuetify (v-text-field). How can I convert a non-vuetify element into vuetify's version of it if the element gets added programmatically (i.e. I don't have control of the text field getting added since this is a 3rd party script)</p>
0debug
Should I use use express or switch to javascript and html? : <p>I have been building this web application that takes user input and after doing so it modifies files on the server side. The core logic of this is build in node.js and works through command line, but most of the site is build using just javascript and HTML.</p> <p>I've read that using express is easier in conjunction with node to modify server-side files. Is this enough reason to switch or should I revamp my code in regular javascript?</p> <p>PD: I'm new to this and this is my first web application</p>
0debug
Why does webpack need an empty extension : <p>I'm trying to figure out why webpack requires this empty extension.</p> <p>Inside <code>resolve.extensions</code> there's always this kind of configuration:</p> <pre><code>extensions: ['', '.js', '.jsx'] </code></pre> <p>Why can't it be just this:</p> <pre><code>extensions: ['.js', '.jsx'] </code></pre>
0debug
static int file_open(URLContext *h, const char *filename, int flags) { int access; int fd; av_strstart(filename, "file:", &filename); if (flags & URL_RDWR) { access = O_CREAT | O_TRUNC | O_RDWR; } else if (flags & URL_WRONLY) { access = O_CREAT | O_TRUNC | O_WRONLY; } else { access = O_RDONLY; } #if defined(__MINGW32__) || defined(CONFIG_OS2) || defined(__CYGWIN__) access |= O_BINARY; #endif fd = open(filename, access, 0666); if (fd < 0) return AVERROR(ENOENT); h->priv_data = (void *)(size_t)fd; return 0; }
1threat
Flutter for loop to generate list of widgets : <p>I have code like this but I want it to iterate over an integer array to display a dynamic amount of children:</p> <pre><code>return Container( child: Column( children: &lt;Widget&gt;[ Center( child: Text(text[0].toString(), textAlign: TextAlign.center), ), Center( child: Text(text[1].toString(), textAlign: TextAlign.center), ), ], ), ) </code></pre> <p>Where the <code>text</code> variable is a list of integers converter to string here. I tried adding a function to iterate through the array and display the 'children' but was getting a type error. Not sure how to do it since I'm new to Dart and Flutter.</p>
0debug
Parallel vectors in C : I need some help with the use of parallel vectors. What I want to do is have 2 parallel vectors, 1 containing the alphabet and the other, the alphabet the other way around and when someone types in a word, it prints out the word using the inverted alphabet. ```#include <iostream> #include <ctype.h> using namespace std; void search(char alfab[], char cripto[], int code){ cout << "Introduce your message: " << endl; cin >> code; for(int i = 0; i < code; i++) { if(code == 0){ cout << "Your code is:" << cripto[i] << endl; } } } int main(){ char alfab[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; char cripto[26] = {'z','y','x','w','v','u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a'}; char code; }``` This is what I've done up until now and I'm not too sure if I'm on the right track or not, I'd appreciate some help, thank you!
0debug
How can I convert this code into HTML only? : <p>how can I convert this HTML+CSS code into HTML only? I'm trying to use this in an email, so the CSS won't work.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; #u168 { z-index: 34; background-color: #57E8E8; padding-bottom: 7px; position: relative; margin-right: -10000px; margin-top: 345px; width: 48.58%; left: 27.15%; } #u186-5 { z-index: 37; min-height: 23px; background-color: transparent; color: #131E2E; font-size: 18px; line-height: 22px; position: relative; margin-right: -10000px; margin-top: 6px; width: 92.06%; left: 2.65%; } #u174 { z-index: 35; background-color: #57E8E8; padding-bottom: 8px; position: relative; margin-right: -10000px; margin-top: 384px; width: 48.58%; left: 27.15%; } #u186-2,#u189-2 { font-weight: bold; } #u177 { z-index: 36; background-color: #57E8E8; padding-bottom: 8px; position: relative; margin-right: -10000px; margin-top: 423px; width: 48.58%; left: 27.15%; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="clearfix grpelem" id="u168"&gt;&lt;!-- group --&gt; &lt;div class="clearfix grpelem" id="u186-5"&gt;&lt;!-- content --&gt; &lt;p&gt;User: &lt;span id="u186-2"&gt;test&lt;/span&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="clearfix grpelem" id="u174"&gt;&lt;!-- group --&gt; &lt;div class="clearfix grpelem" id="u189-5"&gt;&lt;!-- content --&gt; &lt;p&gt;Password: &lt;span id="u189-2"&gt;test&lt;/span&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/html&gt; </code></pre>
0debug
How to perform arithmetic operations inside concatenating string in PHP? : <p>This code:</p> <pre><code>$a = "100"; echo "abc" . $a - 1; </code></pre> <p>prints out <code>-1</code> instead of <code>abc99</code>.</p> <p>Obvious workaround would be:</p> <pre><code>$a = "100"; $tmp = $a - 1; echo "abc" . $tmp; </code></pre> <p>But is there a way to calculate <code>$a - 1</code> without creating temporary variable?</p>
0debug
static inline int gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, int search_pc) { DisasContext dc1, *dc = &dc1; uint16_t *gen_opc_end; int j, lj; target_ulong pc_start; uint32_t next_page_start; pc_start = tb->pc; dc->tb = tb; gen_opc_ptr = gen_opc_buf; gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; gen_opparam_ptr = gen_opparam_buf; dc->is_jmp = DISAS_NEXT; dc->pc = pc_start; dc->singlestep_enabled = env->singlestep_enabled; dc->condjmp = 0; dc->thumb = env->thumb; dc->is_mem = 0; #if !defined(CONFIG_USER_ONLY) dc->user = (env->uncached_cpsr & 0x1f) == ARM_CPU_MODE_USR; #endif next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; nb_gen_labels = 0; lj = -1; do { if (env->nb_breakpoints > 0) { for(j = 0; j < env->nb_breakpoints; j++) { if (env->breakpoints[j] == dc->pc) { gen_op_movl_T0_im((long)dc->pc); gen_op_movl_reg_TN[0][15](); gen_op_debug(); dc->is_jmp = DISAS_JUMP; } } } if (search_pc) { j = gen_opc_ptr - gen_opc_buf; if (lj < j) { lj++; while (lj < j) gen_opc_instr_start[lj++] = 0; } gen_opc_pc[lj] = dc->pc; gen_opc_instr_start[lj] = 1; } if (env->thumb) disas_thumb_insn(dc); else disas_arm_insn(env, dc); if (dc->condjmp && !dc->is_jmp) { gen_set_label(dc->condlabel); dc->condjmp = 0; } } while (!dc->is_jmp && gen_opc_ptr < gen_opc_end && !env->singlestep_enabled && dc->pc < next_page_start); if (__builtin_expect(env->singlestep_enabled, 0)) { if (dc->condjmp) { gen_op_debug(); gen_set_label(dc->condlabel); } if (dc->condjmp || !dc->is_jmp) { gen_op_movl_T0_im((long)dc->pc); gen_op_movl_reg_TN[0][15](); dc->condjmp = 0; } gen_op_debug(); } else { switch(dc->is_jmp) { case DISAS_NEXT: gen_goto_tb(dc, 1, dc->pc); default: case DISAS_JUMP: case DISAS_UPDATE: gen_op_movl_T0_0(); gen_op_exit_tb(); case DISAS_TB_JUMP: } if (dc->condjmp) { gen_set_label(dc->condlabel); gen_goto_tb(dc, 1, dc->pc); dc->condjmp = 0; } } *gen_opc_ptr = INDEX_op_end; #ifdef DEBUG_DISAS if (loglevel & CPU_LOG_TB_IN_ASM) { fprintf(logfile, "----------------\n"); fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start)); target_disas(logfile, pc_start, dc->pc - pc_start, env->thumb); fprintf(logfile, "\n"); if (loglevel & (CPU_LOG_TB_OP)) { fprintf(logfile, "OP:\n"); dump_ops(gen_opc_buf, gen_opparam_buf); fprintf(logfile, "\n"); } } #endif if (search_pc) { j = gen_opc_ptr - gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; tb->size = 0; } else { tb->size = dc->pc - pc_start; } return 0; }
1threat
int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) { MpegEncContext *s = avctx->priv_data; int ret; AVFrame *pict = data; #ifdef PRINT_FRAME_TIME uint64_t time= rdtsc(); #endif #ifdef DEBUG av_log(avctx, AV_LOG_DEBUG, "*****frame %d size=%d\n", avctx->frame_number, buf_size); if(buf_size>0) av_log(avctx, AV_LOG_DEBUG, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); #endif s->flags= avctx->flags; s->flags2= avctx->flags2; if (buf_size == 0) { if (s->low_delay==0 && s->next_picture_ptr) { *pict= *(AVFrame*)s->next_picture_ptr; s->next_picture_ptr= NULL; *data_size = sizeof(AVFrame); } return 0; } if(s->flags&CODEC_FLAG_TRUNCATED){ int next; if(CONFIG_MPEG4_DECODER && s->codec_id==CODEC_ID_MPEG4){ next= ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size); }else if(CONFIG_H263_DECODER && s->codec_id==CODEC_ID_H263){ next= ff_h263_find_frame_end(&s->parse_context, buf, buf_size); }else{ av_log(s->avctx, AV_LOG_ERROR, "this codec does not support truncated bitstreams\n"); return -1; } if( ff_combine_frame(&s->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 ) return buf_size; } retry: if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){ init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8); }else init_get_bits(&s->gb, buf, buf_size*8); s->bitstream_buffer_size=0; if (!s->context_initialized) { if (MPV_common_init(s) < 0) return -1; } if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ int i= ff_find_unused_picture(s, 0); s->current_picture_ptr= &s->picture[i]; } if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5) { ret= ff_wmv2_decode_picture_header(s); } else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) { ret = msmpeg4_decode_picture_header(s); } else if (s->h263_pred) { if(s->avctx->extradata_size && s->picture_number==0){ GetBitContext gb; init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8); ret = ff_mpeg4_decode_picture_header(s, &gb); } ret = ff_mpeg4_decode_picture_header(s, &s->gb); } else if (s->codec_id == CODEC_ID_H263I) { ret = intel_h263_decode_picture_header(s); } else if (s->h263_flv) { ret = flv_h263_decode_picture_header(s); } else { ret = h263_decode_picture_header(s); } if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_size); if (ret < 0){ av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); return -1; } avctx->has_b_frames= !s->low_delay; if(s->xvid_build==0 && s->divx_version==0 && s->lavc_build==0){ if(s->stream_codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVIX") || s->codec_tag == AV_RL32("RMP4")) s->xvid_build= -1; #if 0 if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==1 && s->padding_bug_score > 0 && s->low_delay) s->xvid_build= -1; #endif } if(s->xvid_build==0 && s->divx_version==0 && s->lavc_build==0){ if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==0) s->divx_version= 400; } if(s->xvid_build && s->divx_version){ s->divx_version= s->divx_build= 0; } if(s->workaround_bugs&FF_BUG_AUTODETECT){ if(s->codec_tag == AV_RL32("XVIX")) s->workaround_bugs|= FF_BUG_XVID_ILACE; if(s->codec_tag == AV_RL32("UMP4")){ s->workaround_bugs|= FF_BUG_UMP4; } if(s->divx_version>=500 && s->divx_build<1814){ s->workaround_bugs|= FF_BUG_QPEL_CHROMA; } if(s->divx_version>502 && s->divx_build<1814){ s->workaround_bugs|= FF_BUG_QPEL_CHROMA2; } if(s->xvid_build && s->xvid_build<=3) s->padding_bug_score= 256*256*256*64; if(s->xvid_build && s->xvid_build<=1) s->workaround_bugs|= FF_BUG_QPEL_CHROMA; if(s->xvid_build && s->xvid_build<=12) s->workaround_bugs|= FF_BUG_EDGE; if(s->xvid_build && s->xvid_build<=32) s->workaround_bugs|= FF_BUG_DC_CLIP; #define SET_QPEL_FUNC(postfix1, postfix2) \ s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\ s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\ s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2; if(s->lavc_build && s->lavc_build<4653) s->workaround_bugs|= FF_BUG_STD_QPEL; if(s->lavc_build && s->lavc_build<4655) s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE; if(s->lavc_build && s->lavc_build<4670){ s->workaround_bugs|= FF_BUG_EDGE; } if(s->lavc_build && s->lavc_build<=4712) s->workaround_bugs|= FF_BUG_DC_CLIP; if(s->divx_version) s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE; if(s->divx_version==501 && s->divx_build==20020416) s->padding_bug_score= 256*256*256*64; if(s->divx_version && s->divx_version<500){ s->workaround_bugs|= FF_BUG_EDGE; } if(s->divx_version) s->workaround_bugs|= FF_BUG_HPEL_CHROMA; #if 0 if(s->divx_version==500) s->padding_bug_score= 256*256*256*64; if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==0 && s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0) s->workaround_bugs|= FF_BUG_NO_PADDING; if(s->lavc_build && s->lavc_build<4609) s->workaround_bugs|= FF_BUG_NO_PADDING; #endif } if(s->workaround_bugs& FF_BUG_STD_QPEL){ SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c) } if(avctx->debug & FF_DEBUG_BUGS) av_log(s->avctx, AV_LOG_DEBUG, "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n", s->workaround_bugs, s->lavc_build, s->xvid_build, s->divx_version, s->divx_build, s->divx_packed ? "p" : ""); #if 0 { static FILE *f=NULL; if(!f) f=fopen("rate_qp_cplx.txt", "w"); fprintf(f, "%d %d %f\n", buf_size, s->qscale, buf_size*(double)s->qscale); } #endif #if HAVE_MMX if(s->codec_id == CODEC_ID_MPEG4 && s->xvid_build && avctx->idct_algo == FF_IDCT_AUTO && (mm_flags & FF_MM_MMX)){ avctx->idct_algo= FF_IDCT_XVIDMMX; avctx->coded_width= 0; s->picture_number=0; } #endif if ( s->width != avctx->coded_width || s->height != avctx->coded_height) { ParseContext pc= s->parse_context; s->parse_context.buffer=0; MPV_common_end(s); s->parse_context= pc; } if (!s->context_initialized) { avcodec_set_dimensions(avctx, s->width, s->height); goto retry; } if((s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P)) s->gob_index = ff_h263_get_gob_height(s); s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == FF_I_TYPE; if(s->last_picture_ptr==NULL && (s->pict_type==FF_B_TYPE || s->dropable)) return get_consumed_bytes(s, buf_size); if(avctx->hurry_up && s->pict_type==FF_B_TYPE) return get_consumed_bytes(s, buf_size); if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==FF_B_TYPE) || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=FF_I_TYPE) || avctx->skip_frame >= AVDISCARD_ALL) return get_consumed_bytes(s, buf_size); if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size); if(s->next_p_frame_damaged){ if(s->pict_type==FF_B_TYPE) return get_consumed_bytes(s, buf_size); else s->next_p_frame_damaged=0; } if((s->avctx->flags2 & CODEC_FLAG2_FAST) && s->pict_type==FF_B_TYPE){ s->me.qpel_put= s->dsp.put_2tap_qpel_pixels_tab; s->me.qpel_avg= s->dsp.avg_2tap_qpel_pixels_tab; }else if((!s->no_rounding) || s->pict_type==FF_B_TYPE){ s->me.qpel_put= s->dsp.put_qpel_pixels_tab; s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab; }else{ s->me.qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab; s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab; } if(MPV_frame_start(s, avctx) < 0) return -1; #ifdef DEBUG av_log(avctx, AV_LOG_DEBUG, "qscale=%d\n", s->qscale); #endif ff_er_frame_start(s); if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5){ ret = ff_wmv2_decode_secondary_picture_header(s); if(ret<0) return ret; if(ret==1) goto intrax8_decoded; } s->mb_x=0; s->mb_y=0; decode_slice(s); while(s->mb_y<s->mb_height){ if(s->msmpeg4_version){ if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_count(&s->gb) > s->gb.size_in_bits) break; }else{ if(ff_h263_resync(s)<0) break; } if(s->msmpeg4_version<4 && s->h263_pred) ff_mpeg4_clean_buffers(s); decode_slice(s); } if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==FF_I_TYPE) if(!CONFIG_MSMPEG4_DECODER || msmpeg4_decode_ext_header(s, buf_size) < 0){ s->error_status_table[s->mb_num-1]= AC_ERROR|DC_ERROR|MV_ERROR; } if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_packed){ int current_pos= get_bits_count(&s->gb)>>3; int startcode_found=0; if(buf_size - current_pos > 5){ int i; for(i=current_pos; i<buf_size-3; i++){ if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){ startcode_found=1; break; } } } if(s->gb.buffer == s->bitstream_buffer && buf_size>20){ startcode_found=1; current_pos=0; } if(startcode_found){ s->bitstream_buffer= av_fast_realloc( s->bitstream_buffer, &s->allocated_bitstream_buffer_size, buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos); s->bitstream_buffer_size= buf_size - current_pos; } } intrax8_decoded: ff_er_frame_end(s); MPV_frame_end(s); assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); assert(s->current_picture.pict_type == s->pict_type); if (s->pict_type == FF_B_TYPE || s->low_delay) { *pict= *(AVFrame*)s->current_picture_ptr; } else if (s->last_picture_ptr != NULL) { *pict= *(AVFrame*)s->last_picture_ptr; } if(s->last_picture_ptr || s->low_delay){ *data_size = sizeof(AVFrame); ff_print_debug_info(s, pict); } avctx->frame_number = s->picture_number - 1; #ifdef PRINT_FRAME_TIME av_log(avctx, AV_LOG_DEBUG, "%"PRId64"\n", rdtsc()-time); #endif return get_consumed_bytes(s, buf_size); }
1threat
How can I perform HTTP POST requests from within a Jenkins Groovy script? : <p>I need to be able to create simple HTTP POST request during our <a href="https://github.com/jenkinsci/workflow-plugin" rel="noreferrer">Jenkins Pipeline</a> builds. However I cannot use a simple curl sh script as I need it to work on Windows and Linux nodes, and I don't wish to enforce more tooling installs on nodes if I can avoid it.</p> <p>The Groovy library in use in the Pipeline plugin we're using should be perfect for this task. There is an extension available for Groovy to perform simple POSTs called <a href="http://mvnrepository.com/artifact/org.codehaus.groovy.modules.http-builder/http-builder/0.7.1" rel="noreferrer">http-builder</a>, but I can't for the life of me work out how to make use of it in Jenkins' Groovy installation.</p> <p>If I try to use Grapes Grab to use it within a Pipeline script I get an error failing to do so, <a href="https://gist.github.com/strich/38e472eac507bc73e785" rel="noreferrer">as seen here</a>.</p> <pre><code>@Grapes( @Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1') ) </code></pre> <p>Maybe Grapes Grab isn't supported in the bundled version of Groovy Jenkins uses. Is it possible to simply download and add http-builder and its dependencies to the Jenkins Groovy installation that goes out to the nodes?</p>
0debug
Is there anyone who know what 'Refused to get unsafe header "X-Bandwidth-Est 3"' error means? : I have a problem with every website that I am working on currently. And the error is this: Refused to get unsafe header "X-Bandwidth-Est 3" in base.js. Base.js is youtube file. I searched a lot and I couldn't find this error. Anyone have idea what this error is? [ And this is image of this error][1] [1]: https://i.stack.imgur.com/UPpzN.png
0debug
interpreting address in core file : I am looking for any references or guidance on how to interpret the addresses in the backtrack of a core file. For e.g. a typical backtrack would look like: (gdb) where #0 [0x000012345] in func1 + 123 (a.out + 0xABC) #1 [0x000034345] in func2 + 567 (a.out + 0xea7) .. I can compile with -g and get exact line numbers. But the executable in production environment would not have been compiled with -g in which case I get a stack as above. I would like to know what the addresses and offsets [0x000012345], +123 and 0xABC represent, how to interpret them and how to map them to line number in the source code. Appreciate any help.
0debug
How to call async method from node console? : <p>I have a Bot class with async printInfo method:</p> <pre><code>class TradeBot { async printInfo() { //..... } } </code></pre> <p>If I start 'node', create the object from the console and call the method:</p> <pre><code>&gt;const createBot = require ('./BotFactory'); &gt;const bot = createBot(); &gt;bot.printInfo(); </code></pre> <p>there is an annoying extra information appears in the console:</p> <pre><code>Promise { &lt;pending&gt;, domain: Domain { domain: null, _events: { error: [Function: debugDomainError] }, _eventsCount: 1, _maxListeners: undefined, members: [] } } </code></pre> <p>is there a way to suppress it?</p> <p>'await' keyword produces an error here.</p>
0debug
static MTPData *usb_mtp_get_object(MTPState *s, MTPControl *c, MTPObject *o) { MTPData *d = usb_mtp_data_alloc(c); trace_usb_mtp_op_get_object(s->dev.addr, o->handle, o->path); d->fd = open(o->path, O_RDONLY); if (d->fd == -1) { return NULL; } d->length = o->stat.st_size; d->alloc = 512; d->data = g_malloc(d->alloc); return d; }
1threat
int swr_convert_frame(SwrContext *s, AVFrame *out, const AVFrame *in) { int ret, setup = 0; if (!swr_is_initialized(s)) { if ((ret = swr_config_frame(s, out, in)) < 0) return ret; if ((ret = swr_init(s)) < 0) return ret; setup = 1; } else { if ((ret = config_changed(s, out, in))) return ret; } if (out) { if (!out->linesize[0]) { out->nb_samples = swr_get_delay(s, s->out_sample_rate) + in->nb_samples*(int64_t)s->out_sample_rate / s->in_sample_rate + 3; if ((ret = av_frame_get_buffer(out, 0)) < 0) { if (setup) swr_close(s); return ret; } } else { if (!out->nb_samples) out->nb_samples = available_samples(out); } } return convert_frame(s, out, in); }
1threat
how to remove unwanted text in string.replace()method : <p>I have one word <strong>a</strong> And i replace it like this.</p> <pre><code> String .replace("a","aa"); </code></pre> <p>when i type <strong>a</strong> then output =aa And when i type <strong>ab</strong> then output=aab I want to remove unwanted any word. i try this code. String.replace("b",""); and type <strong>ab</strong> then its work. output=aa.but when i type <strong>ac</strong> then output=aac.i want to short way for remove any unwanted word.it is possible? Thanks in advance.</p>
0debug
long do_rt_sigreturn(CPUMIPSState *env) { struct target_rt_sigframe *frame; abi_ulong frame_addr; sigset_t blocked; frame_addr = env->active_tc.gpr[29]; trace_user_do_rt_sigreturn(env, frame_addr); if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { goto badframe; } target_to_host_sigset(&blocked, &frame->rs_uc.tuc_sigmask); set_sigmask(&blocked); restore_sigcontext(env, &frame->rs_uc.tuc_mcontext); if (do_sigaltstack(frame_addr + offsetof(struct target_rt_sigframe, rs_uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT) goto badframe; env->active_tc.PC = env->CP0_EPC; mips_set_hflags_isa_mode_from_pc(env); env->CP0_EPC = 0; return -TARGET_QEMU_ESIGRETURN; badframe: force_sig(TARGET_SIGSEGV); return 0; }
1threat
Is it possible to intercept and cache WebSocket messages in a Service Worker like all the examples do for normal HTTP requests? : <p>I know you can create WebSocket connections from within a Service Worker itself; my question is more whether or not you can use a WebSocket from your app as normal and have the Service Worker intercept / cache WebSocket requests just like it can do for normal HTTP fetch requests?</p> <p>Here's an example of intercepting and caching a normal HTTP request from a Service Worker.</p> <pre><code>self.addEventListener('fetch', function(event) { // If a match isn't found in the cache, the response // will look like a connection error event.respondWith(caches.match(event.request)); }); </code></pre> <p>How would I setup the Service Worker if all of my requests were via WebSockets?</p>
0debug
"ImportError: file_cache is unavailable" when using Python client for Google service account file_cache : <p>I'm using a service account for G Suite with full domain delegation. I have a script with readonly access to Google Calendar. The script works just fine, but throws an error (on a background thread?) when I "build" the service. Here's the code:</p> <pre><code>from oauth2client.service_account import ServiceAccountCredentials from httplib2 import Http import urllib import requests from apiclient.discovery import build cal_id = "my_calendar_id@group.calendar.google.com" scopes = ['https://www.googleapis.com/auth/calendar.readonly'] credentials = ServiceAccountCredentials.from_json_keyfile_name('my_cal_key.json', scopes=scopes) delegated_credentials = credentials.create_delegated('me@mydomain.com') http_auth = delegated_credentials.authorize(Http()) # This is the line that throws the error cal_service = build('calendar','v3',http=http_auth) #Then everything continues to work normally request = cal_service.events().list(calendarId=cal_id) response = request.execute() # etc... </code></pre> <p>The error thrown is:</p> <pre><code>WARNING:googleapiclient.discovery_cache:file_cache is unavailable when using oauth2client &gt;= 4.0.0 Traceback (most recent call last): File "/Users/myuseraccount/anaconda3/lib/python3.5/site-packages/googleapiclient/discovery_cache/__init__.py", line 36, in autodetect from google.appengine.api import memcache ImportError: No module named 'google' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/myuseraccount/anaconda3/lib/python3.5/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in &lt;module&gt; from oauth2client.contrib.locked_file import LockedFile ImportError: No module named 'oauth2client.contrib.locked_file' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/myuseraccount/anaconda3/lib/python3.5/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in &lt;module&gt; from oauth2client.locked_file import LockedFile ImportError: No module named 'oauth2client.locked_file' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/myuseraccount/anaconda3/lib/python3.5/site-packages/googleapiclient/discovery_cache/__init__.py", line 41, in autodetect from . import file_cache File "/Users/myuseraccount/anaconda3/lib/python3.5/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in &lt;module&gt; 'file_cache is unavailable when using oauth2client &gt;= 4.0.0') ImportError: file_cache is unavailable when using oauth2client &gt;= 4.0.0 </code></pre> <p>What's going on here and is this something that I can fix? I've tried reinstalling and/or upgrading the <code>google</code> package. </p>
0debug
Permisiion to restrict aws cloudformation : I want to create permissions for cloudformation. I have to provide delete permission. How can i restrict in a way so that it can only delete resources which created by cloudformation.
0debug
Text Allignment in d3 : <!-- begin snippet: js hide: false console: true --> <!-- language: lang-js --> var data = [{"seq":"1","start":"Account","end":"Order","relation":"Account","rows":"1"}, {"seq":"2","start":"Account","end":"Attachment","relation":"Parent","rows":"10"} ,{"seq":"3","start":"Order","end":"Account","relation":"Account","rows":"15"} ,{"seq":"4","start":"Attachment","end":"Account","relation":"Parent","rows":"55"} ,{"seq":"5","start":"Attachment","end":"Campaign","relation":"Parent","rows":"45"} ,{"seq":"6","start":"Attachment","end":"Lead","relation":"Parent","rows":"47"} ,{"seq":"7","start":"Lead","end":"Attachment","relation":"Parent","rows":"75"} ,{"seq":"8","start":"Campaign","end":"Attachment","relation":"Parent","rows":"34"}, {"seq":"9","start":"Order","end":"Account","relation":"Account","rows":"99"} ,{"seq":"10","start":"Attachment","end":"Account","relation":"Parent","rows":"12"} ,{"seq":"11","start":"Attachment","end":"Campaign","relation":"Parent","rows":"5"} ,{"seq":"12","start":"Attachment","end":"Lead","relation":"Parent","rows":"75"}]; /* var data =[{"seq":"1","start":"Account","end":"Contact","relation":" Account ","rows":"8"},{"seq":"2","start":"Account","end":"TopicAssignment","relation":"Entity","rows":"0"},{"seq":"1","start":"Account","end":"Order","relation":" Account ","rows":"0"},{"seq":"1","start":"Contact","end":"Account","relation":"Account","rows":"3"},{"seq":"1","start":"TopicAssignment","end":"Account","relation":"Entity","rows":"0"}, {"seq":"1","start":"Order","end":"Account","relation":"Account","rows":"0"}]; */ var ellipseSelected, pathSelected, parentNodeX, parentNodeY, relationshipName, indexEdge, fromData, toData,nodeSelected,startNodeSelected; //flag =1 ,when we have both src and trg var flag = 1; var newCount =0; var edges = d3.selectAll('.edge'); var path = d3.selectAll('.path') var allEllipse = d3.selectAll('ellipse'); var allNodes = d3.selectAll('.node'); var theGraph = document.getElementById('graph0') //getContainer var polygon = document.getElementsByTagName('polygon')[0] //getPolygon to insert after var allEdgesJS = document.getElementsByClassName("edge"); //select all Edges for (var i = 0; i < allEdgesJS.length; i++) { //Loop through edges to move theGraph.insertBefore(allEdgesJS[i], polygon.nextSibling); //insert after polygon } function ellipseAdd() { d3.select(ellipseSelected.parentNode) .append("circle") .attr('cx', parentNodeX) //thisParentBBox.left + thisParentBBox.width/2) .attr('cy', parentNodeY) .attr("r", 10) .attr("stroke-width", 1) .attr("stroke", "white") .style('fill', '#CE2029'); d3.select(ellipseSelected.parentNode) .data([toData]) .append("text") .attr('x', parentNodeX-8) .attr('y', parentNodeY+4).text(0).style('fill','white') .attr("font-size", "8px") .transition() .duration(3000) .tween("text", function(d) { var i = d3.interpolate(fromData, d), prec = (d + "").split("."), round = (prec.length > 1) ? Math.pow(10, prec[1].length) : 1; return function(t) { this.textContent = Math.round(i(t) * round) / round; }; }); } function blinker() { if(flag==0) { //for adding ellipse and text to it ellipseAdd(); } else{ //blink 3 things\ //ellipse ellipseAdd(); d3.select('#' + indexAndEdge[indexEdge].id + ' path').style('opacity', 1) .transition().style('stroke','grey').duration(300).style('opacity', 1) .transition().style('stroke','#CE2029').style('stroke-width', 1) .transition().duration(300).duration(300).style('opacity', 1) .transition().style('stroke','grey').duration(300).style('opacity', 1) .transition().style('stroke','#CE2029').style('stroke-width', 1) .transition().duration(300).duration(300).style('opacity', 1) .transition().style('stroke','grey').duration(300).style('opacity', 1) .transition().style('stroke','#CE2029').style('stroke-width', 1) .transition().duration(300).duration(300).style('opacity', 1) .transition().style('stroke','grey').style('stroke-width',1) .duration(300).style('opacity', 1) .transition().style('stroke',"#ff800e").style('stroke-width', 1); //select current id from array //select current id from array d3.select('#' + indexAndEdge[indexEdge].id + ' polygon') .transition().style('stroke','grey').style('fill','grey').duration(300).style('opacity', 1) .transition().style('fill','#CE2029').style('stroke','#CE2029').style('stroke-width', 2) .transition().duration(300).duration(300).style('opacity', 1) .transition().style('stroke','grey').style('fill','grey').duration(300).style('opacity', 1) .transition().style('fill','#CE2029').style('stroke','#CE2029').style('stroke-width', 2) .transition().duration(300).duration(300).style('opacity', 1) .transition().style('stroke','grey').style('fill','grey').duration(300).style('opacity', 1) .transition().style('stroke','#CE2029').style('fill','#CE2029').style('stroke-width', 2) .transition().duration(300).duration(300).style('opacity', 1) .transition().style('stroke','grey').style('fill','grey').style('stroke-width',1) .duration(300).style('opacity', 1) .transition().style('stroke',"#ff800e").style('fill',"#ff800e").style('stroke-width', 1); //select current id from array d3.select('#' + indexAndEdge[indexEdge].id + ' text').style('opacity', 0) .transition().style('fill','grey').duration(300).style('opacity', 1) .transition().style('fill','#CE2029') .transition().duration(300).duration(300).style('opacity', 1) .transition().style('fill','grey').duration(300).style('opacity', 1) .transition().style('fill','#CE2029') .transition().duration(300).duration(300).style('opacity', 1) .transition().style('fill','grey').duration(300).style('opacity', 1) .transition().style('fill','#CE2029').style('fill','#CE2029') .transition().duration(300).duration(300).style('opacity', 1) .transition().style('fill','grey') .duration(300).style('opacity', 1) .transition().style('fill',"#ff800e"); } } edges.style('opacity', 1); allNodes.style('fill',"white"); path.style('fill',"yellow"); var indexAndEdge = []; var countOnNode = []; edges.each(function(d, i) { var thisEdgeCount = this.id.substring(4); debugger indexAndEdge.push({ //push index you are at, the edge count worked out above and the id index: i, count: thisEdgeCount, id: this.id, start:String(this.childNodes[0].childNodes[0].nodeValue).split("->")[0], destination:String(this.childNodes[0].childNodes[0].nodeValue).split("->")[1], relation:this.childNodes[6].childNodes[0] }) d3.select('#' + indexAndEdge[i].id + ' polygon').style('fill','grey').style('stroke','grey'); d3.select('#' + indexAndEdge[i].id + ' path').style('stroke','grey'); }); d3.selectAll('.node').each(function(d, i) { var thisNodeCount = this.id; debugger countOnNode.push({ //push index you are at, the edge count worked out above and the id id : thisNodeCount, prevData : 0, incrementData : 0, title : this.childNodes[0].childNodes[0].nodeValue , name: String(this.childNodes[4].childNodes[0].nodeValue) }) }); function timer() { setTimeout(function(d) { if (newCount < data.length) { //if we havent gone through all edges if(data[newCount].end.length==0) { flag = 0; for(j=0;j<allNodes[0].length;j++) { //if sourseName matches if(String(allNodes[0][j].childNodes[4].childNodes[0].nodeValue)==data[newCount].start) { ellipseSelected = d3.selectAll('.node')[0][j].childNodes[2]; parentNodeX = ellipseSelected.attributes.cx.value-ellipseSelected.attributes.rx.value +(2*ellipseSelected.attributes.rx.value) ; parentNodeY =ellipseSelected.attributes.cy.value-(ellipseSelected.attributes.ry.value/2); //send the data to interpolate //match id and update prevData ,incrementData for( var l= 0 ; l < countOnNode.length ; l++ ) { if(countOnNode[l].id == d3.selectAll('.node')[0][j].id ) { countOnNode[l].prevData = countOnNode[l].incrementData; countOnNode[l].incrementData = data[newCount].rows; fromData = countOnNode[l].prevData ; toData = countOnNode[l].incrementData; } } blinker(); flag=1; if(flag==1) {break;} } } } else { //check relation and targetNode //check target flag = 1; for(var j=0 ; j < allNodes[0].length ; j++ ) { if(String(allNodes[0][j].childNodes[4].childNodes[0].nodeValue)==data[newCount].end) { ellipseSelected = d3.selectAll('.node')[0][j].childNodes[2]; parentNodeX = ellipseSelected.attributes.cx.value-ellipseSelected.attributes.rx.value +(2*ellipseSelected.attributes.rx.value) ; parentNodeY =ellipseSelected.attributes.cy.value-(ellipseSelected.attributes.ry.value/2); for( var l= 0 ; l < countOnNode.length ; l++ ) { if(countOnNode[l].id == d3.selectAll('.node')[0][j].id ) { countOnNode[l].prevData = countOnNode[l].incrementData; countOnNode[l].incrementData = +data[newCount].rows + +countOnNode[l].prevData; fromData = countOnNode[l].prevData ; toData = countOnNode[l].incrementData; nodeSelected = l; // console.log(" j =" + j + "l "+l+ " fromData " + fromData + " toData "+toData); } } debugger for (var ll = 0; ll < countOnNode.length; ll++) { if (countOnNode[ll].name == data[newCount].start) { debugger; // console.log(data[newCount]); startNodeSelected = ll; } } debugger //set the edge by checking relation for(var k=0 ; k < indexAndEdge.length ; k++) { //if(edges[0][k].childNodes[7].childNodes[0] == indexAndEdge) if((data[newCount].relation.trim() == (String(indexAndEdge[k].relation.nodeValue).trim()) && (( (countOnNode[nodeSelected].title == indexAndEdge[k].destination)&&(countOnNode[startNodeSelected].title == indexAndEdge[k].start))||((countOnNode[nodeSelected].title == indexAndEdge[k].start)&&(countOnNode[startNodeSelected].title == indexAndEdge[k].destination))))) { indexEdge = k; } } blinker(); flag = 0; if(flag==0) { break; } } } } //allEllipse newCount++; timer(); } else { // count =0 ; timer() console.log('end') //end } }, 3000) } timer(); <!-- language: lang-html --> <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script> <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <!-- Generated by graphviz version 2.38.0 (20140413.2041) --> <!-- Title: graphname Pages: 1 --> <svg width="308pt" height="131pt" viewBox="0.00 0.00 308.09 131.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 127)"> <title>graphname</title> <polygon fill="white" stroke="none" points="-4,4 -4,-127 304.095,-127 304.095,4 -4,4"/> <!-- 0 --> <g id="node1" class="node"><title>0</title> <ellipse fill="#b2dfee" stroke="#b2dfee" cx="51.4971" cy="-105" rx="42.4939" ry="18"/> <text text-anchor="middle" x="51.4971" y="-101.3" font-family="Times New Roman,serif" font-size="14.00">Account</text> </g> <!-- 1 --> <g id="node2" class="node"><title>1</title> <ellipse fill="#b2dfee" stroke="#b2dfee" cx="177.497" cy="-18" rx="51.9908" ry="18"/> <text text-anchor="middle" x="177.497" y="-14.3" font-family="Times New Roman,serif" font-size="14.00">Attachment</text> </g> <!-- 0&#45;&gt;1 --> <g id="edge1" class="edge"><title>0&#45;&gt;1</title> <path fill="none" stroke="#cd0000" d="M81.6636,-83.6496C104.156,-68.4764 134.397,-48.0758 154.846,-34.2806"/> <polygon fill="#cd0000" stroke="#cd0000" points="79.4899,-80.894 73.1573,-89.388 83.4047,-86.697 79.4899,-80.894"/> <text text-anchor="middle" x="143.997" y="-57.8" font-family="Times New Roman,serif" font-size="14.00"> Parent </text> </g> <!-- 2 --> <g id="node3" class="node"><title>2</title> <ellipse fill="#b2dfee" stroke="#b2dfee" cx="32.4971" cy="-18" rx="32.4942" ry="18"/> <text text-anchor="middle" x="32.4971" y="-14.3" font-family="Times New Roman,serif" font-size="14.00">Order</text> </g> <!-- 0&#45;&gt;2 --> <g id="edge2" class="edge"><title>0&#45;&gt;2</title> <path fill="none" stroke="#cd0000" d="M36.6269,-78.2339C35.365,-75.1966 34.2755,-72.0805 33.4971,-69 30.8171,-58.3937 30.5329,-46.1155 30.9355,-36.3806"/> <polygon fill="#cd0000" stroke="#cd0000" points="33.6008,-80.0185 41.0756,-87.527 39.9146,-76.9959 33.6008,-80.0185"/> <text text-anchor="middle" x="61.4971" y="-57.8" font-family="Times New Roman,serif" font-size="14.00"> Account </text> </g> <!-- 3 --> <g id="node4" class="node"><title>3</title> <ellipse fill="#b2dfee" stroke="#b2dfee" cx="177.497" cy="-105" rx="47.3916" ry="18"/> <text text-anchor="middle" x="177.497" y="-101.3" font-family="Times New Roman,serif" font-size="14.00">Campaign</text> </g> <!-- 3&#45;&gt;1 --> <g id="edge3" class="edge"><title>3&#45;&gt;1</title> <path fill="none" stroke="#cd0000" d="M177.497,-76.7339C177.497,-63.4194 177.497,-47.806 177.497,-36.1754"/> <polygon fill="#cd0000" stroke="#cd0000" points="173.997,-76.7989 177.497,-86.799 180.997,-76.799 173.997,-76.7989"/> <text text-anchor="middle" x="198.997" y="-57.8" font-family="Times New Roman,serif" font-size="14.00"> Parent </text> </g> <!-- 4 --> <g id="node5" class="node"><title>4</title> <ellipse fill="#b2dfee" stroke="#b2dfee" cx="271.497" cy="-105" rx="28.6953" ry="18"/> <text text-anchor="middle" x="271.497" y="-101.3" font-family="Times New Roman,serif" font-size="14.00">Lead</text> </g> <!-- 4&#45;&gt;1 --> <g id="edge4" class="edge"><title>4&#45;&gt;1</title> <path fill="none" stroke="#cd0000" d="M251.874,-81.4584C243.735,-72.5603 233.988,-62.4628 224.497,-54 216.904,-47.2291 208.071,-40.4074 200.126,-34.6078"/> <polygon fill="#cd0000" stroke="#cd0000" points="249.277,-83.8042 258.567,-88.8979 254.481,-79.1226 249.277,-83.8042"/> <text text-anchor="middle" x="259.997" y="-57.8" font-family="Times New Roman,serif" font-size="14.00"> Parent </text> </g> </g> </svg> <!-- end snippet --> Here,circle is added to .svg file.And then text to that circle is added. I want to add text at centre of circle and also if number is bigger like 10000 ,it should fit to that circle. I tried with .attr('height', 'auto') .attr('text-anchor', 'middle') But,as position of text is decided on which node is added(present in .svg file) and not on circle position,it is not working. Thank you.
0debug
How to connect LSTM layers in Keras, RepeatVector or return_sequence=True? : <p>I'm trying to develop an Encoder model in keras for timeseries. The shape of data is (5039, 28, 1), meaning that my seq_len is 28 and I have one feature. For the first layer of the encoder, I'm using 112 hunits, second layer will have 56 and to be able to get back to the input shape for decoder, I had to add 3rd layer with 28 hunits (this autoencoder is supposed to reconstruct its input). But I don't know what is the correct approach to connect the LSTM layers together. AFAIK, I can either add <code>RepeatVector</code> or <code>return_seq=True</code>. You can see both of my models in the following code. I wonder what will be the difference and which approach is the correct one? </p> <p>First model using <code>return_sequence=True</code>:</p> <pre><code>inputEncoder = Input(shape=(28, 1)) firstEncLayer = LSTM(112, return_sequences=True)(inputEncoder) snd = LSTM(56, return_sequences=True)(firstEncLayer) outEncoder = LSTM(28)(snd) context = RepeatVector(1)(outEncoder) context_reshaped = Reshape((28,1))(context) encoder_model = Model(inputEncoder, outEncoder) firstDecoder = LSTM(112, return_sequences=True)(context_reshaped) outDecoder = LSTM(1, return_sequences=True)(firstDecoder) autoencoder = Model(inputEncoder, outDecoder) </code></pre> <p>Second model with <code>RepeatVector</code>:</p> <pre><code>inputEncoder = Input(shape=(28, 1)) firstEncLayer = LSTM(112)(inputEncoder) firstEncLayer = RepeatVector(1)(firstEncLayer) snd = LSTM(56)(firstEncLayer) snd = RepeatVector(1)(snd) outEncoder = LSTM(28)(snd) encoder_model = Model(inputEncoder, outEncoder) context = RepeatVector(1)(outEncoder) context_reshaped = Reshape((28, 1))(context) firstDecoder = LSTM(112)(context_reshaped) firstDecoder = RepeatVector(1)(firstDecoder) sndDecoder = LSTM(28)(firstDecoder) outDecoder = RepeatVector(1)(sndDecoder) outDecoder = Reshape((28, 1))(outDecoder) autoencoder = Model(inputEncoder, outDecoder) </code></pre>
0debug
static int mxpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MXpegDecodeContext *s = avctx->priv_data; MJpegDecodeContext *jpg = &s->jpg; const uint8_t *buf_end, *buf_ptr; const uint8_t *unescaped_buf_ptr; int unescaped_buf_size; int start_code; int ret; buf_ptr = buf; buf_end = buf + buf_size; jpg->got_picture = 0; s->got_mxm_bitmask = 0; while (buf_ptr < buf_end) { start_code = ff_mjpeg_find_marker(jpg, &buf_ptr, buf_end, &unescaped_buf_ptr, &unescaped_buf_size); if (start_code < 0) goto the_end; { init_get_bits(&jpg->gb, unescaped_buf_ptr, unescaped_buf_size*8); if (start_code >= APP0 && start_code <= APP15) { mxpeg_decode_app(s, unescaped_buf_ptr, unescaped_buf_size); } switch (start_code) { case SOI: if (jpg->got_picture) goto the_end; break; case EOI: goto the_end; case DQT: ret = ff_mjpeg_decode_dqt(jpg); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "quantization table decode error\n"); return ret; } break; case DHT: ret = ff_mjpeg_decode_dht(jpg); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "huffman table decode error\n"); return ret; } break; case COM: ret = mxpeg_decode_com(s, unescaped_buf_ptr, unescaped_buf_size); if (ret < 0) return ret; break; case SOF0: s->got_sof_data = 0; ret = ff_mjpeg_decode_sof(jpg); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "SOF data decode error\n"); return ret; } if (jpg->interlaced) { av_log(avctx, AV_LOG_ERROR, "Interlaced mode not supported in MxPEG\n"); return AVERROR(EINVAL); } s->got_sof_data = 1; break; case SOS: if (!s->got_sof_data) { av_log(avctx, AV_LOG_WARNING, "Can not process SOS without SOF data, skipping\n"); break; } if (!jpg->got_picture) { if (jpg->first_picture) { av_log(avctx, AV_LOG_WARNING, "First picture has no SOF, skipping\n"); break; } if (!s->got_mxm_bitmask){ av_log(avctx, AV_LOG_WARNING, "Non-key frame has no MXM, skipping\n"); break; } av_frame_unref(jpg->picture_ptr); if ((ret = ff_get_buffer(avctx, jpg->picture_ptr, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; jpg->picture_ptr->pict_type = AV_PICTURE_TYPE_P; jpg->picture_ptr->key_frame = 0; jpg->got_picture = 1; } else { jpg->picture_ptr->pict_type = AV_PICTURE_TYPE_I; jpg->picture_ptr->key_frame = 1; } if (s->got_mxm_bitmask) { AVFrame *reference_ptr = s->picture[s->picture_index ^ 1]; if (mxpeg_check_dimensions(s, jpg, reference_ptr) < 0) break; if (!reference_ptr->data[0] && (ret = ff_get_buffer(avctx, reference_ptr, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; ret = ff_mjpeg_decode_sos(jpg, s->mxm_bitmask, reference_ptr); if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) return ret; } else { ret = ff_mjpeg_decode_sos(jpg, NULL, NULL); if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) return ret; } break; } buf_ptr += (get_bits_count(&jpg->gb)+7) >> 3; } } the_end: if (jpg->got_picture) { int ret = av_frame_ref(data, jpg->picture_ptr); if (ret < 0) return ret; *got_frame = 1; s->picture_index ^= 1; jpg->picture_ptr = s->picture[s->picture_index]; if (!s->has_complete_frame) { if (!s->got_mxm_bitmask) s->has_complete_frame = 1; else *got_frame = 0; } } return buf_ptr - buf; }
1threat
What the symbol => indicates in Type script as well as ES6 : <p>In typescript as well as in ES6 why we are using =>, when we need to use this one actually.how it makes differ from older version of javascript.</p>
0debug
static inline void gen_lookup_tb(DisasContext *s) { tcg_gen_movi_i32(cpu_R[15], s->pc & ~1); s->is_jmp = DISAS_UPDATE; }
1threat
uint32_t HELPER(testblock)(CPUS390XState *env, uint64_t real_addr) { uintptr_t ra = GETPC(); CPUState *cs = CPU(s390_env_get_cpu(env)); int i; real_addr = wrap_address(env, real_addr) & TARGET_PAGE_MASK; if ((env->cregs[0] & CR0_LOWPROT) && real_addr < 0x2000) { cpu_restore_state(cs, ra); program_interrupt(env, PGM_PROTECTION, 4); return 1; } for (i = 0; i < TARGET_PAGE_SIZE; i += 8) { cpu_stq_real_ra(env, real_addr + i, 0, ra); } return 0; }
1threat
static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp) { CcwDevice *ccw_dev = CCW_DEVICE(cdev); CCWDeviceClass *ck = CCW_DEVICE_GET_CLASS(ccw_dev); DeviceState *parent = DEVICE(ccw_dev); BusState *qbus = qdev_get_parent_bus(parent); VirtualCssBus *cbus = VIRTUAL_CSS_BUS(qbus); SubchDev *sch; int ret; Error *err = NULL; s390_ccw_get_dev_info(cdev, sysfsdev, &err); if (err) { goto out_err_propagate; } sch = css_create_sch(ccw_dev->devno, false, cbus->squash_mcss, &err); if (!sch) { goto out_mdevid_free; } sch->driver_data = cdev; sch->do_subchannel_work = do_subchannel_work_passthrough; ccw_dev->sch = sch; ret = css_sch_build_schib(sch, &cdev->hostid); if (ret) { error_setg_errno(&err, -ret, "%s: Failed to build initial schib", __func__); goto out_err; } ck->realize(ccw_dev, &err); if (err) { goto out_err; } css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid, parent->hotplugged, 1); return; out_err: css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL); ccw_dev->sch = NULL; g_free(sch); out_mdevid_free: g_free(cdev->mdevid); out_err_propagate: error_propagate(errp, err); }
1threat
send email with python after specific time : I want to make python script send email with attachment (txt) every 30 minutes here is my code it send mail with attachment without any problem import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email import encoders import os.path email = 'myaddress@gmail.com' password = 'password' send_to_email = 'sentoaddreess@gmail.com' subject = 'This is the subject' message = 'This is my message' file_location = 'C:\\Users\\You\\Desktop\\attach.txt' msg = MIMEMultipart() msg['From'] = email msg['To'] = send_to_email msg['Subject'] = subject msg.attach(MIMEText(message, 'plain')) filename = os.path.basename(file_location) attachment = open(file_location, "rb") part = MIMEBase('application', 'octet-stream') part.set_payload((attachment).read()) encoders.encode_base64(part) part.add_header('Content-Disposition', "attachment; filename= %s" % filename) msg.attach(part) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(email, password) text = msg.as_string() server.sendmail(email, send_to_email, text) server.quit() thanks
0debug
Syntaxe in spark and scala : <p>I'm an amateur in spark and scala, can anyone told me what this syntaxe do ? :</p> <pre><code>val encoded_props = props.map( _.split(" ")).map(t =&gt; Map((t(1),t(0).toLong))).reduce((a1,a2)=&gt;a1++a2) </code></pre> <p>Thanks</p>
0debug
static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret) { IDEState *s = opaque; int data_offset, n; if (ret < 0) { ide_atapi_io_error(s, ret); goto eot; } if (s->io_buffer_size > 0) { if (s->lba != -1) { if (s->cd_sector_size == 2352) { n = 1; cd_data_to_raw(s->io_buffer, s->lba); } else { n = s->io_buffer_size >> 11; } s->lba += n; } s->packet_transfer_size -= s->io_buffer_size; if (s->bus->dma->ops->rw_buf(s->bus->dma, 1) == 0) goto eot; } if (s->packet_transfer_size <= 0) { s->status = READY_STAT | SEEK_STAT; s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD; ide_set_irq(s->bus); goto eot; } s->io_buffer_index = 0; if (s->cd_sector_size == 2352) { n = 1; s->io_buffer_size = s->cd_sector_size; data_offset = 16; } else { n = s->packet_transfer_size >> 11; if (n > (IDE_DMA_BUF_SECTORS / 4)) n = (IDE_DMA_BUF_SECTORS / 4); s->io_buffer_size = n * 2048; data_offset = 0; } #ifdef DEBUG_AIO printf("aio_read_cd: lba=%u n=%d\n", s->lba, n); #endif s->bus->dma->iov.iov_base = (void *)(s->io_buffer + data_offset); s->bus->dma->iov.iov_len = n * 4 * 512; qemu_iovec_init_external(&s->bus->dma->qiov, &s->bus->dma->iov, 1); s->bus->dma->aiocb = blk_aio_readv(s->blk, (int64_t)s->lba << 2, &s->bus->dma->qiov, n * 4, ide_atapi_cmd_read_dma_cb, s); return; eot: block_acct_done(blk_get_stats(s->blk), &s->acct); ide_set_inactive(s, false); }
1threat
Single quotes, Double quotes as Python input values (using Python 3) : I used the following command and I got different values stored in the variable each time. name=input('enter your name:') enter your name:'' (two single quotes) name "''" (this is how it is displayed after I type 'Name' and press 'Enter') name=input('enter your name:') enter your name:"" (two double quotes) name '""' (this is how it is displayed after I type 'Name' and press 'Enter') name=input('enter your name:') enter your name:"'"' (double, single, double, single) name '"\'"\'' (this is how it is displayed after I type 'Name' and press 'Enter') name=input('enter your name:') enter your name:'"'" (single, double, single, double) name '\'"\'"' (this is how it is displayed after I type 'Name' and press 'Enter') 1. What does the \ indicate in the variable 'name' and why is it at all there?
0debug
static void s390_init(MachineState *machine) { ram_addr_t my_ram_size = machine->ram_size; MemoryRegion *sysmem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); int increment_size = 20; void *virtio_region; hwaddr virtio_region_len; hwaddr virtio_region_start; if (machine->ram_slots) { error_report("Memory hotplug not supported by the selected machine."); exit(EXIT_FAILURE); } while ((my_ram_size >> increment_size) > MAX_STORAGE_INCREMENTS) { increment_size++; } my_ram_size = my_ram_size >> increment_size << increment_size; ram_size = my_ram_size; s390_bus = s390_virtio_bus_init(&my_ram_size); s390_sclp_init(); s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline, machine->initrd_filename, ZIPL_FILENAME, false); s390_flic_init(); s390_virtio_register_hcalls(); memory_region_init_ram(ram, NULL, "s390.ram", my_ram_size, &error_abort); vmstate_register_ram_global(ram); memory_region_add_subregion(sysmem, 0, ram); virtio_region_len = my_ram_size - ram_size; virtio_region_start = ram_size; virtio_region = cpu_physical_memory_map(virtio_region_start, &virtio_region_len, true); memset(virtio_region, 0, virtio_region_len); cpu_physical_memory_unmap(virtio_region, virtio_region_len, 1, virtio_region_len); s390_skeys_init(); s390_init_cpus(machine->cpu_model); s390_create_virtio_net((BusState *)s390_bus, "virtio-net-s390"); register_savevm(NULL, "todclock", 0, 1, gtod_save, gtod_load, NULL); }
1threat
static int raw_has_zero_init(BlockDriverState *bs) { return bdrv_has_zero_init(bs->file->bs); }
1threat