problem
stringlengths
26
131k
labels
class label
2 classes
Android Studio delete line and duplicate line shortcuts : <p>What is the shortcut in Android Studio to delete a line? And what is the shortcut to duplicate a line? </p> <p><em>I found the answer in the <a href="https://developer.android.com/studio/intro/keyboard-shortcuts.html" rel="noreferrer">documentation</a> and I am posting it below for quick reference.</em></p>
0debug
static void ppc_heathrow_init (ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { CPUState *env = NULL, *envs[MAX_CPUS]; char *filename; qemu_irq *pic, **heathrow_irqs; int linux_boot, i; ram_addr_t ram_offset, bios_offset, vga_bios_offset; uint32_t kernel_base, initrd_base; int32_t kernel_size, initrd_size; PCIBus *pci_bus; MacIONVRAMState *nvr; int vga_bios_size, bios_size; int pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index; int escc_mem_index, ide_mem_index[2]; uint16_t ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; void *dbdma; uint8_t *vga_bios_ptr; linux_boot = (kernel_filename != NULL); if (cpu_model == NULL) cpu_model = "G3"; for (i = 0; i < smp_cpus; i++) { env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } cpu_ppc_tb_init(env, 16600000UL); env->osi_call = vga_osi_call; qemu_register_reset(&cpu_ppc_reset, env); envs[i] = env; } if (ram_size > (2047 << 20)) { fprintf(stderr, "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n", ((unsigned int)ram_size / (1 << 20))); exit(1); } ram_offset = qemu_ram_alloc(ram_size); cpu_register_physical_memory(0, ram_size, ram_offset); bios_offset = qemu_ram_alloc(BIOS_SIZE); if (bios_name == NULL) bios_name = PROM_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); cpu_register_physical_memory(PROM_ADDR, BIOS_SIZE, bios_offset | IO_MEM_ROM); if (filename) { bios_size = load_elf(filename, 0, NULL, NULL, NULL, 1, ELF_MACHINE, 0); qemu_free(filename); } else { bios_size = -1; } if (bios_size < 0 || bios_size > BIOS_SIZE) { hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name); exit(1); } vga_bios_offset = qemu_ram_alloc(VGA_BIOS_SIZE); vga_bios_ptr = qemu_get_ram_ptr(vga_bios_offset); filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, VGABIOS_FILENAME); if (filename) { vga_bios_size = load_image(filename, vga_bios_ptr + 8); qemu_free(filename); } else { vga_bios_size = -1; } if (vga_bios_size < 0) { fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", VGABIOS_FILENAME); vga_bios_size = 0; } else { vga_bios_ptr[0] = 'N'; vga_bios_ptr[1] = 'D'; vga_bios_ptr[2] = 'R'; vga_bios_ptr[3] = 'V'; cpu_to_be32w((uint32_t *)(vga_bios_ptr + 4), vga_bios_size); vga_bios_size += 8; vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK; } if (linux_boot) { uint64_t lowaddr = 0; int bswap_needed; #ifdef BSWAP_NEEDED bswap_needed = 1; #else bswap_needed = 0; #endif kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_elf(kernel_filename, kernel_base, NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); if (kernel_size > 0 && lowaddr != KERNEL_LOAD_ADDR) { kernel_size = load_elf(kernel_filename, (2 * kernel_base) - lowaddr, NULL, NULL, NULL, 1, ELF_MACHINE, 0); } if (kernel_size < 0) kernel_size = load_aout(kernel_filename, kernel_base, ram_size - kernel_base, bswap_needed, TARGET_PAGE_SIZE); if (kernel_size < 0) kernel_size = load_image_targphys(kernel_filename, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { hw_error("qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } if (initrd_filename) { initrd_base = INITRD_LOAD_ADDR; initrd_size = load_image_targphys(initrd_filename, initrd_base, ram_size - initrd_base); if (initrd_size < 0) { hw_error("qemu: could not load initial ram disk '%s'\n", initrd_filename); exit(1); } } else { initrd_base = 0; initrd_size = 0; } ppc_boot_device = 'm'; } else { kernel_base = 0; kernel_size = 0; initrd_base = 0; initrd_size = 0; ppc_boot_device = '\0'; for (i = 0; boot_device[i] != '\0'; i++) { #if 0 if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { ppc_boot_device = boot_device[i]; break; } #else if (boot_device[i] >= 'c' && boot_device[i] <= 'd') { ppc_boot_device = boot_device[i]; break; } #endif } if (ppc_boot_device == '\0') { fprintf(stderr, "No valid boot device for G3 Beige machine\n"); exit(1); } } isa_mem_base = 0x80000000; isa_mmio_init(0xfe000000, 0x00200000); heathrow_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *)); heathrow_irqs[0] = qemu_mallocz(smp_cpus * sizeof(qemu_irq) * 1); for (i = 0; i < smp_cpus; i++) { switch (PPC_INPUT(env)) { case PPC_FLAGS_INPUT_6xx: heathrow_irqs[i] = heathrow_irqs[0] + (i * 1); heathrow_irqs[i][0] = ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; break; default: hw_error("Bus model not supported on OldWorld Mac machine\n"); } } if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { hw_error("Only 6xx bus is supported on heathrow machine\n"); } pic = heathrow_pic_init(&pic_mem_index, 1, heathrow_irqs); pci_bus = pci_grackle_init(0xfec00000, pic); pci_vga_init(pci_bus, vga_bios_offset, vga_bios_size); escc_mem_index = escc_init(0x80013000, pic[0x0f], pic[0x10], serial_hds[0], serial_hds[1], ESCC_CLOCK, 4); for(i = 0; i < nb_nics; i++) pci_nic_init(&nd_table[i], "ne2k_pci", NULL); if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { fprintf(stderr, "qemu: too many IDE bus\n"); exit(1); } hd[0] = drive_get(IF_IDE, 0, 0); hd[1] = drive_get(IF_IDE, 0, 1); dbdma = DBDMA_init(&dbdma_mem_index); ide_mem_index[0] = -1; ide_mem_index[1] = pmac_ide_init(hd, pic[0x0D], dbdma, 0x16, pic[0x02]); hd[0] = drive_get(IF_IDE, 1, 0); hd[1] = drive_get(IF_IDE, 1, 1); hd[3] = hd[2] = NULL; pci_cmd646_ide_init(pci_bus, hd, 0); cuda_init(&cuda_mem_index, pic[0x12]); adb_kbd_init(&adb_bus); adb_mouse_init(&adb_bus); nvr = macio_nvram_init(&nvram_mem_index, 0x2000, 4); pmac_format_nvram_partition(nvr, 0x2000); macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem_index, dbdma_mem_index, cuda_mem_index, nvr, 2, ide_mem_index, escc_mem_index); if (usb_enabled) { usb_ohci_init_pci(pci_bus, -1); } if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) graphic_depth = 15; fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); 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, ARCH_HEATHROW); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); if (kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR); pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); } fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); }
1threat
Runnable jar pauses when on another window : <p>I made an simple java code to control a powerPoint presentation through hand motion with the help of an device called leap motion. The code works fine in Eclipse, but whenever I switch to an actual powerPoint slide my runnable jar pauses and stops doing what it's suppose to. How do I fix this problem??</p>
0debug
Regex for partial match of word? : <p>Is it possible to perform the following match?</p> <p><code>^do something$</code></p> <p>.. where matches are possible for a partially typed 'something'.</p> <p>For example:</p> <pre><code>^do s$ ^do so$ ^do som$ ^do some$ ^do somet$ ^do someth$ ^do somethi$ ^do somethin$ ^do something$ </code></pre> <p>Is it possible to do this with regex without having to string a bunch of logical ORs?</p>
0debug
static MemTxResult memory_region_write_accessor(MemoryRegion *mr, hwaddr addr, uint64_t *value, unsigned size, unsigned shift, uint64_t mask, MemTxAttrs attrs) { uint64_t tmp; tmp = (*value >> shift) & mask; if (mr->subpage) { trace_memory_region_subpage_write(get_cpu_index(), mr, addr, tmp, size); } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, size); } mr->ops->write(mr->opaque, addr, tmp, size); return MEMTX_OK; }
1threat
Perl grocery list program : I have an array of grocery items I need to buy and a hash with grocery items as keys and the cost of those items as the values. I need a program that will tell me the total cost of my bill based on what's available in the hash and for it to tell me the items that are not available. How should I go about doing this? I am new to programming so it's been pretty difficult..
0debug
How to create gifs with images in Python : <p>Are there any APIs or libraries I can use to create a .gif out of .jpgs and .pngs? I'm looking for one that will work with Python 3. </p>
0debug
static int mov_read_chpl(MOVContext *c, AVIOContext *pb, MOVAtom atom) { int64_t start; int i, nb_chapters, str_len, version; char str[256+1]; if ((atom.size -= 5) < 0) return 0; version = avio_r8(pb); avio_rb24(pb); if (version) avio_rb32(pb); nb_chapters = avio_r8(pb); for (i = 0; i < nb_chapters; i++) { if (atom.size < 9) return 0; start = avio_rb64(pb); str_len = avio_r8(pb); if ((atom.size -= 9+str_len) < 0) return 0; avio_read(pb, str, str_len); str[str_len] = 0; avpriv_new_chapter(c->fc, i, (AVRational){1,10000000}, start, AV_NOPTS_VALUE, str); } return 0; }
1threat
python get deeply nested key value without for loop : folks - I'm no-so-good with Python and am trying to directly query a key value from within a nested dictionary. Working with the following: "Items": { "Ingredients": { "M": { "sugar": { "S": "three quarters of a cup" I can get what I need by using a `for loop` but if I know the the key is named `sugar` how can I .get() to it directly? It seems like wasteful cycles to use the `for loop` when you already know what you want.
0debug
Via/ViaMat/to/toMat in Akka Stream : <p>Can someone explain clearly what are the difference between those 4 methods ? When is it more appropriate to use each one ? Also generally speaking what is the name of this Group of method? Are there more method that does the same job ? A link to the scaladoc could also help. </p> <p>-D-</p>
0debug
How to use Angular2 and Typescript in Jsfiddle : <p>Dummy question ...<br> I try to code an angular2 (2.0.0-beta.6) app in Typescript in jsfiddle.<br> I know that there is other solution online but ...<br> In fact, my example is very small and the problem is on import module : </p> <pre><code>import {bootstrap} from 'angular2/platform/browser' import {Component} from 'angular2/core'; </code></pre> <p>I got the following error : </p> <pre><code>Uncaught ReferenceError: System is not defined Uncaught ReferenceError: require is not defined </code></pre> <p>I try to add some dependencies (require, system ...) but it doesn't work.<br> And there is no more Self-Executing bundle for recent version (beta-6) of Angular2 (angular2.sfx.dev.js).</p> <p>Some tests :<br> <a href="https://jsfiddle.net/asicfr/q8bwosfn/1/">https://jsfiddle.net/asicfr/q8bwosfn/1/</a><br> <a href="https://jsfiddle.net/asicfr/q8bwosfn/3/">https://jsfiddle.net/asicfr/q8bwosfn/3/</a><br> <a href="https://jsfiddle.net/asicfr/q8bwosfn/4/">https://jsfiddle.net/asicfr/q8bwosfn/4/</a><br> <a href="https://jsfiddle.net/asicfr/q8bwosfn/5/">https://jsfiddle.net/asicfr/q8bwosfn/5/</a><br> <a href="https://jsfiddle.net/asicfr/q8bwosfn/6/">https://jsfiddle.net/asicfr/q8bwosfn/6/</a> </p>
0debug
What is open jdk in android studio : <p>open jdk hogging my ram what is it i have android studio 3.0.1 , i already installed Java <code>JDK</code></p> <p><a href="https://i.stack.imgur.com/iZnK6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iZnK6.png" alt="enter image description here"></a></p>
0debug
separate an array of arrays in Swift : and thank you for your help in advance! I have an array of arrays of strings [[String]]. I want to reverse each of the array elements. var players = [["A","B","C","D"],["E","F","G","H"], ["J","K","L","M"]] I want to reverse each of the individual array elements such that the result is ["D","C","B","A"], ["H","G","F","E"], ["M","L","K","J"]
0debug
static void pci_update_mappings(PCIDevice *d) { PCIIORegion *r; int i; pcibus_t new_addr; for(i = 0; i < PCI_NUM_REGIONS; i++) { r = &d->io_regions[i]; if (!r->size) continue; new_addr = pci_bar_address(d, i, r->type, r->size); if (new_addr == r->addr) continue; if (r->addr != PCI_BAR_UNMAPPED) { trace_pci_update_mappings_del(d, pci_bus_num(d->bus), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn), i, r->addr, r->size); memory_region_del_subregion(r->address_space, r->memory); } r->addr = new_addr; if (r->addr != PCI_BAR_UNMAPPED) { trace_pci_update_mappings_add(d, pci_bus_num(d->bus), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn), i, r->addr, r->size); memory_region_add_subregion_overlap(r->address_space, r->addr, r->memory, 1); } } pci_update_vga(d); }
1threat
Logging setLevel is being ignored : <p>The below code is copied from the documentation. I am supposed to be able to see all the info logs. But I don't. I am only able to see the warn and above even though I've set setLevel to INFO.</p> <p>Why is this happening? <code>foo.py</code>:</p> <pre><code>import logging logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) logger.debug('debug message') logger.info('info message') logger.warn('warn message') logger.error('error message') logger.critical('critical message') </code></pre> <p>Output:</p> <pre><code>workingDirectory$ python foo.py warn message error message critical message </code></pre> <p>Where did the info and debug messages go??</p>
0debug
static void do_interrupt_v7m(CPUARMState *env) { uint32_t xpsr = xpsr_read(env); uint32_t lr; uint32_t addr; lr = 0xfffffff1; if (env->v7m.current_sp) lr |= 4; if (env->v7m.exception == 0) lr |= 8; switch (env->exception_index) { case EXCP_UDEF: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); return; case EXCP_SWI: env->regs[15] += 2; armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC); return; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM); return; case EXCP_BKPT: if (semihosting_enabled) { int nr; nr = lduw_code(env->regs[15]) & 0xff; if (nr == 0xab) { env->regs[15] += 2; env->regs[0] = do_arm_semihosting(env); return; } } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG); return; case EXCP_IRQ: env->v7m.exception = armv7m_nvic_acknowledge_irq(env->nvic); break; case EXCP_EXCEPTION_EXIT: do_v7m_exception_exit(env); return; default: cpu_abort(env, "Unhandled exception 0x%x\n", env->exception_index); return; } if (env->regs[13] & 4) { env->regs[13] -= 4; xpsr |= 0x200; } v7m_push(env, xpsr); v7m_push(env, env->regs[15]); v7m_push(env, env->regs[14]); v7m_push(env, env->regs[12]); v7m_push(env, env->regs[3]); v7m_push(env, env->regs[2]); v7m_push(env, env->regs[1]); v7m_push(env, env->regs[0]); switch_v7m_sp(env, 0); env->condexec_bits = 0; env->regs[14] = lr; addr = ldl_phys(env->v7m.vecbase + env->v7m.exception * 4); env->regs[15] = addr & 0xfffffffe; env->thumb = addr & 1; }
1threat
C Programming Rock-Paper-Scissors Not Working : <p>I'm having a problem with this C Programming activity. I'm new to C-Programming and would really like to ask you guys for your help. So please bear with me.</p> <p>So here's the problem...</p> <p>When I run the program as I enter my choice for Player Two the program automatically stops and closes. It wont even let me press "ENTER" before it closes. I tried everything else I can and looked for a solution online but to no avail. I am only allowed to use the conditional statement If-Else for this. I would really appreciate any suggestions. Thanks in advance. </p> <pre><code>#include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(){ clrscr(); char one, two; printf("\t\t\t Rock-Paper-Scissors\n"); printf("Choose from the following:\n"); printf("r for Rock\np for Paper\ns for Scissors\n\n"); printf("Player One enter your choice: "); scanf("%c",&amp;one); printf("Player Two enter your choice: "); scanf("%c",&amp;two); printf("\n"); //rock over scissors if (one == 'r' &amp;&amp; two == 's'){ printf("Rock Destroys Scissors\n"); printf("Player One Wins!"); } else if (two == 'r' &amp;&amp; one == 's'){ printf("Rock Destroys Scissors\n"); printf("Player Two Wins!"); } //paper over rock else if (one == 'p' &amp;&amp; two == 'r'){ printf("Paper Covers Rock\n"); printf("Player One Wins!"); } else if (two == 'p' &amp;&amp; one == 'r'){ printf("Paper Covers Rock\n"); printf("Player Two Wins!"); } //scissors over paper else if (one == 's' &amp;&amp; two == 'p'){ printf("Scissors Cut Paper\n"); printf("Player One Wins!"); } else if (two == 's' &amp;&amp; one == 'p'){ printf("Scissors Cut Paper\n"); printf("Player Two Wins!"); } else printf("It's a Tie!"); getch(); } </code></pre>
0debug
Xss when I save html document : <p>When entering</p> <pre><code>&lt;script&gt;alert(1)&lt;/script&gt; </code></pre> <p>The resulting Html after submitting is</p> <pre><code>&lt;form action="/action_page.php" novalidate&gt; E-mail: &lt;input type="email" Id="user_email"&gt;"&lt;script&gt;alert(1)&lt;/script&gt; &lt;input type="submit"&gt; &lt;/form&gt; </code></pre> <p>And the xss not triggered. If I replace the payload with </p> <pre><code>&lt;img src=xss onerror=alert(1)&gt; </code></pre> <p>Xss triggered! this xss happening with the id attribute! In browsers.</p> <p>So I want to know 2 thing.</p> <ol> <li><p>If this is a vulnerability then how an attacker can use it. I mean what payload would be used. Cause xss happening with <code>Id=</code> attribute</p></li> <li><p>If this is a vulnerability. How can I fix it? </p></li> </ol> <p>I am a beginner. I will be happy if you guys answer my question. </p> <p>Thanks.</p>
0debug
static void *alloc_buffer(FFVAContext *vactx, int type, unsigned int size, uint32_t *buf_id) { void *data = NULL; *buf_id = 0; if (vaCreateBuffer(vactx->display, vactx->context_id, type, size, 1, NULL, buf_id) == VA_STATUS_SUCCESS) vaMapBuffer(vactx->display, *buf_id, &data); return data; }
1threat
Regular expression (regex) help: Need to delete everything on several lines after an IP address : <p>I have several lines that are</p> <p>192.168.86.3 0x1 0x2 3cbbaxrad * br-lan 192.168.86.213 0x1 0x2 3cccfargarad * br-lan 192.168.86.51 0x1 0x2 3cccfcvrad * br-lan 192.168.86.11 0x1 0x2 3cccfxxrad * br-lan</p> <p>I need to extract only the ip addresses so it's 192.168.86.3 192.168.86.213 192.168.86.51 192.168.86.11</p> <p>Can anyone help? Thanks</p>
0debug
void net_host_device_add(Monitor *mon, const char *device, const char *opts) { if (!net_host_check_device(device)) { monitor_printf(mon, "invalid host network device %s\n", device); return; } if (net_client_init(device, opts ? : "") < 0) { monitor_printf(mon, "adding host network device %s failed\n", device); } }
1threat
Java with input first letter number then output inclue number words : am jst starting on Java, need to have output where if input is put in using Scanner class. Have tried the following: } else if (first.charAt(0) == 1++) { String str = ""; for (int i = 1++ ; i < first.length(i); i = i charAt(i)) { str += first.charAt(i); } first = str; An example, if user inputs "3stars", output would be "3st", or input "7appendices" output would be "7append". Any help would be great.
0debug
Algorithm to find winner of tic tac toe : <p>What is the best optimal way to find out the winner in 3x3 Tic tac toe game where board is represented by a matrix ? Suggestions please</p>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
static void intra_predict_horiz_16x16_msa(uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride) { uint32_t row; uint8_t inp0, inp1, inp2, inp3; v16u8 src0, src1, src2, src3; for (row = 4; row--;) { inp0 = src[0]; src += src_stride; inp1 = src[0]; src += src_stride; inp2 = src[0]; src += src_stride; inp3 = src[0]; src += src_stride; src0 = (v16u8) __msa_fill_b(inp0); src1 = (v16u8) __msa_fill_b(inp1); src2 = (v16u8) __msa_fill_b(inp2); src3 = (v16u8) __msa_fill_b(inp3); ST_UB4(src0, src1, src2, src3, dst, dst_stride); dst += (4 * dst_stride); } }
1threat
When to use F#'s typedefof<'T> vs. typeof<'T>? : <p>Can someone clarify when to use <a href="https://msdn.microsoft.com/en-us/visualfsharpdocs/conceptual/operators.typedefof%5B&#39;t%5D-type-function-%5Bfsharp%5D" rel="noreferrer">typedefof&lt;'T></a> vs. <a href="https://msdn.microsoft.com/en-us/visualfsharpdocs/conceptual/operators.typeof%5B&#39;t%5D-type-function-%5Bfsharp%5D" rel="noreferrer">typeof&lt;'T></a>?</p> <p>Both <code>typedefof&lt;System.String&gt;</code> and <code>typeof&lt;System.String&gt;</code> return the same <code>Type</code> instance.</p> <p>However, they return different instances and different information for <code>System.Collections.Generic.List&lt;_&gt;</code>.</p> <p>Can I think of <code>typedefof</code> as a new and improved <code>typeof</code>? Should I just switch to always using <code>typedefof</code>? Or is it more subtle than that?</p>
0debug
Using clang-format in CLion : <p>I'd like to format my code using clang-format in CLion. I've gone through the settings and haven't found any setting that would allow me to run an external command to transform code. How are such things normally done in CLion?</p>
0debug
static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs, bool want_zero, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map, BlockDriverState **file) { int64_t total_size; int64_t n; int ret; int64_t local_map = 0; BlockDriverState *local_file = NULL; int64_t aligned_offset, aligned_bytes; uint32_t align; assert(pnum); *pnum = 0; total_size = bdrv_getlength(bs); if (total_size < 0) { ret = total_size; goto early_out; } if (offset >= total_size) { ret = BDRV_BLOCK_EOF; goto early_out; } if (!bytes) { ret = 0; goto early_out; } n = total_size - offset; if (n < bytes) { bytes = n; } if (!bs->drv->bdrv_co_get_block_status) { *pnum = bytes; ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED; if (offset + bytes == total_size) { ret |= BDRV_BLOCK_EOF; } if (bs->drv->protocol_name) { ret |= BDRV_BLOCK_OFFSET_VALID; local_map = offset; local_file = bs; } goto early_out; } bdrv_inc_in_flight(bs); align = MAX(bs->bl.request_alignment, BDRV_SECTOR_SIZE); aligned_offset = QEMU_ALIGN_DOWN(offset, align); aligned_bytes = ROUND_UP(offset + bytes, align) - aligned_offset; { int count; int64_t longret; assert(QEMU_IS_ALIGNED(aligned_offset | aligned_bytes, BDRV_SECTOR_SIZE)); longret = bs->drv->bdrv_co_get_block_status( bs, aligned_offset >> BDRV_SECTOR_BITS, MIN(INT_MAX, aligned_bytes) >> BDRV_SECTOR_BITS, &count, &local_file); if (longret < 0) { assert(INT_MIN <= longret); ret = longret; goto out; } if (longret & BDRV_BLOCK_OFFSET_VALID) { local_map = longret & BDRV_BLOCK_OFFSET_MASK; } ret = longret & ~BDRV_BLOCK_OFFSET_MASK; *pnum = count * BDRV_SECTOR_SIZE; } assert(QEMU_IS_ALIGNED(*pnum, align) && align > offset - aligned_offset); *pnum -= offset - aligned_offset; if (*pnum > bytes) { *pnum = bytes; } if (ret & BDRV_BLOCK_OFFSET_VALID) { local_map += offset - aligned_offset; } if (ret & BDRV_BLOCK_RAW) { assert(ret & BDRV_BLOCK_OFFSET_VALID && local_file); ret = bdrv_co_block_status(local_file, want_zero, local_map, *pnum, pnum, &local_map, &local_file); goto out; } if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) { ret |= BDRV_BLOCK_ALLOCATED; } else if (want_zero) { if (bdrv_unallocated_blocks_are_zero(bs)) { ret |= BDRV_BLOCK_ZERO; } else if (bs->backing) { BlockDriverState *bs2 = bs->backing->bs; int64_t size2 = bdrv_getlength(bs2); if (size2 >= 0 && offset >= size2) { ret |= BDRV_BLOCK_ZERO; } } } if (want_zero && local_file && local_file != bs && (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) && (ret & BDRV_BLOCK_OFFSET_VALID)) { int64_t file_pnum; int ret2; ret2 = bdrv_co_block_status(local_file, want_zero, local_map, *pnum, &file_pnum, NULL, NULL); if (ret2 >= 0) { if (ret2 & BDRV_BLOCK_EOF && (!file_pnum || ret2 & BDRV_BLOCK_ZERO)) { ret |= BDRV_BLOCK_ZERO; } else { *pnum = file_pnum; ret |= (ret2 & BDRV_BLOCK_ZERO); } } } out: bdrv_dec_in_flight(bs); if (ret >= 0 && offset + *pnum == total_size) { ret |= BDRV_BLOCK_EOF; } early_out: if (file) { *file = local_file; } if (map) { *map = local_map; } return ret; }
1threat
python output for addition : <p>I'm new to python (version 2.7) and I want to know how I can input two numbers on a single line and calculate the sum of both numbers. I'm looking for the output to read like this:</p> <p>11 + 11 = 22</p> <p>The input would look like this: </p> <p>11 11 </p>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
Trying to read the text of an FTP website into a string in pythong : <p>This is the site I can open in Chrome and see text:</p> <p><a href="ftp://ftp.cmegroup.com/pub/settle/stlags" rel="nofollow noreferrer">ftp://ftp.cmegroup.com/pub/settle/stlags</a></p> <p>Any idea how to read this into a string in python?</p>
0debug
static int emulated_initfn(CCIDCardState *base) { EmulatedState *card = DO_UPCAST(EmulatedState, base, base); VCardEmulError ret; const EnumTable *ptable; QSIMPLEQ_INIT(&card->event_list); QSIMPLEQ_INIT(&card->guest_apdu_list); qemu_mutex_init(&card->event_list_mutex); qemu_mutex_init(&card->vreader_mutex); qemu_mutex_init(&card->handle_apdu_mutex); qemu_cond_init(&card->handle_apdu_cond); card->reader = NULL; card->quit_apdu_thread = 0; if (init_pipe_signaling(card) < 0) { return -1; } card->backend = parse_enumeration(card->backend_str, backend_enum_table, 0); if (card->backend == 0) { printf("unknown backend, must be one of:\n"); for (ptable = backend_enum_table; ptable->name != NULL; ++ptable) { printf("%s\n", ptable->name); } return -1; } if (card->backend == BACKEND_CERTIFICATES) { if (card->cert1 != NULL && card->cert2 != NULL && card->cert3 != NULL) { ret = emulated_initialize_vcard_from_certificates(card); } else { printf("%s: you must provide all three certs for" " certificates backend\n", EMULATED_DEV_NAME); return -1; } } else { if (card->backend != BACKEND_NSS_EMULATED) { printf("%s: bad backend specified. The options are:\n%s (default)," " %s.\n", EMULATED_DEV_NAME, BACKEND_NSS_EMULATED_NAME, BACKEND_CERTIFICATES_NAME); return -1; } if (card->cert1 != NULL || card->cert2 != NULL || card->cert3 != NULL) { printf("%s: unexpected cert parameters to nss emulated backend\n", EMULATED_DEV_NAME); return -1; } ret = wrap_vcard_emul_init(NULL); } if (ret != VCARD_EMUL_OK) { printf("%s: failed to initialize vcard\n", EMULATED_DEV_NAME); return -1; } qemu_thread_create(&card->event_thread_id, event_thread, card, QEMU_THREAD_JOINABLE); qemu_thread_create(&card->apdu_thread_id, handle_apdu_thread, card, QEMU_THREAD_JOINABLE); return 0; }
1threat
How I Print pyramid reverse : my code print this 1 123 12345 1234567 int a = 1; int b = 4; for (int i = 1 ; i <= 4 ; i++){ for (int c = 1 ; c <= b - 1 ; c++){ text.append(" "); } for (int k = 1 ; k <= a ; k++){ String result = String.valueOf(k); text.append(result); } a = a + 2; b--; text.append("\n"); } but i have to print this type of number 1234567 12345 123 1 please advice
0debug
Swap 2 variables with XOR : I am trying to swap 2 variables with XOR operation. `int a = 5; int b = 4; a ^= b ^= a ^= b;` This code works in objective c and c++, but doesnt work in C# and js, and I cant understand the reason.
0debug
static inline void qpel_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int field_based, int bottom_field, int field_select, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16], int motion_x, int motion_y, int h) { uint8_t *ptr_y, *ptr_cb, *ptr_cr; int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y, v_edge_pos; ptrdiff_t linesize, uvlinesize; dxy = ((motion_y & 3) << 2) | (motion_x & 3); src_x = s->mb_x * 16 + (motion_x >> 2); src_y = s->mb_y * (16 >> field_based) + (motion_y >> 2); v_edge_pos = s->v_edge_pos >> field_based; linesize = s->linesize << field_based; uvlinesize = s->uvlinesize << field_based; if (field_based) { mx = motion_x / 2; my = motion_y >> 1; } else if (s->workaround_bugs & FF_BUG_QPEL_CHROMA2) { static const int rtab[8] = { 0, 0, 1, 1, 0, 0, 0, 1 }; mx = (motion_x >> 1) + rtab[motion_x & 7]; my = (motion_y >> 1) + rtab[motion_y & 7]; } else if (s->workaround_bugs & FF_BUG_QPEL_CHROMA) { mx = (motion_x >> 1) | (motion_x & 1); my = (motion_y >> 1) | (motion_y & 1); } else { mx = motion_x / 2; my = motion_y / 2; } mx = (mx >> 1) | (mx & 1); my = (my >> 1) | (my & 1); uvdxy = (mx & 1) | ((my & 1) << 1); mx >>= 1; my >>= 1; uvsrc_x = s->mb_x * 8 + mx; uvsrc_y = s->mb_y * (8 >> field_based) + my; ptr_y = ref_picture[0] + src_y * linesize + src_x; ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x; ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x; if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 3) - 16, 0) || (unsigned)src_y > FFMAX(v_edge_pos - (motion_y & 3) - h, 0)) { s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y, s->linesize, s->linesize, 17, 17 + field_based, src_x, src_y << field_based, s->h_edge_pos, s->v_edge_pos); ptr_y = s->sc.edge_emu_buffer; if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { uint8_t *uvbuf = s->sc.edge_emu_buffer + 18 * s->linesize; s->vdsp.emulated_edge_mc(uvbuf, ptr_cb, s->uvlinesize, s->uvlinesize, 9, 9 + field_based, uvsrc_x, uvsrc_y << field_based, s->h_edge_pos >> 1, s->v_edge_pos >> 1); s->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr, s->uvlinesize, s->uvlinesize, 9, 9 + field_based, uvsrc_x, uvsrc_y << field_based, s->h_edge_pos >> 1, s->v_edge_pos >> 1); ptr_cb = uvbuf; ptr_cr = uvbuf + 16; } } if (!field_based) qpix_op[0][dxy](dest_y, ptr_y, linesize); else { if (bottom_field) { dest_y += s->linesize; dest_cb += s->uvlinesize; dest_cr += s->uvlinesize; } if (field_select) { ptr_y += s->linesize; ptr_cb += s->uvlinesize; ptr_cr += s->uvlinesize; } qpix_op[1][dxy](dest_y, ptr_y, linesize); qpix_op[1][dxy](dest_y + 8, ptr_y + 8, linesize); } if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { pix_op[1][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> 1); pix_op[1][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> 1); } }
1threat
What's the substitute for ::shadow and /deep/? : <p>The two shadow-piercing combinators have been deprecated as stated in <a href="https://www.chromestatus.com/features/6750456638341120" rel="noreferrer">https://www.chromestatus.com/features/6750456638341120</a><br>Then what's the substitude for achieving the same thing, or this shadow-piercing feature has been completely abandoned?</p>
0debug
What is Android Test Orchestrator? : <p>Google released Android Testing Support Library 1.0 recently. After reading the <a href="https://android-developers.googleblog.com/2017/07/android-testing-support-library-10-is.html" rel="noreferrer">overview</a>, I'm a little confused with Android Test Orchestrator.</p> <p>It said </p> <blockquote> <p>Typically, AndroidJUnitRunner runs all tests in the same instrumentation process, which can cause a number of problems.</p> </blockquote> <p>Can you explain which kinds of problems will be caused by using the same instrumentation process?</p> <blockquote> <p>if one test crashes, it prevents the remainder of the test suite from running</p> </blockquote> <p>Through my experience, one test crash won't prevent from other test cases from running. Please point out what I misunderstood here?</p> <p>And from <a href="https://developer.android.com/training/testing/junit-runner.html#using-android-test-orchestrator" rel="noreferrer">Android Testing Orchestrator developer guide</a>,</p> <blockquote> <p>For completeness, Android Test Orchestrator runs pm clear after each test.</p> </blockquote> <p>So Android Test Orchestrator will run <strong>pm clear [test_package_name]</strong> after each test, right?</p> <p>Through my test, <strong>pm clear [app_package_name]</strong> won't be executed after each test. That means the data of application under test will not be cleared. So test cases might still have dependencies on each other. For example:</p> <ul> <li>Test case A stores a SharedPreference key-value</li> <li>Test case B which runs after test case A can read out the value stored by test case A</li> </ul> <p>Overall, after some trial, I did not find any advantage of Android Test Orchestrator. Can somebody help to address my confusion? Thanks.</p>
0debug
How do I specify a clang-format file? : <p>I just built clang 5.0.0 on a Redhat 6 machine and tried to run clang-format. I'm unable to get the -style option to read in a style file. Here's an example of a set of commands that I think should work:</p> <pre><code>./clang-format -style=llvm -dump-config &gt; .llvm-format ./clang-format -style=.llvm-format ~/myFile.cc </code></pre> <p>When I run this command I get the following error:</p> <pre><code>Invalid value for -style </code></pre> <p>It appears to find and use .clang-format when placed in a parent directory as expect. The built-in types also work:</p> <pre><code>./clang-format -style=Mozilla ~/myFile.cc </code></pre> <p>The problem, then, is that I can't specify explicitly a .clang-format file to use. Is this a problem with my build or am I misusing clang-format oir misunderstanding the documentation?</p>
0debug
i'm trying to apply ajax to my tbody only not all table : 1- i`m trying to apply Ajax to my tbody only not all my table but i can`t do this the ajax working good if i put my complete table in page. i want to split my table header & tbady to be in separated page. the following code is ajax : `function jsQueryData(){ var objData = { action : actionSplit0 +'/QueryData', }; $.post( index_File, objData, function(data, status){ $('#table-container').html(data) }, 'html' )}` 2- this is the code of my table "if i put the table code completely in one page the ajax working good": <table class="table table-striped table-bordered table-hover main-table-h"> <thead> <tr> <td scope="col" class="search-th"> <input type="text" name="" value=""> <!-- for search --> </td> </tr> <tr> <th scope="col" class="align-top">item no</th> </tr> </thead> <tbody> <?php foreach ($allData1 as $data): ?> <tr> <td><?=$data->{2}; ?></td> </tr> <?php endforeach; ?> </tbody> </table> 3- i tried to split the above code to be tbody in separate page but the data didn't come as a table but all td come together
0debug
how to pass the href variable to the switch case : i have four links which are redirected on the same page only there variables are different for eg: <a href="tab1.php?type=square">Square</a> <a href="tab1.php?type=circle">Circle</a> <a href="tab2.php?type=triangle">Triangle</a> <a href="tab3.php?type=rectangle">Rectangle</a> i want to write a switch case to pass the href variables so that if the type is square it should alert me that it is a square and similarly for the others.
0debug
About lambdas, conversions to function pointers and visibility of private data members : <p>Consider the following example:</p> <pre><code>#include &lt;cassert&gt; struct S { auto func() { return +[](S &amp;s) { s.x++; }; } int get() { return x; } private: int x{0}; }; int main() { S s; s.func()(s); assert(s.get() == 1); } </code></pre> <p>It compiles both with G++ and clang, so I'm tempted to expect that is allowed by the standard. However, the lambda has no capture list and it cannot have it because of the <code>+</code> that forces the conversion to a function pointer. Therefore, I expected it was not allowed to access private data members of <code>S</code>.<br> Instead, it behaves more or less how if it was defined as a static member function.</p> <p>So far, so good. If I knew it before, I would have used this trick often to avoid writing redundant code.</p> <p>What I'd like to know now is where in the standard (the working draft is fine) this is defined, for I've not been able to find the section, the bullet or whatever that rules about it.<br> Is there any limitation for the lambda or it works <em>exactly</em> as if it was defined as a static member function?</p>
0debug
static int dnxhd_init_rc(DNXHDEncContext *ctx) { CHECKED_ALLOCZ(ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry)); if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD) CHECKED_ALLOCZ(ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry)); ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4) * 8; ctx->qscale = 1; ctx->lambda = 2<<LAMBDA_FRAC_BITS; return 0; fail: return -1; }
1threat
Get current app's build version - Xamarin.Android : <p>I need to display the app's build version in my settings page.</p> <p>So how can i get the <code>versionCode</code> and <code>versionName</code> from <code>AndroidManifest.xml</code> file programmatically.</p> <p>Or</p> <p>Is there any way to get the build version programmatically in <code>xamarin.forms</code>.</p>
0debug
void stw_be_phys(target_phys_addr_t addr, uint32_t val) { stw_phys_internal(addr, val, DEVICE_BIG_ENDIAN); }
1threat
Using JSON.stringify in conjunction with TypeScript getter/setter : <p>I am using getter/setter accessors in TypeScript. As it is not possible to have the same name for a variable and method, I started to prefix the variable with a lower dash, as is done in many examples:</p> <pre><code>private _major: number; get major(): number { return this._major; } set major(major: number) { this._major = major; } </code></pre> <p>Now when I use the JSON.stringify() method to convert the object into a JSON string, it will use the variable name as the key: _major.</p> <p>As I don't want the JSON file to have all keys prefixed with a lower dash, is there any possibility to make TypeScript use the name of the getter method, if available? Or are there any other ways to use the getter/setter methods but still produce a clean JSON output?</p> <p>I know that there are ways to manually modify the JSON keys before they are written to the string output. I am curious if there is simpler solution though.</p> <p><a href="https://jsfiddle.net/7d7tndhh/1/" rel="noreferrer">Here is a JSFiddle</a> which demonstrates the current behaviour.</p>
0debug
What is the meaning of a dollar sign before an Android resource id : <p>In the accepted answer of the following post(<a href="https://stackoverflow.com/questions/21872150/android-custom-numeric-keyboard/21873135">Android custom numeric keyboard</a>) I found a syntax that I don't understand: </p> <pre><code>$(R.id.t9_key_0).setOnClickListener(this); </code></pre> <p>What does the dollar sign mean in front? Is it specifically related to Android resource ids or is more a general Java syntax? Search engine results didn't show any suitable results. </p>
0debug
How to read a file line by line and making a new file for each line having same filename as last word of each line? : <p>Suppose the file contents are:</p> <pre><code>May 30, Thu, England vs SouthAfrica, Match 1 ,Afternoon, London May 31, Fri, Windies vs Pakistan, Match 2 ,Afternoon, Nottingham Jun 01, Sat, NewZealand vs SriLanka, Match 3 ,Afternoon, Cardiff </code></pre> <p>I want to create three files each having names London, Nottingham and Cardiff. Each file must have its own line. Like,content of Nottingham should be:</p> <pre><code>May 31, Fri, Windies vs Pakistan, Match 2 ,Afternoon </code></pre> <p>I don't want to use awk. Any help is appreciated.</p>
0debug
document.write('<script src="evil.js"></script>');
1threat
Python - How to get "out" of a while loop? : I'm trying to make a login menu. I've created a user/pass system that is changeable. But I want to sorta get out of the loop, to ask them to input their username/password again?
0debug
static int mov_write_trailer(AVFormatContext *s) { MOVMuxContext *mov = s->priv_data; AVIOContext *pb = s->pb; int res = 0; int i; int64_t moov_pos; for (i = 0; i < mov->nb_streams; i++) { MOVTrack *trk = &mov->tracks[i]; if (trk->enc->codec_id == AV_CODEC_ID_MOV_TEXT && !trk->last_sample_is_subtitle_end) { mov_write_subtitle_end_packet(s, i, trk->track_duration); trk->last_sample_is_subtitle_end = 1; } } if (!mov->chapter_track && !(mov->flags & FF_MOV_FLAG_FRAGMENT)) { if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters) { mov->chapter_track = mov->nb_streams++; if ((res = mov_create_chapter_track(s, mov->chapter_track)) < 0) goto error; } } if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) { moov_pos = avio_tell(pb); if (mov->mdat_size + 8 <= UINT32_MAX) { avio_seek(pb, mov->mdat_pos, SEEK_SET); avio_wb32(pb, mov->mdat_size + 8); } else { avio_seek(pb, mov->mdat_pos - 8, SEEK_SET); avio_wb32(pb, 1); ffio_wfourcc(pb, "mdat"); avio_wb64(pb, mov->mdat_size + 16); } avio_seek(pb, mov->reserved_moov_size > 0 ? mov->reserved_moov_pos : moov_pos, SEEK_SET); if (mov->flags & FF_MOV_FLAG_FASTSTART) { av_log(s, AV_LOG_INFO, "Starting second pass: moving the moov atom to the beginning of the file\n"); res = shift_data(s); if (res == 0) { avio_seek(s->pb, mov->reserved_moov_pos, SEEK_SET); mov_write_moov_tag(pb, mov, s); } } else if (mov->reserved_moov_size > 0) { int64_t size; mov_write_moov_tag(pb, mov, s); size = mov->reserved_moov_size - (avio_tell(pb) - mov->reserved_moov_pos); if (size < 8){ av_log(s, AV_LOG_ERROR, "reserved_moov_size is too small, needed %"PRId64" additional\n", 8-size); return -1; } avio_wb32(pb, size); ffio_wfourcc(pb, "free"); for (i = 0; i < size; i++) avio_w8(pb, 0); avio_seek(pb, moov_pos, SEEK_SET); } else { mov_write_moov_tag(pb, mov, s); } } else { mov_flush_fragment(s); mov_write_mfra_tag(pb, mov); } for (i = 0; i < mov->nb_streams; i++) { if (mov->flags & FF_MOV_FLAG_FRAGMENT && mov->tracks[i].vc1_info.struct_offset && s->pb->seekable) { int64_t off = avio_tell(pb); uint8_t buf[7]; if (mov_write_dvc1_structs(&mov->tracks[i], buf) >= 0) { avio_seek(pb, mov->tracks[i].vc1_info.struct_offset, SEEK_SET); avio_write(pb, buf, 7); avio_seek(pb, off, SEEK_SET); } } } error: mov_free(s); return res; }
1threat
Javascript eval() function not working properly : <p>I'm currently making a calculator with HTML, CSS and Javascript, for practice. I found out that the "built in" eval function did the math from a string. But it doesn't work properly. </p> <p>I don't know what the problem is. But when i for example do: 11+11/2 which should be 11. Becomes 16.5 for some reason. I have no idea why. I would really appreciate some help. </p> <p>Here is the code: </p> <pre><code> function revealAnswer(){ var math = document.getElementById("numbersInputted"); math.innerHTML += " = " + eval(math.innerHTML); } </code></pre>
0debug
how to put an object in an array? : My array is like this "taxDetails": [ { "taxType": "Flat Service Charge", "taxAmount": 0 }, { "taxTypeId": "1", "taxType": "Service Tax", "validFrm": "2016-01-18", "validTo": "2020-02-27", "taxPrctgSbt": 200, "taxPrctg": 14.5, "taxAmount": 300, "remarks": "test" }, { "taxTypeId": "2", "taxType": "VAT", "validFrm": "2016-01-18", "validTo": "2020-02-29", "taxPrctgSbt": 300, "taxPrctg": 12.5, "taxAmount": 400, "remarks": "rest" }, { "taxTypeId": "3", "taxType": "Swatch Bharath Cess", "validFrm": "2016-01-18", "validTo": "2020-03-31", "taxPrctgSbt": 400, "taxPrctg": 1, "taxAmount": 500, "remarks": "fest" }, { "taxTypeId": "5", "taxType": "Swatch Bharath Cess", "validFrm": "2016-01-18", "validTo": "2020-03-31", "taxPrctgSbt": 400, "taxPrctg": 1, "taxAmount": 500, "remarks": "fest" }, { "taxTypeId": "6", "taxType": "Percent Service Char", "validFrm": "2016-01-18", "validTo": "2020-08-01", "taxPrctgSbt": 200, "taxPrctg": 10, "taxAmount": 200, "remarks": "zest" }, { "taxTypeId": "7", "taxType": "Percent Service Char", "validFrm": "2016-01-18", "validTo": "2020-08-01", "taxPrctgSbt": 300, "taxPrctg": 15, "taxAmount": 200, "remarks": "zest" } ] and my code is $scope.paymentForm.taxDetails = []; //$scope.taxDetails = []; var flat= {"flat" : true}; $scope.taxList = function () { $http.get('http://192.168.0.113:8080/feasthunt/registration/getTaxDetails?restUniqCode='+uniqueCode) .success(function (response) { $scope.paymentForm.taxDetails = response; for(var i=0; i< $scope.paymentForm.taxDetails.length; i++){ $scope.paymentForm.taxDetails[i].push( flat ); } }) .error(function (data, status, header, config) { //alert('error'); }); }; $scope.taxList(); I want add another object in every array of elements. And final result will be like this "taxDetails": [ { "taxType": "Flat Service Charge", "taxAmount": 0, "flat": true }, { "taxTypeId": "1", "taxType": "Service Tax", "validFrm": "2016-01-18", "validTo": "2020-02-27", "taxPrctgSbt": 200, "taxPrctg": 14.5, "taxAmount": 300, "remarks": "test", "flat": true }, { "taxTypeId": "2", "taxType": "VAT", "validFrm": "2016-01-18", "validTo": "2020-02-29", "taxPrctgSbt": 300, "taxPrctg": 12.5, "taxAmount": 400, "remarks": "rest", "flat": true }, { "taxTypeId": "3", "taxType": "Swatch Bharath Cess", "validFrm": "2016-01-18", "validTo": "2020-03-31", "taxPrctgSbt": 400, "taxPrctg": 1, "taxAmount": 500, "remarks": "fest", "flat": true }, { "taxTypeId": "5", "taxType": "Swatch Bharath Cess", "validFrm": "2016-01-18", "validTo": "2020-03-31", "taxPrctgSbt": 400, "taxPrctg": 1, "taxAmount": 500, "remarks": "fest", "flat": true }, { "taxTypeId": "6", "taxType": "Percent Service Char", "validFrm": "2016-01-18", "validTo": "2020-08-01", "taxPrctgSbt": 200, "taxPrctg": 10, "taxAmount": 200, "remarks": "zest", "flat": true }, { "taxTypeId": "7", "taxType": "Percent Service Char", "validFrm": "2016-01-18", "validTo": "2020-08-01", "taxPrctgSbt": 300, "taxPrctg": 15, "taxAmount": 200, "remarks": "zest", "flat": true } ] Any one can give the answer for my question because it's very urgent requirement Thanks for responses
0debug
static void cpu_x86_register(X86CPU *cpu, const char *name, Error **errp) { CPUX86State *env = &cpu->env; x86_def_t def1, *def = &def1; memset(def, 0, sizeof(*def)); if (cpu_x86_find_by_name(cpu, def, name) < 0) { error_setg(errp, "Unable to find CPU definition: %s", name); return; } object_property_set_str(OBJECT(cpu), def->vendor, "vendor", errp); object_property_set_int(OBJECT(cpu), def->level, "level", errp); object_property_set_int(OBJECT(cpu), def->family, "family", errp); object_property_set_int(OBJECT(cpu), def->model, "model", errp); object_property_set_int(OBJECT(cpu), def->stepping, "stepping", errp); env->features[FEAT_1_EDX] = def->features[FEAT_1_EDX]; env->features[FEAT_1_ECX] = def->features[FEAT_1_ECX]; env->features[FEAT_8000_0001_EDX] = def->features[FEAT_8000_0001_EDX]; env->features[FEAT_8000_0001_ECX] = def->features[FEAT_8000_0001_ECX]; object_property_set_int(OBJECT(cpu), def->xlevel, "xlevel", errp); env->features[FEAT_KVM] = def->features[FEAT_KVM]; env->features[FEAT_SVM] = def->features[FEAT_SVM]; env->features[FEAT_C000_0001_EDX] = def->features[FEAT_C000_0001_EDX]; env->features[FEAT_7_0_EBX] = def->features[FEAT_7_0_EBX]; env->cpuid_xlevel2 = def->xlevel2; cpu->cache_info_passthrough = def->cache_info_passthrough; object_property_set_str(OBJECT(cpu), def->model_id, "model-id", errp); if (kvm_enabled()) { env->features[FEAT_KVM] |= kvm_default_features; } env->features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR; }
1threat
How to convert String to GString and replace placeholder in Groovy? : <p>I want to read a String from database and replace the placeholder by converting it to a GString. Can I do this with Eval? Any other ideas?</p> <pre><code>String stringFromDatabase = 'Hello ${name}!' String name = 'world' assert 'Hello world!'== TODO </code></pre>
0debug
static void gen_mtc0(DisasContext *ctx, TCGv arg, int reg, int sel) { const char *rn = "invalid"; if (sel != 0) check_insn(ctx, ISA_MIPS32); if (use_icount) gen_io_start(); switch (reg) { case 0: switch (sel) { case 0: gen_helper_mtc0_index(cpu_env, arg); rn = "Index"; break; case 1: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_mvpcontrol(cpu_env, arg); rn = "MVPControl"; break; case 2: CP0_CHECK(ctx->insn_flags & ASE_MT); rn = "MVPConf0"; break; case 3: CP0_CHECK(ctx->insn_flags & ASE_MT); rn = "MVPConf1"; break; default: goto cp0_unimplemented; } break; case 1: switch (sel) { case 0: rn = "Random"; break; case 1: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_vpecontrol(cpu_env, arg); rn = "VPEControl"; break; case 2: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_vpeconf0(cpu_env, arg); rn = "VPEConf0"; break; case 3: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_vpeconf1(cpu_env, arg); rn = "VPEConf1"; break; case 4: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_yqmask(cpu_env, arg); rn = "YQMask"; break; case 5: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_mtc0_store64(arg, offsetof(CPUMIPSState, CP0_VPESchedule)); rn = "VPESchedule"; break; case 6: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_mtc0_store64(arg, offsetof(CPUMIPSState, CP0_VPEScheFBack)); rn = "VPEScheFBack"; break; case 7: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_vpeopt(cpu_env, arg); rn = "VPEOpt"; break; default: goto cp0_unimplemented; } break; case 2: switch (sel) { case 0: gen_helper_mtc0_entrylo0(cpu_env, arg); rn = "EntryLo0"; break; case 1: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcstatus(cpu_env, arg); rn = "TCStatus"; break; case 2: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcbind(cpu_env, arg); rn = "TCBind"; break; case 3: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcrestart(cpu_env, arg); rn = "TCRestart"; break; case 4: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tchalt(cpu_env, arg); rn = "TCHalt"; break; case 5: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tccontext(cpu_env, arg); rn = "TCContext"; break; case 6: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcschedule(cpu_env, arg); rn = "TCSchedule"; break; case 7: CP0_CHECK(ctx->insn_flags & ASE_MT); gen_helper_mtc0_tcschefback(cpu_env, arg); rn = "TCScheFBack"; break; default: goto cp0_unimplemented; } break; case 3: switch (sel) { case 0: gen_helper_mtc0_entrylo1(cpu_env, arg); rn = "EntryLo1"; break; default: goto cp0_unimplemented; } break; case 4: switch (sel) { case 0: gen_helper_mtc0_context(cpu_env, arg); rn = "Context"; break; case 1: rn = "ContextConfig"; goto cp0_unimplemented; case 2: CP0_CHECK(ctx->ulri); tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, active_tc.CP0_UserLocal)); rn = "UserLocal"; break; default: goto cp0_unimplemented; } break; case 5: switch (sel) { case 0: gen_helper_mtc0_pagemask(cpu_env, arg); rn = "PageMask"; break; case 1: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_pagegrain(cpu_env, arg); rn = "PageGrain"; break; default: goto cp0_unimplemented; } break; case 6: switch (sel) { case 0: gen_helper_mtc0_wired(cpu_env, arg); rn = "Wired"; break; case 1: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf0(cpu_env, arg); rn = "SRSConf0"; break; case 2: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf1(cpu_env, arg); rn = "SRSConf1"; break; case 3: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf2(cpu_env, arg); rn = "SRSConf2"; break; case 4: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf3(cpu_env, arg); rn = "SRSConf3"; break; case 5: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsconf4(cpu_env, arg); rn = "SRSConf4"; break; default: goto cp0_unimplemented; } break; case 7: switch (sel) { case 0: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_hwrena(cpu_env, arg); ctx->bstate = BS_STOP; rn = "HWREna"; break; default: goto cp0_unimplemented; } break; case 8: switch (sel) { case 0: rn = "BadVAddr"; break; case 1: rn = "BadInstr"; break; case 2: rn = "BadInstrP"; break; default: goto cp0_unimplemented; } break; case 9: switch (sel) { case 0: gen_helper_mtc0_count(cpu_env, arg); rn = "Count"; break; default: goto cp0_unimplemented; } break; case 10: switch (sel) { case 0: gen_helper_mtc0_entryhi(cpu_env, arg); rn = "EntryHi"; break; default: goto cp0_unimplemented; } break; case 11: switch (sel) { case 0: gen_helper_mtc0_compare(cpu_env, arg); rn = "Compare"; break; default: goto cp0_unimplemented; } break; case 12: switch (sel) { case 0: save_cpu_state(ctx, 1); gen_helper_mtc0_status(cpu_env, arg); gen_save_pc(ctx->pc + 4); ctx->bstate = BS_EXCP; rn = "Status"; break; case 1: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_intctl(cpu_env, arg); ctx->bstate = BS_STOP; rn = "IntCtl"; break; case 2: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_srsctl(cpu_env, arg); ctx->bstate = BS_STOP; rn = "SRSCtl"; break; case 3: check_insn(ctx, ISA_MIPS32R2); gen_mtc0_store32(arg, offsetof(CPUMIPSState, CP0_SRSMap)); ctx->bstate = BS_STOP; rn = "SRSMap"; break; default: goto cp0_unimplemented; } break; case 13: switch (sel) { case 0: save_cpu_state(ctx, 1); gen_helper_mtc0_cause(cpu_env, arg); rn = "Cause"; break; default: goto cp0_unimplemented; } break; case 14: switch (sel) { case 0: gen_mtc0_store64(arg, offsetof(CPUMIPSState, CP0_EPC)); rn = "EPC"; break; default: goto cp0_unimplemented; } break; case 15: switch (sel) { case 0: rn = "PRid"; break; case 1: check_insn(ctx, ISA_MIPS32R2); gen_helper_mtc0_ebase(cpu_env, arg); rn = "EBase"; break; default: goto cp0_unimplemented; } break; case 16: switch (sel) { case 0: gen_helper_mtc0_config0(cpu_env, arg); rn = "Config"; ctx->bstate = BS_STOP; break; case 1: rn = "Config1"; break; case 2: gen_helper_mtc0_config2(cpu_env, arg); rn = "Config2"; ctx->bstate = BS_STOP; break; case 3: gen_helper_mtc0_config3(cpu_env, arg); rn = "Config3"; ctx->bstate = BS_STOP; break; case 4: gen_helper_mtc0_config4(cpu_env, arg); rn = "Config4"; ctx->bstate = BS_STOP; break; case 5: gen_helper_mtc0_config5(cpu_env, arg); rn = "Config5"; ctx->bstate = BS_STOP; break; case 6: rn = "Config6"; break; case 7: rn = "Config7"; break; default: rn = "Invalid config selector"; goto cp0_unimplemented; } break; case 17: switch (sel) { case 0: gen_helper_mtc0_lladdr(cpu_env, arg); rn = "LLAddr"; break; default: goto cp0_unimplemented; } break; case 18: switch (sel) { case 0 ... 7: gen_helper_0e1i(mtc0_watchlo, arg, sel); rn = "WatchLo"; break; default: goto cp0_unimplemented; } break; case 19: switch (sel) { case 0 ... 7: gen_helper_0e1i(mtc0_watchhi, arg, sel); rn = "WatchHi"; break; default: goto cp0_unimplemented; } break; case 20: switch (sel) { case 0: #if defined(TARGET_MIPS64) check_insn(ctx, ISA_MIPS3); gen_helper_mtc0_xcontext(cpu_env, arg); rn = "XContext"; break; #endif default: goto cp0_unimplemented; } break; case 21: CP0_CHECK(!(ctx->insn_flags & ISA_MIPS32R6)); switch (sel) { case 0: gen_helper_mtc0_framemask(cpu_env, arg); rn = "Framemask"; break; default: goto cp0_unimplemented; } break; case 22: rn = "Diagnostic"; break; case 23: switch (sel) { case 0: gen_helper_mtc0_debug(cpu_env, arg); gen_save_pc(ctx->pc + 4); ctx->bstate = BS_EXCP; rn = "Debug"; break; case 1: rn = "TraceControl"; ctx->bstate = BS_STOP; case 2: rn = "TraceControl2"; ctx->bstate = BS_STOP; case 3: ctx->bstate = BS_STOP; rn = "UserTraceData"; ctx->bstate = BS_STOP; case 4: ctx->bstate = BS_STOP; rn = "TraceBPC"; default: goto cp0_unimplemented; } break; case 24: switch (sel) { case 0: gen_mtc0_store64(arg, offsetof(CPUMIPSState, CP0_DEPC)); rn = "DEPC"; break; default: goto cp0_unimplemented; } break; case 25: switch (sel) { case 0: gen_helper_mtc0_performance0(cpu_env, arg); rn = "Performance0"; break; case 1: rn = "Performance1"; case 2: rn = "Performance2"; case 3: rn = "Performance3"; case 4: rn = "Performance4"; case 5: rn = "Performance5"; case 6: rn = "Performance6"; case 7: rn = "Performance7"; default: goto cp0_unimplemented; } break; case 26: rn = "ECC"; break; case 27: switch (sel) { case 0 ... 3: rn = "CacheErr"; break; default: goto cp0_unimplemented; } break; case 28: switch (sel) { case 0: case 2: case 4: case 6: gen_helper_mtc0_taglo(cpu_env, arg); rn = "TagLo"; break; case 1: case 3: case 5: case 7: gen_helper_mtc0_datalo(cpu_env, arg); rn = "DataLo"; break; default: goto cp0_unimplemented; } break; case 29: switch (sel) { case 0: case 2: case 4: case 6: gen_helper_mtc0_taghi(cpu_env, arg); rn = "TagHi"; break; case 1: case 3: case 5: case 7: gen_helper_mtc0_datahi(cpu_env, arg); rn = "DataHi"; break; default: rn = "invalid sel"; goto cp0_unimplemented; } break; case 30: switch (sel) { case 0: gen_mtc0_store64(arg, offsetof(CPUMIPSState, CP0_ErrorEPC)); rn = "ErrorEPC"; break; default: goto cp0_unimplemented; } break; case 31: switch (sel) { case 0: gen_mtc0_store32(arg, offsetof(CPUMIPSState, CP0_DESAVE)); rn = "DESAVE"; break; case 2 ... 7: CP0_CHECK(ctx->kscrexist & (1 << sel)); tcg_gen_st_tl(arg, cpu_env, offsetof(CPUMIPSState, CP0_KScratch[sel-2])); rn = "KScratch"; break; default: goto cp0_unimplemented; } ctx->bstate = BS_STOP; break; default: goto cp0_unimplemented; } (void)rn; LOG_DISAS("mtc0 %s (reg %d sel %d)\n", rn, reg, sel); if (use_icount) { gen_io_end(); ctx->bstate = BS_STOP; } return; cp0_unimplemented: LOG_DISAS("mtc0 %s (reg %d sel %d)\n", rn, reg, sel); }
1threat
jQuery checkbox check-uncheck issue : <p>I have checkboxes on my page:</p> <pre><code>&lt;div class="mail-control"&gt; &lt;input class="magic-checkbox select-doc" type="checkbox"&gt; &lt;label for="email-list-1"&gt;&lt;/label&gt; &lt;/div&gt; </code></pre> <p>I also have links to select and deselect all checkboxes:</p> <pre><code>&lt;ul class="dropdown-menu"&gt; &lt;li&gt;&lt;a href="#" id="select-all-list"&gt;Select all&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" id="deselect-all-list"&gt;Deselect all&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>This code selects and deselects the checkboxes:</p> <pre><code>$('#select-all-list').on('click', function() { $('.select-doc').prop('checked', true); }); $('#deselect-all-list').on('click', function() { $('.select-doc').prop('checked', true); }); </code></pre> <p><strong>The problem is: when I select all checkboxes - I can't uncheck some of them manually (directly with my mouse). How do I do it?</strong></p>
0debug
How to set and call private data members of multiple classes? : <p>Overview: I'm trying to create a bank account program that has multiple classes (4 to be exact). Here's the heirarchy - </p> <blockquote> <p>Bank</p> <blockquote> <p>Account accounts;</p> </blockquote> <p>Account </p> <blockquote> <p>Depositor depositor_info;</p> <p>Int Account_number;</p> <p>Double account_balance;</p> </blockquote> <p>Depositor</p> <blockquote> <p>Name depositor_name;</p> <p>string Social Security Number;</p> </blockquote> <p>Name</p> <blockquote> <p>String first, last;</p> </blockquote> </blockquote> <p>I can set the depositor's name, and then assign depositor to an account. However I can't seem to print out the depositor's name. Here's the main testing code:</p> <pre><code>Account test[MAX_ACCTS]; string first = "john", last = "doe", social = "132456789"; int acctNumber = 987654; Name name; Depositor depositor; name.setFirst(first); // works name.setLast(last); // works depositor.setName(name); // this works depositor.setSSN(social); // this works test[1].setDepositor(depositor); // this also works. cout &lt;&lt; test[1].getDepositor(); // Here I get an error: no match for 'operator&lt;&lt;' (operand types are 'std::ostream {aka std::basic_ostream&lt;char&gt;}' and 'Depositor') </code></pre> <p>What am I doing wrong?</p>
0debug
Why does the container created with - 'docker run -d alpine sleep infinity' goes into exited/stopped state? : <p>I have nothing to execute inside a container but want it to be running. So, I tried to create a container using the following command line - <code>'docker run -d alpine sleep infinity'</code>. But, instead, it is going into a exited/stopped state immediately. What's the explanation?</p>
0debug
How do I implement collision into my code? : from graphics import* import time import random def main(): numx=random.randint(10,700) wn=GraphWin("AK",700,700) wn.setBackground("white") msg=Text(Point(25,30),"Score") msg.setSize(12) msg.setTextColor('blue') msg.draw(wn) inch=Entry(Point(60,30),2) inch.setFill('white') inch.draw(wn) sqrg=Rectangle(Point(330,650),Point(430,665)) sqrg.setFill("red") sqrg.draw(wn) blx=Circle(Point(numx,80),20) blx.setFill("blue") blx.draw(wn) xval=10 yval=0 wn.getMouse() for i in range(150): sqrg.move(xval,yval) symbl=wn.checkKey() if symbl=="Right": xval=10 yval=0 if symbl=="Left": xval=-10 yval=0 time.sleep(0.08) blx.move(0,20) main() I'm very confused my professor is very confusing, and I need to do this for a project where when collision is detected the score goes up.
0debug
Greenshot does not work in Visual Studio : <p>Anyone know why you cannot use Greenshot in Visual Studio? I hit the Screen Print button and it does not bring up the cross-hairs to drag my window size. Instead it just takes a plain windows screenshot. I looked for keyboard commands that might override it but didnt see anything at first glance. It works for every other program but not when Visual Studio is the active window. </p>
0debug
i use ping6 in mininet. mininet call unknown host : I use mininet and odl,but in mininet ,I use mininet>h1 ping6 h2 mininet>unknown host I changed odl to Ryu.It is same.
0debug
static void output_visitor_test_add(const char *testpath, TestOutputVisitorData *data, void (*test_func)(TestOutputVisitorData *data, const void *user_data)) { g_test_add(testpath, TestOutputVisitorData, data, visitor_output_setup, test_func, visitor_output_teardown); }
1threat
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt) { CCaptionSubContext *ctx = avctx->priv_data; AVSubtitle *sub = data; const int64_t start_time = sub->pts; uint8_t *bptr = NULL; int len = avpkt->size; int ret = 0; int i; if (ctx->pktbuf->size < len) { ret = av_buffer_realloc(&ctx->pktbuf, len); if (ret < 0) { av_log(ctx, AV_LOG_WARNING, "Insufficient Memory of %d truncated to %d\n", len, ctx->pktbuf->size); len = ctx->pktbuf->size; ret = 0; } } memcpy(ctx->pktbuf->data, avpkt->data, len); bptr = ctx->pktbuf->data; for (i = 0; i < len; i += 3) { uint8_t cc_type = *(bptr + i) & 3; if (validate_cc_data_pair(bptr + i)) continue; if(cc_type == 1) continue; else process_cc608(ctx, start_time, *(bptr + i + 1) & 0x7f, *(bptr + i + 2) & 0x7f); if (!ctx->buffer_changed) continue; ctx->buffer_changed = 0; if (*ctx->buffer.str || ctx->real_time) { ff_dlog(ctx, "cdp writing data (%s)\n",ctx->buffer.str); ret = ff_ass_add_rect(sub, ctx->buffer.str, ctx->readorder++, 0, NULL, NULL); if (ret < 0) return ret; sub->pts = ctx->start_time; if (!ctx->real_time) sub->end_display_time = av_rescale_q(ctx->end_time - ctx->start_time, AV_TIME_BASE_Q, ms_tb); else sub->end_display_time = -1; ctx->buffer_changed = 0; ctx->last_real_time = sub->pts; ctx->screen_touched = 0; } } if (ctx->real_time && ctx->screen_touched && sub->pts > ctx->last_real_time + av_rescale_q(200, ms_tb, AV_TIME_BASE_Q)) { ctx->last_real_time = sub->pts; ctx->screen_touched = 0; capture_screen(ctx); ctx->buffer_changed = 0; ret = ff_ass_add_rect(sub, ctx->buffer.str, ctx->readorder++, 0, NULL, NULL); if (ret < 0) return ret; sub->end_display_time = -1; } *got_sub = sub->num_rects > 0; return ret; }
1threat
static void monitor_control_read(void *opaque, const uint8_t *buf, int size) { Monitor *old_mon = cur_mon; cur_mon = opaque; cur_mon = old_mon; }
1threat
How to use Action Filters with Dependency Injection in ASP.NET CORE? : <p>I use constructor-based dependency injection everywhere in my <code>ASP.NET CORE</code> application and I also need to resolve dependencies in my action filters:</p> <pre><code>public class MyAttribute : ActionFilterAttribute { public int Limit { get; set; } // some custom parameters passed from Action private ICustomService CustomService { get; } // this must be resolved public MyAttribute() { } public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { // my code ... await next(); } } </code></pre> <p>Then in Controller:</p> <pre><code>[MyAttribute(Limit = 10)] public IActionResult() { ... </code></pre> <p>If I put ICustomService to the constructor, then I'm unable to compile my project. So, how do I supossed to get interface instances in action filter?</p>
0debug
Join table and take name into model MVC , LINQ, C#, Models : <p>Here is my Office model</p> <pre><code>public class Office { public int ID { get; set; } public string Color { get; set; } } </code></pre> <p>And here is my Worker model</p> <pre><code>public class Worker { public int ID { get; set; } public int OfficeID { get; set; } public string FullName { get; set; } [NotMapped] public string OfficeColor { get; set; } } </code></pre> <p>what I want is to get all workers with LINQ with OfficeColor the Color of the specified OfficeID color</p>
0debug
how to get the table structure in sql server(Microsoft SQL Server Management Studio) : Could you please help me... my task is to get the table structure in sql server.(that means what are all the columns and its data type and column constraints)
0debug
How does html-webpack-plugin work with html-loader? : <p>I thought a loader is invoked only when some resource is <em>import</em>ed or <em>require</em>d somewhere and the resources match with such a loader. </p> <p>But in the following codes, no html file is imported anywhere but the html-loader is still necessary to make the compilation pass because of the underscore template stuff in the html. </p> <p>So I have the following questions:</p> <ol> <li>When does the html-loader come to play? After or before the bundle is generated?</li> <li>Why does webpack invoke the html-loader? Because of the template setting in the plugin?</li> <li><p>Does the plugin use the output of the loader? But the output is just a string and how could it make a difference?</p> <pre><code>//webpack.config.js const webpack = require('webpack'); const path = require('path'); const htmlPlugin = require('html-webpack-plugin'); module.exports = { entry: { a: './a.js' }, output: { filename: '[name].[chunkhash].js', chunkFilename: '[name].[chunkhash].js', path: path.resolve(__dirname, 'dist') }, module: { rules: [ { test: /\.html$/, loader: "html-loader" } ] }, plugins: [ new htmlPlugin({ template:path.resolve(__dirname,'index.html') }) ] }; //index.html &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;script id="item-template" type="text/template"&gt; &lt;label&gt;&lt;%= title %&gt;&lt;/label&gt; &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre></li> </ol>
0debug
Can I build a full fledge client web app with Angular 2 : I am working on a food purchase web app. The app has already been launched on mobile(Android). Now we want to build a web version. The backend of this app was built using Node, Angular and Firebase. I would like to know if I can only use angular 2(without Node.JS) for the web application. What the web app will basically do is to: 1. User authentication 2. Consume Backend API 3. Checkout, after purchase My major concern is, do I need Node.js for anything? or can I accomplish all these with just Angular 2?
0debug
static void map_val_34_to_20(INTFLOAT par[PS_MAX_NR_IIDICC]) { #if USE_FIXED par[ 0] = (int)(((int64_t)(par[ 0] + (par[ 1]>>1)) * 1431655765 + \ 0x40000000) >> 31); par[ 1] = (int)(((int64_t)((par[ 1]>>1) + par[ 2]) * 1431655765 + \ 0x40000000) >> 31); par[ 2] = (int)(((int64_t)(par[ 3] + (par[ 4]>>1)) * 1431655765 + \ 0x40000000) >> 31); par[ 3] = (int)(((int64_t)((par[ 4]>>1) + par[ 5]) * 1431655765 + \ 0x40000000) >> 31); #else par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f; par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f; par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f; par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f; #endif par[ 4] = AAC_HALF_SUM(par[ 6], par[ 7]); par[ 5] = AAC_HALF_SUM(par[ 8], par[ 9]); par[ 6] = par[10]; par[ 7] = par[11]; par[ 8] = AAC_HALF_SUM(par[12], par[13]); par[ 9] = AAC_HALF_SUM(par[14], par[15]); par[10] = par[16]; par[11] = par[17]; par[12] = par[18]; par[13] = par[19]; par[14] = AAC_HALF_SUM(par[20], par[21]); par[15] = AAC_HALF_SUM(par[22], par[23]); par[16] = AAC_HALF_SUM(par[24], par[25]); par[17] = AAC_HALF_SUM(par[26], par[27]); #if USE_FIXED par[18] = (((par[28]+2)>>2) + ((par[29]+2)>>2) + ((par[30]+2)>>2) + ((par[31]+2)>>2)); #else par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f; #endif par[19] = AAC_HALF_SUM(par[32], par[33]); }
1threat
Spyder missing Object Inspector : <p>I just installed Anaconda and running Spyder I cannot find the Object Inspector. Hitting Ctrl+I has no effect and in the View/Panes menu there is no item Object Inspector. </p> <p>I have seen videos and tutorials that show the Object Inspector. What is happening?</p>
0debug
static int i440fx_initfn(PCIDevice *dev) { PCII440FXState *d = DO_UPCAST(PCII440FXState, dev, dev); pci_config_set_vendor_id(d->dev.config, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(d->dev.config, PCI_DEVICE_ID_INTEL_82441); d->dev.config[0x08] = 0x02; pci_config_set_class(d->dev.config, PCI_CLASS_BRIDGE_HOST); d->dev.config[I440FX_SMRAM] = 0x02; cpu_smm_register(&i440fx_set_smm, d); return 0; }
1threat
Swift and iOS programming : I've been trying to download xCode for swift programming, but when I open it nothing happens. Xcode_8.1.xip Do I need to us using a mac to be programming for iOS, I am currently using windows10? Thanks
0debug
char *qdist_pr(const struct qdist *dist, size_t n_bins, uint32_t opt) { const char *border = opt & QDIST_PR_BORDER ? "|" : ""; char *llabel, *rlabel; char *hgram; GString *s; if (dist->n == 0) { return NULL; } s = g_string_new(""); llabel = qdist_pr_label(dist, n_bins, opt, true); rlabel = qdist_pr_label(dist, n_bins, opt, false); hgram = qdist_pr_plain(dist, n_bins); g_string_append_printf(s, "%s%s%s%s%s", llabel, border, hgram, border, rlabel); g_free(llabel); g_free(rlabel); g_free(hgram); return g_string_free(s, FALSE); }
1threat
unreachable statement when trying call two getItemCount(); : i am trying to call two getItemCount(); and get unreachable statement any idea how to return two counts without getting this problem[enter image description here][1] [1]: https://i.stack.imgur.com/ZxU0L.png
0debug
int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet) { MpegEncContext *s = avctx->priv_data; int i, stuffing_count, ret; int context_count = s->slice_context_count; s->picture_in_gop_number++; if (load_input_picture(s, pic_arg) < 0) return -1; if (select_input_picture(s) < 0) { return -1; } if (s->new_picture.f.data[0]) { if (!pkt->data && (ret = ff_alloc_packet(pkt, s->mb_width*s->mb_height*MAX_MB_BYTES)) < 0) return ret; if (s->mb_info) { s->mb_info_ptr = av_packet_new_side_data(pkt, AV_PKT_DATA_H263_MB_INFO, s->mb_width*s->mb_height*12); s->prev_mb_info = s->last_mb_info = s->mb_info_size = 0; } for (i = 0; i < context_count; i++) { int start_y = s->thread_context[i]->start_mb_y; int end_y = s->thread_context[i]-> end_mb_y; int h = s->mb_height; uint8_t *start = pkt->data + (size_t)(((int64_t) pkt->size) * start_y / h); uint8_t *end = pkt->data + (size_t)(((int64_t) pkt->size) * end_y / h); init_put_bits(&s->thread_context[i]->pb, start, end - start); } s->pict_type = s->new_picture.f.pict_type; ff_MPV_frame_start(s, avctx); vbv_retry: if (encode_picture(s, s->picture_number) < 0) return -1; avctx->header_bits = s->header_bits; avctx->mv_bits = s->mv_bits; avctx->misc_bits = s->misc_bits; avctx->i_tex_bits = s->i_tex_bits; avctx->p_tex_bits = s->p_tex_bits; avctx->i_count = s->i_count; avctx->p_count = s->mb_num - s->i_count - s->skip_count; avctx->skip_count = s->skip_count; ff_MPV_frame_end(s); if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG) ff_mjpeg_encode_picture_trailer(s); if (avctx->rc_buffer_size) { RateControlContext *rcc = &s->rc_context; int max_size = rcc->buffer_index * avctx->rc_max_available_vbv_use; if (put_bits_count(&s->pb) > max_size && s->lambda < s->avctx->lmax) { s->next_lambda = FFMAX(s->lambda + 1, s->lambda * (s->qscale + 1) / s->qscale); if (s->adaptive_quant) { int i; for (i = 0; i < s->mb_height * s->mb_stride; i++) s->lambda_table[i] = FFMAX(s->lambda_table[i] + 1, s->lambda_table[i] * (s->qscale + 1) / s->qscale); } s->mb_skipped = 0; if (s->pict_type == AV_PICTURE_TYPE_P) { if (s->flipflop_rounding || s->codec_id == AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_MPEG4) s->no_rounding ^= 1; } if (s->pict_type != AV_PICTURE_TYPE_B) { s->time_base = s->last_time_base; s->last_non_b_time = s->time - s->pp_time; } for (i = 0; i < context_count; i++) { PutBitContext *pb = &s->thread_context[i]->pb; init_put_bits(pb, pb->buf, pb->buf_end - pb->buf); } goto vbv_retry; } assert(s->avctx->rc_max_rate); } if (s->flags & CODEC_FLAG_PASS1) ff_write_pass1_stats(s); for (i = 0; i < 4; i++) { s->current_picture_ptr->f.error[i] = s->current_picture.f.error[i]; avctx->error[i] += s->current_picture_ptr->f.error[i]; } if (s->flags & CODEC_FLAG_PASS1) assert(avctx->header_bits + avctx->mv_bits + avctx->misc_bits + avctx->i_tex_bits + avctx->p_tex_bits == put_bits_count(&s->pb)); flush_put_bits(&s->pb); s->frame_bits = put_bits_count(&s->pb); stuffing_count = ff_vbv_update(s, s->frame_bits); if (stuffing_count) { if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb) >> 3) < stuffing_count + 50) { av_log(s->avctx, AV_LOG_ERROR, "stuffing too large\n"); return -1; } switch (s->codec_id) { case AV_CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_MPEG2VIDEO: while (stuffing_count--) { put_bits(&s->pb, 8, 0); } break; case AV_CODEC_ID_MPEG4: put_bits(&s->pb, 16, 0); put_bits(&s->pb, 16, 0x1C3); stuffing_count -= 4; while (stuffing_count--) { put_bits(&s->pb, 8, 0xFF); } break; default: av_log(s->avctx, AV_LOG_ERROR, "vbv buffer overflow\n"); } flush_put_bits(&s->pb); s->frame_bits = put_bits_count(&s->pb); } if (s->avctx->rc_max_rate && s->avctx->rc_min_rate == s->avctx->rc_max_rate && s->out_format == FMT_MPEG1 && 90000LL * (avctx->rc_buffer_size - 1) <= s->avctx->rc_max_rate * 0xFFFFLL) { int vbv_delay, min_delay; double inbits = s->avctx->rc_max_rate * av_q2d(s->avctx->time_base); int minbits = s->frame_bits - 8 * (s->vbv_delay_ptr - s->pb.buf - 1); double bits = s->rc_context.buffer_index + minbits - inbits; if (bits < 0) av_log(s->avctx, AV_LOG_ERROR, "Internal error, negative bits\n"); assert(s->repeat_first_field == 0); vbv_delay = bits * 90000 / s->avctx->rc_max_rate; min_delay = (minbits * 90000LL + s->avctx->rc_max_rate - 1) / s->avctx->rc_max_rate; vbv_delay = FFMAX(vbv_delay, min_delay); assert(vbv_delay < 0xFFFF); s->vbv_delay_ptr[0] &= 0xF8; s->vbv_delay_ptr[0] |= vbv_delay >> 13; s->vbv_delay_ptr[1] = vbv_delay >> 5; s->vbv_delay_ptr[2] &= 0x07; s->vbv_delay_ptr[2] |= vbv_delay << 3; avctx->vbv_delay = vbv_delay * 300; } s->total_bits += s->frame_bits; avctx->frame_bits = s->frame_bits; pkt->pts = s->current_picture.f.pts; if (!s->low_delay) { if (!s->current_picture.f.coded_picture_number) pkt->dts = pkt->pts - s->dts_delta; else pkt->dts = s->reordered_pts; s->reordered_pts = s->input_picture[0]->f.pts; } else pkt->dts = pkt->pts; if (s->current_picture.f.key_frame) pkt->flags |= AV_PKT_FLAG_KEY; if (s->mb_info) av_packet_shrink_side_data(pkt, AV_PKT_DATA_H263_MB_INFO, s->mb_info_size); } else { assert((put_bits_ptr(&s->pb) == s->pb.buf)); s->frame_bits = 0; } assert((s->frame_bits & 7) == 0); pkt->size = s->frame_bits / 8; *got_packet = !!pkt->size; return 0; }
1threat
static void nvdimm_dsm_device(NvdimmDsmIn *in, hwaddr dsm_mem_addr) { if (!in->function) { nvdimm_dsm_function0(0 , dsm_mem_addr); return; } nvdimm_dsm_no_payload(1 , dsm_mem_addr); }
1threat
How can i count only 'Yes' entities in my column of a dataframe? : [In Input[96] I tried many things but couldnot do anything, always getting both 'yes, and 'no values'][1] [1]: https://i.stack.imgur.com/svTFy.png
0debug
static void gen_msa_elm_df(CPUMIPSState *env, DisasContext *ctx, uint32_t df, uint32_t n) { #define MASK_MSA_ELM(op) (MASK_MSA_MINOR(op) | (op & (0xf << 22))) uint8_t ws = (ctx->opcode >> 11) & 0x1f; uint8_t wd = (ctx->opcode >> 6) & 0x1f; TCGv_i32 tws = tcg_const_i32(ws); TCGv_i32 twd = tcg_const_i32(wd); TCGv_i32 tn = tcg_const_i32(n); TCGv_i32 tdf = tcg_const_i32(df); switch (MASK_MSA_ELM(ctx->opcode)) { case OPC_SLDI_df: gen_helper_msa_sldi_df(cpu_env, tdf, twd, tws, tn); break; case OPC_SPLATI_df: gen_helper_msa_splati_df(cpu_env, tdf, twd, tws, tn); break; case OPC_INSVE_df: gen_helper_msa_insve_df(cpu_env, tdf, twd, tws, tn); break; case OPC_COPY_S_df: case OPC_COPY_U_df: case OPC_INSERT_df: #if !defined(TARGET_MIPS64) if (df == DF_DOUBLE) { generate_exception_end(ctx, EXCP_RI); break; } #endif switch (MASK_MSA_ELM(ctx->opcode)) { case OPC_COPY_S_df: gen_helper_msa_copy_s_df(cpu_env, tdf, twd, tws, tn); break; case OPC_COPY_U_df: gen_helper_msa_copy_u_df(cpu_env, tdf, twd, tws, tn); break; case OPC_INSERT_df: gen_helper_msa_insert_df(cpu_env, tdf, twd, tws, tn); break; } break; default: MIPS_INVAL("MSA instruction"); generate_exception_end(ctx, EXCP_RI); } tcg_temp_free_i32(twd); tcg_temp_free_i32(tws); tcg_temp_free_i32(tn); tcg_temp_free_i32(tdf); }
1threat
Canvas HTML5 Effects : <p>I'm looking for create a CANVAS effect on a logo, something like this:</p> <p><a href="http://www.teamgeek.co.za/" rel="nofollow">http://www.teamgeek.co.za/</a></p> <p>I couldn't find something like that. Someone know how to do it?</p> <p>Thanks!</p>
0debug
static int opt_streamid(const char *opt, const char *arg) { int idx; char *p; char idx_str[16]; av_strlcpy(idx_str, arg, sizeof(idx_str)); p = strchr(idx_str, ':'); if (!p) { fprintf(stderr, "Invalid value '%s' for option '%s', required syntax is 'index:value'\n", arg, opt); ffmpeg_exit(1); } *p++ = '\0'; idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, INT_MAX); streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1); streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX); return 0; }
1threat
How do you use the express framework but store a users data with a sql database? : How do you use the express framework but store a users data with a built in sql database?
0debug
How to import multiple excel sheets to sql tables using c# : I need to import a multiple excel sheets to multiple sql tables(according to their table by clicking a c# button control Please help with that
0debug
def tuple_to_set(t): s = set(t) return (s)
0debug
static ssize_t handle_aiocb_ioctl(RawPosixAIOData *aiocb) { int ret; ret = ioctl(aiocb->aio_fildes, aiocb->aio_ioctl_cmd, aiocb->aio_ioctl_buf); if (ret == -1) { return -errno; } return aiocb->aio_nbytes; }
1threat
Kotlin Coroutines in a Android Service : <p>I have a android service which starts and syncs different types of data with the server when it's online. I'm new to Kotlin coroutines and I'm trying to accomplish the following:</p> <pre><code>fun syncData{ //Job1 make retrofit call to server //Job2 make retrofit call to server after job1 is done. //Job3 make retrofit call to server after job 2 is done and so on. //After all jobs are done I'll stop service. } </code></pre> <p>I'm following this post: <a href="https://stackoverflow.com/questions/43132080/kotlin-coroutines-the-right-way-in-android">Kotlin Coroutines the right way in Android</a></p> <p>Which brought me this solution:</p> <pre><code>fun syncData() = async(CommonPool){ try{ val sync1 = async(CommonPool){ job1.sync() } val sync2 = async(CommonPool){ job2.sync() } val sync3 = async(CommonPool){ job3.sync() } val sync4 = async(CommonPool){ job4.sync() } job1.await() job2.await() job3.await() job4.await() }catch (e: Exception){ }finally { stopSelf() } } </code></pre> <p>But when I get retrofit's log on logcat every call is mixed. Calls from job3 comes before job1, and so on. How can I execute then in a pipeline ?I'm kinda lost in kotlin's coroutines so I don't know exactly to implement this.</p> <p>Thanks in advance.</p>
0debug
How to enable migrations in Visual Studio for Mac : <p>I have Visual Studio for Mac and I'm trying to learn Xamarin with Azure using the following tutorial: <a href="https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter3/server/" rel="noreferrer">https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter3/server/</a></p> <p>At some point, I have to enable EF migrations. The tutorial says: Go to View -> Other Windows -> Package Manager Console.</p> <p>Unfortunately there is no Package Manager Console in Visual Studio for Mac... so how do you handle things like <code>enable-migrations</code>, <code>add-migration</code> or <code>update-database</code> on the Mac?</p>
0debug
static int qemu_chr_open_win(QemuOpts *opts, CharDriverState **_chr) { const char *filename = qemu_opt_get(opts, "path"); CharDriverState *chr; WinCharState *s; chr = g_malloc0(sizeof(CharDriverState)); s = g_malloc0(sizeof(WinCharState)); chr->opaque = s; chr->chr_write = win_chr_write; chr->chr_close = win_chr_close; if (win_chr_init(chr, filename) < 0) { g_free(s); g_free(chr); return -EIO; } qemu_chr_generic_open(chr); *_chr = chr; return 0; }
1threat
static uint64_t spapr_io_read(void *opaque, hwaddr addr, unsigned size) { switch (size) { case 1: return cpu_inb(addr); case 2: return cpu_inw(addr); case 4: return cpu_inl(addr); } assert(0); }
1threat
static void put_int16(QEMUFile *f, void *pv, size_t size) { int16_t *v = pv; qemu_put_sbe16s(f, v); }
1threat
TypeError: 'float' object has no attribute '__getitem__' in python : I am working on a project in python.I am a beginner and I am getting this error when i am running on the program.Please help me what has to be done in this case Traceback (most recent call last): File "E:/Python/1616/checkProfile.py", line 104, in <module> p.getResults() File "E:\Python\1616\Profile.py", line 67, in getResults for i in range(2): self._s[1] += e.getS[1] TypeError: 'float' object has no attribute '__getitem__' Error in Line 67 http://pastebin.com/HXvppfmU..please help me as its little urgent
0debug
How to do a 2d quadratic fit in C++? : <p>How would you perform a 2d quadratic fit in C++? The equation to fit is of the form:</p> <pre><code>f(x, y) = a*x^2 + b*x*y + c*y^2 + d*x + e*y + f </code></pre> <p>where a, b, c, d, e and f are the fit parameters. Is it straightforward to write? Is there a library that is free to use for that?</p>
0debug
Calculate a distance between two points having lat, long and elevation in R : <p>Is there a package which allows to compute the spatial distance between two points taking into account the elevation. So for each point, we would have latitude, longitude and elevation. So far, I had to write the following function:</p> <pre><code>library(geosphere) distance3D &lt;- function (point1, point2) { planiDist &lt;- distm(point1[1:2], point2[1:2]) altiDist &lt;- point2[3] - point1[3] dist3D &lt;- sqrt(planiDist^2+altiDist^2) return(dist3D) } </code></pre> <p>I was just wondering if one function existed in one of the R packages.</p>
0debug
Fluentd vs Kafka : <p>The use case is this: I've several java applications running which all have to interact with different (each one has a specific target) elasticsearch indices. For instance an application A uses the indices A,B,C of ElasticSearch to query and update. Application B uses indices A,C,D(say). </p> <p>Some common interface is required which can manage all these data streams. Currently I'm evaluating Kafka and fluentd for this purpose. Can someone explain which will be better suited for this situation. I've looked at features of both Kafka and Fluentd and I don't really understand the difference it would make here. Thanks a lot.</p>
0debug
static void decodeplane8(uint8_t *dst, const uint8_t *const buf, int buf_size, int bps, int plane) { GetBitContext gb; int i, b; init_get_bits(&gb, buf, buf_size * 8); for(i = 0; i < (buf_size * 8 + bps - 1) / bps; i++) { for (b = 0; b < bps; b++) { dst[ i*bps + b ] |= get_bits1(&gb) << plane; } } }
1threat
static inline int silk_is_lpc_stable(const int16_t lpc[16], int order) { int k, j, DC_resp = 0; int32_t lpc32[2][16]; int totalinvgain = 1 << 30; int32_t *row = lpc32[0], *prevrow; for (k = 0; k < order; k++) { DC_resp += lpc[k]; row[k] = lpc[k] * 4096; } if (DC_resp >= 4096) return 0; for (k = order - 1; 1; k--) { int rc; int gaindiv; int gain; int fbits; int error; if (FFABS(row[k]) > 16773022) return 0; rc = -(row[k] * 128); gaindiv = (1 << 30) - MULH(rc, rc); totalinvgain = MULH(totalinvgain, gaindiv) << 2; if (k == 0) return (totalinvgain >= 107374); fbits = opus_ilog(gaindiv); gain = ((1 << 29) - 1) / (gaindiv >> (fbits + 1 - 16)); error = (1 << 29) - MULL(gaindiv << (15 + 16 - fbits), gain, 16); gain = ((gain << 16) + (error * gain >> 13)); prevrow = row; row = lpc32[k & 1]; for (j = 0; j < k; j++) { int x = prevrow[j] - ROUND_MULL(prevrow[k - j - 1], rc, 31); row[j] = ROUND_MULL(x, gain, fbits); } } }
1threat
How to profile React Native source code using Xcode/Instruments/Time Profiler : <p>We're using React Native <code>0.59.10</code> and React-Redux <code>5.0.7</code>, and are experiencing a CPU-bound performance issue, in which our Redux actions are taking ~0.25s to complete.</p> <p>We've profiled using the Time Profiler configuration in Instruments, but none of our JS code is symbolicated.</p> <p>Remotely debugging in Chrome seems to just debug the "remote inspector" page, which is entirely unhelpful.</p> <p>Is there a way to build/attach a source map, or symbolicate the memory addresses seen below, to the JS function names/calls?</p> <p><a href="https://i.stack.imgur.com/HW82V.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HW82V.png" alt="Instruments Callstack"></a></p>
0debug
How to read data from a serial port and write it to a file : <p>I have code written that opens a serial port and also opens a txt log file. I want to write incoming data on the serial port to the log file. My question is how to I or what is the best way to read data from the serial port and write it to a file. I can post the code that opens the serial port and log file if its necessary but I don't want to clutter my questions.</p> <p>I currently have a while loop which reads data from the serial port into a 32 element char array and then writes it to the file. However, the file contains garbage because it is writing the buffer continuously to the file. </p> <p>I'd appreciate any advice on how to do this properly. I should really only write when the buffer is full but how do I know what size the buffer should be and what happens if there are buffer overruns for example if I don't read on time.</p> <pre><code>int i,rdlen, ptr; char buf[32]; while( 1 ) { rdlen = read(fd_serial_port, &amp;buf[ptr], 1); //read data from serial line into buffer fwrite(buf , 1 , sizeof(buf) , log_file); fflush(log_file); } </code></pre> <p>The data coming in from the serial line looks like this and arrives every 2 seconds (if that matters)</p> <pre><code>Starting Contiki-1cb08a4 With DriverLib v0.44336 TI SmartRF06EB + CC26xx EM Net: sicslowpan MAC: TSCH2 RDC: nordc RF: Channel 25 [node] id=0, role=6ln </code></pre>
0debug
Left click in selenium : which method is used to click left of mouse in selenium using java ,can it be done using action class I tried using action class but did not get result
0debug
Why can I replace one word in a text file but not another? : <p>I'm reading through the following text file word for word a replacing the words "@name@" and "@festival@". My program works perfectly for @name@ but only changes the first @festival@, but not the second. I have no idea why. </p> <p>John Doe</p> <p>Room 213-A</p> <p>Generic Old Building</p> <p>School of Information Technology</p> <p>Programming State University</p> <p>New York NY 12345-0987</p> <p>USA</p> <p>To: @name@</p> <p>Subject: Season's greetings: @festival@</p> <p>Dear @name@,</p> <p>A very @festival@ to you and your family!</p> <p>Your sincerely,</p> <p>John</p> <pre><code>void Main::readFile() { while (v.size() != 0) { string name; name = v.at(v.size()-1); v.pop_back(); std::ofstream out(name + ".txt"); ifstream file; file.open("letter.txt"); string word; string comma; char x; word.clear(); while (!file.eof()) { x = file.get(); while (x != ' ' &amp;&amp; x != std::ifstream::traits_type::eof()) { if (word == "@name@") { word = name; } if (word == "@festival@") { word = "THISISATEST!!!!!!!!!!!!!!"; } word = word + x; x = file.get(); } out &lt;&lt; word + " "; word.clear(); } } </code></pre>
0debug