problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void mips_cps_realize(DeviceState *dev, Error **errp)
{
MIPSCPSState *s = MIPS_CPS(dev);
CPUMIPSState *env;
MIPSCPU *cpu;
int i;
Error *err = NULL;
target_ulong gcr_base;
bool itu_present = false;
for (i = 0; i < s->num_vp; i++) {
cpu = cpu_mips_init(s->cpu_model);
if (cpu == NULL) {
error_setg(errp, "%s: CPU initialization failed\n", __func__);
return;
}
cpu_mips_irq_init_cpu(cpu);
cpu_mips_clock_init(cpu);
env = &cpu->env;
if (cpu_mips_itu_supported(env)) {
itu_present = true;
env->itc_tag = mips_itu_get_tag_region(&s->itu);
}
qemu_register_reset(main_cpu_reset, cpu);
}
cpu = MIPS_CPU(first_cpu);
env = &cpu->env;
if (itu_present) {
object_initialize(&s->itu, sizeof(s->itu), TYPE_MIPS_ITU);
qdev_set_parent_bus(DEVICE(&s->itu), sysbus_get_default());
object_property_set_int(OBJECT(&s->itu), 16, "num-fifo", &err);
object_property_set_int(OBJECT(&s->itu), 16, "num-semaphores", &err);
object_property_set_bool(OBJECT(&s->itu), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
memory_region_add_subregion(&s->container, 0,
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->itu), 0));
}
object_initialize(&s->cpc, sizeof(s->cpc), TYPE_MIPS_CPC);
qdev_set_parent_bus(DEVICE(&s->cpc), sysbus_get_default());
object_property_set_int(OBJECT(&s->cpc), s->num_vp, "num-vp", &err);
object_property_set_int(OBJECT(&s->cpc), 1, "vp-start-running", &err);
object_property_set_bool(OBJECT(&s->cpc), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
memory_region_add_subregion(&s->container, 0,
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->cpc), 0));
object_initialize(&s->gic, sizeof(s->gic), TYPE_MIPS_GIC);
qdev_set_parent_bus(DEVICE(&s->gic), sysbus_get_default());
object_property_set_int(OBJECT(&s->gic), s->num_vp, "num-vp", &err);
object_property_set_int(OBJECT(&s->gic), 128, "num-irq", &err);
object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
memory_region_add_subregion(&s->container, 0,
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gic), 0));
gcr_base = env->CP0_CMGCRBase << 4;
object_initialize(&s->gcr, sizeof(s->gcr), TYPE_MIPS_GCR);
qdev_set_parent_bus(DEVICE(&s->gcr), sysbus_get_default());
object_property_set_int(OBJECT(&s->gcr), s->num_vp, "num-vp", &err);
object_property_set_int(OBJECT(&s->gcr), 0x800, "gcr-rev", &err);
object_property_set_int(OBJECT(&s->gcr), gcr_base, "gcr-base", &err);
object_property_set_link(OBJECT(&s->gcr), OBJECT(&s->gic.mr), "gic", &err);
object_property_set_link(OBJECT(&s->gcr), OBJECT(&s->cpc.mr), "cpc", &err);
object_property_set_bool(OBJECT(&s->gcr), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
memory_region_add_subregion(&s->container, gcr_base,
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gcr), 0));
}
| 1threat
|
How to save decimal numbers that add up in savedPreferences? : The time i dealt with whole numbers (1,2,3,4...) i was able to save the scores using the following code in java:
pointsAmount = pointsAmount +10;
pointsAvailable.setText("C."+pointsAmount);
SharedPreferences saveCoins = this.getSharedPreferences("mySaverCoins", Context.MODE_PRIVATE);
saveCoins.edit().putInt("C.",pointsAmount).commit();
I can add 10 points and they add up and save in Saved Preferences, even if i close and open app again my points are always there with this code.
Now i want the `pointsAmount` to be a decimal number `+0.05`. Using the same code with above is not permitting, it is giving me errors. So I used the following code to save coins with decimal numbers. Now the error is, My Coins disappear when i close and reopen the app again:
pointsAmount = (pointsAmount +0.05);
pointsAmount .setText("C."+pointsAmount );
SharedPreferences saveCoins = this.getSharedPreferences("mySaverCoins", Context.MODE_PRIVATE);
saveCoins.edit().putInt("C.",(int)pointsAmount).apply();
SharedPreferences.Editor editor= saveCoins.edit();
editor.putString("mySaverCoins", "mySaverCoins");
editor.commit();
I want my coins to be saved when i wake up the app after closing it. What is the problem with my code?
| 0debug
|
static int parse_bootdevices(char *devices)
{
const char *p;
int bitmap = 0;
for (p = devices; *p != '\0'; p++) {
if (*p < 'a' || *p > 'p') {
fprintf(stderr, "Invalid boot device '%c'\n", *p);
exit(1);
}
if (bitmap & (1 << (*p - 'a'))) {
fprintf(stderr, "Boot device '%c' was given twice\n", *p);
exit(1);
}
bitmap |= 1 << (*p - 'a');
}
return bitmap;
}
| 1threat
|
Filtering files with the given range of inputin perl : <p>The perl script which takes an input i.e name of the file, I need to find all the files that matches with that pattern.</p>
<pre><code>Example: given input as 2019052300 2019052323 (YYYYMMDDHH)
</code></pre>
<p>Here, I need to fetch all the files that named with 2019052300 to 2019052323. like 2019052300,2019052301.. 2019052323.</p>
<p>Thanks!</p>
| 0debug
|
static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len)
{
struct VirtIOSerialPort *port;
struct virtio_console_control cpkt, *gcpkt;
uint8_t *buffer;
size_t buffer_len;
gcpkt = buf;
if (len < sizeof(cpkt)) {
return;
}
cpkt.event = lduw_p(&gcpkt->event);
cpkt.value = lduw_p(&gcpkt->value);
port = find_port_by_id(vser, ldl_p(&gcpkt->id));
if (!port && cpkt.event != VIRTIO_CONSOLE_DEVICE_READY)
return;
switch(cpkt.event) {
case VIRTIO_CONSOLE_DEVICE_READY:
if (!cpkt.value) {
error_report("virtio-serial-bus: Guest failure in adding device %s\n",
vser->bus.qbus.name);
break;
}
QTAILQ_FOREACH(port, &vser->ports, next) {
send_control_event(port, VIRTIO_CONSOLE_PORT_ADD, 1);
}
break;
case VIRTIO_CONSOLE_PORT_READY:
if (!cpkt.value) {
error_report("virtio-serial-bus: Guest failure in adding port %u for device %s\n",
port->id, vser->bus.qbus.name);
break;
}
if (port->is_console) {
send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1);
}
if (port->name) {
stw_p(&cpkt.event, VIRTIO_CONSOLE_PORT_NAME);
stw_p(&cpkt.value, 1);
buffer_len = sizeof(cpkt) + strlen(port->name) + 1;
buffer = qemu_malloc(buffer_len);
memcpy(buffer, &cpkt, sizeof(cpkt));
memcpy(buffer + sizeof(cpkt), port->name, strlen(port->name));
buffer[buffer_len - 1] = 0;
send_control_msg(port, buffer, buffer_len);
qemu_free(buffer);
}
if (port->host_connected) {
send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 1);
}
if (port->info->guest_ready) {
port->info->guest_ready(port);
}
break;
case VIRTIO_CONSOLE_PORT_OPEN:
port->guest_connected = cpkt.value;
if (cpkt.value && port->info->guest_open) {
port->info->guest_open(port);
}
if (!cpkt.value && port->info->guest_close) {
port->info->guest_close(port);
}
break;
}
}
| 1threat
|
static void legacy_mouse_event(DeviceState *dev, QemuConsole *src,
InputEvent *evt)
{
static const int bmap[INPUT_BUTTON__MAX] = {
[INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON,
[INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,
[INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
};
QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)dev;
InputBtnEvent *btn;
InputMoveEvent *move;
switch (evt->type) {
case INPUT_EVENT_KIND_BTN:
btn = evt->u.btn;
if (btn->down) {
s->buttons |= bmap[btn->button];
} else {
s->buttons &= ~bmap[btn->button];
}
if (btn->down && btn->button == INPUT_BUTTON_WHEEL_UP) {
s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
s->axis[INPUT_AXIS_X],
s->axis[INPUT_AXIS_Y],
-1,
s->buttons);
}
if (btn->down && btn->button == INPUT_BUTTON_WHEEL_DOWN) {
s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
s->axis[INPUT_AXIS_X],
s->axis[INPUT_AXIS_Y],
1,
s->buttons);
}
break;
case INPUT_EVENT_KIND_ABS:
move = evt->u.abs;
s->axis[move->axis] = move->value;
break;
case INPUT_EVENT_KIND_REL:
move = evt->u.rel;
s->axis[move->axis] += move->value;
break;
default:
break;
}
}
| 1threat
|
PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
qemu_irq *p_rtc_irq,
AlphaCPU *cpus[4], pci_map_irq_fn sys_map_irq)
{
const uint64_t MB = 1024 * 1024;
const uint64_t GB = 1024 * MB;
MemoryRegion *addr_space = get_system_memory();
MemoryRegion *addr_space_io = get_system_io();
DeviceState *dev;
TyphoonState *s;
PCIHostState *phb;
PCIBus *b;
int i;
dev = qdev_create(NULL, TYPE_TYPHOON_PCI_HOST_BRIDGE);
qdev_init_nofail(dev);
s = TYPHOON_PCI_HOST_BRIDGE(dev);
phb = PCI_HOST_BRIDGE(dev);
for (i = 0; i < 4; i++) {
AlphaCPU *cpu = cpus[i];
s->cchip.cpu[i] = cpu;
if (cpu != NULL) {
CPUAlphaState *env = &cpu->env;
env->alarm_timer = qemu_new_timer_ns(rtc_clock,
typhoon_alarm_timer,
(void *)((uintptr_t)s + i));
}
}
*p_rtc_irq = *qemu_allocate_irqs(typhoon_set_timer_irq, s, 1);
memory_region_init_ram(&s->ram_region, "ram", ram_size);
vmstate_register_ram_global(&s->ram_region);
memory_region_add_subregion(addr_space, 0, &s->ram_region);
memory_region_init_io(&s->pchip.region, &pchip_ops, s, "pchip0", 256*MB);
memory_region_add_subregion(addr_space, 0x80180000000ULL,
&s->pchip.region);
memory_region_init_io(&s->cchip.region, &cchip_ops, s, "cchip0", 256*MB);
memory_region_add_subregion(addr_space, 0x801a0000000ULL,
&s->cchip.region);
memory_region_init_io(&s->dchip_region, &dchip_ops, s, "dchip0", 256*MB);
memory_region_add_subregion(addr_space, 0x801b0000000ULL,
&s->dchip_region);
memory_region_init(&s->pchip.reg_mem, "pci0-mem", 4*GB);
memory_region_add_subregion(addr_space, 0x80000000000ULL,
&s->pchip.reg_mem);
memory_region_init_io(&s->pchip.reg_io, &alpha_pci_bw_io_ops, NULL,
"pci0-io", 32*MB);
memory_region_add_subregion(addr_space, 0x801fc000000ULL,
&s->pchip.reg_io);
b = pci_register_bus(dev, "pci",
typhoon_set_irq, sys_map_irq, s,
&s->pchip.reg_mem, addr_space_io, 0, 64);
phb->bus = b;
memory_region_init_io(&s->pchip.reg_iack, &alpha_pci_iack_ops, b,
"pci0-iack", 64*MB);
memory_region_add_subregion(addr_space, 0x801f8000000ULL,
&s->pchip.reg_iack);
memory_region_init_io(&s->pchip.reg_conf, &alpha_pci_conf1_ops, b,
"pci0-conf", 16*MB);
memory_region_add_subregion(addr_space, 0x801fe000000ULL,
&s->pchip.reg_conf);
{
qemu_irq isa_pci_irq, *isa_irqs;
*isa_bus = isa_bus_new(NULL, addr_space_io);
isa_pci_irq = *qemu_allocate_irqs(typhoon_set_isa_irq, s, 1);
isa_irqs = i8259_init(*isa_bus, isa_pci_irq);
isa_bus_irqs(*isa_bus, isa_irqs);
}
return b;
}
| 1threat
|
Debug puppeteer : <p>Is there some way to debug a puppeteer script? One of the buttons just doesn't get clicked for some reason. I've tried all different ways, and actually in another script I get it clicked, but in this one I don't.</p>
<pre><code>await page.focus('#outer-container > nav > span.right > span.search-notification-wrapper > span > form > input[type="text"]');
await page.type("Some text");
await page.click('#outer-container > nav > span.right > span.search-notification-wrapper > span > form'); // I am clicking on the form because it did work in the other script
</code></pre>
| 0debug
|
static int alloc_refcount_block(BlockDriverState *bs,
int64_t cluster_index, uint16_t **refcount_block)
{
BDRVQcowState *s = bs->opaque;
unsigned int refcount_table_index;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC);
refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
if (refcount_table_index < s->refcount_table_size) {
uint64_t refcount_block_offset =
s->refcount_table[refcount_table_index];
if (refcount_block_offset) {
return load_refcount_block(bs, refcount_block_offset,
(void**) refcount_block);
}
}
*refcount_block = NULL;
qcow2_cache_flush(bs, s->l2_table_cache);
int64_t new_block = alloc_clusters_noref(bs, s->cluster_size);
if (new_block < 0) {
return new_block;
}
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64
" at %" PRIx64 "\n",
refcount_table_index, cluster_index << s->cluster_bits, new_block);
#endif
if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) {
ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
(void**) refcount_block);
if (ret < 0) {
goto fail_block;
}
memset(*refcount_block, 0, s->cluster_size);
int block_index = (new_block >> s->cluster_bits) &
((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
(*refcount_block)[block_index] = cpu_to_be16(1);
} else {
ret = update_refcount(bs, new_block, s->cluster_size, 1);
if (ret < 0) {
goto fail_block;
}
bdrv_flush(bs->file);
ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
(void**) refcount_block);
if (ret < 0) {
goto fail_block;
}
memset(*refcount_block, 0, s->cluster_size);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
qcow2_cache_entry_mark_dirty(s->refcount_block_cache, *refcount_block);
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
goto fail_block;
}
if (refcount_table_index < s->refcount_table_size) {
uint64_t data64 = cpu_to_be64(new_block);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP);
ret = bdrv_pwrite_sync(bs->file,
s->refcount_table_offset + refcount_table_index * sizeof(uint64_t),
&data64, sizeof(data64));
if (ret < 0) {
goto fail_block;
}
s->refcount_table[refcount_table_index] = new_block;
return 0;
}
ret = qcow2_cache_put(bs, s->refcount_block_cache, (void**) refcount_block);
if (ret < 0) {
goto fail_block;
}
BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_GROW);
uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT);
uint64_t blocks_used = (s->free_cluster_index +
refcount_block_clusters - 1) / refcount_block_clusters;
uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
uint64_t last_table_size;
uint64_t blocks_clusters;
do {
uint64_t table_clusters = size_to_clusters(s, table_size);
blocks_clusters = 1 +
((table_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters);
uint64_t meta_clusters = table_clusters + blocks_clusters;
last_table_size = table_size;
table_size = next_refcount_table_size(s, blocks_used +
((meta_clusters + refcount_block_clusters - 1)
/ refcount_block_clusters));
} while (last_table_size != table_size);
#ifdef DEBUG_ALLOC2
fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
s->refcount_table_size, table_size);
#endif
uint64_t meta_offset = (blocks_used * refcount_block_clusters) *
s->cluster_size;
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
uint16_t *new_blocks = g_malloc0(blocks_clusters * s->cluster_size);
uint64_t *new_table = g_malloc0(table_size * sizeof(uint64_t));
assert(meta_offset >= (s->free_cluster_index * s->cluster_size));
memcpy(new_table, s->refcount_table,
s->refcount_table_size * sizeof(uint64_t));
new_table[refcount_table_index] = new_block;
int i;
for (i = 0; i < blocks_clusters; i++) {
new_table[blocks_used + i] = meta_offset + (i * s->cluster_size);
}
uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
int block = 0;
for (i = 0; i < table_clusters + blocks_clusters; i++) {
new_blocks[block++] = cpu_to_be16(1);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks,
blocks_clusters * s->cluster_size);
g_free(new_blocks);
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE);
ret = bdrv_pwrite_sync(bs->file, table_offset, new_table,
table_size * sizeof(uint64_t));
if (ret < 0) {
goto fail_table;
}
for(i = 0; i < table_size; i++) {
cpu_to_be64s(&new_table[i]);
}
uint8_t data[12];
cpu_to_be64w((uint64_t*)data, table_offset);
cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset),
data, sizeof(data));
if (ret < 0) {
goto fail_table;
}
uint64_t old_table_offset = s->refcount_table_offset;
uint64_t old_table_size = s->refcount_table_size;
g_free(s->refcount_table);
s->refcount_table = new_table;
s->refcount_table_size = table_size;
s->refcount_table_offset = table_offset;
uint64_t old_free_cluster_index = s->free_cluster_index;
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
s->free_cluster_index = old_free_cluster_index;
ret = load_refcount_block(bs, new_block, (void**) refcount_block);
if (ret < 0) {
return ret;
}
return new_block;
fail_table:
g_free(new_table);
fail_block:
if (*refcount_block != NULL) {
qcow2_cache_put(bs, s->refcount_block_cache, (void**) refcount_block);
}
return ret;
}
| 1threat
|
static void decode_postinit(H264Context *h, int setup_finished)
{
H264Picture *out = h->cur_pic_ptr;
H264Picture *cur = h->cur_pic_ptr;
int i, pics, out_of_order, out_idx;
int invalid = 0, cnt = 0;
h->cur_pic_ptr->f->pict_type = h->pict_type;
if (h->next_output_pic)
return;
if (cur->field_poc[0] == INT_MAX || cur->field_poc[1] == INT_MAX) {
return;
}
cur->f->interlaced_frame = 0;
cur->f->repeat_pict = 0;
if (h->sps.pic_struct_present_flag) {
switch (h->sei_pic_struct) {
case SEI_PIC_STRUCT_FRAME:
break;
case SEI_PIC_STRUCT_TOP_FIELD:
case SEI_PIC_STRUCT_BOTTOM_FIELD:
cur->f->interlaced_frame = 1;
break;
case SEI_PIC_STRUCT_TOP_BOTTOM:
case SEI_PIC_STRUCT_BOTTOM_TOP:
if (FIELD_OR_MBAFF_PICTURE(h))
cur->f->interlaced_frame = 1;
else
cur->f->interlaced_frame = h->prev_interlaced_frame;
break;
case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
cur->f->repeat_pict = 1;
break;
case SEI_PIC_STRUCT_FRAME_DOUBLING:
cur->f->repeat_pict = 2;
break;
case SEI_PIC_STRUCT_FRAME_TRIPLING:
cur->f->repeat_pict = 4;
break;
}
if ((h->sei_ct_type & 3) &&
h->sei_pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP)
cur->f->interlaced_frame = (h->sei_ct_type & (1 << 1)) != 0;
} else {
cur->f->interlaced_frame = FIELD_OR_MBAFF_PICTURE(h);
}
h->prev_interlaced_frame = cur->f->interlaced_frame;
if (cur->field_poc[0] != cur->field_poc[1]) {
cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1];
} else {
if (cur->f->interlaced_frame || h->sps.pic_struct_present_flag) {
if (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM ||
h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)
cur->f->top_field_first = 1;
else
cur->f->top_field_first = 0;
} else {
cur->f->top_field_first = 0;
}
}
if (h->sei_frame_packing_present &&
h->frame_packing_arrangement_type >= 0 &&
h->frame_packing_arrangement_type <= 6 &&
h->content_interpretation_type > 0 &&
h->content_interpretation_type < 3) {
AVStereo3D *stereo = av_stereo3d_create_side_data(cur->f);
if (!stereo)
return;
switch (h->frame_packing_arrangement_type) {
case 0:
stereo->type = AV_STEREO3D_CHECKERBOARD;
break;
case 1:
stereo->type = AV_STEREO3D_COLUMNS;
break;
case 2:
stereo->type = AV_STEREO3D_LINES;
break;
case 3:
if (h->quincunx_subsampling)
stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
else
stereo->type = AV_STEREO3D_SIDEBYSIDE;
break;
case 4:
stereo->type = AV_STEREO3D_TOPBOTTOM;
break;
case 5:
stereo->type = AV_STEREO3D_FRAMESEQUENCE;
break;
case 6:
stereo->type = AV_STEREO3D_2D;
break;
}
if (h->content_interpretation_type == 2)
stereo->flags = AV_STEREO3D_FLAG_INVERT;
}
if (h->sei_display_orientation_present &&
(h->sei_anticlockwise_rotation || h->sei_hflip || h->sei_vflip)) {
double angle = h->sei_anticlockwise_rotation * 360 / (double) (1 << 16);
AVFrameSideData *rotation = av_frame_new_side_data(cur->f,
AV_FRAME_DATA_DISPLAYMATRIX,
sizeof(int32_t) * 9);
if (!rotation)
return;
av_display_rotation_set((int32_t *)rotation->data, angle);
av_display_matrix_flip((int32_t *)rotation->data,
h->sei_hflip, h->sei_vflip);
}
if (h->sps.bitstream_restriction_flag &&
h->avctx->has_b_frames < h->sps.num_reorder_frames) {
h->avctx->has_b_frames = h->sps.num_reorder_frames;
h->low_delay = 0;
}
if (h->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT &&
!h->sps.bitstream_restriction_flag) {
h->avctx->has_b_frames = MAX_DELAYED_PIC_COUNT - 1;
h->low_delay = 0;
}
pics = 0;
while (h->delayed_pic[pics])
pics++;
assert(pics <= MAX_DELAYED_PIC_COUNT);
h->delayed_pic[pics++] = cur;
if (cur->reference == 0)
cur->reference = DELAYED_PIC_REF;
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) {
cnt += out->poc < h->last_pocs[i];
invalid += out->poc == INT_MIN;
}
if (!h->mmco_reset && !cur->f->key_frame &&
cnt + invalid == MAX_DELAYED_PIC_COUNT && cnt > 0) {
h->mmco_reset = 2;
if (pics > 1)
h->delayed_pic[pics - 2]->mmco_reset = 2;
}
if (h->mmco_reset || cur->f->key_frame) {
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
h->last_pocs[i] = INT_MIN;
cnt = 0;
invalid = MAX_DELAYED_PIC_COUNT;
}
out = h->delayed_pic[0];
out_idx = 0;
for (i = 1; i < MAX_DELAYED_PIC_COUNT &&
h->delayed_pic[i] &&
!h->delayed_pic[i - 1]->mmco_reset &&
!h->delayed_pic[i]->f->key_frame;
i++)
if (h->delayed_pic[i]->poc < out->poc) {
out = h->delayed_pic[i];
out_idx = i;
}
if (h->avctx->has_b_frames == 0 &&
(h->delayed_pic[0]->f->key_frame || h->mmco_reset))
h->next_outputed_poc = INT_MIN;
out_of_order = !out->f->key_frame && !h->mmco_reset &&
(out->poc < h->next_outputed_poc);
if (h->sps.bitstream_restriction_flag &&
h->avctx->has_b_frames >= h->sps.num_reorder_frames) {
} else if (out_of_order && pics - 1 == h->avctx->has_b_frames &&
h->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT) {
if (invalid + cnt < MAX_DELAYED_PIC_COUNT) {
h->avctx->has_b_frames = FFMAX(h->avctx->has_b_frames, cnt);
}
h->low_delay = 0;
} else if (h->low_delay &&
((h->next_outputed_poc != INT_MIN &&
out->poc > h->next_outputed_poc + 2) ||
cur->f->pict_type == AV_PICTURE_TYPE_B)) {
h->low_delay = 0;
h->avctx->has_b_frames++;
}
if (pics > h->avctx->has_b_frames) {
out->reference &= ~DELAYED_PIC_REF;
for (i = out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i + 1];
}
memmove(h->last_pocs, &h->last_pocs[1],
sizeof(*h->last_pocs) * (MAX_DELAYED_PIC_COUNT - 1));
h->last_pocs[MAX_DELAYED_PIC_COUNT - 1] = cur->poc;
if (!out_of_order && pics > h->avctx->has_b_frames) {
h->next_output_pic = out;
if (out->mmco_reset) {
if (out_idx > 0) {
h->next_outputed_poc = out->poc;
h->delayed_pic[out_idx - 1]->mmco_reset = out->mmco_reset;
} else {
h->next_outputed_poc = INT_MIN;
}
} else {
if (out_idx == 0 && pics > 1 && h->delayed_pic[0]->f->key_frame) {
h->next_outputed_poc = INT_MIN;
} else {
h->next_outputed_poc = out->poc;
}
}
h->mmco_reset = 0;
} else {
av_log(h->avctx, AV_LOG_DEBUG, "no picture\n");
}
if (h->next_output_pic) {
if (h->next_output_pic->recovered) {
h->frame_recovered |= FRAME_RECOVERED_SEI;
}
h->next_output_pic->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_SEI);
}
if (setup_finished && !h->avctx->hwaccel)
ff_thread_finish_setup(h->avctx);
}
| 1threat
|
static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
int is_write, sigset_t *old_set,
void *puc)
{
TranslationBlock *tb;
int ret;
if (cpu_single_env)
env = cpu_single_env;
#if defined(DEBUG_SIGNAL)
printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
pc, address, is_write, *(unsigned long *)old_set);
#endif
if (is_write && page_unprotect(h2g(address), pc, puc)) {
return 1;
}
ret = cpu_mb_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);
if (ret < 0)
return 0;
if (ret == 0)
return 1;
tb = tb_find_pc(pc);
if (tb) {
cpu_restore_state(tb, env, pc, puc);
}
if (ret == 1) {
#if 0
printf("PF exception: PC=0x" TARGET_FMT_lx " error=0x%x %p\n",
env->PC, env->error_code, tb);
#endif
sigprocmask(SIG_SETMASK, old_set, NULL);
cpu_loop_exit();
} else {
cpu_resume_from_signal(env, puc);
}
return 1;
}
| 1threat
|
static void nvdimm_dsm_set_label_data(NVDIMMDevice *nvdimm, NvdimmDsmIn *in,
hwaddr dsm_mem_addr)
{
NVDIMMClass *nvc = NVDIMM_GET_CLASS(nvdimm);
NvdimmFuncSetLabelDataIn *set_label_data;
uint32_t status;
set_label_data = (NvdimmFuncSetLabelDataIn *)in->arg3;
le32_to_cpus(&set_label_data->offset);
le32_to_cpus(&set_label_data->length);
nvdimm_debug("Write Label Data: offset %#x length %#x.\n",
set_label_data->offset, set_label_data->length);
status = nvdimm_rw_label_data_check(nvdimm, set_label_data->offset,
set_label_data->length);
if (status != 0 ) {
nvdimm_dsm_no_payload(status, dsm_mem_addr);
return;
}
assert(sizeof(*in) + sizeof(*set_label_data) + set_label_data->length <=
4096);
nvc->write_label_data(nvdimm, set_label_data->in_buf,
set_label_data->length, set_label_data->offset);
nvdimm_dsm_no_payload(0 , dsm_mem_addr);
}
| 1threat
|
why is my code not executing? and no clue where i'm going wrong? : Im fairly new to programming - my only experience is in schooling environments, as much as i have done is visual basic
Currently learning C - and i have no clue where i'm going wrong
#include <stdio.h>
int main()
{
char alphabet[20];
int i;
for (int i = 0; i > 20; i++)
{
printf("Enter in a letter:\n");
scanf("%s", alphabet[i]);
if (alphabet[i] == alphabet[i+1])
{
printf("Duplicate Letters");
};
return 0;
}
}
The program that i am asked to make for class - im required to create a 1D array, add validation for alphabetical letters and duplicate letters as well as creating a function for sorting the letters and specifying the number of times each letter was put in
As much as ive been able to attempt coding is
- Create a 1D array to read 20 alphabetical letters
- Add validation for duplicate letters and printf 'Duplicate Letters'
but everytime i try, the program terminates at 'Enter in a letter:' or it wont execute
Where did i go wrong?
For background - I work mainly on windows 7 as thats what the school has - using MinGW as my compiler, but for working at home i use MacOS using Terminal as the compiler
| 0debug
|
Multiply a string in JS : <p>i want to display a string as many times I have a generated variable. Therefore I'd like to do something like that, which doesn't work</p>
<pre><code>var shower_total = 7; // this gets generated, but for simplification...
var uhrzeit = "<p class='clock_item'>Foo</p>";
document.getElementById("uhrzeit_block").innerHTML =5*uhrzeit;
</code></pre>
<p>That's why I tried looping it but that doesn't work neither</p>
<pre><code>document.getElementById("uhrzeit_block").innerHTML =
for(b=0, b <= shower_total; b++){
uhrzeit
};
</code></pre>
<p>What do I do wrong or what would be a possible - beginner-compatible - solution. Thanks!</p>
| 0debug
|
String Encoding Python 2.7 : I have a non-literal string that is programmatically obtained from the title of a printed document online:
"wxPython: Windows Styles and Events Hunter « The Mouse Vs. The Python" # retrieved string
I am trying to put it in to a database which does not accept non-ASCII characters and it always throws exceptions every attempt I make to `encode` and `decode` with `UTF-8` encoding. Any suggestions?
| 0debug
|
BdrvNextIterator *bdrv_next(BdrvNextIterator *it, BlockDriverState **bs)
{
if (!it) {
it = g_new(BdrvNextIterator, 1);
*it = (BdrvNextIterator) {
.phase = BDRV_NEXT_BACKEND_ROOTS,
};
}
if (it->phase == BDRV_NEXT_BACKEND_ROOTS) {
do {
it->blk = blk_all_next(it->blk);
*bs = it->blk ? blk_bs(it->blk) : NULL;
} while (it->blk && (*bs == NULL || bdrv_first_blk(*bs) != it->blk));
if (*bs) {
return it;
}
it->phase = BDRV_NEXT_MONITOR_OWNED;
}
do {
it->bs = bdrv_next_monitor_owned(it->bs);
*bs = it->bs;
} while (*bs && bdrv_has_blk(*bs));
return *bs ? it : NULL;
}
| 1threat
|
How to generate a cryptographically secure random integer within a range? : <p>I have to generate a uniform, secure random integer within a given range for a program that generates passwords. Right now I use this :</p>
<pre><code>RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
byte[] rand = new byte[4];
rng.GetBytes(rand);
int i = BitConverter.ToUInt16(rand, 0);
int result = i%max; //max is the range's upper bound (the lower is 0)
</code></pre>
<p>Is this method safe to use for cryptographic purposes ? If not, how should I do it ?</p>
| 0debug
|
Is It possible to create class name starts with digits in c++ : <p>I need to create a class name starting with digits as 206xx.if it is possible to create then how to achieve this.</p>
| 0debug
|
Find an exact length match in a string using regex in python : <p>How can I match the string which starts with C88 and ends with 03D using regex in Python from the text below:</p>
<pre><code>0:d=0 hl=4 l= 266 cons: SEQUENCE
4:d=1 hl=4 l= 257 prim: INTEGER :C88C87D325BFC86211ED38A05F04F90A92F252E9D6E5425D54F1B27F3888F95B123BFBB634864DEDF0A6B8636830B6AB70011C6B4C6D8368BCD6FC72D1C341B97130737F0BA520D4C44982EA4554AE19CD54F21DA48ECF634C38E3586253FFC815633510FA4FA8B7B1E07E4E2EABF48603EDFB2E53DFA6CC1F894F892B742B84A2CEA29837B1047D7CC401365B3091B6C7DED09CD3BFECD8EAF66F198A80B27DB9DB334CAE200410AE984D3CE413D8BA04833AB5CE7B7FA43CC848143F82B542343D537E4C79DB30FDFDB66B01259CACE9C3D430A38574F3A09278DD4263CACB8A12175CE7A082FBA63A565F31CBA2176C710008C1781E50C5270FE18142B03D
265:d=1 hl=2 l= 3 prim: INTEGER :010001
</code></pre>
<p>As it is clearly seen, there are also some whitespace between the string and the keyword 'INTEGER'. If needed, we know the exact length of the match which is 512 characters.</p>
| 0debug
|
static void ipmi_sim_handle_command(IPMIBmc *b,
uint8_t *cmd, unsigned int cmd_len,
unsigned int max_cmd_len,
uint8_t msg_id)
{
IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(b);
IPMIInterface *s = ibs->parent.intf;
IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);
unsigned int netfn;
uint8_t rsp[MAX_IPMI_MSG_SIZE];
unsigned int rsp_len_holder = 0;
unsigned int *rsp_len = &rsp_len_holder;
unsigned int max_rsp_len = sizeof(rsp);
if (max_rsp_len < 3) {
rsp[2] = IPMI_CC_REQUEST_DATA_TRUNCATED;
goto out;
}
IPMI_ADD_RSP_DATA(cmd[0] | 0x04);
IPMI_ADD_RSP_DATA(cmd[1]);
IPMI_ADD_RSP_DATA(0);
if (cmd_len < 2) {
rsp[2] = IPMI_CC_REQUEST_DATA_LENGTH_INVALID;
goto out;
}
if (cmd_len > max_cmd_len) {
rsp[2] = IPMI_CC_REQUEST_DATA_TRUNCATED;
goto out;
}
if ((cmd[0] & 0x03) != 0) {
rsp[2] = IPMI_CC_COMMAND_INVALID_FOR_LUN;
goto out;
}
netfn = cmd[0] >> 2;
if ((netfn & 1) || !ibs->netfns[netfn / 2] ||
(cmd[1] >= ibs->netfns[netfn / 2]->cmd_nums) ||
(!ibs->netfns[netfn / 2]->cmd_handlers[cmd[1]])) {
rsp[2] = IPMI_CC_INVALID_CMD;
goto out;
}
ibs->netfns[netfn / 2]->cmd_handlers[cmd[1]](ibs, cmd, cmd_len, rsp, rsp_len,
max_rsp_len);
out:
k->handle_rsp(s, msg_id, rsp, *rsp_len);
next_timeout(ibs);
}
| 1threat
|
static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr,
SpectrumParameters *spectrum)
{
unsigned int temp, max_qmf_subbands;
unsigned int start_min, stop_min;
int k;
const int8_t *sbr_offset_ptr;
int16_t stop_dk[13];
if (sbr->sample_rate < 32000) {
temp = 3000;
} else if (sbr->sample_rate < 64000) {
temp = 4000;
} else
temp = 5000;
switch (sbr->sample_rate) {
case 16000:
sbr_offset_ptr = sbr_offset[0];
break;
case 22050:
sbr_offset_ptr = sbr_offset[1];
break;
case 24000:
sbr_offset_ptr = sbr_offset[2];
break;
case 32000:
sbr_offset_ptr = sbr_offset[3];
break;
case 44100: case 48000: case 64000:
sbr_offset_ptr = sbr_offset[4];
break;
case 88200: case 96000: case 128000: case 176400: case 192000:
sbr_offset_ptr = sbr_offset[5];
break;
default:
av_log(ac->avctx, AV_LOG_ERROR,
"Unsupported sample rate for SBR: %d\n", sbr->sample_rate);
return -1;
}
start_min = ((temp << 7) + (sbr->sample_rate >> 1)) / sbr->sample_rate;
stop_min = ((temp << 8) + (sbr->sample_rate >> 1)) / sbr->sample_rate;
sbr->k[0] = start_min + sbr_offset_ptr[spectrum->bs_start_freq];
if (spectrum->bs_stop_freq < 14) {
sbr->k[2] = stop_min;
make_bands(stop_dk, stop_min, 64, 13);
qsort(stop_dk, 13, sizeof(stop_dk[0]), qsort_comparison_function_int16);
for (k = 0; k < spectrum->bs_stop_freq; k++)
sbr->k[2] += stop_dk[k];
} else if (spectrum->bs_stop_freq == 14) {
sbr->k[2] = 2*sbr->k[0];
} else if (spectrum->bs_stop_freq == 15) {
sbr->k[2] = 3*sbr->k[0];
} else {
av_log(ac->avctx, AV_LOG_ERROR,
"Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq);
return -1;
}
sbr->k[2] = FFMIN(64, sbr->k[2]);
if (sbr->sample_rate <= 32000) {
max_qmf_subbands = 48;
} else if (sbr->sample_rate == 44100) {
max_qmf_subbands = 35;
} else if (sbr->sample_rate >= 48000)
max_qmf_subbands = 32;
if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) {
av_log(ac->avctx, AV_LOG_ERROR,
"Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]);
return -1;
}
if (!spectrum->bs_freq_scale) {
int dk, k2diff;
dk = spectrum->bs_alter_scale + 1;
sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1;
if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
return -1;
for (k = 1; k <= sbr->n_master; k++)
sbr->f_master[k] = dk;
k2diff = sbr->k[2] - sbr->k[0] - sbr->n_master * dk;
if (k2diff < 0) {
sbr->f_master[1]--;
sbr->f_master[2]-= (k2diff < -1);
} else if (k2diff) {
sbr->f_master[sbr->n_master]++;
}
sbr->f_master[0] = sbr->k[0];
for (k = 1; k <= sbr->n_master; k++)
sbr->f_master[k] += sbr->f_master[k - 1];
} else {
int half_bands = 7 - spectrum->bs_freq_scale;
int two_regions, num_bands_0;
int vdk0_max, vdk1_min;
int16_t vk0[49];
if (49 * sbr->k[2] > 110 * sbr->k[0]) {
two_regions = 1;
sbr->k[1] = 2 * sbr->k[0];
} else {
two_regions = 0;
sbr->k[1] = sbr->k[2];
}
num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2;
if (num_bands_0 <= 0) {
av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0);
return -1;
}
vk0[0] = 0;
make_bands(vk0+1, sbr->k[0], sbr->k[1], num_bands_0);
qsort(vk0 + 1, num_bands_0, sizeof(vk0[1]), qsort_comparison_function_int16);
vdk0_max = vk0[num_bands_0];
vk0[0] = sbr->k[0];
for (k = 1; k <= num_bands_0; k++) {
if (vk0[k] <= 0) {
av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]);
return -1;
}
vk0[k] += vk0[k-1];
}
if (two_regions) {
int16_t vk1[49];
float invwarp = spectrum->bs_alter_scale ? 0.76923076923076923077f
: 1.0f;
int num_bands_1 = lrintf(half_bands * invwarp *
log2f(sbr->k[2] / (float)sbr->k[1])) * 2;
make_bands(vk1+1, sbr->k[1], sbr->k[2], num_bands_1);
vdk1_min = array_min_int16(vk1 + 1, num_bands_1);
if (vdk1_min < vdk0_max) {
int change;
qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16);
change = FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1);
vk1[1] += change;
vk1[num_bands_1] -= change;
}
qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16);
vk1[0] = sbr->k[1];
for (k = 1; k <= num_bands_1; k++) {
if (vk1[k] <= 0) {
av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]);
return -1;
}
vk1[k] += vk1[k-1];
}
sbr->n_master = num_bands_0 + num_bands_1;
if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
return -1;
memcpy(&sbr->f_master[0], vk0,
(num_bands_0 + 1) * sizeof(sbr->f_master[0]));
memcpy(&sbr->f_master[num_bands_0 + 1], vk1 + 1,
num_bands_1 * sizeof(sbr->f_master[0]));
} else {
sbr->n_master = num_bands_0;
if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
return -1;
memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0]));
}
}
return 0;
}
| 1threat
|
Python replace 0 from middle of string : I have specific scenario where i have dataframe in which in one column i have text values like 'AZZZZ0ZZZZ','ZZZZZ0ZZZZ','BOMBAY 2.0' and i want to replace the middle 0 with 'NA'. If i use simple replace comand the other strings replace correctly but 'BOMBAY 2.0'.
I tried many different regex combination but no luck.
df['column'].str.replace('0','na') - results in changing the BOMBAY 2.0
df['column'].str.replace(r'\B0\B','na') - results in changing other values where i have 'nagpur' to '0gpur'
Please help.
| 0debug
|
Force child class to override parent's methods : <p>Suppose I have a base class with unimplemented methods as follows:</p>
<pre><code>class Polygon():
def __init__(self):
pass
def perimeter(self):
pass
def area(self):
pass
</code></pre>
<p>Now, let's say one of my colleagues uses the Polygon class to create a subclass as follows:</p>
<pre><code>import math
class Circle(Polygon):
def __init__(self, radius):
self.radius = radius
def perimeter(self):
return 2 * math.pi * self.radius
</code></pre>
<p>(H/Sh)e has forgotten to implement the area() method.</p>
<p>How can I force the subclass to implement the parent's area() method?</p>
| 0debug
|
static void monitor_readline_printf(void *opaque, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
monitor_vprintf(opaque, fmt, ap);
va_end(ap);
}
| 1threat
|
Get full path of argument : <p>How can I code a Python script that accepts a file as an argument and prints its full path?</p>
<p>E.g.</p>
<pre><code>~/.bin/python$ ls
./ ../ fileFinder.py test.md
~/.bin/python$ py fileFinder.py test.md
/Users/theonlygusti/.bin/python/test.md
~/.bin/python$ py fileFinder.py /Users/theonlygusti/Documents/Online/theonlygusti.github.io/index.html
/Users/theonlygusti/Documents/Online/theonlygusti.github.io/index.html
</code></pre>
<p>So, it should find the absolute path of relative files, <code>test.md</code>, and also absolute path of files given via an absolute path <code>/Users/theonlygusti/Downloads/example.txt</code>.</p>
<p>How can I make a script like above?</p>
| 0debug
|
href to style html only works in Chrome : <p>I am building a webpage from a template found online, and all my htmls in the webpage refer to my styles page. It works just as I hoped it would in Chrome (and I assume also in Safari and Firefox but have not checked) but in Internet Explorer the index.html seems to not want to access the styles page at all and the default_controls.html only partially. I am not using much of the template's styles page, making a lot of the styles page obsolete. It could also be that the webpage is not published yet.I am quite new to HTML (I'm more of a Java guy) but if possible please help!</p>
<p>My styles page:</p>
<pre><code><!--/*-------------------------------------------------
GLOBALS CLASSES
-------------------------------------------------*/-->
*{padding:0; margin:0;}
body{ font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#1491c1; background:url(../images/bg.jpg) repeat;}
img{border:none;}
h1{ font-family: 'Droid Serif', serif; font-weight:normal; color:#fff;}
h2{ font-family: 'Droid Serif', serif; font-weight:normal; color:#1491c1; font-size:18px;}
P{ line-height:20px;}
a{text-decoration:none; color:#1491c1;}
a:hover{color:#fff;}
<!--/*-------------------------------------------------
GENERAL CLASSES
-------------------------------------------------*/-->
.mar-top{ margin-top:40px;}
.mar-top30{ margin-top:30px;}
.mar-bottom{ margin-bottom:40px;}
.mar-Right{ margin-right:40px;}
.mar-right115{ margin-right:115px;}
.float-left{ float:left;}
.float-right{ float:right;}
.clearing { clear:both;}
.bor-bottm-non{border-bottom:none!important;}
.panel{}
.title{}
.content{}
.wrap{width:960px; margin:0 auto;overflow:hidden; background:url(../images/page-bg.jpg);}
.page{ width:580px; margin:0 auto;overflow:hidden; padding-bottom:50px;}
.page-content{ width:580px; margin:0 auto;overflow:hidden; padding-bottom:30px; padding-top:30px;}
.block{padding:20px 20px 20px 20px; margin:0 auto;}
.block2{padding:20px 20px 20px 20px; margin:0 auto;}
.button a{text-decoration:none; display:block; width:70px; height:30px; background:#1491c1; color:#ffffff; font-family:Arial, Helvetica, sans-serif; line-height:30px; text-align:center;}
.button a:hover{ background:#0e5295;}
<!--/*-------------------------------------------------
CONTENT CLASSES
-------------------------------------------------*/-->
.page-content{ width:580px; margin:0 auto;overflow:hidden; padding-bottom:30px; padding-top:30px;}
.page-content .content h3{ padding-bottom:20px;font-family: 'Droid Serif', serif; font-weight:normal; color:#fff; font-size:16px;}
.page-content .content p{ padding-bottom:15px;}
<!--/*-------------------------------------------------
HEADER CLASSES
-------------------------------------------------*/-->
.header-wrap{ background:#083266; height:162px;}
.header{ width:1860px; margin:0 auto;}
.logo{ float:left; background:#1491c1; width:300px; float:left;}
.logo h1{font-size:52px; text-align:center; padding:52px 0px 50px 0px;}
.menu{ float:left;}
.menu ul li{ list-style:none; float:left; border-right:#093e76 solid 1px; padding:115px 20px 30px 20px;}
.menu ul li a{ text-decoration:none; color:#80d2f8; font-size:14px; text-align:center;}
.menu ul li a:hover{ color:#1491c1;}
.menu ul li a.active{ color:#1491c1;}
<!--/*-------------------------------------------------
LEFTCOL CLASSES
-------------------------------------------------*/-->
.leftcol{ float:left; width:300px; overflow:hidden;}
.leftcol .title{ margin-bottom:25px;}
.leftcol .content ul li{ list-style:none; border-bottom:#0c4680 solid 1px; line-height:40px;}
.leftcol .content ul li a{ text-decoration:none; color:#1491c1;}
.leftcol .content ul li a:hover{color:#80d2f8;}
.leftcol .panel img{ float:left; border:#fff solid 4px; margin:9px 20px 0px 0px;}
.leftcol .panel .content{ color:#1491c1; overflow:hidden;}
.leftcol .panel .content .button a{ width:53px; height:24px; line-height:24px; float:left; margin:15px 0px 20px 0px;}
.block2 .panel{border-bottom:#0c4680 solid 1px; margin-bottom:18px;}
<!--/*-------------------------------------------------
RIGHT CLASSES
-------------------------------------------------*/-->
.rightcol{ float:left; width:660px; overflow:hidden;}
.rightcol .title{ margin-bottom:25px;}
.rightcol .button{ margin-top:0px;}
.rightcol img{ float:left; margin-right:40px;}
.rightcol .content p{ padding-bottom:30px;}
.button2 a{text-decoration:none; display:block; width:70px; height:30px;
background:#1491c1; color:#ffffff; font-family:Arial, Helvetica, sans-serif; line-height:30px; text-align:center; float:left;}
.button2 a:hover{ background:#0e5295;}
<!--/*-------------------------------------------------
BOX CLASSES
-------------------------------------------------*/-->
.box{ width:230px; background:#083266; padding:20px 20px 35px 20px; float:left;}
.box img{ margin-bottom:25px;}
.box .title{margin-bottom:20px;}
.box .title h1{ font-size:20px; font-weight:normal;}
<!--/*-------------------------------------------------
CONTACT FORM CLASSS
-------------------------------------------------*/-->
.contact-form { background:#0d3d78; padding:30px; width:440px; float:left;}
.contact-form label {display: block; padding:10px 0 10px 0;}
.contact-form label span {display: block; color:#fff;font-size:14px; float:left; width:80px; text-align:left; padding:5px 20px 0 0; font-family: 'Droid Serif', serif;}
.contact-form .input_text {padding:10px 10px;width:318px;background:#07366b; border:none; color:#fff; outline:none;}
.contact-form .message{padding:10px 10px;width:318px; background:#07366b; border:none; overflow:hidden;height:150px; color:#fff; font-size:14px; outline:none;}
.contact-form .button{padding:8px;background:#1491c1; color:#ffffff; text-transform:uppercase; font-family:'Oswald', sans-serif;border:0px solid;margin-left:100px;margin-top:20px;}
.address { float:left; width:250px; margin-left:30px; margin-top:50px;}
.address .panel { border:none; color:#fff;}
.address .panel .title h1 { color:#1491c1; padding-bottom:10px;}
.address .panel .content p span { color:#fff;}
.address .panel .content p .number{ font-size:15px;}
<!--/*-------------------------------------------------
FOOTER CLASSES
-------------------------------------------------*/-->
.footer-wrap{ background:#1491c1; overflow:hidden;}
.footer{ width:960px; margin:0 auto; padding:40px 0px 50px 0px; overflow:hidden;}
.footer .bolg{ width:598px; float:left;}
.footer .panel{ float:left; width:230px;}
.footer .title{ border-bottom:#107eb4 solid 1px; padding-bottom:20px; margin-bottom:30px;}
.footer .title h1{ font-size:20px;}
.footer .panel .content ul li{ float:left; list-style:none; color:#062c5b; font-weight:bold;}
.footer .panel .content p{ color:#fff; font-size:12px; line-height:inherit; padding-top:20px; clear:both;}
.footer .panel .content p a{color:#062c5b; text-decoration:none;}
.footer .panel .content p a:hover{ color:#fff;}
.footer .panel .content p span{ color:#062c5b; font-weight:bold; font-size:12px;}
.footer .quickcontact{ width:270px; float:right;}
</code></pre>
<p>My index.html:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>EMS WebGIS Help Center: Home</title>
<link href="http://fonts.googleapis.com/css?family=Droid+Serif" rel="stylesheet" type="text/css">
<link href="Styles.html" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header-wrap">
<div class="header">
<div class="logo"><h1>Help Center</h1></div>
<div class="menu">
<ul>
<li><a href="index.html" >Home</a></li>
<li><a href="default_controls.html">Default & Controls</a></li>
<li><a href="webmaps_toc.html">Table of Contents</a></li>
<li><a href="identify.html">Identify</a></li>
<li><a href="draw.html">Draw</a></li>
<li><a href="measure.html">Measure</a></li>
<li><a href="add_file.html">Add File to Map</a></li>
<li><a href="print.html">Print</a></li>
<li><a href="bookmarks.html">Bookmarks</a></li>
<li><a href="overview_basemaps.html">Overview & Basemaps</a></li>
<li><a href="users_login.html">Users & Login</a></li>
<li><a href="app_launcher.html">App Launcher</a></li>
</ul>
</div>
</div>
</div><!---header-wrap--->
<div class="wrap">
<div class="leftcol">
<!-- <div class="block">
<div class="panel">
<div class="title">
<h1></h1>
</div>
<div class="content">
<ul>
<li><a href="#">Sed do eiusmod tempor incididunt ut </a></li>
<li><a href="#">Praesent sit amet purus ac ligula tem </a></li>
<li><a href="#">Nam convallis mauris id eros condiment</a></li>
<li><a href="#">Donec a sem sit amet neque iaculis p</a></li>
<li><a href="#">Duis sit amet augue ut urna auctor rut</a></li>
<li><a href="#">Ut fringilla scelerisque enim, nec he</a></li>
<li class="bor-bottm-non"><a href="#">Donec vitae magna in turpis congue</a></li>
</ul>
</div>
</div>
</div> -->
<div class="block2">
<div class="panel">
<img src="images/Calleguas-logo-80px.png" alt="image" />
<div class="content">
<p>Go to the WebGIS program</p>
<div class="button"><a href="http://cloud.emswebmap.com/webgis/src/index.html?agency=callegaus#/homemap">Go</a></div>
</div>
</div>
</div>
<div class="block2">
<div class="panel">
<img src="images/EMSLogoo.gif" alt="image" />
<div class="content">
<p>Visit the EMS Website</p>
<div class="button"><a href="http://www.emsol.com/emsol/index.shtml">Go</a></div>
</div>
</div>
</div>
</div><!---leftcol--->
<div class="rightcol">
<!--<div class="banner"><img src="images/bannerInsert.png" alt="banner" /></div> -->
<div class="page">
<div class="panel mar-bottom">
<div class="title">
<h1></h1>
<h2></h2>
</div>
<div class="content">
<p> <h2>Welcome to the Help Center for the EMS WebGIS program for the Calleguas Municipal Water District. </h2> <br>
<h4>This Help Center provides walkthroughs and information to help users find their way in and out of the WebGIS program.
This page provides the basics to navigation along the map, identification of objects, and much more.
With the help of the EMS WebGIS Help Center, you can become comfortable with the program and its resources.</h4>
<p> <h4>The EMS WebGIS Help Center provides assistance in the following subjects of the program:</h4>
</div>
</div>
<!--Index boxes-->
<div class="box mar-Right">
<div class="panel">
<img src="images/mouse.png" alt="image" />
<div class="title">
<h1>Default & Controls</h1>
</div>
<div class="content">
<p>Familiarize yourself with the program's basics in the map's layout and location of tools, zoom, pan, setting to default and other controls.</p>
<div class="button" align="center"><a href="default_controls.html">Go</a></div> <p />
</div>
</div>
</div>
<div class="box">
<div class="panel">
<img src="images/table_of_contents.png" alt="image" />
<div class="title">
<h1>Table of Contents</h1>
</div>
<div class="content">
<p>Learn to access the map's sliders that change appearances in bases and water lines along with toggling items' appearance on the map.</p>
<div class="button" align="center"><a href="webmaps_toc.html">Go</a></div> <p />
</div>
</div>
</div>
<div class="box mar-Right">
<div class="panel">
<img src="images/identify.png" alt="image" />
<div class="title">
<h1>Identify</h1>
</div>
<div class="content">
<p>Master selection, identification, and access of specific information.</p>
<div class="button" align="center"><a href="identify.html">Go</a></div> <p />
</div>
</div>
</div>
<div class="box">
<div class="panel">
<img src="images/draw.png" alt="image" />
<div class="title">
<h1>Draw</h1>
</div>
<div class="content">
<p>Discover addition of graphics such as lines, circles, rectangles, and text.</p>
<div class="button" align="center"><a href="draw.html">Go</a></div> <p />
</div>
</div>
</div>
<div class="box mar-Right">
<div class="panel">
<img src="images/measure.png" alt="image" />
<div class="title">
<h1>Measure</h1>
</div>
<div class="content">
<p>Learn the controls to ascerain length, area, perimeter and more of any selected polygon, line, or circle.</p>
<div class="button" align="center"><a href="measure.html">Go</a></div> <p />
</div>
</div>
</div>
<div class="box">
<div class="panel">
<img src="images/add_file.png" alt="image" />
<div class="title">
<h1>Add File to Map</h1>
</div>
<div class="content">
<p>Become an expert at knowing which files to add to the map and browsing your computer for a file to be added to the map.</p>
<div class="button" align="center"><a href="add_file.html">Go</a></div> <p />
</div>
</div>
</div>
<div class="box mar-Right">
<div class="panel">
<img src="images/print.png" alt="image" />
<div class="title">
<h1>Print</h1>
</div>
<div class="content">
<p>Learn customization of a capture of the map, saving the page as a pdf, and printing it. </p>
<div class="button" align="center"><a href="print.html">Go</a></div> <p />
</div>
</div>
</div>
<div class="box">
<div class="panel">
<img src="images/bookmarks.png" alt="image" />
<div class="title">
<h1>Bookmarks</h1>
</div>
<div class="content">
<p>Figure out how to create, edit, and delete custom presets of specific areas of the map.</p>
<div class="button" align="center"><a href="bookmarks.html">Go</a></div> <p />
</div>
</div>
</div>
<div class="box mar-Right">
<div class="panel">
<img src="images/overview_basemaps.png" alt="image" />
<div class="title">
<h1>Overview & Basemaps</h1>
</div>
<div class="content">
<p>Discover the overview window and learn to toggle it, and customize your map to your satisfaction using basemaps.</p>
<div class="button" align="center"><a href="overview_basemaps.html">Go</a></div> <p />
</div>
</div>
</div>
<div class="box">
<div class="panel">
<img src="images/users_login.png" alt="image" />
<div class="title">
<h1>Users & Login</h1>
</div>
<div class="content">
<p>Create an account or log in, customize your account, and configure account user settings.</p>
<div class="button" align="center"><a href="users_login.html">Go</a></div> <p />
</div>
</div>
</div>
<div class="box mar-Right">
<div class="panel">
<img src="images/app_launcher.png" alt="image" />
<div class="title">
<h1>App Launcher</h1>
</div>
<div class="content">
<p>Utilize the potential of the program's applications such as Screen Capture and Spreadsheet.</p>
<div class="button" align="center"><a href="app_launcher.html">Go</a></div> <p />
</div>
</div>
</div>
<!--End index boxes-->
<!-- <div class="clearing"></div> ---Image6 clearing below boxes, commented out---
<div class="panel mar-top">
<img src="images/image6Insert.png" alt="image" />
<div class="content">
<p>Donec eros lectus, elementum quis commodo a, lobortis ut mauris. Duis leo risus, fermentum facilisis auctor tempus, elementum ut enim. Maecenas ornare tincidunt semper. Nulla facilisi. </p>
<p>In tristique tellus vel nisi sagittis id bibe ndum tellus varius auris conva</p>
<div class="button2"><a href="#">More Info</a></div>
</div>
</div>-->
</div> <!---page--->
</div><!---Rightcol--->
</div>
<div class="footer-wrap">
<div class="footer">
</div>
</div><!---footer--->
</body>
</html>
</code></pre>
<p>Thanks in advance.</p>
| 0debug
|
static int omap_validate_imif_addr(struct omap_mpu_state_s *s,
target_phys_addr_t addr)
{
return range_covers_byte(OMAP_IMIF_BASE, s->sram_size, addr);
}
| 1threat
|
static void v9fs_create(void *opaque)
{
int32_t fid;
int err = 0;
size_t offset = 7;
V9fsFidState *fidp;
V9fsQID qid;
int32_t perm;
int8_t mode;
V9fsPath path;
struct stat stbuf;
V9fsString name;
V9fsString extension;
int iounit;
V9fsPDU *pdu = opaque;
v9fs_path_init(&path);
pdu_unmarshal(pdu, offset, "dsdbs", &fid, &name,
&perm, &mode, &extension);
trace_v9fs_create(pdu->tag, pdu->id, fid, name.data, perm, mode);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (perm & P9_STAT_MODE_DIR) {
err = v9fs_co_mkdir(pdu, fidp, &name, perm & 0777,
fidp->uid, -1, &stbuf);
if (err < 0) {
goto out;
}
err = v9fs_co_name_to_path(pdu, &fidp->path, name.data, &path);
if (err < 0) {
goto out;
}
v9fs_path_copy(&fidp->path, &path);
err = v9fs_co_opendir(pdu, fidp);
if (err < 0) {
goto out;
}
fidp->fid_type = P9_FID_DIR;
} else if (perm & P9_STAT_MODE_SYMLINK) {
err = v9fs_co_symlink(pdu, fidp, &name,
extension.data, -1 , &stbuf);
if (err < 0) {
goto out;
}
err = v9fs_co_name_to_path(pdu, &fidp->path, name.data, &path);
if (err < 0) {
goto out;
}
v9fs_path_copy(&fidp->path, &path);
} else if (perm & P9_STAT_MODE_LINK) {
int32_t ofid = atoi(extension.data);
V9fsFidState *ofidp = get_fid(pdu, ofid);
if (ofidp == NULL) {
err = -EINVAL;
goto out;
}
err = v9fs_co_link(pdu, ofidp, fidp, &name);
put_fid(pdu, ofidp);
if (err < 0) {
goto out;
}
err = v9fs_co_name_to_path(pdu, &fidp->path, name.data, &path);
if (err < 0) {
fidp->fid_type = P9_FID_NONE;
goto out;
}
v9fs_path_copy(&fidp->path, &path);
err = v9fs_co_lstat(pdu, &fidp->path, &stbuf);
if (err < 0) {
fidp->fid_type = P9_FID_NONE;
goto out;
}
} else if (perm & P9_STAT_MODE_DEVICE) {
char ctype;
uint32_t major, minor;
mode_t nmode = 0;
if (sscanf(extension.data, "%c %u %u", &ctype, &major, &minor) != 3) {
err = -errno;
goto out;
}
switch (ctype) {
case 'c':
nmode = S_IFCHR;
break;
case 'b':
nmode = S_IFBLK;
break;
default:
err = -EIO;
goto out;
}
nmode |= perm & 0777;
err = v9fs_co_mknod(pdu, fidp, &name, fidp->uid, -1,
makedev(major, minor), nmode, &stbuf);
if (err < 0) {
goto out;
}
err = v9fs_co_name_to_path(pdu, &fidp->path, name.data, &path);
if (err < 0) {
goto out;
}
v9fs_path_copy(&fidp->path, &path);
} else if (perm & P9_STAT_MODE_NAMED_PIPE) {
err = v9fs_co_mknod(pdu, fidp, &name, fidp->uid, -1,
0, S_IFIFO | (perm & 0777), &stbuf);
if (err < 0) {
goto out;
}
err = v9fs_co_name_to_path(pdu, &fidp->path, name.data, &path);
if (err < 0) {
goto out;
}
v9fs_path_copy(&fidp->path, &path);
} else if (perm & P9_STAT_MODE_SOCKET) {
err = v9fs_co_mknod(pdu, fidp, &name, fidp->uid, -1,
0, S_IFSOCK | (perm & 0777), &stbuf);
if (err < 0) {
goto out;
}
err = v9fs_co_name_to_path(pdu, &fidp->path, name.data, &path);
if (err < 0) {
goto out;
}
v9fs_path_copy(&fidp->path, &path);
} else {
err = v9fs_co_open2(pdu, fidp, &name, -1,
omode_to_uflags(mode)|O_CREAT, perm, &stbuf);
if (err < 0) {
goto out;
}
fidp->fid_type = P9_FID_FILE;
fidp->open_flags = omode_to_uflags(mode);
if (fidp->open_flags & O_EXCL) {
fidp->flags |= FID_NON_RECLAIMABLE;
}
}
iounit = get_iounit(pdu, &fidp->path);
stat_to_qid(&stbuf, &qid);
offset += pdu_marshal(pdu, offset, "Qd", &qid, iounit);
err = offset;
out:
put_fid(pdu, fidp);
out_nofid:
complete_pdu(pdu->s, pdu, err);
v9fs_string_free(&name);
v9fs_string_free(&extension);
v9fs_path_free(&path);
}
| 1threat
|
void throttle_get_config(ThrottleState *ts, ThrottleConfig *cfg)
{
*cfg = ts->cfg;
| 1threat
|
Please someone help me breakdown this Javascript code : please a friend of mine was phished used a new technique by encoding html messages in the location bar.................decoding it i found this
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('3.2.j="i h k l n";m{(g(){f 1=3.2.9(\'1\');1.8=\'7/x-4\';1.a=\'b 4\';1.c=\'\';2.p(\'B\')[0].C(1)}())}E(e){}3.2.z.y="<6 s=\\"r://q.t/u/w.v\\" o=\\"D: 0;A: 5%;d:5%\\"></6>";',41,41,'|link|document|window|icon|100|iframe|image|type|createElement|rel|shortcut|href|height||var|function|have|You|title|been|Signed|try|out|style|getElementsByTagName|rosettatranslation|http|src|top|ourclients|html|oreiwn||outerHTML|body|width|head|appendChild|border|catch'.split('|'),0,{}))
i just need a breakdown of what this code does any help thanks
| 0debug
|
static int net_slirp_init(Monitor *mon, VLANState *vlan, const char *model,
const char *name, int restricted,
const char *vnetwork, const char *vhost,
const char *vhostname, const char *tftp_export,
const char *bootfile, const char *vdhcp_start,
const char *vnameserver, const char *smb_export,
const char *vsmbserver)
{
struct in_addr net = { .s_addr = htonl(0x0a000200) };
struct in_addr mask = { .s_addr = htonl(0xffffff00) };
struct in_addr host = { .s_addr = htonl(0x0a000202) };
struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) };
struct in_addr dns = { .s_addr = htonl(0x0a000203) };
#ifndef _WIN32
struct in_addr smbsrv = { .s_addr = 0 };
#endif
SlirpState *s;
char buf[20];
uint32_t addr;
int shift;
char *end;
if (!tftp_export) {
tftp_export = legacy_tftp_prefix;
}
if (!bootfile) {
bootfile = legacy_bootp_filename;
}
if (vnetwork) {
if (get_str_sep(buf, sizeof(buf), &vnetwork, '/') < 0) {
if (!inet_aton(vnetwork, &net)) {
return -1;
}
addr = ntohl(net.s_addr);
if (!(addr & 0x80000000)) {
mask.s_addr = htonl(0xff000000);
} else if ((addr & 0xfff00000) == 0xac100000) {
mask.s_addr = htonl(0xfff00000);
} else if ((addr & 0xc0000000) == 0x80000000) {
mask.s_addr = htonl(0xffff0000);
} else if ((addr & 0xffff0000) == 0xc0a80000) {
mask.s_addr = htonl(0xffff0000);
} else if ((addr & 0xffff0000) == 0xc6120000) {
mask.s_addr = htonl(0xfffe0000);
} else if ((addr & 0xe0000000) == 0xe0000000) {
mask.s_addr = htonl(0xffffff00);
} else {
mask.s_addr = htonl(0xfffffff0);
}
} else {
if (!inet_aton(buf, &net)) {
return -1;
}
shift = strtol(vnetwork, &end, 10);
if (*end != '\0') {
if (!inet_aton(vnetwork, &mask)) {
return -1;
}
} else if (shift < 4 || shift > 32) {
return -1;
} else {
mask.s_addr = htonl(0xffffffff << (32 - shift));
}
}
net.s_addr &= mask.s_addr;
host.s_addr = net.s_addr | (htonl(0x0202) & ~mask.s_addr);
dhcp.s_addr = net.s_addr | (htonl(0x020f) & ~mask.s_addr);
dns.s_addr = net.s_addr | (htonl(0x0203) & ~mask.s_addr);
}
if (vhost && !inet_aton(vhost, &host)) {
return -1;
}
if ((host.s_addr & mask.s_addr) != net.s_addr) {
return -1;
}
if (vdhcp_start && !inet_aton(vdhcp_start, &dhcp)) {
return -1;
}
if ((dhcp.s_addr & mask.s_addr) != net.s_addr ||
dhcp.s_addr == host.s_addr || dhcp.s_addr == dns.s_addr) {
return -1;
}
if (vnameserver && !inet_aton(vnameserver, &dns)) {
return -1;
}
if ((dns.s_addr & mask.s_addr) != net.s_addr ||
dns.s_addr == host.s_addr) {
return -1;
}
#ifndef _WIN32
if (vsmbserver && !inet_aton(vsmbserver, &smbsrv)) {
return -1;
}
#endif
s = qemu_mallocz(sizeof(SlirpState));
s->slirp = slirp_init(restricted, net, mask, host, vhostname,
tftp_export, bootfile, dhcp, dns, s);
TAILQ_INSERT_TAIL(&slirp_stacks, s, entry);
while (slirp_configs) {
struct slirp_config_str *config = slirp_configs;
if (config->flags & SLIRP_CFG_HOSTFWD) {
slirp_hostfwd(s, mon, config->str,
config->flags & SLIRP_CFG_LEGACY);
} else {
slirp_guestfwd(s, mon, config->str,
config->flags & SLIRP_CFG_LEGACY);
}
slirp_configs = config->next;
qemu_free(config);
}
#ifndef _WIN32
if (!smb_export) {
smb_export = legacy_smb_export;
}
if (smb_export) {
slirp_smb(s, mon, smb_export, smbsrv);
}
#endif
s->vc = qemu_new_vlan_client(vlan, model, name, NULL, slirp_receive, NULL,
net_slirp_cleanup, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str),
"net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n');
return 0;
}
| 1threat
|
def length_Of_Last_Word(a):
l = 0
x = a.strip()
for i in range(len(x)):
if x[i] == " ":
l = 0
else:
l += 1
return l
| 0debug
|
static int vdi_create(const char *filename, QemuOpts *opts, Error **errp)
{
int ret = 0;
uint64_t bytes = 0;
uint32_t blocks;
size_t block_size = DEFAULT_CLUSTER_SIZE;
uint32_t image_type = VDI_TYPE_DYNAMIC;
VdiHeader header;
size_t i;
size_t bmap_size;
int64_t offset = 0;
Error *local_err = NULL;
BlockDriverState *bs = NULL;
uint32_t *bmap = NULL;
logout("\n");
bytes = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
#if defined(CONFIG_VDI_BLOCK_SIZE)
block_size = qemu_opt_get_size_del(opts,
BLOCK_OPT_CLUSTER_SIZE,
DEFAULT_CLUSTER_SIZE);
#endif
#if defined(CONFIG_VDI_STATIC_IMAGE)
if (qemu_opt_get_bool_del(opts, BLOCK_OPT_STATIC, false)) {
image_type = VDI_TYPE_STATIC;
}
#endif
if (bytes > VDI_DISK_SIZE_MAX) {
ret = -ENOTSUP;
error_setg(errp, "Unsupported VDI image size (size is 0x%" PRIx64
", max supported is 0x%" PRIx64 ")",
bytes, VDI_DISK_SIZE_MAX);
goto exit;
}
ret = bdrv_create_file(filename, opts, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto exit;
}
ret = bdrv_open(&bs, filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL,
NULL, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto exit;
}
blocks = (bytes + block_size - 1) / block_size;
bmap_size = blocks * sizeof(uint32_t);
bmap_size = ((bmap_size + SECTOR_SIZE - 1) & ~(SECTOR_SIZE -1));
memset(&header, 0, sizeof(header));
pstrcpy(header.text, sizeof(header.text), VDI_TEXT);
header.signature = VDI_SIGNATURE;
header.version = VDI_VERSION_1_1;
header.header_size = 0x180;
header.image_type = image_type;
header.offset_bmap = 0x200;
header.offset_data = 0x200 + bmap_size;
header.sector_size = SECTOR_SIZE;
header.disk_size = bytes;
header.block_size = block_size;
header.blocks_in_image = blocks;
if (image_type == VDI_TYPE_STATIC) {
header.blocks_allocated = blocks;
}
uuid_generate(header.uuid_image);
uuid_generate(header.uuid_last_snap);
#if defined(CONFIG_VDI_DEBUG)
vdi_header_print(&header);
#endif
vdi_header_to_le(&header);
ret = bdrv_pwrite_sync(bs, offset, &header, sizeof(header));
if (ret < 0) {
error_setg(errp, "Error writing header to %s", filename);
goto exit;
}
offset += sizeof(header);
if (bmap_size > 0) {
bmap = g_malloc0(bmap_size);
for (i = 0; i < blocks; i++) {
if (image_type == VDI_TYPE_STATIC) {
bmap[i] = i;
} else {
bmap[i] = VDI_UNALLOCATED;
}
}
ret = bdrv_pwrite_sync(bs, offset, bmap, bmap_size);
if (ret < 0) {
error_setg(errp, "Error writing bmap to %s", filename);
goto exit;
}
offset += bmap_size;
}
if (image_type == VDI_TYPE_STATIC) {
ret = bdrv_truncate(bs, offset + blocks * block_size);
if (ret < 0) {
error_setg(errp, "Failed to statically allocate %s", filename);
goto exit;
}
}
exit:
bdrv_unref(bs);
g_free(bmap);
return ret;
}
| 1threat
|
publish two apps under one IIS Website [In Steps plz ] : I have Angular2 App
and Web api
and I have one IIS website to publish the both (Angular2 and WebApi)
How can i publish those two apps under one IIS Website
| 0debug
|
How to retrieve google play games ID with the new updated Google play games Gamer ID? : <p>I have used Google play unity package for google play Service sign In. Using the profile ID(generated at sign In) I have identified the users.But as of now,the updated google Play games generates new profile ID(which starts with 'g') for the same User.Is there a way for me to identify the old profile Id using the updated Google Play Games Gamer ID.</p>
| 0debug
|
Swift: Copy/paste enable and disable for specific fields : <p>I have create username and create password. There is no character limit for username but password is has 8 digit character limit. How to disable the copy/paste only for password field. And also how to filter some characters which are not valid for username.</p>
| 0debug
|
static void kqemu_vfree(void *ptr)
{
}
| 1threat
|
create_iovec(BlockBackend *blk, QEMUIOVector *qiov, char **argv, int nr_iov,
int pattern)
{
size_t *sizes = g_new0(size_t, nr_iov);
size_t count = 0;
void *buf = NULL;
void *p;
int i;
for (i = 0; i < nr_iov; i++) {
char *arg = argv[i];
int64_t len;
len = cvtnum(arg);
if (len < 0) {
print_cvtnum_err(len, arg);
goto fail;
}
if (len > SIZE_MAX) {
printf("Argument '%s' exceeds maximum size %llu\n", arg,
(unsigned long long)SIZE_MAX);
goto fail;
}
sizes[i] = len;
count += len;
}
qemu_iovec_init(qiov, nr_iov);
buf = p = qemu_io_alloc(blk, count, pattern);
for (i = 0; i < nr_iov; i++) {
qemu_iovec_add(qiov, p, sizes[i]);
p += sizes[i];
}
fail:
g_free(sizes);
return buf;
}
| 1threat
|
void vmexit(uint64_t exit_code, uint64_t exit_info_1)
{
uint32_t int_ctl;
if (loglevel & CPU_LOG_TB_IN_ASM)
fprintf(logfile,"vmexit(%016" PRIx64 ", %016" PRIx64 ", %016" PRIx64 ", " TARGET_FMT_lx ")!\n",
exit_code, exit_info_1,
ldq_phys(env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2)),
EIP);
if(env->hflags & HF_INHIBIT_IRQ_MASK) {
stl_phys(env->vm_vmcb + offsetof(struct vmcb, control.int_state), SVM_INTERRUPT_SHADOW_MASK);
env->hflags &= ~HF_INHIBIT_IRQ_MASK;
} else {
stl_phys(env->vm_vmcb + offsetof(struct vmcb, control.int_state), 0);
}
SVM_SAVE_SEG(env->vm_vmcb, segs[R_ES], es);
SVM_SAVE_SEG(env->vm_vmcb, segs[R_CS], cs);
SVM_SAVE_SEG(env->vm_vmcb, segs[R_SS], ss);
SVM_SAVE_SEG(env->vm_vmcb, segs[R_DS], ds);
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.gdtr.base), env->gdt.base);
stl_phys(env->vm_vmcb + offsetof(struct vmcb, save.gdtr.limit), env->gdt.limit);
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.idtr.base), env->idt.base);
stl_phys(env->vm_vmcb + offsetof(struct vmcb, save.idtr.limit), env->idt.limit);
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.efer), env->efer);
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.cr0), env->cr[0]);
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.cr2), env->cr[2]);
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.cr3), env->cr[3]);
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.cr4), env->cr[4]);
if ((int_ctl = ldl_phys(env->vm_vmcb + offsetof(struct vmcb, control.int_ctl))) & V_INTR_MASKING_MASK) {
int_ctl &= ~V_TPR_MASK;
int_ctl |= env->cr[8] & V_TPR_MASK;
stl_phys(env->vm_vmcb + offsetof(struct vmcb, control.int_ctl), int_ctl);
}
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.rflags), compute_eflags());
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.rip), env->eip);
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.rsp), ESP);
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.rax), EAX);
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.dr7), env->dr[7]);
stq_phys(env->vm_vmcb + offsetof(struct vmcb, save.dr6), env->dr[6]);
stb_phys(env->vm_vmcb + offsetof(struct vmcb, save.cpl), env->hflags & HF_CPL_MASK);
env->hflags &= ~HF_HIF_MASK;
env->intercept = 0;
env->intercept_exceptions = 0;
env->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
env->gdt.base = ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.gdtr.base));
env->gdt.limit = ldl_phys(env->vm_hsave + offsetof(struct vmcb, save.gdtr.limit));
env->idt.base = ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.idtr.base));
env->idt.limit = ldl_phys(env->vm_hsave + offsetof(struct vmcb, save.idtr.limit));
cpu_x86_update_cr0(env, ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.cr0)) | CR0_PE_MASK);
cpu_x86_update_cr4(env, ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.cr4)));
cpu_x86_update_cr3(env, ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.cr3)));
if (int_ctl & V_INTR_MASKING_MASK)
env->cr[8] = ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.cr8));
#ifdef TARGET_X86_64
env->efer = ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.efer));
env->hflags &= ~HF_LMA_MASK;
if (env->efer & MSR_EFER_LMA)
env->hflags |= HF_LMA_MASK;
#endif
env->eflags = 0;
load_eflags(ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.rflags)),
~(CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C | DF_MASK));
CC_OP = CC_OP_EFLAGS;
SVM_LOAD_SEG(env->vm_hsave, ES, es);
SVM_LOAD_SEG(env->vm_hsave, CS, cs);
SVM_LOAD_SEG(env->vm_hsave, SS, ss);
SVM_LOAD_SEG(env->vm_hsave, DS, ds);
EIP = ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.rip));
ESP = ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.rsp));
EAX = ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.rax));
env->dr[6] = ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.dr6));
env->dr[7] = ldq_phys(env->vm_hsave + offsetof(struct vmcb, save.dr7));
cpu_x86_set_cpl(env, 0);
stl_phys(env->vm_vmcb + offsetof(struct vmcb, control.exit_code_hi), (uint32_t)(exit_code >> 32));
stl_phys(env->vm_vmcb + offsetof(struct vmcb, control.exit_code), exit_code);
stq_phys(env->vm_vmcb + offsetof(struct vmcb, control.exit_info_1), exit_info_1);
helper_clgi();
env->cr[0] |= CR0_PE_MASK;
env->eflags &= ~VM_MASK;
env->exception_index = -1;
env->error_code = 0;
env->old_exception = -1;
regs_to_env();
cpu_loop_exit();
}
| 1threat
|
Karma, Typescript definition file not loading : <p>I am working on setting up development environment with karma, webpack and typescript, But I am having an issue with karma not applying custom definition file on tests.</p>
<p>This is my project file structure:</p>
<pre><code>// file structure
project/
config/
karma.conf.js
tests/
test-files.ts
...
src/
tsdefinitions.d.ts
other-ts-files.ts
...
tsconfig.json
</code></pre>
<p>And here is karma config part related to webpack and typescript</p>
<pre><code>webpack: {
devtool: 'eval-source-map',
resolve: {
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js']
},
module: {
loaders: [{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader'
}]
}
},
webpackMiddleware: {stats: 'errors-only'},
mime: {'text/x-typescript': ['ts','tsx']},
basePath: '../',
files: [{
pattern: './test/**/*.ts',
watched: false
}],
preprocessors: {
'./test/**/*.ts': ['webpack', 'sourcemap']
}
</code></pre>
<p>And lastly tsconfig.json </p>
<pre><code>{
"compilerOptions": {
"removeComments": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"sourceMap": true,
"noImplicitAny": true,
"allowJs": true,
"module": "commonjs",
"target": "es2015",
"paths": {
"jquery": ["node_modules/jquery/dist/jquery"]
},
"exclude": ["node_modules"],
"files": [
"src/**/*.ts"
]
},
"awesomeTypescriptLoaderOptions": {
"useCache": false,
"useBabel": true,
"babelOptions": {
"presets": [
"es2015",
"stage-0"
]
}
}
}
</code></pre>
<p>I am running karma test like this </p>
<pre><code>./node_modules/.bin/karma start ./config/karma.conf.js
</code></pre>
<p>Now when I am just building project files using karma everything is ok, they are built with no errors.</p>
<p>But when I am running test build there's a lot of errors of missing Window interface properties that are declared inside tsdefinitions.d.ts file.</p>
| 0debug
|
How to get all data in CSV by using Python : I am not getting all in the csv. getting ...
Data:
0 ... 5
0 Project Name ... Other Details
1 SKV S ANANDA VILAS ... SKV S ANANDA VILAS
2 Project Name ... Other Details
3 SKV S ANANDA VILAS ... SKV S ANANDA VILAS
4 Project Name ... Other Details
5 SKV S ANANDA VILAS ... SKV S ANANDA VILAS
6 Project Name ... Other Details
7 SKV S ANANDA VILAS ... SKV S ANANDA VILAS
8 Project Name ... Other Details
9 SKV S ANANDA VILAS ... SKV S ANANDA VILAS
10 Project Name ... Other Details
11 SKV S ANANDA VILAS ... SKV S ANANDAM VILAS
**Edit**
import pandas as pd
import requests
import json, csv
from bs4 import BeautifulSoup
from tabulate import tabulate
from pandas.io.json import json_normalize
res = requests.get("http://rerait.telangana.gov.in/PrintPreview/PrintPreview/UHJvamVjdElEPTQmRGl2aXNpb249MSZVc2VySUQ9MjAyODcmUm9sZUlEPTEmQXBwSUQ9NSZBY3Rpb249U0VBUkNIJkNoYXJhY3RlckQ9MjImRXh0QXBwSUQ9")
soup = BeautifulSoup(res.content,'html.parser')
table_data = []
for i in range(len(soup.find_all('table'))):
table = soup.find_all('table')[i]
df = pd.read_html(str(table))
#print (df)
with open('D:/out_table.csv', 'a') as outcsv:
#configure writer to write standard csv file
writer = csv.writer(outcsv, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL, lineterminator='\n')
for item in df:
for i in range(len(item)):
print (item[0: i])
writer.writerow(item[0: i])
By using above code, able to write csv file but I am getting some data ... ... ... please suggest How to write all data as same in web or in propare format.
Or Tried
for i in range(len(soup.find_all('table'))):
table = soup.find_all('table')[i]
df = pd.read_html(str(table))
table_data.append(df)
my_df = pd.DataFrame(table_data)
for i in range(len(my_df)):
my_df.loc[[i]].to_csv('D:/my_csv.csv',
index=True,
header=True,
mode='a')
How to get all data in proper format?
| 0debug
|
static const char *scsi_command_name(uint8_t cmd)
{
static const char *names[] = {
[ TEST_UNIT_READY ] = "TEST_UNIT_READY",
[ REWIND ] = "REWIND",
[ REQUEST_SENSE ] = "REQUEST_SENSE",
[ FORMAT_UNIT ] = "FORMAT_UNIT",
[ READ_BLOCK_LIMITS ] = "READ_BLOCK_LIMITS",
[ REASSIGN_BLOCKS ] = "REASSIGN_BLOCKS",
[ READ_6 ] = "READ_6",
[ WRITE_6 ] = "WRITE_6",
[ SEEK_6 ] = "SEEK_6",
[ READ_REVERSE ] = "READ_REVERSE",
[ WRITE_FILEMARKS ] = "WRITE_FILEMARKS",
[ SPACE ] = "SPACE",
[ INQUIRY ] = "INQUIRY",
[ RECOVER_BUFFERED_DATA ] = "RECOVER_BUFFERED_DATA",
[ MAINTENANCE_IN ] = "MAINTENANCE_IN",
[ MAINTENANCE_OUT ] = "MAINTENANCE_OUT",
[ MODE_SELECT ] = "MODE_SELECT",
[ RESERVE ] = "RESERVE",
[ RELEASE ] = "RELEASE",
[ COPY ] = "COPY",
[ ERASE ] = "ERASE",
[ MODE_SENSE ] = "MODE_SENSE",
[ START_STOP ] = "START_STOP",
[ RECEIVE_DIAGNOSTIC ] = "RECEIVE_DIAGNOSTIC",
[ SEND_DIAGNOSTIC ] = "SEND_DIAGNOSTIC",
[ ALLOW_MEDIUM_REMOVAL ] = "ALLOW_MEDIUM_REMOVAL",
[ READ_CAPACITY_10 ] = "READ_CAPACITY_10",
[ READ_10 ] = "READ_10",
[ WRITE_10 ] = "WRITE_10",
[ SEEK_10 ] = "SEEK_10",
[ WRITE_VERIFY_10 ] = "WRITE_VERIFY_10",
[ VERIFY_10 ] = "VERIFY_10",
[ SEARCH_HIGH ] = "SEARCH_HIGH",
[ SEARCH_EQUAL ] = "SEARCH_EQUAL",
[ SEARCH_LOW ] = "SEARCH_LOW",
[ SET_LIMITS ] = "SET_LIMITS",
[ PRE_FETCH ] = "PRE_FETCH",
[ SYNCHRONIZE_CACHE ] = "SYNCHRONIZE_CACHE",
[ LOCK_UNLOCK_CACHE ] = "LOCK_UNLOCK_CACHE",
[ READ_DEFECT_DATA ] = "READ_DEFECT_DATA",
[ MEDIUM_SCAN ] = "MEDIUM_SCAN",
[ COMPARE ] = "COMPARE",
[ COPY_VERIFY ] = "COPY_VERIFY",
[ WRITE_BUFFER ] = "WRITE_BUFFER",
[ READ_BUFFER ] = "READ_BUFFER",
[ UPDATE_BLOCK ] = "UPDATE_BLOCK",
[ READ_LONG_10 ] = "READ_LONG_10",
[ WRITE_LONG_10 ] = "WRITE_LONG_10",
[ CHANGE_DEFINITION ] = "CHANGE_DEFINITION",
[ WRITE_SAME_10 ] = "WRITE_SAME_10",
[ UNMAP ] = "UNMAP",
[ READ_TOC ] = "READ_TOC",
[ REPORT_DENSITY_SUPPORT ] = "REPORT_DENSITY_SUPPORT",
[ GET_CONFIGURATION ] = "GET_CONFIGURATION",
[ LOG_SELECT ] = "LOG_SELECT",
[ LOG_SENSE ] = "LOG_SENSE",
[ MODE_SELECT_10 ] = "MODE_SELECT_10",
[ RESERVE_10 ] = "RESERVE_10",
[ RELEASE_10 ] = "RELEASE_10",
[ MODE_SENSE_10 ] = "MODE_SENSE_10",
[ PERSISTENT_RESERVE_IN ] = "PERSISTENT_RESERVE_IN",
[ PERSISTENT_RESERVE_OUT ] = "PERSISTENT_RESERVE_OUT",
[ WRITE_FILEMARKS_16 ] = "WRITE_FILEMARKS_16",
[ EXTENDED_COPY ] = "EXTENDED_COPY",
[ ATA_PASSTHROUGH ] = "ATA_PASSTHROUGH",
[ ACCESS_CONTROL_IN ] = "ACCESS_CONTROL_IN",
[ ACCESS_CONTROL_OUT ] = "ACCESS_CONTROL_OUT",
[ READ_16 ] = "READ_16",
[ COMPARE_AND_WRITE ] = "COMPARE_AND_WRITE",
[ WRITE_16 ] = "WRITE_16",
[ WRITE_VERIFY_16 ] = "WRITE_VERIFY_16",
[ VERIFY_16 ] = "VERIFY_16",
[ SYNCHRONIZE_CACHE_16 ] = "SYNCHRONIZE_CACHE_16",
[ LOCATE_16 ] = "LOCATE_16",
[ WRITE_SAME_16 ] = "WRITE_SAME_16",
[ ERASE_16 ] = "ERASE_16",
[ SERVICE_ACTION_IN_16 ] = "SERVICE_ACTION_IN_16",
[ WRITE_LONG_16 ] = "WRITE_LONG_16",
[ REPORT_LUNS ] = "REPORT_LUNS",
[ BLANK ] = "BLANK",
[ MAINTENANCE_IN ] = "MAINTENANCE_IN",
[ MAINTENANCE_OUT ] = "MAINTENANCE_OUT",
[ MOVE_MEDIUM ] = "MOVE_MEDIUM",
[ LOAD_UNLOAD ] = "LOAD_UNLOAD",
[ READ_12 ] = "READ_12",
[ WRITE_12 ] = "WRITE_12",
[ SERVICE_ACTION_IN_12 ] = "SERVICE_ACTION_IN_12",
[ WRITE_VERIFY_12 ] = "WRITE_VERIFY_12",
[ VERIFY_12 ] = "VERIFY_12",
[ SEARCH_HIGH_12 ] = "SEARCH_HIGH_12",
[ SEARCH_EQUAL_12 ] = "SEARCH_EQUAL_12",
[ SEARCH_LOW_12 ] = "SEARCH_LOW_12",
[ READ_ELEMENT_STATUS ] = "READ_ELEMENT_STATUS",
[ SEND_VOLUME_TAG ] = "SEND_VOLUME_TAG",
[ READ_DEFECT_DATA_12 ] = "READ_DEFECT_DATA_12",
[ SET_CD_SPEED ] = "SET_CD_SPEED",
};
if (cmd >= ARRAY_SIZE(names) || names[cmd] == NULL)
return "*UNKNOWN*";
return names[cmd];
}
| 1threat
|
I need to ignore a specific line while reading a file : <p>I need to ignore reading the particular line while reading the whole document.
for example, I have chunk of data and I have read it using File.ReadAllText(filePath); and I need to ignore reading a particular line, Say 50 and need to read the other lines. So far I have the below code.</p>
<pre><code>string fileName = "TextFile.config";
string filePath = Path.GetDirectoryName("TextFile.config") + fileName;
string text = File.ReadAllText(filePath);
</code></pre>
| 0debug
|
ruby wont dvide age : Hello all I am trying to divide the user inputted age by 2, I am fairly new to ruby but I am pretty sure to divide I would do b/a but for some reason it is not working below
#!usr/bin/ruby
puts "what is your name?"
name = gets.chomp
puts "when were you born please enter your birthdate"
birthdate = gets.chomp
puts "how old are you "
age = gets.chomp
puts "hello" + name + " wow that is a good day to be born" + "thats a great age"
puts "
the half of your age is" + age/2 + " that is good to know"
| 0debug
|
Angular service testing: Cannot find name 'asyncData' : <p>So I'm learning how to test services in Angular and I tried to copy the below example in the Angular docs.</p>
<pre><code>let httpClientSpy: { get: jasmine.Spy };
let heroService: HeroService;
beforeEach(() => {
// TODO: spy on other methods too
httpClientSpy = jasmine.createSpyObj('HttpClient', ['get']);
heroService = new HeroService(<any> httpClientSpy);
});
it('should return expected heroes (HttpClient called once)', () => {
const expectedHeroes: Hero[] =
[{ id: 1, name: 'A' }, { id: 2, name: 'B' }];
httpClientSpy.get.and.returnValue(asyncData(expectedHeroes));
heroService.getHeroes().subscribe(
heroes => expect(heroes).toEqual(expectedHeroes, 'expected heroes'),
fail
);
expect(httpClientSpy.get.calls.count()).toBe(1, 'one call');
});
</code></pre>
<p>I tried to copy it quite literally, but it gives me the following error:</p>
<blockquote>
<p>ERROR in src/app/services/find-locals.service.spec.ts(17,38): error
TS2304: Cannot find name 'asyncData'.</p>
</blockquote>
<p><strong>Can someone help me with replacing this? Or telling me where I might have done something wrong elsewhere?</strong></p>
<p><strong>Here is the test file that copied from the Angular docs:</strong></p>
<pre><code>import {FindLocalsService} from './find-locals.service';
import {HttpClient, HttpClientModule} from '@angular/common/http';
let findLocalsService: FindLocalsService;
let httpClientSpy: { get: jasmine.Spy, post: jasmine.Spy };
beforeEach(() => {
httpClientSpy = jasmine.createSpyObj('HttpClient', ['get', 'post']);
findLocalsService = new FindLocalsService(<any> httpClientSpy, null);
});
it('should save location to server', function () {
const expectedData: any =
[{ id: 1, name: 'A' }, { id: 2, name: 'B' }];
httpClientSpy.post.and.returnValue(asyncData(expectedData));
findLocalsService.saveLocation('something').subscribe(
data => expect(data).toEqual(expectedData),
fail
);
expect(httpClientSpy.post.calls.count()).toBe(1, 'one call');
});
</code></pre>
<p><strong>Here is the service itself</strong></p>
<pre><code>@Injectable()
export class FindLocalsService {
constructor(private http: HttpClient, private authService: AuthenticationService){}
saveLocation(locationObj){
return this.http.post(url + '/findLocals/saveLocation', locationObj);
}
getThreeClosestPlayers() {
const userId = this.authService.currentUser().user._id;
console.log('entered 3 closest service', userId);
return this.http.get(url + '/findLocals/getThreeClosestPlayers/' + userId)
.pipe(
map((data: any) => data.obj),
catchError(this.handleError)
)
}
}
</code></pre>
| 0debug
|
If statement not detecting boolean change : <p>Even though I changed the boolean, "root", the if statement uses the event that is supposed to find the square root of a number instead of doing the normal operations (addition, subtraction, etc.)</p>
<pre><code> String piCheck = "pi";
String rootCheck = "square root";
Double n1 = null;
boolean root = false;
Scanner reader = new Scanner(System.in);
System.out.println("Welcome to Calculator!");
System.out.println(" ");
System.out.println("Enter a number, ");
System.out.println("or enter 'pi' to insert PI,");
System.out.println("or enter 'square root' to find the square root of a number.");
String input = reader.nextLine();
if (input.toLowerCase().contains(piCheck)) {
n1 = Math.PI;
root = false;
} else if (input.toLowerCase().contains(rootCheck)) {
root = true;
} else {
n1 = Double.parseDouble(input);
root=false;
}
if (root = true) {
System.out.println("Which number would you like to find the square root of?");
n1 = reader.nextDouble();
System.out.println("The square root of " + n1 + " is:");
System.out.println(Math.sqrt(n1));
} else if (root != true) {
Scanner reader2 = new Scanner(System.in);
System.out.println("Would you like to multiply, divide, add, subtract?");
String uOperation = reader2.nextLine();
</code></pre>
| 0debug
|
How to check if token already exists in database table : <p>I stuck with this,</p>
<p>show an error if the token is already exists in the database table,
and if there is no token in database table this will show success message for example</p>
<pre><code>$token = cleanfrm($_REQUEST['t']);
$user = $user_info['id'];
$ad_info = $db->fetchRow(("SELECT * FROM video WHERE token='" . $token . "'"));
$logs_info = $db->fetchRow(("SELECT token FROM video_ WHERE uid='" . $user . "'"));
if ($logs_info = " . $ad_token . ") {
$error_msg = "<div class='message'>you already watch this video </div>";
}else {
$error_msg = "<div class='message'>Click here to watch </div>";
}
</code></pre>
| 0debug
|
Skip object items if the value is null : <p>I have a nested <code>for ... in</code> loop in vue js. What I'm trying to to is to skip elements if the value of the element is <code>null</code>. Here is the html code:</p>
<pre><code><ul>
<li v-for="item in items" track-by="id">
<ol>
<li v-for="child in item.children" track-by="id"></li>
</ol>
</li>
</ul>
</code></pre>
<p><code>null</code> elements may be present in both <code>item</code> and <code>item.children</code> objects.</p>
<p>For example:</p>
<pre><code>var data = {
1: {
id: 1,
title: "This should be rendered",
children: {
100: {
id: 100,
subtitle: "I am a child"
},
101: null
}
},
2: null,
3: {
id: 3,
title: "Should should be rendered as well",
children: {}
}
};
</code></pre>
<p>With this data <code>data[1].children[101]</code> should not be rendered and if <code>data[1].children[100]</code> becomes null later it should be omitted from the list.</p>
<p>P.S. I know this is probably not the best way to represent data but I'm not responsible for that :)</p>
| 0debug
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
static void cuda_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
{
CUDAState *s = opaque;
addr = (addr >> 9) & 0xf;
CUDA_DPRINTF("write: reg=0x%x val=%02x\n", (int)addr, val);
switch(addr) {
case 0:
s->b = val;
cuda_update(s);
break;
case 1:
s->a = val;
break;
case 2:
s->dirb = val;
break;
case 3:
s->dira = val;
break;
case 4:
s->timers[0].latch = (s->timers[0].latch & 0xff00) | val;
cuda_timer_update(s, &s->timers[0], qemu_get_clock_ns(vm_clock));
break;
case 5:
s->timers[0].latch = (s->timers[0].latch & 0xff) | (val << 8);
s->ifr &= ~T1_INT;
set_counter(s, &s->timers[0], s->timers[0].latch);
break;
case 6:
s->timers[0].latch = (s->timers[0].latch & 0xff00) | val;
cuda_timer_update(s, &s->timers[0], qemu_get_clock_ns(vm_clock));
break;
case 7:
s->timers[0].latch = (s->timers[0].latch & 0xff) | (val << 8);
s->ifr &= ~T1_INT;
cuda_timer_update(s, &s->timers[0], qemu_get_clock_ns(vm_clock));
break;
case 8:
s->timers[1].latch = val;
set_counter(s, &s->timers[1], val);
break;
case 9:
set_counter(s, &s->timers[1], (val << 8) | s->timers[1].latch);
break;
case 10:
s->sr = val;
break;
case 11:
s->acr = val;
cuda_timer_update(s, &s->timers[0], qemu_get_clock_ns(vm_clock));
cuda_update(s);
break;
case 12:
s->pcr = val;
break;
case 13:
s->ifr &= ~val;
cuda_update_irq(s);
break;
case 14:
if (val & IER_SET) {
s->ier |= val & 0x7f;
} else {
s->ier &= ~val;
}
cuda_update_irq(s);
break;
default:
case 15:
s->anh = val;
break;
}
}
| 1threat
|
Shortest possible to way to check if float is a square number : <p>I'm doing a competition which prioritizes solutions with the least characters. My current code for checking for a square number is:</p>
<pre><code>def checkSqr(x):
return x**.5 % 1 == 0
</code></pre>
<p>Is there a more compact solution?</p>
| 0debug
|
If ng-content has content or empty Angular2 : <p>I am trying to understand how to create an if to show when a <code>ng-content</code> is empty.</p>
<pre><code><div #contentWrapper [hidden]="isOpen">
<ng-content ></ng-content>
</div>
<span *ngIf="contentWrapper.childNodes.length == 0">
<p>Display this if ng-content is empty!</p>
</span>
</code></pre>
<p>I've tried to use that one to show a display data when the content is empty but even if the information is empty doesn't show the <code><span></code> tag</p>
<p>Thanks, always grateful for your help. </p>
| 0debug
|
static uint64_t macio_nvram_readb(void *opaque, hwaddr addr,
unsigned size)
{
MacIONVRAMState *s = opaque;
uint32_t value;
addr = (addr >> s->it_shift) & (s->size - 1);
value = s->data[addr];
NVR_DPRINTF("readb addr %04x val %x\n", (int)addr, value);
return value;
}
| 1threat
|
Why is `const int& k = i; ++i; ` possible? : <p>I am supposed to determine whether this function is syntactically correct:</p>
<p><code>int f3(int i, int j) { const int& k=i; ++i; return k; }</code></p>
<p>I have tested it out and it compiles with my main function. </p>
<p>I do not understand why this is so. </p>
<p>Surely by calling the function <code>f3</code> I create copies of the variables <code>i</code>and <code>j</code> in a new memory space and setting <code>const int& k=i</code> I am setting the memory space of the newly created <code>k</code> to the exact the same space of the memory space of the copied <code>i</code>, therefore any change, i.e. the increment <code>++i</code>will result in <code>++k</code> which is not possible given that it was set <code>const</code></p>
<p>Any help is greatly appreciated</p>
| 0debug
|
Got an error when trying to get the geolocation in safari on iOS 10 : <p>[blocked] Access to geolocation was blocked over insecure connection to <a href="http://www.hnsjb.cn" rel="noreferrer">http://www.hnsjb.cn</a>.</p>
<p>Should I change my website to the https protocol?</p>
| 0debug
|
Why does HttpClient appear to hang without .Result? : <p>I have this code to call an API which returns a token. However, it will only return if I replace this line:</p>
<pre><code>var response = await TokenClient.PostAsync(EnvironmentHelper.TokenUrl, formContent);
</code></pre>
<p>with this line:</p>
<pre><code>var response = TokenClient.PostAsync(EnvironmentHelper.TokenUrl, formContent).Result;
</code></pre>
<p>Why?</p>
<pre><code>public static async Task<Token> GetAPIToken()
{
if (DateTime.Now < Token.Expiry)
return Token;
TokenClient.DefaultRequestHeaders.Clear();
TokenClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
TokenClient.BaseAddress = new Uri(EnvironmentHelper.BaseUrl);
TokenClient.Timeout = TimeSpan.FromSeconds(3);
var formContent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("grant_type", "client_credentials"),
new KeyValuePair<string, string>("client_id", EnvironmentHelper.APITokenClientId),
new KeyValuePair<string, string>("client_secret", EnvironmentHelper.APITokenClientSecret)
});
try
{
// HANGS - this next line will only ever return if suffixed with '.Result'
var response = await TokenClient.PostAsync(EnvironmentHelper.TokenUrl, formContent);
var content = await response.Content.ReadAsStringAsync();
dynamic jsonContent = JsonConvert.DeserializeObject(content);
Token token = new Token();
token.AccessToken = jsonContent.access_token;
token.Type = jsonContent.token_type;
token.Expiry = DateTimeOffset.Now.AddSeconds(Convert.ToDouble(jsonContent.expires_in.ToString()) - 30);
token.Scope = Convert.ToString(jsonContent.scope).Split(' ');
Token = token;
}
catch (Exception ex)
{
var m = ex.Message;
}
return Token;
}
</code></pre>
| 0debug
|
C: why int[] array is not allowed in C or C++ : <pre><code>int main() {
int[3] arr = { 11, 22, 33 };
}
</code></pre>
<p>Error: expected identifier or ‘(’ before ‘[’ token</p>
<p>As far as I remember, this was allowed in C to declare an array either with "int[3] arr" (NOT OK) or "int arr[3]" (OK). I tried to find a reason but to no avail. I will appreciate any insight.</p>
<p>Used gcc version: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609</p>
| 0debug
|
Whats happening in memory when I use references in c++? : <p>Let me start by saying that I understand pointers. I know what they are and how they work. But I know them because I visually imagine how they are being used in memory by saving the address of something else and so on.</p>
<p>I'm trying to find information online and I can seem to find any information on how references are treated.</p>
<p>Could someone either link or explain how they work having memory management in mind?</p>
<p>thx</p>
| 0debug
|
uint32_t HELPER(neon_narrow_sat_s32)(CPUState *env, uint64_t x)
{
if ((int64_t)x != (int32_t)x) {
SET_QC();
return (x >> 63) ^ 0x7fffffff;
}
return x;
}
| 1threat
|
Anther Solution For Running Python file from C# With out ironpython : <p>i am not <strong>python</strong> permanent user how to run <strong>python script</strong> by click event from <strong>visual studio 2012</strong>. </p>
| 0debug
|
static int hda_audio_post_load(void *opaque, int version)
{
HDAAudioState *a = opaque;
HDAAudioStream *st;
int i;
dprint(a, 1, "%s\n", __FUNCTION__);
if (version == 1) {
for (i = 0; i < ARRAY_SIZE(a->running_compat); i++)
a->running_real[16 + i] = a->running_compat[i];
}
for (i = 0; i < ARRAY_SIZE(a->st); i++) {
st = a->st + i;
if (st->node == NULL)
continue;
hda_codec_parse_fmt(st->format, &st->as);
hda_audio_setup(st);
hda_audio_set_amp(st);
hda_audio_set_running(st, a->running_real[st->output * 16 + st->stream]);
}
return 0;
}
| 1threat
|
document.write('<script src="evil.js"></script>');
| 1threat
|
Why do my app crash? : I am a beginner making Android apps. Try doing a tutorial and add a Relative layout and a Gridlayout and some Imageviews. But my app crash.
MainActivity.java
package se.jakobia.connect3;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
public void dropIn(View view) {
ImageView counter =(ImageView)view;
counter.setTranslationY(-1000f);
counter.setImageResource(R.drawable.yellow);
counter.animate().translationYBy(1000f).setDuration(300);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
and activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="se.jakobia.connect3.MainActivity">
<GridLayout
android:layout_width="match_parent"
android:layout_height="360dp"
android:layout_centerVertical="true"
android:background="@drawable/board"
android:columnCount="3"
android:rowCount="3">
<ImageView
android:id="@+id/imageView"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_column="0"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_row="0"
android:src="@drawable/red" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_column="1"
android:layout_marginBottom="10dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_row="0"
android:src="@drawable/red" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_column="2"
android:layout_marginBottom="10dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_row="0"
android:src="@drawable/red" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_column="0"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:layout_row="1"
android:src="@drawable/red" />
<ImageView
android:id="@+id/imageView5"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_column="1"
android:layout_marginLeft="40dp"
android:layout_marginTop="30dp"
android:layout_row="1"
android:onClick="dropIn" />
<ImageView
android:id="@+id/imageView6"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_column="2"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:layout_row="1"
android:src="@drawable/red" />
<ImageView
android:id="@+id/imageView7"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_column="0"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:layout_row="2"
android:src="@drawable/red" />
<ImageView
android:id="@+id/imageView8"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_column="1"
android:layout_marginLeft="40dp"
android:layout_marginTop="30dp"
android:layout_row="2"
android:src="@drawable/red" />
<ImageView
android:id="@+id/imageView9"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_column="2"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:layout_row="2"
android:src="@drawable/red" />
</GridLayout>
</RelativeLayout>
I got an error message FATAL EXCEPTION: main. And fatal Exceptions main. I dont understand what the error message does mean.
I think I havnt done so much just so I dont understand why it is not working.
| 0debug
|
Xcode 9 Jump to definition in a new tab, window, or other navigation area with Option-Shift-Command+Click : <p>Xcode 9 seems to be missing jump to definition shortcut Option-Shift-Command+Click. You used to be able to use to open definition in a new tab, window, or other navigation areas with Option-Shift-Command+Click. In Xcode 9 this still works from the file navigator but not when you use this on a class. Has anyone been able to figure out how to use this shortcut in xcode 9?</p>
| 0debug
|
bundle install error - Your bundle only supports platforms [] but your local platforms are ["ruby", "x86_64-linux"] : <p>Getting this error doing a bundle install; google around seems like a common issue but I can't seem to find the fix (seem suggestion on Gemfile.lock but I moved that file to another directory)</p>
<pre><code># bundle install
Your bundle only supports platforms [] but your local platforms are ["ruby", "x86_64-linux"], and there's no compatible match between those two lists.
</code></pre>
<p>Here's my Gemfile and there is no Gemfile.lock in the directory.</p>
<pre><code>[root@ip-172-30-4-16 rails]# gem -v
2.6.11
[root@ip-172-30-4-16 rails]# ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
[root@ip-172-30-4-16 rails]# bundle -v
Bundler version 1.14.6
[root@ip-172-30-4-16 rails]# cat Gemfile
source 'http://rubygems.org'
gem 'echoe'
gem 'rails', '~> 3.2.11'
gem 'mysql2'
gem 'prawn', '~> 0.5.0.1'
gem 'prawn-core', '~> 0.5.0.1', :require => 'prawn/core'
gem 'prawn-layout', '~> 0.2.0.1', :require => 'prawn/layout'
gem 'prawn-format', '~> 0.2.0.1', :require => 'prawn/format'
gem 'spreadsheet', '~> 0.6.5'
gem 'libxml-ruby', :require => 'libxml_ruby'
gem 'faker'
gem 'json'
gem 'rake'
gem 'jquery-rails'
gem 'therubyracer'
gem 'delayed_job_active_record'
gem 'daemons'
gem 'memcache-client'
gem 'rb-readline'
gem 'rubyzip', '~> 1.0.0'
gem 'zip-zip' # Rubyzip old API compatibility addon
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
#group :development do
# gem 'ruby-debug19'
#end
group :test do
gem 'flexmock', '= 0.9.0'
gem 'machinist', '= 2.0'
gem 'test-unit', '~> 1.2.3'
# Use SimpleCov and Coveralls for test coverage reports
gem 'simplecov'
gem 'coveralls'
end
group :production do
gem 'passenger'
end
group :test, :development do
gem 'rspec-rails', '~> 2.0'
end
</code></pre>
| 0debug
|
int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
{
graph->filters = av_realloc(graph->filters,
sizeof(AVFilterContext*) * ++graph->filter_count);
if (!graph->filters)
return AVERROR(ENOMEM);
graph->filters[graph->filter_count - 1] = filter;
return 0;
}
| 1threat
|
Scraping data when javascript is involved? : <p>I'm really new to web stuff so plz forgive my noobness. I am trying to make website that takes data from a British cycling event then analyses it. The main trouble that I'm having is that to get the table, you have to click on a button "view entrants" which I think runs a JavaScript which brings up the table. So how would I go about scraping the data from a given event?</p>
<p>Thanks in advanced</p>
<p>Here is an example: <a href="https://www.britishcycling.org.uk/events/details/141520/London-Dynamo-Summer-Road-Race-2016" rel="nofollow">https://www.britishcycling.org.uk/events/details/141520/London-Dynamo-Summer-Road-Race-2016</a></p>
| 0debug
|
static int local_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
{
char buffer[PATH_MAX];
char *path = fs_path->data;
if (fs_ctx->fs_sm == SM_MAPPED) {
return local_set_xattr(rpath(fs_ctx, path, buffer), credp);
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
(fs_ctx->fs_sm == SM_NONE)) {
return chmod(rpath(fs_ctx, path, buffer), credp->fc_mode);
}
return -1;
}
| 1threat
|
Adding a class to an ArrayList, but got NullPointerException : <p>So, I was trying to add a class to an ArrayList, but when I do it gives me a Null Pointer Exception. I'm sure I am just overlooking a variable that I thought was initialized, but I can't figure it out. </p>
<p>This is the class:</p>
<pre><code>enum WebType { GoogleResult, Webpage };
public class Webpage {
WebType type;
String pageName;
String content;
String url;
String MLA = "";
public Webpage(String pageName, String content, String url, WebType type){
this.type = type;
this.pageName = pageName;
this.content = content;
this.url = url;
this.MLA = ""; // Temp
}
// TODO: Make Citation Maker
</code></pre>
<p>}</p>
<p>This is where I add the class to the ArrayList:</p>
<pre><code> public void Start(){
for(Integer i = 0; i < tags.size(); i++){
if(tags.get(i) == null)
return;
Webpage page = Google(tags.get(i));
parseList.add(page); // The Error is on this line!
log.append("Added " + page.url + " to parse list");
}
for(Integer i = 0; i < parseList.size(); i++){
ParsePageCode(parseList.get(i));
}
}
</code></pre>
<p>Here is the Google function, it googles whatever you tell it to and returns the page information:</p>
<pre><code> public Webpage Google(String search){
String url = "https://www.google.com/search?q=" + search;
String content = "";
try {
URLEncoder.encode(url, "UTF-8");
} catch (UnsupportedEncodingException e) {
log.append("\n Unsupported Encoding Contacting Google");
}
try {
content = GetPageCode(url);
} catch (IOException e) {
log.append("\n Unable To Reach Google");
log.append(e.getMessage());
}
Webpage w = new Webpage("Google Result For " + search, content, url, WebType.GoogleResult);
// System.out.println(search + url + WebType.GoogleResult);
return w;
}
</code></pre>
<p>Any Ideas?</p>
| 0debug
|
Generate Apk from ionic cordova : **> cordova.cmd build android
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\Newsoft\AppData\Local\Android\sdk (DEPRECATED)
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
[ERROR] An error occurred while running subprocess cordova.**
please can any one help me
i need to generate build apk from ionic angular project
but they have an problem for android environment
and sdk root i setup android studio with all configuration but the error is still
| 0debug
|
static void gif_fill_rect(AVFrame *picture, uint32_t color, int l, int t, int w, int h)
{
const int linesize = picture->linesize[0] / sizeof(uint32_t);
const uint32_t *py = (uint32_t *)picture->data[0] + t * linesize;
const uint32_t *pr, *pb = py + (t + h) * linesize;
uint32_t *px;
for (; py < pb; py += linesize) {
px = (uint32_t *)py + l;
pr = px + w;
for (; px < pr; px++)
*px = color;
}
}
| 1threat
|
How to write a c# windows forms application that uses Gmail API? : <p>I find the Google documentation quite confusing.
Any good tutorials about this?</p>
| 0debug
|
void helper_store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask)
{
uint32_t prev, new;
int i;
prev = env->fpscr;
new = (uint32_t)arg;
new &= ~0x60000000;
new |= prev & 0x60000000;
for (i = 0; i < 8; i++) {
if (mask & (1 << i)) {
env->fpscr &= ~(0xF << (4 * i));
env->fpscr |= new & (0xF << (4 * i));
}
}
if (fpscr_ix != 0) {
env->fpscr |= 1 << FPSCR_VX;
} else {
env->fpscr &= ~(1 << FPSCR_VX);
}
if ((fpscr_ex & fpscr_eex) != 0) {
env->fpscr |= 1 << FPSCR_FEX;
env->exception_index = POWERPC_EXCP_PROGRAM;
env->error_code = POWERPC_EXCP_FP;
} else {
env->fpscr &= ~(1 << FPSCR_FEX);
}
fpscr_set_rounding_mode(env);
}
| 1threat
|
Regional/Edge-optimized API Gateway VS Regional/Edge-optimized custom domain name : <p>This does not make sense to me at all. When you create a new API Gateway you can specify whether it should be regional or edge-optimized. But then again, when you are creating a custom domain name for API Gateway, you can choose between the two.</p>
<p>Worst of all, you can mix and match them!!! You can have a regional custom domain name for an edge-optimized API gateway and it's absolutely meaningless to me!</p>
<p>Why these two can be regional/edge-optimized separately? And when do I want each of them to be regional/edge-optimized?</p>
| 0debug
|
What does the constant E do in the c language : <p>When I run the code below</p>
<pre><code>int main(int argc,char *argv[]) {
double n = 2E-1;
printf("%d",n);
}
</code></pre>
<p>When I run the code it prints a weird number instead of 0.2(2E-1).</p>
| 0debug
|
React-Native run-android on specific device : <p>Is it possible to use the <code>run-android</code> command for one specific device only?</p>
<p>For example, if I have three devices (or emulators) connected and I want to use <code>run-android</code> on only one of them?</p>
<p>Maybe something like <code>adb install -s DEVICE_NUMBER</code>?</p>
<p>Thanks in advance</p>
| 0debug
|
Can factory provider have optional dependencies? : <p>For example:</p>
<pre><code>@NgModule ({
providers: [
{ provide: MyService,
useFactory: (optionalDep) => new MyService(optionalDep)
deps: [SOME_DEP]
}
})
class MyModule {}
</code></pre>
<p>Can <strong>useFactory</strong> have optional dependencies? </p>
| 0debug
|
getting java.lang.IllegalArgumentException: width and height must be > 0 error while initializing Mat in android : I am trying to initialize Mat and this is my code
Mat imgRgba = new Mat();
final Bitmap bitmap =
Bitmap.createBitmap(imgRgba.width(), imgRgba.height(), Bitmap.Config.RGB_565);
Utils.matToBitmap(imgRgba, bitmap);
I have tried this too
Bitmap.createBitmap(imgRgba.cols(), imgRgba.rows(), Bitmap.Config.RGB_565);
but when I am going to run my app I am getting crash and exception is this
Stack trace:
java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:969)
at android.graphics.Bitmap.createBitmap(Bitmap.java:948)
at android.graphics.Bitmap.createBitmap(Bitmap.java:915)
at com.jmr.agency.banking.ui.facerecognition.FRAddPersonPreviewActivity.onCameraFrame(FRAddPersonPreviewActivity.java:156)
| 0debug
|
static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int size;
FFMContext *ffm = s->priv_data;
int duration, ret;
switch(ffm->read_state) {
case READ_HEADER:
if ((ret = ffm_is_avail_data(s, FRAME_HEADER_SIZE+4)) < 0)
return ret;
av_dlog(s, "pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n",
avio_tell(s->pb), s->pb->pos, ffm->write_index, ffm->file_size);
if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) !=
FRAME_HEADER_SIZE)
return -1;
if (ffm->header[1] & FLAG_DTS)
if (ffm_read_data(s, ffm->header+16, 4, 1) != 4)
return -1;
ffm->read_state = READ_DATA;
case READ_DATA:
size = AV_RB24(ffm->header + 2);
if ((ret = ffm_is_avail_data(s, size)) < 0)
return ret;
duration = AV_RB24(ffm->header + 5);
av_new_packet(pkt, size);
pkt->stream_index = ffm->header[0];
if ((unsigned)pkt->stream_index >= s->nb_streams) {
av_log(s, AV_LOG_ERROR, "invalid stream index %d\n", pkt->stream_index);
av_free_packet(pkt);
ffm->read_state = READ_HEADER;
return -1;
}
pkt->pos = avio_tell(s->pb);
if (ffm->header[1] & FLAG_KEY_FRAME)
pkt->flags |= AV_PKT_FLAG_KEY;
ffm->read_state = READ_HEADER;
if (ffm_read_data(s, pkt->data, size, 0) != size) {
av_free_packet(pkt);
return -1;
}
pkt->pts = AV_RB64(ffm->header+8);
if (ffm->header[1] & FLAG_DTS)
pkt->dts = pkt->pts - AV_RB32(ffm->header+16);
else
pkt->dts = pkt->pts;
pkt->duration = duration;
break;
}
return 0;
}
| 1threat
|
Prevent function taking const std::string& from accepting 0 : <p>Worth a thousand words:</p>
<pre><code>#include<string>
#include<iostream>
class SayWhat {
public:
SayWhat& operator[](const std::string& s) {
std::cout<<"here\n"; // To make sure we fail on function entry
std::cout<<s<<"\n";
return *this;
}
};
int main() {
SayWhat ohNo;
// ohNo[1]; // Does not compile. Logic prevails.
ohNo[0]; // you didn't! this compiles.
return 0;
}
</code></pre>
<p>The compiler is not complaining when passing the number 0 to the bracket operator accepting a string. Instead, this compiles and fails before entry to the method with:</p>
<pre><code>terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
</code></pre>
<p>For reference:</p>
<pre><code>> g++ -std=c++17 -O3 -Wall -Werror -pedantic test.cpp -o test && ./test
> g++ --version
gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)
</code></pre>
<p><strong>My guess</strong></p>
<p>The compiler is implicitly using the <code>std::string(0)</code> constructor to enter the method, which yields the same problem (google the above error) for no good reason.</p>
<p><strong>Question</strong></p>
<p>Is there anyway to fix this on the class side, so the API user does not feel this and the error is detected at compile time? </p>
<p>That is, adding an overload</p>
<pre><code>void operator[](size_t t) {
throw std::runtime_error("don't");
}
</code></pre>
<p>is not a good solution.</p>
| 0debug
|
How to get an array of all sub-entries of an array? : <p>Is it possible to get an array of all <em>subentries</em> with a certain name of an array? For example, I have this array: </p>
<pre><code>var array = [
{
"char": "a",
"number": 5
},
{
"char": "x",
"number": 9
},
{
"char": "u",
"number": 2
},
{
"char": "q",
"number": 4
}
];
</code></pre>
<p>How can I then get an array of all <em>number</em> (or all <em>char</em>) entries like this?</p>
<p><code>*returned array* = ["a", "x", "u", "q"];</code> or <code>*returned array* = [5, 9, 2, 4];</code></p>
<p>A simple (one-line) solution would be most helpful. Thanks in advance!</p>
| 0debug
|
How to give glow to linearlayout? : <p>I tried giving glow to linear layout like we give to textview :</p>
<pre><code> <style name="shadowstyle">
<item name="android:textColor">@color/clrab</item>
<item name="android:shadowColor">@color/clrab</item>
<item name="android:textStyle">bold</item>
<item name="android:shadowDx">0.0</item>
<item name="android:shadowDy">0.0</item>
<item name="android:shadowRadius">8</item>
</style>
</code></pre>
<p>But it isn't working for linearlayout.</p>
<p>I want a output like this :</p>
<p><a href="https://i.stack.imgur.com/nIh9b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nIh9b.png" alt="enter image description here"></a></p>
<p>How to I give this glow to this linearlayout.</p>
<p>I am trying cardview layout but not working.</p>
| 0debug
|
Passing data within Shiny Modules from Module 1 to Module 2 : <p>I dont have a reproducible example as the question is more on how modules work. I am trying to understand how to pass some reactive function from one module to the next. I have received replies in the past about using ObserveEvent but they have not seem to work when I am using the reactive value in one module to perform some other operation in another module</p>
<pre><code>module1 <- function(input, output, session){
data1<-reactive({
#some reacttive funcion that produces an output
})
data2<-reactive({
#some reacttive funcion that produces another output
})
return(list(data1,data2))
}
module2 <- function(input, output, session,data1){
observe( data1(), {
#perform some other functions here using data1().e.g reading or parsing data
})
}
</code></pre>
<p>So basically I have a module1 that returns two outputs from data1 and data2</p>
<p>I want to use the value of data1 in module 2 and perform some new operation using that value.</p>
<p>I have looked at other answers to similar questions here but I still dont understand them. If someone can help me explain this concept more clearly that would be of great help
thanks for your help</p>
| 0debug
|
Issues with ifstream reading CSV data : <p>Non-working code:</p>
<pre><code>#include<iostream>
#include<fstream>
#include<string>
int main(){
int id; string name;char comma ; double money;
ifstream read("testfile.csv");
while (read >> id >> comma>> name >> comma >> money)
{cout << id <<comma<<name<<comma<<money<< endl ;}
read.close();
_getch();
return 0;}
</code></pre>
<p>The csv file data & structure:</p>
<p><code>1,user1,999
2,user2,33
3,user3,337</code></p>
<p>But, the following works fine. Why so?</p>
<p><code>while (read >> id >>comma>>name)
{cout << id<<comma<<name <<endl ;}</code></p>
| 0debug
|
xamp - fatal eror (notpad++) :
Notice: Undefined variable: con in C:\xampp\htdocs\projekt\ps.php on line 34
Fatal error: Call to a member function query() on null in C:\xampp\htdocs\projekt\ps.php on line 34
This opened in my browser, i looked for other replay on this quedition but i cound't find a resolve..``
Problem is here in index.html
<?php
$res -$con->query("SELECT * FROM studenti");
while ($row=$res->fetch_array()){
?>
This is base:
<?php
$con =mysqli_connect('localhost', 'root','');
if(!$con)
{
echo 'Not connected';
}
if(!mysqli_select_db($con,'studenti'))
{
echo 'database not selected';
}
?>
| 0debug
|
How to get all Airlines from DBpedia in Asia : <p>I'm just learning querying DBpedia. How would look query to return all Airline companies located in Asia that have income greater than X and are used by Y passengers.</p>
| 0debug
|
If statement not evaluating all the conditions and executing anyway : <p>Ok so I am new to python and trying to learn how to code. I ran into an issue today that I don't understand. So this code executes as expected and prints the largest of the three numbers no matter what position the largest number is.</p>
<pre><code> if num1 >= num2 and num3:
print(num1, 'Is the greatest number!')
elif num2 >= num3 and num1:
print(num2, 'Is the greatest number!')
else:
print(num3, 'Is the greatest number')
</code></pre>
<p>But if i change the elif statement to this:</p>
<pre><code> elif num2 >= num1 and num3:
print(num2, 'Is the greatest number!')
</code></pre>
<p>Even if num3 is the largest the else statement will not execute and it will display the larger number of num1 or num2. </p>
| 0debug
|
static int alloc_buffer(AVCodecContext *s, InputStream *ist, FrameBuffer **pbuf)
{
FrameBuffer *buf = av_mallocz(sizeof(*buf));
int i, ret;
const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1;
int h_chroma_shift, v_chroma_shift;
int edge = 32;
int w = s->width, h = s->height;
if (!buf)
return AVERROR(ENOMEM);
if (!(s->flags & CODEC_FLAG_EMU_EDGE)) {
w += 2*edge;
h += 2*edge;
}
avcodec_align_dimensions(s, &w, &h);
if ((ret = av_image_alloc(buf->base, buf->linesize, w, h,
s->pix_fmt, 32)) < 0) {
av_freep(&buf);
return ret;
}
memset(buf->base[0], 128, ret);
avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) {
const int h_shift = i==0 ? 0 : h_chroma_shift;
const int v_shift = i==0 ? 0 : v_chroma_shift;
if (s->flags & CODEC_FLAG_EMU_EDGE)
buf->data[i] = buf->base[i];
else
buf->data[i] = buf->base[i] +
FFALIGN((buf->linesize[i]*edge >> v_shift) +
(pixel_size*edge >> h_shift), 32);
}
buf->w = s->width;
buf->h = s->height;
buf->pix_fmt = s->pix_fmt;
buf->ist = ist;
*pbuf = buf;
return 0;
}
| 1threat
|
echo out a php variable inside a class : <p>I'm trying to echo out a php variable inside a div like that <code><div class="kor $value"></code></p>
<pre><code> $value = get_theme_mod( 'ani', 'fadeIn' );
$output .= apply_filters( 'wal') ? '<div class="kor' <?php echo $value' ">':'');
</code></pre>
| 0debug
|
Code explanation with strings : <p>Okay, so I am trying to be able to explain the answer to the question below to a friend, but I don't know how. I know that the process method doesn't change s and that the answer is ABCD (s is unchanged), but I don't know why. Is it because strings are immutable? My friend thinks it should be CBA. Any help?</p>
<pre><code>public void process(String s)
{
s = s.substring(2, 3) + s.substring(1, 2) + s.substring(0, 1);
}
</code></pre>
<p>What is printed as a result of executing the following statements (in a method in the same class)?</p>
<pre><code>String s = “ABCD”;
process(s);
System.out.println(s);
</code></pre>
| 0debug
|
What is the syntax to accept only numbers and ignore any extra signs like "%" as user input in python? : I am using Python 3. I want the user to input the interest and I know that they will answer it with a % symbol following it.
My current syntax is
interest = input ('Enter the interest ')
(Does using raw_input help ? It didn't even work somehow)
| 0debug
|
static void invalidate_tlb (int idx, int use_extra)
{
tlb_t *tlb;
target_ulong addr;
uint8_t ASID;
ASID = env->CP0_EntryHi & 0xFF;
tlb = &env->tlb[idx];
if (tlb->G == 0 && tlb->ASID != ASID) {
return;
}
if (use_extra && env->tlb_in_use < MIPS_TLB_MAX) {
env->tlb[env->tlb_in_use] = *tlb;
env->tlb_in_use++;
return;
}
if (tlb->V0) {
tb_invalidate_page_range(tlb->PFN[0], tlb->end - tlb->VPN);
addr = tlb->VPN;
while (addr < tlb->end) {
tlb_flush_page (env, addr);
addr += TARGET_PAGE_SIZE;
}
}
if (tlb->V1) {
tb_invalidate_page_range(tlb->PFN[1], tlb->end2 - tlb->end);
addr = tlb->end;
while (addr < tlb->end2) {
tlb_flush_page (env, addr);
addr += TARGET_PAGE_SIZE;
}
}
}
| 1threat
|
Can Android Instant Apps handle deep links? : I want do develop a really simple Android prototype app.
The app needs to be compatible with Android Instant Apps. The user will open the app without installing it (Instant Apps). The user will use chrome to navigate to https://example.com/path (deep link). The app will show a dialog with "Hello World" automatically because user navigated to https://example.com/path (deep link on AndroidManifest).
Is this possible with Instant Apps or just with installed apps?
Thanks.
| 0debug
|
Can I declare an array to Firebase Remote config? : <p>I am a novice to Android and Firebase.
Is it possible to declare an array inside the the Parameter key of Firebase Remote Config?
<a href="https://i.stack.imgur.com/01ku6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/01ku6.png" alt="enter image description here"></a></p>
<p>I want to provide some promotions to some specific models/mobile devices. So if I could declare an array of models(i,e, Samsung J5, Xiaomi Note2 etc) I could easily enable promotions on those models.
Please help me.</p>
| 0debug
|
How to refresh different page if a button was clicked in javascript or jquery . : So i have this form where the admin update all the products info and prices and whenever he click save it button, i want that different page who display all product to be refreshed so that it will update the changes. Which the client will see an updated info and they don't have to manually refresh it.
| 0debug
|
Can someone please tell me why my "name" class goes over my navigation menu on mobile please : <p>When viewed at mobile and tablet, my "name" class will conflict with my burger menu.</p>
<p><a href="https://johnblairgraphicart.firebaseapp.com/" rel="nofollow noreferrer">https://johnblairgraphicart.firebaseapp.com/</a></p>
| 0debug
|
def count_unset_bits(n):
count = 0
x = 1
while(x < n + 1):
if ((x & n) == 0):
count += 1
x = x << 1
return count
| 0debug
|
Jenkins Pipeline sh bad substitution : <p>A step in my pipeline uploads a .tar to an artifactory server. I am getting a Bad substitution error when passing in env.BUILD_NUMBER, but the same commands works when the number is hard coded. The script is written in groovy through jenkins and is running in the jenkins workspace.</p>
<pre><code>sh 'curl -v --user user:password --data-binary ${buildDir}package${env.BUILD_NUMBER}.tar -X PUT "http://artifactory.mydomain.com/artifactory/release-packages/package${env.BUILD_NUMBER}.tar"'
</code></pre>
<p>returns the errors:</p>
<pre><code>[Pipeline] sh
[Package_Deploy_Pipeline] Running shell script
/var/lib/jenkins/workspace/Package_Deploy_Pipeline@tmp/durable-4c8b7958/script.sh: 2:
/var/lib/jenkins/workspace/Package_Deploy_Pipeline@tmp/durable-4c8b7958/script.sh: Bad substitution
[Pipeline] } //node
[Pipeline] Allocate node : End
[Pipeline] End of Pipeline
ERROR: script returned exit code 2
</code></pre>
<p>If hard code in a build number and swap out <code>${env.BUILD_NUMBER}</code> I get no errors and the code runs successfully.</p>
<pre><code>sh 'curl -v --user user:password --data-binary ${buildDir}package113.tar -X PUT "http://artifactory.mydomain.com/artifactory/release-packages/package113.tar"'
</code></pre>
<p>I use ${env.BUILD_NUMBER} within other sh commands within the same script and have no issues in any other places.</p>
| 0debug
|
static int reap_filters(void)
{
AVFilterBufferRef *picref;
AVFrame *filtered_frame = NULL;
int i;
int64_t frame_pts;
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
OutputFile *of = output_files[ost->file_index];
int ret = 0;
if (!ost->filter)
continue;
if (!ost->filtered_frame && !(ost->filtered_frame = avcodec_alloc_frame())) {
return AVERROR(ENOMEM);
} else
avcodec_get_frame_defaults(ost->filtered_frame);
filtered_frame = ost->filtered_frame;
while (1) {
ret = av_buffersink_get_buffer_ref(ost->filter->filter, &picref,
AV_BUFFERSINK_FLAG_NO_REQUEST);
if (ret < 0) {
if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
char buf[256];
av_strerror(ret, buf, sizeof(buf));
av_log(NULL, AV_LOG_WARNING,
"Error in av_buffersink_get_buffer_ref(): %s\n", buf);
frame_pts = AV_NOPTS_VALUE;
if (picref->pts != AV_NOPTS_VALUE) {
filtered_frame->pts = frame_pts = av_rescale_q(picref->pts,
ost->filter->filter->inputs[0]->time_base,
ost->st->codec->time_base) -
av_rescale_q(of->start_time,
AV_TIME_BASE_Q,
ost->st->codec->time_base);
if (of->start_time && filtered_frame->pts < 0) {
avfilter_unref_buffer(picref);
continue;
switch (ost->filter->filter->inputs[0]->type) {
case AVMEDIA_TYPE_VIDEO:
avfilter_copy_buf_props(filtered_frame, picref);
filtered_frame->pts = frame_pts;
if (!ost->frame_aspect_ratio)
ost->st->codec->sample_aspect_ratio = picref->video->sample_aspect_ratio;
do_video_out(of->ctx, ost, filtered_frame);
case AVMEDIA_TYPE_AUDIO:
avfilter_copy_buf_props(filtered_frame, picref);
filtered_frame->pts = frame_pts;
do_audio_out(of->ctx, ost, filtered_frame);
default:
av_assert0(0);
avfilter_unref_buffer(picref);
return 0;
| 1threat
|
i want to open .pdf file in android application via android studio. : I want to open document file in android application with help of android studio. How can be possible ? Should i need to use web view ? I had try source code from many web but file was opened by other aaplication
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.