problem
stringlengths
26
131k
labels
class label
2 classes
I need to update a variable in an __init__ each time i run it, how do i do this? Python : I have this class in Python. (Removed the unecessary parts) class Spillebrett: def __init__(self, rader, kolonner): self._rader = rader self._kolonner = kolonner self._generasjonsnummer = 0 I need to add 1 to _generasjonsnummer everytime i run the class. If i try _generasjonsnummer += 1 i get an error. I tried to make a def addGenerasjonsnummer() and call it in the __init__ like so: class Spillebrett: def __init__(self, rader, kolonner): self._rader = rader self._kolonner = kolonner self._generasjonsnummer = 0 addGenerasjonsnummer() def addGenerasjonsnummer(): self._generasjonsnummer += 1 But i cant call on functions in the __init__. What i need is for this number to update to +=1 each time i start the init, how do i do this?
0debug
void load_kernel (CPUState *env, int ram_size, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename) { int64_t entry = 0; long kernel_size, initrd_size; kernel_size = load_elf(kernel_filename, VIRT_TO_PHYS_ADDEND, &entry); if (kernel_size >= 0) { if ((entry & ~0x7fffffffULL) == 0x80000000) entry = (int32_t)entry; env->PC = entry; } else { kernel_size = load_image(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR + VIRT_TO_PHYS_ADDEND); if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } env->PC = KERNEL_LOAD_ADDR; } initrd_size = 0; if (initrd_filename) { initrd_size = load_image(initrd_filename, phys_ram_base + INITRD_LOAD_ADDR + VIRT_TO_PHYS_ADDEND); if (initrd_size == (target_ulong) -1) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", initrd_filename); exit(1); } } if (initrd_size > 0) { int ret; ret = sprintf(phys_ram_base + (16 << 20) - 256, "rd_start=0x" TLSZ " rd_size=%li ", INITRD_LOAD_ADDR, initrd_size); strcpy (phys_ram_base + (16 << 20) - 256 + ret, kernel_cmdline); } else { strcpy (phys_ram_base + (16 << 20) - 256, kernel_cmdline); } *(int *)(phys_ram_base + (16 << 20) - 260) = tswap32 (0x12345678); *(int *)(phys_ram_base + (16 << 20) - 264) = tswap32 (ram_size); }
1threat
How to get the location when GPS/LOCATION is turned off? : <p>I want to get the Lat/Long of a device when its GPS is turned off. I tried few tutorials but am not able to get the Location when GPS is off. Is there any way to do it?? or GPS is compulsory? Looking for help. Thanks in advance.</p>
0debug
static void socket_start_incoming_migration(SocketAddress *saddr, Error **errp) { QIOChannelSocket *listen_ioc = qio_channel_socket_new(); qio_channel_set_name(QIO_CHANNEL(listen_ioc), "migration-socket-listener"); if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) { object_unref(OBJECT(listen_ioc)); qapi_free_SocketAddress(saddr); return; } qio_channel_add_watch(QIO_CHANNEL(listen_ioc), G_IO_IN, socket_accept_incoming_migration, listen_ioc, (GDestroyNotify)object_unref); qapi_free_SocketAddress(saddr); }
1threat
How can I make a page private with code login on php? : <p>I'm working on a new website for a business I'd like to start and I got stuck in one of its pages. I actually want one page to be private unless you log in with a code, and I don't know how to deal with it. </p> <p>I've thought of using PHP for comparing both login form pass and a MySQL pass uploaded by me before but I'm not really used to work with PHP so I get stuck on it every time I try it. Could anyone, please, suggest me a piece of code for making it private? </p> <p>Thank you.</p>
0debug
static av_cold int amr_wb_encode_init(AVCodecContext *avctx) { AMRWBContext *s = avctx->priv_data; if (avctx->sample_rate != 16000) { av_log(avctx, AV_LOG_ERROR, "Only 16000Hz sample rate supported\n"); return AVERROR(ENOSYS); } if (avctx->channels != 1) { av_log(avctx, AV_LOG_ERROR, "Only mono supported\n"); return AVERROR(ENOSYS); } s->mode = get_wb_bitrate_mode(avctx->bit_rate, avctx); s->last_bitrate = avctx->bit_rate; avctx->frame_size = 320; avctx->delay = 80; s->state = E_IF_init(); return 0; }
1threat
int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, void *opaque, int alias_id, int required_for_version, Error **errp) { SaveStateEntry *se; assert(alias_id == -1 || required_for_version >= vmsd->minimum_version_id); se = g_new0(SaveStateEntry, 1); se->version_id = vmsd->version_id; se->section_id = savevm_state.global_section_id++; se->opaque = opaque; se->vmsd = vmsd; se->alias_id = alias_id; if (dev) { char *id = qdev_get_dev_path(dev); if (id) { if (snprintf(se->idstr, sizeof(se->idstr), "%s/", id) >= sizeof(se->idstr)) { error_setg(errp, "Path too long for VMState (%s)", id); g_free(se); return -1; } se->compat = g_new0(CompatEntry, 1); pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->name); se->compat->instance_id = instance_id == -1 ? calculate_compat_instance_id(vmsd->name) : instance_id; instance_id = -1; } } pstrcat(se->idstr, sizeof(se->idstr), vmsd->name); if (instance_id == -1) { se->instance_id = calculate_new_instance_id(se->idstr); } else { se->instance_id = instance_id; } assert(!se->compat || se->instance_id == 0); savevm_state_handler_insert(se); return 0; }
1threat
Securely pass a Javascript variable to PHP : <p>I have implemented this XMR Mining script on my page:</p> <p>HTML:</p> <pre><code>&lt;div class="content"&gt; &lt;img src="https://pexlab.net/assets/coin.png" width="100px" /&gt;&lt;br&gt;&lt;br&gt; &lt;button id="button" onclick="toggleEarning()"&gt;Start earning&lt;/button&gt;&lt;br&gt; &lt;br&gt; &lt;div id=earnings&gt;PLC earned: 0&lt;/div&gt; &lt;div id=current&gt;Current PLC/s rate: 0&lt;/div&gt;&lt;br&gt; &lt;/div&gt; </code></pre> <p>Script:</p> <pre><code>&lt;script src="https://www.freecontent.date./7pZJ.js"&gt;&lt;/script&gt; &lt;script&gt; var miner = new Client.Anonymous('0589835a36af7e7e38ad13068b19801902b078e2c88b6a21b41419b16baa54ba', {throttle: 2}); function toggleEarning(){ var button = document.getElementById("button"); var earnings = document.getElementById("earnings"); var current = document.getElementById("current"); if(miner.isRunning()){ button.innerHTML = "Stopping..."; button.disabled = true; miner.stop(); }else{ button.innerHTML = "Initializing..."; button.disabled = true; miner.start(); updateValues(); } } function updateValues(){ var earned = Math.round(miner.getTotalHashes(true) / 8); var rate = Math.floor((miner.getHashesPerSecond() / 8) * 100) / 100; if(earned &gt; 0.1){ button.innerHTML = "Stop earning"; button.disabled = false; earnings.innerHTML = "PLC Earned: " + earned; current.innerHTML = "Current PLC/s rate: " + rate; } if(miner.isRunning()){ setTimeout(updateValues, 3000); }else{ button.innerHTML = "Start earning"; button.disabled = false; } } &lt;/script&gt; </code></pre> <p>Everytime I refresh the page the earnings resets to 0. I want to save the PLC earned in a MySQL Database using PHP. But I think passing the variable using POST is unsafe and could be manipulated.</p>
0debug
Javascript - Show alert when specific radio button is checked on ID : <p>I need to show a alert when someone clicks on a radio button with a specific ID.</p> <p>This is the radio button:</p> <pre><code>&lt;input name="shipping_method" type="radio" class="validate-one-required-by-name" value="kerst_shipping_standard" id="s_method_kerst_shipping_standard"&gt; </code></pre> <p>And when someone clicks that radio button it needs to show a alert.</p>
0debug
Does java support multiple inheritance? : <p>Does java support multiple inheritance? (<a href="https://i.stack.imgur.com/PkhMD.png" rel="nofollow noreferrer">https://i.stack.imgur.com/PkhMD.png</a>)</p>
0debug
static void unpack_alpha(GetBitContext *gb, uint16_t *dst, int num_coeffs, const int num_bits) { const int mask = (1 << num_bits) - 1; int i, idx, val, alpha_val; idx = 0; alpha_val = mask; do { do { if (get_bits1(gb)) val = get_bits(gb, num_bits); else { int sign; val = get_bits(gb, num_bits == 16 ? 7 : 4); sign = val & 1; val = (val + 2) >> 1; if (sign) val = -val; } alpha_val = (alpha_val + val) & mask; if (num_bits == 16) dst[idx++] = alpha_val >> 6; else dst[idx++] = (alpha_val << 2) | (alpha_val >> 6); if (idx == num_coeffs - 1) break; } while (get_bits1(gb)); val = get_bits(gb, 4); if (!val) val = get_bits(gb, 11); if (idx + val > num_coeffs) val = num_coeffs - idx; if (num_bits == 16) for (i = 0; i < val; i++) dst[idx++] = alpha_val >> 6; else for (i = 0; i < val; i++) dst[idx++] = (alpha_val << 2) | (alpha_val >> 6); } while (idx < num_coeffs); }
1threat
static void musicpal_init(MachineState *machine) { const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; ARMCPU *cpu; qemu_irq pic[32]; DeviceState *dev; DeviceState *i2c_dev; DeviceState *lcd_dev; DeviceState *key_dev; DeviceState *wm8750_dev; SysBusDevice *s; I2CBus *i2c; int i; unsigned long flash_size; DriveInfo *dinfo; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *sram = g_new(MemoryRegion, 1); if (!cpu_model) { cpu_model = "arm926"; } cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, cpu_model)); if (!cpu) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } memory_region_allocate_system_memory(ram, NULL, "musicpal.ram", MP_RAM_DEFAULT_SIZE); memory_region_add_subregion(address_space_mem, 0, ram); memory_region_init_ram(sram, NULL, "musicpal.sram", MP_SRAM_SIZE, &error_fatal); memory_region_add_subregion(address_space_mem, MP_SRAM_BASE, sram); dev = sysbus_create_simple(TYPE_MV88W8618_PIC, MP_PIC_BASE, qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ)); for (i = 0; i < 32; i++) { pic[i] = qdev_get_gpio_in(dev, i); } sysbus_create_varargs(TYPE_MV88W8618_PIT, MP_PIT_BASE, pic[MP_TIMER1_IRQ], pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ], pic[MP_TIMER4_IRQ], NULL); if (serial_hds[0]) { serial_mm_init(address_space_mem, MP_UART1_BASE, 2, pic[MP_UART1_IRQ], 1825000, serial_hds[0], DEVICE_NATIVE_ENDIAN); } if (serial_hds[1]) { serial_mm_init(address_space_mem, MP_UART2_BASE, 2, pic[MP_UART2_IRQ], 1825000, serial_hds[1], DEVICE_NATIVE_ENDIAN); } dinfo = drive_get(IF_PFLASH, 0, 0); if (dinfo) { BlockBackend *blk = blk_by_legacy_dinfo(dinfo); flash_size = blk_getlength(blk); if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 && flash_size != 32*1024*1024) { fprintf(stderr, "Invalid flash image size\n"); exit(1); } #ifdef TARGET_WORDS_BIGENDIAN pflash_cfi02_register(0x100000000ULL-MP_FLASH_SIZE_MAX, NULL, "musicpal.flash", flash_size, blk, 0x10000, (flash_size + 0xffff) >> 16, MP_FLASH_SIZE_MAX / flash_size, 2, 0x00BF, 0x236D, 0x0000, 0x0000, 0x5555, 0x2AAA, 1); #else pflash_cfi02_register(0x100000000ULL-MP_FLASH_SIZE_MAX, NULL, "musicpal.flash", flash_size, blk, 0x10000, (flash_size + 0xffff) >> 16, MP_FLASH_SIZE_MAX / flash_size, 2, 0x00BF, 0x236D, 0x0000, 0x0000, 0x5555, 0x2AAA, 0); #endif } sysbus_create_simple(TYPE_MV88W8618_FLASHCFG, MP_FLASHCFG_BASE, NULL); qemu_check_nic_model(&nd_table[0], "mv88w8618"); dev = qdev_create(NULL, TYPE_MV88W8618_ETH); qdev_set_nic_properties(dev, &nd_table[0]); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, MP_ETH_BASE); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[MP_ETH_IRQ]); sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL); sysbus_create_simple(TYPE_MUSICPAL_MISC, MP_MISC_BASE, NULL); dev = sysbus_create_simple(TYPE_MUSICPAL_GPIO, MP_GPIO_BASE, pic[MP_GPIO_IRQ]); i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL); i2c = (I2CBus *)qdev_get_child_bus(i2c_dev, "i2c"); lcd_dev = sysbus_create_simple(TYPE_MUSICPAL_LCD, MP_LCD_BASE, NULL); key_dev = sysbus_create_simple(TYPE_MUSICPAL_KEY, -1, NULL); qdev_connect_gpio_out(i2c_dev, 0, qdev_get_gpio_in(dev, MP_GPIO_I2C_DATA_BIT)); qdev_connect_gpio_out(dev, 3, qdev_get_gpio_in(i2c_dev, 0)); qdev_connect_gpio_out(dev, 4, qdev_get_gpio_in(i2c_dev, 1)); for (i = 0; i < 3; i++) { qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(lcd_dev, i)); } for (i = 0; i < 4; i++) { qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 8)); } for (i = 4; i < 8; i++) { qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15)); } wm8750_dev = i2c_create_slave(i2c, "wm8750", MP_WM_ADDR); dev = qdev_create(NULL, "mv88w8618_audio"); s = SYS_BUS_DEVICE(dev); qdev_prop_set_ptr(dev, "wm8750", wm8750_dev); qdev_init_nofail(dev); sysbus_mmio_map(s, 0, MP_AUDIO_BASE); sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]); musicpal_binfo.ram_size = MP_RAM_DEFAULT_SIZE; musicpal_binfo.kernel_filename = kernel_filename; musicpal_binfo.kernel_cmdline = kernel_cmdline; musicpal_binfo.initrd_filename = initrd_filename; arm_load_kernel(cpu, &musicpal_binfo); }
1threat
static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) { AVFrame *decoded_frame, *f; int i, ret = 0, err = 0; if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc())) return AVERROR(ENOMEM); if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc())) return AVERROR(ENOMEM); decoded_frame = ist->decoded_frame; ret = decode(ist->dec_ctx, decoded_frame, got_output, pkt); if (!*got_output || ret < 0) return ret; ist->frames_decoded++; if (ist->hwaccel_retrieve_data && decoded_frame->format == ist->hwaccel_pix_fmt) { err = ist->hwaccel_retrieve_data(ist->dec_ctx, decoded_frame); if (err < 0) goto fail; } ist->hwaccel_retrieved_pix_fmt = decoded_frame->format; decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pts, decoded_frame->pkt_dts); if (ist->framerate.num) decoded_frame->pts = ist->cfr_next_pts++; if (ist->st->sample_aspect_ratio.num) decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio; for (i = 0; i < ist->nb_filters; i++) { if (i < ist->nb_filters - 1) { f = ist->filter_frame; err = av_frame_ref(f, decoded_frame); if (err < 0) break; } else f = decoded_frame; err = ifilter_send_frame(ist->filters[i], f); if (err < 0) break; } fail: av_frame_unref(ist->filter_frame); av_frame_unref(decoded_frame); return err < 0 ? err : ret; }
1threat
int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg) { int64_t deadline = -1; QEMUClockType type; bool play = replay_mode == REPLAY_MODE_PLAY; for (type = 0; type < QEMU_CLOCK_MAX; type++) { if (qemu_clock_use_for_deadline(type)) { if (!play || type == QEMU_CLOCK_REALTIME) { deadline = qemu_soonest_timeout(deadline, timerlist_deadline_ns(tlg->tl[type])); } else { qemu_clock_get_ns(type); } } } return deadline; }
1threat
How to set dpi in JPEG Image in java : <p>How can I set DPI to a JPEG image such that even if the size of the image gets shorter the quality of the picture stays good</p>
0debug
Batchfile: What's the best way to declare and use a boolean variable? : <p>What's the best way to declare and use a boolean variable in Batch files? This is what I'm doing now:</p> <pre><code>set "condition=true" :: Some code that may change the condition if %condition% == true ( :: Some work ) </code></pre> <p>Is there a better, more "formal" way to do this? (e.g. In Bash you can just do <code>if $condition</code> since <code>true</code> and <code>false</code> are commands of their own.)</p>
0debug
static uint32_t virtio_ioport_read(void *opaque, uint32_t addr) { VirtIODevice *vdev = to_virtio_device(opaque); uint32_t ret = 0xFFFFFFFF; addr -= vdev->addr; switch (addr) { case VIRTIO_PCI_HOST_FEATURES: ret = vdev->get_features(vdev); ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY); break; case VIRTIO_PCI_GUEST_FEATURES: ret = vdev->features; break; case VIRTIO_PCI_QUEUE_PFN: ret = vdev->vq[vdev->queue_sel].pfn; break; case VIRTIO_PCI_QUEUE_NUM: ret = vdev->vq[vdev->queue_sel].vring.num; break; case VIRTIO_PCI_QUEUE_SEL: ret = vdev->queue_sel; break; case VIRTIO_PCI_STATUS: ret = vdev->status; break; case VIRTIO_PCI_ISR: ret = vdev->isr; vdev->isr = 0; virtio_update_irq(vdev); break; default: break; } return ret; }
1threat
how to call functions from one subclass to another subclass in python3 : class Acct: def __init__(self, deposit): self.balance = deposit def balance(self): print("Your balance is $",self.balance) def getDeposit(self, deposit): self.balance = self.balance + deposit print("Your new balance is $",self.balance) def getWithdraw(self, withdraw): self.balance = self.balance - withdraw print("Your new balance is $",self.balance) class ChkAcct(Acct): def __init__(self, deposit): super().__init__(deposit) class SavAcct(Acct): def __init__(self, deposit): super().__init__(deposit) savings_account_starting_balance = float(input("Enter a starting balance for your savings account :")) savings_account = SavAcct(savings_account_starting_balance) savings_account.balance() checking_account_starting_balance = float(input("Enter a starting balance for your checking account :")) checking_account = ChkAcct(checking_account_starting_balance) checking_account.balance() savings_account.getDeposit(float(input("Enter a deposit ammout for savings account :"))) checking_account.getDeposit(float(input("Enter a deposit ammout for checking account:"))) savings_account.getWithdraw(float(input("Enter a withdraw ammout from savings:"))) checking_account.getWithdraw(float(input("Enter a withdraw ammout from checking:"))) I need to make 2 classes 'ChkAcct' and 'SavAcct'. Each class should have a balance property. Each class should have a deposit method. Each class should have a withdraw method.Each class should also have a transfer method that calls it's own withdraw method and invokes the deposit method from the other class. I can't seem to figure out how to make the transfer methods. any help is greatly appreciated.
0debug
char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index, int64_t cpu_index, Error **errp) { char *output = NULL; Monitor *old_mon, hmp; memset(&hmp, 0, sizeof(hmp)); hmp.outbuf = qstring_new(); hmp.skip_flush = true; old_mon = cur_mon; cur_mon = &hmp; if (has_cpu_index) { int ret = monitor_set_cpu(cpu_index); if (ret < 0) { cur_mon = old_mon; error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index", "a CPU number"); goto out; } } handle_user_command(&hmp, command_line); cur_mon = old_mon; if (qstring_get_length(hmp.outbuf) > 0) { output = g_strdup(qstring_get_str(hmp.outbuf)); } else { output = g_strdup(""); } out: QDECREF(hmp.outbuf); return output; }
1threat
How include node_modules in output directory with TypeScript : <p>I want to know if it possible copy node_modules folder into output directory after run tsc command.</p> <p>My situation it that I have a project with TypeScript and use some npm packages. And i need that my output directory has all npm dependencies, because i need to compress it and send by http (to AWS Lambda).</p> <p>My project structure is like this:</p> <pre><code>|-.vscode --&gt; visual studio code |-lib --&gt; output dir |-node_modules --&gt; npm dependencies |-src --&gt; .ts files |-jsconfig.json |-tsconfig.json </code></pre> <p>How can achieve it?</p> <p>Thanks a lot!</p>
0debug
static void init_proc_970 (CPUPPCState *env) { gen_spr_ne_601(env); gen_spr_7xx(env); gen_tbl(env); spr_register(env, SPR_HID0, "HID0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_clear, 0x60000000); spr_register(env, SPR_HID1, "HID1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_750_HID2, "HID2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_970_HID5, "HID5", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, POWERPC970_HID5_INIT); gen_low_BATs(env); spr_register(env, SPR_MMUCFG, "MMUCFG", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, SPR_NOACCESS, 0x00000000); spr_register(env, SPR_MMUCSR0, "MMUCSR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_HIOR, "SPR_HIOR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0xFFF00000); #if !defined(CONFIG_USER_ONLY) env->excp_prefix = 0xFFF00000; #endif #if !defined(CONFIG_USER_ONLY) env->slb_nr = 32; #endif init_excp_970(env); env->dcache_line_size = 128; env->icache_line_size = 128; ppc970_irq_init(env); }
1threat
static int analyze(const uint8_t *buf, int size, int packet_size, int *index, int probe) { int stat[TS_MAX_PACKET_SIZE]; int stat_all = 0; int i; int best_score = 0; memset(stat, 0, packet_size * sizeof(*stat)); for (i = 0; i < size - 3; i++) { if (buf[i] == 0x47 && (!probe || (!(buf[i + 1] & 0x80) && buf[i + 3] != 0x47))) { int x = i % packet_size; stat[x]++; stat_all++; if (stat[x] > best_score) { best_score = stat[x]; if (index) *index = x; } } } return best_score - FFMAX(stat_all - 10*best_score, 0)/10; }
1threat
I need help in understanding the following kernel module written in C : <p>As an assignment I need to complete the following C code in order to produce a kernel module able to act as a memory, but from how it's written I can't understand how it works and why many variables are not used but just declared. I have already tried looking on the teaching material they gave me, and it's even more confusing, plus I can't find on the web a good site where to find documentation about these functions. </p> <p>The code is the following:</p> <pre><code>#include &lt;linux/kernel.h&gt; #include &lt;linux/module.h&gt; #include &lt;linux/init.h&gt; #include &lt;linux/fs.h&gt; #include &lt;asm/uaccess.h&gt; #define DEVICE_NAME "my_device" #define MAJOR_DEVICE_NUMBER 60 #define MINOR_DEVICE_NUMBER 0 #define BUF_LEN 1024 static char msg[BUF_LEN]; static char *msg_ptr; // I'm pretty sure this should become msg_reading_offset static int major; MODULE_AUTHOR("&lt;YOUR NAME&gt;"); MODULE_LICENSE("GPL"); static ssize_t my_read ( struct file *filp, char __user *buf, size_t length, loff_t *offset); static ssize_t my_write ( struct file *filp, const char __user *buf, size_t length, loff_t *offset); static int my_open (struct inode *inode, struct file *filp); static int my_close (struct inode *inode, struct file *filp); static int __init my_init (void); static void __exit my_cleanup (void); static struct file_operations fops = { .read = my_read, .write = my_write, .open = my_open, .release = my_close, }; // I need to implement this function static int my_open (struct inode *inode, struct file *filp) { return 0; } // and this function static int my_close (struct inode *inode, struct file *filp) { return 0; } static ssize_t my_read ( struct file *filp, char __user *buf, size_t length, loff_t *offset) { int nc = 0; // if no more "valid" bytes can be read, stop if (*msg_reading_offset == 0) return 0; // no-negative values allowed if (length &lt; 0) return -EINVAL; // read the whole msg, nothing more if (length &gt; strlen(msg)) { length = strlen(msg); } nc = copy_to_user(buf, msg_reading_offset, length); /* updates the current reading offset pointer so that a recursive call due to not original full length will get a 0 (nothing to read) */ msg_reading_offset += sizeof(char) * (length-nc); // returns the number of REAL bytes read. return length - nc; } static ssize_t my_write ( struct file *filp, const char __user *buf, size_t length, loff_t *offset) { int nc = 0; if (length &gt; BUF_LEN) return BUF_LEN-length; nc = copy_from_user(msg,buf,length); msg_ptr = msg; return length - nc; } static int __init my_init (void) { register_chrdev (MAJOR_DEVICE_NUMBER, DEVICE_NAME, &amp;fops); } module_init(my_init); static void __exit my_cleanup (void) { unregister_chrdev (major, DEVICE_NAME); } module_exit(my_cleanup); </code></pre> <p>At the moment these are my biggest problems:</p> <ul> <li>Where are all the *inode, *filp variables going? Am I supposed to use them?</li> <li>How is this program even working? I know I need to compile it with a makefile I've been give, but then how am I supposed to access these functions? </li> <li>Is this supposed to be a real program executed by the kernel or is it just a collections of functions I should use in another C program?</li> </ul> <p>I'm sorry if the questions may seem stupid, but I am at a loss to know how the hell I'm supposed to approach this.</p>
0debug
Prepend element to numpy array : <p>I have the following numpy array</p> <pre><code>import numpy as np X = np.array([[5.], [4.], [3.], [2.], [1.]]) </code></pre> <p>I want to insert <code>[6.]</code> at the beginning. I've tried:</p> <pre><code>X = X.insert(X, 0) </code></pre> <p>how do I insert into X?</p>
0debug
Python 3 : TypeError : 'str' does bit support the buffer interface : I'm developing a graphical interface with python 3, so i found a code that helps me to send a file(gcode) to GRBL , but this code is on python 2. I tried to modify the programm to work on python 3 ---------- import serial import time # Open grbl serial port s = serial.Serial('/dev/ttyS0',115200) # Open g-code file f = open(r'/home/pi/Downloads/spinner.gcode'); # Wake up grbl s.write("\r\n\r\n").encode("utf8") time.sleep(2) # Wait for grbl to initialize s.flushInput() # Flush startup text in serial input # Stream g-code to grbl for line in f: l = line.strip() # Strip all EOL characters for streaming print ('Sending: ' + l) s.write(l + '\n') # Send g-code block to grbl grbl_out = s.readline() # Wait for grbl response with carriage return print( ' : ' + grbl_out.strip()) # Wait here until grbl is finished to close serial port and file. raw_input(" Press <Enter> to exit and disable grbl.") # Close file and serial port f.close() s.close() When i run it ,it shows me an error : TypeError : 'str' does not support the buffer interface
0debug
Making My Own CLI(Command Line Interface) Using CMD : <p>In the previous accepted reply I found the following code. <a href="https://codereview.stackexchange.com/questions/41121/making-a-bat-batch-command-line-interface#new-answer?s=0857a55f8b4e43c1a1d4b13236169370">source</a>: <a href="https://codereview.stackexchange.com/questions/41121/making-a-bat-batch-command-line-interface#new-answer?s=0857a55f8b4e43c1a1d4b13236169370">https://codereview.stackexchange.com/questions/41121/making-a-bat-batch-command-line-interface#new-answer?s=0857a55f8b4e43c1a1d4b13236169370</a></p> <h2>Title: Making a .bat batch command-line interface</h2> <pre><code>:: Define all valid commands: make sure there is a space between each command :: and also one at beginning and end set "commands= something echo exit " :input.get :: Clear the existing value in case user hits &lt;Enter&gt; without entering anything set "input=" :: Get the next command set /p "input=COMMAND\&gt;" :: Parse command into command and arguments. for /f "tokens=1* delims= " %%A in ("!input!") do ( REM check if command is valid (not case sensitive) and act accordingly if "!commands: %%A =!" equ "!commands!" ( echo Invalid command: %%A ) else if /i %%A equ exit ( exit /b ) else ( call :%%A %%B ) ) echo( goto input.get :something echo Doing something with Arg1=[%1] and Arg2=[%2] exit /b :echo echo(%* exit /b </code></pre> <p>If I want to add one more command how to do that? like if user write 'pop' then he/she wile get the reply like bellow:</p> <pre><code>You wrote pop </code></pre> <p>Now how can I this by editing this.</p>
0debug
def func(nums, k): import collections d = collections.defaultdict(int) for row in nums: for i in row: d[i] += 1 temp = [] import heapq for key, v in d.items(): if len(temp) < k: temp.append((v, key)) if len(temp) == k: heapq.heapify(temp) else: if v > temp[0][0]: heapq.heappop(temp) heapq.heappush(temp, (v, key)) result = [] while temp: v, key = heapq.heappop(temp) result.append(key) return result
0debug
static void scsi_do_read(void *opaque, int ret) { SCSIDiskReq *r = opaque; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); uint32_t n; if (r->req.aiocb != NULL) { r->req.aiocb = NULL; bdrv_acct_done(s->qdev.conf.bs, &r->acct); if (ret < 0) { if (scsi_handle_rw_error(r, -ret)) { goto done; if (r->req.sg) { dma_acct_start(s->qdev.conf.bs, &r->acct, r->req.sg, BDRV_ACCT_READ); r->req.resid -= r->req.sg->size; r->req.aiocb = dma_bdrv_read(s->qdev.conf.bs, r->req.sg, r->sector, scsi_dma_complete, r); } else { n = scsi_init_iovec(r, SCSI_DMA_BUF_SIZE); bdrv_acct_start(s->qdev.conf.bs, &r->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_READ); r->req.aiocb = bdrv_aio_readv(s->qdev.conf.bs, r->sector, &r->qiov, n, scsi_read_complete, r); done: if (!r->req.io_canceled) { scsi_req_unref(&r->req);
1threat
Android - change Date format to - dd.mm.yyyy HH:mm : <p>I have a Date object like this:</p> <pre><code>Fri Jan 29 13:22:57 GMT+01:00 2016 </code></pre> <p>And I need it to look like this:</p> <p><strong><em>29.01.2016 13:22</em></strong></p> <p>How can I do that ?</p>
0debug
Evaluation of method in Watch window cannot be called in this context : <p>I'm trying to see the <code>DateTimeOffset</code> values of some objects in a collection in the Watch window. So I typed:</p> <pre><code>collection.Select(v =&gt; v.CreatedAt.ToString("O")) </code></pre> <p>Trying to evaluate this however yields an error:</p> <blockquote> <p>Evaluation of method System.Linq.SystemCore_EnumerableDebugView`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].get_Items requires calling method System.Globalization.GregorianCalendar.get_ID, which cannot be called in this context.</p> </blockquote> <p>I could have just specified <code>v.CreatedAt</code> which works but I'm interested in the milliseconds too, so I'm using the <code>O</code> format. Just calling <code>ToString()</code> yields the same error.</p> <p>So I'm wondering what is "this context" in the error message, and is there a chance to extend this context to make this possible?</p>
0debug
How can I convert this SQL queriy to Linq with C# : Since I am new to Linq so not able to convert this SQL query to Linq I am pasting my code that I have already tried, it gives null records. **Thanks in advance** **This is my Linq C# Statements that I have tried.** from ts in Db.Tasks join prt in Db.ProjectTasks on ts.Id equals prt.TaskId into PojTsk from t1 in PojTsk join TL in Db.Timeline on ts.Id equals TL.TypeId into Tmln from t2 in Tmln join DUR in Db.Duration on ts.Id equals DUR.TypeId into Dur from t3 in Tmln where t1.ProjectId == ProjectId && t2.Type == (int)Provider.EntityType.TASK && t3.Type == (int)Provider.EntityType.TASK select ts **This Is my SQL Query that I am trying to convert into Linq with C#.** SELECT CONCAT('T', R1.Id) as Id, R1.Name, R1.Description, R1.Priority, R1.Stage, R1.Status, R1.CreatorId, R2.ProjectId, R3.StartDate, R3.EndDate, R3.LatestEndDate , R3.LatestStartDate, R3.EarliestStartDate, R3.ActualStart, R3.ActualEnd, R3.RemTime, R3.ReshowDate, R3.RemTime, R3.Completed, R4.ActualDuration, R4.ActualDurationPlanned FROM (select * from [ProjectManagement].[dbo].[Tasks] as TS) as R1 join (select * from [ProjectManagement].[dbo].[ProjectTasks] ) as R2 on R1.Id = R2.TaskId left join (select * from [ProjectManagement].[dbo].[Timelines] where Type = 3 ) as R3 on R1.Id = R3.TypeId left join (select * from [ProjectManagement].[dbo].[Durations] where Type = 3 ) as R4 on R1.Id = R4.TypeId where ProjectId = 1
0debug
only the first line of my javasript code works : I have used some code to fill my inputs bij an onlcick fucntion. Now the first line works but it seems that he skips the other lines what can i do?. This is my code: `var InputProduct = document.getElementById("product"); var InputNaam = document.getElementById("Anaam"); var InputPrijs = document.getElementById("APrijs"); var InputVolgorde = document.getElementById("AvolgNR");` function fill($name, $prijs , $volgorde) { InputProduct.value = $name; InputNaam.value = $name; InputPrijs.value = $prijs; InputVolgorde.value = $volgorde; } and this is how i use the onclick: `onclick="fill('<?php echo $adviesprijzen['Naam']; ?>', '<?php echo $adviesprijzen['BedragInclBTW']; ?>', '<?php echo $adviesprijzen['volgorde']; ?>')"`
0debug
void ff_xvmc_field_end(MpegEncContext *s) { struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2]; assert(render); if (render->filled_mv_blocks_num > 0) ff_mpeg_draw_horiz_band(s, 0, 0); }
1threat
static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) { SliceContext *slice = link->dst->priv; if (slice->use_random_h) { slice->lcg_state = slice->lcg_state * 1664525 + 1013904223; slice->h = 8 + (uint64_t)slice->lcg_state * 25 / UINT32_MAX; } slice->h = FFMAX(8, slice->h & (-1 << slice->vshift)); av_log(link->dst, AV_LOG_DEBUG, "h:%d\n", slice->h); link->cur_buf = NULL; return ff_start_frame(link->dst->outputs[0], picref); }
1threat
static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVRawState *s = bs->opaque; void *buf = NULL; BlockDriver *drv; QEMUIOVector local_qiov; int ret; if (s->has_size && (offset > s->size || bytes > (s->size - offset))) { return -ENOSPC; } if (offset > UINT64_MAX - s->offset) { ret = -EINVAL; goto fail; } if (bs->probed && offset < BLOCK_PROBE_BUF_SIZE && bytes) { QEMU_BUILD_BUG_ON(BLOCK_PROBE_BUF_SIZE != 512); QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE != 512); assert(offset == 0 && bytes >= BLOCK_PROBE_BUF_SIZE); buf = qemu_try_blockalign(bs->file->bs, 512); if (!buf) { ret = -ENOMEM; goto fail; } ret = qemu_iovec_to_buf(qiov, 0, buf, 512); if (ret != 512) { ret = -EINVAL; goto fail; } drv = bdrv_probe_all(buf, 512, NULL); if (drv != bs->drv) { ret = -EPERM; goto fail; } qemu_iovec_init(&local_qiov, qiov->niov + 1); qemu_iovec_add(&local_qiov, buf, 512); qemu_iovec_concat(&local_qiov, qiov, 512, qiov->size - 512); qiov = &local_qiov; } offset += s->offset; BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); ret = bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); fail: if (qiov == &local_qiov) { qemu_iovec_destroy(&local_qiov); } qemu_vfree(buf); return ret; }
1threat
How to chain functions? : <p>I am trying to understand the mechanics of chained functions such as</p> <pre><code>&gt;&gt;&gt; 'hello'.upper() 'HELLO' </code></pre> <p>(the chain can be longer, I do not have a good example in my head right now - something like <code>'hello'.upper().reverse().take_every_second_character().rot13()</code>)</p> <p>How is this functionality achieved? What must be returned by each of the functions (and intercepted (= used as a parameter?) by the next one), taken into account that one can break the chain somewhere and still get an output? To take the fictional example above:</p> <pre><code>&gt;&gt;&gt; 'hello' 'hello' &gt;&gt;&gt; 'hello'.upper() 'HELLO' &gt;&gt;&gt; 'hello'.upper().reverse() 'OLLEH' </code></pre> <p>etc.</p>
0debug
aio_ctx_finalize(GSource *source) { AioContext *ctx = (AioContext *) source; thread_pool_free(ctx->thread_pool); #ifdef CONFIG_LINUX_AIO if (ctx->linux_aio) { laio_detach_aio_context(ctx->linux_aio, ctx); laio_cleanup(ctx->linux_aio); ctx->linux_aio = NULL; } #endif qemu_lockcnt_lock(&ctx->list_lock); assert(!qemu_lockcnt_count(&ctx->list_lock)); while (ctx->first_bh) { QEMUBH *next = ctx->first_bh->next; assert(ctx->first_bh->deleted); g_free(ctx->first_bh); ctx->first_bh = next; } qemu_lockcnt_unlock(&ctx->list_lock); aio_set_event_notifier(ctx, &ctx->notifier, false, NULL, NULL); event_notifier_cleanup(&ctx->notifier); qemu_rec_mutex_destroy(&ctx->lock); qemu_lockcnt_destroy(&ctx->list_lock); timerlistgroup_deinit(&ctx->tlg); }
1threat
In the sas ,the length of a variable is 8 bytes, but display 12 bytes : [In my opinion, the length of variable is the bytes in which the variable is stored , but in the following picture, the the length of variable displayed is beyond the length of variable. Help me, please][1] [1]: http://i.stack.imgur.com/BLe4T.jpg
0debug
static int qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext) { switch (le32_to_cpu(ext->cmd.type)) { case QXL_CMD_SURFACE: { QXLSurfaceCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id); if (!cmd) { uint32_t id = le32_to_cpu(cmd->surface_id); if (id >= qxl->ssd.num_surfaces) { qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE id %d >= %d", id, qxl->ssd.num_surfaces); qemu_mutex_lock(&qxl->track_lock); if (cmd->type == QXL_SURFACE_CMD_CREATE) { qxl->guest_surfaces.cmds[id] = ext->cmd.data; qxl->guest_surfaces.count++; if (qxl->guest_surfaces.max < qxl->guest_surfaces.count) qxl->guest_surfaces.max = qxl->guest_surfaces.count; if (cmd->type == QXL_SURFACE_CMD_DESTROY) { qxl->guest_surfaces.cmds[id] = 0; qxl->guest_surfaces.count--; qemu_mutex_unlock(&qxl->track_lock); break; case QXL_CMD_CURSOR: { QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id); if (!cmd) { if (cmd->type == QXL_CURSOR_SET) { qemu_mutex_lock(&qxl->track_lock); qxl->guest_cursor = ext->cmd.data; qemu_mutex_unlock(&qxl->track_lock); break; return 0;
1threat
Is there a way to use method references for top-level functions in jshell? : <p>Suppose I do this in jshell:</p> <pre><code>jshell&gt; void printIsEven(int i) { ...&gt; System.out.println(i % 2 == 0); ...&gt; } | created method printIsEven(int) jshell&gt; List&lt;Integer&gt; l = Arrays.asList(7,5,4,8,5,9); l ==&gt; [7, 5, 4, 8, 5, 9] jshell&gt; l.forEach(/* ??? */); // is it possible to use a method reference here? </code></pre> <p>In a normal program I could write <code>l.forEach(this::printIsEven)</code> in a non-static context or <code>l.forEach(MyClass::printIsEven)</code> in the static context of a class named <code>MyClass</code>.</p> <p>Using <code>this::printIsEven</code> in jshell doesn't work because jshell executes statements in a static context, but you can't use a static method reference because there's no class name to prefix <code>::printIsEven</code>, and trying <code>l.forEach(::printIsEven)</code> is just a syntax error.</p>
0debug
Pip installed, but command not found : <p>I checked a few posts with similar wording in the question, and tried out the offered solutions, but I have not been able to fix the problem. My computer says pip is installed, but it does not recognize the command. When I try to use 'sudo' to install it, it won't let me, responding that it is already installed, as shown in the attached photo.</p> <p><a href="https://i.stack.imgur.com/GKugL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GKugL.png" alt="enter image description here"></a></p>
0debug
nand_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { struct nand_state_t *s = opaque; int rdy; DNAND(printf("%s addr=%x v=%x\n", __func__, addr, (unsigned)value)); nand_setpins(s->nand, s->cle, s->ale, s->ce, 1, 0); nand_setio(s->nand, value); nand_getpins(s->nand, &rdy); s->rdy = rdy; }
1threat
How to get correct readings from arduino sensors : i am currently working on my graduation project. i'm using 6 different sensors which are working simultaneously. But i got a problem in the readings from the LM35 temperature sensor and the MQ-7 Carbon Monoxide sensor. The readings are changing depending on the power source. how to fix this problem? i'm planning to use a Sony battery bank to feed my system by i get wrong readings especially from the temperature sensor. Thank you
0debug
static int mpegts_audio_write(void *opaque, uint8_t *buf, int size) { MpegTSWriteStream *ts_st = (MpegTSWriteStream *)opaque; if (ts_st->adata_pos + size > ts_st->adata_size) return AVERROR(EIO); memcpy(ts_st->adata + ts_st->adata_pos, buf, size); ts_st->adata_pos += size; return 0; }
1threat
static int protocol_client_auth_sasl_step(VncState *vs, uint8_t *data, size_t len) { uint32_t datalen = len; const char *serverout; unsigned int serveroutlen; int err; char *clientdata = NULL; if (datalen) { clientdata = (char*)data; clientdata[datalen-1] = '\0'; datalen--; } VNC_DEBUG("Step using SASL Data %p (%d bytes)\n", clientdata, datalen); err = sasl_server_step(vs->sasl.conn, clientdata, datalen, &serverout, &serveroutlen); if (err != SASL_OK && err != SASL_CONTINUE) { VNC_DEBUG("sasl step failed %d (%s)\n", err, sasl_errdetail(vs->sasl.conn)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } if (serveroutlen > SASL_DATA_MAX_LEN) { VNC_DEBUG("sasl step reply data too long %d\n", serveroutlen); sasl_dispose(&vs->sasl.conn); vs->sasl.conn = NULL; goto authabort; } VNC_DEBUG("SASL return data %d bytes, nil; %d\n", serveroutlen, serverout ? 0 : 1); if (serveroutlen) { vnc_write_u32(vs, serveroutlen + 1); vnc_write(vs, serverout, serveroutlen + 1); } else { vnc_write_u32(vs, 0); } vnc_write_u8(vs, err == SASL_CONTINUE ? 0 : 1); if (err == SASL_CONTINUE) { VNC_DEBUG("%s", "Authentication must continue\n"); vnc_read_when(vs, protocol_client_auth_sasl_step_len, 4); } else { if (!vnc_auth_sasl_check_ssf(vs)) { VNC_DEBUG("Authentication rejected for weak SSF %p\n", vs->ioc); goto authreject; } if (vnc_auth_sasl_check_access(vs) < 0) { VNC_DEBUG("Authentication rejected for ACL %p\n", vs->ioc); goto authreject; } VNC_DEBUG("Authentication successful %p\n", vs->ioc); vnc_write_u32(vs, 0); if (vs->sasl.runSSF) vs->sasl.waitWriteSSF = vs->output.offset; start_client_init(vs); } return 0; authreject: vnc_write_u32(vs, 1); vnc_write_u32(vs, sizeof("Authentication failed")); vnc_write(vs, "Authentication failed", sizeof("Authentication failed")); vnc_flush(vs); vnc_client_error(vs); return -1; authabort: vnc_client_error(vs); return -1; }
1threat
static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, uint32_t node, Error **errp) { Error *local_err = NULL; sPAPRMachineState *ms = SPAPR_MACHINE(hotplug_dev); PCDIMMDevice *dimm = PC_DIMM(dev); PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); MemoryRegion *mr = ddc->get_memory_region(dimm); uint64_t align = memory_region_get_alignment(mr); uint64_t size = memory_region_size(mr); uint64_t addr; char *mem_dev; if (size % SPAPR_MEMORY_BLOCK_SIZE) { error_setg(&local_err, "Hotplugged memory size must be a multiple of " "%lld MB", SPAPR_MEMORY_BLOCK_SIZE/M_BYTE); pc_dimm_memory_plug(dev, &ms->hotplug_memory, mr, align, &local_err); if (local_err) { addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err); if (local_err) { pc_dimm_memory_unplug(dev, &ms->hotplug_memory, mr); spapr_add_lmbs(dev, addr, size, node, spapr_ovec_test(ms->ov5_cas, OV5_HP_EVT), &error_abort); out: error_propagate(errp, local_err);
1threat
Migrate to Kotlin coroutines in Android with Kotlin 1.3 : <p>What should I change in my <code>build.gradle</code> file or import in classes to use stable coroutine functions in my Android project with Kotlin 1.3 ?</p> <p>Fragment about coroutines in my <code>build.gradle</code></p> <p><code>implementation "org.jetbrains.kotlin:kotlin-coroutines-core:$coroutines_version" implementation "org.jetbrains.kotlin:kotlin-coroutines-android:$coroutines_version"</code></p> <p>Of course I use Android Studio 3.3 Preview</p>
0debug
how to get the form name dynamically : I have many forms that are dynamically created and each form is ends with a number which is incremental. Each form has a submit button which also has a dynamically assigned name. I am using the following code to call a function but its limited to only one form. Is there anyway to customize it so it dynamically uses the form name assigned? **THE JQUERY** <!-- begin snippet: js hide: false --> <!-- language: lang-none --> $("myform0").submit(function (e) { //Stops the submit request e.preventDefault(); }); //checks for the button click event $("#submit0").click(function (e) { callfunction(); }); <!-- end snippet --> **The HTML** <!-- begin snippet: js hide: false --> <!-- language: lang-none --> <form name="myform0"> <input type="hidden" name="caseid" value="5008000000oYdXIAA0"> <input type="submit" name="submit0" value="submit"> </form> <!-- end snippet -->
0debug
static void zero_remaining(unsigned int b, unsigned int b_max, const unsigned int *div_blocks, int32_t *buf) { unsigned int count = 0; while (b < b_max) count += div_blocks[b]; if (count) memset(buf, 0, sizeof(*buf) * count); }
1threat
Angular2 get window width onResize : <p>Trying to figure out how to get window width on resizing events in Angular2. Here is my code:</p> <pre><code>export class SideNav { innerWidth: number; constructor(private window: Window){ let getWindow = function(){ return window.innerWidth; }; window.onresize = function() { this.innerWidth = getWindow(); console.log(getWindow()); }; } </code></pre> <p>I am importing window provider globally in the bootstrap.ts file using provide to gain access across my app to window. The problem I am having is this does give me a window size, but on resizing the window - it just repeats the same size over and over even if the window changes size. See image for console.log example: <a href="https://i.stack.imgur.com/RtVCD.png" rel="noreferrer">Screenshot image</a></p> <p>My overall goal is to be able to set the window number to a variable onresize so I can have access to it in the template. Any ideas on what I am doing wrong here?</p> <p>Thanks!</p>
0debug
Nested Exception could not execute statement - HTTP Status 500 - Hibernate : I've been working on project in Spring, I'm trying to add functionality which will add int ( mark in this case ) to my MySQL database but after clicking button I've a following error: HTTP Status 500 - Request processing failed; nested exception is org.springframework.orm.hibernate5.HibernateJdbcException: JDBC exception on Hibernate data access: SQLException for SQL [n/a]; SQL state [HY000]; error code [1364]; could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement This is the log from the console: SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/eschool] threw exception [Request processing failed; nested exception is org.springframework.orm.hibernate5.HibernateJdbcException: JDBC exception on Hibernate data access: SQLException for SQL [n/a]; SQL state [HY000]; error code [1364]; could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement] with root cause java.sql.SQLException: Field 'value' doesn't have a default value at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:205) at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3003) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3503) at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:586) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:460) at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39) at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1428) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:484) at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3190) at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2404) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220) at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68) at org.springframework.orm.hibernate5.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:582) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) at com.sun.proxy.$Proxy54.addMark(Unknown Source) These are my classes and the view: Teacher.class https://paste.ofcode.org/v6EHpJL5v5QSPmgis4ZPcZ MarkDAO https://paste.ofcode.org/NtqNgS6FqrbR6DRiWdNRNJ MarkDAOImpl https://paste.ofcode.org/33QPdkTZXhfaUi2th5uydbP TeacherController - I'm adding mark in this class https://paste.ofcode.org/QUC7BDiwAPgAkMW6Uznyb2 and the view - it suppose to change from disable to enable but it's not working too, don't know why exactly... I've got three students there but it shows 0 :/ https://paste.ofcode.org/BiV6GjFVfmyPzzF753sams If you'll need more logs or another class, which I forgot to add, let me know in a comment. Please help, it's urgent :/
0debug
How can I find the service principal secret of my AKS cluster? : <p>Okay, so I messed up, I accidentally ran <code>az ad sp reset-credentials</code> against the Service Principal that our AKS cluster runs under. And now we are getting errors like: </p> <blockquote> <p>Error creating load balancer (will retry): error getting LB for service test/admin-api: azure.BearerAuthorizer#WithAuthorization: Failed to refresh the Token for request to <a href="https://management.azure.com/subscriptions/" rel="noreferrer">https://management.azure.com/subscriptions/</a>****/resourceGroups/MC_****/providers/Microsoft.Network/loadBalancers?api-version=2017-09-01: StatusCode=0 -- Original Error: adal: Refresh request failed. Status Code = '401'. Response body: {"error":"invalid_client","error_description":"AADSTS70002: Error validating credentials. AADSTS50012: Invalid client secret is provided.\r\nTrace ID:****\r\nCorrelation ID:**** \r\nTimestamp: 2018-08-23 12:01:33Z","error_codes":[70002,50012],"timestamp":"2018-08-23 12:01:33Z","trace_id":"****","correlation_id":"****"}</p> </blockquote> <p>and</p> <blockquote> <p>Failed to pull image "****.azurecr.io/****:****": rpc error: code = Unknown desc = Error response from daemon: Get https://****.azurecr.io/v2/****/manifests/****: unauthorized: authentication required</p> </blockquote> <p>So now I want to find the original client secret that the Service Principal uses, so that I can re-add that as a key to the Service Principal. That's the only solution I can think of other than recreating the entire cluster.</p> <p>Any ideas?</p>
0debug
Object must implement IConvertible (InvalidCastException) while casting to interface : <p>I'm trying to cast an object of a certain type to an interface it implements using <code>Convert.ChangeType()</code>, however an <code>InvalidCastException</code> gets thrown because <em>the object must implement IConvertible</em>.</p> <p>The types:</p> <pre><code>public IDocumentSet : IQueryable {} public IDocumentSet&lt;TDocument&gt; : IDocumentSet, IQueryable&lt;TDocument&gt; {} public XmlDocumentSet&lt;TDocument&gt; : IDocumentSet&lt;TDocument&gt; {} </code></pre> <p>Excerpt from code where the error happens:</p> <pre><code>private readonly ConcurrentDictionary&lt;Type, IDocumentSet&gt; _openDocumentSets = new ConcurrentDictionary&lt;Type, IDocumentSet&gt;(); public void Commit() { if (_isDisposed) throw new ObjectDisposedException(nameof(IDocumentStore)); if (!_openDocumentSets.Any()) return; foreach (var openDocumentSet in _openDocumentSets) { var documentType = openDocumentSet.Key; var documentSet = openDocumentSet.Value; var fileName = GetDocumentSetFileName(documentType); var documentSetPath = Path.Combine(FolderPath, fileName); using (var stream = new FileStream(documentSetPath, FileMode.Create, FileAccess.Write)) using (var writer = new StreamWriter(stream)) { var documentSetType = typeof (IDocumentSet&lt;&gt;).MakeGenericType(documentType); var writeMethod = typeof (FileSystemDocumentStoreBase) .GetMethod(nameof(WriteDocumentSet), BindingFlags.Instance | BindingFlags.NonPublic) .MakeGenericMethod(documentSetType); var genericDocumentSet = Convert.ChangeType(documentSet, documentSetType); &lt;------- writeMethod.Invoke(this, new[] {writer, genericDocumentSet}); } } } </code></pre> <p>Now, I'm failing to understand why exactly this happens (as <code>XmlDocumentSet</code> is not a value type) and <code>XmlDocumentSet&lt;'1&gt;</code> implements <code>IDocumentSet&lt;'1&gt;</code>. Am I missing something? Or is there an easier way to achieve what I'm doing?</p>
0debug
static int u3_agp_pci_host_init(PCIDevice *d) { pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_U3_AGP); d->config[0x08] = 0x00; pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0C] = 0x08; d->config[0x0D] = 0x10; return 0; }
1threat
static void mmio_ide_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { MMIOState *s = opaque; addr >>= s->shift; if (addr & 7) ide_ioport_write(&s->bus, addr, val); else ide_data_writew(&s->bus, 0, val); }
1threat
static const mon_cmd_t *monitor_parse_command(Monitor *mon, const char *cmdline, QDict *qdict) { const char *p, *typestr; int c; const mon_cmd_t *cmd; char cmdname[256]; char buf[1024]; char *key; #ifdef DEBUG monitor_printf(mon, "command='%s'\n", cmdline); #endif p = get_command_name(cmdline, cmdname, sizeof(cmdname)); if (!p) return NULL; for(cmd = mon_cmds; cmd->name != NULL; cmd++) { if (compare_cmd(cmdname, cmd->name)) break; } if (cmd->name == NULL) { monitor_printf(mon, "unknown command: '%s'\n", cmdname); return NULL; } typestr = cmd->args_type; for(;;) { typestr = key_get_info(typestr, &key); if (!typestr) break; c = *typestr; typestr++; switch(c) { case 'F': case 'B': case 's': { int ret; while (qemu_isspace(*p)) p++; if (*typestr == '?') { typestr++; if (*p == '\0') { break; } } ret = get_str(buf, sizeof(buf), &p); if (ret < 0) { switch(c) { case 'F': monitor_printf(mon, "%s: filename expected\n", cmdname); break; case 'B': monitor_printf(mon, "%s: block device name expected\n", cmdname); break; default: monitor_printf(mon, "%s: string expected\n", cmdname); break; } goto fail; } qdict_put(qdict, key, qstring_from_str(buf)); } break; case '/': { int count, format, size; while (qemu_isspace(*p)) p++; if (*p == '/') { p++; count = 1; if (qemu_isdigit(*p)) { count = 0; while (qemu_isdigit(*p)) { count = count * 10 + (*p - '0'); p++; } } size = -1; format = -1; for(;;) { switch(*p) { case 'o': case 'd': case 'u': case 'x': case 'i': case 'c': format = *p++; break; case 'b': size = 1; p++; break; case 'h': size = 2; p++; break; case 'w': size = 4; p++; break; case 'g': case 'L': size = 8; p++; break; default: goto next; } } next: if (*p != '\0' && !qemu_isspace(*p)) { monitor_printf(mon, "invalid char in format: '%c'\n", *p); goto fail; } if (format < 0) format = default_fmt_format; if (format != 'i') { if (size < 0) size = default_fmt_size; default_fmt_size = size; } default_fmt_format = format; } else { count = 1; format = default_fmt_format; if (format != 'i') { size = default_fmt_size; } else { size = -1; } } qdict_put(qdict, "count", qint_from_int(count)); qdict_put(qdict, "format", qint_from_int(format)); qdict_put(qdict, "size", qint_from_int(size)); } break; case 'i': case 'l': { int64_t val; while (qemu_isspace(*p)) p++; if (*typestr == '?' || *typestr == '.') { if (*typestr == '?') { if (*p == '\0') { typestr++; break; } } else { if (*p == '.') { p++; while (qemu_isspace(*p)) p++; } else { typestr++; break; } } typestr++; } if (get_expr(mon, &val, &p)) goto fail; if ((c == 'i') && ((val >> 32) & 0xffffffff)) { monitor_printf(mon, "\'%s\' has failed: ", cmdname); monitor_printf(mon, "integer is for 32-bit values\n"); goto fail; } qdict_put(qdict, key, qint_from_int(val)); } break; case '-': { const char *tmp = p; int has_option, skip_key = 0; c = *typestr++; if (c == '\0') goto bad_type; while (qemu_isspace(*p)) p++; has_option = 0; if (*p == '-') { p++; if(c != *p) { if(!is_valid_option(p, typestr)) { monitor_printf(mon, "%s: unsupported option -%c\n", cmdname, *p); goto fail; } else { skip_key = 1; } } if(skip_key) { p = tmp; } else { p++; has_option = 1; } } qdict_put(qdict, key, qint_from_int(has_option)); } break; default: bad_type: monitor_printf(mon, "%s: unknown type '%c'\n", cmdname, c); goto fail; } qemu_free(key); key = NULL; } while (qemu_isspace(*p)) p++; if (*p != '\0') { monitor_printf(mon, "%s: extraneous characters at the end of line\n", cmdname); goto fail; } return cmd; fail: qemu_free(key); return NULL; }
1threat
static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { DeviceState *dev = DEVICE(obj); Property *prop = opaque; PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop); char buffer[] = "xxxx:xx:xx.x"; char *p = buffer; int rc = 0; rc = snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d", addr->domain, addr->bus, addr->slot, addr->function); assert(rc == sizeof(buffer) - 1); visit_type_str(v, name, &p, errp); }
1threat
PHP - How To Improve This Inconvenient Function : I'm making a function to return whenether or not the given user ID is a staff member of the site. This is what I have and it works, however I feel like it can be greatly improved and I'm taking a wrong turn of doing what I want to achieve: public function isUserStaff($uid) { $stmt = $this->conn->prepare("SELECT user_role FROM users WHERE user_id=:user_id"); $stmt->execute(array(':user_id'=>$uid)); $userRow = $stmt->fetch(PDO::FETCH_ASSOC); $role = $userRow['user_role']; switch($role) { case 3: return true; break; case 4: return true; break; case 5: return true; break; case 6: return true; break; case 7: return true; break; default: return false; break; } } I hope someone can help me out and describe how I can make my code better.
0debug
Unable to Update UI using AsyncTask in Android : I have a `MapActivity` in my android application and I want to draw a route from source to destination followed by drawing `polyline` along the path found. I am showing a `progressDialog` while `polyline` is drawn along the path. I think drawing polyline is a heavy task as it caused `progressDialog` to stop spinning. So I put `drawPolyline` functionality inside an `AsyncTask`. But the problem I am facing now is I am not getting updated screen but suddenly the `MapActivity` screen blinks and disappear and I see the MainActivity now. Why is it happening? I want to know whether or not updating UI in AsyncTask is conceptually correct? If yes, how can we go about doing it? **Note:** I have checked AsyncTask functionality by putting breakPoints. It is working as expected but drawPolyline causes error. Also drawPolyline has no problem as it works fine when called without AsyncTask. Any kind of suggestions will be greatly appreciated. Thanks!
0debug
allocating a specific number of bytes in memory : <p>I have been trying to allocate a memory pool of a specified number of bytes in memory. when I proceeded to test the program, it would only allocate a single byte at a time for each memory pool.</p> <pre><code> typedef struct _POOL { int size; void* memory; } Pool; Pool* allocatePool(int x); void freePool(Pool* pool); void store(Pool* pool, int offset, int size, void *object); int main() { printf("enter the number of bytes you want to allocate//&gt;\n"); int x; int y; Pool* p; scanf("%d", &amp;x); printf("enter the number of bytes you want to allocate//&gt;\n"); scanf("%d", &amp;x); p=allocatePool(x,y); return 0; } Pool* allocatePool(int x,int y) { static Pool p; static Pool p2; p.size = x; p2.size=y; p.memory = malloc(x); p2.memory = malloc(y); printf("%p\n", &amp;p); printf("%p\n", &amp;p2); return &amp;p;//return the adress of the Pool } </code></pre>
0debug
Reactive Angular form to wait for async validator complete on submit : <p>I am building a reactive angular form and I'm trying to find a way to trigger all validators on submit. If the validor is a sync one, it'd be ok, as I can get the status of it inline. Otherwise, if the validator is an async one and it was not triggered yet, the form on <code>ngSubmit</code> method would be in pending status. I've tried to register a subscribe for the form <code>statusChange</code> property, but it's not triggered when I call for validation manualy with <code>markAsTouched</code> function.</p> <p>Here's some snippets:</p> <pre><code> //initialization of form and watching for statusChanges ngOnInit() { this.ctrlForm = new FormGroup({ 'nome': new FormControl('', Validators.required), 'razao_social': new FormControl('', [], CustomValidators.uniqueName), 'cnpj': new FormControl('', CustomValidators.cnpj), }); this.ctrlForm.statusChanges.subscribe( x =&gt; console.log('Observer got a next value: ' + x), err =&gt; console.error('Observer got an error: ' + err), () =&gt; console.log('Observer got a complete notification') ) } //called on ngSubmit register(ctrlForm: NgForm) { Forms.validateAllFormFields(this.ctrlForm); console.log(ctrlForm.pending); //above will be true if the async validator //CustomValidators.uniqueName was not called during form fill. } //iterates on controls and call markAsTouched for validation, //which doesn't fire statusChanges validateAllFormFields(formGroup: FormGroup) { Object.keys(formGroup.controls).forEach(field =&gt; { const control = formGroup.get(field); if (control instanceof FormControl) { control.markAsTouched({ onlySelf: true }); } else if (control instanceof FormGroup) { this.validateAllFormFields(control); } }); } </code></pre> <p>Any ideas on how can I ensure that the async validator was executed so I can continue with the register logic having all validators triggered and completed?</p>
0debug
void framebuffer_update_display( DisplaySurface *ds, MemoryRegion *address_space, hwaddr base, int cols, int rows, int src_width, int dest_row_pitch, int dest_col_pitch, int invalidate, drawfn fn, void *opaque, int *first_row, int *last_row ) { hwaddr src_len; uint8_t *dest; uint8_t *src; uint8_t *src_base; int first, last = 0; int dirty; int i; ram_addr_t addr; MemoryRegionSection mem_section; MemoryRegion *mem; i = *first_row; *first_row = -1; src_len = src_width * rows; mem_section = memory_region_find(address_space, base, src_len); if (int128_get64(mem_section.size) != src_len || !memory_region_is_ram(mem_section.mr)) { return; } mem = mem_section.mr; assert(mem); assert(mem_section.offset_within_address_space == base); memory_region_sync_dirty_bitmap(mem); src_base = cpu_physical_memory_map(base, &src_len, 0); if (!src_base) return; if (src_len != src_width * rows) { cpu_physical_memory_unmap(src_base, src_len, 0, 0); return; } src = src_base; dest = surface_data(ds); if (dest_col_pitch < 0) dest -= dest_col_pitch * (cols - 1); if (dest_row_pitch < 0) { dest -= dest_row_pitch * (rows - 1); } first = -1; addr = mem_section.offset_within_region; addr += i * src_width; src += i * src_width; dest += i * dest_row_pitch; for (; i < rows; i++) { dirty = memory_region_get_dirty(mem, addr, src_width, DIRTY_MEMORY_VGA); if (dirty || invalidate) { fn(opaque, dest, src, cols, dest_col_pitch); if (first == -1) first = i; last = i; } addr += src_width; src += src_width; dest += dest_row_pitch; } cpu_physical_memory_unmap(src_base, src_len, 0, 0); if (first < 0) { return; } memory_region_reset_dirty(mem, mem_section.offset_within_region, src_len, DIRTY_MEMORY_VGA); *first_row = first; *last_row = last; }
1threat
void pc_basic_device_init(qemu_irq *isa_irq, ISADevice **rtc_state) { int i; DriveInfo *fd[MAX_FD]; PITState *pit; qemu_irq rtc_irq = NULL; qemu_irq *a20_line; ISADevice *i8042, *port92, *vmmouse; qemu_irq *cpu_exit_irq; register_ioport_write(0x80, 1, 1, ioport80_write, NULL); register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL); if (!no_hpet) { DeviceState *hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL); if (hpet) { for (i = 0; i < 24; i++) { sysbus_connect_irq(sysbus_from_qdev(hpet), i, isa_irq[i]); } rtc_irq = qdev_get_gpio_in(hpet, 0); } } *rtc_state = rtc_init(2000, rtc_irq); qemu_register_boot_set(pc_boot_set, *rtc_state); pit = pit_init(0x40, isa_reserve_irq(0)); pcspk_init(pit); for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { serial_isa_init(i, serial_hds[i]); } } for(i = 0; i < MAX_PARALLEL_PORTS; i++) { if (parallel_hds[i]) { parallel_init(i, parallel_hds[i]); } } a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2); i8042 = isa_create_simple("i8042"); i8042_setup_a20_line(i8042, &a20_line[0]); vmport_init(); vmmouse = isa_try_create("vmmouse"); if (vmmouse) { qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042); } port92 = isa_create_simple("port92"); port92_init(port92, &a20_line[1]); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } fdctrl_init_isa(fd); }
1threat
how to get specific day from date by user input in Phyton? : example a user input a date in my command prompt 21 October 2013 and it will come out in Monday I have tried to use import datetime but didn't work as intended another example i input 15 April 2011 and i get Friday
0debug
split students by success : <p>i have 5 region that students wants to go. Every region has quota. For example </p> <ul> <li>region A has 3 </li> <li>region B has 2 </li> <li>region C has 1 </li> <li>region D has 2 </li> <li>region E has 1</li> </ul> <p>And i have 9 students. (total quota and student number is same ) and student list is ordered by their success. My problem is i will send students to region with order like first student needs to go A if quote is not full second will go to B if quote is not full</p> <p>For the example above i need a string like; A,B,C,D,E,A,B,D,A This means</p> <ul> <li>1st, 5th and 9th student will go region A</li> <li>2,7 -> B</li> <li>c -> C</li> <li>4,8 -> D</li> <li>5 -> E</li> </ul> <p>i did already an algorithm for this but it works really slow for 100k student.</p> <pre><code>public String split(int quotoA, int quotoB, int quotoC, int quotoD, int quotoE) { boolean AdidNotGetYet = true, BdidNotGetYet = true, CdidNotGetYet = true, DdidNotGetYet = true, EdidNotGetYet = true; StringBuffer list = new StringBuffer(); while (true) { if (quotoA &gt; 0 &amp;&amp; AdidNotGetYet) { list.append(",A"); AdidNotGetYet = false; quotoA--; } else if (quotoB &gt; 0 &amp;&amp; BdidNotGetYet) { list.append(",B"); BdidNotGetYet = false; quotoB--; } else if (quotoC &gt; 0 &amp;&amp; CdidNotGetYet) { list.append(",C"); CdidNotGetYet = false; quotoC--; } else if (quotoD &gt; 0 &amp;&amp; DdidNotGetYet) { list.append(",D"); DdidNotGetYet = false; quotoD--; } else if (quotoE &gt; 0 &amp;&amp; EdidNotGetYet) { list.append(",E"); EdidNotGetYet = false; quotoE--; } else { AdidNotGetYet = true; BdidNotGetYet = true; CdidNotGetYet = true; DdidNotGetYet = true; EdidNotGetYet = true; } if (quotoA == 0 &amp;&amp; quotoB == 0 &amp;&amp; quotoC == 0 &amp;&amp; quotoD == 0 &amp;&amp; quotoE == 0) { break; } } list.deleteCharAt(0); return list.toString(); } </code></pre>
0debug
static void term_backward_char(void) { if (term_cmd_buf_index > 0) { term_cmd_buf_index--; } }
1threat
how do i check if the session is going to expire in php : <p>I have a usecase that i want to check if the session is going to expire in 30 sec or 60 sec. if so I should be able to extend the session. I am fine with any solutions with session or cookies. How do I acomplish that. Pls eloborate your solution. But I should know before the session expires.</p>
0debug
How do I install Composer PHP packages without Composer? : <p>I'm trying to install the Coinbase PHP API but it requires Composer:</p> <p><a href="https://github.com/coinbase/coinbase-php" rel="noreferrer">https://github.com/coinbase/coinbase-php</a></p> <p>I'm looking for a universal PHP solution (perhaps a function) to let me install composer packages directly onto my server, without having to use Composer.</p> <p>I think the developers of Composer believe they are helping people, but actually there are thousands of beginner developers that are being locked out of learning web development by the 'Composer barrier'.</p> <p>It would really help if there was a flexible solution or some approach where we could install without Composer? How can I do this?</p> <p><strong>Please don't respond with some sarcastic comment</strong>. There are people that don't want to use Composer and I don't see why we should be herded into a specific third-party software in order to do web development.</p>
0debug
document.getElementById('input').innerHTML = user_input;
1threat
document.write('<script src="evil.js"></script>');
1threat
What is the equivalent of EEDATA from BASIC and EWrite in C language : I am having a very hard time figuring out how I can use EEDATA = 0xFF, 0x00, 0xFF, 0x00, 0x01, 0x03 ; and turn that into C code. From what I can understand, it's a way of allocating memory in BASIC but I really do not know. If anyone out there could help I would much appreciate it. Thanks
0debug
Why does using std::move on a unique_ptr destroy it? : <p>So my understanding of move semantics is that this code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;memory&gt; class hello { public: ~hello() { std::cout &lt;&lt; "destroyed" &lt;&lt; std::endl; } hello() { std::cout &lt;&lt; "constructred" &lt;&lt; std::endl; } }; void takecontrol(std::unique_ptr&lt;hello&gt;&amp;&amp; ptr) { ptr.release(); } int main() { auto ptr = std::make_unique&lt;hello&gt;(); } </code></pre> <p>should create a memory leak and only print "constructed."</p> <p>yet when run (<a href="http://cpp.sh/2upqq" rel="nofollow noreferrer">http://cpp.sh/2upqq</a>) it destroys the object!</p> <p>To me it seems it should be moved into <code>ptr</code> in <code>takecontrol</code> then released then not deleted so it shouldn't ever be destroyed.</p> <p>What am I missing?</p>
0debug
Is the 'volatile' keyword still broken in C#? : <p>Joe Albahari has a <a href="http://www.albahari.com/threading/" rel="noreferrer">great series</a> on multithreading that's a must read and should be known by heart for anyone doing C# multithreading.</p> <p>In part 4 however he mentions the problems with volatile:</p> <blockquote> <p>Notice that applying volatile doesn’t prevent a write followed by a read from being swapped, and this can create brainteasers. Joe Duffy illustrates the problem well with the following example: if Test1 and Test2 run simultaneously on different threads, it’s possible for a and b to both end up with a value of 0 (despite the use of volatile on both x and y)</p> </blockquote> <p>Followed by a note that the MSDN documentation is incorrect:</p> <blockquote> <p>The MSDN documentation states that use of the volatile keyword ensures that the most up-to-date value is present in the field at all times. This is incorrect, since as we’ve seen, a write followed by a read can be reordered.</p> </blockquote> <p>I've checked the <a href="https://msdn.microsoft.com/en-us/library/x13ttww7.aspx" rel="noreferrer">MSDN documentation</a>, which was last changed in 2015 but still lists:</p> <blockquote> <p>The volatile keyword indicates that a field might be modified by multiple threads that are executing at the same time. Fields that are declared volatile are not subject to compiler optimizations that assume access by a single thread. <strong>This ensures that the most up-to-date value is present in the field at all times</strong>.</p> </blockquote> <p>Right now I still avoid volatile in favor of the more verbose to prevent threads using stale data:</p> <pre><code>private int foo; private object fooLock = new object(); public int Foo { get { lock(fooLock) return foo; } set { lock(fooLock) foo = value; } } </code></pre> <p>As the parts about multithreading were written in 2011, is the argument still valid today? Should volatile still be avoided at all costs in favor of locks or full memory fences to prevent introducing very hard to produce bugs that as mentioned are even dependent on the CPU vendor it's running on?</p>
0debug
Initiate Codable Model Class in swift : <p>Is it possible to initiate object which is codable. So that I can add values into variables.</p> <p>Ex: let obj = MyClass() for NSObject class. Something like this.</p> <p>Please help me.</p> <p>Thanks in advance.</p>
0debug
How to add/remove properties to object in runtime in javascript : <p>I would like to know how to add/ remove properties to object at run time in javascript? How to achieve this in javascript ?</p>
0debug
Error in converting varchar to float in mssql server 2012 : I have imported large excel sheet in my sql db and all columns are by default varchar datatype. I want to select sale volume in float(double) which is in varchar format. My query is like this but i still get converting error. How can I overcome this conversion error? select [CompanyCode] as 'Company Code', [Sitecode] as 'Site Code', [Product] as 'Product Name', '' as 'Tank ID', CONVERT(date, [InvDay]) as Date, CAST([Sales] as decimal) as 'Sale Volume', '' as 'Record ID' From [dbo].[2019-01]
0debug
static inline int get_ue_code(GetBitContext *gb, int order) { if (order) { int ret = get_ue_golomb(gb) << order; return ret + get_bits(gb, order); } return get_ue_golomb(gb); }
1threat
JavaScript - For loop not working : <p>so i have this code where i pass two arrays to the function "addPlayers" and in the funcion i loop trough the arrays to make a string, but the second loop does not wants to work. Here is the code:</p> <pre><code>$("#btnSend").on("click", function(){ var mPlayers = $("#txtJugadores").val().split("/"); var mRoles = $("#txtRoles").val().split("/"); /*here i call the function with the two arrays*/ addPlayers(mPlayers,mRoles); /*Here a console.log prints that mPlayer is an array with 2 numbers and that mRoles is an array with 2 numbers wich is good*/ }); function addPlayers(players, roles){ var players_list = ""; /*this loops works fine*/ for (var i = 0; i &lt; players.length; i++) { players_list = players_list + players[i] + "/"; } var roles_list = "asd"; /*but this loop don't*/ for (var n = 0; n &lt; roles.lenght; n++) { roles_list = roles_list + roles[n] + "/"; } console.log(players_list); /*here the console prints the string with the two numbers plus the */ console.log(roles_list);/*but here the console prints "asd" */ } </code></pre> <p>The second loop should work like this first one but it doesn't.</p>
0debug
How do I put the result of call into a varible? : I'm trying to use another batch file (called uppercase.bat) to convert an existing string to uppercase. @ECHO off set /p TitleID=Enter the ID of the title you want to download. set /p GameName=What is the name of the game you are trying to download? :Execute java -jar JNUSTool.jar %TitleID% -dlEncrypted pause :Change_to_uppercase call %~dp0\uppercase.bat %TitleID% :Rename echo Renaming to %GameName%... rename "%~dp0temp_%UpperTitleID%" "%~dp0%GameName%" pause
0debug
Java - best merging tool for multiple project in svn : <p>I have a svn branch which holds multiple projects. I want to merge specific revisions of the branch to trunk. What is the best program to do this with? It has to show me the dif and let me resolve any conflicts if there are any. I usually use eclipse but i dont think eclipse supports mergeing a revision of a branch into multiple projects? Are there any alternatives?</p>
0debug
static int check_strtox_error(const char **next, char *endptr, int err) { if (!next && *endptr) { return -EINVAL; } if (next) { *next = endptr; } return -err; }
1threat
Asp message box with yesno buttons with close button enabled at the top right of the message box : I have asp .net web site in where I created one message box show using dialog result class with yesnocancel buttons but i want only yes no buttons message box but with close button enabled to the top right of the message box without cancel button.With yesno message box it displays only yes no buttons with close button disabled at the top right of the message box.Could it be possible?
0debug
Concatinating stream in it's own forEach loop : Example 1: public TailCall<TestClass> useOfStream(Stream<Test> streamL) { ArrayList<Test> testList2 = new ArrayList<>(); Stream<Test> streamL2 = testList2.stream(); streamL.forEach(test -> { for (int i = 1; i < 14; i++) { if (/*insert if statement*/) { Test test2 = new Test(); Stream<Test> streamT = stream.Of(test2); **streamL2.concat(streamL2, streamT);** } else { //do something with TestClass } } }); if (streamL2.findAny().isPresent()) { return call(() -> useOfStream(streamL2)); } else { return TailCalls.done(TestClass); } } So, for a certain element in streamL I can possibly make up to 13 same-class elements. These newly made elements (that I've added to streamL2) should be iterated over the same way streamL was iterated over. Is there a possibility of adding those new elements to streamL? Doing: streamL.forEach(test -> { for (int i = 1; i < 14; i++) { if (/*insert if statement*/) { Test test2 = new Test(); Stream<Test> streamT = stream.Of(test2); **streamL.concat(streamL, streamT);** } else { //do something with TestClass } } }); If it's even possible to concat a stream within it's own for-Each loop, would the forEach loop also go through those newly added elements? That would eliminate my need of a recursive method. Another question is, will an object made within a stream (for ex. `Test test2 = new Test();` in the forEach loop of streamL) be processed lazily by the program? With other words, would this object take any place in the memory heap? (but this question is not that important, primarly my first question)
0debug
static int nsv_probe(AVProbeData *p) { int i; av_dlog(NULL, "nsv_probe(), buf_size %d\n", p->buf_size); if (p->buf[0] == 'N' && p->buf[1] == 'S' && p->buf[2] == 'V' && (p->buf[3] == 'f' || p->buf[3] == 's')) return AVPROBE_SCORE_MAX; for (i = 1; i < p->buf_size - 3; i++) { if (p->buf[i+0] == 'N' && p->buf[i+1] == 'S' && p->buf[i+2] == 'V' && p->buf[i+3] == 's') return AVPROBE_SCORE_MAX-20; } if (av_match_ext(p->filename, "nsv")) return AVPROBE_SCORE_MAX/2; return 0; }
1threat
uint32_t HELPER(csst)(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2) { #if !defined(CONFIG_USER_ONLY) || defined(CONFIG_ATOMIC128) uint32_t mem_idx = cpu_mmu_index(env, false); #endif uintptr_t ra = GETPC(); uint32_t fc = extract32(env->regs[0], 0, 8); uint32_t sc = extract32(env->regs[0], 8, 8); uint64_t pl = get_address(env, 1) & -16; uint64_t svh, svl; uint32_t cc; if (fc > 1 || sc > 3) { if (!s390_has_feat(S390_FEAT_COMPARE_AND_SWAP_AND_STORE_2)) { goto spec_exception; } if (fc > 2 || sc > 4 || (fc == 2 && (r3 & 1))) { goto spec_exception; } } if (extract32(a1, 0, 4 << fc) || extract32(a2, 0, 1 << sc)) { goto spec_exception; } #ifndef CONFIG_USER_ONLY probe_write(env, a2, mem_idx, ra); #endif if (parallel_cpus) { int mask = 0; #if !defined(CONFIG_ATOMIC64) mask = -8; #elif !defined(CONFIG_ATOMIC128) mask = -16; #endif if (((4 << fc) | (1 << sc)) & mask) { cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } } svh = cpu_ldq_data_ra(env, pl + 16, ra); svl = cpu_ldq_data_ra(env, pl + 24, ra); switch (fc) { case 0: { uint32_t nv = cpu_ldl_data_ra(env, pl, ra); uint32_t cv = env->regs[r3]; uint32_t ov; if (parallel_cpus) { #ifdef CONFIG_USER_ONLY uint32_t *haddr = g2h(a1); ov = atomic_cmpxchg__nocheck(haddr, cv, nv); #else TCGMemOpIdx oi = make_memop_idx(MO_TEUL | MO_ALIGN, mem_idx); ov = helper_atomic_cmpxchgl_be_mmu(env, a1, cv, nv, oi, ra); #endif } else { ov = cpu_ldl_data_ra(env, a1, ra); cpu_stl_data_ra(env, a1, (ov == cv ? nv : ov), ra); } cc = (ov != cv); env->regs[r3] = deposit64(env->regs[r3], 32, 32, ov); } break; case 1: { uint64_t nv = cpu_ldq_data_ra(env, pl, ra); uint64_t cv = env->regs[r3]; uint64_t ov; if (parallel_cpus) { #ifdef CONFIG_ATOMIC64 # ifdef CONFIG_USER_ONLY uint64_t *haddr = g2h(a1); ov = atomic_cmpxchg__nocheck(haddr, cv, nv); # else TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN, mem_idx); ov = helper_atomic_cmpxchgq_be_mmu(env, a1, cv, nv, oi, ra); # endif #else g_assert_not_reached(); #endif } else { ov = cpu_ldq_data_ra(env, a1, ra); cpu_stq_data_ra(env, a1, (ov == cv ? nv : ov), ra); } cc = (ov != cv); env->regs[r3] = ov; } break; case 2: { uint64_t nvh = cpu_ldq_data_ra(env, pl, ra); uint64_t nvl = cpu_ldq_data_ra(env, pl + 8, ra); Int128 nv = int128_make128(nvl, nvh); Int128 cv = int128_make128(env->regs[r3 + 1], env->regs[r3]); Int128 ov; if (parallel_cpus) { #ifdef CONFIG_ATOMIC128 TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); ov = helper_atomic_cmpxchgo_be_mmu(env, a1, cv, nv, oi, ra); cc = !int128_eq(ov, cv); #else g_assert_not_reached(); #endif } else { uint64_t oh = cpu_ldq_data_ra(env, a1 + 0, ra); uint64_t ol = cpu_ldq_data_ra(env, a1 + 8, ra); ov = int128_make128(ol, oh); cc = !int128_eq(ov, cv); if (cc) { nv = ov; } cpu_stq_data_ra(env, a1 + 0, int128_gethi(nv), ra); cpu_stq_data_ra(env, a1 + 8, int128_getlo(nv), ra); } env->regs[r3 + 0] = int128_gethi(ov); env->regs[r3 + 1] = int128_getlo(ov); } break; default: g_assert_not_reached(); } if (cc == 0) { switch (sc) { case 0: cpu_stb_data_ra(env, a2, svh >> 56, ra); break; case 1: cpu_stw_data_ra(env, a2, svh >> 48, ra); break; case 2: cpu_stl_data_ra(env, a2, svh >> 32, ra); break; case 3: cpu_stq_data_ra(env, a2, svh, ra); break; case 4: if (parallel_cpus) { #ifdef CONFIG_ATOMIC128 TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 sv = int128_make128(svl, svh); helper_atomic_sto_be_mmu(env, a2, sv, oi, ra); #else g_assert_not_reached(); #endif } else { cpu_stq_data_ra(env, a2 + 0, svh, ra); cpu_stq_data_ra(env, a2 + 8, svl, ra); } break; default: g_assert_not_reached(); } } return cc; spec_exception: cpu_restore_state(ENV_GET_CPU(env), ra); program_interrupt(env, PGM_SPECIFICATION, 6); g_assert_not_reached(); }
1threat
ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size) { VocDecContext *voc = s->priv_data; AVCodecParameters *par = st->codecpar; AVIOContext *pb = s->pb; VocType type; int size, tmp_codec=-1; int sample_rate = 0; int channels = 1; int64_t duration; int ret; av_add_index_entry(st, avio_tell(pb), voc->pts, voc->remaining_size, 0, AVINDEX_KEYFRAME); while (!voc->remaining_size) { type = avio_r8(pb); if (type == VOC_TYPE_EOF) return AVERROR_EOF; voc->remaining_size = avio_rl24(pb); if (!voc->remaining_size) { if (!s->pb->seekable) return AVERROR(EIO); voc->remaining_size = avio_size(pb) - avio_tell(pb); } max_size -= 4; switch (type) { case VOC_TYPE_VOICE_DATA: if (!par->sample_rate) { par->sample_rate = 1000000 / (256 - avio_r8(pb)); if (sample_rate) par->sample_rate = sample_rate; avpriv_set_pts_info(st, 64, 1, par->sample_rate); par->channels = channels; par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id); } else avio_skip(pb, 1); tmp_codec = avio_r8(pb); voc->remaining_size -= 2; max_size -= 2; channels = 1; break; case VOC_TYPE_VOICE_DATA_CONT: break; case VOC_TYPE_EXTENDED: sample_rate = avio_rl16(pb); avio_r8(pb); channels = avio_r8(pb) + 1; sample_rate = 256000000 / (channels * (65536 - sample_rate)); voc->remaining_size = 0; max_size -= 4; break; case VOC_TYPE_NEW_VOICE_DATA: if (!par->sample_rate) { par->sample_rate = avio_rl32(pb); avpriv_set_pts_info(st, 64, 1, par->sample_rate); par->bits_per_coded_sample = avio_r8(pb); par->channels = avio_r8(pb); } else avio_skip(pb, 6); tmp_codec = avio_rl16(pb); avio_skip(pb, 4); voc->remaining_size -= 12; max_size -= 12; break; default: avio_skip(pb, voc->remaining_size); max_size -= voc->remaining_size; voc->remaining_size = 0; break; } } if (par->sample_rate <= 0) { av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", par->sample_rate); return AVERROR_INVALIDDATA; } if (tmp_codec >= 0) { tmp_codec = ff_codec_get_id(ff_voc_codec_tags, tmp_codec); if (par->codec_id == AV_CODEC_ID_NONE) par->codec_id = tmp_codec; else if (par->codec_id != tmp_codec) av_log(s, AV_LOG_WARNING, "Ignoring mid-stream change in audio codec\n"); if (par->codec_id == AV_CODEC_ID_NONE) { if (s->audio_codec_id == AV_CODEC_ID_NONE) { av_log(s, AV_LOG_ERROR, "unknown codec tag\n"); return AVERROR(EINVAL); } av_log(s, AV_LOG_WARNING, "unknown codec tag\n"); } } par->bit_rate = par->sample_rate * par->channels * par->bits_per_coded_sample; if (max_size <= 0) max_size = 2048; size = FFMIN(voc->remaining_size, max_size); voc->remaining_size -= size; ret = av_get_packet(pb, pkt, size); pkt->dts = pkt->pts = voc->pts; duration = av_get_audio_frame_duration2(st->codecpar, size); if (duration > 0 && voc->pts != AV_NOPTS_VALUE) voc->pts += duration; else voc->pts = AV_NOPTS_VALUE; return ret; }
1threat
How to tie emitted events events into redux-saga? : <p>I'm trying to use <a href="https://github.com/yelouafi/redux-saga">redux-saga</a> to connect events from <a href="http://pouchdb.com/api.html#replication">PouchDB</a> to my <a href="http://reactjs.com/">React.js</a> application, but I'm struggling to figure out how to connect events emitted from PouchDB to my Saga. Since the event uses a callback function (and I can't pass it a generator), I can't use <code>yield put()</code> inside the callback, it gives weird errors after ES2015 compilation (using Webpack).</p> <p>So here's what I'm trying to accomplish, the part that doesn't work is inside <code>replication.on('change' (info) =&gt; {})</code>.</p> <pre><code>function * startReplication (wrapper) { while (yield take(DATABASE_SET_CONFIGURATION)) { yield call(wrapper.connect.bind(wrapper)) // Returns a promise, or false. let replication = wrapper.replicate() if (replication) { replication.on('change', (info) =&gt; { yield put(replicationChange(info)) }) } } } export default [ startReplication ] </code></pre>
0debug
"if" multiple conditions in javascript : <p>I'm new to javascript and I'd just like a simple explanation of how to use "if" with multiple conditions in javascript.</p> <p>I've seen stuff like this: if (condition1 &amp;&amp; condition2) and if (condition1) || (condition2)</p> <p>To my understanding, &amp;&amp; is basically "and", and || is basically "or". Please correct me if I'm wrong.</p> <p>But would you use these if you wanted to test more than 2 conditions? And are there any other marks besides &amp;&amp; and || ? Also, if you were to have a much larger list of conditions. Let's say 10 or 20, then is there a better/proper way to test them other than sticking them all in if() seperated by &amp;&amp; and || ?</p>
0debug
int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2) { CPUS390XState *env = &cpu->env; uint32_t fh; S390PCIBusDevice *pbdev; S390PCIIOMMU *iommu; hwaddr start, end; IOMMUTLBEntry entry; MemoryRegion *mr; cpu_synchronize_state(CPU(cpu)); if (env->psw.mask & PSW_MASK_PSTATE) { program_interrupt(env, PGM_PRIVILEGED, 4); goto out; } if (r2 & 0x1) { program_interrupt(env, PGM_SPECIFICATION, 4); goto out; } fh = env->regs[r1] >> 32; start = env->regs[r2]; end = start + env->regs[r2 + 1]; pbdev = s390_pci_find_dev_by_fh(s390_get_phb(), fh); if (!pbdev) { DPRINTF("rpcit no pci dev\n"); setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE); goto out; } switch (pbdev->state) { case ZPCI_FS_RESERVED: case ZPCI_FS_STANDBY: case ZPCI_FS_DISABLED: case ZPCI_FS_PERMANENT_ERROR: setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE); return 0; case ZPCI_FS_ERROR: setcc(cpu, ZPCI_PCI_LS_ERR); s390_set_status_code(env, r1, ZPCI_MOD_ST_ERROR_RECOVER); return 0; default: break; } iommu = pbdev->iommu; if (!iommu->g_iota) { pbdev->state = ZPCI_FS_ERROR; setcc(cpu, ZPCI_PCI_LS_ERR); s390_set_status_code(env, r1, ZPCI_PCI_ST_INSUF_RES); s390_pci_generate_error_event(ERR_EVENT_INVALAS, pbdev->fh, pbdev->fid, start, 0); goto out; } if (end < iommu->pba || start > iommu->pal) { pbdev->state = ZPCI_FS_ERROR; setcc(cpu, ZPCI_PCI_LS_ERR); s390_set_status_code(env, r1, ZPCI_PCI_ST_INSUF_RES); s390_pci_generate_error_event(ERR_EVENT_OORANGE, pbdev->fh, pbdev->fid, start, 0); goto out; } mr = &iommu->iommu_mr; while (start < end) { entry = mr->iommu_ops->translate(mr, start, 0); if (!entry.translated_addr) { pbdev->state = ZPCI_FS_ERROR; setcc(cpu, ZPCI_PCI_LS_ERR); s390_set_status_code(env, r1, ZPCI_PCI_ST_INSUF_RES); s390_pci_generate_error_event(ERR_EVENT_SERR, pbdev->fh, pbdev->fid, start, ERR_EVENT_Q_BIT); goto out; } memory_region_notify_iommu(mr, entry); start += entry.addr_mask + 1; } setcc(cpu, ZPCI_PCI_LS_OK); out: return 0; }
1threat
Coloring mesh edges in meshlab : <p>I have been working on an algorithm that takes a mesh, does some fancy things with it, and produces some output.</p> <p>To visualize the result I decided to produce a copy of the mesh, colour it in a smart way that is somehow related to the produced output, and visualize it with Meshlab. However, I need to color <em>some</em> of the edges of the mesh differently from others.</p> <p>After googling for several hours, I haven't been able to find a way to do this, even though the file formats (.obj, .ply ...) seem to support this behaviour, as suggested by <a href="http://paulbourke.net/dataformats/ply/" rel="noreferrer">this tutorial</a> (which I followed to produce the output mesh).</p> <p>I have produced a work around, which is, to each vertex I assign the colour of one of the edges it is adjacent to, and then I just colour the edges based on the vertex colour, but unfortunately, this means that (for example) edges that are of two different colours will be rendered with a gradient from one colour to the other, which is not the intended behaviour.</p> <p>Am I doing something wrong here? (Like ignoring some patently obvious option). Or alternatively, is there an alternate way of rendering the mesh that would allow one to colour edges (that wouldn't imply coding one's own renderer or spending 3 days scouring through blender's manual looking for the right key combination)?</p> <p>Any help would be very welcome. Thanks in advance.</p>
0debug
xmit_seg(E1000State *s) { uint16_t len, *sp; unsigned int frames = s->tx.tso_frames, css, sofar, n; struct e1000_tx *tp = &s->tx; if (tp->tse && tp->cptse) { css = tp->ipcss; DBGOUT(TXSUM, "frames %d size %d ipcss %d\n", frames, tp->size, css); if (tp->ip) { cpu_to_be16wu((uint16_t *)(tp->data+css+2), tp->size - css); cpu_to_be16wu((uint16_t *)(tp->data+css+4), be16_to_cpup((uint16_t *)(tp->data+css+4))+frames); } else cpu_to_be16wu((uint16_t *)(tp->data+css+4), tp->size - css); css = tp->tucss; len = tp->size - css; DBGOUT(TXSUM, "tcp %d tucss %d len %d\n", tp->tcp, css, len); if (tp->tcp) { sofar = frames * tp->mss; cpu_to_be32wu((uint32_t *)(tp->data+css+4), be32_to_cpupu((uint32_t *)(tp->data+css+4))+sofar); if (tp->paylen - sofar > tp->mss) tp->data[css + 13] &= ~9; } else cpu_to_be16wu((uint16_t *)(tp->data+css+4), len); if (tp->sum_needed & E1000_TXD_POPTS_TXSM) { sp = (uint16_t *)(tp->data + tp->tucso); cpu_to_be16wu(sp, be16_to_cpup(sp) + len); } tp->tso_frames++; } if (tp->sum_needed & E1000_TXD_POPTS_TXSM) putsum(tp->data, tp->size, tp->tucso, tp->tucss, tp->tucse); if (tp->sum_needed & E1000_TXD_POPTS_IXSM) putsum(tp->data, tp->size, tp->ipcso, tp->ipcss, tp->ipcse); if (tp->vlan_needed) { memmove(tp->vlan, tp->data, 4); memmove(tp->data, tp->data + 4, 8); memcpy(tp->data + 8, tp->vlan_header, 4); qemu_send_packet(&s->nic->nc, tp->vlan, tp->size + 4); } else qemu_send_packet(&s->nic->nc, tp->data, tp->size); s->mac_reg[TPT]++; s->mac_reg[GPTC]++; n = s->mac_reg[TOTL]; if ((s->mac_reg[TOTL] += s->tx.size) < n) s->mac_reg[TOTH]++; }
1threat
writing the data in text file while converting it to csv with python : I am very new withh python. I have a .txt file and want to convert it to a .csv file with the format i was told but could not manage to accomplish. a hand can be useful for it. i am going to explain it with screenshots. [I have a txt file with the name of bip.txt. and the data inside of it is:][1] [and i want to convert it to csv like this csv file:][2] [1]: http://i.stack.imgur.com/NNHH8.png [2]: http://i.stack.imgur.com/jDKqF.png so far, what i could do is only writing all the data from text file with this code: read_files = glob.glob("C:/Users/Emrehana1/Desktop/bip.txt") with open("C:/Users/Emrehana1/Desktop/Test_Result_Report.csv", "w") as outfile: for f in read_files: with open(f, "r") as infile: outfile.write(infile.read()) so is there a solution to convert it to a csv file in the format i desire? I hope i could have explained it clearly.
0debug
static int transcode_init(void) { int ret = 0, i, j, k; AVFormatContext *oc; AVCodecContext *codec, *icodec; OutputStream *ost; InputStream *ist; char error[1024]; int want_sdp = 1; for (i = 0; i < nb_input_files; i++) { InputFile *ifile = input_files[i]; if (ifile->rate_emu) for (j = 0; j < ifile->nb_streams; j++) input_streams[j + ifile->ist_index]->start = av_gettime(); } for (i = 0; i < nb_output_files; i++) { oc = output_files[i]->ctx; if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) { av_dump_format(oc, i, oc->filename, 1); av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", i); return AVERROR(EINVAL); } } for (i = 0; i < nb_filtergraphs; i++) if ((ret = avfilter_graph_config(filtergraphs[i]->graph, NULL)) < 0) return ret; for (i = 0; i < nb_output_streams; i++) { ost = output_streams[i]; oc = output_files[ost->file_index]->ctx; ist = get_input_stream(ost); if (ost->attachment_filename) continue; codec = ost->st->codec; if (ist) { icodec = ist->st->codec; ost->st->disposition = ist->st->disposition; codec->bits_per_raw_sample = icodec->bits_per_raw_sample; codec->chroma_sample_location = icodec->chroma_sample_location; } if (ost->stream_copy) { uint64_t extra_size; av_assert0(ist && !ost->filter); extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) { return AVERROR(EINVAL); } codec->codec_id = icodec->codec_id; codec->codec_type = icodec->codec_type; if (!codec->codec_tag) { if (!oc->oformat->codec_tag || av_codec_get_id (oc->oformat->codec_tag, icodec->codec_tag) == codec->codec_id || av_codec_get_tag(oc->oformat->codec_tag, icodec->codec_id) <= 0) codec->codec_tag = icodec->codec_tag; } codec->bit_rate = icodec->bit_rate; codec->rc_max_rate = icodec->rc_max_rate; codec->rc_buffer_size = icodec->rc_buffer_size; codec->field_order = icodec->field_order; codec->extradata = av_mallocz(extra_size); if (!codec->extradata) { return AVERROR(ENOMEM); } memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size = icodec->extradata_size; if (!copy_tb) { codec->time_base = icodec->time_base; codec->time_base.num *= icodec->ticks_per_frame; av_reduce(&codec->time_base.num, &codec->time_base.den, codec->time_base.num, codec->time_base.den, INT_MAX); } else codec->time_base = ist->st->time_base; switch (codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if (audio_volume != 256) { av_log(NULL, AV_LOG_FATAL, "-acodec copy and -vol are incompatible (frames are not decoded)\n"); exit_program(1); } codec->channel_layout = icodec->channel_layout; codec->sample_rate = icodec->sample_rate; codec->channels = icodec->channels; codec->frame_size = icodec->frame_size; codec->audio_service_type = icodec->audio_service_type; codec->block_align = icodec->block_align; break; case AVMEDIA_TYPE_VIDEO: codec->pix_fmt = icodec->pix_fmt; codec->width = icodec->width; codec->height = icodec->height; codec->has_b_frames = icodec->has_b_frames; if (!codec->sample_aspect_ratio.num) { codec->sample_aspect_ratio = ost->st->sample_aspect_ratio = ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio : ist->st->codec->sample_aspect_ratio.num ? ist->st->codec->sample_aspect_ratio : (AVRational){0, 1}; } break; case AVMEDIA_TYPE_SUBTITLE: codec->width = icodec->width; codec->height = icodec->height; break; case AVMEDIA_TYPE_DATA: case AVMEDIA_TYPE_ATTACHMENT: break; default: abort(); } } else { if (!ost->enc) { snprintf(error, sizeof(error), "Automatic encoder selection " "failed for output stream #%d:%d. Default encoder for " "format %s is probably disabled. Please choose an " "encoder manually.\n", ost->file_index, ost->index, oc->oformat->name); ret = AVERROR(EINVAL); goto dump_format; } if (ist) ist->decoding_needed = 1; ost->encoding_needed = 1; switch (codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ost->fifo = av_fifo_alloc(1024); if (!ost->fifo) { return AVERROR(ENOMEM); } if (!codec->sample_rate) codec->sample_rate = icodec->sample_rate; choose_sample_rate(ost->st, ost->enc); codec->time_base = (AVRational){ 1, codec->sample_rate }; if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) codec->sample_fmt = icodec->sample_fmt; choose_sample_fmt(ost->st, ost->enc); if (!codec->channels) codec->channels = icodec->channels; if (!codec->channel_layout) codec->channel_layout = icodec->channel_layout; if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels) codec->channel_layout = 0; icodec->request_channels = codec-> channels; ost->resample_sample_fmt = icodec->sample_fmt; ost->resample_sample_rate = icodec->sample_rate; ost->resample_channels = icodec->channels; ost->resample_channel_layout = icodec->channel_layout; break; case AVMEDIA_TYPE_VIDEO: if (!ost->filter) { FilterGraph *fg; fg = init_simple_filtergraph(ist, ost); if (configure_video_filters(fg)) { av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n"); exit(1); } } if (!ost->frame_rate.num && ist && (video_sync_method == VSYNC_CFR || (video_sync_method == VSYNC_AUTO && !(oc->oformat->flags & (AVFMT_NOTIMESTAMPS | AVFMT_VARIABLE_FPS))))) { ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25, 1}; if (ost->enc && ost->enc->supported_framerates && !ost->force_fps) { int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); ost->frame_rate = ost->enc->supported_framerates[idx]; } } if (ost->frame_rate.num) { codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num}; video_sync_method = VSYNC_CFR; } else if (ist) codec->time_base = ist->st->time_base; else codec->time_base = ost->filter->filter->inputs[0]->time_base; codec->width = ost->filter->filter->inputs[0]->w; codec->height = ost->filter->filter->inputs[0]->h; codec->sample_aspect_ratio = ost->st->sample_aspect_ratio = ost->frame_aspect_ratio ? av_d2q(ost->frame_aspect_ratio * codec->height/codec->width, 255) : ost->filter->filter->inputs[0]->sample_aspect_ratio; codec->pix_fmt = ost->filter->filter->inputs[0]->format; if (codec->width != icodec->width || codec->height != icodec->height || codec->pix_fmt != icodec->pix_fmt) { codec->bits_per_raw_sample = 0; } break; case AVMEDIA_TYPE_SUBTITLE: codec->time_base = (AVRational){1, 1000}; break; default: abort(); break; } if ((codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char logfilename[1024]; FILE *f; snprintf(logfilename, sizeof(logfilename), "%s-%d.log", pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, i); if (!strcmp(ost->enc->name, "libx264")) { av_dict_set(&ost->opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE); } else { if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(logfilename, "wb"); if (!f) { av_log(NULL, AV_LOG_FATAL, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno)); exit_program(1); } ost->logfile = f; } else { char *logbuffer; size_t logbuffer_size; if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n", logfilename); exit_program(1); } codec->stats_in = logbuffer; } } } } } for (i = 0; i < nb_output_streams; i++) { ost = output_streams[i]; if (ost->encoding_needed) { AVCodec *codec = ost->enc; AVCodecContext *dec = NULL; if ((ist = get_input_stream(ost))) dec = ist->st->codec; if (dec && dec->subtitle_header) { ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size); if (!ost->st->codec->subtitle_header) { ret = AVERROR(ENOMEM); goto dump_format; } memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); ost->st->codec->subtitle_header_size = dec->subtitle_header_size; } if (!av_dict_get(ost->opts, "threads", NULL, 0)) av_dict_set(&ost->opts, "threads", "auto", 0); if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } assert_codec_experimental(ost->st->codec, 1); assert_avoptions(ost->opts); if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000) av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." "It takes bits/s as argument, not kbits/s\n"); extra_size += ost->st->codec->extradata_size; if (ost->st->codec->me_threshold) input_streams[ost->source_index]->st->codec->debug |= FF_DEBUG_MV; } } for (i = 0; i < nb_input_streams; i++) if ((ret = init_input_stream(i, error, sizeof(error))) < 0) goto dump_format; for (i = 0; i < nb_input_files; i++) { InputFile *ifile = input_files[i]; for (j = 0; j < ifile->ctx->nb_programs; j++) { AVProgram *p = ifile->ctx->programs[j]; int discard = AVDISCARD_ALL; for (k = 0; k < p->nb_stream_indexes; k++) if (!input_streams[ifile->ist_index + p->stream_index[k]]->discard) { discard = AVDISCARD_DEFAULT; break; } p->discard = discard; } } for (i = 0; i < nb_output_files; i++) { oc = output_files[i]->ctx; oc->interrupt_callback = int_cb; if (avformat_write_header(oc, &output_files[i]->opts) < 0) { snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i); ret = AVERROR(EINVAL); goto dump_format; } assert_avoptions(output_files[i]->opts); if (strcmp(oc->oformat->name, "rtp")) { want_sdp = 0; } } dump_format: for (i = 0; i < nb_output_files; i++) { av_dump_format(output_files[i]->ctx, i, output_files[i]->ctx->filename, 1); } av_log(NULL, AV_LOG_INFO, "Stream mapping:\n"); for (i = 0; i < nb_input_streams; i++) { ist = input_streams[i]; for (j = 0; j < ist->nb_filters; j++) { AVFilterLink *link = ist->filters[j]->filter->outputs[0]; if (ist->filters[j]->graph->graph_desc) { av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s", ist->file_index, ist->st->index, ist->dec ? ist->dec->name : "?", link->dst->filter->name); if (link->dst->input_count > 1) av_log(NULL, AV_LOG_INFO, ":%s", link->dstpad->name); if (nb_filtergraphs > 1) av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index); av_log(NULL, AV_LOG_INFO, "\n"); } } } for (i = 0; i < nb_output_streams; i++) { ost = output_streams[i]; if (ost->attachment_filename) { av_log(NULL, AV_LOG_INFO, " File %s -> Stream #%d:%d\n", ost->attachment_filename, ost->file_index, ost->index); continue; } if (ost->filter && ost->filter->graph->graph_desc) { AVFilterLink *link = ost->filter->filter->inputs[0]; av_log(NULL, AV_LOG_INFO, " %s", link->src->filter->name); if (link->src->output_count > 1) av_log(NULL, AV_LOG_INFO, ":%s", link->srcpad->name); if (nb_filtergraphs > 1) av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index); av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file_index, ost->index, ost->enc ? ost->enc->name : "?"); continue; } av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d", input_streams[ost->source_index]->file_index, input_streams[ost->source_index]->st->index, ost->file_index, ost->index); if (ost->sync_ist != input_streams[ost->source_index]) av_log(NULL, AV_LOG_INFO, " [sync #%d:%d]", ost->sync_ist->file_index, ost->sync_ist->st->index); if (ost->stream_copy) av_log(NULL, AV_LOG_INFO, " (copy)"); else av_log(NULL, AV_LOG_INFO, " (%s -> %s)", input_streams[ost->source_index]->dec ? input_streams[ost->source_index]->dec->name : "?", ost->enc ? ost->enc->name : "?"); av_log(NULL, AV_LOG_INFO, "\n"); } if (ret) { av_log(NULL, AV_LOG_ERROR, "%s\n", error); return ret; } if (want_sdp) { print_sdp(); } return 0; }
1threat
Jquery Ajax method POST does not work on hosting : I've been working on a website for quite some time, but it was all done on localhost. After making login form work properly I decided to upload it to hosting. Issue is that callback functions of ajax don't seem to work if I use method: "POST". If I change POST to GET it will work... Ajax code: $.ajax({ method: 'POST', url: "php/login.php", data: { username: val_username, password: val_password }, success: function(response) { if (response == 0) { location.reload(); } else { alert("Wrong username or password. Error #"+response); } } }); login.php <?php session_start(); require "../php_includes/mysql.php"; // Create connection $conn = new mysqli($db_server, $db_user, $db_pass, $db_name); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // escape your parameters to prevent sql injection $username = mysqli_real_escape_string($conn, $_POST['username']); $password = mysqli_real_escape_string($conn, $_POST['password']); $sql = "SELECT * FROM korisnici WHERE username='$username'"; $sql_result = $conn->query($sql); if ($sql_result->num_rows > 0) { $row = $sql_result->fetch_assoc(); if (password_verify($password, $row["password"])) { $_SESSION["loggedin"] = true; $_SESSION["userid"] = $row["id"]; echo 0; } else echo 2; } else echo 1; ?> I have checked all the file locations, no issue there, since everything works if I change method to GET. I tried changing datatypes in ajax, tried adding some headers to php file that I've found searching around stackoverflow, but nothing helps...
0debug
How to disable NavigationView push and pop animations : <p>Given this simple <code>NavigationView</code>:</p> <pre class="lang-swift prettyprint-override"><code>struct ContentView : View { var body: some View { NavigationView { VStack { NavigationLink("Push Me", destination: Text("PUSHED VIEW")) } } } } </code></pre> <p>Did anyone find a way of disabling the <code>NavigationView</code> animation when a destination view is pushed/popped into/from the stack?</p> <p>This has been possible in UIKit since iOS2.0! I think it is not too much to ask from the framework. I tried all sorts of modifiers on all views (i.e., the <code>NavigationView</code> container, the destination view, the <code>NavigationLink</code>, etc)</p> <p>These are some of the modifiers I tried:</p> <pre class="lang-swift prettyprint-override"><code>.animation(nil) </code></pre> <pre class="lang-swift prettyprint-override"><code>.transition(.identity) </code></pre> <pre class="lang-swift prettyprint-override"><code>.transaction { t in t.disablesAnimations = true } </code></pre> <pre class="lang-swift prettyprint-override"><code>.transaction { t in t.animation = nil } </code></pre> <p>None made a difference. I did not find anything useful in the <code>EnvironmentValues</code> either :-(</p> <p>Am I missing something very obvious, or is the functionality just not there yet?</p>
0debug
Paid Application varification : I have an Already paid App in Playstore. then I want to check user already paid in play store or not. If the user installs apk from other Resource(like Bluetooth, Xender.etc) how to prevent those users who not paid or not Install From Playstore.
0debug
static void kvm_add_routing_entry(KVMState *s, struct kvm_irq_routing_entry *entry) { struct kvm_irq_routing_entry *new; int n, size; if (s->irq_routes->nr == s->nr_allocated_irq_routes) { n = s->nr_allocated_irq_routes * 2; if (n < 64) { n = 64; } size = sizeof(struct kvm_irq_routing); size += n * sizeof(*new); s->irq_routes = g_realloc(s->irq_routes, size); s->nr_allocated_irq_routes = n; } n = s->irq_routes->nr++; new = &s->irq_routes->entries[n]; memset(new, 0, sizeof(*new)); new->gsi = entry->gsi; new->type = entry->type; new->flags = entry->flags; new->u = entry->u; set_gsi(s, entry->gsi); }
1threat
unsigned avutil_version(void) { av_assert0(AV_PIX_FMT_VDA_VLD == 81); av_assert0(AV_SAMPLE_FMT_DBLP == 9); av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4); av_assert0(AV_PICTURE_TYPE_BI == 7); av_assert0(LIBAVUTIL_VERSION_MICRO >= 100); av_assert0(HAVE_MMX2 == HAVE_MMXEXT); if (av_sat_dadd32(1, 2) != 5) { av_log(NULL, AV_LOG_FATAL, "Libavutil has been build with a broken binutils, please upgrade binutils and rebuild\n"); abort(); } ff_check_pixfmt_descriptors(); return LIBAVUTIL_VERSION_INT; }
1threat
Android Studio SDK Manager : I've installed Android Studio along with sdk , but in sdk manager notifies that sdk has been **partially installed** and also some of the options in sdk like **(sdk tools and sdk updates sites tab are disabled)**. Also I'm not able to add previous or other sdk versions. Sdk Manager show the updates , but its disabled and thus not able to download and install them. Yes I've tried to run as admin , but it didn't helped
0debug
How can I click a checkbox and know if checked or not checked? : <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>$('.p_check').click(function() { if ($(this).is(':checked')) { alert("checked"); } else { alert("unchecked"); } });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;div class='checkbox p_check'&gt;&lt;label&gt;&lt;input type='checkbox'&gt;New Password&lt;/label&gt;&lt;/div&gt;</code></pre> </div> </div> </p> <p>My alert is always "unchecked", no matter if I check or uncheck it</p>
0debug