problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
int main(int argc, char **argv, char **envp)
{
const char *gdbstub_dev = NULL;
int i;
int snapshot, linux_boot;
const char *icount_option = NULL;
const char *initrd_filename;
const char *kernel_filename, *kernel_cmdline;
char boot_devices[33] = "cad";
DisplayState *ds;
DisplayChangeListener *dcl;
int cyls, heads, secs, translation;
QemuOpts *hda_opts = NULL, *opts;
QemuOptsList *olist;
int optind;
const char *optarg;
const char *loadvm = NULL;
QEMUMachine *machine;
const char *cpu_model;
const char *pid_file = NULL;
const char *incoming = NULL;
#ifdef CONFIG_VNC
int show_vnc_port = 0;
#endif
int defconfig = 1;
const char *log_mask = NULL;
const char *log_file = NULL;
GMemVTable mem_trace = {
.malloc = malloc_and_trace,
.realloc = realloc_and_trace,
.free = free_and_trace,
};
const char *trace_events = NULL;
const char *trace_file = NULL;
atexit(qemu_run_exit_notifiers);
error_set_progname(argv[0]);
g_mem_set_vtable(&mem_trace);
if (!g_thread_supported()) {
#if !GLIB_CHECK_VERSION(2, 31, 0)
g_thread_init(NULL);
#else
fprintf(stderr, "glib threading failed to initialize.\n");
exit(1);
#endif
}
runstate_init();
init_clocks();
rtc_clock = host_clock;
qemu_cache_utils_init(envp);
QLIST_INIT (&vm_change_state_head);
os_setup_early_signal_handling();
module_call_init(MODULE_INIT_MACHINE);
machine = find_default_machine();
cpu_model = NULL;
initrd_filename = NULL;
ram_size = 0;
snapshot = 0;
kernel_filename = NULL;
kernel_cmdline = "";
cyls = heads = secs = 0;
translation = BIOS_ATA_TRANSLATION_AUTO;
for (i = 0; i < MAX_NODES; i++) {
node_mem[i] = 0;
node_cpumask[i] = 0;
}
nb_numa_nodes = 0;
nb_nics = 0;
autostart= 1;
optind = 1;
while (optind < argc) {
if (argv[optind][0] != '-') {
optind++;
continue;
} else {
const QEMUOption *popt;
popt = lookup_opt(argc, argv, &optarg, &optind);
switch (popt->index) {
case QEMU_OPTION_nodefconfig:
defconfig=0;
break;
}
}
}
if (defconfig) {
int ret;
ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf");
if (ret < 0 && ret != -ENOENT) {
exit(1);
}
ret = qemu_read_config_file(arch_config_name);
if (ret < 0 && ret != -ENOENT) {
exit(1);
}
}
cpudef_init();
optind = 1;
for(;;) {
if (optind >= argc)
break;
if (argv[optind][0] != '-') {
hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
} else {
const QEMUOption *popt;
popt = lookup_opt(argc, argv, &optarg, &optind);
if (!(popt->arch_mask & arch_type)) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
switch(popt->index) {
case QEMU_OPTION_M:
machine = machine_parse(optarg);
break;
case QEMU_OPTION_cpu:
if (*optarg == '?') {
list_cpus(stdout, &fprintf, optarg);
exit(0);
} else {
cpu_model = optarg;
}
break;
case QEMU_OPTION_initrd:
initrd_filename = optarg;
break;
case QEMU_OPTION_hda:
{
char buf[256];
if (cyls == 0)
snprintf(buf, sizeof(buf), "%s", HD_OPTS);
else
snprintf(buf, sizeof(buf),
"%s,cyls=%d,heads=%d,secs=%d%s",
HD_OPTS , cyls, heads, secs,
translation == BIOS_ATA_TRANSLATION_LBA ?
",trans=lba" :
translation == BIOS_ATA_TRANSLATION_NONE ?
",trans=none" : "");
drive_add(IF_DEFAULT, 0, optarg, buf);
break;
}
case QEMU_OPTION_hdb:
case QEMU_OPTION_hdc:
case QEMU_OPTION_hdd:
drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg,
HD_OPTS);
break;
case QEMU_OPTION_drive:
if (drive_def(optarg) == NULL) {
exit(1);
}
break;
case QEMU_OPTION_set:
if (qemu_set_option(optarg) != 0)
exit(1);
break;
case QEMU_OPTION_global:
if (qemu_global_option(optarg) != 0)
exit(1);
break;
case QEMU_OPTION_mtdblock:
drive_add(IF_MTD, -1, optarg, MTD_OPTS);
break;
case QEMU_OPTION_sd:
drive_add(IF_SD, 0, optarg, SD_OPTS);
break;
case QEMU_OPTION_pflash:
drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS);
break;
case QEMU_OPTION_snapshot:
snapshot = 1;
break;
case QEMU_OPTION_hdachs:
{
const char *p;
p = optarg;
cyls = strtol(p, (char **)&p, 0);
if (cyls < 1 || cyls > 16383)
goto chs_fail;
if (*p != ',')
goto chs_fail;
p++;
heads = strtol(p, (char **)&p, 0);
if (heads < 1 || heads > 16)
goto chs_fail;
if (*p != ',')
goto chs_fail;
p++;
secs = strtol(p, (char **)&p, 0);
if (secs < 1 || secs > 63)
goto chs_fail;
if (*p == ',') {
p++;
if (!strcmp(p, "none"))
translation = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(p, "lba"))
translation = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(p, "auto"))
translation = BIOS_ATA_TRANSLATION_AUTO;
else
goto chs_fail;
} else if (*p != '\0') {
chs_fail:
fprintf(stderr, "qemu: invalid physical CHS format\n");
exit(1);
}
if (hda_opts != NULL) {
char num[16];
snprintf(num, sizeof(num), "%d", cyls);
qemu_opt_set(hda_opts, "cyls", num);
snprintf(num, sizeof(num), "%d", heads);
qemu_opt_set(hda_opts, "heads", num);
snprintf(num, sizeof(num), "%d", secs);
qemu_opt_set(hda_opts, "secs", num);
if (translation == BIOS_ATA_TRANSLATION_LBA)
qemu_opt_set(hda_opts, "trans", "lba");
if (translation == BIOS_ATA_TRANSLATION_NONE)
qemu_opt_set(hda_opts, "trans", "none");
}
}
break;
case QEMU_OPTION_numa:
if (nb_numa_nodes >= MAX_NODES) {
fprintf(stderr, "qemu: too many NUMA nodes\n");
exit(1);
}
numa_add(optarg);
break;
case QEMU_OPTION_display:
display_type = select_display(optarg);
break;
case QEMU_OPTION_nographic:
display_type = DT_NOGRAPHIC;
break;
case QEMU_OPTION_curses:
#ifdef CONFIG_CURSES
display_type = DT_CURSES;
#else
fprintf(stderr, "Curses support is disabled\n");
exit(1);
#endif
break;
case QEMU_OPTION_portrait:
graphic_rotate = 90;
break;
case QEMU_OPTION_rotate:
graphic_rotate = strtol(optarg, (char **) &optarg, 10);
if (graphic_rotate != 0 && graphic_rotate != 90 &&
graphic_rotate != 180 && graphic_rotate != 270) {
fprintf(stderr,
"qemu: only 90, 180, 270 deg rotation is available\n");
exit(1);
}
break;
case QEMU_OPTION_kernel:
kernel_filename = optarg;
break;
case QEMU_OPTION_append:
kernel_cmdline = optarg;
break;
case QEMU_OPTION_cdrom:
drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
break;
case QEMU_OPTION_boot:
{
static const char * const params[] = {
"order", "once", "menu",
"splash", "splash-time", NULL
};
char buf[sizeof(boot_devices)];
char *standard_boot_devices;
int legacy = 0;
if (!strchr(optarg, '=')) {
legacy = 1;
pstrcpy(buf, sizeof(buf), optarg);
} else if (check_params(buf, sizeof(buf), params, optarg) < 0) {
fprintf(stderr,
"qemu: unknown boot parameter '%s' in '%s'\n",
buf, optarg);
exit(1);
}
if (legacy ||
get_param_value(buf, sizeof(buf), "order", optarg)) {
validate_bootdevices(buf);
pstrcpy(boot_devices, sizeof(boot_devices), buf);
}
if (!legacy) {
if (get_param_value(buf, sizeof(buf),
"once", optarg)) {
validate_bootdevices(buf);
standard_boot_devices = g_strdup(boot_devices);
pstrcpy(boot_devices, sizeof(boot_devices), buf);
qemu_register_reset(restore_boot_devices,
standard_boot_devices);
}
if (get_param_value(buf, sizeof(buf),
"menu", optarg)) {
if (!strcmp(buf, "on")) {
boot_menu = 1;
} else if (!strcmp(buf, "off")) {
boot_menu = 0;
} else {
fprintf(stderr,
"qemu: invalid option value '%s'\n",
buf);
exit(1);
}
}
qemu_opts_parse(qemu_find_opts("boot-opts"),
optarg, 0);
}
}
break;
case QEMU_OPTION_fda:
case QEMU_OPTION_fdb:
drive_add(IF_FLOPPY, popt->index - QEMU_OPTION_fda,
optarg, FD_OPTS);
break;
case QEMU_OPTION_no_fd_bootchk:
fd_bootchk = 0;
break;
case QEMU_OPTION_netdev:
if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) {
exit(1);
}
break;
case QEMU_OPTION_net:
if (net_client_parse(qemu_find_opts("net"), optarg) == -1) {
exit(1);
}
break;
#ifdef CONFIG_SLIRP
case QEMU_OPTION_tftp:
legacy_tftp_prefix = optarg;
break;
case QEMU_OPTION_bootp:
legacy_bootp_filename = optarg;
break;
case QEMU_OPTION_redir:
if (net_slirp_redir(optarg) < 0)
exit(1);
break;
#endif
case QEMU_OPTION_bt:
add_device_config(DEV_BT, optarg);
break;
case QEMU_OPTION_audio_help:
if (!(audio_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
AUD_help ();
exit (0);
break;
case QEMU_OPTION_soundhw:
if (!(audio_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
select_soundhw (optarg);
break;
case QEMU_OPTION_h:
help(0);
break;
case QEMU_OPTION_version:
version();
exit(0);
break;
case QEMU_OPTION_m: {
int64_t value;
char *end;
value = strtosz(optarg, &end);
if (value < 0 || *end) {
fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);
exit(1);
}
if (value != (uint64_t)(ram_addr_t)value) {
fprintf(stderr, "qemu: ram size too large\n");
exit(1);
}
ram_size = value;
break;
}
case QEMU_OPTION_mempath:
mem_path = optarg;
break;
#ifdef MAP_POPULATE
case QEMU_OPTION_mem_prealloc:
mem_prealloc = 1;
break;
#endif
case QEMU_OPTION_d:
log_mask = optarg;
break;
case QEMU_OPTION_D:
log_file = optarg;
break;
case QEMU_OPTION_s:
gdbstub_dev = "tcp::" DEFAULT_GDBSTUB_PORT;
break;
case QEMU_OPTION_gdb:
gdbstub_dev = optarg;
break;
case QEMU_OPTION_L:
data_dir = optarg;
break;
case QEMU_OPTION_bios:
bios_name = optarg;
break;
case QEMU_OPTION_singlestep:
singlestep = 1;
break;
case QEMU_OPTION_S:
autostart = 0;
break;
case QEMU_OPTION_k:
keyboard_layout = optarg;
break;
case QEMU_OPTION_localtime:
rtc_utc = 0;
break;
case QEMU_OPTION_vga:
select_vgahw (optarg);
break;
case QEMU_OPTION_g:
{
const char *p;
int w, h, depth;
p = optarg;
w = strtol(p, (char **)&p, 10);
if (w <= 0) {
graphic_error:
fprintf(stderr, "qemu: invalid resolution or depth\n");
exit(1);
}
if (*p != 'x')
goto graphic_error;
p++;
h = strtol(p, (char **)&p, 10);
if (h <= 0)
goto graphic_error;
if (*p == 'x') {
p++;
depth = strtol(p, (char **)&p, 10);
if (depth != 8 && depth != 15 && depth != 16 &&
depth != 24 && depth != 32)
goto graphic_error;
} else if (*p == '\0') {
depth = graphic_depth;
} else {
goto graphic_error;
}
graphic_width = w;
graphic_height = h;
graphic_depth = depth;
}
break;
case QEMU_OPTION_echr:
{
char *r;
term_escape_char = strtol(optarg, &r, 0);
if (r == optarg)
printf("Bad argument to echr\n");
break;
}
case QEMU_OPTION_monitor:
monitor_parse(optarg, "readline");
default_monitor = 0;
break;
case QEMU_OPTION_qmp:
monitor_parse(optarg, "control");
default_monitor = 0;
break;
case QEMU_OPTION_mon:
opts = qemu_opts_parse(qemu_find_opts("mon"), optarg, 1);
if (!opts) {
exit(1);
}
default_monitor = 0;
break;
case QEMU_OPTION_chardev:
opts = qemu_opts_parse(qemu_find_opts("chardev"), optarg, 1);
if (!opts) {
exit(1);
}
break;
case QEMU_OPTION_fsdev:
olist = qemu_find_opts("fsdev");
if (!olist) {
fprintf(stderr, "fsdev is not supported by this qemu build.\n");
exit(1);
}
opts = qemu_opts_parse(olist, optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
break;
case QEMU_OPTION_virtfs: {
QemuOpts *fsdev;
QemuOpts *device;
const char *writeout;
olist = qemu_find_opts("virtfs");
if (!olist) {
fprintf(stderr, "virtfs is not supported by this qemu build.\n");
exit(1);
}
opts = qemu_opts_parse(olist, optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
if (qemu_opt_get(opts, "fsdriver") == NULL ||
qemu_opt_get(opts, "mount_tag") == NULL ||
qemu_opt_get(opts, "path") == NULL) {
fprintf(stderr, "Usage: -virtfs fsdriver,path=/share_path/,"
"[security_model={mapped|passthrough|none}],"
"mount_tag=tag.\n");
exit(1);
}
fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
qemu_opt_get(opts, "mount_tag"), 1);
if (!fsdev) {
fprintf(stderr, "duplicate fsdev id: %s\n",
qemu_opt_get(opts, "mount_tag"));
exit(1);
}
writeout = qemu_opt_get(opts, "writeout");
if (writeout) {
#ifdef CONFIG_SYNC_FILE_RANGE
qemu_opt_set(fsdev, "writeout", writeout);
#else
fprintf(stderr, "writeout=immediate not supported on "
"this platform\n");
exit(1);
#endif
}
qemu_opt_set(fsdev, "fsdriver", qemu_opt_get(opts, "fsdriver"));
qemu_opt_set(fsdev, "path", qemu_opt_get(opts, "path"));
qemu_opt_set(fsdev, "security_model",
qemu_opt_get(opts, "security_model"));
qemu_opt_set_bool(fsdev, "readonly",
qemu_opt_get_bool(opts, "readonly", 0));
device = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(device, "driver", "virtio-9p-pci");
qemu_opt_set(device, "fsdev",
qemu_opt_get(opts, "mount_tag"));
qemu_opt_set(device, "mount_tag",
qemu_opt_get(opts, "mount_tag"));
break;
}
case QEMU_OPTION_virtfs_synth: {
QemuOpts *fsdev;
QemuOpts *device;
fsdev = qemu_opts_create(qemu_find_opts("fsdev"), "v_synth", 1);
if (!fsdev) {
fprintf(stderr, "duplicate option: %s\n", "virtfs_synth");
exit(1);
}
qemu_opt_set(fsdev, "fsdriver", "synth");
qemu_opt_set(fsdev, "path", "/");
device = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(device, "driver", "virtio-9p-pci");
qemu_opt_set(device, "fsdev", "v_synth");
qemu_opt_set(device, "mount_tag", "v_synth");
break;
}
case QEMU_OPTION_serial:
add_device_config(DEV_SERIAL, optarg);
default_serial = 0;
if (strncmp(optarg, "mon:", 4) == 0) {
default_monitor = 0;
}
break;
case QEMU_OPTION_watchdog:
if (watchdog) {
fprintf(stderr,
"qemu: only one watchdog option may be given\n");
return 1;
}
watchdog = optarg;
break;
case QEMU_OPTION_watchdog_action:
if (select_watchdog_action(optarg) == -1) {
fprintf(stderr, "Unknown -watchdog-action parameter\n");
exit(1);
}
break;
case QEMU_OPTION_virtiocon:
add_device_config(DEV_VIRTCON, optarg);
default_virtcon = 0;
if (strncmp(optarg, "mon:", 4) == 0) {
default_monitor = 0;
}
break;
case QEMU_OPTION_parallel:
add_device_config(DEV_PARALLEL, optarg);
default_parallel = 0;
if (strncmp(optarg, "mon:", 4) == 0) {
default_monitor = 0;
}
break;
case QEMU_OPTION_debugcon:
add_device_config(DEV_DEBUGCON, optarg);
break;
case QEMU_OPTION_loadvm:
loadvm = optarg;
break;
case QEMU_OPTION_full_screen:
full_screen = 1;
break;
#ifdef CONFIG_SDL
case QEMU_OPTION_no_frame:
no_frame = 1;
break;
case QEMU_OPTION_alt_grab:
alt_grab = 1;
break;
case QEMU_OPTION_ctrl_grab:
ctrl_grab = 1;
break;
case QEMU_OPTION_no_quit:
no_quit = 1;
break;
case QEMU_OPTION_sdl:
display_type = DT_SDL;
break;
#else
case QEMU_OPTION_no_frame:
case QEMU_OPTION_alt_grab:
case QEMU_OPTION_ctrl_grab:
case QEMU_OPTION_no_quit:
case QEMU_OPTION_sdl:
fprintf(stderr, "SDL support is disabled\n");
exit(1);
#endif
case QEMU_OPTION_pidfile:
pid_file = optarg;
break;
case QEMU_OPTION_win2k_hack:
win2k_install_hack = 1;
break;
case QEMU_OPTION_rtc_td_hack:
rtc_td_hack = 1;
break;
case QEMU_OPTION_acpitable:
do_acpitable_option(optarg);
break;
case QEMU_OPTION_smbios:
do_smbios_option(optarg);
break;
case QEMU_OPTION_enable_kvm:
olist = qemu_find_opts("machine");
qemu_opts_reset(olist);
qemu_opts_parse(olist, "accel=kvm", 0);
break;
case QEMU_OPTION_machine:
olist = qemu_find_opts("machine");
qemu_opts_reset(olist);
opts = qemu_opts_parse(olist, optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
optarg = qemu_opt_get(opts, "type");
if (optarg) {
machine = machine_parse(optarg);
}
break;
case QEMU_OPTION_usb:
usb_enabled = 1;
break;
case QEMU_OPTION_usbdevice:
usb_enabled = 1;
add_device_config(DEV_USB, optarg);
break;
case QEMU_OPTION_device:
if (!qemu_opts_parse(qemu_find_opts("device"), optarg, 1)) {
exit(1);
}
break;
case QEMU_OPTION_smp:
smp_parse(optarg);
if (smp_cpus < 1) {
fprintf(stderr, "Invalid number of CPUs\n");
exit(1);
}
if (max_cpus < smp_cpus) {
fprintf(stderr, "maxcpus must be equal to or greater than "
"smp\n");
exit(1);
}
if (max_cpus > 255) {
fprintf(stderr, "Unsupported number of maxcpus\n");
exit(1);
}
break;
case QEMU_OPTION_vnc:
#ifdef CONFIG_VNC
display_remote++;
vnc_display = optarg;
#else
fprintf(stderr, "VNC support is disabled\n");
exit(1);
#endif
break;
case QEMU_OPTION_no_acpi:
acpi_enabled = 0;
break;
case QEMU_OPTION_no_hpet:
no_hpet = 1;
break;
case QEMU_OPTION_balloon:
if (balloon_parse(optarg) < 0) {
fprintf(stderr, "Unknown -balloon argument %s\n", optarg);
exit(1);
}
break;
case QEMU_OPTION_no_reboot:
no_reboot = 1;
break;
case QEMU_OPTION_no_shutdown:
no_shutdown = 1;
break;
case QEMU_OPTION_show_cursor:
cursor_hide = 0;
break;
case QEMU_OPTION_uuid:
if(qemu_uuid_parse(optarg, qemu_uuid) < 0) {
fprintf(stderr, "Fail to parse UUID string."
" Wrong format.\n");
exit(1);
}
break;
case QEMU_OPTION_option_rom:
if (nb_option_roms >= MAX_OPTION_ROMS) {
fprintf(stderr, "Too many option ROMs\n");
exit(1);
}
opts = qemu_opts_parse(qemu_find_opts("option-rom"), optarg, 1);
option_rom[nb_option_roms].name = qemu_opt_get(opts, "romfile");
option_rom[nb_option_roms].bootindex =
qemu_opt_get_number(opts, "bootindex", -1);
if (!option_rom[nb_option_roms].name) {
fprintf(stderr, "Option ROM file is not specified\n");
exit(1);
}
nb_option_roms++;
break;
case QEMU_OPTION_semihosting:
semihosting_enabled = 1;
break;
case QEMU_OPTION_name:
qemu_name = g_strdup(optarg);
{
char *p = strchr(qemu_name, ',');
if (p != NULL) {
*p++ = 0;
if (strncmp(p, "process=", 8)) {
fprintf(stderr, "Unknown subargument %s to -name\n", p);
exit(1);
}
p += 8;
os_set_proc_name(p);
}
}
break;
case QEMU_OPTION_prom_env:
if (nb_prom_envs >= MAX_PROM_ENVS) {
fprintf(stderr, "Too many prom variables\n");
exit(1);
}
prom_envs[nb_prom_envs] = optarg;
nb_prom_envs++;
break;
case QEMU_OPTION_old_param:
old_param = 1;
break;
case QEMU_OPTION_clock:
configure_alarms(optarg);
break;
case QEMU_OPTION_startdate:
configure_rtc_date_offset(optarg, 1);
break;
case QEMU_OPTION_rtc:
opts = qemu_opts_parse(qemu_find_opts("rtc"), optarg, 0);
if (!opts) {
exit(1);
}
configure_rtc(opts);
break;
case QEMU_OPTION_tb_size:
tcg_tb_size = strtol(optarg, NULL, 0);
if (tcg_tb_size < 0) {
tcg_tb_size = 0;
}
break;
case QEMU_OPTION_icount:
icount_option = optarg;
break;
case QEMU_OPTION_incoming:
incoming = optarg;
break;
case QEMU_OPTION_nodefaults:
default_serial = 0;
default_parallel = 0;
default_virtcon = 0;
default_monitor = 0;
default_vga = 0;
default_net = 0;
default_floppy = 0;
default_cdrom = 0;
default_sdcard = 0;
break;
case QEMU_OPTION_xen_domid:
if (!(xen_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
xen_domid = atoi(optarg);
break;
case QEMU_OPTION_xen_create:
if (!(xen_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
xen_mode = XEN_CREATE;
break;
case QEMU_OPTION_xen_attach:
if (!(xen_available())) {
printf("Option %s not supported for this target\n", popt->name);
exit(1);
}
xen_mode = XEN_ATTACH;
break;
case QEMU_OPTION_trace:
{
opts = qemu_opts_parse(qemu_find_opts("trace"), optarg, 0);
if (!opts) {
exit(1);
}
trace_events = qemu_opt_get(opts, "events");
trace_file = qemu_opt_get(opts, "file");
break;
}
case QEMU_OPTION_readconfig:
{
int ret = qemu_read_config_file(optarg);
if (ret < 0) {
fprintf(stderr, "read config %s: %s\n", optarg,
strerror(-ret));
exit(1);
}
break;
}
case QEMU_OPTION_spice:
olist = qemu_find_opts("spice");
if (!olist) {
fprintf(stderr, "spice is not supported by this qemu build.\n");
exit(1);
}
opts = qemu_opts_parse(olist, optarg, 0);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
break;
case QEMU_OPTION_writeconfig:
{
FILE *fp;
if (strcmp(optarg, "-") == 0) {
fp = stdout;
} else {
fp = fopen(optarg, "w");
if (fp == NULL) {
fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
exit(1);
}
}
qemu_config_write(fp);
fclose(fp);
break;
}
default:
os_parse_cmd_args(popt->index, optarg);
}
}
}
loc_set_none();
if (log_mask) {
if (log_file) {
set_cpu_log_filename(log_file);
}
set_cpu_log(log_mask);
}
if (!trace_backend_init(trace_events, trace_file)) {
exit(1);
}
if (!data_dir) {
data_dir = os_find_datadir(argv[0]);
}
if (!data_dir) {
data_dir = CONFIG_QEMU_DATADIR;
}
if (machine == NULL) {
fprintf(stderr, "No machine found.\n");
exit(1);
}
if (!max_cpus)
max_cpus = smp_cpus;
machine->max_cpus = machine->max_cpus ?: 1;
if (smp_cpus > machine->max_cpus) {
fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus "
"supported by machine `%s' (%d)\n", smp_cpus, machine->name,
machine->max_cpus);
exit(1);
}
if (machine->default_machine_opts) {
QemuOptsList *list = qemu_find_opts("machine");
const char *p = NULL;
if (!QTAILQ_EMPTY(&list->head)) {
p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel");
}
if (p == NULL) {
qemu_opts_reset(list);
opts = qemu_opts_parse(list, machine->default_machine_opts, 0);
if (!opts) {
fprintf(stderr, "parse error for machine %s: %s\n",
machine->name, machine->default_machine_opts);
exit(1);
}
}
}
qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0);
qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0);
if (machine->no_serial) {
default_serial = 0;
}
if (machine->no_parallel) {
default_parallel = 0;
}
if (!machine->use_virtcon) {
default_virtcon = 0;
}
if (machine->no_vga) {
default_vga = 0;
}
if (machine->no_floppy) {
default_floppy = 0;
}
if (machine->no_cdrom) {
default_cdrom = 0;
}
if (machine->no_sdcard) {
default_sdcard = 0;
}
if (display_type == DT_NOGRAPHIC) {
if (default_parallel)
add_device_config(DEV_PARALLEL, "null");
if (default_serial && default_monitor) {
add_device_config(DEV_SERIAL, "mon:stdio");
} else if (default_virtcon && default_monitor) {
add_device_config(DEV_VIRTCON, "mon:stdio");
} else {
if (default_serial)
add_device_config(DEV_SERIAL, "stdio");
if (default_virtcon)
add_device_config(DEV_VIRTCON, "stdio");
if (default_monitor)
monitor_parse("stdio", "readline");
}
} else {
if (default_serial)
add_device_config(DEV_SERIAL, "vc:80Cx24C");
if (default_parallel)
add_device_config(DEV_PARALLEL, "vc:80Cx24C");
if (default_monitor)
monitor_parse("vc:80Cx24C", "readline");
if (default_virtcon)
add_device_config(DEV_VIRTCON, "vc:80Cx24C");
}
if (default_vga)
vga_interface_type = VGA_CIRRUS;
socket_init();
if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
exit(1);
#ifdef CONFIG_VIRTFS
if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) {
exit(1);
}
#endif
os_daemonize();
if (pid_file && qemu_create_pidfile(pid_file) != 0) {
os_pidfile_error();
exit(1);
}
if (ram_size == 0) {
ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
}
configure_accelerator();
qemu_init_cpu_loop();
if (qemu_init_main_loop()) {
fprintf(stderr, "qemu_init_main_loop failed\n");
exit(1);
}
linux_boot = (kernel_filename != NULL);
if (!linux_boot && *kernel_cmdline != '\0') {
fprintf(stderr, "-append only allowed with -kernel option\n");
exit(1);
}
if (!linux_boot && initrd_filename != NULL) {
fprintf(stderr, "-initrd only allowed with -kernel option\n");
exit(1);
}
os_set_line_buffering();
if (init_timer_alarm() < 0) {
fprintf(stderr, "could not initialize alarm timer\n");
exit(1);
}
if (icount_option && (kvm_enabled() || xen_enabled())) {
fprintf(stderr, "-icount is not allowed with kvm or xen\n");
exit(1);
}
configure_icount(icount_option);
if (net_init_clients() < 0) {
exit(1);
}
if (foreach_device_config(DEV_BT, bt_parse))
exit(1);
if (!xen_enabled()) {
if (ram_size > (2047 << 20) && HOST_LONG_BITS == 32) {
fprintf(stderr, "qemu: at most 2047 MB RAM can be simulated\n");
exit(1);
}
}
cpu_exec_init_all();
bdrv_init_with_whitelist();
blk_mig_init();
if (snapshot)
qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, 0);
if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine->use_scsi, 1) != 0)
exit(1);
default_drive(default_cdrom, snapshot, machine->use_scsi,
IF_DEFAULT, 2, CDROM_OPTS);
default_drive(default_floppy, snapshot, machine->use_scsi,
IF_FLOPPY, 0, FD_OPTS);
default_drive(default_sdcard, snapshot, machine->use_scsi,
IF_SD, 0, SD_OPTS);
register_savevm_live(NULL, "ram", 0, 4, NULL, ram_save_live, NULL,
ram_load, NULL);
if (nb_numa_nodes > 0) {
int i;
if (nb_numa_nodes > MAX_NODES) {
nb_numa_nodes = MAX_NODES;
}
for (i = 0; i < nb_numa_nodes; i++) {
if (node_mem[i] != 0)
break;
}
if (i == nb_numa_nodes) {
uint64_t usedmem = 0;
for (i = 0; i < nb_numa_nodes - 1; i++) {
node_mem[i] = (ram_size / nb_numa_nodes) & ~((1 << 23UL) - 1);
usedmem += node_mem[i];
}
node_mem[i] = ram_size - usedmem;
}
for (i = 0; i < nb_numa_nodes; i++) {
if (node_cpumask[i] != 0)
break;
}
if (i == nb_numa_nodes) {
for (i = 0; i < max_cpus; i++) {
node_cpumask[i % nb_numa_nodes] |= 1 << i;
}
}
}
if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) {
exit(1);
}
if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
exit(1);
if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
exit(1);
if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0)
exit(1);
if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
exit(1);
module_call_init(MODULE_INIT_DEVICE);
if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) != 0)
exit(0);
if (watchdog) {
i = select_watchdog(watchdog);
if (i > 0)
exit (i == 1 ? 1 : 0);
}
if (machine->compat_props) {
qdev_prop_register_global_list(machine->compat_props);
}
qemu_add_globals();
qdev_machine_init();
machine->init(ram_size, boot_devices,
kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
cpu_synchronize_all_post_init();
set_numa_modes();
current_machine = machine;
if (usb_enabled) {
if (foreach_device_config(DEV_USB, usb_parse) < 0)
exit(1);
}
if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) != 0)
exit(1);
net_check_clients();
ds = get_displaystate();
if (using_spice)
display_remote++;
if (display_type == DT_DEFAULT && !display_remote) {
#if defined(CONFIG_SDL) || defined(CONFIG_COCOA)
display_type = DT_SDL;
#elif defined(CONFIG_VNC)
vnc_display = "localhost:0,to=99";
show_vnc_port = 1;
#else
display_type = DT_NONE;
#endif
}
switch (display_type) {
case DT_NOGRAPHIC:
break;
#if defined(CONFIG_CURSES)
case DT_CURSES:
curses_display_init(ds, full_screen);
break;
#endif
#if defined(CONFIG_SDL)
case DT_SDL:
sdl_display_init(ds, full_screen, no_frame);
break;
#elif defined(CONFIG_COCOA)
case DT_SDL:
cocoa_display_init(ds, full_screen);
break;
#endif
default:
break;
}
os_setup_signal_handling();
#ifdef CONFIG_VNC
if (vnc_display) {
vnc_display_init(ds);
if (vnc_display_open(ds, vnc_display) < 0)
exit(1);
if (show_vnc_port) {
printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
}
}
#endif
#ifdef CONFIG_SPICE
if (using_spice && !qxl_enabled) {
qemu_spice_display_init(ds);
}
#endif
dpy_resize(ds);
dcl = ds->listeners;
while (dcl != NULL) {
if (dcl->dpy_refresh != NULL) {
ds->gui_timer = qemu_new_timer_ms(rt_clock, gui_update, ds);
qemu_mod_timer(ds->gui_timer, qemu_get_clock_ms(rt_clock));
break;
}
dcl = dcl->next;
}
text_consoles_set_display(ds);
if (gdbstub_dev && gdbserver_start(gdbstub_dev) < 0) {
fprintf(stderr, "qemu: could not open gdbserver on device '%s'\n",
gdbstub_dev);
exit(1);
}
qdev_machine_creation_done();
if (rom_load_all() != 0) {
fprintf(stderr, "rom loading failed\n");
exit(1);
}
qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());
qemu_run_machine_init_done_notifiers();
qemu_system_reset(VMRESET_SILENT);
if (loadvm) {
if (load_vmstate(loadvm) < 0) {
autostart = 0;
}
}
if (incoming) {
runstate_set(RUN_STATE_INMIGRATE);
int ret = qemu_start_incoming_migration(incoming);
if (ret < 0) {
fprintf(stderr, "Migration failed. Exit code %s(%d), exiting.\n",
incoming, ret);
exit(ret);
}
} else if (autostart) {
vm_start();
}
os_setup_post();
resume_all_vcpus();
main_loop();
bdrv_close_all();
pause_all_vcpus();
net_cleanup();
res_free();
return 0;
}
| 1threat
|
how can I modulo operation for strings issue? : <p>I am trying to use modulo operation with my dummy data <code>msg</code> if msg mutiples by 8 <code>msg%8</code> then give me the output of <code>printf("[-] Error: Size too long");</code> if not then it will be okay , but using directly to <code>msg%8</code>doesnt mean to work how can I fix this? </p>
<p>error output</p>
<p><code>Error C2296 '%': illegal, left operand has type 'char [1000]'</code></p>
<pre><code>int main() {
char buf[8];
char msg[1000];
printf("Enter cookie:\n");
scanf("%s", buf);
printf("Your cookie %s \n", buf);
if (strlen(buf) == 16) {
printf(" [+] Header received: %d bytes \n", strlen(buf));
if (stricmp("0x41414141414141", buf) == 0)
{
strcpy(buf, "hello");
printf("Enter msg:\n");
scanf("%s", msg);
if (strlen(msg) <= 512) {
if (msg % 8) {
printf("[-] Error: Size too long");
}
else {
printf("[-] Good");
}
}
else {
printf(" [-] Error: Invalid \n");
}
}
else {
printf(" [-] Error: Invalid \n");
}
}
else {
printf(" [-] Error: Invalid \n");
}
return 0;
}
</code></pre>
| 0debug
|
wpf binding not refreshing if equals and gethashcode (NO IPROPERTYCHANGED NEEDED!) : <p>My WPF binding is not working because my viewmodel has overwritten Equals and GetHashCode. If i comment it out (region Object-Stuff), everything works fine.</p>
<p>Further info about my reasons: All my viewmodels have an Id. I load data with Id=1 and set the datacontext. Later i reload the data (same id, but other properties can have changed), i reset the datacontext and nothing happens (DataContextChanged-event is raised).
And for everybody who want to mark this as duplicate... No, i did not forget the INotifyPropertyChanged-Interface. The binding is refreshed when the datacontext is set, this has nothing to do with INotifyPropertyChanged.</p>
<p>Has anybody an idea how to refresh the datacontext? (by the way, set it to null and then to my new viewmodel is not an solution because the regulation is that a views datacontext is never null). Here is some small demo code to reproduce this. Window.xaml:</p>
<pre><code><Grid>
<Button Content="Button1" HorizontalAlignment="Left" Margin="565,84,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="206,173,0,0" TextWrapping="Wrap" Text="{Binding Text}" VerticalAlignment="Top" Width="120"/>
<Button Content="Button2" HorizontalAlignment="Left" Margin="565,138,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
<Button Content="Button3" HorizontalAlignment="Left" Margin="565,191,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_2"/>
</Grid>
</code></pre>
<p>Window.xaml.cs:</p>
<pre><code> private void Button_Click(object sender, RoutedEventArgs e)
{
ViewModel vm = new ViewModel { Id = 1, Text = "Button1" };
DataContext = vm;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
ViewModel vm = new ViewModel { Id = 1, Text = "Button2" };
DataContext = vm;
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
ViewModel vm = new ViewModel { Id = 1, Text = "Button3" };
DataContext = vm;
}
</code></pre>
<p>ViewModel:</p>
<pre><code>class ViewModel
{
public int Id { get; set; }
public string Text { get; set; }
#region Object-Stuff
public override int GetHashCode()
{
return Id.GetHashCode();
}
public override bool Equals(object obj)
{
ViewModel other = obj as ViewModel;
if ((object)other == null)
{
return false;
}
return Id == other.Id;
}
public virtual bool Equals(ViewModel other)
{
if ((object)other == null)
{
return false;
}
return Id == other.Id;
}
#endregion
}
</code></pre>
| 0debug
|
Python pandas : Merge two tables without keys (Multiply 2 dataframes with broadcasting all elements; NxN dataframe) : <p>I want to merge 2 dataframes with broadcast relationship:
No common index, just want to find all pairs of the rows in the 2 dataframes.
So want to make N row dataframe x M row dataframe = N*M row dataframe.
Is there any rule to make this happen without using itertool?</p>
<pre><code>DF1=
id quantity
0 1 20
1 2 23
DF2=
name part
0 'A' 3
1 'B' 4
2 'C' 5
DF_merged=
id quantity name part
0 1 20 'A' 3
1 1 20 'B' 4
2 1 20 'C' 5
3 2 23 'A' 3
4 2 23 'B' 4
5 2 23 'C' 5
</code></pre>
| 0debug
|
How to slide a activity in android : <p>how to Slide an activity like the image below, after sliding the trail of the activities must be visible like the below image.</p>
<p><a href="https://i.stack.imgur.com/aoXy7.png" rel="nofollow noreferrer">enter image description here</a></p>
| 0debug
|
HashMap Java. Code is correct but not running : import java.util.*;
public class Map {
public static void main(String[] args) {
Map map = new HashMap();
map.put("father", "Rob");
System.out.println(map.get("father"));
}
}
| 0debug
|
void op_ddiv (void)
{
if (T1 != 0) {
env->LO = (int64_t)T0 / (int64_t)T1;
env->HI = (int64_t)T0 % (int64_t)T1;
}
RETURN();
}
| 1threat
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
static int eject_device(Monitor *mon, BlockDriverState *bs, int force)
{
if (bdrv_is_inserted(bs)) {
if (!force) {
if (!bdrv_is_removable(bs)) {
qerror_report(QERR_DEVICE_NOT_REMOVABLE,
bdrv_get_device_name(bs));
return -1;
}
if (bdrv_is_locked(bs)) {
qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs));
return -1;
}
}
bdrv_close(bs);
}
return 0;
}
| 1threat
|
Angular4 reactive form validation not working : <p>In pic1 I have written a input tag (line: 101) and another input tag copied from other place (line: 102)
But first input tag is working but not second one, because for second input tag there is no "ng-invalid ng-touched" class in DOM (pic2). <a href="https://i.stack.imgur.com/yM7V7.png" rel="nofollow noreferrer">pic1</a>
<a href="https://i.stack.imgur.com/rf8mm.png" rel="nofollow noreferrer">pic2</a></p>
<pre><code>import { Component, OnInit } from "@angular/core";
import { FormGroup, FormControl, Validators } from "@angular/forms";
@Component({
selector: "app-sign-up",
templateUrl: "./sign-up.component.html",
styleUrls: ["./sign-up.component.css"]
})
export class SignUpComponent implements OnInit {
ngOnInit(): void {
//this.Registration.va
}
Registration = new FormGroup({
fullName: new FormControl("",[Validators.required])
});
}
</code></pre>
| 0debug
|
Firebase shows app version needs investigation : <p>My app's firebase dashboard shows needs investigation (Analytics -> App release) I don't know why it is showing like that. Please see the screenshot</p>
<p><a href="https://i.stack.imgur.com/MMbYM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MMbYM.png" alt="Screenshot"></a> </p>
<p>Searched google to find out the reason, but got no useful links. Anyone knows why it is showing "Needs investigation"?</p>
| 0debug
|
Write a PERL script that lists the directory contents of a directory specified by the user : I have tried this code but it doesnt work for the user-input directory.
It only lists the PWD.
Help!
[My code screenshot][1]
[1]: https://i.stack.imgur.com/kirW6.png
| 0debug
|
void qemu_co_rwlock_unlock(CoRwlock *lock)
{
assert(qemu_in_coroutine());
if (lock->writer) {
lock->writer = false;
qemu_co_queue_restart_all(&lock->queue);
} else {
lock->reader--;
assert(lock->reader >= 0);
if (!lock->reader) {
qemu_co_queue_next(&lock->queue);
}
}
}
| 1threat
|
static int ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p)
{
CCID_Header *ccid_header;
if (p->len + s->bulk_out_pos > BULK_OUT_DATA_SIZE) {
return USB_RET_STALL;
}
ccid_header = (CCID_Header *)s->bulk_out_data;
memcpy(s->bulk_out_data + s->bulk_out_pos, p->data, p->len);
s->bulk_out_pos += p->len;
if (p->len == CCID_MAX_PACKET_SIZE) {
DPRINTF(s, D_VERBOSE,
"usb-ccid: bulk_in: expecting more packets (%d/%d)\n",
p->len, ccid_header->dwLength);
return 0;
}
if (s->bulk_out_pos < 10) {
DPRINTF(s, 1,
"%s: bad USB_TOKEN_OUT length, should be at least 10 bytes\n",
__func__);
} else {
DPRINTF(s, D_MORE_INFO, "%s %x\n", __func__, ccid_header->bMessageType);
switch (ccid_header->bMessageType) {
case CCID_MESSAGE_TYPE_PC_to_RDR_GetSlotStatus:
ccid_write_slot_status(s, ccid_header);
break;
case CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOn:
DPRINTF(s, 1, "PowerOn: %d\n",
((CCID_IccPowerOn *)(ccid_header))->bPowerSelect);
s->powered = true;
if (!ccid_card_inserted(s)) {
ccid_report_error_failed(s, ERROR_ICC_MUTE);
}
ccid_write_data_block_atr(s, ccid_header);
break;
case CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOff:
DPRINTF(s, 1, "PowerOff\n");
ccid_reset_error_status(s);
s->powered = false;
ccid_write_slot_status(s, ccid_header);
break;
case CCID_MESSAGE_TYPE_PC_to_RDR_XfrBlock:
ccid_on_apdu_from_guest(s, (CCID_XferBlock *)s->bulk_out_data);
break;
case CCID_MESSAGE_TYPE_PC_to_RDR_SetParameters:
ccid_reset_error_status(s);
ccid_set_parameters(s, ccid_header);
ccid_write_parameters(s, ccid_header);
break;
case CCID_MESSAGE_TYPE_PC_to_RDR_ResetParameters:
ccid_reset_error_status(s);
ccid_reset_parameters(s);
ccid_write_parameters(s, ccid_header);
break;
case CCID_MESSAGE_TYPE_PC_to_RDR_GetParameters:
ccid_reset_error_status(s);
ccid_write_parameters(s, ccid_header);
break;
default:
DPRINTF(s, 1,
"handle_data: ERROR: unhandled message type %Xh\n",
ccid_header->bMessageType);
ccid_report_error_failed(s, ERROR_CMD_NOT_SUPPORTED);
ccid_write_slot_status(s, ccid_header);
break;
}
}
s->bulk_out_pos = 0;
return 0;
}
| 1threat
|
Check if user is logged in with Token Based Authentication in ASP.NET Core : <p>I managed to implement this token based authentication system in my application, but I have a little question. How can I check if a user is signed it (eg if the there is a valid token in the request) within the method? So with the [Authorize] ?</p>
<p>So I have controller, and in that controller I want to check if the user is signed in. I thought of using this:</p>
<pre><code>if (_signInManager.IsSignedIn(ClaimsPrincipal.Current))
{
...
}
</code></pre>
<p>but it does not work since ClaimsPrincipal.Current is always null</p>
| 0debug
|
docker-compose up vs docker-compose up --build vs docker-compose build --no-cache : <p>I couldn't figure out what the difference between those.</p>
<ul>
<li><p><code>docker-compose up</code> </p></li>
<li><p><code>docker-compose up --build</code></p></li>
<li><p><code>docker-compose build --no-cache</code></p></li>
</ul>
<p>Is there any command for <code>up</code>without cache?</p>
| 0debug
|
static av_cold void rv34_init_tables(void)
{
int i, j, k;
for(i = 0; i < NUM_INTRA_TABLES; i++){
for(j = 0; j < 2; j++){
rv34_gen_vlc(rv34_table_intra_cbppat [i][j], CBPPAT_VLC_SIZE, &intra_vlcs[i].cbppattern[j], NULL, 19*i + 0 + j);
rv34_gen_vlc(rv34_table_intra_secondpat[i][j], OTHERBLK_VLC_SIZE, &intra_vlcs[i].second_pattern[j], NULL, 19*i + 2 + j);
rv34_gen_vlc(rv34_table_intra_thirdpat [i][j], OTHERBLK_VLC_SIZE, &intra_vlcs[i].third_pattern[j], NULL, 19*i + 4 + j);
for(k = 0; k < 4; k++){
rv34_gen_vlc(rv34_table_intra_cbp[i][j+k*2], CBP_VLC_SIZE, &intra_vlcs[i].cbp[j][k], rv34_cbp_code, 19*i + 6 + j*4 + k);
}
}
for(j = 0; j < 4; j++){
rv34_gen_vlc(rv34_table_intra_firstpat[i][j], FIRSTBLK_VLC_SIZE, &intra_vlcs[i].first_pattern[j], NULL, 19*i + 14 + j);
}
rv34_gen_vlc(rv34_intra_coeff[i], COEFF_VLC_SIZE, &intra_vlcs[i].coefficient, NULL, 19*i + 18);
}
for(i = 0; i < NUM_INTER_TABLES; i++){
rv34_gen_vlc(rv34_inter_cbppat[i], CBPPAT_VLC_SIZE, &inter_vlcs[i].cbppattern[0], NULL, i*12 + 95);
for(j = 0; j < 4; j++){
rv34_gen_vlc(rv34_inter_cbp[i][j], CBP_VLC_SIZE, &inter_vlcs[i].cbp[0][j], rv34_cbp_code, i*12 + 96 + j);
}
for(j = 0; j < 2; j++){
rv34_gen_vlc(rv34_table_inter_firstpat [i][j], FIRSTBLK_VLC_SIZE, &inter_vlcs[i].first_pattern[j], NULL, i*12 + 100 + j);
rv34_gen_vlc(rv34_table_inter_secondpat[i][j], OTHERBLK_VLC_SIZE, &inter_vlcs[i].second_pattern[j], NULL, i*12 + 102 + j);
rv34_gen_vlc(rv34_table_inter_thirdpat [i][j], OTHERBLK_VLC_SIZE, &inter_vlcs[i].third_pattern[j], NULL, i*12 + 104 + j);
}
rv34_gen_vlc(rv34_inter_coeff[i], COEFF_VLC_SIZE, &inter_vlcs[i].coefficient, NULL, i*12 + 106);
}
}
| 1threat
|
Linq Group with inside array element : ```
a = new { Key = new[] {1, 2} };
b = new { Key = new[] {2, 3} };
c = new { Key = new[] {3} };
```
I want a linq func that will got the result below, after `new [] {a, b, c}.func(x => x.Key)`
```
new KeyValuePair[] {
{ Key = 1, Value = new [] { a } },
{ Key = 2, Value = new [] { a, b } },
{ Key = 3, Value = new [] { b, c } }
}
```
| 0debug
|
How TO Generate Number Incrementing by previous number in php : I want TO generate A Number In Sequence in php On Page Refresh. Like
if I start with 1 then after Page Refresh It Should Be 2.Please Help
| 0debug
|
What is the recommended project structure for spring boot rest projects? : <p>I'm a beginner with spring boot. I'm involved in the beginning of a project where we would build rest services using spring boot. Could you please advise the recommended directory structure to follow when building a project that will just expose rest services?</p>
| 0debug
|
How can I select unique row based on value matched in other column : I have searched a lot but can not get my head around this.
I need to filter the results based on comparing values in 2 rows.
Data)
[Data I want to filter][1]
Results I want to end up with
[Desired results][2]
Is this possible in MySQL?
If there is a way to do this in PHP after the query I'm happy with that too.
Thanks for any help.
[1]: https://i.stack.imgur.com/bEKfz.png [2]: https://i.stack.imgur.com/35CMY.png
| 0debug
|
static void gen_thumb2_parallel_addsub(int op1, int op2, TCGv a, TCGv b)
{
TCGv tmp;
switch (op1) {
#define gen_pas_helper(name) glue(gen_helper_,name)(a, a, b, tmp)
case 0:
tmp = tcg_temp_new(TCG_TYPE_PTR);
tcg_gen_addi_ptr(tmp, cpu_env, offsetof(CPUState, GE));
PAS_OP(s)
break;
case 4:
tmp = tcg_temp_new(TCG_TYPE_PTR);
tcg_gen_addi_ptr(tmp, cpu_env, offsetof(CPUState, GE));
PAS_OP(u)
break;
#undef gen_pas_helper
#define gen_pas_helper(name) glue(gen_helper_,name)(a, a, b)
case 1:
PAS_OP(q);
break;
case 2:
PAS_OP(sh);
break;
case 5:
PAS_OP(uq);
break;
case 6:
PAS_OP(uh);
break;
#undef gen_pas_helper
}
}
| 1threat
|
Is there any other way of doing this? if section of this code make it work but is there any way of using setw() to organize (*) properly? :
void showTheater(char theater[][20],int row,int seat)
{
cout << "Seats: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19" << endl;
for (int i = 0; i <= row; i++)
{
for (int j = 0; j <= seat; j++)
{
if (j == 0) {
cout << "Row " << i;
}
else if (i < 10) {
cout << setw(3) << theater[row][seat];
}
else {
cout <<" " << theater[row][seat]<<" ";
}
}
cout << "\n";
}
}
output without writing if section:
Seats: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Row 0 * * * * * * * * * * * * * * * * * * * *
Row 1 * * * * * * * * * * * * * * * * * * * *
Row 2 * * * * * * * * * * * * * * * * * * * *
Row 3 * * * * * * * * * * * * * * * * * * * *
Row 4 * * * * * * * * * * * * * * * * * * * *
Row 5 * * * * * * * * * * * * * * * * * * * *
Row 6 * * * * * * * * * * * * * * * * * * * *
Row 7 * * * * * * * * * * * * * * * * * * * *
Row 8 * * * * * * * * * * * * * * * * * * * *
Row 9 * * * * * * * * * * * * * * * * * * * *
Row 10 * * * * * * * * * * * * * * * * * * * *
Row 11 * * * * * * * * * * * * * * * * * * * *
Row 12 * * * * * * * * * * * * * * * * * * * *
Row 13 * * * * * * * * * * * * * * * * * * * *
Row 14 * * * * * * * * * * * * * * * * * * * *
Row 15 * * * * * * * * * * * * * * * * * * * *
output with if section:
Seats: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Row 0 * * * * * * * * * * * * * * * * * * * *
Row 1 * * * * * * * * * * * * * * * * * * * *
Row 2 * * * * * * * * * * * * * * * * * * * *
Row 3 * * * * * * * * * * * * * * * * * * * *
Row 4 * * * * * * * * * * * * * * * * * * * *
Row 5 * * * * * * * * * * * * * * * * * * * *
Row 6 * * * * * * * * * * * * * * * * * * * *
Row 7 * * * * * * * * * * * * * * * * * * * *
Row 8 * * * * * * * * * * * * * * * * * * * *
Row 9 * * * * * * * * * * * * * * * * * * * *
Row 10 * * * * * * * * * * * * * * * * * * * *
Row 11 * * * * * * * * * * * * * * * * * * * *
Row 12 * * * * * * * * * * * * * * * * * * * *
Row 13 * * * * * * * * * * * * * * * * * * * *
Row 14 * * * * * * * * * * * * * * * * * * * *
Row 15 * * * * * * * * * * * * * * * * * * * *
| 0debug
|
static int libopenjpeg_copy_packed8(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
{
int compno;
int x;
int y;
int *image_line;
int frame_index;
const int numcomps = image->numcomps;
for (compno = 0; compno < numcomps; ++compno) {
if (image->comps[compno].w > frame->linesize[0] / numcomps) {
av_log(avctx, AV_LOG_ERROR, "Error: frame's linesize is too small for the image\n");
return 0;
}
}
for (compno = 0; compno < numcomps; ++compno) {
for (y = 0; y < avctx->height; ++y) {
image_line = image->comps[compno].data + y * image->comps[compno].w;
frame_index = y * frame->linesize[0] + compno;
for (x = 0; x < avctx->width; ++x) {
image_line[x] = frame->data[0][frame_index];
frame_index += numcomps;
}
for (; x < image->comps[compno].w; ++x) {
image_line[x] = image_line[x - 1];
}
}
for (; y < image->comps[compno].h; ++y) {
image_line = image->comps[compno].data + y * image->comps[compno].w;
for (x = 0; x < image->comps[compno].w; ++x) {
image_line[x] = image_line[x - image->comps[compno].w];
}
}
}
return 1;
}
| 1threat
|
How to solve MongoError: pool destroyed while connecting to CosmosDB : <p>I have Node.js service in which I am using mongo-API to communicate with Document/Cosmos DB.
My service run's fine and performs all the crud operation but after 1 min some mongo error throws from the service.</p>
<pre><code>/document-db-service/node_modules/mongodb/lib/utils.js:123
process.nextTick(function() { throw err; });
^
MongoError: pool destroyed
at Pool.write (/document-db-service/node_modules/mongodb-core/lib/connection/pool.js:922:12)
at Cursor._find (/document-db-service/node_modules/mongodb-core/lib/cursor.js:286:22)
at nextFunction (/document-db-service/node_modules/mongodb-core/lib/cursor.js:584:10)
at Cursor.next [as _next] (/document-db-service/node_modules/mongodb-core/lib/cursor.js:692:3)
at fetchDocs (/document-db-service/node_modules/mongodb/lib/cursor.js:856:10)
at toArray (/document-db-service/node_modules/mongodb/lib/cursor.js:883:3)
at Cursor.toArray (/document-db-service/node_modules/mongodb/lib/cursor.js:836:44)
at exports.getDocsOfCollections (/document-db-service/services/collections.js:273:10)
at Layer.handle [as handle_request] (/document-db-service/node_modules/express/lib/router/layer.js:95:5)
at next (/document-db-service/node_modules/express/lib/router/route.js:137:13)
</code></pre>
<p>I am not able to understand why this error is coming up.Please suggest the changes that need to be done to resolve this error.</p>
| 0debug
|
CocoaPods and Carthage : <p>I had a project with both Carthage and Cocoapods. They both have one common dependency (PureLayout, to be precise). Strange, but project compiles fine without any errors about class redeclaration, etc.
So the question is: why it works and which version of dependency is actually used when I call PureLayout's methods – Carthage's or Cocoapods' one?</p>
| 0debug
|
Need a few clarifications for C++ related items : <p>So I am taking a class right now to learn C++ at my University. </p>
<p>I would like some clarifications that my professor has made. </p>
<p>First...<br>
He said that .hpp was a depreciated file as of 2003 and that because Apple uses the .hpp in Xcode they could not be used for real world development. Is this true? </p>
<p>I read that .hpp was only exclusive to C++ where .h is used for C/C++ is this correct. </p>
<p>Second...<br>
He tried telling me that Swift is a scripting language. Why would he say that? </p>
<p>Also if I have read correctly Swift is like the best of both C++ and Objective C right? or is that just a marketing gimmick by Apple?</p>
<p>One last thing<br>
How does swift stack up to languages such as C++, Java, etc in terms of performance, power (if that makes any sense) and so on? The professor makes seem like it is a mediocre language and will never leave 10th place of most used language. Again this is all his word not mine. I am learning and I feel like I am not getting accurate information. </p>
| 0debug
|
C# random number and greater than operator : <p>I'm trying to generate a random number and give the user 5 tries to guess the right number. I want to compare their guess and tell them if they're too high or too low. VS wont execute and I don't understand why I'm getting errors.</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NumberGuessingGame
{
class Program
{
static void Main(string[] args)
{
bool keepGoing = true;
while (keepGoing)
{
Random rnd = new Random();
int randomnumber = rnd.Next(1, 100);
//PC tells user to pick a number, display guessed number
Console.Write("Guess any integer between 1 and 100: ");
int userentry = Console.ReadLine();
{
if (int.Parse(userentry > rnd.Next))
{ Console.WriteLine($"You entered {userentry}. That's too
high. Try again.");
keepGoing = true;
}
if (int.Parse(userentry < randomnumber))
{
Console.WriteLine($"You entered {userentry}. That's too
low. Try again.");
keepGoing = true;
}
if (int.Parse(userentry = randomnumber))
{
Console.WriteLine($"You entered {userentry}. That's
right. Good job.");
keepGoing = false;
}
else (keepgoing) > 5);
{
Console.WriteLine($"You've already tried 5 times. You
lose.");
keepGoing = false;
}
else
{
Console.WriteLine("That is not a valid number.");
}
}
}
}
</code></pre>
<p>}</p>
| 0debug
|
static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
{
VideoData *s = s1->priv_data;
int ret, first_index, last_index;
char buf[1024];
ByteIOContext pb1, *f = &pb1;
AVStream *st;
st = av_new_stream(s1, 0);
if (!st) {
av_free(s);
return -ENOMEM;
}
if (ap->image_format)
s->img_fmt = ap->image_format;
pstrcpy(s->path, sizeof(s->path), s1->filename);
s->img_number = 0;
s->img_count = 0;
if (s1->iformat->flags & AVFMT_NOFILE)
s->is_pipe = 0;
else
s->is_pipe = 1;
if (!ap->time_base.num) {
st->codec->time_base= (AVRational){1,25};
} else {
st->codec->time_base= ap->time_base;
}
if (!s->is_pipe) {
if (find_image_range(&first_index, &last_index, s->path) < 0)
goto fail;
s->img_first = first_index;
s->img_last = last_index;
s->img_number = first_index;
st->start_time = 0;
st->duration = last_index - first_index + 1;
if (get_frame_filename(buf, sizeof(buf), s->path, s->img_number) < 0)
goto fail;
if (url_fopen(f, buf, URL_RDONLY) < 0)
goto fail;
} else {
f = &s1->pb;
}
ret = av_read_image(f, s1->filename, s->img_fmt, read_header_alloc_cb, s);
if (ret < 0)
goto fail1;
if (!s->is_pipe) {
url_fclose(f);
} else {
url_fseek(f, 0, SEEK_SET);
}
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec->width = s->width;
st->codec->height = s->height;
st->codec->pix_fmt = s->pix_fmt;
s->img_size = avpicture_get_size(s->pix_fmt, (s->width+15)&(~15), (s->height+15)&(~15));
return 0;
fail1:
if (!s->is_pipe)
url_fclose(f);
fail:
av_free(s);
return AVERROR_IO;
}
| 1threat
|
Convert column to timestamp - Pandas Dataframe : <p>I have a Pandas Dataframe that has date values stored in 2 columns in the below format:</p>
<pre><code>Column 1: 04-APR-2018 11:04:29
Column 2: 2018040415203
</code></pre>
<p>How could I convert this to a time stamp. Datatype of both these column is Object.</p>
| 0debug
|
How do i add an item to the end of a linked list? : class Node:
def __init__(self, item, next):
self.item = item
self.next = next
class LinkedList:
def __init__(self):
self.head = None
def add(self, item):
self.head = Node(item, self.head)
def is_empty(self):
return self.head == None
I tried doing it this way but it doesn't work.
from LinkedList import Node, LinkedList
def insert_at_end(linked_list, item):
linked_list.add(item)
Can anyone help?
| 0debug
|
Comparing two dates using if statement not working - javascript + nodejs : <p>Here my below code:</p>
<pre><code>var date = new Date().toLocaleString();
console.log(date); // output: 2018-01-15 16:39:00
var schedule = 2018-01-15 16:39:00 (which is coming from my html form, i putting this date in one input box and getting into variable called schedule).
console.log(schedule); // output: 2018-01-15 16:39:00
if(date === schedule) {
console.log('date is matched');
} else {
console.log('error');
}
</code></pre>
<p>This will show correctly as output: // 'date is matched'
(I am typing this date in input box without any date picker).</p>
<p>My problem is if i do this same code using date picker instead of writing date in input box.</p>
<p>My code:</p>
<pre><code>var date = new Date().toLocaleString();
console.log(date); // output: 2018-01-15 16:39:00
var schedule = 2018-01-15 16:39:00 (which is coming from my html form,using date picker).
console.log(schedule); // output: 2018-01-15 16:39:00
if(date === schedule) {
console.log('date is matched');
} else {
console.log('error');
}
</code></pre>
<p>Now i am getting error in console.
Date picker which i am using <a href="https://www.npmjs.com/package/angularjs-datetime-picker" rel="nofollow noreferrer">https://www.npmjs.com/package/angularjs-datetime-picker</a></p>
| 0debug
|
static int get_cluster_duration(MOVTrack *track, int cluster_idx)
{
int64_t next_dts;
if (cluster_idx >= track->entry)
return 0;
if (cluster_idx + 1 == track->entry)
next_dts = track->track_duration + track->start_dts;
else
next_dts = track->cluster[cluster_idx + 1].dts;
return next_dts - track->cluster[cluster_idx].dts;
}
| 1threat
|
def max_profit(price, k):
n = len(price)
final_profit = [[None for x in range(n)] for y in range(k + 1)]
for i in range(k + 1):
for j in range(n):
if i == 0 or j == 0:
final_profit[i][j] = 0
else:
max_so_far = 0
for x in range(j):
curr_price = price[j] - price[x] + final_profit[i-1][x]
if max_so_far < curr_price:
max_so_far = curr_price
final_profit[i][j] = max(final_profit[i][j-1], max_so_far)
return final_profit[k][n-1]
| 0debug
|
static int gsm_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
GSMParseContext *s = s1->priv_data;
ParseContext *pc = &s->pc;
int next;
if (!s->block_size) {
switch (avctx->codec_id) {
case AV_CODEC_ID_GSM:
s->block_size = GSM_BLOCK_SIZE;
s->duration = GSM_FRAME_SIZE;
break;
case AV_CODEC_ID_GSM_MS:
s->block_size = GSM_MS_BLOCK_SIZE;
s->duration = GSM_FRAME_SIZE * 2;
break;
default:
return AVERROR(EINVAL);
}
}
if (!s->remaining)
s->remaining = s->block_size;
if (s->remaining <= buf_size) {
next = s->remaining;
s->remaining = 0;
} else {
next = END_NOT_FOUND;
s->remaining -= buf_size;
}
if (ff_combine_frame(pc, next, &buf, &buf_size) < 0 || !buf_size) {
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
s1->duration = s->duration;
*poutbuf = buf;
*poutbuf_size = buf_size;
return next;
}
| 1threat
|
static int xan_decode_frame_type1(AVCodecContext *avctx)
{
XanContext *s = avctx->priv_data;
uint8_t *ybuf, *src = s->scratch_buffer;
int cur, last;
int i, j;
int ret;
if ((ret = xan_decode_chroma(avctx, bytestream2_get_le32(&s->gb))) != 0)
return ret;
bytestream2_seek(&s->gb, 16, SEEK_SET);
ret = xan_unpack_luma(s, src,
s->buffer_size >> 1);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Luma decoding failed\n");
return ret;
}
ybuf = s->y_buffer;
for (i = 0; i < avctx->height; i++) {
last = (ybuf[0] + (*src++ << 1)) & 0x3F;
ybuf[0] = last;
for (j = 1; j < avctx->width - 1; j += 2) {
cur = (ybuf[j + 1] + (*src++ << 1)) & 0x3F;
ybuf[j] = (last + cur) >> 1;
ybuf[j+1] = cur;
last = cur;
}
ybuf[j] = last;
ybuf += avctx->width;
}
src = s->y_buffer;
ybuf = s->pic.data[0];
for (j = 0; j < avctx->height; j++) {
for (i = 0; i < avctx->width; i++)
ybuf[i] = (src[i] << 2) | (src[i] >> 3);
src += avctx->width;
ybuf += s->pic.linesize[0];
}
return 0;
}
| 1threat
|
How to Add mysql foreign key from another table primary key in php : <?
$connect->exec("INSERT INTO questions
(questions_points, questions_ask, answer_option, contest_id)
VALUES ('$questionspoints', '$questionsask', '$answeroption', '$lastid') ");
$connect->exec(" INSERT INTO answers(choice_option, questions_id)
VALUES('$choiceoption', what should i add here except last id because it is not working , I want to add the questions primary key)");
?>
| 0debug
|
int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left)
{
int e;
int bit_count_start = get_bits_count(gb_host);
int header;
int bits_consumed;
GetBitContext gbc = *gb_host, *gb = &gbc;
header = get_bits1(gb);
if (header) {
ps->enable_iid = get_bits1(gb);
if (ps->enable_iid) {
int iid_mode = get_bits(gb, 3);
if (iid_mode > 5) {
av_log(avctx, AV_LOG_ERROR, "iid_mode %d is reserved.\n",
iid_mode);
goto err;
}
ps->nr_iid_par = nr_iidicc_par_tab[iid_mode];
ps->iid_quant = iid_mode > 2;
ps->nr_ipdopd_par = nr_iidopd_par_tab[iid_mode];
}
ps->enable_icc = get_bits1(gb);
if (ps->enable_icc) {
ps->icc_mode = get_bits(gb, 3);
if (ps->icc_mode > 5) {
av_log(avctx, AV_LOG_ERROR, "icc_mode %d is reserved.\n",
ps->icc_mode);
goto err;
}
ps->nr_icc_par = nr_iidicc_par_tab[ps->icc_mode];
}
ps->enable_ext = get_bits1(gb);
}
ps->frame_class = get_bits1(gb);
ps->num_env_old = ps->num_env;
ps->num_env = num_env_tab[ps->frame_class][get_bits(gb, 2)];
ps->border_position[0] = -1;
if (ps->frame_class) {
for (e = 1; e <= ps->num_env; e++)
ps->border_position[e] = get_bits(gb, 5);
} else
for (e = 1; e <= ps->num_env; e++)
ps->border_position[e] = (e * numQMFSlots >> ff_log2_tab[ps->num_env]) - 1;
if (ps->enable_iid) {
for (e = 0; e < ps->num_env; e++) {
int dt = get_bits1(gb);
if (read_iid_data(avctx, gb, ps, ps->iid_par, huff_iid[2*dt+ps->iid_quant], e, dt))
goto err;
}
} else
if (ps->enable_icc)
for (e = 0; e < ps->num_env; e++) {
int dt = get_bits1(gb);
if (read_icc_data(avctx, gb, ps, ps->icc_par, dt ? huff_icc_dt : huff_icc_df, e, dt))
goto err;
}
else
if (ps->enable_ext) {
int cnt = get_bits(gb, 4);
if (cnt == 15) {
cnt += get_bits(gb, 8);
}
cnt *= 8;
while (cnt > 7) {
int ps_extension_id = get_bits(gb, 2);
cnt -= 2 + ps_read_extension_data(gb, ps, ps_extension_id);
}
if (cnt < 0) {
av_log(avctx, AV_LOG_ERROR, "ps extension overflow %d\n", cnt);
goto err;
}
skip_bits(gb, cnt);
}
ps->enable_ipdopd &= !PS_BASELINE;
if (!ps->num_env || ps->border_position[ps->num_env] < numQMFSlots - 1) {
int source = ps->num_env ? ps->num_env - 1 : ps->num_env_old - 1;
if (source >= 0 && source != ps->num_env) {
if (ps->enable_iid) {
memcpy(ps->iid_par+ps->num_env, ps->iid_par+source, sizeof(ps->iid_par[0]));
}
if (ps->enable_icc) {
memcpy(ps->icc_par+ps->num_env, ps->icc_par+source, sizeof(ps->icc_par[0]));
}
if (ps->enable_ipdopd) {
memcpy(ps->ipd_par+ps->num_env, ps->ipd_par+source, sizeof(ps->ipd_par[0]));
memcpy(ps->opd_par+ps->num_env, ps->opd_par+source, sizeof(ps->opd_par[0]));
}
}
ps->num_env++;
ps->border_position[ps->num_env] = numQMFSlots - 1;
}
ps->is34bands_old = ps->is34bands;
if (!PS_BASELINE && (ps->enable_iid || ps->enable_icc))
ps->is34bands = (ps->enable_iid && ps->nr_iid_par == 34) ||
(ps->enable_icc && ps->nr_icc_par == 34);
if (!ps->enable_ipdopd) {
}
if (header)
ps->start = 1;
bits_consumed = get_bits_count(gb) - bit_count_start;
if (bits_consumed <= bits_left) {
skip_bits_long(gb_host, bits_consumed);
return bits_consumed;
}
av_log(avctx, AV_LOG_ERROR, "Expected to read %d PS bits actually read %d.\n", bits_left, bits_consumed);
err:
ps->start = 0;
skip_bits_long(gb_host, bits_left);
return bits_left;
}
| 1threat
|
OpenCV Python: cv2.VideoCapture can only find 2 of 3 cameras, Windows Camera app finds all : <p>I'm trying to create 3 real-time capture frames with webcams into a USB hub into my laptop. Using the "camera" app on Windows, I can change the camera source one at a time and confirm that all 3 webcams are working. However, my OpenCV Python code can only ever find two. </p>
<p>(Quick notes on the USB - it's a USB 3.0 hub, laptop port is USB 3, and I even have an active USB female-to-male cable going into the laptop, so given this and the Windows app working, I generally trust the hardware.) </p>
<p>Below I did some raw testing of <code>cv2.VideoCapture(src)</code> with the results below: </p>
<pre><code>cams_test = 10
for i in range(0, cams_test):
cap = cv2.VideoCapture(i)
test, frame = cap.read()
print("i : "+str(i)+" /// result: "+str(test))
</code></pre>
<p>That first argument, <code>test</code>, returns True/False depending on if the frame can be read. Results:</p>
<pre><code>i : 0 /// result: True
i : 1 /// result: True
i : 2 /// result: False
i : 3 /// result: False
i : 4 /// result: False
i : 5 /// result: False
i : 6 /// result: False
i : 7 /// result: False
i : 8 /// result: False
i : 9 /// result: False
</code></pre>
<p>As with other sample code I tested, only 2 webcams can be registered and show frames in Python. And the Windows 10 camera app lets me scroll between all 3 working and connected webcam feeds. </p>
<p>I know I can create multiple, like 3+, <code>cv2.imshow()</code> frames if I use the <code>cap</code>s that work. My project involves doing this to show realtime USB webcam feeds on the laptop from multiple cameras. </p>
<p>Any help and advice appreciated; also potentially interested in (Python-based) alternative solutions. Cheers. </p>
| 0debug
|
How to validate if data and column headers in the table are refreshed or not : <p>Given : There is table with 3 rows and 5 columns and a refresh button . After Refresh button is triggered, the data along with the column headers (3 columns headers) getting changed on every refresh except 2 columns headers.</p>
<p>How can we handle such a scenario using selenium?</p>
<p>Thanks</p>
| 0debug
|
Python replace part of long url : <p>I have a long url like</p>
<pre><code>https://yyyyyy.com/yyyyy/xxxxx/yyyyy/yyyyyy/yyyyy/pppp/kkkk
</code></pre>
<p>And I want to replace the xxxx part to zzzz</p>
<p>I tried with the re.sub</p>
<pre><code>b = url.split('/')[-6] #which gives me the right part of the url to change
newurl = re.sub(b, 'zzzz', url)
</code></pre>
<p>But when i print it i still get the old url.. Any idea? </p>
| 0debug
|
init_disasm (struct disassemble_info *info)
{
const struct s390_opcode *opcode;
const struct s390_opcode *opcode_end;
memset (opc_index, 0, sizeof (opc_index));
opcode_end = s390_opcodes + s390_num_opcodes;
for (opcode = s390_opcodes; opcode < opcode_end; opcode++)
{
opc_index[(int) opcode->opcode[0]] = opcode - s390_opcodes;
while ((opcode < opcode_end) &&
(opcode[1].opcode[0] == opcode->opcode[0]))
opcode++;
}
#ifdef QEMU_DISABLE
switch (info->mach)
{
case bfd_mach_s390_31:
current_arch_mask = 1 << S390_OPCODE_ESA;
break;
case bfd_mach_s390_64:
current_arch_mask = 1 << S390_OPCODE_ZARCH;
break;
default:
abort ();
}
#endif
init_flag = 1;
}
| 1threat
|
static void sbr_hf_inverse_filter(SBRDSPContext *dsp,
int (*alpha0)[2], int (*alpha1)[2],
const int X_low[32][40][2], int k0)
{
int k;
int shift, round;
for (k = 0; k < k0; k++) {
SoftFloat phi[3][2][2];
SoftFloat a00, a01, a10, a11;
SoftFloat dk;
dsp->autocorrelate(X_low[k], phi);
dk = av_sub_sf(av_mul_sf(phi[2][1][0], phi[1][0][0]),
av_mul_sf(av_add_sf(av_mul_sf(phi[1][1][0], phi[1][1][0]),
av_mul_sf(phi[1][1][1], phi[1][1][1])), FLOAT_0999999));
if (!dk.mant) {
a10 = FLOAT_0;
a11 = FLOAT_0;
} else {
SoftFloat temp_real, temp_im;
temp_real = av_sub_sf(av_sub_sf(av_mul_sf(phi[0][0][0], phi[1][1][0]),
av_mul_sf(phi[0][0][1], phi[1][1][1])),
av_mul_sf(phi[0][1][0], phi[1][0][0]));
temp_im = av_sub_sf(av_add_sf(av_mul_sf(phi[0][0][0], phi[1][1][1]),
av_mul_sf(phi[0][0][1], phi[1][1][0])),
av_mul_sf(phi[0][1][1], phi[1][0][0]));
a10 = av_div_sf(temp_real, dk);
a11 = av_div_sf(temp_im, dk);
}
if (!phi[1][0][0].mant) {
a00 = FLOAT_0;
a01 = FLOAT_0;
} else {
SoftFloat temp_real, temp_im;
temp_real = av_add_sf(phi[0][0][0],
av_add_sf(av_mul_sf(a10, phi[1][1][0]),
av_mul_sf(a11, phi[1][1][1])));
temp_im = av_add_sf(phi[0][0][1],
av_sub_sf(av_mul_sf(a11, phi[1][1][0]),
av_mul_sf(a10, phi[1][1][1])));
temp_real.mant = -temp_real.mant;
temp_im.mant = -temp_im.mant;
a00 = av_div_sf(temp_real, phi[1][0][0]);
a01 = av_div_sf(temp_im, phi[1][0][0]);
}
shift = a00.exp;
if (shift >= 3)
alpha0[k][0] = 0x7fffffff;
else if (shift <= -30)
alpha0[k][0] = 0;
else {
a00.mant *= 2;
shift = 2-shift;
if (shift == 0)
alpha0[k][0] = a00.mant;
else {
round = 1 << (shift-1);
alpha0[k][0] = (a00.mant + round) >> shift;
}
}
shift = a01.exp;
if (shift >= 3)
alpha0[k][1] = 0x7fffffff;
else if (shift <= -30)
alpha0[k][1] = 0;
else {
a01.mant *= 2;
shift = 2-shift;
if (shift == 0)
alpha0[k][1] = a01.mant;
else {
round = 1 << (shift-1);
alpha0[k][1] = (a01.mant + round) >> shift;
}
}
shift = a10.exp;
if (shift >= 3)
alpha1[k][0] = 0x7fffffff;
else if (shift <= -30)
alpha1[k][0] = 0;
else {
a10.mant *= 2;
shift = 2-shift;
if (shift == 0)
alpha1[k][0] = a10.mant;
else {
round = 1 << (shift-1);
alpha1[k][0] = (a10.mant + round) >> shift;
}
}
shift = a11.exp;
if (shift >= 3)
alpha1[k][1] = 0x7fffffff;
else if (shift <= -30)
alpha1[k][1] = 0;
else {
a11.mant *= 2;
shift = 2-shift;
if (shift == 0)
alpha1[k][1] = a11.mant;
else {
round = 1 << (shift-1);
alpha1[k][1] = (a11.mant + round) >> shift;
}
}
shift = (int)(((int64_t)(alpha1[k][0]>>1) * (alpha1[k][0]>>1) + \
(int64_t)(alpha1[k][1]>>1) * (alpha1[k][1]>>1) + \
0x40000000) >> 31);
if (shift >= 0x20000000){
alpha1[k][0] = 0;
alpha1[k][1] = 0;
alpha0[k][0] = 0;
alpha0[k][1] = 0;
}
shift = (int)(((int64_t)(alpha0[k][0]>>1) * (alpha0[k][0]>>1) + \
(int64_t)(alpha0[k][1]>>1) * (alpha0[k][1]>>1) + \
0x40000000) >> 31);
if (shift >= 0x20000000){
alpha1[k][0] = 0;
alpha1[k][1] = 0;
alpha0[k][0] = 0;
alpha0[k][1] = 0;
}
}
}
| 1threat
|
iscsi_allocmap_update(IscsiLun *iscsilun, int64_t sector_num,
int nb_sectors, bool allocated, bool valid)
{
int64_t cl_num_expanded, nb_cls_expanded, cl_num_shrunk, nb_cls_shrunk;
if (iscsilun->allocmap == NULL) {
return;
}
cl_num_expanded = sector_num / iscsilun->cluster_sectors;
nb_cls_expanded = DIV_ROUND_UP(sector_num + nb_sectors,
iscsilun->cluster_sectors) - cl_num_expanded;
cl_num_shrunk = DIV_ROUND_UP(sector_num, iscsilun->cluster_sectors);
nb_cls_shrunk = (sector_num + nb_sectors) / iscsilun->cluster_sectors
- cl_num_shrunk;
if (allocated) {
bitmap_set(iscsilun->allocmap, cl_num_expanded, nb_cls_expanded);
} else {
bitmap_clear(iscsilun->allocmap, cl_num_shrunk, nb_cls_shrunk);
}
if (iscsilun->allocmap_valid == NULL) {
return;
}
if (valid) {
bitmap_set(iscsilun->allocmap_valid, cl_num_shrunk, nb_cls_shrunk);
} else {
bitmap_clear(iscsilun->allocmap_valid, cl_num_expanded,
nb_cls_expanded);
}
}
| 1threat
|
How to convert 007898989 to 7898989 python : I am trying to convert 007898989 to 7898989 using long(007898989)
but it gives error as invalid token.
please help
| 0debug
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
static void do_bit_allocation1(AC3DecodeContext *ctx, int chnl)
{
ac3_audio_block *ab = &ctx->audio_block;
int sdecay, fdecay, sgain, dbknee, floor;
int lowcomp = 0, fgain = 0, snroffset = 0, fastleak = 0, slowleak = 0;
int psd[256], bndpsd[50], excite[50], mask[50], delta;
int start = 0, end = 0, bin = 0, i = 0, j = 0, k = 0, lastbin = 0, bndstrt = 0;
int bndend = 0, begin = 0, deltnseg = 0, band = 0, seg = 0, address = 0;
int fscod = ctx->sync_info.fscod;
uint8_t *exps, *deltoffst = 0, *deltlen = 0, *deltba = 0;
uint8_t *baps;
int do_delta = 0;
sdecay = sdecaytab[ab->sdcycod];
fdecay = fdecaytab[ab->fdcycod];
sgain = sgaintab[ab->sgaincod];
dbknee = dbkneetab[ab->dbpbcod];
floor = floortab[ab->floorcod];
if (chnl == 5) {
start = ab->cplstrtmant;
end = ab->cplendmant;
fgain = fgaintab[ab->cplfgaincod];
snroffset = (((ab->csnroffst - 15) << 4) + ab->cplfsnroffst) << 2;
fastleak = (ab->cplfleak << 8) + 768;
slowleak = (ab->cplsleak << 8) + 768;
exps = ab->dcplexps;
baps = ab->cplbap;
if (ab->cpldeltbae == AC3_DBASTR_NEW || ab->cpldeltbae == AC3_DBASTR_REUSE) {
do_delta = 1;
deltnseg = ab->cpldeltnseg;
deltoffst = ab->cpldeltoffst;
deltlen = ab->cpldeltlen;
deltba = ab->cpldeltba;
}
}
else if (chnl == 6) {
start = 0;
end = 7;
lowcomp = 0;
fastleak = 0;
slowleak = 0;
fgain = fgaintab[ab->lfefgaincod];
snroffset = (((ab->csnroffst - 15) << 4) + ab->lfefsnroffst) << 2;
exps = ab->dlfeexps;
baps = ab->lfebap;
}
else {
start = 0;
end = ab->endmant[chnl];
lowcomp = 0;
fastleak = 0;
slowleak = 0;
fgain = fgaintab[ab->fgaincod[chnl]];
snroffset = (((ab->csnroffst - 15) << 4) + ab->fsnroffst[chnl]) << 2;
exps = ab->dexps[chnl];
baps = ab->bap[chnl];
if (ab->deltbae[chnl] == AC3_DBASTR_NEW || ab->deltbae[chnl] == AC3_DBASTR_REUSE) {
do_delta = 1;
deltnseg = ab->deltnseg[chnl];
deltoffst = ab->deltoffst[chnl];
deltlen = ab->deltlen[chnl];
deltba = ab->deltba[chnl];
}
}
for (bin = start; bin < end; bin++)
psd[bin] = (3072 - ((int)(exps[bin]) << 7));
j = start;
k = masktab[start];
do {
lastbin = FFMIN(bndtab[k] + bndsz[k], end);
bndpsd[k] = psd[j];
j++;
for (i = j; i < lastbin; i++) {
bndpsd[k] = logadd(bndpsd[k], psd[j]);
j++;
}
k++;
} while (end > lastbin);
bndstrt = masktab[start];
bndend = masktab[end - 1] + 1;
if (bndstrt == 0) {
lowcomp = calc_lowcomp(lowcomp, bndpsd[0], bndpsd[1], 0);
excite[0] = bndpsd[0] - fgain - lowcomp;
lowcomp = calc_lowcomp(lowcomp, bndpsd[1], bndpsd[2], 1);
excite[1] = bndpsd[1] - fgain - lowcomp;
begin = 7;
for (bin = 2; bin < 7; bin++) {
if (bndend != 7 || bin != 6)
lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin + 1], bin);
fastleak = bndpsd[bin] - fgain;
slowleak = bndpsd[bin] - sgain;
excite[bin] = fastleak - lowcomp;
if (bndend != 7 || bin != 6)
if (bndpsd[bin] <= bndpsd[bin + 1]) {
begin = bin + 1;
break;
}
}
for (bin = begin; bin < FFMIN(bndend, 22); bin++) {
if (bndend != 7 || bin != 6)
lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin + 1], bin);
fastleak -= fdecay;
fastleak = FFMAX(fastleak, bndpsd[bin] - fgain);
slowleak -= sdecay;
slowleak = FFMAX(slowleak, bndpsd[bin] - sgain);
excite[bin] = FFMAX(fastleak - lowcomp, slowleak);
}
begin = 22;
}
else {
begin = bndstrt;
}
for (bin = begin; bin < bndend; bin++) {
fastleak -= fdecay;
fastleak = FFMAX(fastleak, bndpsd[bin] - fgain);
slowleak -= sdecay;
slowleak = FFMAX(slowleak, bndpsd[bin] - sgain);
excite[bin] = FFMAX(fastleak, slowleak);
}
for (bin = bndstrt; bin < bndend; bin++) {
if (bndpsd[bin] < dbknee)
excite[bin] += ((dbknee - bndpsd[bin]) >> 2);
mask[bin] = FFMAX(excite[bin], hth[bin][fscod]);
}
if (do_delta) {
band = 0;
for (seg = 0; seg < deltnseg + 1; seg++) {
band += (int)(deltoffst[seg]);
if ((int)(deltba[seg]) >= 4)
delta = ((int)(deltba[seg]) - 3) << 7;
else
delta = ((int)(deltba[seg]) - 4) << 7;
for (k = 0; k < (int)(deltlen[seg]); k++) {
mask[band] += delta;
band++;
}
}
}
i = start;
j = masktab[start];
do {
lastbin = FFMIN(bndtab[j] + bndsz[j], end);
mask[j] -= snroffset;
mask[j] -= floor;
if (mask[j] < 0)
mask[j] = 0;
mask[j] &= 0x1fe0;
mask[j] += floor;
for (k = i; k < lastbin; k++) {
address = (psd[i] - mask[j]) >> 5;
address = FFMIN(63, FFMAX(0, address));
baps[i] = baptab[address];
i++;
}
j++;
} while (end > lastbin);
}
| 1threat
|
for (auto room : rooms) explanation? : <p>i'm trying to learn c++.
The problem of this task is to print out the total rent of rooms. The code work fine. but there are something i want to ask:</p>
<p>i don't get this line in the main function: "for (auto room : rooms)", i thought for loop suppose to have ";" ? and auto syntax has "=" ?
and do we really need "delete room;" and why?</p>
<pre><code>#include <iostream>
#include <vector>
using namespace std;
class HotelRoom {
public:
HotelRoom(int bedrooms, int bathrooms)
: bedrooms_(bedrooms), bathrooms_(bathrooms) {}
virtual int get_price() {
return 50 * bedrooms_ + 100 * bathrooms_;
}
private:
int bedrooms_;
int bathrooms_;
};
class HotelApartment : public HotelRoom {
public:
HotelApartment(int bedrooms, int bathrooms)
: HotelRoom(bedrooms, bathrooms) {}
int get_price() {
return HotelRoom::get_price() + 100;
}
};
int main() {
int n;
cin >> n;
vector<HotelRoom*> rooms;
for (int i = 0; i < n; ++i) {
string room_type;
int bedrooms;
int bathrooms;
cin >> room_type >> bedrooms >> bathrooms;
if (room_type == "standard") {
rooms.push_back(new HotelRoom(bedrooms, bathrooms));
}
else {
rooms.push_back(new HotelApartment(bedrooms, bathrooms));
}
}
int total_profit = 0;
for (auto room : rooms) {
total_profit += room->get_price();
}
cout << total_profit << endl;
for (auto room : rooms) {
delete room;
}
rooms.clear();
return 0;
}
</code></pre>
| 0debug
|
How do i search divs for text from a select form and change diplay of the divs to none? : I'm trying to hide divs based on a value in a dropdown selector. I'm not sure where I have went wrong. here is my code.
document.getElementById("SearchFilter").onchange = function() {
var matcher = new RegExp(document.getElementById("SearchFilter").value, "gi");
for (var i = 0; i < document.getElementsByClassName("v-product").length; i++) {
if (matcher.test(document.getElementsByClassName("tipue_search_content_text")[i].innerHTML)) {
document.getElementById("v-product").style.display = "inline-block";
} else {
document.getElementById("v-product").style.display = "none";
}
}
| 0debug
|
How to get 1 or 0 according to the content of a list : <p>I'm scraping with python and I have a list made at most of two letters(R and D), where the content can be always the same (i.e. all the elements are R or alternatively D) or it can be that there are some D and some R. How can I get 1 if the list is made of either R only (or D only) and 0 if there are both D and R? Thanks in advance</p>
| 0debug
|
int swri_realloc_audio(AudioData *a, int count){
int i, countb;
AudioData old;
if(count < 0 || count > INT_MAX/2/a->bps/a->ch_count)
return AVERROR(EINVAL);
if(a->count >= count)
return 0;
count*=2;
countb= FFALIGN(count*a->bps, ALIGN);
old= *a;
av_assert0(a->bps);
av_assert0(a->ch_count);
a->data= av_mallocz_array(countb, a->ch_count);
if(!a->data)
return AVERROR(ENOMEM);
for(i=0; i<a->ch_count; i++){
a->ch[i]= a->data + i*(a->planar ? countb : a->bps);
if(a->planar) memcpy(a->ch[i], old.ch[i], a->count*a->bps);
}
if(!a->planar) memcpy(a->ch[0], old.ch[0], a->count*a->ch_count*a->bps);
av_freep(&old.data);
a->count= count;
return 1;
}
| 1threat
|
void vnc_display_open(const char *id, Error **errp)
{
VncDisplay *vs = vnc_display_find(id);
QemuOpts *opts = qemu_opts_find(&qemu_vnc_opts, id);
QemuOpts *sopts, *wsopts;
const char *share, *device_id;
QemuConsole *con;
bool password = false;
bool reverse = false;
const char *vnc;
const char *has_to;
char *h;
bool has_ipv4 = false;
bool has_ipv6 = false;
const char *websocket;
bool tls = false, x509 = false;
#ifdef CONFIG_VNC_TLS
const char *path;
#endif
bool sasl = false;
#ifdef CONFIG_VNC_SASL
int saslErr;
#endif
#if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL)
int acl = 0;
#endif
int lock_key_sync = 1;
if (!vs) {
error_setg(errp, "VNC display not active");
return;
}
vnc_display_close(vs);
if (!opts) {
return;
}
vnc = qemu_opt_get(opts, "vnc");
if (!vnc || strcmp(vnc, "none") == 0) {
return;
}
sopts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort);
wsopts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort);
h = strrchr(vnc, ':');
if (h) {
char *host = g_strndup(vnc, h - vnc);
qemu_opt_set(sopts, "host", host, &error_abort);
qemu_opt_set(wsopts, "host", host, &error_abort);
qemu_opt_set(sopts, "port", h+1, &error_abort);
g_free(host);
} else {
error_setg(errp, "no vnc port specified");
goto fail;
}
has_to = qemu_opt_get(opts, "to");
has_ipv4 = qemu_opt_get_bool(opts, "ipv4", false);
has_ipv6 = qemu_opt_get_bool(opts, "ipv6", false);
if (has_to) {
qemu_opt_set(sopts, "to", has_to, &error_abort);
qemu_opt_set(wsopts, "to", has_to, &error_abort);
}
if (has_ipv4) {
qemu_opt_set(sopts, "ipv4", "on", &error_abort);
qemu_opt_set(wsopts, "ipv4", "on", &error_abort);
}
if (has_ipv6) {
qemu_opt_set(sopts, "ipv6", "on", &error_abort);
qemu_opt_set(wsopts, "ipv6", "on", &error_abort);
}
password = qemu_opt_get_bool(opts, "password", false);
if (password && fips_get_state()) {
error_setg(errp,
"VNC password auth disabled due to FIPS mode, "
"consider using the VeNCrypt or SASL authentication "
"methods as an alternative");
goto fail;
}
reverse = qemu_opt_get_bool(opts, "reverse", false);
lock_key_sync = qemu_opt_get_bool(opts, "lock-key-sync", true);
sasl = qemu_opt_get_bool(opts, "sasl", false);
#ifndef CONFIG_VNC_SASL
if (sasl) {
error_setg(errp, "VNC SASL auth requires cyrus-sasl support");
goto fail;
}
#endif
tls = qemu_opt_get_bool(opts, "tls", false);
#ifdef CONFIG_VNC_TLS
path = qemu_opt_get(opts, "x509");
if (!path) {
path = qemu_opt_get(opts, "x509verify");
if (path) {
vs->tls.x509verify = true;
}
}
if (path) {
x509 = true;
if (vnc_tls_set_x509_creds_dir(vs, path) < 0) {
error_setg(errp, "Failed to find x509 certificates/keys in %s",
path);
goto fail;
}
}
#else
if (tls) {
error_setg(errp, "VNC TLS auth requires gnutls support");
goto fail;
}
#endif
#if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL)
acl = qemu_opt_get_bool(opts, "acl", false);
#endif
share = qemu_opt_get(opts, "share");
if (share) {
if (strcmp(share, "ignore") == 0) {
vs->share_policy = VNC_SHARE_POLICY_IGNORE;
} else if (strcmp(share, "allow-exclusive") == 0) {
vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
} else if (strcmp(share, "force-shared") == 0) {
vs->share_policy = VNC_SHARE_POLICY_FORCE_SHARED;
} else {
error_setg(errp, "unknown vnc share= option");
goto fail;
}
} else {
vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
}
vs->connections_limit = qemu_opt_get_number(opts, "connections", 32);
websocket = qemu_opt_get(opts, "websocket");
if (websocket) {
#ifdef CONFIG_VNC_WS
vs->ws_enabled = true;
qemu_opt_set(wsopts, "port", websocket, &error_abort);
#else
error_setg(errp, "Websockets protocol requires gnutls support");
goto fail;
#endif
}
#ifdef CONFIG_VNC_JPEG
vs->lossy = qemu_opt_get_bool(opts, "lossy", false);
#endif
vs->non_adaptive = qemu_opt_get_bool(opts, "non-adaptive", false);
if (!vs->lossy) {
vs->non_adaptive = true;
}
#ifdef CONFIG_VNC_TLS
if (acl && x509 && vs->tls.x509verify) {
char *aclname;
if (strcmp(vs->id, "default") == 0) {
aclname = g_strdup("vnc.x509dname");
} else {
aclname = g_strdup_printf("vnc.%s.x509dname", vs->id);
}
vs->tls.acl = qemu_acl_init(aclname);
if (!vs->tls.acl) {
fprintf(stderr, "Failed to create x509 dname ACL\n");
exit(1);
}
g_free(aclname);
}
#endif
#ifdef CONFIG_VNC_SASL
if (acl && sasl) {
char *aclname;
if (strcmp(vs->id, "default") == 0) {
aclname = g_strdup("vnc.username");
} else {
aclname = g_strdup_printf("vnc.%s.username", vs->id);
}
vs->sasl.acl = qemu_acl_init(aclname);
if (!vs->sasl.acl) {
fprintf(stderr, "Failed to create username ACL\n");
exit(1);
}
g_free(aclname);
}
#endif
vnc_display_setup_auth(vs, password, sasl, tls, x509, websocket);
#ifdef CONFIG_VNC_SASL
if ((saslErr = sasl_server_init(NULL, "qemu")) != SASL_OK) {
error_setg(errp, "Failed to initialize SASL auth: %s",
sasl_errstring(saslErr, NULL, NULL));
goto fail;
}
#endif
vs->lock_key_sync = lock_key_sync;
device_id = qemu_opt_get(opts, "display");
if (device_id) {
DeviceState *dev;
int head = qemu_opt_get_number(opts, "head", 0);
dev = qdev_find_recursive(sysbus_get_default(), device_id);
if (dev == NULL) {
error_setg(errp, "Device '%s' not found", device_id);
goto fail;
}
con = qemu_console_lookup_by_device(dev, head);
if (con == NULL) {
error_setg(errp, "Device %s is not bound to a QemuConsole",
device_id);
goto fail;
}
} else {
con = NULL;
}
if (con != vs->dcl.con) {
unregister_displaychangelistener(&vs->dcl);
vs->dcl.con = con;
register_displaychangelistener(&vs->dcl);
}
if (reverse) {
int csock;
vs->lsock = -1;
#ifdef CONFIG_VNC_WS
vs->lwebsock = -1;
#endif
if (strncmp(vnc, "unix:", 5) == 0) {
csock = unix_connect(vnc+5, errp);
} else {
csock = inet_connect(vnc, errp);
}
if (csock < 0) {
goto fail;
}
vnc_connect(vs, csock, false, false);
} else {
if (strncmp(vnc, "unix:", 5) == 0) {
vs->lsock = unix_listen(vnc+5, NULL, 0, errp);
vs->is_unix = true;
} else {
vs->lsock = inet_listen_opts(sopts, 5900, errp);
if (vs->lsock < 0) {
goto fail;
}
#ifdef CONFIG_VNC_WS
if (vs->ws_enabled) {
vs->lwebsock = inet_listen_opts(wsopts, 0, errp);
if (vs->lwebsock < 0) {
if (vs->lsock != -1) {
close(vs->lsock);
vs->lsock = -1;
}
goto fail;
}
}
#endif
}
vs->enabled = true;
qemu_set_fd_handler2(vs->lsock, NULL,
vnc_listen_regular_read, NULL, vs);
#ifdef CONFIG_VNC_WS
if (vs->ws_enabled) {
qemu_set_fd_handler2(vs->lwebsock, NULL,
vnc_listen_websocket_read, NULL, vs);
}
#endif
}
qemu_opts_del(sopts);
qemu_opts_del(wsopts);
return;
fail:
qemu_opts_del(sopts);
qemu_opts_del(wsopts);
vs->enabled = false;
#ifdef CONFIG_VNC_WS
vs->ws_enabled = false;
#endif
}
| 1threat
|
python switch/case with conditions : <p>if-else statements are cumbersome. I want to construct a switch/case statement in Python. But switch/case statements in Python are geared towards specific cases such as: </p>
<pre><code>def switch(case):
return {
"a":fa,
"b":fb,
}.get(case, f_default)
</code></pre>
<p>But I want the case to meet certain conditions as in the following:</p>
<pre><code>def descriptor(magnitude):
return {
magnitude == 10.0: 'Meteoric',
magnitude >= 9.0: 'Great',
magnitude >= 8.0: 'Major',
magnitude >= 7.0: 'Strong',
magnitude >= 6.0: 'Moderate',
magnitude >= 5.0: 'Light',
magnitude >= 4.0: 'Minor',
magnitude >= 3.0: 'Very Minor',
magnitude <= 2.0: 'Micro'
}.get(magnitude, magnitude == True)()
</code></pre>
<p>My thinking is that the return key in the dictionary is anything that is true. which is why I wrote <code>magnitude == True</code>. Can someone give me some guidance, my thoughts are in <code>magnitude == True</code> but without it, there is a KeyValue error as expected.</p>
| 0debug
|
int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)
{
if (max_packet_size <= 0)
return -1;
return url_open_dyn_buf_internal(s, max_packet_size);
}
| 1threat
|
Passing Multiple Arguments to GraphQL Query : <p><strong>First thing</strong></p>
<p>Appreciate this may be a bit of a stupid question, but I'm working with GraphQL having come from the RDF/Linked Data world and having a lot of trouble getting my head around how I would return a set. Essentially I want something where I could select, let's say a list of <code>Characters</code> (using the examples from the GraphQL docs) via their <code>id</code>. In SPARQL I'd be using the <code>VALUES</code> clause and then binding, something like:</p>
<pre><code>VALUES { <http://uri/id-1> <http://uri/id-2> <http://uri/id-3> }
</code></pre>
<p>I'd assume something like this would be what I'd want (pseudocode)</p>
<pre><code>{
human(id: ["1", "2", "3", "4", "5"]) {
name
height
}
}
</code></pre>
<p><a href="http://graphql.org/learn/queries/#aliases" rel="noreferrer">Aliases</a> kind of do what I want, but I don't want to have to specify in advance or manually what the different named return values are - I want to say in my code pass a list of IDs:</p>
<pre><code>[1 2 3 4 5]
</code></pre>
<p>...and have a query that could accept that array of IDs and return me results in a predictable non-scalar shape as per the pseudo-query above.</p>
<p><strong>Second thing</strong></p>
<p>I'm also assuming that it's in fact not possible to have a query resolve to either a <code>Human</code> or <code>[Human]</code> - that it has to be one or the other? No biggie if so, I'd just settle for the latter... but I think I'm just generally quite confused over this now.</p>
| 0debug
|
PowerPCCPU *ppc4xx_init(const char *cpu_model,
clk_setup_t *cpu_clk, clk_setup_t *tb_clk,
uint32_t sysclk)
{
PowerPCCPU *cpu;
CPUPPCState *env;
cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model));
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC %s CPU definition\n",
cpu_model);
exit(1);
}
env = &cpu->env;
cpu_clk->cb = NULL;
cpu_clk->opaque = env;
tb_clk->cb = ppc_40x_timers_init(env, sysclk, PPC_INTERRUPT_PIT);
tb_clk->opaque = env;
ppc_dcr_init(env, NULL, NULL);
qemu_register_reset(ppc4xx_reset, cpu);
return cpu;
}
| 1threat
|
Print everything in column of file bash : <p>My file looks like this </p>
<pre><code>ID Done Have ETA Up Down Ratio Status Name
2 100% 858.1 MB Done 56.0 0.0 1.2 Seeding lubuntu-16.04.1-desktop-i386.iso
</code></pre>
<p>What I need to do is write a grep/awk string that will give me everything under the last column "Name"</p>
<p>Any ideas?</p>
| 0debug
|
Does passing an object via props to child react component, clone the original object or pass by reference? : <p>If am to pass an object to a child component via the components props, does this object get cloned or does it simply pass a reference to the original object?</p>
<p>For example in my <code>App.js</code> I am importing a JSON object <code>ENTRY_DATA</code>. I am then passing that object via props to my child components (or in this case, routes). Am I saving on memory by doing this or would it be the same as if I was to import <code>ENTRY_DATA</code> on each component?</p>
<pre><code>import React, { Component } from 'react';
import { withRouter, Route } from 'react-router-dom'
import ENTRY_DATA from './../../entry_data.json';
import Register from '../Register/Register';
import Categories from '../Categories/Categories';
import Category from '../Category/Category';
import Entry from '../Entry/Entry';
class App extends Component {
render() {
return (
<div className="app" >
<main>
<Route exact path="/" component={Register} />
<Route exact path='/categories' render={(props) => (
<Categories {...props} categories={ENTRY_DATA} />
)}/>
<Route exact path='/categories/:category' render={(props) => (
<Category {...props} categories={ENTRY_DATA} />
)}/>
<Route exact path='/categories/:category/:entry' render={(props) => (
<Entry {...props} categories={ENTRY_DATA} />
)}/>
</main>
</div>
);
}
}
export default withRouter(App);
</code></pre>
<p>If <code>ENTRY_DATA</code> is 5kb's, And I am passing it to 3 different components, does that mean I end up with 20kb's worth of <code>ENTRY_DATA</code> or do they all reference the one 5kb <code>ENTRY_DATA</code>?</p>
| 0debug
|
R from For-Loop to apply : this is my second day developing in R, so please bare with me/forgive any naivety. My following code has Vector BaseSal with the Base Salary for 38 different positions, as well as Vector AnnualInc which is the annual amount the Base Salary increases for each of the 38 positions. This code works perfectly:
for (i in 1:38)
print(BaseSal[i]+(AnnualInc[i] * 0:10));
The reason for the rang 0:10 is 0 is the first year salary, and the annual increment is added each year for 10 years.
And I was actually surprised at how little I had to do to get there. I have read a bit about apply being better for use in R, and I have it partially working in apply. The results I get deliver me the value of if the first years annual increase was applied to the base salary. Here is the code I'm using to get there :
l<-matrix(BaseSal,38,11,FALSE);
apply(l,2,function(z) z+(AnnualInc));
Can anyone help me figure out how to iterate through each years increment using a matrix and apply, including leaving the first year as just the base salary?
| 0debug
|
I have a Relational tables in sql server : I have a Relational table in sql server.
When i delete a field in one of them, the Related field in second table also have delete.
I don't want the second one delete. How can i do it?
[enter image description here][1]
[1]: https://i.stack.imgur.com/owCbx.png
| 0debug
|
Am I 'allowed' to modify props in the constructor? : <p>They say you shouldn't modify the <code>props</code> in a React Component. Does that extend to modifying them in the constructor?</p>
<p>Specifically,</p>
<pre><code>export default class BookingForm extends React.Component {
constructor(props) {
// am I allowed to modify `props` here?
super(props);
}
}
</code></pre>
<p>To be perfectly clear, I'm aware that JavaScript will allow me to do so, I'm asking if this is a bad design pattern that will cause me headache in the future.</p>
<p>I want to re-format some of the props upon initialization; they won't change again after that.</p>
| 0debug
|
def extract_missing(test_list, strt_val, stop_val):
res = []
for sub in test_list:
if sub[0] > strt_val:
res.append((strt_val, sub[0]))
strt_val = sub[1]
if strt_val < stop_val:
res.append((strt_val, stop_val))
return (res)
| 0debug
|
3 divs same line (boostrap4) : I wanna make a layout with a left menu, ight menu and a middle with pages stuff just like this:
http://3.bp.blogspot.com/-82HunzQsyzI/T0RaxdMxUvI/AAAAAAAAAx0/mKkTADcL_34/s1600/tc.PNG
I'm trying to do with with boostrap 4 (to help me with responsible stuff), but i can not put the 3 menus in same line
What do i doing wrong?
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Test</title>
</head>
<body>
<style type="text/css">
#tela {
color: blue;
display: inline;
/* height:100vh; */
}
</style>
<main>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">Features</a>
<a class="nav-item nav-link" href="#">Pricing</a>
<a class="nav-item nav-link disabled" href="#">Disabled</a>
</div>
</div>
</nav>
<div class="container" id="tela">
<div class="col-md-2" id="left_menu" style="background-color: green; height: 300px;">
GREEN
</div>
<div class="col-md-6" id="middle" style="background-color: yellow; height: 300px;">
YELLOW
</div>
<div class="col-md-2" id="right_menu" style="background-color: red; height: 300px;">
RED
</div>
</div>
<footer class="footer" style="background-color: black;">
<div class="container">
<span class="text-muted">Place sticky footer content here.</span>
</div>
</footer>
</main>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
| 0debug
|
why after I connection to sql server with library golang go-mssqldb , they print <nil>? : I have problem , after I connection to sql server , they print `<nil>` , what wrong with my code or problem with my connection to sql server because they just print `<nil>`?
error can see in here [enter image description here][1]
package main
import (
"database/sql"
"fmt"
_ "github.com/denisenkom/go-mssqldb"
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
db, err := sql.Open("sqlserver","sqlserver://sa:@localhost:1433?database=CONFINS&connection+timeout=30")
if err != nil{
fmt.Print(err.Error())
}
err = db.Ping()
if err != nil {
fmt.Print(err.Error())
}
defer db.Close()
type SMSBlast struct {
SequenceID string
MobilePhone string
Output string
WillBeSentDate string
SentDate string
Status string
DtmUpd string
}
router := gin.Default()
//Get a SMSBlast detail
router.GET("/SMSBlast2/:SequenceID", func(context *gin.Context) {
var(
smsblast SMSBlast
result gin.H
)
SequenceID := context.Param("SequenceID")
fmt.Println(db.Ping())
row := db.QueryRow("select SequenceID, MobilePhone, Output, WillBeSentDate, SentDate, Status, DtmUpd from SMSBlast2 = ?;",SequenceID)
err = row.Scan(&smsblast.SequenceID, &smsblast.MobilePhone, &smsblast.Output, &smsblast.WillBeSentDate, &smsblast.SentDate, &smsblast.Status, &smsblast.DtmUpd)
if err != nil{
//if no results send null
result = gin.H{
"result": nil,
"count": 0,
}
}else{
result = gin.H{
"result" : smsblast,
"count" : 1,
}
}
context.JSON(http.StatusOK, result)
})
router.Run(":8080")
}
[1]: https://i.stack.imgur.com/OUSJc.png
| 0debug
|
static inline void mix_dualmono_to_stereo(AC3DecodeContext *ctx)
{
int i;
float tmp;
float (*output)[256] = ctx->audio_block.block_output;
for (i = 0; i < 256; i++) {
tmp = output[1][i] + output[2][i];
output[1][i] = output[2][i] = tmp;
}
}
| 1threat
|
Kotlin - creating a mutable list with repeating elements : <p>What would be an idiomatic way to create a mutable list of a given length <code>n</code> with repeating elements of value <code>v</code> (e.g <code>listOf(4,4,4,4,4)</code>) as an expression.</p>
<p>I'm doing <code>val list = listOf((0..n-1)).flatten().map{v}</code> but it can only create an immutable list.</p>
| 0debug
|
IntelliJ IDEA - What is the keyboard shortcut for 'git pull' command? : <p>Since Intellij relies on keyboard shortcuts a lot,I was wondering if there is one for "git pull" command. That would save couple of seconds.
I am using Intellij Version 15.0.4 on Windows.</p>
| 0debug
|
static CoroutineThreadState *coroutine_get_thread_state(void)
{
CoroutineThreadState *s = pthread_getspecific(thread_state_key);
if (!s) {
s = g_malloc0(sizeof(*s));
s->current = &s->leader.base;
QLIST_INIT(&s->pool);
pthread_setspecific(thread_state_key, s);
}
return s;
}
| 1threat
|
document.location = 'http://evil.com?username=' + user_input;
| 1threat
|
static int usb_serial_handle_data(USBDevice *dev, USBPacket *p)
{
USBSerialState *s = (USBSerialState *)dev;
int ret = 0;
uint8_t devep = p->devep;
uint8_t *data = p->data;
int len = p->len;
int first_len;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
qemu_chr_write(s->cs, data, len);
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
first_len = RECV_BUF - s->recv_ptr;
if (len <= 2) {
ret = USB_RET_NAK;
break;
}
*data++ = usb_get_modem_lines(s) | 1;
if (s->event_trigger && s->event_trigger & FTDI_BI) {
s->event_trigger &= ~FTDI_BI;
*data = FTDI_BI;
ret = 2;
break;
} else {
*data++ = 0;
}
len -= 2;
if (len > s->recv_used)
len = s->recv_used;
if (!len) {
ret = USB_RET_NAK;
break;
}
if (first_len > len)
first_len = len;
memcpy(data, s->recv_buf + s->recv_ptr, first_len);
if (len > first_len)
memcpy(data + first_len, s->recv_buf, len - first_len);
s->recv_used -= len;
s->recv_ptr = (s->recv_ptr + len) % RECV_BUF;
ret = len + 2;
break;
default:
DPRINTF("Bad token\n");
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| 1threat
|
Understanding _ids array in CakePHP model data : <p>Using CakePHP v3.1 w/ Postgres DB. When I retrieve records with associations I often see an extra array of <code>_ids</code>. Something like this:</p>
<pre><code> ...
(int) 26 => [
'agency_id' => (int) 23,
'routes' => [
'_ids' => (int) 2
]
]
</code></pre>
<p>Or sometimes:</p>
<pre><code> '_ids' => Array (
0 => 1
1 => 5
2 => 3
3 => 4
)
]
</code></pre>
<p>I would like to understand:</p>
<ol>
<li>How and why do these magic <code>_ids</code> appear?</li>
<li>Is there a way to control or prevent that behavior?</li>
</ol>
| 0debug
|
Having services in React application : <p>I'm coming from the angular world where I could extract logic to a service/factory and consume them in my controllers.</p>
<p>I'm trying to understand how can I achieve the same in a React application.</p>
<p>Let's say that I have a component that validates user's password input (it's strength). It's logic is pretty complex hence I don't want to write it in the component it self.</p>
<p>Where should I write this logic? In a store if I'm using flux? Or is there a better option?</p>
| 0debug
|
Missing Marketing Icon : <p>When trying to submit my app, iTunes Connect says</p>
<blockquote>
<p>Missing Marketing Icon. iOS Apps must include a 1024x1024px Marketing Icon in PNG format. Apps that do not include the Marketing Icon cannot be submitted for App Review or Beta App Review.</p>
</blockquote>
<p>I do have a 1024x1024px PNG in my submission in iTunes Connect, under <code>General App Information</code> and <code>App Icon</code>. So I guess they want me to add it as an Asset to the bundle, in Xcode. But when I drag and drop my PNG to this <code>Unassigned</code> placeholder, nothing happens.</p>
<p><a href="https://i.stack.imgur.com/SeYI7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SeYI7.png" alt="Unassigned placeholder for Marketing 1024x PNG"></a></p>
<p>This error started appearing after WWDC 2017 and I installed XCode 9 Beta. This issue is occuring in Version 8.3.1 (8E1000a) too though.</p>
| 0debug
|
Looping through Arrays : I am trying to write a program to simulate an airline reservation system. I an supposed to use an array of type boolean to represent the number of seats. First five seats represent first class and last five represent economy. Initially the program must allow the user to make a choice between first class and economy and then his choice is processed as follows:
A user can only be assigned an empty seat in the class he chooses.
Once a class is full, the user is offered the option to move to the next class
If the user agrees to move to the next class a simple boarding pass is printed.
If the user refuses to move to the next class. The time for the next flight is displayed. i would appreciate help on how to loop through the elements of the array to determine whether its true of false. Also i am trying to display the number of seats available in each class before the user makes a selection this is what i've written so far.. My code is far from complete, i acknowledge that, i am a novice programmer please help. Thank you.
import java.util.Scanner;
public class AirlineReservation
{
private boolean[] seats =; // array to hold seating capacity
private String AirlineName; // name of airline
private int[] counter = new int[5]
// constructor to initialize name and seats
public Airline(String name, boolean[] capacity )
{
AirlineName = name;
seats = capacity;
} // end constructor
// method to set the Airline name
public void setName( String name )
{
AirlineName = name; // store the course name
} // end method setCourseName
// method to retreive the course name
public String getName()
{
return AirlineName;
} // end method getName
// display a welcome message to the Airline user
public void displayMessage()
{
// display welcome message to the user
System.out.printf("Welcome to the Self-Service menu for\n%s!\n\n",
getName() );
} // end method displayMessage
// processUserRequest
public void processUserRequest()
{
// output welcome message
displayMessage();
// call methods statusA and StatusB
System.out.printf("\n%s %d:\n%s %d:\n\n",
"Number of available seats in First class category is:", statusA(),
"Number of available seats in Economy is", statusB() );
// call method choice
choice();
// call method determine availability
availability();
// call method boarding pass
boardingPass();
} // end method processUserRequest
public int statusA()
{
for ( int counter = 0; counter <= (seats.length)/2; counter++ )
} // revisit method
// method to ask users choice
public String choice()
{
System.out.printf(" Enter 0 to select First Class or 1 to select Economy:")
Scanner input = new Scanner( System.in );
boolean choice = input.nextBoolean();
} // end method choice
// method to check availability of user request
public String availability()
{
if ( input == 0)
System.out.printf("You have been assigned seat number \t%d", seats[ counter ]);
else
System.out.printf("You have been assigned seat number \t%d", seats[ counter ]);
}
}
| 0debug
|
Karma webpack outputting multiple "webpack: wait until bundle finished" : <p>After the recent releases of webpack 1.14.0 / karma 1.4.0 / karma-webpack 2.2.0, that I now see a lot of these messages when karma starts its webpack build. </p>
<pre><code>webpack: wait until bundle finished:
</code></pre>
<p>Sometimes I see as many as 6-8 of them and they seem to be making the build longer. For example, this:</p>
<pre><code>Hash: 255562a2a96fffe34fae
Version: webpack 1.14.0
Time: 408ms
webpack: bundle is now VALID.
webpack: bundle is now INVALID.
webpack: wait until bundle finished:
webpack: wait until bundle finished:
webpack: wait until bundle finished:
webpack: wait until bundle finished:
webpack: wait until bundle finished:
webpack: wait until bundle finished:
ts-loader: Using typescript@2.1.5 and C:\git\project\tsconfig.json
</code></pre>
<p>So far, it hasn't stopped my build, but at the very least it seems like something is now locking up, if even temporarily. Anyone else seeing this? I'd like to clean this up if it is something on my end, but as I say, my config files haven't changed, yet this has now appeared with the recent flood of releases from the karma/webpack family of products in the last 3 weeks.</p>
<p>My questions are:</p>
<ol>
<li>What does this message mean?</li>
<li>What can be done to fix the issue creating them?</li>
</ol>
| 0debug
|
React native TouchableOpacity onPress not working on Android : <p>TouchabelOpacity works fine on iOS but the onPress method does not work on Android for me. </p>
<p>My react-native version: 0.57.4</p>
<p>My code:</p>
<pre><code>const initDrawer = navigation => (
<TouchableOpacity
style={{ left: 16 }}
onPress={() => onPressDrawerButton(navigation)}
>
<Ionicons name="ios-menu" color="white" size={30} />
</TouchableOpacity>
);
</code></pre>
| 0debug
|
How can I select these green color values and paste it in a single separate column? : These are the multiple choice answers, green one are the correct ones. I want only green answeres in the 5th column. Please suggest some way.
[Click here for image][1]
[1]: https://i.stack.imgur.com/PewzC.png
| 0debug
|
Change divs width/height dinamically : <p>Hi stackoverflow community! I'm making some practice with css/html5 "copying" other websites layouts and stuff to learn and understand how things works.</p>
<p>Now I'm get into this website codepen.io/picks/10/ where the divs after "Picked Pens" change their size dinamically if i resize my browser. So my question is: what is the "magic" behind this thing?
I'm not looking for any code but just some stuff to study to understand how this kind of things works.</p>
| 0debug
|
static int ds1338_init(I2CSlave *i2c)
{
return 0;
}
| 1threat
|
static target_ulong h_enter(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
CPUPPCState *env = &cpu->env;
target_ulong flags = args[0];
target_ulong pte_index = args[1];
target_ulong pteh = args[2];
target_ulong ptel = args[3];
target_ulong page_shift = 12;
target_ulong raddr;
target_ulong i;
hwaddr hpte;
if (pteh & HPTE64_V_LARGE) {
#if 0
if ((ptel & 0xf000) == 0x1000) {
} else
#endif
if ((ptel & 0xff000) == 0) {
page_shift = 24;
if (pteh & 0x80) {
return H_PARAMETER;
}
} else {
return H_PARAMETER;
}
}
raddr = (ptel & HPTE64_R_RPN) & ~((1ULL << page_shift) - 1);
if (raddr < spapr->ram_limit) {
if ((ptel & HPTE64_R_WIMG) != HPTE64_R_M) {
return H_PARAMETER;
}
} else {
if ((ptel & (HPTE64_R_W | HPTE64_R_I | HPTE64_R_M)) != HPTE64_R_I) {
return H_PARAMETER;
}
}
pteh &= ~0x60ULL;
if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
return H_PARAMETER;
}
if (likely((flags & H_EXACT) == 0)) {
pte_index &= ~7ULL;
hpte = pte_index * HASH_PTE_SIZE_64;
for (i = 0; ; ++i) {
if (i == 8) {
return H_PTEG_FULL;
}
if ((ppc_hash64_load_hpte0(env, hpte) & HPTE64_V_VALID) == 0) {
break;
}
hpte += HASH_PTE_SIZE_64;
}
} else {
i = 0;
hpte = pte_index * HASH_PTE_SIZE_64;
if (ppc_hash64_load_hpte0(env, hpte) & HPTE64_V_VALID) {
return H_PTEG_FULL;
}
}
ppc_hash64_store_hpte1(env, hpte, ptel);
ppc_hash64_store_hpte0(env, hpte, pteh | HPTE64_V_HPTE_DIRTY);
args[0] = pte_index + i;
return H_SUCCESS;
}
| 1threat
|
Fresh install of Rails and getting OpenSSL errors: "already initialized constant OpenSSL" : <p>I am stuck trying to get going with RoR. I did the Ruby Installfest, but am running into an issue with what I think is openssl.bundle.</p>
<p>I am using RVM, and am running Rails 5.0.1 and Ruby 2.4.0</p>
<p>I tried a full removal/fresh start by using <code>rvm implode</code> and went through and reinstalled everything following <a href="http://railsapps.github.io/installrubyonrails-mac.html" title="RailsApps Guide">RailsApps Guide</a> but am still seeing the identical error. I am running the latest version of macOS Sierra. </p>
<p>This is the output I get when running $Rake -T in my_app. </p>
<pre><code>richsmith@Richs-MacBook-Pro:~/workspace/myapp$ rake -T
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::VERSION
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::OPENSSL_VERSION
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::OPENSSL_LIBRARY_VERSION
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::OPENSSL_VERSION_NUMBER
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::OPENSSL_FIPS
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::Config::DEFAULT_CONFIG_FILE
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::Signer
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::TEXT
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::NOCERTS
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::NOSIGS
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::NOCHAIN
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::NOINTERN
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::NOVERIFY
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::DETACHED
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::BINARY
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::NOATTR
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::NOSMIMECAP
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::ASN1::UNIVERSALSTRING
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::ASN1::CHARACTER_STRING
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::ASN1::BMPSTRING
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/pkey.rb:8: warning: already initialized constant OpenSSL::PKey::DH::DEFAULT_1024
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/pkey.rb:8: warning: previous definition of DEFAULT_1024 was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/pkey.rb:17: warning: already initialized constant OpenSSL::PKey::DH::DEFAULT_2048
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/pkey.rb:17: warning: previous definition of DEFAULT_2048 was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/pkey.rb:30: warning: already initialized constant OpenSSL::PKey::DEFAULT_TMP_DH_CALLBACK
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/pkey.rb:30: warning: previous definition of DEFAULT_TMP_DH_CALLBACK was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:18: warning: constant OpenSSL::Cipher::Cipher is deprecated
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:24: warning: already initialized constant OpenSSL::Cipher::AES
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/cipher.rb:24: warning: previous definition of AES was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:18: warning: constant OpenSSL::Cipher::Cipher is deprecated
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:24: warning: already initialized constant OpenSSL::Cipher::CAST5
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/cipher.rb:24: warning: previous definition of CAST5 was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:18: warning: constant OpenSSL::Cipher::Cipher is deprecated
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:24: warning: already initialized constant OpenSSL::Cipher::BF
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/cipher.rb:24: warning: previous definition of BF was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:18: warning: constant OpenSSL::Cipher::Cipher is deprecated
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:24: warning: already initialized constant OpenSSL::Cipher::DES
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/cipher.rb:24: warning: previous definition of DES was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:18: warning: constant OpenSSL::Cipher::Cipher is deprecated
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:24: warning: already initialized constant OpenSSL::Cipher::IDEA
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/cipher.rb:24: warning: previous definition of IDEA was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:18: warning: constant OpenSSL::Cipher::Cipher is deprecated
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:24: warning: already initialized constant OpenSSL::Cipher::RC2
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/cipher.rb:24: warning: previous definition of RC2 was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:18: warning: constant OpenSSL::Cipher::Cipher is deprecated
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:24: warning: already initialized constant OpenSSL::Cipher::RC4
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/cipher.rb:24: warning: previous definition of RC4 was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:18: warning: constant OpenSSL::Cipher::Cipher is deprecated
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:24: warning: already initialized constant OpenSSL::Cipher::RC5
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/cipher.rb:24: warning: previous definition of RC5 was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:28: warning: constant OpenSSL::Cipher::Cipher is deprecated
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:33: warning: already initialized constant OpenSSL::Cipher::AES128
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/cipher.rb:33: warning: previous definition of AES128 was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:28: warning: constant OpenSSL::Cipher::Cipher is deprecated
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:33: warning: already initialized constant OpenSSL::Cipher::AES192
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/cipher.rb:33: warning: previous definition of AES192 was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:28: warning: constant OpenSSL::Cipher::Cipher is deprecated
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:33: warning: already initialized constant OpenSSL::Cipher::AES256
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/openssl-2.0.3/lib/openssl/cipher.rb:33: warning: previous definition of AES256 was here
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:64: warning: constant OpenSSL::Cipher::Cipher is deprecated
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/openssl/cipher.rb:64: warning: constant OpenSSL::Cipher::Cipher is deprecated
rake aborted!
TypeError: superclass mismatch for class Cipher
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/activesupport-5.0.1/lib/active_support/key_generator.rb:2:in `require'
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/activesupport-5.0.1/lib/active_support/key_generator.rb:2:in `<top (required)>'
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/railties-5.0.1/lib/rails/application.rb:4:in `require'
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/railties-5.0.1/lib/rails/application.rb:4:in `<top (required)>'
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/railties-5.0.1/lib/rails.rb:11:in `require'
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/railties-5.0.1/lib/rails.rb:11:in `<top (required)>'
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/railties-5.0.1/lib/rails/all.rb:1:in `require'
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/railties-5.0.1/lib/rails/all.rb:1:in `<top (required)>'
/Users/richsmith/workspace/myapp/config/application.rb:3:in `require'
/Users/richsmith/workspace/myapp/config/application.rb:3:in `<top (required)>'
/Users/richsmith/workspace/myapp/Rakefile:4:in `require_relative'
/Users/richsmith/workspace/myapp/Rakefile:4:in `<top (required)>'
/Users/richsmith/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)
</code></pre>
| 0debug
|
static av_cold int asink_init(AVFilterContext *ctx, const char *args, void *opaque)
{
BufferSinkContext *buf = ctx->priv;
AVABufferSinkParams *params;
if (!opaque) {
av_log(ctx, AV_LOG_ERROR,
"No opaque field provided, an AVABufferSinkParams struct is required\n");
return AVERROR(EINVAL);
} else
params = (AVABufferSinkParams *)opaque;
buf->sample_fmts = params->sample_fmts;
buf->channel_layouts = params->channel_layouts;
buf->packing_fmts = params->packing_fmts;
return common_init(ctx);
}
| 1threat
|
Bootstrap button inside input-group : <p>How to make it so that it appears nicely after input page with same height?</p>
<pre><code><div class="input-group">
<input type="text" class="form-control"/>
<button class="input-group-addon" type="submit">
<i class="fa fa-search"></i>
</button>
</div>
</code></pre>
<p>Here is code <a href="http://jsfiddle.net/6mcxdjdr/" rel="noreferrer">http://jsfiddle.net/6mcxdjdr/</a> The first one is original input-group, the second one is something what I am trying to have</p>
| 0debug
|
How to call function properties from other file : <p>There are 2 Files 1.Frontend 2.Backend
In Frontend There is one function pop(), which basically is b = a.get()
and what i want is whenever user type something in entry box it should be printed via backend...</p>
<h1>FRONTEND</h1>
<pre><code>from tkinter import *
import backend
win = Tk()
win.geometry("500x500")
def pop():
b = a.get()
But = Button(text = "CLICK",command = pop)
But.pack()
a = StringVar()
e_1 = Entry(textvariable = a)
e_1.pack()
</code></pre>
<h1>BACKEND</h1>
<pre><code>from frontend import pop
print(b)
</code></pre>
<p>I was expected that whenever use type something in entry box it should be print via backend but i got an error that is "b" is not define..</p>
| 0debug
|
static void dcr_write_pob (void *opaque, int dcrn, uint32_t val)
{
ppc4xx_pob_t *pob;
pob = opaque;
switch (dcrn) {
case POB0_BEAR:
break;
case POB0_BESR0:
case POB0_BESR1:
pob->besr[dcrn - POB0_BESR0] &= ~val;
break;
}
}
| 1threat
|
Error setcontentview : I have a problem in android studio. When run aplication in emulator or a device, appear the next error.
11-21 13:20:10.248 1191-1191/com.foca.deboInventario E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.foca.deboInventario/com.foca.deboInventario.DeboInventario}: android.view.InflateException: Binary XML file line #191: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #191: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
at android.app.Activity.setContentView(Activity.java:1867)
at com.foca.deboInventario.DeboInventario.onCreate(DeboInventario.java:162)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
at android.app.Activity.setContentView(Activity.java:1867)
at com.foca.deboInventario.DeboInventario.onCreate(DeboInventario.java:162)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02000e a=-1 r=0x7f02000e}
at android.content.res.Resources.loadDrawable(Resources.java:1897)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.widget.ImageView.<init>(ImageView.java:120)
at android.widget.ImageView.<init>(ImageView.java:110)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
at android.app.Activity.setContentView(Activity.java:1867)
at com.foca.deboInventario.DeboInventario.onCreate(DeboInventario.java:162)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at
dalvik.system.NativeStart.main(Native Method)
11-21 13:20:10.298 152-152/system_process W/ActivityManager: Force finishing activity com.foca.deboInventario/.DeboInventario
11-21 13:20:10.408 1191-1194/com.foca.deboInventario D/dalvikvm: GC_CONCURRENT freed 340K, 4% free 10837K/11271K, paused 20ms+15ms, total 140ms
11-21 13:20:10.738 152-155/system_process D/dalvikvm: GC_CONCURRENT freed 841K, 15% free 17081K/19911K, paused 23ms+24ms, total 296ms
11-21 13:20:10.919 152-166/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{416ab440 com.foca.deboInventario/.DeboInventario}
11-21 13:20:11.008 262-262/com.android.launcher W/EGL_emulation: eglSurfaceAttrib not implemented
11-21 13:20:12.858 1191-1191/? I/Process: Sending signal. PID: 1191 SIG: 9
11-21 13:20:12.868 152-307/system_process I/ActivityManager: Process com.foca.deboInventario (pid 1191) has died.
11-21 13:20:12.928 152-517/system_process W/InputMethodManagerService: Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@415a1258 attribute=null
11-21 13:20:21.248 152-166/system_process W/ActivityManager: Activity destroy timeout for ActivityRecord{416ab440 com.foca.deboInventario/.DeboInventario}
The activity crash in the setContent View.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("Here1");
setContentView(R.layout.xml_deboinventario);
System.out.println("Here2");
The first print appears but the second no.
The xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/fondo_recepcion_inventario" >
I replace android:background with a color but is the same. I clean and build the project again and nothing.
If i generate the apk and install the apk the aplication works.
What is the problem, i have something wrong, some update android studio can modify something in the project?
Thanks
| 0debug
|
Javascript Functions - Calling Two Function In A File : <p>Question: Two Functions Return Different Data But After Calling Both Functions Receive Output From Last Function. Why? </p>
<blockquote>
<p>javascript</p>
</blockquote>
<pre><code>var printStudentInfo = function () {
return 'Name';
}
var printStudentTerritory = function () {
return 'Age';
}
printStudentInfo();
printStudentTerritory();
</code></pre>
| 0debug
|
void qemu_opts_print(QemuOpts *opts, const char *separator)
{
QemuOpt *opt;
QemuOptDesc *desc = opts->list->desc;
const char *sep = "";
if (opts->id) {
printf("id=%s", opts->id);
sep = separator;
}
if (desc[0].name == NULL) {
QTAILQ_FOREACH(opt, &opts->head, next) {
printf("%s%s=", sep, opt->name);
escaped_print(opt->str);
sep = separator;
}
return;
}
for (; desc && desc->name; desc++) {
const char *value;
QemuOpt *opt = qemu_opt_find(opts, desc->name);
value = opt ? opt->str : desc->def_value_str;
if (!value) {
continue;
}
if (desc->type == QEMU_OPT_STRING) {
printf("%s%s=", sep, desc->name);
escaped_print(value);
} else if ((desc->type == QEMU_OPT_SIZE ||
desc->type == QEMU_OPT_NUMBER) && opt) {
printf("%s%s=%" PRId64, sep, desc->name, opt->value.uint);
} else {
printf("%s%s=%s", sep, desc->name, value);
}
sep = separator;
}
}
| 1threat
|
How to properly remove a control from memory, in VB.Net? : <p>Relatively simple problem.</p>
<p>I have a panel with some textboxes on it, all dynamically created.
The user fills in some of the textboxes and then proceeds to close the panel.</p>
<p>Now in the code I use the line;</p>
<pre><code>Me.Pnl_Main.Controls.Clear()
</code></pre>
<p>and this works fine, the panel contents are "removed".</p>
<p>The problem is, is that when the textboxes are recreated for the same purpose, they still contain the values they had previously.</p>
<p>And unfortunately for me, most of the UI is created like this, which inevitably leads to a memory leak.</p>
<p>So my question is, is there a proper way to remove a control completly from memory? Or do I need to run a routine to set all text values to Nothing?</p>
<p>Thanks in advance.</p>
| 0debug
|
how to append to a list in jinja2 for ansible : <p>Below is the jinja2 template that i wrote to use in ansible.</p>
<pre><code>{% set port = 1234 %}
{% set server_ip = [] %}
{% for ip in host_ip %}
{% do server_ip.append({{ ip }}:{{ port }}) %}
{% endfor %}
{% server_ip|join(', ') %}
</code></pre>
<p>Below is the my desired output:</p>
<pre><code>devices = 192.168.56.14:1234,192.168.56.13:1234,192.168.56.10:1234
</code></pre>
<p>But when i am running the ansible playbook, it is throwing the error as below:</p>
<pre><code>"AnsibleError: teme templating string: Encountered unknown tag 'do'. Jinja was looking for th: 'endfor' or 'else'
</code></pre>
<p>Any help would be appreciated..</p>
| 0debug
|
Can code that doesn't execute cause segmentation fault? : <p>I have this piece of code working just fine. Statement in <code>if</code> is true which leads me to printing <code>TRUE</code>. However when I remove the content of <code>else</code> statement, this gives me segmentation fault, even if it doesn't execute (still prints <code>TRUE</code>). </p>
<p>Does anybody have any idea why whould it be that way?</p>
<pre><code>if(parser->checkToken(Token::Type::Int)) {
std::cout << "TRUE" << std::endl;
parser->scanner->getToken().getNumber();
parser->advance();
} else {
std::cout << "FALSE" << std::endl;
parser->requireToken(Token::Type::String);
}
</code></pre>
<p>p.s. parser is unique_ptr</p>
| 0debug
|
PHP Mysql Inbox feature in messaging system : <p>Hello I am saving messages in my mysql database. The columns are </p>
<pre><code>id
sender_id
receiver_id
dateTime
</code></pre>
<p>I want to build an inbox functionality. I don't understand how can I build this feature. I mean sender can be receiver and receiver can be sender. So for example If user id wants to see his messages in the inbox, how can I query it. I mean lets say there are two records with <code>sender_id</code> is 10 and <code>receiver_id</code> is 11 and three records with <code>sender_id</code> is 11 and <code>receiver_id</code> is 10. So now I want is to get single row between two persons conversations so that I can show them in the inbox. Its very difficult to explain but I hope you have understood this</p>
| 0debug
|
static void cpu_openrisc_load_kernel(ram_addr_t ram_size,
const char *kernel_filename,
OpenRISCCPU *cpu)
{
long kernel_size;
uint64_t elf_entry;
hwaddr entry;
if (kernel_filename && !qtest_enabled()) {
kernel_size = load_elf(kernel_filename, NULL, NULL,
&elf_entry, NULL, NULL, 1, ELF_MACHINE, 1);
entry = elf_entry;
if (kernel_size < 0) {
kernel_size = load_uimage(kernel_filename,
&entry, NULL, NULL);
}
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename,
KERNEL_LOAD_ADDR,
ram_size - KERNEL_LOAD_ADDR);
entry = KERNEL_LOAD_ADDR;
}
if (kernel_size < 0) {
fprintf(stderr, "QEMU: couldn't load the kernel '%s'\n",
kernel_filename);
exit(1);
}
}
cpu->env.pc = entry;
}
| 1threat
|
Java - Sort ArrayList of Objects based on another array : I want to sort arraylist of object based on another array using Java 7.
List A ={[id:1,name:"A"],[id:2,name:"B"],[id:3,name:"C"],[id:4,name:"D"]}
Array : {2,4}
Output: {[id:2,name:"B"],[id:4,name:"D"],[id:3,name:"C"],[id:1,name:"A"]}
Something similar to the below question but need to implement the same in Java 7(without Lambda)
https://stackoverflow.com/questions/45030842/sort-arraylist-of-objects-based-on-another-array-java
| 0debug
|
How do I pass variables between stages in a declarative Jenkins pipeline? : <p>How do I pass variables between stages in a declarative pipeline?</p>
<p>In a scripted pipeline, I gather the procedure is to write to a temporary file, then read the file into a variable.</p>
<p>How do I do this in a declarative pipeline?</p>
<p>E.g. I want to trigger a build of a different job, based on a variable created by a shell action.</p>
<pre><code>stage("stage 1") {
steps {
sh "do_something > var.txt"
// I want to get var.txt into VAR
}
}
stage("stage 2") {
steps {
build job: "job2", parameters[string(name: "var", value: "${VAR})]
}
}
</code></pre>
| 0debug
|
PreferenceFragmentCompat custom layout : <p>I need a custom layout for my PreferenceFragmentCompat. In the docs for <a href="http://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat.html#onCreateView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle)" rel="noreferrer">PreferenceFragmentCompat</a> it seems that you can possibly inflate and return a view in onCreateView().</p>
<p>However a NPE results:-</p>
<pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setAdapter(android.support.v7.widget.RecyclerView$Adapter)' on a null object reference
at android.support.v7.preference.PreferenceFragmentCompat.bindPreferences(PreferenceFragmentCompat.java:511)
at android.support.v7.preference.PreferenceFragmentCompat.onActivityCreated(PreferenceFragmentCompat.java:316)
at com.cls.example.MyPrefFrag.onActivityCreated(MyPrefFrag.java:42)
</code></pre>
<p>After I checked the source of PreferenceFragmentCompat:onCreateView I found the following piece of code :-</p>
<pre><code> RecyclerView listView = this.onCreateRecyclerView(themedInflater, listContainer, savedInstanceState);
if(listView == null) {
throw new RuntimeException("Could not create RecyclerView");
} else {
this.mList = listView; //problem
...
return view;
}
</code></pre>
<p>So if you override onCreateView() and return a custom layout the onCreateRecyclerView() is not called plus the RecyclerView private field mList will not be set. So the NPE on setAdapter() results.</p>
<p>Should I assume that having a custom layout is not feasible for PreferenceFragmentCompat ?</p>
| 0debug
|
static unsigned int dec_abs_r(DisasContext *dc)
{
TCGv t0;
DIS(fprintf (logfile, "abs $r%u, $r%u\n",
dc->op1, dc->op2));
cris_cc_mask(dc, CC_MASK_NZ);
t0 = tcg_temp_new(TCG_TYPE_TL);
tcg_gen_sari_tl(t0, cpu_R[dc->op1], 31);
tcg_gen_xor_tl(cpu_R[dc->op2], cpu_R[dc->op1], t0);
tcg_gen_sub_tl(cpu_R[dc->op2], cpu_R[dc->op2], t0);
tcg_temp_free(t0);
cris_alu(dc, CC_OP_MOVE,
cpu_R[dc->op2], cpu_R[dc->op2], cpu_R[dc->op2], 4);
return 2;
}
| 1threat
|
static int ac3_parse_sync_info(AC3DecodeContext *ctx)
{
ac3_sync_info *sync_info = &ctx->sync_info;
GetBitContext *gb = &ctx->gb;
sync_info->sync_word = get_bits(gb, 16);
sync_info->crc1 = get_bits(gb, 16);
sync_info->fscod = get_bits(gb, 2);
if (sync_info->fscod == 0x03)
return -1;
sync_info->frmsizecod = get_bits(gb, 6);
if (sync_info->frmsizecod >= 0x38)
return -1;
sync_info->sampling_rate = ac3_freqs[sync_info->fscod];
sync_info->bit_rate = ac3_bitratetab[sync_info->frmsizecod >> 1];
return 0;
}
| 1threat
|
call function in another aws lambda using existing call : Please refer the code snippet below:
import awsgi
import json
from flask import (
Flask,
jsonify,
request
)
app = Flask(__name__)
@app.route('/')
def index():
return jsonify(status=200, message='OK')
@app.route('/tester')
def tst():
rule = request.url_rule
if 'tester' in rule.rule:
return {'status':200, 'message':'test'}
def lambda_handler(event, context):
test = (awsgi.response(app, event, context))
for key, value in test.items():
if key == 'message':
call = value
return {
'body': json.dumps(test)
}
Now in call variable we have value 'test'.
This 'test' is also the name of a method in another lambda that I want to call.
can someone please help me with this
Thanking You
| 0debug
|
Error System.OverflowException: Value was either too large or too small for an Int32 : <pre><code> protected void Button3_Click(object sender, EventArgs e)
{
UserStore<IdentityUser> userStore = new UserStore<IdentityUser>();
userStore.Context.Database.Connection.ConnectionString =
System.Configuration.ConfigurationManager.ConnectionStrings
["db1ConnectionString"].ConnectionString;
UserManager<IdentityUser> manager = new UserManager<IdentityUser>
(userStore);
//create new user and try to store in db
IdentityUser user = new IdentityUser();
user.UserName = txtUserName.Text;
user.Email = txtEmail.Text;
user.PhoneNumber = txtPhNo.Text;
if (txtPassword.Text == txtConfirmPassword.Text)
{
try
{
//create user object.
//DB will be created /expanded automatically.
IdentityResult result = manager.Create(user, txtPassword.Text);
if (result.Succeeded)
{
**UserInformation1 info = new UserInformation1
{
Address = txtAddress.Text,
FirstName = txtFirstName.Text,
LastName = txtLastName.Text,
PostalCode = Convert.ToInt32(txtPostalCode.Text),
PhoneNo = Convert.ToInt32(txtPhNo.Text),
Email = user.Email,
GUID = user.Id
};
UserInfoModel model = new UserInfoModel();
model.InsertUserInformation(info);**
//store user in db
var authenticationManager =
HttpContext.Current.GetOwinContext().Authentication;
//set to log in new user by cookie
var userIdentity = manager.CreateIdentity(user,
DefaultAuthenticationTypes.ApplicationCookie);
//log in the new user and redirect to homepage
authenticationManager.SignIn(new
Microsoft.Owin.Security.AuthenticationProperties(), userIdentity);
Response.Redirect("~/Pages/greetings_home.aspx");
}
else
{
litStatus.Text = result.Errors.FirstOrDefault();
}
}
catch (Exception ex)
{
litStatus.Text = ex.ToString();
}
}
else
{
litStatus.Text = "Password must match";
}
}
</code></pre>
<p>error:
System.OverflowException: Value was either too large or too small for an Int32. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Convert.ToInt32(String value) at Pages_register.Button3_Click(Object sender, EventArgs e) in c:\Users\shreya\Documents\Visual Studio 2015\Project_Greetings\Pages\register.aspx.cs:line 38
My model class</p>
<pre><code>public partial class UserInformation1
{
public int Id { get; set; }
public string GUID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Address { get; set; }
public Int32 PostalCode { get; set; }
public Int32 PhoneNo { get; set; }
public string Email { get; set; }
}
</code></pre>
<p>Any Solution for this error</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.