problem
stringlengths
26
131k
labels
class label
2 classes
How do you use @Input with components created with a ComponentFactoryResolver? : <p>Is there a method that can be used to define an @Input property on an Angular 2 component that's created dynamically?</p> <p>I'm using the <a href="https://angular.io/docs/ts/latest/api/core/index/ComponentFactoryResolver-class.html" rel="noreferrer">ComponentFactoryResolver</a> to create components in a container component. For example:</p> <pre><code>let componentFactory = this.componentFactoryResolver.resolveComponentFactory(componentName); let componentRef = entryPoint.createComponent(componentFactory); </code></pre> <p>Where "entryPoint" is something like this in the component HTML:</p> <pre><code>&lt;div #entryPoint&gt;&lt;/div&gt; </code></pre> <p>And defined in my container component with:</p> <pre><code>@ViewChild('entryPoint', { read: ViewContainerRef } entryPoint: ViewContainerRef; </code></pre> <p>This works well, but I can't find a way to make an @Input property work on the newly created component. I know that you can explicitly set public properties on the component class, but this doesn't seem to work with ng-reflect. Prior to making this change I had a "selected" property decorated with "@Input()" that caused Angular to add the following to the DOM:</p> <pre><code>&lt;my-component ng-reflected-selected="true"&gt;&lt;/my-component&gt; </code></pre> <p>With this in place I was able to dynamically update the markup to switch a CSS class:</p> <pre><code>&lt;div class="header" [class.active-header]="selected === true"&gt;&lt;/div&gt; </code></pre> <p>Based on some searching I was able to find a method to make "@Output" work as expected, but I've yet to find anything for @Input.</p> <p>Let me know if additional context would be helpful and I'd be happy to add it.</p>
0debug
Install EXPORT requires target from subproject : <p>I'm trying to write a cmake script for installing a project I'm working on. Part of this is the necessary <code>install(EXPORT LIB_EXPORTS ...)</code> where <code>LIB_EXPORTS</code> is what I've been using for the EXPORT property in my various <code>install(TARGETS ...)</code>.</p> <p>I have a superbuild structure that uses <code>add_subdirectory</code> to build some projects (SDL2, CivetWeb) that my project depends on.</p> <p>My problem is that when I use <code>target_link_libraries</code> to add a link from a subproject (SDL2-static from SDL2, c-library from CivetWeb) cmake complains that these dependencies aren't in the export set.</p> <pre><code>CMake Error: install(EXPORT "LIB_EXPORTS" ...) includes target "sc2api" which requires target "c-library" that is not in the export set. CMake Error: install(EXPORT "LIB_EXPORTS" ...) includes target "sc2renderer" which requires target "SDL2-static" that is not in the export set. </code></pre> <p>The only way I know to add targets to an export set is by using <code>install(TARGETS ... EXPORT LIB_EXPORTS)</code> but we can't install a target that this subdirectory hasn't created. I could <code>install(FILES ... EXPORT LIB_EXPORTS)</code> if I could find for sure where that library file's been generated but I have a feeling that this would install it twice (once by the CMakeLists.txt in the project subdirectory, once here). Frankly, I'm not sure why including these are necessary, since the libraries should be statically linked into the targets in my project.</p> <p>My questions:</p> <ol> <li>How should I include these external targets in the export set?</li> <li>If I shouldn't, what is the correct way to install the export set?</li> <li>Bonus question: These subprojects automatically add their install targets to my project's install target. Is this necessary? If it isn't, how do I disable this?</li> </ol>
0debug
Exeption with int to string convert in WriteLine : [Picture][1] [1]: https://i.stack.imgur.com/Htstz.png Exeption on english - "Argument 1: cant convert "int" into "string" But, in my parametrs and arguments i used only "int"-type. How can i typed my parametrs ( X and Y) used WriteLine metod?
0debug
static void gd_update_cursor(VirtualConsole *vc) { GtkDisplayState *s = vc->s; GdkWindow *window; if (vc->type != GD_VC_GFX) { return; } window = gtk_widget_get_window(GTK_WIDGET(vc->gfx.drawing_area)); if (s->full_screen || qemu_input_is_absolute() || gd_is_grab_active(s)) { gdk_window_set_cursor(window, s->null_cursor); } else { gdk_window_set_cursor(window, NULL); } }
1threat
mysql select query based on array value : I have a dynamic array . For example like this. $color = array('red','blue','green'); "SELECT * FROM mytable where colors=(red or blue or green)" But my array is dynamic. So i dont know the values and how can I loop the array and select the rows. PLz help me.
0debug
c++ loop hang if add any code inside if condition : hello i made a code and i see something very very strange. this is my code struct Mime { int key; string value; }; class Storage { private: int Size; Mime * _storage; int last = 0; public: Storage(int __size) { Size = __size; _storage = new Mime[Size + 2]; } void add(const Mime & __mime) { for (int x = 0; x < last; x++) if (_storage[x].key == __mime.key) {} _storage[last++] = __mime; } }; void test2() { int thisSize = 1000000; Storage storage(thisSize); auto start_t = chrono::high_resolution_clock::now(); for (int i = 0; i < thisSize; i++) { Mime temp; temp.key = i; temp.value = "Hey"; storage.add(temp); } cout << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start_t).count() << " milliseconds\n" << endl; } int main() { test2(); cout << "Done" << endl; return 0; } this code run in 120 milliseconds for me. but when i add some code here inside the `{}` if (_storage[x].key == __mime.key) {} like if (_storage[x].key == __mime.key) { return; } or anything else, my program run in 10 min !!! or sometimes hang !!! by adding return; or something else in this (if) nothing happen in the process because this bet is never happen to run the return; or something else. but when i add something like this return; or something else in this condition, my program hang !!!!!!!!!!!!!!!!!
0debug
How to upload multiple PDF files to server using alamofire? #Swift 4 #IOS : <p>How to upload multiple PDF files to server using third party library in swift 4 ?</p>
0debug
Change Azure virtual machine name in Azure portal : <p>Can we change the name of an Azure Virtual Machine in the Azure portal? I am sure we cannot change it via portal, do we have any PowerShell cmdlet to change the virtual machine name??</p> <p>Note: I am not referring to VM name inside the VM, but the name that is displayed in the Azure Portal.</p>
0debug
static void mips_fulong2e_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) { char *filename; unsigned long ram_offset, bios_offset; long bios_size; int64_t kernel_entry; qemu_irq *i8259; qemu_irq *cpu_exit_irq; int via_devfn; PCIBus *pci_bus; uint8_t *eeprom_buf; i2c_bus *smbus; int i; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DeviceState *eeprom; CPUState *env; if (cpu_model == NULL) { cpu_model = "Loongson-2E"; } env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } register_savevm(NULL, "cpu", 0, 3, cpu_save, cpu_load, env); qemu_register_reset(main_cpu_reset, env); ram_size = 256 * 1024 * 1024; bios_size = 1024 * 1024; ram_offset = qemu_ram_alloc(NULL, "fulong2e.ram", ram_size); bios_offset = qemu_ram_alloc(NULL, "fulong2e.bios", bios_size); cpu_register_physical_memory(0, ram_size, ram_offset); cpu_register_physical_memory(0x1fc00000LL, bios_size, bios_offset | IO_MEM_ROM); if (kernel_filename) { loaderparams.ram_size = ram_size; loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; kernel_entry = load_kernel (env); write_bootloader(env, qemu_get_ram_ptr(bios_offset), kernel_entry); } else { if (bios_name == NULL) { bios_name = FULONG_BIOSNAME; } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = load_image_targphys(filename, 0x1fc00000LL, BIOS_SIZE); qemu_free(filename); } else { bios_size = -1; } if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) { fprintf(stderr, "qemu: Could not load MIPS bios '%s'\n", bios_name); exit(1); } } cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); i8259 = i8259_init(env->irq[5]); pci_bus = bonito_init((qemu_irq *)&(env->irq[2])); if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { fprintf(stderr, "qemu: too many IDE bus\n"); exit(1); } for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); } via_devfn = vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0)); if (via_devfn < 0) { fprintf(stderr, "vt82c686b_init error \n"); exit(1); } isa_bus_irqs(i8259); vt82c686b_ide_init(pci_bus, hd, PCI_DEVFN(FULONG2E_VIA_SLOT, 1)); usb_uhci_vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 2)); usb_uhci_vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 3)); smbus = vt82c686b_pm_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 4), 0xeee1, NULL); eeprom_buf = qemu_mallocz(8 * 256); memcpy(eeprom_buf, eeprom_spd, sizeof(eeprom_spd)); eeprom = qdev_create((BusState *)smbus, "smbus-eeprom"); qdev_prop_set_uint8(eeprom, "address", 0x50); qdev_prop_set_ptr(eeprom, "data", eeprom_buf); qdev_init_nofail(eeprom); pit = pit_init(0x40, isa_reserve_irq(0)); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); isa_create_simple("i8042"); rtc_init(2000, NULL); for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { serial_isa_init(i, serial_hds[i]); } } if (parallel_hds[0]) { parallel_init(0, parallel_hds[0]); } audio_init(pci_bus); network_init(); }
1threat
static void rc4030_reset(DeviceState *dev) { rc4030State *s = RC4030(dev); int i; s->config = 0x410; s->revision = 1; s->invalid_address_register = 0; memset(s->dma_regs, 0, sizeof(s->dma_regs)); rc4030_dma_tt_update(s, 0, 0); s->remote_failed_address = s->memory_failed_address = 0; s->cache_maint = 0; s->cache_ptag = s->cache_ltag = 0; s->cache_bmask = 0; s->memory_refresh_rate = 0x18186; s->nvram_protect = 7; for (i = 0; i < 15; i++) s->rem_speed[i] = 7; s->imr_jazz = 0x10; s->isr_jazz = 0; s->itr = 0; qemu_irq_lower(s->timer_irq); qemu_irq_lower(s->jazz_bus_irq); }
1threat
static void gen_tlbre_booke206(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } gen_helper_booke206_tlbre(cpu_env); #endif }
1threat
Why are the thread ids not unique? : <p>I am trying to create a thread for each file (targeting Linux). The number of files is based off of the number of files in the current directory. Thus, I am trying to create a dynamic number of threads.</p> <p>After reading many SO questions and answers about dynamic thread creation and additional research, I came up with the following code. It is my understanding that to check if a thread was created for each file I can call gettid() which returns the caller's thread ID, and in a multithreaded process, all threads have the same PID, but each one has a unique TID. </p> <p>However, the TID I am printing is not unique, and I am not understanding why.</p> <pre><code>char **filenames; int file_cnt; DIR *dir; int main(int argc, char *argv[]) { int i; long tid; //atexit(cleanup); get_filenames(); //gets all files in the current directory printf("There are %d files:\n", file_cnt); pthread_t file[file_cnt]; for(i = 0; i &lt; file_cnt; i++) { printf("%s\n", filenames[i]); tid = syscall(SYS_gettid); pthread_create(&amp;(file[i], NULL, get_filenames, (void *)file[i]); printf("%ld\n", tid); } return EXIT_SUCCESS; } </code></pre> <p>Any suggestions as to why the threads are not unique? I am new to multithreading and am not understanding where I went wrong despite a lot of research.</p>
0debug
void mips_malta_init(QEMUMachineInitArgs *args) { ram_addr_t ram_size = args->ram_size; const char *cpu_model = args->cpu_model; const char *kernel_filename = args->kernel_filename; const char *kernel_cmdline = args->kernel_cmdline; const char *initrd_filename = args->initrd_filename; char *filename; pflash_t *fl; MemoryRegion *system_memory = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios, *bios_copy = g_new(MemoryRegion, 1); target_long bios_size = FLASH_SIZE; const size_t smbus_eeprom_size = 8 * 256; uint8_t *smbus_eeprom_buf = g_malloc0(smbus_eeprom_size); int64_t kernel_entry; PCIBus *pci_bus; ISABus *isa_bus; MIPSCPU *cpu; CPUMIPSState *env; qemu_irq *isa_irq; qemu_irq *cpu_exit_irq; int piix4_devfn; i2c_bus *smbus; int i; DriveInfo *dinfo; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DriveInfo *fd[MAX_FD]; int fl_idx = 0; int fl_sectors = bios_size >> 16; int be; DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA); MaltaState *s = MIPS_MALTA(dev); qdev_init_nofail(dev); for(i = 0; i < 3; i++) { if (!serial_hds[i]) { char label[32]; snprintf(label, sizeof(label), "serial%d", i); serial_hds[i] = qemu_chr_new(label, "null", NULL); } } if (cpu_model == NULL) { #ifdef TARGET_MIPS64 cpu_model = "20Kc"; #else cpu_model = "24Kf"; #endif } for (i = 0; i < smp_cpus; i++) { cpu = cpu_mips_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } env = &cpu->env; cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); qemu_register_reset(main_cpu_reset, cpu); } cpu = MIPS_CPU(first_cpu); env = &cpu->env; if (ram_size > (256 << 20)) { fprintf(stderr, "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n", ((unsigned int)ram_size / (1 << 20))); exit(1); } memory_region_init_ram(ram, NULL, "mips_malta.ram", ram_size); vmstate_register_ram_global(ram); memory_region_add_subregion(system_memory, 0, ram); generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size); generate_eeprom_serial(&smbus_eeprom_buf[6 * 256]); #ifdef TARGET_WORDS_BIGENDIAN be = 1; #else be = 0; #endif malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[4], serial_hds[2]); dinfo = drive_get(IF_PFLASH, 0, fl_idx); #ifdef DEBUG_BOARD_INIT if (dinfo) { printf("Register parallel flash %d size " TARGET_FMT_lx " at " "addr %08llx '%s' %x\n", fl_idx, bios_size, FLASH_ADDRESS, bdrv_get_device_name(dinfo->bdrv), fl_sectors); } #endif fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios", BIOS_SIZE, dinfo ? dinfo->bdrv : NULL, 65536, fl_sectors, 4, 0x0000, 0x0000, 0x0000, 0x0000, be); bios = pflash_cfi01_get_memory(fl); fl_idx++; if (kernel_filename) { loaderparams.ram_size = ram_size; loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; kernel_entry = load_kernel(); write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry); } else { if (!dinfo) { if (bios_name == NULL) { bios_name = BIOS_FILENAME; } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = load_image_targphys(filename, FLASH_ADDRESS, BIOS_SIZE); g_free(filename); } else { bios_size = -1; } if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename && !qtest_enabled()) { error_report("Could not load MIPS bios '%s', and no " "-kernel argument was specified", bios_name); exit(1); } } #ifndef TARGET_WORDS_BIGENDIAN { uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS); if (!addr) { addr = memory_region_get_ram_ptr(bios); } end = (void *)addr + MIN(bios_size, 0x3e0000); while (addr < end) { bswap32s(addr); addr++; } } #endif } memory_region_init_ram(bios_copy, NULL, "bios.1fc", BIOS_SIZE); if (!rom_copy(memory_region_get_ram_ptr(bios_copy), FLASH_ADDRESS, BIOS_SIZE)) { memcpy(memory_region_get_ram_ptr(bios_copy), memory_region_get_ram_ptr(bios), BIOS_SIZE); } memory_region_set_readonly(bios_copy, true); memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_copy); stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420); cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); isa_irq = qemu_irq_proxy(&s->i8259, 16); pci_bus = gt64120_register(isa_irq); ide_drive_get(hd, MAX_IDE_BUS); piix4_devfn = piix4_init(pci_bus, &isa_bus, 80); s->i8259 = i8259_init(isa_bus, env->irq[2]); isa_bus_irqs(isa_bus, s->i8259); pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1); pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci"); smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, isa_get_irq(NULL, 9), NULL, 0, NULL); smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, smbus_eeprom_size); g_free(smbus_eeprom_buf); pit = pit_init(isa_bus, 0x40, 0, NULL); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); isa_create_simple(isa_bus, "i8042"); rtc_init(isa_bus, 2000, NULL); serial_isa_init(isa_bus, 0, serial_hds[0]); serial_isa_init(isa_bus, 1, serial_hds[1]); if (parallel_hds[0]) parallel_init(isa_bus, 0, parallel_hds[0]); for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } fdctrl_init_isa(isa_bus, fd); network_init(pci_bus); pci_vga_init(pci_bus); }
1threat
int bdrv_get_flags(BlockDriverState *bs) { return bs->open_flags; }
1threat
static bool spapr_drc_needed(void *opaque) { sPAPRDRConnector *drc = (sPAPRDRConnector *)opaque; sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); bool rc = false; sPAPRDREntitySense value = drck->dr_entity_sense(drc); if (value != SPAPR_DR_ENTITY_SENSE_PRESENT) { return false; } switch (spapr_drc_type(drc)) { case SPAPR_DR_CONNECTOR_TYPE_PCI: case SPAPR_DR_CONNECTOR_TYPE_CPU: case SPAPR_DR_CONNECTOR_TYPE_LMB: rc = !((drc->isolation_state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) && (drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE) && drc->configured && !drc->awaiting_release); break; case SPAPR_DR_CONNECTOR_TYPE_PHB: case SPAPR_DR_CONNECTOR_TYPE_VIO: default: g_assert_not_reached(); } return rc; }
1threat
singly linked list counting algorithm : I need to write a metod that goes over a sorted singly linked list and returns the numer that appears the most times but goes over the list only one time can someone point me in the right direction? can't find an elegent solution yet, should i use recursion? I want the code to be as efficient as possible thanks in advance
0debug
cannot close menu when changing page : i just created a new page, valid only for devices right now i tested only for android, ios in the future You can take a look at this page here : [http://www.suale.it/prova/cqc/index.html][1] <br>The main problem, is that every time i change page in the menu, it does not collapse itself.<br> I tried with this code in the **quiz.js** file to collapse the menu, but has no effect: var x = document.getElementById("myTopnav"); x.className = "topnav"; what can i do? [1]: http://www.suale.it/prova/cqc/index.html
0debug
static int blk_mig_save_bulked_block(Monitor *mon, QEMUFile *f) { int64_t completed_sector_sum = 0; BlkMigDevState *bmds; int progress; int ret = 0; QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { if (bmds->bulk_completed == 0) { if (mig_save_device_bulk(mon, f, bmds) == 1) { bmds->bulk_completed = 1; } completed_sector_sum += bmds->completed_sectors; ret = 1; break; } else { completed_sector_sum += bmds->completed_sectors; } } if (block_mig_state.total_sector_sum != 0) { progress = completed_sector_sum * 100 / block_mig_state.total_sector_sum; } else { progress = 100; } if (progress != block_mig_state.prev_progress) { block_mig_state.prev_progress = progress; qemu_put_be64(f, (progress << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS); monitor_printf(mon, "Completed %d %%\r", progress); monitor_flush(mon); } return ret; }
1threat
How to expose audio from Docker container to a Mac? : <p>I know it's possible by using pulse audio on a Linux host system But <code>paprefs</code> is built for linux not mac.</p>
0debug
Mat-icon does not center in its div : <p>I am very new to css and I cannot align the mat-icon (the thought bubble) to the div class=img (the green square on the left) - see the attached image. At this moment the icon is a little bit near the top</p> <p>For adding the svg icon I used Material Angular - MatIconRegistry class (don't know if it matters)</p> <p>My result: <a href="https://i.stack.imgur.com/mdJKn.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/mdJKn.jpg" alt="enter image description here"></a></p> <p>Here is my html:</p> <pre><code>&lt;div class="container"&gt; &lt;div class="img"&gt;&lt;mat-icon svgIcon="info"&gt;&lt;/mat-icon&gt;&lt;/div&gt; Some text here! &lt;/div&gt; </code></pre> <p>Here is my css:</p> <pre><code>$conainer-min-width: 256px !default; $conainer-max-width: 512px !default; $conainer-height: 50px !default; div.container { max-width: $container-max-width; min-width: $container-min-width; height: $container-height; margin: auto; color: #000000; background-color: #ffffff; line-height: $container-height; text-align: center; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); border-width: 1px; border-style: solid; border-color: #9e9e9e; padding-right: 20px; position: fixed; z-index: 1000; left: 0; right: 0; top: 30px; } div.img { width: $container-height; height: $container-height; float: left; display: block; margin: 0 auto; border-right-width: 1px; border-right-style: solid; border-right-color: #9e9e9e; line-height: $container-height; justify-content: center; background-color: #3f9c35; } </code></pre> <p>Any thoughts on how to fix this?</p>
0debug
static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size, int64_t pos, uint64_t cluster_time, uint64_t block_duration, int is_keyframe, int64_t cluster_pos) { uint64_t timecode = AV_NOPTS_VALUE; MatroskaTrack *track; int res = 0; AVStream *st; int16_t block_time; uint32_t *lace_size = NULL; int n, flags, laces = 0; uint64_t num, duration; if ((n = matroska_ebmlnum_uint(matroska, data, size, &num)) < 0) { av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n"); return n; } data += n; size -= n; track = matroska_find_track_by_num(matroska, num); if (!track || !track->stream) { av_log(matroska->ctx, AV_LOG_INFO, "Invalid stream %"PRIu64" or size %u\n", num, size); return AVERROR_INVALIDDATA; } else if (size <= 3) return 0; st = track->stream; if (st->discard >= AVDISCARD_ALL) return res; block_time = AV_RB16(data); data += 2; flags = *data++; size -= 3; if (is_keyframe == -1) is_keyframe = flags & 0x80 ? AV_PKT_FLAG_KEY : 0; if (cluster_time != (uint64_t)-1 && (block_time >= 0 || cluster_time >= -block_time)) { timecode = cluster_time + block_time; if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE && timecode < track->end_timecode) is_keyframe = 0; if (is_keyframe) av_add_index_entry(st, cluster_pos, timecode, 0,0,AVINDEX_KEYFRAME); } if (matroska->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) { if (!is_keyframe || timecode < matroska->skip_to_timecode) return res; matroska->skip_to_keyframe = 0; } res = matroska_parse_laces(matroska, &data, &size, (flags & 0x06) >> 1, &lace_size, &laces); if (res) goto end; if (block_duration != AV_NOPTS_VALUE) { duration = block_duration / laces; if (block_duration != duration * laces) { av_log(matroska->ctx, AV_LOG_WARNING, "Incorrect block_duration, possibly corrupted container"); } } else { duration = track->default_duration / matroska->time_scale; block_duration = duration * laces; } if (timecode != AV_NOPTS_VALUE) track->end_timecode = FFMAX(track->end_timecode, timecode + block_duration); for (n = 0; n < laces; n++) { if ((st->codec->codec_id == AV_CODEC_ID_RA_288 || st->codec->codec_id == AV_CODEC_ID_COOK || st->codec->codec_id == AV_CODEC_ID_SIPR || st->codec->codec_id == AV_CODEC_ID_ATRAC3) && st->codec->block_align && track->audio.sub_packet_size) { res = matroska_parse_rm_audio(matroska, track, st, data, size, timecode, duration, pos); if (res) goto end; } else { res = matroska_parse_frame(matroska, track, st, data, lace_size[n], timecode, duration, pos, !n? is_keyframe : 0); if (res) goto end; } if (timecode != AV_NOPTS_VALUE) timecode = duration ? timecode + duration : AV_NOPTS_VALUE; data += lace_size[n]; size -= lace_size[n]; } end: av_free(lace_size); return res; }
1threat
Differences between Angular JS, JSON and JS? : I know that Angular JS is advanced JavaScript but what will be the extension for it? And know about what is JSON? Also want to know how to select syntax in sublime text editor 3 for Angular JS?
0debug
How to use NSLog with data from a server : <p>Hi there I'm trying to do an NSLog but what I want to see is what it's inside of my dictionary like this. </p> <p>NSLog(@"diccionario", diccionario); </p> <p>And this warning appears:</p> <p>Data argument not used by format string</p> <p>The diccionario object contains data from a server so like I said I want to print in the console the info that diccionario contains, because is not printing anything. </p> <p>Thanks. </p>
0debug
static int synthfilt_build_sb_samples(QDM2Context *q, GetBitContext *gb, int length, int sb_min, int sb_max) { int sb, j, k, n, ch, run, channels; int joined_stereo, zero_encoding; int type34_first; float type34_div = 0; float type34_predictor; float samples[10]; int sign_bits[16]; if (length == 0) { for (sb=sb_min; sb < sb_max; sb++) build_sb_samples_from_noise (q, sb); return 0; } for (sb = sb_min; sb < sb_max; sb++) { channels = q->nb_channels; if (q->nb_channels <= 1 || sb < 12) joined_stereo = 0; else if (sb >= 24) joined_stereo = 1; else joined_stereo = (get_bits_left(gb) >= 1) ? get_bits1 (gb) : 0; if (joined_stereo) { if (get_bits_left(gb) >= 16) for (j = 0; j < 16; j++) sign_bits[j] = get_bits1 (gb); for (j = 0; j < 64; j++) if (q->coding_method[1][sb][j] > q->coding_method[0][sb][j]) q->coding_method[0][sb][j] = q->coding_method[1][sb][j]; if (fix_coding_method_array(sb, q->nb_channels, q->coding_method)) { av_log(NULL, AV_LOG_ERROR, "coding method invalid\n"); build_sb_samples_from_noise(q, sb); continue; } channels = 1; } for (ch = 0; ch < channels; ch++) { FIX_NOISE_IDX(q->noise_idx); zero_encoding = (get_bits_left(gb) >= 1) ? get_bits1(gb) : 0; type34_predictor = 0.0; type34_first = 1; for (j = 0; j < 128; ) { switch (q->coding_method[ch][sb][j / 2]) { case 8: if (get_bits_left(gb) >= 10) { if (zero_encoding) { for (k = 0; k < 5; k++) { if ((j + 2 * k) >= 128) break; samples[2 * k] = get_bits1(gb) ? dequant_1bit[joined_stereo][2 * get_bits1(gb)] : 0; } } else { n = get_bits(gb, 8); if (n >= 243) { av_log(NULL, AV_LOG_ERROR, "Invalid 8bit codeword\n"); return AVERROR_INVALIDDATA; } for (k = 0; k < 5; k++) samples[2 * k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]]; } for (k = 0; k < 5; k++) samples[2 * k + 1] = SB_DITHERING_NOISE(sb,q->noise_idx); } else { for (k = 0; k < 10; k++) samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 10; break; case 10: if (get_bits_left(gb) >= 1) { float f = 0.81; if (get_bits1(gb)) f = -f; f -= noise_samples[((sb + 1) * (j +5 * ch + 1)) & 127] * 9.0 / 40.0; samples[0] = f; } else { samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 1; break; case 16: if (get_bits_left(gb) >= 10) { if (zero_encoding) { for (k = 0; k < 5; k++) { if ((j + k) >= 128) break; samples[k] = (get_bits1(gb) == 0) ? 0 : dequant_1bit[joined_stereo][2 * get_bits1(gb)]; } } else { n = get_bits (gb, 8); if (n >= 243) { av_log(NULL, AV_LOG_ERROR, "Invalid 8bit codeword\n"); return AVERROR_INVALIDDATA; } for (k = 0; k < 5; k++) samples[k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]]; } } else { for (k = 0; k < 5; k++) samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 5; break; case 24: if (get_bits_left(gb) >= 7) { n = get_bits(gb, 7); if (n >= 125) { av_log(NULL, AV_LOG_ERROR, "Invalid 7bit codeword\n"); return AVERROR_INVALIDDATA; } for (k = 0; k < 3; k++) samples[k] = (random_dequant_type24[n][k] - 2.0) * 0.5; } else { for (k = 0; k < 3; k++) samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 3; break; case 30: if (get_bits_left(gb) >= 4) { unsigned index = qdm2_get_vlc(gb, &vlc_tab_type30, 0, 1); if (index >= FF_ARRAY_ELEMS(type30_dequant)) { av_log(NULL, AV_LOG_ERROR, "index %d out of type30_dequant array\n", index); return AVERROR_INVALIDDATA; } samples[0] = type30_dequant[index]; } else samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); run = 1; break; case 34: if (get_bits_left(gb) >= 7) { if (type34_first) { type34_div = (float)(1 << get_bits(gb, 2)); samples[0] = ((float)get_bits(gb, 5) - 16.0) / 15.0; type34_predictor = samples[0]; type34_first = 0; } else { unsigned index = qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1); if (index >= FF_ARRAY_ELEMS(type34_delta)) { av_log(NULL, AV_LOG_ERROR, "index %d out of type34_delta array\n", index); return AVERROR_INVALIDDATA; } samples[0] = type34_delta[index] / type34_div + type34_predictor; type34_predictor = samples[0]; } } else { samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); } run = 1; break; default: samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx); run = 1; break; } if (joined_stereo) { for (k = 0; k < run && j + k < 128; k++) { q->sb_samples[0][j + k][sb] = q->tone_level[0][sb][(j + k) / 2] * samples[k]; if (q->nb_channels == 2) { if (sign_bits[(j + k) / 8]) q->sb_samples[1][j + k][sb] = q->tone_level[1][sb][(j + k) / 2] * -samples[k]; else q->sb_samples[1][j + k][sb] = q->tone_level[1][sb][(j + k) / 2] * samples[k]; } } } else { for (k = 0; k < run; k++) if ((j + k) < 128) q->sb_samples[ch][j + k][sb] = q->tone_level[ch][sb][(j + k)/2] * samples[k]; } j += run; } } } return 0; }
1threat
C++ check for valid IP-Adress or IP : <p>I'm currently trying to check the user input to be a valid URL (http(s)://www.abc.at or localhost) or a valid IP-Address (127.0.0.1, ...) using only the standard C++ methods like REGEX. I could use the libraries ASIO (standalone), regex and arpa/inet.h. Is there a way to do that in very simple ways?</p> <p>Thanks for your help!</p>
0debug
Solving the double precision issue for string representations of 0d and -.1d : I have a numeric up/down control, essentially a normal textbox with up down buttons next to it that stores its value as a double. I have been running into an issue when cycling up and down, when the value is (or should be) 0 or -.1, the text box displays "1.38777878078145E-16" and "-0.0999999999999999" respectively. I get that the floating point precision of double means that values get truncated and absolute precision for decimals longer than the doubles precision are lost. But seeing as how .1 does not have a long decimal or need high precision, shouldn't .1 - .1 = 0? Right now I am just catching the string in my double to string converter and handling it, but is there a better way to do this? No I cannot use decimal due to its overhead. [ValueConversion(typeof(Double), typeof(String))] public class DoubleToStringValueConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string res = ((double)value).ToString(culture); if (res == "1.38777878078145E-16") res = "0"; if (res == "-0.0999999999999999") res = "-1"; return res; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string val = value as string; double res = 0d; double.TryParse(val, System.Globalization.NumberStyles.Float, culture, out res); return res; } }
0debug
How to convert characters of a string "One" into an Integer "1" in swift : <p>I have implemented an quiz application in swift 4.0. Here, user can enter his choice from ("one" or "1") to ("four" or "4") .</p> <p>If the user can provide his choice as an integer(Eg 1,2,3, or 4)then there is no issue. but if he provide his choice as an alphabet characters (Eg "one","two", ..), then i am facing the issues while validating correct answer.</p> <p>Kindly, could anyone help me, How to convert word characters "one" into integer 1 etc..</p> <p>thanks a lot in advance.</p>
0debug
How can I read the first line only in file : <p>I want a code that reads the first line only ( horizontal),and a code that convert a string to an integer number</p>
0debug
PHP auto compute multidimensional arrays against one another : <p>I have a multidimensional array.</p> <pre><code>$parent_array($child1('lat','long'),$child2('lat','long')...) </code></pre> <p>The amount of child arrays can be of any value per request starting from 2. The parent array is then called into a function that has a google distance calculator between to or more points.</p> <pre><code>function distance($parent_array) { foreach ( $parent_array as $child){ $distance = file_get_contents('https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&amp;origins='.$child1['lat'].','.$child1['long'].'&amp;destinations='.$child2['lat'].','.$child2['long'].'&amp;key=********************************'); $trim = trim($this-&gt;objectToArray($distance)['rows'][0]['elements'][0]['distance']['text'],' km'); } return $trim; } </code></pre> <p>I need to get this function to calculate the distance between all posted child arrays as illustrated on the above function using </p> <blockquote> <p>$child1 and $child2</p> </blockquote>
0debug
static void socket_start_outgoing_migration(MigrationState *s, SocketAddress *saddr, Error **errp) { QIOChannelSocket *sioc = qio_channel_socket_new(); struct SocketConnectData *data = g_new0(struct SocketConnectData, 1); data->s = s; if (saddr->type == SOCKET_ADDRESS_KIND_INET) { data->hostname = g_strdup(saddr->u.inet.data->host); } qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-outgoing"); qio_channel_socket_connect_async(sioc, saddr, socket_outgoing_migration, data, socket_connect_data_free); qapi_free_SocketAddress(saddr); }
1threat
int avpicture_fill(AVPicture *picture, uint8_t *ptr, enum AVPixelFormat pix_fmt, int width, int height) { int ret; if ((ret = av_image_check_size(width, height, 0, NULL)) < 0) return ret; if ((ret = av_image_fill_linesizes(picture->linesize, pix_fmt, width)) < 0) return ret; return av_image_fill_pointers(picture->data, pix_fmt, height, ptr, picture->linesize); }
1threat
Difference between organisation member and outside collaborator in github : <p>The <a href="https://help.github.com/categories/setting-up-and-managing-organizations-and-teams/" rel="noreferrer">github docs</a> are a bit unclear about the semantic difference between organisation member and outside collaborator. What is the distinction?</p> <p>I run an github organisation for my school. I create repos and allocate them to students. Should the students be members of the org or outside collaborators? </p>
0debug
How to Sort Date in ArrayList in Java : <p>I have a Map&lt; String,ArrayList&lt; BonusEntity > > Here key is EmpId of Employee and key will contains the List&lt; BonusEntity ></p> <p>BonusEntity will contains the following fields(All fields are String)</p> <p>Empid BonusDate BonusAmount Dept</p> <p>I need to sort the ArrayList in Map based on the BonusDate descending order,Can anyone help Thanks in advance.</p>
0debug
How to rename a pane in tmux? : <p>How to rename a pane in <code>tmux</code> ?</p>
0debug
void helper_syscall(CPUX86State *env, int next_eip_addend) { int selector; if (!(env->efer & MSR_EFER_SCE)) { raise_exception_err(env, EXCP06_ILLOP, 0); } selector = (env->star >> 32) & 0xffff; if (env->hflags & HF_LMA_MASK) { int code64; env->regs[R_ECX] = env->eip + next_eip_addend; env->regs[11] = cpu_compute_eflags(env); code64 = env->hflags & HF_CS64_MASK; env->eflags &= ~env->fmask; cpu_load_eflags(env, env->eflags, 0); cpu_x86_set_cpl(env, 0); cpu_x86_load_seg_cache(env, R_CS, selector & 0xfffc, 0, 0xffffffff, DESC_G_MASK | DESC_P_MASK | DESC_S_MASK | DESC_CS_MASK | DESC_R_MASK | DESC_A_MASK | DESC_L_MASK); cpu_x86_load_seg_cache(env, R_SS, (selector + 8) & 0xfffc, 0, 0xffffffff, DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | DESC_W_MASK | DESC_A_MASK); if (code64) { env->eip = env->lstar; } else { env->eip = env->cstar; } } else { env->regs[R_ECX] = (uint32_t)(env->eip + next_eip_addend); env->eflags &= ~(IF_MASK | RF_MASK | VM_MASK); cpu_x86_set_cpl(env, 0); cpu_x86_load_seg_cache(env, R_CS, selector & 0xfffc, 0, 0xffffffff, DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | DESC_CS_MASK | DESC_R_MASK | DESC_A_MASK); cpu_x86_load_seg_cache(env, R_SS, (selector + 8) & 0xfffc, 0, 0xffffffff, DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | DESC_W_MASK | DESC_A_MASK); env->eip = (uint32_t)env->star; } }
1threat
Generate clang compilation database for a Visual Studio project : <p>Visual Studio was added a lot of support for Clang.</p> <p>I want to use clang-tidy.exe for a Visual-Studio project. In order to do that I need the JSON "compilation database".</p> <p>Is there some way to export this database from a visual studio (2015) project?</p>
0debug
build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets) { AcpiRsdtDescriptorRev1 *rsdt; size_t rsdt_len; int i; const int table_data_len = (sizeof(uint32_t) * table_offsets->len); rsdt_len = sizeof(*rsdt) + table_data_len; rsdt = acpi_data_push(table_data, rsdt_len); memcpy(rsdt->table_offset_entry, table_offsets->data, table_data_len); for (i = 0; i < table_offsets->len; ++i) { bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TABLE_FILE, table_data, &rsdt->table_offset_entry[i], sizeof(uint32_t)); } build_header(linker, table_data, (void *)rsdt, "RSDT", rsdt_len, 1, NULL, NULL); }
1threat
Calling a function in another form : My question is about dealing with multiple forms in c# windows form application. I am developing a code for playing a movie and moving it frame by frame with buttons. I already have the code for moving the movie frame by frame with ctlcontrols in windows media player. The thing that I'm having an issue with is that I want to have a main form and a movie form, and when i click the button in the main form, i want to send a number to the other form and if the number was 2, i want the movie to go frame by frame in the movie form. And I want to do it without opening a new form every time I click the button. I have made a function in my second form and I called it in the button in the main form. It is expected to work but it doesn't. Any help ASAP would be appreciated. The code for the button in the main form is: private void button1_Click(object sender, EventArgs e) { value = txtSendNum.Text; //get the value from the textox and assign it to string variable MovieForm movieform = new MovieForm(); //create an object for MovieForm movieform.ConnectForms(value); } The code for the function(ConnectForms function) in the second form is: public void ConnectForms(string value) { val = Convert.ToInt32(value); if (val == 2) { axWindowsMediaPlayer1.Ctlcontrols.play(); axWindowsMediaPlayer1.Ctlcontrols.currentPosition += 0.5; axWindowsMediaPlayer1.Ctlcontrols.stop(); } }
0debug
React: Do children always rerender when the parent component rerenders? : <p>It is to my knowledge that if a parent component rerenders, then all its children will rerender UNLESS they implement <code>shouldComponentUpdate()</code>. I <a href="https://codesandbox.io/s/2x3rmx7rr0" rel="noreferrer">made an example</a> where this doesn't seem to be the true.</p> <p>I have 3 components: <code>&lt;DynamicParent/&gt;</code>, <code>&lt;StaticParent/&gt;</code> and <code>&lt;Child/&gt;</code>. The <code>&lt;Parent/&gt;</code> components are responsible for rendering the <code>&lt;Child/&gt;</code> but do so in different ways.</p> <p><code>&lt;StaticParent/&gt;</code>'s render function statically declares the <code>&lt;Child/&gt;</code> before runtime, like so:</p> <pre><code> &lt;StaticParent&gt; &lt;Child /&gt; &lt;/StaticParent&gt; </code></pre> <p>While the <code>&lt;DynamicParent/&gt;</code> handles receiving and rendering the <code>&lt;Child/&gt;</code> dynamically at runtime, like so: </p> <pre><code> &lt;DynamicParent&gt; { this.props.children } &lt;/DynamicParent&gt; </code></pre> <p>Both <code>&lt;DynamicParent/&gt;</code> and <code>&lt;StaticParent/&gt;</code> have <code>onClick</code> listeners to change their state and rerender when clicked. I noticed that when clicking <code>&lt;StaticParent/&gt;</code> both it and the <code>&lt;Child/&gt;</code> are rerendered. But when I click <code>&lt;DynamicParent/&gt;</code>, then only the parent and NOT <code>&lt;Child/&gt;</code> are rerendered.</p> <p><code>&lt;Child/&gt;</code> is a functional component without <code>shouldComponentUpdate()</code> so I don't understand why it doesn't rerender. Can someone explain why this is to be the case? I can't find anything in the docs related to this use case.</p>
0debug
int net_init_vhost_user(const NetClientOptions *opts, const char *name, NetClientState *peer, Error **errp) { const NetdevVhostUserOptions *vhost_user_opts; CharDriverState *chr; assert(opts->kind == NET_CLIENT_OPTIONS_KIND_VHOST_USER); vhost_user_opts = opts->vhost_user; chr = net_vhost_parse_chardev(vhost_user_opts, errp); if (!chr) { return -1; } if (qemu_opts_foreach(qemu_find_opts("device"), net_vhost_check_net, (char *)name, errp)) { return -1; } return net_vhost_user_init(peer, "vhost_user", name, chr); }
1threat
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags) { OverlayContext *over = ctx->priv; int ret; if (!strcmp(cmd, "x")) ret = set_expr(&over->x_pexpr, args, ctx); else if (!strcmp(cmd, "y")) ret = set_expr(&over->y_pexpr, args, ctx); else if (!strcmp(cmd, "enable")) ret = set_expr(&over->enable_pexpr, args, ctx); else ret = AVERROR(ENOSYS); if (ret < 0) return ret; if (over->eval_mode == EVAL_MODE_INIT) { eval_expr(ctx, EVAL_ALL); av_log(ctx, AV_LOG_VERBOSE, "x:%f xi:%d y:%f yi:%d enable:%f\n", over->var_values[VAR_X], over->x, over->var_values[VAR_Y], over->y, over->enable); } return ret; }
1threat
Are swift classes inside struct passed by copy during assignment? : <p>If I have a struct in swift with inside a class attribute and I copy the struct object, is the class attribute copied or passed by reference?</p>
0debug
Why opencv parameter table will have [ this symbol sometimes has one sometimes three : https://i.stack.imgur.com/89gTQ.png veryveryveryevrythank you for your help
0debug
static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp) { int idx = 0; BlockDriverState *new_bs = NULL; Error *local_err = NULL; char *desc = NULL; int64_t total_size = 0, filesize; char *adapter_type = NULL; char *backing_file = NULL; char *fmt = NULL; int flags = 0; int ret = 0; bool flat, split, compress; GString *ext_desc_lines; char path[PATH_MAX], prefix[PATH_MAX], postfix[PATH_MAX]; const int64_t split_size = 0x80000000; const char *desc_extent_line; char parent_desc_line[BUF_SIZE] = ""; uint32_t parent_cid = 0xffffffff; uint32_t number_heads = 16; bool zeroed_grain = false; uint32_t desc_offset = 0, desc_len; const char desc_template[] = "# Disk DescriptorFile\n" "version=1\n" "CID=%" PRIx32 "\n" "parentCID=%" PRIx32 "\n" "createType=\"%s\"\n" "%s" "\n" "# Extent description\n" "%s" "\n" "# The Disk Data Base\n" "#DDB\n" "\n" "ddb.virtualHWVersion = \"%d\"\n" "ddb.geometry.cylinders = \"%" PRId64 "\"\n" "ddb.geometry.heads = \"%" PRIu32 "\"\n" "ddb.geometry.sectors = \"63\"\n" "ddb.adapterType = \"%s\"\n"; ext_desc_lines = g_string_new(NULL); if (filename_decompose(filename, path, prefix, postfix, PATH_MAX, errp)) { ret = -EINVAL; goto exit; } total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); adapter_type = qemu_opt_get_del(opts, BLOCK_OPT_ADAPTER_TYPE); backing_file = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE); if (qemu_opt_get_bool_del(opts, BLOCK_OPT_COMPAT6, false)) { flags |= BLOCK_FLAG_COMPAT6; } fmt = qemu_opt_get_del(opts, BLOCK_OPT_SUBFMT); if (qemu_opt_get_bool_del(opts, BLOCK_OPT_ZEROED_GRAIN, false)) { zeroed_grain = true; } if (!adapter_type) { adapter_type = g_strdup("ide"); } else if (strcmp(adapter_type, "ide") && strcmp(adapter_type, "buslogic") && strcmp(adapter_type, "lsilogic") && strcmp(adapter_type, "legacyESX")) { error_setg(errp, "Unknown adapter type: '%s'", adapter_type); ret = -EINVAL; goto exit; } if (strcmp(adapter_type, "ide") != 0) { number_heads = 255; } if (!fmt) { fmt = g_strdup("monolithicSparse"); } else if (strcmp(fmt, "monolithicFlat") && strcmp(fmt, "monolithicSparse") && strcmp(fmt, "twoGbMaxExtentSparse") && strcmp(fmt, "twoGbMaxExtentFlat") && strcmp(fmt, "streamOptimized")) { error_setg(errp, "Unknown subformat: '%s'", fmt); ret = -EINVAL; goto exit; } split = !(strcmp(fmt, "twoGbMaxExtentFlat") && strcmp(fmt, "twoGbMaxExtentSparse")); flat = !(strcmp(fmt, "monolithicFlat") && strcmp(fmt, "twoGbMaxExtentFlat")); compress = !strcmp(fmt, "streamOptimized"); if (flat) { desc_extent_line = "RW %" PRId64 " FLAT \"%s\" 0\n"; } else { desc_extent_line = "RW %" PRId64 " SPARSE \"%s\"\n"; } if (flat && backing_file) { error_setg(errp, "Flat image can't have backing file"); ret = -ENOTSUP; goto exit; } if (flat && zeroed_grain) { error_setg(errp, "Flat image can't enable zeroed grain"); ret = -ENOTSUP; goto exit; } if (backing_file) { BlockDriverState *bs = NULL; ret = bdrv_open(&bs, backing_file, NULL, NULL, BDRV_O_NO_BACKING, NULL, errp); if (ret != 0) { goto exit; } if (strcmp(bs->drv->format_name, "vmdk")) { bdrv_unref(bs); ret = -EINVAL; goto exit; } parent_cid = vmdk_read_cid(bs, 0); bdrv_unref(bs); snprintf(parent_desc_line, sizeof(parent_desc_line), "parentFileNameHint=\"%s\"", backing_file); } filesize = total_size; while (filesize > 0) { char desc_line[BUF_SIZE]; char ext_filename[PATH_MAX]; char desc_filename[PATH_MAX]; int64_t size = filesize; if (split && size > split_size) { size = split_size; } if (split) { snprintf(desc_filename, sizeof(desc_filename), "%s-%c%03d%s", prefix, flat ? 'f' : 's', ++idx, postfix); } else if (flat) { snprintf(desc_filename, sizeof(desc_filename), "%s-flat%s", prefix, postfix); } else { snprintf(desc_filename, sizeof(desc_filename), "%s%s", prefix, postfix); } snprintf(ext_filename, sizeof(ext_filename), "%s%s", path, desc_filename); if (vmdk_create_extent(ext_filename, size, flat, compress, zeroed_grain, opts, errp)) { ret = -EINVAL; goto exit; } filesize -= size; snprintf(desc_line, sizeof(desc_line), desc_extent_line, size / BDRV_SECTOR_SIZE, desc_filename); g_string_append(ext_desc_lines, desc_line); } desc = g_strdup_printf(desc_template, g_random_int(), parent_cid, fmt, parent_desc_line, ext_desc_lines->str, (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4), total_size / (int64_t)(63 * number_heads * BDRV_SECTOR_SIZE), number_heads, adapter_type); desc_len = strlen(desc); if (!split && !flat) { desc_offset = 0x200; } else { ret = bdrv_create_file(filename, opts, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; } } assert(new_bs == NULL); ret = bdrv_open(&new_bs, filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, NULL, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; } ret = bdrv_pwrite(new_bs, desc_offset, desc, desc_len); if (ret < 0) { error_setg_errno(errp, -ret, "Could not write description"); goto exit; } if (desc_offset == 0) { ret = bdrv_truncate(new_bs, desc_len); if (ret < 0) { error_setg_errno(errp, -ret, "Could not truncate file"); } } exit: if (new_bs) { bdrv_unref(new_bs); } g_free(adapter_type); g_free(backing_file); g_free(fmt); g_free(desc); g_string_free(ext_desc_lines, true); return ret; }
1threat
how java compiler solved lambda return type while Predicator's method can only return boolean? : Note: this question look like some others but different Things i can't understand is that we know java doesn't support dynamic type even use Lambda, and it's compiled to Predictor during compile time. Things i can't understand is that Predicator's default method only can return boolean, while Lambda expression can return anything. HOW is this archived?
0debug
int net_client_init(Monitor *mon, const char *device, const char *p) { static const char * const fd_params[] = { "vlan", "name", "fd", NULL }; char buf[1024]; int vlan_id, ret; VLANState *vlan; char *name = NULL; vlan_id = 0; if (get_param_value(buf, sizeof(buf), "vlan", p)) { vlan_id = strtol(buf, NULL, 0); } vlan = qemu_find_vlan(vlan_id); if (get_param_value(buf, sizeof(buf), "name", p)) { name = qemu_strdup(buf); } if (!strcmp(device, "nic")) { static const char * const nic_params[] = { "vlan", "name", "macaddr", "model", "addr", NULL }; NICInfo *nd; uint8_t *macaddr; int idx = nic_get_free_idx(); if (check_params(buf, sizeof(buf), nic_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); ret = -1; goto out; } if (idx == -1 || nb_nics >= MAX_NICS) { config_error(mon, "Too Many NICs\n"); ret = -1; goto out; } nd = &nd_table[idx]; macaddr = nd->macaddr; macaddr[0] = 0x52; macaddr[1] = 0x54; macaddr[2] = 0x00; macaddr[3] = 0x12; macaddr[4] = 0x34; macaddr[5] = 0x56 + idx; if (get_param_value(buf, sizeof(buf), "macaddr", p)) { if (parse_macaddr(macaddr, buf) < 0) { config_error(mon, "invalid syntax for ethernet address\n"); ret = -1; goto out; } } if (get_param_value(buf, sizeof(buf), "model", p)) { nd->model = strdup(buf); } if (get_param_value(buf, sizeof(buf), "addr", p)) { nd->devaddr = strdup(buf); } nd->vlan = vlan; nd->name = name; nd->used = 1; name = NULL; nb_nics++; vlan->nb_guest_devs++; ret = idx; } else if (!strcmp(device, "none")) { if (*p != '\0') { config_error(mon, "'none' takes no parameters\n"); ret = -1; goto out; } ret = 0; } else #ifdef CONFIG_SLIRP if (!strcmp(device, "user")) { static const char * const slirp_params[] = { "vlan", "name", "hostname", "restrict", "ip", NULL }; int restricted = 0; char *ip = NULL; if (check_params(buf, sizeof(buf), slirp_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); ret = -1; goto out; } if (get_param_value(buf, sizeof(buf), "hostname", p)) { pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf); } if (get_param_value(buf, sizeof(buf), "restrict", p)) { restricted = (buf[0] == 'y') ? 1 : 0; } if (get_param_value(buf, sizeof(buf), "ip", p)) { ip = qemu_strdup(buf); } vlan->nb_host_devs++; ret = net_slirp_init(vlan, device, name, restricted, ip); qemu_free(ip); } else if (!strcmp(device, "channel")) { long port; char name[20], *devname; struct VMChannel *vmc; port = strtol(p, &devname, 10); devname++; if (port < 1 || port > 65535) { config_error(mon, "vmchannel wrong port number\n"); ret = -1; goto out; } vmc = malloc(sizeof(struct VMChannel)); snprintf(name, 20, "vmchannel%ld", port); vmc->hd = qemu_chr_open(name, devname, NULL); if (!vmc->hd) { config_error(mon, "could not open vmchannel device '%s'\n", devname); ret = -1; goto out; } vmc->port = port; slirp_add_exec(3, vmc->hd, 4, port); qemu_chr_add_handlers(vmc->hd, vmchannel_can_read, vmchannel_read, NULL, vmc); ret = 0; } else #endif #ifdef _WIN32 if (!strcmp(device, "tap")) { static const char * const tap_params[] = { "vlan", "name", "ifname", NULL }; char ifname[64]; if (check_params(buf, sizeof(buf), tap_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); ret = -1; goto out; } if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { config_error(mon, "tap: no interface name\n"); ret = -1; goto out; } vlan->nb_host_devs++; ret = tap_win32_init(vlan, device, name, ifname); } else #elif defined (_AIX) #else if (!strcmp(device, "tap")) { char ifname[64], chkbuf[64]; char setup_script[1024], down_script[1024]; TAPState *s; int fd; vlan->nb_host_devs++; if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { if (check_params(chkbuf, sizeof(chkbuf), fd_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } fd = strtol(buf, NULL, 0); fcntl(fd, F_SETFL, O_NONBLOCK); s = net_tap_fd_init(vlan, device, name, fd); } else { static const char * const tap_params[] = { "vlan", "name", "ifname", "script", "downscript", NULL }; if (check_params(chkbuf, sizeof(chkbuf), tap_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { ifname[0] = '\0'; } if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) { pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT); } if (get_param_value(down_script, sizeof(down_script), "downscript", p) == 0) { pstrcpy(down_script, sizeof(down_script), DEFAULT_NETWORK_DOWN_SCRIPT); } s = net_tap_init(vlan, device, name, ifname, setup_script, down_script); } if (s != NULL) { ret = 0; } else { ret = -1; } } else #endif if (!strcmp(device, "socket")) { char chkbuf[64]; if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { int fd; if (check_params(chkbuf, sizeof(chkbuf), fd_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } fd = strtol(buf, NULL, 0); ret = -1; if (net_socket_fd_init(vlan, device, name, fd, 1)) ret = 0; } else if (get_param_value(buf, sizeof(buf), "listen", p) > 0) { static const char * const listen_params[] = { "vlan", "name", "listen", NULL }; if (check_params(chkbuf, sizeof(chkbuf), listen_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } ret = net_socket_listen_init(vlan, device, name, buf); } else if (get_param_value(buf, sizeof(buf), "connect", p) > 0) { static const char * const connect_params[] = { "vlan", "name", "connect", NULL }; if (check_params(chkbuf, sizeof(chkbuf), connect_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } ret = net_socket_connect_init(vlan, device, name, buf); } else if (get_param_value(buf, sizeof(buf), "mcast", p) > 0) { static const char * const mcast_params[] = { "vlan", "name", "mcast", NULL }; if (check_params(chkbuf, sizeof(chkbuf), mcast_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); ret = -1; goto out; } ret = net_socket_mcast_init(vlan, device, name, buf); } else { config_error(mon, "Unknown socket options: %s\n", p); ret = -1; goto out; } vlan->nb_host_devs++; } else #ifdef CONFIG_VDE if (!strcmp(device, "vde")) { static const char * const vde_params[] = { "vlan", "name", "sock", "port", "group", "mode", NULL }; char vde_sock[1024], vde_group[512]; int vde_port, vde_mode; if (check_params(buf, sizeof(buf), vde_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p); ret = -1; goto out; } vlan->nb_host_devs++; if (get_param_value(vde_sock, sizeof(vde_sock), "sock", p) <= 0) { vde_sock[0] = '\0'; } if (get_param_value(buf, sizeof(buf), "port", p) > 0) { vde_port = strtol(buf, NULL, 10); } else { vde_port = 0; } if (get_param_value(vde_group, sizeof(vde_group), "group", p) <= 0) { vde_group[0] = '\0'; } if (get_param_value(buf, sizeof(buf), "mode", p) > 0) { vde_mode = strtol(buf, NULL, 8); } else { vde_mode = 0700; } ret = net_vde_init(vlan, device, name, vde_sock, vde_port, vde_group, vde_mode); } else #endif if (!strcmp(device, "dump")) { int len = 65536; if (get_param_value(buf, sizeof(buf), "len", p) > 0) { len = strtol(buf, NULL, 0); } if (!get_param_value(buf, sizeof(buf), "file", p)) { snprintf(buf, sizeof(buf), "qemu-vlan%d.pcap", vlan_id); } ret = net_dump_init(mon, vlan, device, name, buf, len); } else { config_error(mon, "Unknown network device: %s\n", device); ret = -1; goto out; } if (ret < 0) { config_error(mon, "Could not initialize device '%s'\n", device); } out: qemu_free(name); return ret; }
1threat
Why Spring Boot Application class needs to have @Configuration annotation? : <p>I am learning about the Spring Framework but I can't understand what exactly the <code>@Configuration</code> annotation means and which classes should be annotated so. In the Spring Boot docs it is said that the Application class should be <code>@Configuration</code> class.</p> <blockquote> <p>Spring Boot favors Java-based configuration. Although it is possible to call SpringApplication.run() with an XML source, we generally recommend that your primary source is a @Configuration class.</p> </blockquote> <p>Trying to learn about <code>@Configuration</code> I find that annotating a class with the <code>@Configuration</code> indicates that the class can be used by the Spring IoC container as a source of bean definitions. </p> <p>If that is so then how is this application class a source of bean definitions?</p> <pre><code>@SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan public class App { public static void main(String[] args) throws Exception { SpringApplication.run(App.class, args); } } </code></pre> <p>I have pretty much understood most other basic concepts regarding Spring but I can't understand the purpose of <code>@Configuration</code> or which classes should be <code>@Configuration</code> classes? Can someone please help. Thanks !!</p>
0debug
uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap *bitmap) { return hbitmap_serialization_align(bitmap->bitmap); }
1threat
Identical strings not equal in PHP : <p> <pre><code>class VocabularyValidator { public function __construct() { $this-&gt;check('termIdenfifier'); } public function check ($tst) { var_dump($tst); $a = (string)'a:termIdentifier'; $b = sprintf('a:%s', (string)$tst); var_dump($a); var_dump($b); var_dump(bin2hex($a)); var_dump(bin2hex($b)); var_dump(strcmp($a, $b)); var_dump($a === $b); } public static function check2 ($tst) { var_dump($tst); $a = (string)'a:termIdentifier'; $b = sprintf('a:%s', (string)$tst); var_dump($a); var_dump($b); var_dump(bin2hex($a)); var_dump(bin2hex($b)); var_dump(strcmp($a, $b)); var_dump($a === $b); } } </code></pre> <p>I call this in a Controller like this:</p> <pre><code>VocabularyValidator::check2('termIdentifier'); new VocabularyValidator(); </code></pre> <p>The output:</p> <pre><code>string 'termIdentifier' (length=14) string 'a:termIdentifier' (length=16) string 'a:termIdentifier' (length=16) string '613a7465726d4964656e746966696572' (length=32) string '613a7465726d4964656e746966696572' (length=32) int 0 boolean true string 'termIdenfifier' (length=14) string 'a:termIdentifier' (length=16) string 'a:termIdenfifier' (length=16) string '613a7465726d4964656e746966696572' (length=32) string '613a7465726d4964656e666966696572' (length=32) int 14 boolean false </code></pre> <p>Why are identical functions giving different results?</p>
0debug
How can I manipulate Math symbols in a web page? : <p>I am building a web page dedicated to explaining Math and other topics. I'd like to animate the process of doing certain mathematical steps like adding numbers and solving an equation. I know I can create an animated .gif but this comes with the draw back of having to find some way of drawing the symbols in a picture or maybe exporting a LaTeX rendering, etc. I'm wondering if there is some more programmable, systematic solution.</p> <p>Suppose for concreteness that I want to animate the solution to 2(x-1)=10 and then several other similar equations, and the process of dividing 123 by 45.</p> <p>For some context, I have some decent but non-pro skills with HTML, CSS, JavaScript, other C-like languages, Python, and similar stuff. </p>
0debug
Active Php Code using javascript and url : Okay so I have a self destruct Php Code that would delete all files and folders in my domains directory. `<?Php $dir = 'C:\wamp64\www\FileDirectory' . DIRECTORY_SEPARATOR . 'Files'; $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS); $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); foreach($files as $file) { if ($file->isDir()){ rmdir($file->getRealPath()); } else { unlink($file->getRealPath()); } } rmdir($dir); $filename = 'C:\wamp64\www\FileDirectory\Files'; if (file_exists($filename)) { echo "The Directory has not been deleted"; } else { echo "All Files And Folders Are Deleted"; } ?>` I need a way to only activate this code when I type in extra code to the end of my URL. I thought you could do that with JavaScript but not too certain. Please let me know if I can do this. If I have to use a different code to do so not a big deal.
0debug
What does => do and what is it called in the context below? : <p>What does (a=>) do in the context below?</p> <pre><code>function findOutlier(int){ var even = int.filter(a=&gt;a%2==0); var odd = int.filter(a=&gt;a%2!==0); return even.length==1? even[0] : odd[0]; } </code></pre>
0debug
Comparing logical values to NaN in pandas/numpy : <p>I want to do an element-wise OR operation on two pandas Series of boolean values. <code>np.nan</code>s are also included.</p> <p>I have tried three approaches and realized that the expression "<code>np.nan</code> or <code>False</code>" can be evaluted to <code>True</code>, <code>False</code>, and <code>np.nan</code> depending on the approach.</p> <p>These are my example Series: </p> <pre><code>series_1 = pd.Series([True, False, np.nan]) series_2 = pd.Series([False, False, False]) </code></pre> <h3>Approach #1</h3> <p>Using the <code>|</code> operator of pandas: </p> <pre><code>In [5]: series_1 | series_2 Out[5]: 0 True 1 False 2 False dtype: bool </code></pre> <h3>Approach #2</h3> <p>Using the <code>logical_or</code> function from numpy:</p> <pre><code>In [6]: np.logical_or(series_1, series_2) Out[6]: 0 True 1 False 2 NaN dtype: object </code></pre> <h3>Approach #3</h3> <p>I define a vectorized version of <code>logical_or</code> which is supposed to be evaluated row-by-row over the arrays:</p> <pre><code>@np.vectorize def vectorized_or(a, b): return np.logical_or(a, b) </code></pre> <p>I use <code>vectorized_or</code> on the two series and convert its output (which is a numpy array) into a pandas Series:</p> <pre><code>In [8]: pd.Series(vectorized_or(series_1, series_2)) Out[8]: 0 True 1 False 2 True dtype: bool </code></pre> <h3>Question</h3> <p>I am wondering about the reasons for these results.<br> <a href="https://stackoverflow.com/a/17274707/6295616">This answer</a> explains <code>np.logical_or</code> and says <code>np.logical_or(np.nan, False)</code> is be <code>True</code> but why does this only works when vectorized and not in Approach #2? And how can the results of Approach #1 be explained? </p>
0debug
Difference output for "" and " " in javascript : <p>I have tried 2 conditions in JavaScript and output:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>if(""){console.log("Called")} //No Output if("_"){console.log("Called")} //Output: Called</code></pre> </div> </div> </p> <p>What could be the possible reason for this?</p>
0debug
Want to copy past the program in python shell but can't do : I'm new to programming currently learning with python and I have a small problem I created a small program to calculate minutes in a week it executed well as I envisioned. but now I want to make little change in a program just to change the number of days in the week from 24 to 26 so I just copy pasted the whole program in python shell itself and made a change as cited above and here the problem it shows and syntax error [screen shot ][1] added screen shot : [1]: https://i.stack.imgur.com/3dsoW.png [1]: https://i.stack.imgur.com/3dsoW.png
0debug
SwiftUI Preview canvas and Core Data : <p>Preview canvas is is crashing but in simulator everything working fine. I assuming it related to @ObservedObject and @Fetchrequest...</p> <p>tried solution for here <a href="https://stackoverflow.com/questions/57700304/previewing-contentview-with-coredata">Previewing ContentView with CoreData</a></p> <p>doesn't work</p> <pre><code> import SwiftUI import CoreData struct TemplateEditor: View { @Environment(\.managedObjectContext) var managedObjectContext @FetchRequest( entity: GlobalPlaceholders.entity(), sortDescriptors: [ NSSortDescriptor(keyPath: \GlobalPlaceholders.category, ascending: false), ] ) var placeholders: FetchedResults&lt;GlobalPlaceholders&gt; @ObservedObject var documentTemplate: Templates @State private var documentTemplateDraft = DocumentTemplateDraft() @Binding var editing: Bool var body: some View { VStack(){ HStack(){ cancelButton Spacer() saveButton }.padding() addButton ForEach(placeholders) {placeholder in Text(placeholder.name) } TextField("Title", text: $documentTemplateDraft.title) TextField("Body", text: $documentTemplateDraft.body) .padding() .frame(width: 100, height:400) Spacer() } ... } struct TemplateEditor_Previews: PreviewProvider { static var previews: some View { let managedObjectContext = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext let request = NSFetchRequest&lt;NSFetchRequestResult&gt;(entityName: "Templates") request.sortDescriptors = [NSSortDescriptor(keyPath: \Templates.created, ascending: false)] let documentTemplate = try! managedObjectContext.fetch(request).first as! Templates return TemplateEditor(documentTemplate: documentTemplate, editing: .constant(true)).environment(\.managedObjectContext, managedObjectContext).environmentObject(documentTemplate) } } </code></pre> <p>Expected to generate preview</p>
0debug
install NUnit with Visual Studio 2017 : I'm trying to create Nunit C# project. For that purpose I have installed NUnit 3 Test Adapter from Tools->Extensions And Updates. Than restart VS. But when I tried to chose new NUnit project it is still not available. Thank you in advance for your help!
0debug
static void ppc_hash64_set_isi(CPUState *cs, CPUPPCState *env, uint64_t error_code) { bool vpm; if (msr_ir) { vpm = !!(env->spr[SPR_LPCR] & LPCR_VPM1); } else { vpm = !!(env->spr[SPR_LPCR] & LPCR_VPM0); } if (vpm && !msr_hv) { cs->exception_index = POWERPC_EXCP_HISI; } else { cs->exception_index = POWERPC_EXCP_ISI; } env->error_code = error_code; }
1threat
static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile, unsigned *nb_files_alloc) { ConcatContext *cat = avf->priv_data; ConcatFile *file; char *url; size_t url_len; url_len = strlen(avf->filename) + strlen(filename) + 16; if (!(url = av_malloc(url_len))) return AVERROR(ENOMEM); ff_make_absolute_url(url, url_len, avf->filename, filename); av_free(filename); if (cat->nb_files >= *nb_files_alloc) { unsigned n = FFMAX(*nb_files_alloc * 2, 16); ConcatFile *new_files; if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) || !(new_files = av_realloc(cat->files, n * sizeof(*cat->files)))) return AVERROR(ENOMEM); cat->files = new_files; *nb_files_alloc = n; } file = &cat->files[cat->nb_files++]; memset(file, 0, sizeof(*file)); *rfile = file; file->url = url; file->start_time = AV_NOPTS_VALUE; file->duration = AV_NOPTS_VALUE; return 0; }
1threat
How do you access global variables updated in functions in JavaScipt? : I have two functions that update previously defined global variables. When I want to add the updated versions of the variables and print them to the console, JavaScript adds the original values that the variables were defined as. How do I add the updated values? I have included the code below. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var number1 = 1; var number2 = 2; function function1() { number1 = 3; } function function2() { number2 = 4; } console.log(number1 + number 2); <!-- end snippet -->
0debug
What's the error with my code here? I can't seem to get it to work. : <p>The program should sort the numbers from lowest to highest. I can't get it to work. Any help would be greatly appreciated. </p> <pre><code>n=int(input("Enter any positive integer, 0 to stop: ")) while n!=0: anyList.append(n) n=int(input("Enter any positive integer, 0 to stop: ")) L=len(anyList) for j in range(L): c=999999999 for i in range(L): if anyList[i]&lt;check: c=anyList[i] p=i anyList[p]=999999999 newList.append(c) print (newList) </code></pre>
0debug
How to create an auto-generate class in .NET from an XML file? : Originally I wanted to create an auto-generated .NET class from an XML. This class could be written in VB, C#, JS, VJS, and C++.
0debug
How to transform given dataset in python? : <pre><code> 1 0.0 6.400000000 2 6.400000000 27.0 2 27.0 27.100000000 2 27.100000000 27.400000000 2 27.400000000 27.700000000 2 27.700000000 30.600000000 1 30.600000000 31.0 1 31.0 36.600000000 1 36.600000000 36.900000000 1 36.900000000 37.100000000 1 37.100000000 37.100000000 1 37.100000000 37.300000000 1 37.300000000 37.800000000 1 37.800000000 38.900000000 1 38.900000000 39.200000000 1 39.200000000 39.300000000 1 39.300000000 39.500000000 1 39.500000000 39.700000000 2 39.700000000 42.600000000 2 42.600000000 42.600000000 2 42.600000000 42.800000000 1 42.800000000 44.900000000 1 44.900000000 45.600000000 2 45.600000000 51.0 1 51.0 51.800000000 </code></pre> <pre><code> 1 0.0 6.400000000 2 6.400000000 30.600000000 1 30.600000000 39.500000000 ... so on </code></pre> <p>I want to transform my data in the above format. I tried this with groupBy min and max for column but it seems like it doesn't give me the desirable results. </p>
0debug
int net_init_dump(const NetClientOptions *opts, const char *name, NetClientState *peer, Error **errp) { int len; const char *file; char def_file[128]; const NetdevDumpOptions *dump; assert(opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP); dump = opts->dump; assert(peer); if (dump->has_file) { file = dump->file; } else { int id; int ret; ret = net_hub_id_for_client(peer, &id); assert(ret == 0); snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", id); file = def_file; } if (dump->has_len) { if (dump->len > INT_MAX) { error_report("invalid length: %"PRIu64, dump->len); return -1; } len = dump->len; } else { len = 65536; } return net_dump_init(peer, "dump", name, file, len); }
1threat
static int eval_refl(int *refl, const int16_t *coefs, RA144Context *ractx) { int b, i, j; int buffer1[10]; int buffer2[10]; int *bp1 = buffer1; int *bp2 = buffer2; for (i=0; i < 10; i++) buffer2[i] = coefs[i]; refl[9] = bp2[9]; if ((unsigned) bp2[9] + 0x1000 > 0x1fff) { av_log(ractx, AV_LOG_ERROR, "Overflow. Broken sample?\n"); return 1; } for (i=8; i >= 0; i--) { b = 0x1000-((bp2[i+1] * bp2[i+1]) >> 12); if (!b) b = -2; for (j=0; j <= i; j++) bp1[j] = ((bp2[j] - ((refl[i+1] * bp2[i-j]) >> 12)) * (0x1000000 / b)) >> 12; refl[i] = bp1[i]; if ((unsigned) bp1[i] + 0x1000 > 0x1fff) return 1; FFSWAP(int *, bp1, bp2); } return 0; }
1threat
static void *qemu_tcg_rr_cpu_thread_fn(void *arg) { CPUState *cpu = arg; rcu_register_thread(); qemu_thread_get_self(cpu->thread); CPU_FOREACH(cpu) { cpu->thread_id = qemu_get_thread_id(); cpu->created = true; cpu->can_do_io = 1; } qemu_cond_signal(&qemu_cpu_cond); while (first_cpu->stopped) { qemu_cond_wait(first_cpu->halt_cond, &qemu_global_mutex); CPU_FOREACH(cpu) { current_cpu = cpu; qemu_wait_io_event_common(cpu); } } start_tcg_kick_timer(); cpu = first_cpu; cpu->exit_request = 1; while (1) { qemu_account_warp_timer(); if (!cpu) { cpu = first_cpu; } while (cpu && !cpu->queued_work_first && !cpu->exit_request) { atomic_mb_set(&tcg_current_rr_cpu, cpu); current_cpu = cpu; qemu_clock_enable(QEMU_CLOCK_VIRTUAL, (cpu->singlestep_enabled & SSTEP_NOTIMER) == 0); if (cpu_can_run(cpu)) { int r; r = tcg_cpu_exec(cpu); if (r == EXCP_DEBUG) { cpu_handle_guest_debug(cpu); } } else if (cpu->stop) { if (cpu->unplug) { cpu = CPU_NEXT(cpu); } } cpu = CPU_NEXT(cpu); } atomic_set(&tcg_current_rr_cpu, NULL); if (cpu && cpu->exit_request) { atomic_mb_set(&cpu->exit_request, 0); } handle_icount_deadline(); qemu_tcg_wait_io_event(cpu ? cpu : QTAILQ_FIRST(&cpus)); deal_with_unplugged_cpus(); } return NULL; }
1threat
What is the difference between OnChanges and DoCheck in Angular 2? : <p>Difference between them seems to be very confusing to me. What is difference between them and exactly when they are called</p>
0debug
Date return in string order : <p>my 4th assignment</p> <p>Write a javascript function that returns the date. The date should be returned as a string in the order (DD-MM-YYYY) and in the following formats: 01-12-2016 01/12/2017 Tip: Make over an input argument that is chosen for the dash (-) or slash (/) as a separator stabbing.</p> <p>I got this</p> <pre><code>&lt;script&gt; function formattedDate(date) { var vandaag = new Date(date || Date.now()), month = '' + (vandaag.getMonth() + 1), day = '' + vandaag.getDate(), year = vandaag.getFullYear(); if (month.length &lt; 2) month = '0' + month; if (day.length &lt; 2) day = '0' + day; return [day, month, year].join('-');} document.write('&lt;br&gt; Vandaag met (-) : ' + formattedDate()); function formattedDat(date) { var vandaa = new Date(date || Date.now()), mont = '' + (vandaa.getMonth() + 1), da = '' + vandaa.getDate(), yea = vandaa.getFullYear(); if (mont.length &lt; 2) mont = '0' + mont; if (da.length &lt; 2) da = '0' + da; return [da, mont, yea].join('/');} document.write('&lt;br&gt; Vandaag met (/): ' + formattedDat()); &lt;/script </code></pre> <p>but i dont want it to write two times, and i need buttons for each order (-) and (/)</p>
0debug
static void alloc_picture(void *opaque) { VideoState *is = opaque; VideoPicture *vp; vp = &is->pictq[is->pictq_windex]; if (vp->bmp) SDL_FreeYUVOverlay(vp->bmp); #if CONFIG_AVFILTER if (vp->picref) avfilter_unref_buffer(vp->picref); vp->picref = NULL; vp->width = is->out_video_filter->inputs[0]->w; vp->height = is->out_video_filter->inputs[0]->h; vp->pix_fmt = is->out_video_filter->inputs[0]->format; #else vp->width = is->video_st->codec->width; vp->height = is->video_st->codec->height; vp->pix_fmt = is->video_st->codec->pix_fmt; #endif vp->bmp = SDL_CreateYUVOverlay(vp->width, vp->height, SDL_YV12_OVERLAY, screen); if (!vp->bmp || vp->bmp->pitches[0] < vp->width) { fprintf(stderr, "Error: the video system does not support an image\n" "size of %dx%d pixels. Try using -vf \"scale=w:h\"\n" "to reduce the image size.\n", vp->width, vp->height ); do_exit(is); } SDL_LockMutex(is->pictq_mutex); vp->allocated = 1; SDL_CondSignal(is->pictq_cond); SDL_UnlockMutex(is->pictq_mutex); }
1threat
static inline int cris_bound_w(int v, int b) { int r = v; asm ("bound.w\t%1, %0\n" : "+r" (r) : "ri" (b)); return r; }
1threat
PHP project: Telnet connction to Nokia Equipements(MSS) with PHP and data interaction with database throught telnet : As part of my graduation project, I have to make a web application that connects to a Nokia proprietary equipment. This is the architecture of my project. 1-Is it possible to do this project with to language PHP: Can I connect to the equipment with php throught telnet 2-and for the hand "1" Can the database through php interacat with the equipment with telnet Just to know I had never developed any thing in php ,even with devolopping web applications [enter image description here][1] Thank you in advance [1]: http://i.stack.imgur.com/hKmy1.png
0debug
Date and Json in type definition for graphql : <p>Is it possible to have a define a field as Date or JSON in my graphql schema ?</p> <pre><code>type Individual { id: Int name: String birthDate: Date token: JSON } </code></pre> <p>actually the server is returning me an error saying : </p> <pre><code>Type "Date" not found in document. at ASTDefinitionBuilder._resolveType (****node_modules\graphql\utilities\buildASTSchema.js:134:11) </code></pre> <p>And same error for JSON...</p> <p>Any idea ?</p>
0debug
START_TEST(simple_whitespace) { int i; struct { const char *encoded; LiteralQObject decoded; } test_cases[] = { { .encoded = " [ 43 , 42 ]", .decoded = QLIT_QLIST(((LiteralQObject[]){ QLIT_QINT(43), QLIT_QINT(42), { } })), }, { .encoded = " [ 43 , { 'h' : 'b' }, [ ], 42 ]", .decoded = QLIT_QLIST(((LiteralQObject[]){ QLIT_QINT(43), QLIT_QDICT(((LiteralQDictEntry[]){ { "h", QLIT_QSTR("b") }, { }})), QLIT_QLIST(((LiteralQObject[]){ { }})), QLIT_QINT(42), { } })), }, { .encoded = " [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]", .decoded = QLIT_QLIST(((LiteralQObject[]){ QLIT_QINT(43), QLIT_QDICT(((LiteralQDictEntry[]){ { "h", QLIT_QSTR("b") }, { "a", QLIT_QINT(32) }, { }})), QLIT_QLIST(((LiteralQObject[]){ { }})), QLIT_QINT(42), { } })), }, { } }; for (i = 0; test_cases[i].encoded; i++) { QObject *obj; QString *str; obj = qobject_from_json(test_cases[i].encoded); fail_unless(obj != NULL); fail_unless(qobject_type(obj) == QTYPE_QLIST); fail_unless(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1); str = qobject_to_json(obj); qobject_decref(obj); obj = qobject_from_json(qstring_get_str(str)); fail_unless(obj != NULL); fail_unless(qobject_type(obj) == QTYPE_QLIST); fail_unless(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1); qobject_decref(obj); QDECREF(str); } }
1threat
def max_len_sub( arr, n): mls=[] max = 0 for i in range(n): mls.append(1) for i in range(n): for j in range(i): if (abs(arr[i] - arr[j]) <= 1 and mls[i] < mls[j] + 1): mls[i] = mls[j] + 1 for i in range(n): if (max < mls[i]): max = mls[i] return max
0debug
why do we have to use @Modifying annotation for queries in Data Jpa : <p>for example I have a method in my CRUD interface which deletes a user from the database:</p> <pre><code>public interface CrudUserRepository extends JpaRepository&lt;User, Integer&gt; { @Transactional @Modifying @Query("DELETE FROM User u WHERE u.id=:id") int delete(@Param("id") int id, @Param("userId") int userId); } </code></pre> <p>This method will work only with the annotation @Modifying. But what is the need for the annotation here? Why cant spring analyze the query and understand that it is a modifying query?</p>
0debug
static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { *pnum = nb_sectors; return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID | BDRV_BLOCK_DATA | (sector_num << BDRV_SECTOR_BITS); }
1threat
static void *iommu_init(target_phys_addr_t addr, uint32_t version, qemu_irq irq) { DeviceState *dev; SysBusDevice *s; dev = qdev_create(NULL, "iommu"); qdev_prop_set_uint32(dev, "version", version); qdev_init(dev); s = sysbus_from_qdev(dev); sysbus_connect_irq(s, 0, irq); sysbus_mmio_map(s, 0, addr); return s; }
1threat
CPUArchState *cpu_copy(CPUArchState *env) { CPUState *cpu = ENV_GET_CPU(env); CPUArchState *new_env = cpu_init(cpu_model); CPUState *new_cpu = ENV_GET_CPU(new_env); #if defined(TARGET_HAS_ICE) CPUBreakpoint *bp; CPUWatchpoint *wp; #endif cpu_reset(new_cpu); memcpy(new_env, env, sizeof(CPUArchState)); QTAILQ_INIT(&cpu->breakpoints); QTAILQ_INIT(&cpu->watchpoints); #if defined(TARGET_HAS_ICE) QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) { cpu_breakpoint_insert(new_cpu, bp->pc, bp->flags, NULL); } QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { cpu_watchpoint_insert(new_cpu, wp->vaddr, wp->len, wp->flags, NULL); } #endif return new_env; }
1threat
e1000_cleanup(NetClientState *nc) { E1000State *s = qemu_get_nic_opaque(nc); s->nic = NULL; }
1threat
static void win32_rearm_timer(struct qemu_alarm_timer *t, int64_t nearest_delta_ns) { HANDLE hTimer = t->timer; int nearest_delta_ms; BOOLEAN success; nearest_delta_ms = (nearest_delta_ns + 999999) / 1000000; if (nearest_delta_ms < 1) { nearest_delta_ms = 1; } success = ChangeTimerQueueTimer(NULL, hTimer, nearest_delta_ms, 3600000); if (!success) { fprintf(stderr, "Failed to rearm win32 alarm timer: %ld\n", GetLastError()); exit(-1); } }
1threat
static void pred8x8_left_dc_rv40_c(uint8_t *src, int stride){ int i; int dc0; dc0=0; for(i=0;i<8; i++) dc0+= src[-1+i*stride]; dc0= 0x01010101*((dc0 + 4)>>3); for(i=0; i<8; i++){ ((uint32_t*)(src+i*stride))[0]= ((uint32_t*)(src+i*stride))[1]= dc0; } }
1threat
Evaluate Irrational with Julia : <p>Julia has the built-in constant <code>pi</code>, with type <code>Irrational</code>.</p> <pre><code>julia&gt; pi π = 3.1415926535897... julia&gt; π π = 3.1415926535897... julia&gt; typeof(pi) Irrational{:π} </code></pre> <p>Coming from SymPy, which has the <code>N()</code> function, I would like to evaluate <code>pi</code> (or other <code>Irrational</code>s, such as <code>e</code>, <code>golden</code>, etc.) to n digits.</p> <pre><code>In [5]: N(pi, n=50) Out[5]: 3.1415926535897932384626433832795028841971693993751 </code></pre> <p>Is this possible? I am assuming that <code>pi</code> is based on its mathematical definition, rather than just to thirteen decimal places.</p>
0debug
static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt) { MpegDemuxContext *vobsub = s->priv_data; FFDemuxSubtitlesQueue *q; AVIOContext *pb = vobsub->sub_ctx->pb; int ret, psize, total_read = 0, i; AVPacket idx_pkt; int64_t min_ts = INT64_MAX; int sid = 0; for (i = 0; i < s->nb_streams; i++) { FFDemuxSubtitlesQueue *tmpq = &vobsub->q[i]; int64_t ts = tmpq->subs[tmpq->current_sub_idx].pts; if (ts < min_ts) { min_ts = ts; sid = i; } } q = &vobsub->q[sid]; ret = ff_subtitles_queue_read_packet(q, &idx_pkt); if (ret < 0) return ret; if (q->current_sub_idx < q->nb_subs) { psize = q->subs[q->current_sub_idx].pos - idx_pkt.pos; } else { int64_t fsize = avio_size(pb); psize = fsize < 0 ? 0xffff : fsize - idx_pkt.pos; } avio_seek(pb, idx_pkt.pos, SEEK_SET); av_init_packet(pkt); pkt->size = 0; pkt->data = NULL; do { int n, to_read, startcode; int64_t pts, dts; int64_t old_pos = avio_tell(pb), new_pos; int pkt_size; ret = mpegps_read_pes_header(vobsub->sub_ctx, NULL, &startcode, &pts, &dts); if (ret < 0) { if (pkt->size) break; goto fail; } to_read = ret & 0xffff; new_pos = avio_tell(pb); pkt_size = ret + (new_pos - old_pos); if (total_read + pkt_size > psize) break; total_read += pkt_size; if ((startcode & 0x1f) != idx_pkt.stream_index) break; ret = av_grow_packet(pkt, to_read); if (ret < 0) goto fail; n = avio_read(pb, pkt->data + (pkt->size - to_read), to_read); if (n < to_read) pkt->size -= to_read - n; } while (total_read < psize); pkt->pts = pkt->dts = idx_pkt.pts; pkt->pos = idx_pkt.pos; pkt->stream_index = idx_pkt.stream_index; av_free_packet(&idx_pkt); return 0; fail: av_free_packet(pkt); av_free_packet(&idx_pkt); return ret; }
1threat
int qemu_pipe(int pipefd[2]) { int ret; #ifdef CONFIG_PIPE2 ret = pipe2(pipefd, O_CLOEXEC); #else ret = pipe(pipefd); if (ret == 0) { qemu_set_cloexec(pipefd[0]); qemu_set_cloexec(pipefd[1]); } #endif return ret; }
1threat
void helper_movl_sreg_reg (uint32_t sreg, uint32_t reg) { uint32_t srs; srs = env->pregs[PR_SRS]; srs &= 3; env->sregs[srs][sreg] = env->regs[reg]; #if !defined(CONFIG_USER_ONLY) if (srs == 1 || srs == 2) { if (sreg == 6) { env->sregs[SFR_RW_MM_TLB_HI] = env->regs[reg]; env->sregs[SFR_R_MM_CAUSE] = env->regs[reg]; } else if (sreg == 5) { uint32_t set; uint32_t idx; uint32_t lo, hi; uint32_t vaddr; int tlb_v; idx = set = env->sregs[SFR_RW_MM_TLB_SEL]; set >>= 4; set &= 3; idx &= 15; lo = env->sregs[SFR_RW_MM_TLB_LO]; hi = env->sregs[SFR_R_MM_CAUSE]; vaddr = EXTRACT_FIELD(env->tlbsets[srs-1][set][idx].hi, 13, 31); vaddr <<= TARGET_PAGE_BITS; tlb_v = EXTRACT_FIELD(env->tlbsets[srs-1][set][idx].lo, 3, 3); env->tlbsets[srs - 1][set][idx].lo = lo; env->tlbsets[srs - 1][set][idx].hi = hi; D_LOG("tlb flush vaddr=%x v=%d pc=%x\n", vaddr, tlb_v, env->pc); tlb_flush_page(env, vaddr); } } #endif }
1threat
Fargate vs Lambda, when to use which? : <p>I'm pretty new to the whole Serverless landscape, and am trying to wrap my head around when to use Fargate vs Lambda. </p> <p>I am aware that Fargate is a serverless subset of ECS, and Lambda is serverless as well but driven by events. But I'd like to be able to explain the two paradigms in simple terms to other folks that are familiar with containers but not that much with AWS and serverless. </p> <p>Currently we have a couple of physical servers in charge of receiving text files, parsing them out, and populating several db tables with the results. Based on my understanding, I think this would be a use case better suited for Lambda because the process that parses out the text files is triggered by a schedule, is not long running, and ramps down when not in use. </p> <p>However, if we were to port over one of our servers that receive API calls, we would probably want to use Fargate because we would always need at least one instance of the image up and running. </p> <p>In terms of containers, and in very general terms would it be safe to say that if the container is designed to do: </p> <pre><code>docker run &lt;some_input&gt; </code></pre> <p>Then it is a job for Lambda. </p> <p>But if the container is designed to do something like:</p> <pre><code>docker run --expose 80 </code></pre> <p>Then it is a job for Fargate. </p> <p>Is this a good analogy? </p>
0debug
static void destroy_page_desc(uint16_t section_index) { MemoryRegionSection *section = &phys_sections[section_index]; MemoryRegion *mr = section->mr; if (mr->subpage) { subpage_t *subpage = container_of(mr, subpage_t, iomem); memory_region_destroy(&subpage->iomem); g_free(subpage); } }
1threat
Asp Mvc Add to int filed each time an action called? : I want to increase 1 unit of my int field named `BookViews` by per action run. **My Action :** [HttpGet] public IActionResult BookDetails(int id) { MultiModels model = new MultiModels(); model.UserListed = (from u in _userManager.Users orderby u.Id descending select u).Take(10).ToList(); using (var db = _iServiceProvider.GetRequiredService<ApplicationDbContext>()) { var result = from b in db.books where (b.BookId == id) select b; if (result.Count() != 0) { ///error occure here db.books.Update((from b in db.books where b.BookId == id select b.BookViews) + 1)); db.SaveChanges(); } } return View(model); } But my code get error. How can i increase `BookViews` field 1 unit per run and update it in database?
0debug
MAMP Pro 4 and Sophos Warning about Adminer Database Manager : <p>I have been using Sophos Anti-Virus on the Mac for several years now with good results. Recently when attempting to download the new MAMP Pro 4.x, I received a Sophos alert that the MAMP installer contains the Adminer Database Manager, which it identifies as known Adware and PUA.</p> <p>Has anyone experienced a similar warning, and is there any reason for concern about this warning?</p> <p>The only real information I can find about Adminer is this:</p> <p><a href="http://philipdowner.com/2012/01/using-adminer-with-mamp-on-mac-os-x/" rel="noreferrer">http://philipdowner.com/2012/01/using-adminer-with-mamp-on-mac-os-x/</a></p> <p>This post indicates that Adminer is some type of script designed to be an alternative to PHPMyAdmin.</p> <p>Can I just remove Adminer after installing?</p> <p>-- Lee</p>
0debug
How i free/deallocate the memory for a std::map properly : I need to free (to avoid memory leaks) the all allocated memory for following C code(std::map , both key & value created by using 'new'). int main() { std::map<char*, char*> *mp = new std::map<char*, char*>; char *a = new char; a = (char*)"abc"; char *b = new char; b = (char*)"pqr"; mp->insert(std::pair<char*, char*>(a, b)); a = NULL , b = NULL; // no extra pointers to keys now // printf("element : %s", (*mp)["abc"]); // working /* need to free the allocated memory by the map in here properly, clear() & erase() are ok ? , bcoz i think, need some 'delete's */ }
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
Can python3.6 install crypto on windows : <p>My python version is python3.6.5. I want to install pycrypto,but there is some errors to install it.So did anyone know how to solve the problen. Thank you very much.</p>
0debug
Is it possible to make this json object? How can I? : ``` "data" : [ "1000": "1000", "1200": "1200", "1400": "1400", "1600": "1600", "1800": "1800", ] ``` or ``` "data" : [ 1000: 1000, 1200: 1200, 1400: 1400, 1600: 1600, 1800: 1800, ] ``` Not like this ``` "data" : [ "1000", "1200", "1400", "1600", "1800", ] ``` or ``` "data" : [ 0: "1000", 1: "1200", 2: "1400", 3: "1600", 4: "1800", ] ``` Note: String or integer, that's not a matter. I'm beginner. Thanks in advanced. I only want to use integer. Not any letters or words. I'am outputting this using laravel resources.
0debug
If this contains that change CSS of another element : I have a percent bar that need to change your width when a element appears. I tried use .has but :contains is more correct I think. But does't work. Some idea how to do this work? var animals = [ 'Lion', 'Cat', 'Tiger', 'Dog' ] var box_animals = animals.valueOf; if ("box_animals:contains(Cat)"){ $("#ruler_bar").css("width", 2% ); } if ("box_animals:contains(Lion)"){ $("#ruler_bar").css("width", 50% ); }
0debug
Why does Electron need to be saved as a developer dependency? : <p>As per the official website, the correct way to save electron files is:</p> <pre><code>npm install electron --save-dev </code></pre> <p>Electron is actually required for running the app (quite literally: <code>require()</code>) and this goes against the <a href="https://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencies">top voted answer here</a>. So why do we make this exception, if this is even one?</p>
0debug
CONVERT DATE TYPE TO VACHAR IN SQL SERVER : HOW DO I CONVERT A ENDDATE COLOUMN WHICH IS DATE TYPE TO VARCHAR IN SQL SERVER ? E.G ENDDATE(DATE TYPE) '1947-12-01 00-00-00' TO ENDDATE(VARCHAR) 121947
0debug
Generating an array based on min and max number in angular 4 : I need to generate an array of numbers that has difference of 5000 between them in Typescript angular 4. So for e.g the function should be able to take min and max and based on that it should generate the numbers. So consider the min is 0 and max is 20000, the array generated should be 0,5000,10000,15000,20000
0debug
static void v9fs_wstat_post_utime(V9fsState *s, V9fsWstatState *vs, int err) { if (err < 0) { goto out; } if (vs->v9stat.n_gid != -1) { if (v9fs_do_chown(s, &vs->fidp->path, vs->v9stat.n_uid, vs->v9stat.n_gid)) { err = -errno; } } v9fs_wstat_post_chown(s, vs, err); return; out: v9fs_stat_free(&vs->v9stat); complete_pdu(s, vs->pdu, err); qemu_free(vs); }
1threat
check a specific character in textbox visual basic? : <p>Lets say i have a textbox containing the string "hello".</p> <p>Is there a way in which can i check that the 3rd character of textbox.text = "l"?</p> <p>We are talking about visual basic, of course.</p> <p>Thanks!</p>
0debug
Selenium (Python) - waiting for a download process to complete using Chrome web driver : <p>I'm using selenium and python via chromewebdriver (windows) in order to automate a task of downloading large amount of files from different pages. My code works, but the solution is far from ideal: the function below clicks on the website button that initiating a java script function that generating a PDF file and then downloading it.</p> <p>I had to use a static wait in order to wait for the download to be completed (ugly) I cannot check the file system in order to verify when the download is completed since i'm using multi threading (downloading lot's of files from different pages at once) and also the the name of the files is generated dynamically in the website itself.</p> <p>My code:</p> <pre><code>def file_download(num, drivervar): Counter += 1 try: drivervar.get(url[num]) download_button = WebDriverWait(drivervar, 20).until(EC.element_to_be_clickable((By.ID, 'download button ID'))) download_button.click() time.sleep(10) except TimeoutException: # Retry once print('Timeout in thread number: ' + str(num) + ', retrying...') ..... </code></pre> <p>Is it possible to determine download completion in webdriver? I want to avoid using time.sleep(x).</p> <p>Thanks a lot.</p>
0debug