problem
stringlengths
26
131k
labels
class label
2 classes
how to split a string in a list and use the output to compare with a dictionary? python : suppose my dictionary contains {'one'='1','two'='2'........'hundred' = '100'} and my list contains [['for 30']['for thirty']] i want to split the strings in the list as :- [for],[30] and [for],[thirty] then use the 'thirty' to use to compare with dictionary and get output as '30' import csv reader = csv.reader(open('dict.csv', 'r')) d = {} for row in reader: k, v = row d[k] = v with open('test_term.csv', 'rb') as f: reader = csv.reader(f) your_list = list(reader) im new to python!...help!!
0debug
void helper_ldl_raw(uint64_t t0, uint64_t t1) { ldl_raw(t1, t0); }
1threat
what are the use of "|" operator and "<<" operators in c : <p>PINS_DRV_SetPinsDirection(GPIO_PORT, ((1 &lt;&lt; LED1) | (1 &lt;&lt; LED2)));</p> <p>here "PINS_DRV_SetPinsDirection" is a function and i am passing arguments which are in (). what is the meaning of those arguments "(GPIO_PORT, ((1 &lt;&lt; LED1) | (1 &lt;&lt; LED2)))"???</p>
0debug
For loop Syntax in C strange form : <p>I'm analyzing a C program and i find this loop that i can't understand. There is no counter or limit or variable.</p> <pre><code>/* ioloop */ for (;;) { // statements } </code></pre> <p>is this an infinite loop ?</p>
0debug
Check if column value is in other columns in pandas : <p>I have the following dataframe in pandas</p> <pre><code> target A B C 0 cat bridge cat brush 1 brush dog cat shoe 2 bridge cat shoe bridge </code></pre> <p>How do I test whether <code>df.target</code> is in any of the columns <code>['A','B','C', etc.]</code>, where there are many columns to check?</p> <p>I have tried merging A,B and C into a string to use <code>df.abcstring.str.contains(df.target)</code> but this does not work.</p>
0debug
void phys_mem_set_alloc(void *(*alloc)(size_t)) { phys_mem_alloc = alloc; }
1threat
Lottery program in python from Y Daniel Liang : <p>I am new to python. The following is a practice programming exercise from Y Daniel Liang Python book Chapter 4. if the lottery number is 333, am getting perfect match for different user inputs such as 133, 233, 433, 533, 633, 733, 833, 933, I have no idea why.</p> <pre><code>#!/usr/bin/env python3 #import random lottery = 333 #random.randint(100, 999) guess = int(input("\nEnter a three-digit number: ")) print("\nThe Lottery Number is:", lottery) lottery_digit1 = lottery // 100 lottery %= 100 lottery_digit2 = lottery // 10 lottery_digit3 = lottery % 10 guess_digit1 = guess // 100 guess %= 100 guess_digit2 = guess // 10 guess_digit3 = guess % 10 if guess == lottery: print("Perfect Match: First Prize $10,000") elif (guess_digit1 == lottery_digit1 or guess_digit1 == lottery_digit2 or guess_digit1 == lottery_digit3) and \ (guess_digit2 == lottery_digit1 or guess_digit2 == lottery_digit2 or guess_digit2 == lottery_digit3) and \ (guess_digit3 == lottery_digit1 or guess_digit3 == lottery_digit2 or guess_digit3 == lottery_digit3): print("Matching All Digits: Second Prize $3,000") elif (guess_digit1 == lottery_digit1 or guess_digit1 == lottery_digit2 or guess_digit1 == lottery_digit3) or \ (guess_digit2 == lottery_digit1 or guess_digit2 == lottery_digit2 or guess_digit2 == lottery_digit3) or \ (guess_digit3 == lottery_digit1 or guess_digit3 == lottery_digit2 or guess_digit3 == lottery_digit3): print("Matching a Single Digit: Third Prize $1,000") else: print("Nice Try.") </code></pre>
0debug
Disable mouse wheel integration in Android emulator : <p>Is it possible to <strong>disable mouse wheel scrolling in AVD</strong>? Because I am using apple magic mouse and almost every mouse touch (not click - just touch) acts as click in Emulator and it drives me crazy.</p> <p>Same thing is happening even on BlueStacks emulator but I do not use it for now.</p> <p>Thanks</p>
0debug
static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, QEMUMachineInitArgs *args) { const char *cpu_model = args->cpu_model; unsigned int i; void *iommu, *espdma, *ledma, *nvram; qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS], espdma_irq, ledma_irq; qemu_irq esp_reset, dma_enable; qemu_irq fdc_tc; qemu_irq *cpu_halt; unsigned long kernel_size; DriveInfo *fd[MAX_FD]; FWCfgState *fw_cfg; unsigned int num_vsimms; if (!cpu_model) cpu_model = hwdef->default_cpu_model; for(i = 0; i < smp_cpus; i++) { cpu_devinit(cpu_model, i, hwdef->slavio_base, &cpu_irqs[i]); } for (i = smp_cpus; i < MAX_CPUS; i++) cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS); ram_init(0, args->ram_size, hwdef->max_mem); if (!hwdef->ecc_base) { empty_slot_init(args->ram_size, hwdef->max_mem - args->ram_size); } prom_init(hwdef->slavio_base, bios_name); slavio_intctl = slavio_intctl_init(hwdef->intctl_base, hwdef->intctl_base + 0x10000ULL, cpu_irqs); for (i = 0; i < 32; i++) { slavio_irq[i] = qdev_get_gpio_in(slavio_intctl, i); } for (i = 0; i < MAX_CPUS; i++) { slavio_cpu_irq[i] = qdev_get_gpio_in(slavio_intctl, 32 + i); } if (hwdef->idreg_base) { idreg_init(hwdef->idreg_base); } if (hwdef->afx_base) { afx_init(hwdef->afx_base); } iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version, slavio_irq[30]); if (hwdef->iommu_pad_base) { empty_slot_init(hwdef->iommu_pad_base,hwdef->iommu_pad_len); } espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[18], iommu, &espdma_irq, 0); ledma = sparc32_dma_init(hwdef->dma_base + 16ULL, slavio_irq[16], iommu, &ledma_irq, 1); if (graphic_depth != 8 && graphic_depth != 24) { fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth); exit (1); } num_vsimms = 0; if (num_vsimms == 0) { tcx_init(hwdef->tcx_base, 0x00100000, graphic_width, graphic_height, graphic_depth); } for (i = num_vsimms; i < MAX_VSIMMS; i++) { if (hwdef->vsimm[i].reg_base) { empty_slot_init(hwdef->vsimm[i].reg_base, 0x2000); } } if (hwdef->sx_base) { empty_slot_init(hwdef->sx_base, 0x2000); } lance_init(&nd_table[0], hwdef->le_base, ledma, ledma_irq); nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, 0x2000, 8); slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus); slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[14], display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1); escc_init(hwdef->serial_base, slavio_irq[15], slavio_irq[15], serial_hds[0], serial_hds[1], ESCC_CLOCK, 1); cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1); if (hwdef->apc_base) { apc_init(hwdef->apc_base, cpu_halt[0]); } if (hwdef->fd_base) { memset(fd, 0, sizeof(fd)); fd[0] = drive_get(IF_FLOPPY, 0, 0); sun4m_fdctrl_init(slavio_irq[22], hwdef->fd_base, fd, &fdc_tc); } else { fdc_tc = *qemu_allocate_irqs(dummy_fdc_tc, NULL, 1); } slavio_misc_init(hwdef->slavio_base, hwdef->aux1_base, hwdef->aux2_base, slavio_irq[30], fdc_tc); if (drive_get_max_bus(IF_SCSI) > 0) { fprintf(stderr, "qemu: too many SCSI bus\n"); exit(1); } esp_init(hwdef->esp_base, 2, espdma_memory_read, espdma_memory_write, espdma, espdma_irq, &esp_reset, &dma_enable); qdev_connect_gpio_out(espdma, 0, esp_reset); qdev_connect_gpio_out(espdma, 1, dma_enable); if (hwdef->cs_base) { sysbus_create_simple("SUNW,CS4231", hwdef->cs_base, slavio_irq[5]); } if (hwdef->dbri_base) { empty_slot_init(hwdef->dbri_base+0x1000, 0x30); empty_slot_init(hwdef->dbri_base+0x10000, 0x100); } if (hwdef->bpp_base) { empty_slot_init(hwdef->bpp_base, 0x20); } kernel_size = sun4m_load_kernel(args->kernel_filename, args->initrd_filename, args->ram_size); nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, args->kernel_cmdline, args->boot_device, args->ram_size, kernel_size, graphic_width, graphic_height, graphic_depth, hwdef->nvram_machine_id, "Sun4m"); if (hwdef->ecc_base) ecc_init(hwdef->ecc_base, slavio_irq[28], hwdef->ecc_version); fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id); fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth); fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_HEIGHT, graphic_height); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); if (args->kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR); pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, args->kernel_cmdline); fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, args->kernel_cmdline); fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(args->kernel_cmdline) + 1); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0); } fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, args->boot_device[0]); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); }
1threat
HTML special character (& symbol) not rendering in React component : <p>Consider this react code:</p> <pre><code>subTopicOptions = curSubTopics.map((topic) =&gt; { return ( &lt;option value={topic.id}&gt;{topic.name}&lt;/option&gt; ) }); </code></pre> <p>The <code>topic.name</code> output <code>Environment &amp;amp; Forest</code> value from rest API to display.</p> <p>How can I display <code>Environment &amp; Forest</code> in the select field?</p>
0debug
How to use Alamofires ServerTrustPolicy.disableEvaluation in swift 5 alamofire 5.0.3 : <p>in alamofire 4 I used this code to disable sever evaluation:</p> <pre><code>private var Manager : Alamofire.Session = { // Create the server trust policies let serverTrustPolicies: [String: ServerTrustPolicy] = ["serverurl.com": .disableEvaluation] // Create custom manager let configuration = URLSessionConfiguration.default configuration.httpAdditionalHeaders = Alamofire.Session.defaultHTTPHeaders let man = Alamofire.Session( configuration: URLSessionConfiguration.default, serverTrustPolicyManager: ServerTrustManager(policies: serverTrustPolicies) ) return man }() </code></pre> <p>but is not working anymore in alamofire 5 with swift 5 xcode 10.2, I got this errors.</p> <blockquote> <p>Use of undeclared type 'ServerTrustPolicy' Type 'Session' has no member 'defaultHTTPHeaders'</p> </blockquote> <p>but I cant find a new way to make this work with alamofire 5.</p>
0debug
static void xhci_process_commands(XHCIState *xhci) { XHCITRB trb; TRBType type; XHCIEvent event = {ER_COMMAND_COMPLETE, CC_SUCCESS}; dma_addr_t addr; unsigned int i, slotid = 0; DPRINTF("xhci_process_commands()\n"); if (!xhci_running(xhci)) { DPRINTF("xhci_process_commands() called while xHC stopped or paused\n"); return; } xhci->crcr_low |= CRCR_CRR; while ((type = xhci_ring_fetch(xhci, &xhci->cmd_ring, &trb, &addr))) { event.ptr = addr; switch (type) { case CR_ENABLE_SLOT: for (i = 0; i < xhci->numslots; i++) { if (!xhci->slots[i].enabled) { break; } } if (i >= xhci->numslots) { DPRINTF("xhci: no device slots available\n"); event.ccode = CC_NO_SLOTS_ERROR; } else { slotid = i+1; event.ccode = xhci_enable_slot(xhci, slotid); } break; case CR_DISABLE_SLOT: slotid = xhci_get_slot(xhci, &event, &trb); if (slotid) { event.ccode = xhci_disable_slot(xhci, slotid); } break; case CR_ADDRESS_DEVICE: slotid = xhci_get_slot(xhci, &event, &trb); if (slotid) { event.ccode = xhci_address_slot(xhci, slotid, trb.parameter, trb.control & TRB_CR_BSR); } break; case CR_CONFIGURE_ENDPOINT: slotid = xhci_get_slot(xhci, &event, &trb); if (slotid) { event.ccode = xhci_configure_slot(xhci, slotid, trb.parameter, trb.control & TRB_CR_DC); } break; case CR_EVALUATE_CONTEXT: slotid = xhci_get_slot(xhci, &event, &trb); if (slotid) { event.ccode = xhci_evaluate_slot(xhci, slotid, trb.parameter); } break; case CR_STOP_ENDPOINT: slotid = xhci_get_slot(xhci, &event, &trb); if (slotid) { unsigned int epid = (trb.control >> TRB_CR_EPID_SHIFT) & TRB_CR_EPID_MASK; event.ccode = xhci_stop_ep(xhci, slotid, epid); } break; case CR_RESET_ENDPOINT: slotid = xhci_get_slot(xhci, &event, &trb); if (slotid) { unsigned int epid = (trb.control >> TRB_CR_EPID_SHIFT) & TRB_CR_EPID_MASK; event.ccode = xhci_reset_ep(xhci, slotid, epid); } break; case CR_SET_TR_DEQUEUE: slotid = xhci_get_slot(xhci, &event, &trb); if (slotid) { unsigned int epid = (trb.control >> TRB_CR_EPID_SHIFT) & TRB_CR_EPID_MASK; unsigned int streamid = (trb.status >> 16) & 0xffff; event.ccode = xhci_set_ep_dequeue(xhci, slotid, epid, streamid, trb.parameter); } break; case CR_RESET_DEVICE: slotid = xhci_get_slot(xhci, &event, &trb); if (slotid) { event.ccode = xhci_reset_slot(xhci, slotid); } break; case CR_GET_PORT_BANDWIDTH: event.ccode = xhci_get_port_bandwidth(xhci, trb.parameter); break; case CR_VENDOR_VIA_CHALLENGE_RESPONSE: xhci_via_challenge(xhci, trb.parameter); break; case CR_VENDOR_NEC_FIRMWARE_REVISION: event.type = 48; event.length = 0x3025; break; case CR_VENDOR_NEC_CHALLENGE_RESPONSE: { uint32_t chi = trb.parameter >> 32; uint32_t clo = trb.parameter; uint32_t val = xhci_nec_challenge(chi, clo); event.length = val & 0xFFFF; event.epid = val >> 16; slotid = val >> 24; event.type = 48; } break; default: trace_usb_xhci_unimplemented("command", type); event.ccode = CC_TRB_ERROR; break; } event.slotid = slotid; xhci_event(xhci, &event, 0); } }
1threat
def round_and_sum(list1): lenght=len(list1) round_and_sum=sum(list(map(round,list1))* lenght) return round_and_sum
0debug
from itertools import groupby def pack_consecutive_duplicates(list1): return [list(group) for key, group in groupby(list1)]
0debug
static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) { MpegEncContext * const s = &h->s; const int mb_xy= mb_x + mb_y*s->mb_stride; const int mb_type = s->current_picture.mb_type[mb_xy]; const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4; int first_vertical_edge_done = 0; int dir; static const int ref2frm[34] = {-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; if(!FRAME_MBAFF){ int qp_thresh = 15 - h->slice_alpha_c0_offset - FFMAX(0, h->pps.chroma_qp_index_offset); int qp = s->current_picture.qscale_table[mb_xy]; if(qp <= qp_thresh && (mb_x == 0 || ((qp + s->current_picture.qscale_table[mb_xy-1] + 1)>>1) <= qp_thresh) && (mb_y == 0 || ((qp + s->current_picture.qscale_table[h->top_mb_xy] + 1)>>1) <= qp_thresh)){ return; } } if (FRAME_MBAFF && h->slice_table[mb_xy-1] != 255 && (IS_INTERLACED(mb_type) != IS_INTERLACED(s->current_picture.mb_type[mb_xy-1])) && (h->deblocking_filter!=2 || h->slice_table[mb_xy-1] == h->slice_table[mb_xy])) { const int pair_xy = mb_x + (mb_y&~1)*s->mb_stride; const int left_mb_xy[2] = { pair_xy-1, pair_xy-1+s->mb_stride }; int16_t bS[8]; int qp[2]; int chroma_qp[2]; int mb_qp, mbn0_qp, mbn1_qp; int i; first_vertical_edge_done = 1; if( IS_INTRA(mb_type) ) bS[0] = bS[1] = bS[2] = bS[3] = bS[4] = bS[5] = bS[6] = bS[7] = 4; else { for( i = 0; i < 8; i++ ) { int mbn_xy = MB_FIELD ? left_mb_xy[i>>2] : left_mb_xy[i&1]; if( IS_INTRA( s->current_picture.mb_type[mbn_xy] ) ) bS[i] = 4; else if( h->non_zero_count_cache[12+8*(i>>1)] != 0 || h->non_zero_count[mbn_xy][MB_FIELD ? i&3 : (i>>2)+(mb_y&1)*2] ) bS[i] = 2; else bS[i] = 1; } } mb_qp = s->current_picture.qscale_table[mb_xy]; mbn0_qp = s->current_picture.qscale_table[left_mb_xy[0]]; mbn1_qp = s->current_picture.qscale_table[left_mb_xy[1]]; qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1; chroma_qp[0] = ( get_chroma_qp( h, mb_qp ) + get_chroma_qp( h, mbn0_qp ) + 1 ) >> 1; qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1; chroma_qp[1] = ( get_chroma_qp( h, mb_qp ) + get_chroma_qp( h, mbn1_qp ) + 1 ) >> 1; tprintf(s->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPc:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], chroma_qp[0], chroma_qp[1], linesize, uvlinesize); { int i; for (i = 0; i < 8; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } filter_mb_mbaff_edgev ( h, &img_y [0], linesize, bS, qp ); filter_mb_mbaff_edgecv( h, &img_cb[0], uvlinesize, bS, chroma_qp ); filter_mb_mbaff_edgecv( h, &img_cr[0], uvlinesize, bS, chroma_qp ); } for( dir = 0; dir < 2; dir++ ) { int edge; const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy; const int mbm_type = s->current_picture.mb_type[mbm_xy]; int start = h->slice_table[mbm_xy] == 255 ? 1 : 0; const int edges = (mb_type & (MB_TYPE_16x16|MB_TYPE_SKIP)) == (MB_TYPE_16x16|MB_TYPE_SKIP) ? 1 : 4; const int mask_edge = (mb_type & (MB_TYPE_16x16 | (MB_TYPE_16x8 << dir))) ? 3 : (mb_type & (MB_TYPE_8x16 >> dir)) ? 1 : 0; const int mask_par0 = mb_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)); if (first_vertical_edge_done) { start = 1; first_vertical_edge_done = 0; } if (h->deblocking_filter==2 && h->slice_table[mbm_xy] != h->slice_table[mb_xy]) start = 1; if (FRAME_MBAFF && (dir == 1) && ((mb_y&1) == 0) && start == 0 && !IS_INTERLACED(mb_type) && IS_INTERLACED(mbm_type) ) { static const int nnz_idx[4] = {4,5,6,3}; unsigned int tmp_linesize = 2 * linesize; unsigned int tmp_uvlinesize = 2 * uvlinesize; int mbn_xy = mb_xy - 2 * s->mb_stride; int qp, chroma_qp; int i, j; int16_t bS[4]; for(j=0; j<2; j++, mbn_xy += s->mb_stride){ if( IS_INTRA(mb_type) || IS_INTRA(s->current_picture.mb_type[mbn_xy]) ) { bS[0] = bS[1] = bS[2] = bS[3] = 3; } else { const uint8_t *mbn_nnz = h->non_zero_count[mbn_xy]; for( i = 0; i < 4; i++ ) { if( h->non_zero_count_cache[scan8[0]+i] != 0 || mbn_nnz[nnz_idx[i]] != 0 ) bS[i] = 2; else bS[i] = 1; } } Do not use s->qscale as luma quantizer because it has not the same value in IPCM macroblocks. qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize); { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } filter_mb_edgeh( h, &img_y[j*linesize], tmp_linesize, bS, qp ); chroma_qp = ( h->chroma_qp + get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1; filter_mb_edgech( h, &img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp ); filter_mb_edgech( h, &img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp ); } start = 1; } for( edge = start; edge < edges; edge++ ) { const int mbn_xy = edge > 0 ? mb_xy : mbm_xy; const int mbn_type = s->current_picture.mb_type[mbn_xy]; int16_t bS[4]; int qp; if( (edge&1) && IS_8x8DCT(mb_type) ) continue; if( IS_INTRA(mb_type) || IS_INTRA(mbn_type) ) { int value; if (edge == 0) { if ( (!IS_INTERLACED(mb_type) && !IS_INTERLACED(mbm_type)) || ((FRAME_MBAFF || (s->picture_structure != PICT_FRAME)) && (dir == 0)) ) { value = 4; } else { value = 3; } } else { value = 3; } bS[0] = bS[1] = bS[2] = bS[3] = value; } else { int i, l; int mv_done; if( edge & mask_edge ) { bS[0] = bS[1] = bS[2] = bS[3] = 0; mv_done = 1; } else if( FRAME_MBAFF && IS_INTERLACED(mb_type ^ mbn_type)) { bS[0] = bS[1] = bS[2] = bS[3] = 1; mv_done = 1; } else if( mask_par0 && (edge || (mbn_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)))) ) { int b_idx= 8 + 4 + edge * (dir ? 8:1); int bn_idx= b_idx - (dir ? 8:1); int v = 0; for( l = 0; !v && l < 1 + (h->slice_type == B_TYPE); l++ ) { v |= ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] || FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 || FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit; } bS[0] = bS[1] = bS[2] = bS[3] = v; mv_done = 1; } else mv_done = 0; for( i = 0; i < 4; i++ ) { int x = dir == 0 ? edge : i; int y = dir == 0 ? i : edge; int b_idx= 8 + 4 + x + 8*y; int bn_idx= b_idx - (dir ? 8:1); if( h->non_zero_count_cache[b_idx] != 0 || h->non_zero_count_cache[bn_idx] != 0 ) { bS[i] = 2; } else if(!mv_done) { bS[i] = 0; for( l = 0; l < 1 + (h->slice_type == B_TYPE); l++ ) { if( ref2frm[h->ref_cache[l][b_idx]+2] != ref2frm[h->ref_cache[l][bn_idx]+2] || FFABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 || FFABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= mvy_limit ) { bS[i] = 1; break; } } } } if(bS[0]+bS[1]+bS[2]+bS[3] == 0) continue; } Do not use s->qscale as luma quantizer because it has not the same value in IPCM macroblocks. qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp, s->current_picture.qscale_table[mbn_xy]); tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize); { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); } if( dir == 0 ) { filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp ); if( (edge&1) == 0 ) { int chroma_qp = ( h->chroma_qp + get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1; filter_mb_edgecv( h, &img_cb[2*edge], uvlinesize, bS, chroma_qp ); filter_mb_edgecv( h, &img_cr[2*edge], uvlinesize, bS, chroma_qp ); } } else { filter_mb_edgeh( h, &img_y[4*edge*linesize], linesize, bS, qp ); if( (edge&1) == 0 ) { int chroma_qp = ( h->chroma_qp + get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1; filter_mb_edgech( h, &img_cb[2*edge*uvlinesize], uvlinesize, bS, chroma_qp ); filter_mb_edgech( h, &img_cr[2*edge*uvlinesize], uvlinesize, bS, chroma_qp ); } } } } }
1threat
static int dma_buf_rw(BMDMAState *bm, int is_write) { IDEState *s = bmdma_active_if(bm); struct { uint32_t addr; uint32_t size; } prd; int l, len; for(;;) { l = s->io_buffer_size - s->io_buffer_index; if (l <= 0) break; if (bm->cur_prd_len == 0) { if (bm->cur_prd_last || (bm->cur_addr - bm->addr) >= 4096) return 0; cpu_physical_memory_read(bm->cur_addr, (uint8_t *)&prd, 8); bm->cur_addr += 8; prd.addr = le32_to_cpu(prd.addr); prd.size = le32_to_cpu(prd.size); len = prd.size & 0xfffe; if (len == 0) len = 0x10000; bm->cur_prd_len = len; bm->cur_prd_addr = prd.addr; bm->cur_prd_last = (prd.size & 0x80000000); } if (l > bm->cur_prd_len) l = bm->cur_prd_len; if (l > 0) { if (is_write) { cpu_physical_memory_write(bm->cur_prd_addr, s->io_buffer + s->io_buffer_index, l); } else { cpu_physical_memory_read(bm->cur_prd_addr, s->io_buffer + s->io_buffer_index, l); } bm->cur_prd_addr += l; bm->cur_prd_len -= l; s->io_buffer_index += l; } } return 1; }
1threat
int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb) { MpegEncContext *s = &ctx->m; unsigned startcode, v; int ret; int vol = 0; align_get_bits(gb); if (s->codec_tag == AV_RL32("WV1F") && show_bits(gb, 24) == 0x575630) { skip_bits(gb, 24); if (get_bits(gb, 8) == 0xF0) goto end; startcode = 0xff; for (;;) { if (get_bits_count(gb) >= gb->size_in_bits) { if (gb->size_in_bits == 8 && (ctx->divx_version >= 0 || ctx->xvid_build >= 0) || s->codec_tag == AV_RL32("QMP4")) { av_log(s->avctx, AV_LOG_VERBOSE, "frame skip %d\n", gb->size_in_bits); return FRAME_SKIPPED; } else return -1; v = get_bits(gb, 8); startcode = ((startcode << 8) | v) & 0xffffffff; if ((startcode & 0xFFFFFF00) != 0x100) continue; if (s->avctx->debug & FF_DEBUG_STARTCODE) { av_log(s->avctx, AV_LOG_DEBUG, "startcode: %3X ", startcode); if (startcode <= 0x11F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Start"); else if (startcode <= 0x12F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Layer Start"); else if (startcode <= 0x13F) av_log(s->avctx, AV_LOG_DEBUG, "Reserved"); else if (startcode <= 0x15F) av_log(s->avctx, AV_LOG_DEBUG, "FGS bp start"); else if (startcode <= 0x1AF) av_log(s->avctx, AV_LOG_DEBUG, "Reserved"); else if (startcode == 0x1B0) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq Start"); else if (startcode == 0x1B1) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq End"); else if (startcode == 0x1B2) av_log(s->avctx, AV_LOG_DEBUG, "User Data"); else if (startcode == 0x1B3) av_log(s->avctx, AV_LOG_DEBUG, "Group of VOP start"); else if (startcode == 0x1B4) av_log(s->avctx, AV_LOG_DEBUG, "Video Session Error"); else if (startcode == 0x1B5) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Start"); else if (startcode == 0x1B6) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Plane start"); else if (startcode == 0x1B7) av_log(s->avctx, AV_LOG_DEBUG, "slice start"); else if (startcode == 0x1B8) av_log(s->avctx, AV_LOG_DEBUG, "extension start"); else if (startcode == 0x1B9) av_log(s->avctx, AV_LOG_DEBUG, "fgs start"); else if (startcode == 0x1BA) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object start"); else if (startcode == 0x1BB) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object Plane start"); else if (startcode == 0x1BC) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object start"); else if (startcode == 0x1BD) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object Plane start"); else if (startcode == 0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Texture Object start"); else if (startcode == 0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Texture Spatial Layer start"); else if (startcode == 0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Texture SNR Layer start"); else if (startcode == 0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Texture Tile start"); else if (startcode == 0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Texture Shape Layer start"); else if (startcode == 0x1C3) av_log(s->avctx, AV_LOG_DEBUG, "stuffing start"); else if (startcode <= 0x1C5) av_log(s->avctx, AV_LOG_DEBUG, "reserved"); else if (startcode <= 0x1FF) av_log(s->avctx, AV_LOG_DEBUG, "System start"); av_log(s->avctx, AV_LOG_DEBUG, " at %d\n", get_bits_count(gb)); if (startcode >= 0x120 && startcode <= 0x12F) { if ((ret = decode_vol_header(ctx, gb)) < 0) return ret; } else if (startcode == USER_DATA_STARTCODE) { decode_user_data(ctx, gb); } else if (startcode == GOP_STARTCODE) { mpeg4_decode_gop_header(s, gb); } else if (startcode == VOS_STARTCODE) { mpeg4_decode_profile_level(s, gb); } else if (startcode == VOP_STARTCODE) { break; align_get_bits(gb); startcode = 0xff; end: if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; s->avctx->has_b_frames = !s->low_delay; return decode_vop_header(ctx, gb);
1threat
static void* attribute_align_arg worker(void *v) { ThreadContext *c = v; int our_job = c->nb_jobs; int nb_threads = c->nb_threads; unsigned int last_execute = 0; int self_id; pthread_mutex_lock(&c->current_job_lock); self_id = c->current_job++; for (;;) { while (our_job >= c->nb_jobs) { if (c->current_job == nb_threads + c->nb_jobs) pthread_cond_signal(&c->last_job_cond); while (last_execute == c->current_execute && !c->done) pthread_cond_wait(&c->current_job_cond, &c->current_job_lock); last_execute = c->current_execute; our_job = self_id; if (c->done) { pthread_mutex_unlock(&c->current_job_lock); return NULL; } } pthread_mutex_unlock(&c->current_job_lock); c->rets[our_job % c->nb_rets] = c->func(c->ctx, c->arg, our_job, c->nb_jobs); pthread_mutex_lock(&c->current_job_lock); our_job = c->current_job++; } }
1threat
int main(int argc, char **argv){ int in_sample_rate, out_sample_rate, ch ,i, flush_count; uint64_t in_ch_layout, out_ch_layout; enum AVSampleFormat in_sample_fmt, out_sample_fmt; uint8_t array_in[SAMPLES*8*8]; uint8_t array_mid[SAMPLES*8*8*3]; uint8_t array_out[SAMPLES*8*8+100]; uint8_t *ain[SWR_CH_MAX]; uint8_t *aout[SWR_CH_MAX]; uint8_t *amid[SWR_CH_MAX]; int flush_i=0; int mode; int num_tests = 10000; uint32_t seed = 0; uint32_t rand_seed = 0; int remaining_tests[FF_ARRAY_ELEMS(rates) * FF_ARRAY_ELEMS(layouts) * FF_ARRAY_ELEMS(formats) * FF_ARRAY_ELEMS(layouts) * FF_ARRAY_ELEMS(formats)]; int max_tests = FF_ARRAY_ELEMS(remaining_tests); int test; int specific_test= -1; struct SwrContext * forw_ctx= NULL; struct SwrContext *backw_ctx= NULL; if (argc > 1) { if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { av_log(NULL, AV_LOG_INFO, "Usage: swresample-test [<num_tests>[ <test>]] \n" "num_tests Default is %d\n", num_tests); return 0; } num_tests = strtol(argv[1], NULL, 0); if(num_tests < 0) { num_tests = -num_tests; rand_seed = time(0); } if(num_tests<= 0 || num_tests>max_tests) num_tests = max_tests; if(argc > 2) { specific_test = strtol(argv[1], NULL, 0); } } for(i=0; i<max_tests; i++) remaining_tests[i] = i; for(test=0; test<num_tests; test++){ unsigned r; uint_rand(seed); r = (seed * (uint64_t)(max_tests - test)) >>32; FFSWAP(int, remaining_tests[r], remaining_tests[max_tests - test - 1]); } qsort(remaining_tests + max_tests - num_tests, num_tests, sizeof(remaining_tests[0]), (void*)cmp); in_sample_rate=16000; for(test=0; test<num_tests; test++){ char in_layout_string[256]; char out_layout_string[256]; unsigned vector= remaining_tests[max_tests - test - 1]; int in_ch_count; int out_count, mid_count, out_ch_count; in_ch_layout = layouts[vector % FF_ARRAY_ELEMS(layouts)]; vector /= FF_ARRAY_ELEMS(layouts); out_ch_layout = layouts[vector % FF_ARRAY_ELEMS(layouts)]; vector /= FF_ARRAY_ELEMS(layouts); in_sample_fmt = formats[vector % FF_ARRAY_ELEMS(formats)]; vector /= FF_ARRAY_ELEMS(formats); out_sample_fmt = formats[vector % FF_ARRAY_ELEMS(formats)]; vector /= FF_ARRAY_ELEMS(formats); out_sample_rate = rates [vector % FF_ARRAY_ELEMS(rates )]; vector /= FF_ARRAY_ELEMS(rates); av_assert0(!vector); if(specific_test == 0){ if(out_sample_rate != in_sample_rate || in_ch_layout != out_ch_layout) continue; } in_ch_count= av_get_channel_layout_nb_channels(in_ch_layout); out_ch_count= av_get_channel_layout_nb_channels(out_ch_layout); av_get_channel_layout_string( in_layout_string, sizeof( in_layout_string), in_ch_count, in_ch_layout); av_get_channel_layout_string(out_layout_string, sizeof(out_layout_string), out_ch_count, out_ch_layout); fprintf(stderr, "TEST: %s->%s, rate:%5d->%5d, fmt:%s->%s\n", in_layout_string, out_layout_string, in_sample_rate, out_sample_rate, av_get_sample_fmt_name(in_sample_fmt), av_get_sample_fmt_name(out_sample_fmt)); forw_ctx = swr_alloc_set_opts(forw_ctx, out_ch_layout, out_sample_fmt, out_sample_rate, in_ch_layout, in_sample_fmt, in_sample_rate, 0, 0); backw_ctx = swr_alloc_set_opts(backw_ctx, in_ch_layout, in_sample_fmt, in_sample_rate, out_ch_layout, out_sample_fmt, out_sample_rate, 0, 0); if(swr_init( forw_ctx) < 0) fprintf(stderr, "swr_init(->) failed\n"); if(swr_init(backw_ctx) < 0) fprintf(stderr, "swr_init(<-) failed\n"); if(!forw_ctx) fprintf(stderr, "Failed to init forw_cts\n"); if(!backw_ctx) fprintf(stderr, "Failed to init backw_ctx\n"); setup_array(ain , array_in , in_sample_fmt, SAMPLES); setup_array(amid, array_mid, out_sample_fmt, 3*SAMPLES); setup_array(aout, array_out, in_sample_fmt , SAMPLES); #if 0 for(ch=0; ch<in_ch_count; ch++){ for(i=0; i<SAMPLES; i++) set(ain, ch, i, in_ch_count, in_sample_fmt, sin(i*i*3/SAMPLES)); } #else audiogen(ain, in_sample_fmt, in_ch_count, SAMPLES/6+1, SAMPLES); #endif mode = uint_rand(rand_seed) % 3; if(mode==0 ) { mid_count= swr_convert(forw_ctx, amid, 3*SAMPLES, (const uint8_t **)ain, SAMPLES); } else if(mode==1){ mid_count= swr_convert(forw_ctx, amid, 0, (const uint8_t **)ain, SAMPLES); mid_count+=swr_convert(forw_ctx, amid, 3*SAMPLES, (const uint8_t **)ain, 0); } else { int tmp_count; mid_count= swr_convert(forw_ctx, amid, 0, (const uint8_t **)ain, 1); av_assert0(mid_count==0); shift(ain, 1, in_ch_count, in_sample_fmt); mid_count+=swr_convert(forw_ctx, amid, 3*SAMPLES, (const uint8_t **)ain, 0); shift(amid, mid_count, out_ch_count, out_sample_fmt); tmp_count = mid_count; mid_count+=swr_convert(forw_ctx, amid, 2, (const uint8_t **)ain, 2); shift(amid, mid_count-tmp_count, out_ch_count, out_sample_fmt); tmp_count = mid_count; shift(ain, 2, in_ch_count, in_sample_fmt); mid_count+=swr_convert(forw_ctx, amid, 1, (const uint8_t **)ain, SAMPLES-3); shift(amid, mid_count-tmp_count, out_ch_count, out_sample_fmt); tmp_count = mid_count; shift(ain, -3, in_ch_count, in_sample_fmt); mid_count+=swr_convert(forw_ctx, amid, 3*SAMPLES, (const uint8_t **)ain, 0); shift(amid, -tmp_count, out_ch_count, out_sample_fmt); } out_count= swr_convert(backw_ctx,aout, SAMPLES, (const uint8_t **)amid, mid_count); for(ch=0; ch<in_ch_count; ch++){ double sse, maxdiff=0; double sum_a= 0; double sum_b= 0; double sum_aa= 0; double sum_bb= 0; double sum_ab= 0; for(i=0; i<out_count; i++){ double a= get(ain , ch, i, in_ch_count, in_sample_fmt); double b= get(aout, ch, i, in_ch_count, in_sample_fmt); sum_a += a; sum_b += b; sum_aa+= a*a; sum_bb+= b*b; sum_ab+= a*b; maxdiff= FFMAX(maxdiff, FFABS(a-b)); } sse= sum_aa + sum_bb - 2*sum_ab; if(sse < 0 && sse > -0.00001) sse=0; fprintf(stderr, "[e:%f c:%f max:%f] len:%5d\n", sqrt(sse/out_count), sum_ab/(sqrt(sum_aa*sum_bb)), maxdiff, out_count); } flush_i++; flush_i%=21; flush_count = swr_convert(backw_ctx,aout, flush_i, 0, 0); shift(aout, flush_i, in_ch_count, in_sample_fmt); flush_count+= swr_convert(backw_ctx,aout, SAMPLES-flush_i, 0, 0); shift(aout, -flush_i, in_ch_count, in_sample_fmt); if(flush_count){ for(ch=0; ch<in_ch_count; ch++){ double sse, maxdiff=0; double sum_a= 0; double sum_b= 0; double sum_aa= 0; double sum_bb= 0; double sum_ab= 0; for(i=0; i<flush_count; i++){ double a= get(ain , ch, i+out_count, in_ch_count, in_sample_fmt); double b= get(aout, ch, i, in_ch_count, in_sample_fmt); sum_a += a; sum_b += b; sum_aa+= a*a; sum_bb+= b*b; sum_ab+= a*b; maxdiff= FFMAX(maxdiff, FFABS(a-b)); } sse= sum_aa + sum_bb - 2*sum_ab; if(sse < 0 && sse > -0.00001) sse=0; fprintf(stderr, "[e:%f c:%f max:%f] len:%5d F:%3d\n", sqrt(sse/flush_count), sum_ab/(sqrt(sum_aa*sum_bb)), maxdiff, flush_count, flush_i); } } fprintf(stderr, "\n"); } return 0; }
1threat
void cris_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) { unsigned int i; (*cpu_fprintf)(f, "Available CPUs:\n"); for (i = 0; i < ARRAY_SIZE(cris_cores); i++) { (*cpu_fprintf)(f, " %s\n", cris_cores[i].name); } }
1threat
why do we need np.squeeze()? : <p>Very often, arrays are squeezed with <code>np.squeeze()</code>. In the documentation, it says </p> <blockquote> <p>Remove single-dimensional entries from the shape of a.</p> </blockquote> <p>However I'm still wondering: Why <em>are</em> zero and nondimensional entries in the shape of a? Or to put it differently: Why do both <code>a.shape = (2,1)</code> <em>and</em> <code>(2,)</code> exist?</p>
0debug
Adding prefix path to static files in Angular using angular-cli : <p>I have an existing django project where I am serving static files over /static/ path. I am migrating a part of the application to angular2, to be specific mobile version of the site. </p> <p>Adding <code>&lt;base href="/"&gt;</code> to index.html loads static files www.example.com/main.js gets 404 here. Adding <code>&lt;base href="/static/"&gt;</code> to index.html loads static files correctly, but when the application bootstraps, it changes the url to /static/ (i am using routers), although my url should be /order/.</p> <p>is there a way of using base href as / but adding prefix to script and style files using angular-cli</p> <p>using version <code>ng --version</code></p> <pre><code>@angular/cli: 1.0.0-rc.0 node: 6.9.1 os: win32 x64 @angular/common: 2.4.9 @angular/compiler: 2.4.9 @angular/core: 2.4.9 @angular/forms: 2.4.9 @angular/http: 2.4.9 @angular/platform-browser: 2.4.9 @angular/platform-browser-dynamic: 2.4.9 @angular/router: 3.4.9 @angular/cli: 1.0.0-rc.0 @angular/compiler-cli: 2.4.9 </code></pre>
0debug
Replace some Characters in a String : <p>I have this String </p> <pre><code>link="https%3a%2f%2fen.wikipedia.org%2fwiki%2fHuawei/" </code></pre> <p>which shoud be like this:</p> <pre><code>link="https://en.wikipedia.org/wiki/Huawei/" </code></pre> <p>I wrote this code:</p> <pre><code>link.Replace("%2f", "/"); link.Replace("%3a", ":"); </code></pre> <p>But it did not work.</p>
0debug
Golang variable declaration syntax meaning : <p>I am going through some Golang code and came through this block of code, I am not able to comprehend it. I can see that d1,d2,d3 are variables of type int. But what is the last string <code>json:"start"</code></p> <pre><code>type obj1 struct { d1 int `json:"start"` d2 int `json:"end"` d3 int `json:"retries"` } </code></pre>
0debug
Hello, i need jquery function for symbol counter in text box when click on button : i need jquery function for symbol counter in text box when click on button. I dont know how work this. <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title></title> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> </head> <body> <input type="text"id="id1"></input></div><br/><br/> <button onclick="#"id="id2"> Count Symbols</button> <p id="id1"></p> <script> $( document.#id1 ) .click(function() { $( document.#id1 ).append( $( "#id2" ) ); var n = $( "#id2" ).length; $( ).text( "There are " + n + " symbols."); }) </script> </body> </html> <!-- end snippet -->
0debug
ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs) { BlockDriver *drv = bs->drv; if (drv && drv->bdrv_get_specific_info) { return drv->bdrv_get_specific_info(bs); } return NULL; }
1threat
static void qemu_aio_wait_all(void) { while (aio_poll(ctx, true)) { } }
1threat
Can I replace an existing method of an object in Python? : <p><strong>Q:</strong> Is there a way to alter a method of an existing object in Python (3.6)? (By "method" I mean a function that is passed <code>self</code> as an argument.)</p> <hr> <p><strong>Example</strong></p> <p>Let's say I have a class <code>Person</code> having some very useful method <code>SayHi()</code>:</p> <pre><code>class Person(object): Cash = 100 def HasGoodMood(self): return self.Cash &gt; 10 def SayHi(self): if self.HasGoodMood(): print('Hello!') else: print('Hmpf.') &gt;&gt;&gt; joe = Person() &gt;&gt;&gt; joe.SayHi() Hello! </code></pre> <p>As you can see, the response of the person depends on their current mood computed by the method <code>HasGoodMood()</code>. A default person has good mood whenever they have more than 10$ cash on them.</p> <p>I can easily create a person who does not care about the money and is happy all the time:</p> <pre><code>&gt;&gt;&gt; joe.HasGoodMood = lambda: True &gt;&gt;&gt; joe.SayHi() Hello! &gt;&gt;&gt; joe.Cash = 0 &gt;&gt;&gt; joe.SayHi() Hello! </code></pre> <p>Cool. Notice how Python knows that when using the original implementation of <code>HasGoodMood</code>, it passes silently <code>self</code> as the first argument, but if I change it to <code>lambda: True</code>, it calls the function with no arguments. The problem is: What if I want to change the default <code>HasGoodMood</code> for another function which would also accept <code>self</code> as a parameter?</p> <p>Let's continue our example: what if I want to create a greedy <code>Person</code> who is only happy if they have more than 100$ on them? I would like to do something like:</p> <pre><code>&gt;&gt;&gt; greedy_jack = Person() &gt;&gt;&gt; greedy_jack.HasGoodMood = lambda self: self.Cash &gt; 100 TypeError: &lt;lambda&gt;() missing 1 required positional argument: 'self' </code></pre> <p>Unfortunately, this does not work. Is there some other way to change a method?</p> <hr> <p><strong>Disclaimer:</strong> The above example is just for demonstration purposes. I know that I could use inheritance or keep a cash threshold as a property of the <code>Person</code>. But that is not the point of the question.</p>
0debug
getting top 2 rows in each group without row number in sql : i am looking a simple code to get result of 2 rows with latest invoice date in each group . Although this task can be accomplished by a ror_number that you can see in below code , but i need alternative of this with minimum complexity. Code :- create table #tt ( id int, invoiceDT datetime ) insert into #tt values(1,'01-01-2016 00:12'),(1,'01-02-2016 06:16'),(1,'01-01-2016 00:16') ,(2,'01-01-2016 01:12'),(2,'04-02-2016 06:16'),(2,'01-06-2016 00:16') select * from ( SELECT id,invoiceDT,row_number() over(partition by id order by invoiceDT desc) as rownum FROM #tt )tmp where rownum <=2 I need same result that is returned by above query Please suggest alternative.
0debug
Jython vs Python3 vs Cython efficiency : <p>I see a lot of questions and answers related to python optimization but because python 3.x is advancing so rapidly, I am a bit confused as to which is the best option where. </p> <p>I'm wondering if I'm misreading <a href="https://pybenchmarks.org/u64q/jython.php" rel="nofollow noreferrer">these benchmarks</a> which seem to suggest that the python3 interpreter outperforms jython and I'm wondering where and when alternative interpreters/compilers should and should not be used. </p> <p>I have been running a lot of programs that are intense memory/cpu hogs and it's beginning to become more necessary to look at these tools especially with 3.6 being a lot greedier than 2.7 as far as I can tell.</p>
0debug
Endless install in android studio : <p>In the recent times I am considering to change my work title from "Android Developer" to "Endless install progress watcher".</p> <p>It has been happening ever more often that when I try to run my applications or tests Android Studio stucks in endless installing progress like the image below:</p> <p><a href="https://i.stack.imgur.com/HRbiz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HRbiz.png" alt="enter image description here"></a></p> <p>This progress remains like forever. It used to be that if I disconnect my device and connect again the next attempt will succeed. Now it is often the case that I need multiple re-connects until I am able to run.</p> <p>The speculation is the problem is due to ADB hanging and loosing connection somehow, but I do not know how to overcome that.</p> <p>My configuration is: - Ubuntu Linux, but colleagues experience the same on Mac OS e.g. - Android Studio 3.5 - device is Nexus 5X, but the same happens on many other devices </p>
0debug
Write a query to find the rental return date for customers Bill? I want find out the customer "Bill" Car return date : [enter image description here][1] [1]: http://i.stack.imgur.com/RBEdN.jpg Write a query to find the rental return date for customers Bill? I want find out the customer "Bill" Car return date
0debug
Getting a NullReferenceException when trying to compare to null : <p>first time posting on here and a bit of a noob in c#. Basically I'm creating a linkedlist and initializing it to null at the beginning of my class. When I'm ready to use it, I check to make sure that it's not equal to the string passed by the method. I immediately get a NullReferenceException, and i'm supposed to be comparing it to null. Any fixes?</p> <pre><code>private DoubleLinkedListCell&lt;DoubleLinkedListCell&lt;GamePiece&gt;&gt; _columns = null; public void FindColumn(string columnId) { bool right = true; while (_columns.Id != columnId) { if (_columns.Next == null) { right = false; } if (right) { Columns = Columns.Next; } else { Columns = Columns.Prev; } } } </code></pre>
0debug
static inline void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, long dstW, long chrDstW) { if (uDest) { YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, vDest, chrDstW + c->uv_off, c->uv_off) } if (CONFIG_SWSCALE_ALPHA && aDest) { YSCALEYUV2YV12X(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0) } YSCALEYUV2YV12X(LUM_MMX_FILTER_OFFSET, dest, dstW, 0) }
1threat
typescript return type of inherited class : <p>This is what I'm trying to do:</p> <pre><code>class Base{ clone(){ //return new instance of the inherited class } } class Derived extends Base{ } const d1=new Derived(); const d2=d2.clone; // I want d2 to be of type Derived </code></pre> <p>What should be the the return type of the clone method for d2 to be of type Derived?</p>
0debug
How to create jquery accordion out of this code : i am having problem to enable accordion on this code structure. I have tried the following code but it is not working. <li><?php echo get_field('faq_question_1');?> <span class="readLinkTag"><a class="click_acc" href="#">READ MORE <i class="fa fa-chevron-circle-down"></i></a></span></li> <div class="abc"><?php echo get_field('faq_question_1_content');?></div> var allPanels = $('.abc').hide(); $('.click_acc').click(function() { //alert("thanks"); allPanels.slideUp(); $(this).parent().next().slideDown(); return false; });
0debug
Charles proxy shows IP addresses instead of domain names : <p>Charles for me shows IP addresses instead of domain names. Has anyone else seen this problem. See the attached screenshot.</p> <p><a href="https://i.stack.imgur.com/PXG06.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PXG06.png" alt="Charles screenshot"></a></p>
0debug
F# functions vs C# "Func"tions : <p>So I ran across this tour of F#: <a href="https://docs.microsoft.com/en-us/dotnet/articles/fsharp/tour" rel="noreferrer">https://docs.microsoft.com/en-us/dotnet/articles/fsharp/tour</a></p> <p>... and boy howdy is F# interesting! The very beginning of the tour defined a sample function, which looks pretty straightforward:</p> <pre><code>/// You use 'let' to define a function. This one accepts an integer argument and returns an integer. /// Parentheses are optional for function arguments, except for when you use an explicit type annotation. let sampleFunction1 x = x*x + 3 </code></pre> <p>So this makes sense to me. It defines what the function is so if I were to pass some number into this thing, it squares it and adds 3 to that result, as seen by the next line in the tour:</p> <pre><code> /// Apply the function, naming the function return result using 'let'. /// The variable type is inferred from the function return type. let result1 = sampleFunction1 4573 </code></pre> <p>After giving this a few more minutes of thought, I came up with the conclusion that C# can do this too! I sure do love C# a whole lot. This is what the above would look like in C# as far as I can tell:</p> <pre><code> Func&lt;int, int&gt; sampleFunction1 = x =&gt; x*x + 3; var result = sampleFunction1(4573); </code></pre> <p>So my main question is, what is the difference between what I wrote in C# and what the F# tour showed me? Sub-questions are: Is the IL code any different even though it's the same CLR? What are a few reasons I would use F# over C#?</p>
0debug
static void exynos4210_mct_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { Exynos4210MCTState *s = (Exynos4210MCTState *)opaque; int index; int shift; int lt_i; uint64_t new_frc; uint32_t i; uint32_t old_val; #ifdef DEBUG_MCT static uint32_t icntb_max[2] = {0}; static uint32_t icntb_min[2] = {UINT32_MAX, UINT32_MAX}; static uint32_t tcntb_max[2] = {0}; static uint32_t tcntb_min[2] = {UINT32_MAX, UINT32_MAX}; #endif new_frc = s->g_timer.reg.cnt; switch (offset) { case MCT_CFG: s->reg_mct_cfg = value; exynos4210_mct_update_freq(s); break; case G_CNT_L: case G_CNT_U: if (offset == G_CNT_L) { DPRINTF("global timer write to reg.cntl %llx\n", value); new_frc = (s->g_timer.reg.cnt & (uint64_t)UINT32_MAX << 32) + value; s->g_timer.reg.cnt_wstat |= G_CNT_WSTAT_L; } if (offset == G_CNT_U) { DPRINTF("global timer write to reg.cntu %llx\n", value); new_frc = (s->g_timer.reg.cnt & UINT32_MAX) + ((uint64_t)value << 32); s->g_timer.reg.cnt_wstat |= G_CNT_WSTAT_U; } s->g_timer.reg.cnt = new_frc; exynos4210_gfrc_restart(s); break; case G_CNT_WSTAT: s->g_timer.reg.cnt_wstat &= ~(value); break; case G_COMP_L(0): case G_COMP_L(1): case G_COMP_L(2): case G_COMP_L(3): case G_COMP_U(0): case G_COMP_U(1): case G_COMP_U(2): case G_COMP_U(3): index = GET_G_COMP_IDX(offset); shift = 8 * (offset & 0x4); s->g_timer.reg.comp[index] = (s->g_timer.reg.comp[index] & (((uint64_t)UINT32_MAX << 32) >> shift)) + (value << shift); DPRINTF("comparator %d write 0x%llx val << %d\n", index, value, shift); if (offset&0x4) { s->g_timer.reg.wstat |= G_WSTAT_COMP_U(index); } else { s->g_timer.reg.wstat |= G_WSTAT_COMP_L(index); } exynos4210_gfrc_restart(s); break; case G_TCON: old_val = s->g_timer.reg.tcon; s->g_timer.reg.tcon = value; s->g_timer.reg.wstat |= G_WSTAT_TCON_WRITE; DPRINTF("global timer write to reg.g_tcon %llx\n", value); if ((value & G_TCON_TIMER_ENABLE) > (old_val & G_TCON_TIMER_ENABLE)) { exynos4210_gfrc_start(&s->g_timer); } if ((value & G_TCON_TIMER_ENABLE) < (old_val & G_TCON_TIMER_ENABLE)) { exynos4210_gfrc_stop(&s->g_timer); } for (i = 0; i < MCT_GT_CMP_NUM; i++) { if ((value & G_TCON_COMP_ENABLE(i)) != (old_val & G_TCON_COMP_ENABLE(i))) { exynos4210_gfrc_restart(s); } } break; case G_INT_CSTAT: s->g_timer.reg.int_cstat &= ~(value); for (i = 0; i < MCT_GT_CMP_NUM; i++) { if (value & G_INT_CSTAT_COMP(i)) { exynos4210_gcomp_lower_irq(&s->g_timer, i); } } break; case G_INT_ENB: for (i = 0; i < MCT_GT_CMP_NUM; i++) { if ((value & G_INT_ENABLE(i)) > (s->g_timer.reg.tcon & G_INT_ENABLE(i))) { if (s->g_timer.reg.int_cstat & G_INT_CSTAT_COMP(i)) { exynos4210_gcomp_raise_irq(&s->g_timer, i); } } if ((value & G_INT_ENABLE(i)) < (s->g_timer.reg.tcon & G_INT_ENABLE(i))) { exynos4210_gcomp_lower_irq(&s->g_timer, i); } } DPRINTF("global timer INT enable %llx\n", value); s->g_timer.reg.int_enb = value; break; case G_WSTAT: s->g_timer.reg.wstat &= ~(value); break; case G_COMP0_ADD_INCR: case G_COMP1_ADD_INCR: case G_COMP2_ADD_INCR: case G_COMP3_ADD_INCR: index = GET_G_COMP_ADD_INCR_IDX(offset); s->g_timer.reg.comp_add_incr[index] = value; s->g_timer.reg.wstat |= G_WSTAT_COMP_ADDINCR(index); break; case L0_TCON: case L1_TCON: lt_i = GET_L_TIMER_IDX(offset); old_val = s->l_timer[lt_i].reg.tcon; s->l_timer[lt_i].reg.wstat |= L_WSTAT_TCON_WRITE; s->l_timer[lt_i].reg.tcon = value; if ((value & L_TCON_TICK_START) < (old_val & L_TCON_TICK_START)) { DPRINTF("local timer[%d] stop cnt\n", lt_i); exynos4210_ltick_cnt_stop(&s->l_timer[lt_i].tick_timer); } if ((value & L_TCON_INT_START) < (old_val & L_TCON_INT_START)) { DPRINTF("local timer[%d] stop int\n", lt_i); exynos4210_ltick_int_stop(&s->l_timer[lt_i].tick_timer); } if ((value & L_TCON_TICK_START) > (old_val & L_TCON_TICK_START)) { DPRINTF("local timer[%d] start cnt\n", lt_i); exynos4210_ltick_cnt_start(&s->l_timer[lt_i].tick_timer); } if ((value & L_TCON_INT_START) > (old_val & L_TCON_INT_START)) { DPRINTF("local timer[%d] start int\n", lt_i); exynos4210_ltick_int_start(&s->l_timer[lt_i].tick_timer); } if ((value & L_TCON_FRC_START) > (s->l_timer[lt_i].reg.tcon & L_TCON_FRC_START)) { DPRINTF("local timer[%d] start frc\n", lt_i); exynos4210_lfrc_start(&s->l_timer[lt_i]); } if ((value & L_TCON_FRC_START) < (s->l_timer[lt_i].reg.tcon & L_TCON_FRC_START)) { DPRINTF("local timer[%d] stop frc\n", lt_i); exynos4210_lfrc_stop(&s->l_timer[lt_i]); } break; case L0_TCNTB: case L1_TCNTB: lt_i = GET_L_TIMER_IDX(offset); index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i); exynos4210_ltick_set_cntb(&s->l_timer[lt_i].tick_timer, value, s->l_timer[lt_i].tick_timer.icntb); s->l_timer[lt_i].reg.wstat |= L_WSTAT_TCNTB_WRITE; s->l_timer[lt_i].reg.cnt[L_REG_CNT_TCNTB] = value; #ifdef DEBUG_MCT if (tcntb_min[lt_i] > value) { tcntb_min[lt_i] = value; } if (tcntb_max[lt_i] < value) { tcntb_max[lt_i] = value; } DPRINTF("local timer[%d] TCNTB write %llx; max=%x, min=%x\n", lt_i, value, tcntb_max[lt_i], tcntb_min[lt_i]); #endif break; case L0_ICNTB: case L1_ICNTB: lt_i = GET_L_TIMER_IDX(offset); index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i); s->l_timer[lt_i].reg.wstat |= L_WSTAT_ICNTB_WRITE; s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] = value & ~L_ICNTB_MANUAL_UPDATE; if (s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] * s->l_timer[lt_i].reg.cnt[L_REG_CNT_TCNTB] < MCT_LT_CNT_LOW_LIMIT) { if (!s->l_timer[lt_i].reg.cnt[L_REG_CNT_TCNTB]) { s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] = MCT_LT_CNT_LOW_LIMIT; } else { s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] = MCT_LT_CNT_LOW_LIMIT / s->l_timer[lt_i].reg.cnt[L_REG_CNT_TCNTB]; } } if (value & L_ICNTB_MANUAL_UPDATE) { exynos4210_ltick_set_cntb(&s->l_timer[lt_i].tick_timer, s->l_timer[lt_i].tick_timer.tcntb, s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB]); } #ifdef DEBUG_MCT if (icntb_min[lt_i] > value) { icntb_min[lt_i] = value; } if (icntb_max[lt_i] < value) { icntb_max[lt_i] = value; } DPRINTF("local timer[%d] ICNTB write %llx; max=%x, min=%x\n\n", lt_i, value, icntb_max[lt_i], icntb_min[lt_i]); #endif break; case L0_FRCNTB: case L1_FRCNTB: lt_i = GET_L_TIMER_IDX(offset); index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i); DPRINTF("local timer[%d] FRCNTB write %llx\n", lt_i, value); s->l_timer[lt_i].reg.wstat |= L_WSTAT_FRCCNTB_WRITE; s->l_timer[lt_i].reg.cnt[L_REG_CNT_FRCCNTB] = value; break; case L0_TCNTO: case L1_TCNTO: case L0_ICNTO: case L1_ICNTO: case L0_FRCNTO: case L1_FRCNTO: fprintf(stderr, "\n[exynos4210.mct: write to RO register " TARGET_FMT_plx "]\n\n", offset); break; case L0_INT_CSTAT: case L1_INT_CSTAT: lt_i = GET_L_TIMER_IDX(offset); DPRINTF("local timer[%d] CSTAT write %llx\n", lt_i, value); s->l_timer[lt_i].reg.int_cstat &= ~value; if (!s->l_timer[lt_i].reg.int_cstat) { qemu_irq_lower(s->l_timer[lt_i].irq); } break; case L0_INT_ENB: case L1_INT_ENB: lt_i = GET_L_TIMER_IDX(offset); old_val = s->l_timer[lt_i].reg.int_enb; if ((value & L_INT_INTENB_ICNTEIE) > (old_val & L_INT_INTENB_ICNTEIE)) { if (s->l_timer[lt_i].reg.int_cstat & L_INT_CSTAT_INTCNT) { qemu_irq_raise(s->l_timer[lt_i].irq); } } s->l_timer[lt_i].reg.int_enb = value; break; case L0_WSTAT: case L1_WSTAT: lt_i = GET_L_TIMER_IDX(offset); s->l_timer[lt_i].reg.wstat &= ~value; break; default: hw_error("exynos4210.mct: bad write offset " TARGET_FMT_plx "\n", offset); break; } }
1threat
static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd, const QDict *params) { int ret; MonitorCompletionData *cb_data = g_malloc(sizeof(*cb_data)); cb_data->mon = mon; cb_data->user_print = cmd->user_print; monitor_suspend(mon); ret = cmd->mhandler.cmd_async(mon, params, user_monitor_complete, cb_data); if (ret < 0) { monitor_resume(mon); g_free(cb_data); } }
1threat
PHP count down every 30 minutes real time : <p>My Boss give me a project in which i have to show a real time count down of every 30 minutes in PHP anyone can help me how to do this ?? sorry for my Bad English</p>
0debug
How can I improve ths logic : I will have to implement following logic in java - 1. execute query Q1 on data D1 based on condition C1 2. if result of Q1 is more than zero then make another query Q2 on data D2 based on condition C2 3. If Q2 size is more than zero then make another query Q3 on data D2 based on condition C3 4. If Q3 size is more than zero then make another query Q4 on data D2 based on condition C4 5. Now if Q1 result size is zero then execute query Q5 on data D1 based on condition C5 6. If result of Q5 is more than zero then execute query Q6 on data D3 based on condition C2 7. If result of Q6 is more than zero then execute query Q7 on data D3 based on condition C3 8. If result of Q7 is more than zero then execute query Q8 on data D3 based on condition C4 So I'm thinking about to write below logic - R1 = getResult (dataset D1, condition C1); //Query on data D1 based on condition C1; If (R1 is not null) { R2 = getResult (dataset R1, condition C2); // Query on data R1 based on condition C2; if(R2 is null){ R3 = getResult (dataset R1, condition C3); // Query on data R1 based on condition C3 if(R3 is null){ R4 = getResult (dataset R1, condition C4); // Query on data R1 based on condition C4 display(R4); }else{ display(R3); } }else{ display(R2); } }else{ R5 = getResult (dataset D1, condition C5); if(R5 is not null){ R6 = getResult (dataset R5, condition C2); //Query on data R5 based on condition C2; if(R6 is null){ R7 = getResult (dataset R5, condition C3); //Query on data R5 based on condition C3 if(R7 is null){ R8 = getResult(dataset R5, condition C4); //Query on data R5 based on condition C3 }else{ display(R8); } }else{ display(R6); } } } Is there a better way to improve this logic?
0debug
static int bfi_decode_frame(AVCodecContext * avctx, void *data, int *data_size, const uint8_t * buf, int buf_size) { BFIContext *bfi = avctx->priv_data; uint8_t *dst = bfi->dst; uint8_t *src, *dst_offset, colour1, colour2; uint8_t *frame_end = bfi->dst + avctx->width * avctx->height; uint32_t *pal; int i, j, height = avctx->height; if (bfi->frame.data[0]) avctx->release_buffer(avctx, &bfi->frame); bfi->frame.reference = 1; if (avctx->get_buffer(avctx, &bfi->frame) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } if (!avctx->frame_number) { bfi->frame.pict_type = FF_I_TYPE; bfi->frame.key_frame = 1; if(avctx->extradata_size>768) { av_log(NULL, AV_LOG_ERROR, "Palette is too large.\n"); return -1; } pal = (uint32_t *) bfi->frame.data[1]; for (i = 0; i < avctx->extradata_size / 3; i++) { int shift = 16; *pal = 0; for (j = 0; j < 3; j++, shift -= 8) *pal += ((avctx->extradata[i * 3 + j] << 2) | (avctx->extradata[i * 3 + j] >> 4)) << shift; pal++; } bfi->frame.palette_has_changed = 1; } else { bfi->frame.pict_type = FF_P_TYPE; bfi->frame.key_frame = 0; } buf += 4; while (dst != frame_end) { static const uint8_t lentab[4]={0,2,0,1}; unsigned int byte = *buf++, offset; unsigned int code = byte >> 6; unsigned int length = byte & ~0xC0; if (length == 0) { if (code == 1) { length = bytestream_get_byte(&buf); offset = bytestream_get_le16(&buf); } else { length = bytestream_get_le16(&buf); if (code == 2 && length == 0) break; } } else { if (code == 1) offset = bytestream_get_byte(&buf); } if (dst + (length<<lentab[code]) > frame_end) break; switch (code) { case 0: bytestream_get_buffer(&buf, dst, length); dst += length; break; case 1: dst_offset = dst - offset; length *= 4; if (dst_offset < bfi->dst) break; while (length--) *dst++ = *dst_offset++; break; case 2: dst += length; break; case 3: colour1 = bytestream_get_byte(&buf); colour2 = bytestream_get_byte(&buf); while (length--) { *dst++ = colour1; *dst++ = colour2; } break; } } src = bfi->dst; dst = bfi->frame.data[0]; while (height--) { memcpy(dst, src, avctx->width); src += avctx->width; dst += bfi->frame.linesize[0]; } *data_size = sizeof(AVFrame); *(AVFrame *) data = bfi->frame; return buf_size; }
1threat
error in a C program using dynamic memory allocation and array : programming in C for finding maximum in 2D aaray using dynamic memory allocation. int main() { int i,arr[m][n],j,m,n; int max=0; int *ptr; printf("enter the value m"); scanf("%d",m); printf("enter the vaue of n"); scanf("%d",n); ptr=(int*)malloc(m*n*4); printf("enter the values\n"); for (i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",((ptr+i*n)+j)); } } max=arr[0][0]; for (i=0;i<m;i++) { for(j=0;j<n;j++) { if(max<*((ptr+i*n)+j)); max=*((ptr+i*n)+j); } } printf("%d",max); }
0debug
static void test_nesting(void) { Coroutine *root; NestData nd = { .n_enter = 0, .n_return = 0, .max = 128, }; root = qemu_coroutine_create(nest); qemu_coroutine_enter(root, &nd); g_assert_cmpint(nd.n_enter, ==, nd.max); g_assert_cmpint(nd.n_return, ==, nd.max); }
1threat
How construct json I can receive int64 and string using golang? : I have the follow example code: type Num struct { X uint64 `json:"x,string"` Y float64 `json:"y,string"` } Now, I use the command `curl -X POST --data '{"x": "123", "y": "1.23"}' -v "localhost:8080"` it will return OK. But I use the command `curl -X POST --data '{"x": 123, "y": 1.23}' -v "localhost:8080"` it will return error. The result I can understand. Now, my problem is how can receive both string and uint64/float64?
0debug
react / redux-form: how to return promise from onSubmit? : <p>I'm trying to wrap my head around <a href="http://rackt.org/redux/" rel="noreferrer">redux</a>, <a href="http://rackt.org/redux/docs/basics/UsageWithReact.html" rel="noreferrer">react-redux</a> and <a href="http://erikras.github.io/redux-form/" rel="noreferrer">redux-form</a>.</p> <p>I have setup a store and added the reducer from redux-form. My form component looks like this:</p> <p><strong>LoginForm</strong></p> <pre><code>import React, {Component, PropTypes} from 'react' import { reduxForm } from 'redux-form' import { login } from '../../actions/authActions' const fields = ['username', 'password']; class LoginForm extends Component { onSubmit (formData, dispatch) { dispatch(login(formData)) } render() { const { fields: { username, password }, handleSubmit, submitting } = this.props; return ( &lt;form onSubmit={handleSubmit(this.onSubmit)}&gt; &lt;input type="username" placeholder="Username / Email address" {...username} /&gt; &lt;input type="password" placeholder="Password" {...password} /&gt; &lt;input type="submit" disabled={submitting} value="Login" /&gt; &lt;/form&gt; ) } } LoginForm.propTypes = { fields: PropTypes.object.isRequired, handleSubmit: PropTypes.func.isRequired, submitting: PropTypes.bool.isRequired } export default reduxForm({ form: 'login', fields })(LoginForm) </code></pre> <p>This works as expected, in <a href="https://github.com/gaearon/redux-devtools" rel="noreferrer">redux DevTools</a> I can see how the store is updated on form input and on submitting the form the <code>login</code> action creator dispatches the login actions.</p> <p>I added the <a href="https://github.com/gaearon/redux-thunk" rel="noreferrer">redux-thunk</a> middleware to the store and setup the action creator(s) for logging in as described in the <a href="http://rackt.org/redux/docs/advanced/AsyncActions.html" rel="noreferrer">redux docs for Async Actions</a>:</p> <p><strong>authActions.js</strong></p> <pre><code>import ApiClient from '../apiClient' const apiClient = new ApiClient() export const LOGIN_REQUEST = 'LOGIN_REQUEST' function requestLogin(credentials) { return { type: LOGIN_REQUEST, credentials } } export const LOGIN_SUCCESS = 'LOGIN_SUCCESS' function loginSuccess(authToken) { return { type: LOGIN_SUCCESS, authToken } } export const LOGIN_FAILURE = 'LOGIN_FAILURE' function loginFailure(error) { return { type: LOGIN_FAILURE, error } } // thunk action creator returns a function export function login(credentials) { return dispatch =&gt; { // update app state: requesting login dispatch(requestLogin(credentials)) // try to log in apiClient.login(credentials) .then(authToken =&gt; dispatch(loginSuccess(authToken))) .catch(error =&gt; dispatch(loginFailure(error))) } } </code></pre> <p>Again, in redux DevTools I can see that this works as expected. When <code>dispatch(login(formData))</code> is called in <code>onSubmit</code> in the LoginForm, first the <code>LOGIN_REQUEST</code> action is dispatched, followed by <code>LOGIN_SUCCESS</code> or <code>LOGIN_FAILURE</code>. <code>LOGIN_REQUEST</code> will add a property <code>state.auth.pending = true</code> to the store, <code>LOGIN_SUCCESS</code> and <code>LOGIN_FAILURE</code> will remove this property. (I know this might me something to use <a href="https://github.com/rackt/reselect" rel="noreferrer">reselect</a> for, but for now I want to keep it simple.</p> <p>Now, in the redux-form docs I read that I can return a promise from <code>onSubmit</code> to update the form state (<code>submitting</code>, <code>error</code>). But I'm not sure what's the correct way to do this. <code>dispatch(login(formData))</code> returns <code>undefined</code>.</p> <p>I could exchange the <code>state.auth.pending</code> flag in the store with a variable like <code>state.auth.status</code> with the values <em>requested</em>, <em>success</em> and <em>failure</em> (and again, I could probably use reselect or something alike for this).</p> <p>I could then subscribe to the store in <code>onSubmit</code> and handle changes to <code>state.auth.status</code> like this:</p> <pre><code>// ... class LoginForm extends Component { constructor (props) { super(props) this.onSubmit = this.onSubmit.bind(this) } onSubmit (formData, dispatch) { const { store } = this.context return new Promise((resolve, reject) =&gt; { const unsubscribe = store.subscribe(() =&gt; { const state = store.getState() const status = state.auth.status if (status === 'success' || status === 'failure') { unsubscribe() status === 'success' ? resolve() : reject(state.auth.error) } }) dispatch(login(formData)) }).bind(this) } // ... } // ... LoginForm.contextTypes = { store: PropTypes.object.isRequired } // ... </code></pre> <p>However, this solution doesn't feel good and I'm not sure if it will always work as expected when the app grows and more actions might be dispatched from other sources.</p> <p>Another solution I have seen is moving the api call (which returns a promise) to <code>onSubmit</code>, but I would like to keep it seperated from the React component.</p> <p>Any advice on this?</p>
0debug
void qemu_start_incoming_migration(const char *uri, Error **errp) { const char *p; if (strstart(uri, "tcp:", &p)) tcp_start_incoming_migration(p, errp); #ifdef CONFIG_RDMA else if (strstart(uri, "rdma:", &p)) rdma_start_incoming_migration(p, errp); #endif #if !defined(WIN32) else if (strstart(uri, "exec:", &p)) exec_start_incoming_migration(p, errp); else if (strstart(uri, "unix:", &p)) unix_start_incoming_migration(p, errp); else if (strstart(uri, "fd:", &p)) fd_start_incoming_migration(p, errp); #endif else { error_setg(errp, "unknown migration protocol: %s", uri); } }
1threat
Why demo Jquery plugin isn't working? : <p>I downloaded the autocomplete plugin, just a complete plugin demo. The only thing that i need to do is upload the SQL file to my database and update the database login details:</p> <pre><code>/* Database setup information */ $dbhost = 'localhost:3307'; // Database Host $dbuser = 'root'; // Database Username $dbpass = ''; // Database Password $dbname = 'itemsdb'; // Database Name </code></pre> <p>When i take a look in the console then i getting some XML errors, every time i type something in the search field.</p> <p><a href="https://imgur.com/Z9QSeC7" rel="nofollow noreferrer">http://imgur.com/Z9QSeC7</a> This is the autocomplete plugin: <a href="https://www.freshdesignweb.com/downloads/jquery-autocomplete-p1.zip" rel="nofollow noreferrer">https://www.freshdesignweb.com/downloads/jquery-autocomplete-p1.zip</a></p>
0debug
In docker-compose how to create an alias / link to localhost? : <p>In my docker-compose file there is a need for several containers to know the hostname of a specific container, including this specific container.</p> <p>Links will not work, since a container can not link to itself.</p> <p>Basically, what I am looking for is a way to alias localhost in docker-compose.</p>
0debug
Need help: for loop and if statement within a method : I am new to using java and am having some issues in my java class right now and will be needing help with my specific code. I try to look at others questions on here all the time but it's never exactly what I need. Here are my directions: Create a Java file called CompoundInterestYourLastName. Write a method called computeBalance( ) that computes the balance of a bank account with a given initial balance and interest rate, after a given number of years. Assume interest is compounded yearly. Use a loop to control the iterations through the years in your method. Your method should return a double value. In your main method, run the following tests to verify your method is working correctly. System.out.printf("Your total is $%.2f", computeBalance(1000, .045, 3)); // should return $1141.17 I am using eclipse and my only current error is in the comments. I also want some general tips and let me know if my logic is wrong. It probably is. :D Here is what I have currently although I have been trying different things: import java.util.Scanner; import java.lang.Math; public class CompoundInterestTidwell { public static void main(String[] args) { double compInt = computeBalance(1000, 0.045, 3); System.out.printf("Your new balance is $%.2f", compInt); } // Getting arror for line of code below. // Error: This method must return a result of type double public static double computeBalance(int P, double r, int t) { // Formula for compounding interest // A = P(1+(r/n))^(n(t)) // The examples to check my math had rate already divided by 100 so I left out r/n. for(int c = 0; c <= t; c++ ) { // deleted 'n' from equation because it need to equal 1 anyways. double compInt = Math.pow(P*(1+r), t); if (c < t) { c++; return compInt; } } } } Thanks.
0debug
Julia in Google Colab : <p>I am trying to setup Julia with Google Colab. Installation instructions as in <a href="https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319" rel="noreferrer">https://discourse.julialang.org/t/julia-on-google-colab-free-gpu-accelerated-shareable-notebooks/15319</a> have been followed. Despite that, I am unable to launch Julia.</p> <p>I am trying to use Julia with Google Colab. I followed the following steps:</p> <ol> <li>Install CUDA</li> </ol> <pre><code>!wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb !dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb !apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub !apt update -q !apt install cuda gcc-6 g++-6 -y -q !ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc !ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++ </code></pre> <ol start="2"> <li>Install Julia 1.2.0</li> </ol> <pre><code>!curl -sSL "https://julialang-s3.julialang.org/bin/linux/x64/1.2/julia-1.2.0-linux-x86_64.tar.gz" -o julia.tar.gz !tar -xzf julia.tar.gz -C /usr --strip-components 1 !rm -rf julia.tar.gz* !julia -e 'using Pkg; pkg"add IJulia; add CuArrays; add Flux; precompile"' </code></pre> <p>The above two steps run perfectly fine. I am unable to initiate a Julia session. I tried: </p> <pre><code> !julia </code></pre> <p>With this, the Julia start-up screen keeps showing with no command-line.</p>
0debug
Urgent help , please : hello and thank you very very much in advance for helping me with this , i have this array, that is dumped from woocommerce using this lines : $items = $woocommerce->cart->get_cart(); foreach($items as $item => $values) { } array(1) { ["f584d8671586d336d84e8cf9ed43303c"]=> array(11) { ["booking"]=> array(15) { ["_year"]=> int(2016) ["_month"]=> int(8) ["_day"]=> int(28) ["_persons"]=> array(1) { [0]=> int(1) } ["_date"]=> string(9) "2016-8-28" ["date"]=> string(13) "28 août 2016" ["_time"]=> string(5) "21:30" ["time"]=> string(11) "21 h 30 min" ["_qty"]=> int(1) ["Personnes"]=> int(1) ["_start_date"]=> int(1472419800) ["_end_date"]=> int(1472421600) ["_all_day"]=> int(0) ["_cost"]=> int(0) ["_booking_id"]=> int(13013) } ["product_id"]=> int(12856) ["variation_id"]=> int(0) ["variation"]=> array(0) { } ["quantity"]=> int(1) ["line_total"]=> float(0) ["line_tax"]=> int(0) ["line_subtotal"]=> int(0) ["line_subtotal_tax"]=> int(0) ["line_tax_data"]=> array(2) { ["total"]=> array(0) { } ["subtotal"]=> array(0) { } } ["data"]=> object(WC_Product_Booking)#11131 (20) { ["availability_rules":"WC_Product_Booking":private]=> array(0) { } ["id"]=> int(12856) ["post"]=> object(WP_Post)#11132 (24) { ["ID"]=> int(12856) ["post_author"]=> string(2) "14" ["post_date"]=> string(19) "2016-08-16 22:04:09" ["post_date_gmt"]=> string(19) "2016-08-16 20:04:09" ["post_content"]=> string(0) "" ["post_title"]=> string(10) "La Cuchara" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(4) "open" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(12) "la-cuchara-2" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2016-08-16 22:13:52" ["post_modified_gmt"]=> string(19) "2016-08-16 20:13:52" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(59) "" ["menu_order"]=> int(0) ["post_type"]=> string(7) "product" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } ["product_type"]=> string(7) "booking" ["shipping_class":protected]=> string(0) "" ["shipping_class_id":protected]=> int(0) ["total_stock"]=> NULL ["supports":protected]=> array(0) { } ["price"]=> string(1) "0" ["wc_display_cost"]=> string(0) "" ["wc_booking_base_cost"]=> string(0) "" ["wc_booking_min_duration"]=> string(1) "1" ["wc_booking_cost"]=> string(0) "" ["wc_booking_has_resources"]=> string(2) "no" ["wc_booking_has_persons"]=> string(3) "yes" ["wc_booking_has_person_types"]=> string(2) "no" ["wc_booking_min_persons_group"]=> string(1) "1" ["tax_status"]=> string(7) "taxable" ["stock_status"]=> string(7) "instock" ["manage_stock"]=> string(2) "no" } } } what i need to recover the booking date, time and persons into variables : ["date"]=> string(13) "28 août 2016" ["_persons"]=> array(1) { [0]=> int(1) } ["time"]=> string(11) "21 h 30 min"
0debug
static int decode_cce(AACContext * ac, GetBitContext * gb, ChannelElement * che) { int num_gain = 0; int c, g, sfb, ret, idx = 0; int sign; float scale; SingleChannelElement * sce = &che->ch[0]; ChannelCoupling * coup = &che->coup; coup->coupling_point = 2*get_bits1(gb); coup->num_coupled = get_bits(gb, 3); for (c = 0; c <= coup->num_coupled; c++) { num_gain++; coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE; coup->id_select[c] = get_bits(gb, 4); if (coup->type[c] == TYPE_CPE) { coup->ch_select[c] = get_bits(gb, 2); if (coup->ch_select[c] == 3) num_gain++; } else coup->ch_select[c] = 1; } coup->coupling_point += get_bits1(gb); if (coup->coupling_point == 2) { av_log(ac->avccontext, AV_LOG_ERROR, "Independently switched CCE with 'invalid' domain signalled.\n"); memset(coup, 0, sizeof(ChannelCoupling)); return -1; } sign = get_bits(gb, 1); scale = pow(2., pow(2., (int)get_bits(gb, 2) - 3)); if ((ret = decode_ics(ac, sce, gb, 0, 0))) return ret; for (c = 0; c < num_gain; c++) { int cge = 1; int gain = 0; float gain_cache = 1.; if (c) { cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb); gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0; gain_cache = pow(scale, gain); } for (g = 0; g < sce->ics.num_window_groups; g++) { for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) { if (sce->band_type[idx] != ZERO_BT) { if (!cge) { int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; if (t) { int s = 1; if (sign) { s -= 2 * (t & 0x1); t >>= 1; } gain += t; gain_cache = pow(scale, gain) * s; } } coup->gain[c][idx] = gain_cache; } } } } return 0; }
1threat
Nested-list is giving segmentation-fault : I don't understand why this C++ code is producing segmentation error. Please Someone tell... #include<bits/stdc++.h> using namespace std; typedef long long ll; list<int> *adj; void addEdge(int v, int w) { adj[v].push_back(w); // Add w to v’s list. adj[w].push_back(v); } int main(){ int n,m,t; cin>>n>>m>>t; int u, v; for(int i=0; i<m; i++){ cin>>u>>v; addEdge(u,v); } cout<<n<<"\n"; for(int i=1;i<=n;i++)cout<<i<<" "; }
0debug
static void check_native_list(QObject *qobj, UserDefNativeListUnionKind kind) { QDict *qdict; QList *qlist; int i; qdict = qobject_to_qdict(qobj); g_assert(qdict); g_assert(qdict_haskey(qdict, "data")); qlist = qlist_copy(qobject_to_qlist(qdict_get(qdict, "data"))); switch (kind) { case USER_DEF_NATIVE_LIST_UNION_KIND_S8: case USER_DEF_NATIVE_LIST_UNION_KIND_S16: case USER_DEF_NATIVE_LIST_UNION_KIND_S32: case USER_DEF_NATIVE_LIST_UNION_KIND_S64: case USER_DEF_NATIVE_LIST_UNION_KIND_U8: case USER_DEF_NATIVE_LIST_UNION_KIND_U16: case USER_DEF_NATIVE_LIST_UNION_KIND_U32: case USER_DEF_NATIVE_LIST_UNION_KIND_U64: case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: for (i = 0; i < 32; i++) { QObject *tmp; QNum *qvalue; int64_t val; tmp = qlist_peek(qlist); g_assert(tmp); qvalue = qobject_to_qnum(tmp); g_assert(qnum_get_try_int(qvalue, &val)); g_assert_cmpint(val, ==, i); qobject_decref(qlist_pop(qlist)); } break; case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN: for (i = 0; i < 32; i++) { QObject *tmp; QBool *qvalue; tmp = qlist_peek(qlist); g_assert(tmp); qvalue = qobject_to_qbool(tmp); g_assert_cmpint(qbool_get_bool(qvalue), ==, i % 3 == 0); qobject_decref(qlist_pop(qlist)); } break; case USER_DEF_NATIVE_LIST_UNION_KIND_STRING: for (i = 0; i < 32; i++) { QObject *tmp; QString *qvalue; gchar str[8]; tmp = qlist_peek(qlist); g_assert(tmp); qvalue = qobject_to_qstring(tmp); sprintf(str, "%d", i); g_assert_cmpstr(qstring_get_str(qvalue), ==, str); qobject_decref(qlist_pop(qlist)); } break; case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER: for (i = 0; i < 32; i++) { QObject *tmp; QNum *qvalue; GString *double_expected = g_string_new(""); GString *double_actual = g_string_new(""); tmp = qlist_peek(qlist); g_assert(tmp); qvalue = qobject_to_qnum(tmp); g_string_printf(double_expected, "%.6f", (double)i / 3); g_string_printf(double_actual, "%.6f", qnum_get_double(qvalue)); g_assert_cmpstr(double_actual->str, ==, double_expected->str); qobject_decref(qlist_pop(qlist)); g_string_free(double_expected, true); g_string_free(double_actual, true); } break; default: g_assert_not_reached(); } QDECREF(qlist); }
1threat
html to accept only numbers and alphabhets without script : **Input type must accept only:** -letters(a-z and A-Z) - Numbers(only positive integers) - No Special Characters
0debug
copy list element of key values in dictionary through python language? : I have dictionary which have multiple key and those multiple key have multiple list so i want to copy specific value for a specific key dict1={ '1' : [1,2,3] , '2' : [4,5,6] , '3' :[7,8,9]} output: if key == 1 then print 3 if key == 2 then print 6 if key == 3 then print 9
0debug
ATM Account Homework (Classes,Textfiles,Objects) : I am completely lost. Our homework assignment is to: 1. Create an ATM Program that asks a user for their name and pin 2. Program will loop through asking user if they want to check balance, withdraw, deposit, or exit. You exit the loop when user selects exit. The initial balance is $10,000 3. Create a text file that records all transactions. First 2 lines of the file should be the User's name and Pin 4. Create a class called which includes the __init__ and __str__ functions to display info from the user(deposit, check balance, withdraw) 5. Program needs to read from the file and create an object. The fields for the object are the name, pin, and balance. 6.If the pin number and the name they provide to not match the name and pin number for the BAcc object the program will end. Otherwise you can proceeded to make as many transactions as you want updating the file 7.Errors must by handled using try: blocks! This includes both invalid data entry and insufficient funds on a withdraw. This is the code I have right now, it doesn't do much but I just need a way to connect it. accountfile=open("ATMACC.txt", "a") name=input("What is your name? ") pin=input("What is your Pin #? ") accountfile.write("Name: " + name + "\n" + "PIN: " + pin + "\n") USER_BALANCE = 10000 class BankAcc(object): def __init__(self,name,pin,balance): name = self.name pin = self.pin 10000 = self.balance def __str__(self): return "Bank Account with Balance {}".format(self.name,self.balance) def checkbalance(self): print(self) def deposit(self,amount): self.amount += amount def withdraw(self,amount): if self.balance > amount: self.balance -= amount else: raise ValueError while True: answer=input("Would you like to deposit, withdraw, check balance, or exit? ") if answer=="deposit" or answer== "Deposit": x= input("How much would you like to deposit? ") USER_BALANCE += float(x) print ("Your new balance is: $" + str(USER_BALANCE)) accountfile.write("\n" + "Deposit of $" + x + "." + " " + "Current balance is $" + str(USER_BALANCE)) continue elif answer== "withdraw" or answer== "Withdraw": y= input("How much would you like to withdraw? ") if float (y)<=USER_BALANCE: USER_BALANCE -= float(y) print ("Your new balance is: $" + str(USER_BALANCE)) accountfile.write("\n" + "Withdraw of $" + y + "." + " " + "Current balance is $" + str(USER_BALANCE)) continue else: print ("Cannot be done. You have insufficient funds.") elif answer== "check balance" or answer== "Check Balance": print ("$" + str(USER_BALANCE)) elif answer== "exit" or answer== "Exit": print ("Goodbye!") accountfile.close() break else: print ("I'm sorry, that is not an option") Please help. I know this is a complete mess but any help would be greatly appreciated.
0debug
How to handle differnt language in selenium? : My application supporting two language i.e English and french and my single Test case support both the language Then phase1 is able to run Test case in English as well as in french so what will be the basic structure of framework to full-fill this criteria?
0debug
How do i use the % placeholder to write something in python? : <p>I have been asked to use the % placeholder to write something in python. I don't know how to do it can you help. </p>
0debug
My constructor function is not found in main() : <p>I'm getting a for me inexplicable error:</p> <pre><code>PageRankReader.java:19: error: cannot find symbol PageRankReader(args[0]); ^ symbol: method PageRankReader(String) location: class PageRankReader 1 error </code></pre> <p>Which I cannot understand because I've clearly defined the method signature at the top of the class.</p> <pre><code>public class PageRankReader { public PageRankReader(String filename) { try { readPageRanks(filename); }catch (FileNotFoundException e) { System.err.println("File not found"); } } public static void main(String[] args) { if( args.length != 0) { System.err.println("Please provide name of the pageranks file"); } PageRankReader(args[0]); } } </code></pre> <p>What's the reason for this error?</p>
0debug
def count_Rotation(arr,n): for i in range (1,n): if (arr[i] < arr[i - 1]): return i return 0
0debug
Generate single physical javascript file using create-react-app : <p>This is perhaps a newbie question. I have created a small reactjs app using create-react-app and I see that the bundle.js file is being served from <a href="http://localhost:3000/static/js/bundle.js" rel="noreferrer">http://localhost:3000/static/js/bundle.js</a>. However, I do not see a physical "bundled" javascript file on my machine. How can I generate a physical bundled javascript file so I can "register" it in my wordpress php code? I'm building a small wordpress plugin that will use reactjs on the client side. Am I missing something obvious? </p>
0debug
static int check_bd(VIOsPAPRVLANDevice *dev, vlan_bd_t bd, target_ulong alignment) { if ((VLAN_BD_ADDR(bd) % alignment) || (VLAN_BD_LEN(bd) % alignment)) { return -1; } if (spapr_vio_check_tces(&dev->sdev, VLAN_BD_ADDR(bd), VLAN_BD_LEN(bd), SPAPR_TCE_RW) != 0) { return -1; } return 0; }
1threat
static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s, int16_t *block, int n) { int level, i, j, run; RLTable *rl = &ff_rl_mpeg1; uint8_t * const scantable = s->intra_scantable.permutated; const int qscale = s->qscale; OPEN_READER(re, &s->gb); i = -1; UPDATE_CACHE(re, &s->gb); if (((int32_t)GET_CACHE(re, &s->gb)) < 0) { level = (3 * qscale) >> 1; if (GET_CACHE(re, &s->gb) & 0x40000000) level = -level; block[0] = level; i++; SKIP_BITS(re, &s->gb, 2); if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF) goto end; } for (;;) { GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); if (level != 0) { i += run; check_scantable_index(s, i); j = scantable[i]; level = ((level * 2 + 1) * qscale) >> 1; level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1); } else { run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6); UPDATE_CACHE(re, &s->gb); level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12); i += run; check_scantable_index(s, i); j = scantable[i]; if (level < 0) { level = ((-level * 2 + 1) * qscale) >> 1; level = -level; } else { level = ((level * 2 + 1) * qscale) >> 1; } } block[j] = level; if (((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF) break; UPDATE_CACHE(re, &s->gb); } end: LAST_SKIP_BITS(re, &s->gb, 2); CLOSE_READER(re, &s->gb); s->block_last_index[n] = i; return 0; }
1threat
jqury on table div : I have table as follows: <table class="mytable"> <div> <tr> <th>h1</th> <th>h1-1</th> <th>h1-2</th> </tr> <tr> <th>h2</th> <th>h2-2</th> <th>h2-3</th> </tr> </div> <div> <tr> <td>1</td> <td>1</td> <td>1</td> </tr> <tr> <td>2</td> <td>2</td> <td>2</td> </tr> </div> </table> Now i want two jquery as follows: 1) jquery to get all div present in table. 2) jquery to get first tr's td data in every div. it may be in loop. Please help me any body i am new to jquery.
0debug
static uint64_t virtio_pci_config_read(void *opaque, hwaddr addr, unsigned size) { VirtIOPCIProxy *proxy = opaque; uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev); uint64_t val = 0; if (addr < config) { return virtio_ioport_read(proxy, addr); } addr -= config; switch (size) { case 1: val = virtio_config_readb(proxy->vdev, addr); break; case 2: val = virtio_config_readw(proxy->vdev, addr); if (virtio_is_big_endian()) { val = bswap16(val); } break; case 4: val = virtio_config_readl(proxy->vdev, addr); if (virtio_is_big_endian()) { val = bswap32(val); } break; } return val; }
1threat
static float get_band_cost_SQUAD_mips(struct AACEncContext *s, PutBitContext *pb, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits) { const float Q34 = ff_aac_pow34sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; const float IQ = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; int i; float cost = 0; int qc1, qc2, qc3, qc4; int curbits = 0; uint8_t *p_bits = (uint8_t *)ff_aac_spectral_bits[cb-1]; float *p_codes = (float *)ff_aac_codebook_vectors[cb-1]; for (i = 0; i < size; i += 4) { const float *vec; int curidx; int *in_int = (int *)&in[i]; float *in_pos = (float *)&in[i]; float di0, di1, di2, di3; int t0, t1, t2, t3, t4, t5, t6, t7; qc1 = scaled[i ] * Q34 + ROUND_STANDARD; qc2 = scaled[i+1] * Q34 + ROUND_STANDARD; qc3 = scaled[i+2] * Q34 + ROUND_STANDARD; qc4 = scaled[i+3] * Q34 + ROUND_STANDARD; __asm__ volatile ( ".set push \n\t" ".set noreorder \n\t" "slt %[qc1], $zero, %[qc1] \n\t" "slt %[qc2], $zero, %[qc2] \n\t" "slt %[qc3], $zero, %[qc3] \n\t" "slt %[qc4], $zero, %[qc4] \n\t" "lw %[t0], 0(%[in_int]) \n\t" "lw %[t1], 4(%[in_int]) \n\t" "lw %[t2], 8(%[in_int]) \n\t" "lw %[t3], 12(%[in_int]) \n\t" "srl %[t0], %[t0], 31 \n\t" "srl %[t1], %[t1], 31 \n\t" "srl %[t2], %[t2], 31 \n\t" "srl %[t3], %[t3], 31 \n\t" "subu %[t4], $zero, %[qc1] \n\t" "subu %[t5], $zero, %[qc2] \n\t" "subu %[t6], $zero, %[qc3] \n\t" "subu %[t7], $zero, %[qc4] \n\t" "movn %[qc1], %[t4], %[t0] \n\t" "movn %[qc2], %[t5], %[t1] \n\t" "movn %[qc3], %[t6], %[t2] \n\t" "movn %[qc4], %[t7], %[t3] \n\t" ".set pop \n\t" : [qc1]"+r"(qc1), [qc2]"+r"(qc2), [qc3]"+r"(qc3), [qc4]"+r"(qc4), [t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=&r"(t3), [t4]"=&r"(t4), [t5]"=&r"(t5), [t6]"=&r"(t6), [t7]"=&r"(t7) : [in_int]"r"(in_int) : "memory" ); curidx = qc1; curidx *= 3; curidx += qc2; curidx *= 3; curidx += qc3; curidx *= 3; curidx += qc4; curidx += 40; curbits += p_bits[curidx]; vec = &p_codes[curidx*4]; __asm__ volatile ( ".set push \n\t" ".set noreorder \n\t" "lwc1 $f0, 0(%[in_pos]) \n\t" "lwc1 $f1, 0(%[vec]) \n\t" "lwc1 $f2, 4(%[in_pos]) \n\t" "lwc1 $f3, 4(%[vec]) \n\t" "lwc1 $f4, 8(%[in_pos]) \n\t" "lwc1 $f5, 8(%[vec]) \n\t" "lwc1 $f6, 12(%[in_pos]) \n\t" "lwc1 $f7, 12(%[vec]) \n\t" "nmsub.s %[di0], $f0, $f1, %[IQ] \n\t" "nmsub.s %[di1], $f2, $f3, %[IQ] \n\t" "nmsub.s %[di2], $f4, $f5, %[IQ] \n\t" "nmsub.s %[di3], $f6, $f7, %[IQ] \n\t" ".set pop \n\t" : [di0]"=&f"(di0), [di1]"=&f"(di1), [di2]"=&f"(di2), [di3]"=&f"(di3) : [in_pos]"r"(in_pos), [vec]"r"(vec), [IQ]"f"(IQ) : "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", "memory" ); cost += di0 * di0 + di1 * di1 + di2 * di2 + di3 * di3; } if (bits) *bits = curbits; return cost * lambda + curbits; }
1threat
def find_star_num(n): return (6 * n * (n - 1) + 1)
0debug
Local overrides in chrome – keep active while devtools are closed : <p>I really like the <a href="https://developers.google.com/web/updates/2018/01/devtools#overrides" rel="noreferrer">local overrides feature in chrome</a>. While it is handy during development, I'd also like to use it <strong>while my devtools are closed</strong>. If this were possible, it could replace extensions which inject custom <a href="https://chrome.google.com/webstore/detail/user-css/okpjlejfhacmgjkmknjhadmkdbcldfcb?hl=en" rel="noreferrer">css</a> or <a href="https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=en" rel="noreferrer">js</a> into the page. (right now, after loading a page, overrides do not kick in until devtools have been opened at least once)</p> <p><a href="https://glebbahmutov.com/blog/local-overrides/" rel="noreferrer">After</a> <a href="https://www.ghacks.net/2018/02/27/make-permanent-changes-to-web-pages-with-chromes-overrides-dev-tool/" rel="noreferrer">some</a> <a href="https://umaar.com/dev-tips/165-local-overrides-font-display/" rel="noreferrer">digging</a>, I got the impression it's not possible though. Can somebody please confirm this? Is there any way to achieve the desired effect (custom js &amp; css) without extensions?</p>
0debug
Javascript and HTML width : I have an html text for example: <table cellspacing="0" width="50%" id='AAA' border='1' cellpadding="0" > <tr > <td width="5%"><div align="center">Nr. rd.</div></td> <td width="50%"><div align="center">Indicator</div></td> <td width="15%"><div align="center">Valoare</div></td> </tr> <tr > <td width="5%"><div align="center">A</div></td> <td width="50%"><div align="center">B</div></td> <td width="15%"><div align="center">1</div></td> </tr></table>, I want to extract width fro table $("#AAA") using javascript.
0debug
static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb) { int ret = -EOPNOTSUPP; BDRVRawState *s = aiocb->bs->opaque; if (s->has_discard == 0) { return 0; } if (aiocb->aio_type & QEMU_AIO_BLKDEV) { #ifdef BLKDISCARD do { uint64_t range[2] = { aiocb->aio_offset, aiocb->aio_nbytes }; if (ioctl(aiocb->aio_fildes, BLKDISCARD, range) == 0) { return 0; } } while (errno == EINTR); ret = -errno; #endif } else { #ifdef CONFIG_XFS if (s->is_xfs) { return xfs_discard(s, aiocb->aio_offset, aiocb->aio_nbytes); } #endif #ifdef CONFIG_FALLOCATE_PUNCH_HOLE do { if (fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, aiocb->aio_offset, aiocb->aio_nbytes) == 0) { return 0; } } while (errno == EINTR); ret = -errno; #endif } if (ret == -ENODEV || ret == -ENOSYS || ret == -EOPNOTSUPP || ret == -ENOTTY) { s->has_discard = 0; ret = 0; } return ret; }
1threat
In angular 2 im getting response from backend...an im looping it in *ngFor in the html file : In angular 2 after deleting of an item in *ngFor(The item is deleted in the back-End) the item is still visible in the view...DOM is not updating...After the page refresh, the item is not visible in the view...
0debug
AzCopy login fails : <p>After running <code>azcopy login</code> and signing in with my Azure account, I see the following response on the sign in page:</p> <p>“User account from identity provider does not exist in tenant ‘Microsoft’ and cannot access the application in that tenant. This account needs to be added as an external user in the tenant first. Sign out and sign back in again with a different Azure Active Directory user account.”</p> <p>Am I missing something like an App Registration?</p>
0debug
What's the better approach: serving static files with Express or nginx? : <p>I'm building a Node.js applications and I'm using nginx as a reverse proxy. My application has some static files I need to serve and a Socket.io server. </p> <p>I know that I can serve static files directly with Express (using express.static middleware). Also I can point nginx directly to the directory where my static files are located, so they would be served by nginx.</p> <p>So, the question: which one is the better approach? Which pros and cons can I face while using each approach?</p>
0debug
Create a list of texts which are seperated by '+' and '-' : I have a text in following manner `@@+aaa+bbb+ccc-asd-asdfg+hhh` I need to separate the text and save it in a list such that the entries of the list are 'aaa','bbb','ccc','asd','asdfg','hhh' <br> I did `$str = substr($str1,2); ` to remove the '@@'
0debug
Is there a difference between type signatures a -> b -> a and c -> a -> c? : <p>This question is a theoretical question about Haskell functions which can take arguments of any type. Is there a difference between the way functions with the type signatures of </p> <pre><code>a -&gt; b -&gt; a </code></pre> <p>and </p> <pre><code>c -&gt; a -&gt; c </code></pre> <p>are instantiated? Any help is appreciated.</p>
0debug
Can't login to GitHub from SourceTree anymore : <p>I was able to login up until today when it just stopped working. I'm using a Windows 7 machine. I have 2-factor authentication.</p> <p>I've tried personal access tokens. I've tried deleting my credentials and re-adding them. I've tried nuking and/or updating credentials in Windows Credentials Manager. I've tried OATH vs Basic authentication. No luck. It just keeps asking me for "Username or email" and "password". (Man, I hate that login prompt now.)</p> <p>I've tried changing my GitHub password. I've tried authenticating with OAuth (SourceTree says it's connected, but then I get the login screen again).</p> <p>Can anybody out there give me a list of steps to get back into our repo from SourceTree? I'm blocked now and unable to do work until I get this fixed.</p> <p>Thanks very much, Jeff</p>
0debug
Java Convert Integer combined with String amount to Integer : I have to use an int value "nid" to work on. But this int value should be an combination of int "did" and String "a"! int did = 123456; String a = "_b"; int nid = Integer.parseInt((did+a).toString()); But for this code i get the error message java.lang.NumberFormatException: For input string: "123456_b" Is there any way, to convert a combination of int and string to int?
0debug
How to get Leaflet for R use 100% of Shiny dashboard height : <p>I am in the process of creating a Shiny dashboard application, where the dashboard body is supposed to show some maps. So far no problem to get the map expand over the entire width of the body, but it's somehow not willing to adjust to the full height. <a href="https://i.stack.imgur.com/jxEEI.png"><img src="https://i.stack.imgur.com/jxEEI.png" alt="enter image description here"></a></p> <p>The leaflet itself is already set to cover 100% of the height, but it doesn't do the trick. As soon as I use the height attribute for the leafletOutput the leaflet object will not show at all, and I am left with an empty box.</p> <p>The code can be found below:</p> <pre><code>library(shinydashboard) library(leaflet) ui &lt;- dashboardPage( dashboardHeader(title = "Basic dashboard"), dashboardSidebar( sidebarMenu( menuItem( "Maps", tabName = "maps", icon = icon("globe"), menuSubItem("Watersheds", tabName = "m_water", icon = icon("map")), menuSubItem("Population", tabName = "m_pop", icon = icon("map")) ), menuItem( "Charts", tabName = "charts", icon = icon("bar-chart"), menuSubItem("Watersheds", tabName = "c_water", icon = icon("area-chart")), menuSubItem("Population", tabName = "c_pop", icon = icon("area-chart")) ) ) ), dashboardBody( tabItems( tabItem( tabName = "m_water", box( title = "Baltic catchment areas", collapsible = TRUE, width = "100%", height = "100%", leafletOutput("l_watershed") ) ), tabItem( tabName = "m_pop", # Map in Dashboard leafletOutput("l_population") ), tabItem( tabName = "charts", h2("Second tab content") ) ) ) ) server &lt;- function(input, output) { set.seed(122) histdata &lt;- rnorm(500) output$l_watershed &lt;- renderLeaflet({ leaflet(height = "100%") %&gt;% addTiles() %&gt;% setView(19.08, 60.25, zoom = 4) %&gt;%addWMSTiles( "http://62.236.121.188/arcgis/services/DataAndMaps/Background/MapServer/WMSServer?", layers = "11", options = WMSTileOptions( format = "image/png", transparent = TRUE ), attribution = "Catchment area provided by HELCOM" ) }) output$l_population &lt;- renderLeaflet({ leaflet(height = "100%") %&gt;% addTiles() %&gt;% setView(19.08, 60.25, zoom = 4) %&gt;%addWMSTiles( "http://62.236.121.188/arcgis/services/DataAndMaps/Background/MapServer/WMSServer?", layers = "17", options = WMSTileOptions( format = "image/png", transparent = TRUE ), attribution = "Population data provided by HELCOM" ) }) } shinyApp(ui, server) </code></pre>
0debug
static int restore_user_regs(CPUPPCState *env, struct target_mcontext *frame, int sig) { target_ulong save_r2 = 0; target_ulong msr; target_ulong ccr; int i; if (!sig) { save_r2 = env->gpr[2]; } for (i = 0; i < ARRAY_SIZE(env->gpr); i++) { if (__get_user(env->gpr[i], &frame->mc_gregs[i])) { return 1; } } if (__get_user(env->nip, &frame->mc_gregs[TARGET_PT_NIP]) || __get_user(env->ctr, &frame->mc_gregs[TARGET_PT_CTR]) || __get_user(env->lr, &frame->mc_gregs[TARGET_PT_LNK]) || __get_user(env->xer, &frame->mc_gregs[TARGET_PT_XER])) return 1; if (__get_user(ccr, &frame->mc_gregs[TARGET_PT_CCR])) return 1; for (i = 0; i < ARRAY_SIZE(env->crf); i++) { env->crf[i] = (ccr >> (32 - ((i + 1) * 4))) & 0xf; } if (!sig) { env->gpr[2] = save_r2; } if (__get_user(msr, &frame->mc_gregs[TARGET_PT_MSR])) return 1; if (sig) env->msr = (env->msr & ~MSR_LE) | (msr & MSR_LE); if (env->insns_flags & PPC_ALTIVEC) { for (i = 0; i < ARRAY_SIZE(env->avr); i++) { ppc_avr_t *avr = &env->avr[i]; ppc_avr_t *vreg = &frame->mc_vregs.altivec[i]; if (__get_user(avr->u64[0], &vreg->u64[0]) || __get_user(avr->u64[1], &vreg->u64[1])) { return 1; } } if (__get_user(env->spr[SPR_VRSAVE], (target_ulong *)(&frame->mc_vregs.altivec[32].u32[3]))) return 1; } if (env->insns_flags & PPC_FLOAT) { uint64_t fpscr; for (i = 0; i < ARRAY_SIZE(env->fpr); i++) { if (__get_user(env->fpr[i], &frame->mc_fregs[i])) { return 1; } } if (__get_user(fpscr, &frame->mc_fregs[32])) return 1; env->fpscr = (uint32_t) fpscr; } if (env->insns_flags & PPC_SPE) { #if defined(TARGET_PPC64) for (i = 0; i < ARRAY_SIZE(env->gpr); i++) { uint32_t hi; if (__get_user(hi, &frame->mc_vregs.spe[i])) { return 1; } env->gpr[i] = ((uint64_t)hi << 32) | ((uint32_t) env->gpr[i]); } #else for (i = 0; i < ARRAY_SIZE(env->gprh); i++) { if (__get_user(env->gprh[i], &frame->mc_vregs.spe[i])) { return 1; } } #endif if (__get_user(env->spe_fscr, &frame->mc_vregs.spe[32])) return 1; } return 0; }
1threat
Search creiteria using sql server : I need to create a procedure to return the matching criteria for the passed parameter from the table example parameter - The big related match from the table - The Big Bang The Big The big The big bang I can do the case sensitive search using collation The output should be "The big". It has to get the closest match possible Could anyone help me to get that?
0debug
Jekyll theme could not be found : <p>Following the jekyll documentation found here: <a href="https://jekyllrb.com/docs/themes/" rel="noreferrer">https://jekyllrb.com/docs/themes/</a> I was trying to install and change a gem based theme so I have chosen the jekyll-theme-primer for this and I've run the following command and instructed under the <a href="https://jekyllrb.com/docs/themes/#installing-a-theme" rel="noreferrer">https://jekyllrb.com/docs/themes/#installing-a-theme</a> section:</p> <pre><code>gem "jekyll-theme-primer" </code></pre> <p>and got this error:</p> <pre><code>ERROR: While executing gem ... (Gem::CommandLineError) Unknown command jekyll-theme-awesome </code></pre> <p>After doing some research I've found that I should have added <strong>install</strong> to my query as described here: <a href="https://stackoverflow.com/questions/10863576/while-executing-gem-unknown-command">While executing gem, unknown command</a></p> <p>After running this:</p> <pre><code>gem install "jekyll-theme-primer" </code></pre> <p>I successfully installed the primer gem based theme and got the following confirmation:</p> <pre><code>Successfully installed jekyll-theme-primer-0.5.2 Parsing documentation for jekyll-theme-primer-0.5.2 Done installing documentation for jekyll-theme-primer after 0 seconds 1 gem installed </code></pre> <p>First question: Was the official documentation incorrect or am I missing something?</p> <p>I proceeded to run the bundle install command:</p> <pre><code>bundle install </code></pre> <p>and replaced my current minima theme from the _config.yml with the jekyll-theme-primer by adding/replacing this line:</p> <pre><code>theme: jekyll-theme-primer </code></pre> <p>Now when I tried to run either the:</p> <pre><code>jekyll serve </code></pre> <p>or the:</p> <pre><code>bundle exec jekyll serve </code></pre> <p>commands, I get the following error:</p> <pre><code>jekyll 3.5.2 | Error: The jekyll-theme-primer theme could not be found. </code></pre> <p>So why it can't find the gem theme if the installation was successful?</p>
0debug
How to identify letter in an image using Python? : I'm trying to use OpenCV to identify the letters of an image. So far I'm reading the image > Applying Blur > Identifying the Edges of the letters, but for some of them it works well, but most of them I'm facing 2 kind of problems: 1. Sometimes the cv2.Canny() cannot identify all the letters, or just part of them (like the example below it is missing the last letter "d" and it is taking just part of the letter "m") 2. Some letters have a shadow below them and it is has been identifying as a edge and coming below the letter. [Original Image][1] [Processed Image][2] Code: `img = cv2.imread('.\\new_letters\\image.jpg', 0) blur = cv2.GaussianBlur(img,(5,5),0) edges = cv2.Canny(blur,20,60)` [1]: https://i.stack.imgur.com/NHxgb.jpg [2]: https://i.stack.imgur.com/DddcH.jpg Please I would like to ask you if you know how can I identify all the letter properly and how can I remove the lines created by the shadow of some letters?
0debug
static void RENAME(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dest, long width, long height, long src1Stride, long src2Stride, long dstStride) { long h; for (h=0; h < height; h++) { long w; #if COMPILE_TEMPLATE_MMX #if COMPILE_TEMPLATE_SSE2 __asm__( "xor %%"REG_a", %%"REG_a" \n\t" "1: \n\t" PREFETCH" 64(%1, %%"REG_a") \n\t" PREFETCH" 64(%2, %%"REG_a") \n\t" "movdqa (%1, %%"REG_a"), %%xmm0 \n\t" "movdqa (%1, %%"REG_a"), %%xmm1 \n\t" "movdqa (%2, %%"REG_a"), %%xmm2 \n\t" "punpcklbw %%xmm2, %%xmm0 \n\t" "punpckhbw %%xmm2, %%xmm1 \n\t" "movntdq %%xmm0, (%0, %%"REG_a", 2) \n\t" "movntdq %%xmm1, 16(%0, %%"REG_a", 2) \n\t" "add $16, %%"REG_a" \n\t" "cmp %3, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15) : "memory", "%"REG_a"" ); #else __asm__( "xor %%"REG_a", %%"REG_a" \n\t" "1: \n\t" PREFETCH" 64(%1, %%"REG_a") \n\t" PREFETCH" 64(%2, %%"REG_a") \n\t" "movq (%1, %%"REG_a"), %%mm0 \n\t" "movq 8(%1, %%"REG_a"), %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "movq (%2, %%"REG_a"), %%mm4 \n\t" "movq 8(%2, %%"REG_a"), %%mm5 \n\t" "punpcklbw %%mm4, %%mm0 \n\t" "punpckhbw %%mm4, %%mm1 \n\t" "punpcklbw %%mm5, %%mm2 \n\t" "punpckhbw %%mm5, %%mm3 \n\t" MOVNTQ" %%mm0, (%0, %%"REG_a", 2) \n\t" MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2) \n\t" MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2) \n\t" MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2) \n\t" "add $16, %%"REG_a" \n\t" "cmp %3, %%"REG_a" \n\t" " jb 1b \n\t" ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15) : "memory", "%"REG_a ); #endif for (w= (width&(~15)); w < width; w++) { dest[2*w+0] = src1[w]; dest[2*w+1] = src2[w]; } #else for (w=0; w < width; w++) { dest[2*w+0] = src1[w]; dest[2*w+1] = src2[w]; } #endif dest += dstStride; src1 += src1Stride; src2 += src2Stride; } #if COMPILE_TEMPLATE_MMX __asm__( EMMS" \n\t" SFENCE" \n\t" ::: "memory" ); #endif }
1threat
JavaScript: How do I concatenate two values from a single Object? : <p>I know this is simple but for whatever reason I'm completely stumped right now.</p> <p>I have an array of objects all with their own <code>month</code> and <code>year</code> properties and I'm trying to concatenate both from each object and then display them together. My data is as follows:</p> <pre><code>"caloriesBurned": [ { "month": "Nov", "year": "2018", "calories": 64.15 }, { "month": "Dec", "year": "2018", "calories": 75.07 } ] </code></pre>
0debug
static void rtas_ibm_write_pci_config(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { uint32_t val, size, addr; uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2); PCIDevice *dev = find_dev(spapr, buid, rtas_ld(args, 0)); if (!dev) { rtas_st(rets, 0, -1); return; } val = rtas_ld(args, 4); size = rtas_ld(args, 3); addr = rtas_pci_cfgaddr(rtas_ld(args, 0)); pci_default_write_config(dev, addr, val, size); rtas_st(rets, 0, 0); }
1threat
Javascript: function to convert an array object and its rewriting : When choosing a currency to convert all the price products according to what they choose and then defend the change in the page I want when I select a coin to convert the sum of all the products in the chunk and then to show the sum of each product The function must be written in javascript vanilla without jquery This is the list of objects let productsList = [ { imageURL: "https://s12emagst.akamaized.net/products/8096/8095064/images/res_689070343515d1e2bcd294526b17f3c8_200x200_gnvo.jpg", discount: "-15%", name: "Monitor LFD PHILIPS 4k", brand: "philips", colors: "black", stoc: "out stoc", review: "", type: "monitor", price: 70000 }, { imageURL: "https://s12emagst.akamaized.net/products/22044/22043004/images/res_b6ecd7bc761b9d80fcefe28923b1b756_200x200_59vo.jpg", discount: "", name: "Monitor LED Dell Curbat 4k", brand: "dell", colors: "black", stoc: "on stoc", review: "", type: "monitor", price: 49000 }]; This is the function that creates the cards function createCard(product) { let card = document.createElement('div'); card.className = 'card'; let box_d = document.createElement('div'); box_d.className = 'box-d'; box_d.innerHTML = product.discount; if (product.discount !== "") { card.appendChild(box_d); } let box_h = document.createElement('div'); box_h.className = 'box-h'; box_h.innerHTML = '<i class="fas fa-2x fa-heart" onclick="heartSlide()"></i>'; card.appendChild(box_h); let image = document.createElement('img'); image.className = 'card-img'; image.src = product.imageURL; card.appendChild(image); let review = document.createElement('div'); review.className = 'p-info'; review.innerHTML = 'Review: <span class="star"><i class="fas fa-star"></i><i class="fas fa-star"></i><i class="fas fa-star"></i><i class="fas fa-star"></i><i class="fas fa-star"></i></span>'; card.appendChild(review); let name = document.createElement('div'); name.className = 'p-info'; name.innerHTML = product.name; card.appendChild(name); let stoc = document.createElement('div'); stoc.className = 'p-info'; stoc.innerHTML = `Stoc: ${product.stoc}`; card.appendChild(stoc); let price = document.createElement('div'); price.className = 'p-info'; price.innerHTML = `Price: ${product.price} RON`; card.appendChild(price); let button = document.createElement('button'); button.className = 'add-btn'; button.innerHTML = 'Add to cart <i class="fas fa-shopping-cart an"></i>'; card.appendChild(button); return card; }
0debug
How to add an elasticsearch index during docker build : <p>I use the official elasticsearch docker image and wonder how can I include also during building a custom index, so that the index is already there when I start the container. </p> <p>My attempt was to add the following line to my dockerfile:</p> <pre><code>RUN curl -XPUT 'http://127.0.0.1:9200/myindex' -d @index.json </code></pre> <p>I get the following error: </p> <pre><code>0curl: (7) Failed to connect to 127.0.0.1 port 9200: Connection refused </code></pre> <p>Can I reach elasticsearch during build with such an API call or is there a complete different way to implement that? </p>
0debug
static void gain_scale(G723_1_Context *p, int16_t * buf, int energy) { int num, denom, gain, bits1, bits2; int i; num = energy; denom = 0; for (i = 0; i < SUBFRAME_LEN; i++) { int64_t temp = buf[i] >> 2; temp = av_clipl_int32(MUL64(temp, temp) << 1); denom = av_clipl_int32(denom + temp); } if (num && denom) { bits1 = normalize_bits(num, 31); bits2 = normalize_bits(denom, 31); num = num << bits1 >> 1; denom <<= bits2; bits2 = 5 + bits1 - bits2; bits2 = FFMAX(0, bits2); gain = (num >> 1) / (denom >> 16); gain = square_root(gain << 16 >> bits2); } else { gain = 1 << 12; } for (i = 0; i < SUBFRAME_LEN; i++) { p->pf_gain = (15 * p->pf_gain + gain + (1 << 3)) >> 4; buf[i] = av_clip_int16((buf[i] * (p->pf_gain + (p->pf_gain >> 4)) + (1 << 10)) >> 11); } }
1threat
importing an class from the same directory in Perl : <p>i have a directory with main.pl and Product.pl. in the main.pl i try to import the Product class but the execution fails when i run perl main.pl complaining that cant locate Product.pm in @INC. My directory is not in the @INC list. How can i fix this?</p>
0debug
Why unicode elements of lists would be hide? : <p>If I want to display Unicode elements as string correctly, why should I do, in the English language? </p>
0debug
static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) { int i, ret; AVDictionary *options = NULL; AVDictionaryEntry *entry; char *filename; char *format = NULL, *select = NULL; AVFormatContext *avf2 = NULL; AVStream *st, *st2; int stream_count; int fullret; char *subselect = NULL, *next_subselect = NULL, *first_subselect = NULL, *tmp_select = NULL; if ((ret = parse_slave_options(avf, slave, &options, &filename)) < 0) return ret; #define STEAL_OPTION(option, field) do { \ if ((entry = av_dict_get(options, option, NULL, 0))) { \ field = entry->value; \ entry->value = NULL; \ av_dict_set(&options, option, NULL, 0); \ } \ } while (0) STEAL_OPTION("f", format); STEAL_OPTION("select", select); ret = avformat_alloc_output_context2(&avf2, NULL, format, filename); if (ret < 0) goto end; av_dict_copy(&avf2->metadata, avf->metadata, 0); avf2->opaque = avf->opaque; avf2->io_open = avf->io_open; avf2->io_close = avf->io_close; tee_slave->stream_map = av_calloc(avf->nb_streams, sizeof(*tee_slave->stream_map)); if (!tee_slave->stream_map) { ret = AVERROR(ENOMEM); goto end; } stream_count = 0; for (i = 0; i < avf->nb_streams; i++) { st = avf->streams[i]; if (select) { tmp_select = av_strdup(select); if (!tmp_select) { ret = AVERROR(ENOMEM); goto end; } fullret = 0; first_subselect = tmp_select; next_subselect = NULL; while (subselect = av_strtok(first_subselect, slave_select_sep, &next_subselect)) { first_subselect = NULL; ret = avformat_match_stream_specifier(avf, avf->streams[i], subselect); if (ret < 0) { av_log(avf, AV_LOG_ERROR, "Invalid stream specifier '%s' for output '%s'\n", subselect, slave); goto end; } if (ret != 0) { fullret = 1; break; } } av_freep(&tmp_select); if (fullret == 0) { tee_slave->stream_map[i] = -1; continue; } } tee_slave->stream_map[i] = stream_count++; if (!(st2 = avformat_new_stream(avf2, NULL))) { ret = AVERROR(ENOMEM); goto end; } st2->id = st->id; st2->r_frame_rate = st->r_frame_rate; st2->time_base = st->time_base; st2->start_time = st->start_time; st2->duration = st->duration; st2->nb_frames = st->nb_frames; st2->disposition = st->disposition; st2->sample_aspect_ratio = st->sample_aspect_ratio; st2->avg_frame_rate = st->avg_frame_rate; av_dict_copy(&st2->metadata, st->metadata, 0); if ((ret = avcodec_parameters_copy(st2->codecpar, st->codecpar)) < 0) goto end; } if (!(avf2->oformat->flags & AVFMT_NOFILE)) { if ((ret = avf2->io_open(avf2, &avf2->pb, filename, AVIO_FLAG_WRITE, NULL)) < 0) { av_log(avf, AV_LOG_ERROR, "Slave '%s': error opening: %s\n", slave, av_err2str(ret)); goto end; } } if ((ret = avformat_write_header(avf2, &options)) < 0) { av_log(avf, AV_LOG_ERROR, "Slave '%s': error writing header: %s\n", slave, av_err2str(ret)); goto end; } tee_slave->avf = avf2; tee_slave->bsfs = av_calloc(avf2->nb_streams, sizeof(TeeSlave)); if (!tee_slave->bsfs) { ret = AVERROR(ENOMEM); goto end; } entry = NULL; while (entry = av_dict_get(options, "bsfs", NULL, AV_DICT_IGNORE_SUFFIX)) { const char *spec = entry->key + strlen("bsfs"); if (*spec) { if (strspn(spec, slave_bsfs_spec_sep) != 1) { av_log(avf, AV_LOG_ERROR, "Specifier separator in '%s' is '%c', but only characters '%s' " "are allowed\n", entry->key, *spec, slave_bsfs_spec_sep); return AVERROR(EINVAL); } spec++; } for (i = 0; i < avf2->nb_streams; i++) { ret = avformat_match_stream_specifier(avf2, avf2->streams[i], spec); if (ret < 0) { av_log(avf, AV_LOG_ERROR, "Invalid stream specifier '%s' in bsfs option '%s' for slave " "output '%s'\n", spec, entry->key, filename); goto end; } if (ret > 0) { av_log(avf, AV_LOG_DEBUG, "spec:%s bsfs:%s matches stream %d of slave " "output '%s'\n", spec, entry->value, i, filename); if (tee_slave->bsfs[i]) { av_log(avf, AV_LOG_WARNING, "Duplicate bsfs specification associated to stream %d of slave " "output '%s', filters will be ignored\n", i, filename); continue; } ret = parse_bsfs(avf, entry->value, &tee_slave->bsfs[i]); if (ret < 0) { av_log(avf, AV_LOG_ERROR, "Error parsing bitstream filter sequence '%s' associated to " "stream %d of slave output '%s'\n", entry->value, i, filename); goto end; } } } av_dict_set(&options, entry->key, NULL, 0); } if (options) { entry = NULL; while ((entry = av_dict_get(options, "", entry, AV_DICT_IGNORE_SUFFIX))) av_log(avf2, AV_LOG_ERROR, "Unknown option '%s'\n", entry->key); ret = AVERROR_OPTION_NOT_FOUND; goto end; } end: av_free(format); av_free(select); av_dict_free(&options); av_freep(&tmp_select); return ret; }
1threat
float32 helper_fabs_FT(float32 t0) { return float32_abs(t0); }
1threat
static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code) { DrawTextContext *s = ctx->priv; FT_BitmapGlyph bitmapglyph; Glyph *glyph; struct AVTreeNode *node = NULL; int ret; if (FT_Load_Char(s->face, code, s->ft_load_flags)) return AVERROR(EINVAL); if (!(glyph = av_mallocz(sizeof(*glyph))) || !(glyph->glyph = av_mallocz(sizeof(*glyph->glyph)))) { ret = AVERROR(ENOMEM); goto error; } glyph->code = code; if (FT_Get_Glyph(s->face->glyph, glyph->glyph)) { ret = AVERROR(EINVAL); goto error; } if (s->borderw) { FT_Glyph border_glyph = *glyph->glyph; if (FT_Glyph_StrokeBorder(&border_glyph, s->stroker, 0, 0) || FT_Glyph_To_Bitmap(&border_glyph, FT_RENDER_MODE_NORMAL, 0, 1)) { ret = AVERROR_EXTERNAL; goto error; } bitmapglyph = (FT_BitmapGlyph) border_glyph; glyph->border_bitmap = bitmapglyph->bitmap; } if (FT_Glyph_To_Bitmap(glyph->glyph, FT_RENDER_MODE_NORMAL, 0, 1)) { ret = AVERROR_EXTERNAL; goto error; } bitmapglyph = (FT_BitmapGlyph) *glyph->glyph; glyph->bitmap = bitmapglyph->bitmap; glyph->bitmap_left = bitmapglyph->left; glyph->bitmap_top = bitmapglyph->top; glyph->advance = s->face->glyph->advance.x >> 6; FT_Glyph_Get_CBox(*glyph->glyph, ft_glyph_bbox_pixels, &glyph->bbox); if (!(node = av_tree_node_alloc())) { ret = AVERROR(ENOMEM); goto error; } av_tree_insert(&s->glyphs, glyph, glyph_cmp, &node); if (glyph_ptr) *glyph_ptr = glyph; return 0; error: if (glyph) av_freep(&glyph->glyph); av_freep(&glyph); av_freep(&node); return ret; }
1threat
Attribute tag will not work in css as one of my selectors : <p>Is there any reason that this attribute tag a[h2]{color:orange;} wont work in css? I Cant seem to get the attribute tag to work for any elements.</p>
0debug
Node, when I run package.json `bin` `command` , give me `syntax error near unexpected token `(' ` : <p>when I run package.json <code>bin</code> <code>command</code> , give me <code>syntax error near unexpected token</code>(' ` .</p> <p><code>package.json</code>:</p> <pre><code> "bin": { "grabfilenames": "./index.js" } </code></pre> <p><code>npm link</code>:</p> <pre><code>/usr/local/bin/grabfilenames -&gt; /usr/local/lib/node_modules/grabfilename/index.js /usr/local/lib/node_modules/grabfilename -&gt; /Users/dulin/workspace/grabfilename </code></pre> <p>when I run my <code>cli</code>:</p> <p><code>grabfilenames -p /Users/dulin/workspace/learn-jquery</code></p> <p>give me an error: </p> <pre><code>/usr/local/bin/grabfilenames: line 1: syntax error near unexpected token `(' /usr/local/bin/grabfilenames: line 1: `const fs = require('fs');' </code></pre> <p>How to solve it? Thanks!</p>
0debug
Need to expand an inventory journal (log) pandas dataframe to include all dates per product id : <p>I have an inventory journal that contains products and their relative inventory qty (resulting_qty) as well as the loss/gain every time inventory is added or subtracted (delta_qty). </p> <p>The issue is that inventory records do not get updated daily, rather they are only updated when a change in inventory occurs. For this reason, it is difficult to extract the total inventory qty for all items on a given day, because some items are not recorded on certain days, despite the fact that they do have available inventory given their last entry resulting_qty was greater than 0. Logically, this would mean that an item went without a change in qty for a certain amount of days equal to the number of days between the max date and the last recorded date.</p> <p>my data looks something like this, except in reality there are thousands of product ids</p> <pre><code>| date | timestamp | pid | delta_qty | resulting_qty | |------------|---------------------|-----|-----------|---------------| | 2017-03-06 | 2017-03-06 12:24:22 | A | 0 | 0.0 | | 2017-03-31 | 2017-03-31 02:43:11 | A | 3 | 3.0 | | 2017-04-08 | 2017-04-08 22:04:35 | A | -1 | 2.0 | | 2017-04-12 | 2017-04-12 18:26:39 | A | -1 | 1.0 | | 2017-04-19 | 2017-04-19 09:15:38 | A | -1 | 0.0 | | 2019-01-16 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-19 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-05 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-22 | 2019-04-22 11:06:33 | B | -1 | 1.0 | | 2019-04-23 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-05-09 | 2019-05-09 16:25:41 | C | 2 | 2.0 | </code></pre> <p>Essentially, I need to make the data look something more like this so that I can simply pull a date and get the sum of total inventory for a given day when grouping by date (e.g. df.groupby(date).resulting_qty.sum()):</p> <p><strong><em>Note</strong> I removed the PID= A rows due to character limitations, but I hope you get the idea:</em></p> <pre><code>| date | timestamp | pid | delta_qty | resulting_qty | |------------|---------------------|-----|-----------|---------------| | 2019-01-16 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-17 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-18 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-19 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-20 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-21 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-22 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-23 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-24 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-25 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-26 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-27 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-28 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-29 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-30 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-01-31 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-01 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-02 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-03 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-04 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-05 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-06 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-07 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-08 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-09 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-10 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-11 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-12 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-13 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-14 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-15 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-16 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-17 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-18 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-19 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-20 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-21 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-22 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-23 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-24 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-25 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-26 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-27 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-02-28 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-01 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-02 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-03 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-04 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-05 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-06 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-07 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-08 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-09 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-10 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-11 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-12 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-13 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-14 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-15 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-16 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-17 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-18 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-19 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-20 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-21 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-22 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-23 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-24 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-25 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-26 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-27 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-28 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-29 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-30 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-03-31 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-04-01 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-04-02 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-04-03 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-04-04 | 2019-01-16 23:37:17 | B | 0 | 0.0 | | 2019-04-05 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-06 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-07 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-08 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-09 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-10 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-11 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-12 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-13 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-14 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-15 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-16 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-17 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-18 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-19 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-20 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-21 | 2019-04-05 16:40:32 | B | 2 | 2.0 | | 2019-04-22 | 2019-04-22 11:06:33 | B | -1 | 1.0 | | 2019-04-23 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-04-24 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-04-25 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-04-26 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-04-27 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-04-28 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-04-29 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-04-30 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-05-01 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-05-02 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-05-03 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-05-04 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-05-05 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-05-06 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-05-07 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-05-08 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-05-09 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-05-10 | 2019-04-23 13:23:17 | B | -1 | 0.0 | | 2019-01-19 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-01-20 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-01-21 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-01-22 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-01-23 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-01-24 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-01-25 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-01-26 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-01-27 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-01-28 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-01-29 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-01-30 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-01-31 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-01 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-02 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-03 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-04 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-05 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-06 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-07 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-08 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-09 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-10 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-11 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-12 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-13 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-14 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-15 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-16 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-17 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-18 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-19 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-20 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-21 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-22 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-23 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-24 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-25 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-26 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-27 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-02-28 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-01 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-02 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-03 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-04 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-05 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-06 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-07 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-08 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-09 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-10 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-11 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-12 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-13 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-14 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-15 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-16 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-17 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-18 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-19 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-20 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-21 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-22 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-23 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-24 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-25 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-26 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-27 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-28 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-29 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-30 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-03-31 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-01 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-02 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-03 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-04 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-05 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-06 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-07 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-08 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-09 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-10 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-11 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-12 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-13 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-14 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-15 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-16 | 2019-01-19 09:40:38 | C | 0 | 0.0 | | 2019-04-17 | 2019-01-19 09:40:38 | C | 0 | 0.0 | </code></pre> <p>So far what I've done was created a series of loops that generates a date range between the min date of the product lifecycle and the max date of all products. I then append the last recorded row values as a new row with a new date if there is no information for said new date. I append these to lists, and then generate a new dataframe with the updated lists. The code is terribly slow and takes 2+ hours to complete on the total dataset:</p> <pre><code>date_list = [] pid_list= [] time_stamp_list = [] delta_qty_list = [] resulting_qty_list = [] timer = len(test.product_id.unique().tolist()) counter = 0 for product in test.product_id.unique().tolist(): counter+=1 print((counter/timer)*100) temp_df = test.query(f'product_id=={product}', engine='python') for idx,date in enumerate(pd.date_range(temp_df.index.min(),test.index.max()).tolist()): min_date= temp_df.index.min() if date.date() == min_date: date2=min_date pid = temp_df.loc[date2]['product_id'] timestamp = temp_df.loc[date2]['timestamp'] delta_qty = temp_df.loc[date2]['delta_qty'] resulting_qty = temp_df.loc[date2]['resulting_qty'] date_list.append(date2) pid_list.append(pid) delta_qty_list.append(delta_qty) time_stamp_list.append(timestamp) resulting_qty_list.append(resulting_qty) else: if date.date() in temp_df.index: date2= date.date() pid = temp_df.loc[date2]['product_id'] timestamp = temp_df.loc[date2]['timestamp'] delta_qty = temp_df.loc[date2]['delta_qty'] resulting_qty = temp_df.loc[date2]['resulting_qty'] date_list.append(date2) pid_list.append(pid) delta_qty_list.append(delta_qty) time_stamp_list.append(timestamp) resulting_qty_list.append(resulting_qty) elif date.date() &gt; date2: date_list.append(date.date()) pid_list.append(pid) time_stamp_list.append(timestamp) delta_qty_list.append(delta_qty) resulting_qty_list.append(resulting_qty) else: pass </code></pre> <p>Can someone please help me to understand what is the right way I should approach this as I'm 100% sure this is not the best approach.</p> <p>Thank you</p>
0debug
void sws_rgb2rgb_init(int flags){ #if (defined(HAVE_MMX2) || defined(HAVE_3DNOW) || defined(HAVE_MMX)) && defined(CONFIG_GPL) if(flags & SWS_CPU_CAPS_MMX2) rgb2rgb_init_MMX2(); else if(flags & SWS_CPU_CAPS_3DNOW) rgb2rgb_init_3DNOW(); else if(flags & SWS_CPU_CAPS_MMX) rgb2rgb_init_MMX(); else #endif rgb2rgb_init_C(); }
1threat