problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
vmxnet3_io_bar1_write(void *opaque,
hwaddr addr,
uint64_t val,
unsigned size)
{
VMXNET3State *s = opaque;
switch (addr) {
case VMXNET3_REG_VRRS:
VMW_CBPRN("Write BAR1 [VMXNET3_REG_VRRS] = %" PRIx64 ", size %d",
val, size);
break;
case VMXNET3_REG_UVRS:
VMW_CBPRN("Write BAR1 [VMXNET3_REG_UVRS] = %" PRIx64 ", size %d",
val, size);
break;
case VMXNET3_REG_DSAL:
VMW_CBPRN("Write BAR1 [VMXNET3_REG_DSAL] = %" PRIx64 ", size %d",
val, size);
if (val == 0) {
s->device_active = false;
}
s->temp_shared_guest_driver_memory = val;
s->drv_shmem = 0;
break;
case VMXNET3_REG_DSAH:
VMW_CBPRN("Write BAR1 [VMXNET3_REG_DSAH] = %" PRIx64 ", size %d",
val, size);
s->drv_shmem = s->temp_shared_guest_driver_memory | (val << 32);
break;
case VMXNET3_REG_CMD:
VMW_CBPRN("Write BAR1 [VMXNET3_REG_CMD] = %" PRIx64 ", size %d",
val, size);
vmxnet3_handle_command(s, val);
break;
case VMXNET3_REG_MACL:
VMW_CBPRN("Write BAR1 [VMXNET3_REG_MACL] = %" PRIx64 ", size %d",
val, size);
s->temp_mac = val;
break;
case VMXNET3_REG_MACH:
VMW_CBPRN("Write BAR1 [VMXNET3_REG_MACH] = %" PRIx64 ", size %d",
val, size);
vmxnet3_set_variable_mac(s, val, s->temp_mac);
break;
case VMXNET3_REG_ICR:
VMW_CBPRN("Write BAR1 [VMXNET3_REG_ICR] = %" PRIx64 ", size %d",
val, size);
g_assert_not_reached();
break;
case VMXNET3_REG_ECR:
VMW_CBPRN("Write BAR1 [VMXNET3_REG_ECR] = %" PRIx64 ", size %d",
val, size);
vmxnet3_ack_events(s, val);
break;
default:
VMW_CBPRN("Unknown Write to BAR1 [%" PRIx64 "] = %" PRIx64 ", size %d",
addr, val, size);
break;
}
}
| 1threat
|
Javascript array and image : <p>Okay so I've asked this question before but I didn't get the answer that solved my problem, I'll try to explain it better. So let say I have a array with 3 items and let say it landed on 0 I have a code set up for which it will display in div now I need the image to be displayed right next to the array that is displayed. So another example would be like I have an array of cars, BMW, civic, and Mercedes and let say I have a random number generator and it chooses 1 which is bmw the word will be displayed in the div and if the civic was picked the civic will has a civic logo next to it and if Mercedes was picked Mercedes will have a logo next to it. Also if possible I want the id added in I'll put the CSS of background-image to what ever the pic is(reasoning is I want to add some design in the picture)</p>
| 0debug
|
static av_cold int cinvideo_decode_init(AVCodecContext *avctx)
{
CinVideoContext *cin = avctx->priv_data;
unsigned int i;
cin->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
avcodec_get_frame_defaults(&cin->frame);
cin->frame.data[0] = NULL;
cin->bitmap_size = avctx->width * avctx->height;
for (i = 0; i < 3; ++i) {
cin->bitmap_table[i] = av_mallocz(cin->bitmap_size);
if (!cin->bitmap_table[i])
av_log(avctx, AV_LOG_ERROR, "Can't allocate bitmap buffers.\n");
}
return 0;
}
| 1threat
|
static inline void store_cpu_offset(TCGv var, int offset)
{
tcg_gen_st_i32(var, cpu_env, offset);
dead_tmp(var);
}
| 1threat
|
The loop does not come out : <p>I want to get a result that if i use a for loop then 'Monster' comes out 10 times.But 'Monster' came out continually. Could you tell me What the problem is?
Thank you for reading to the end:)</p>
<pre><code>private static void fight() {
for(int i=0; i<10; i++) {
while (user.isalive() && enemy.isalive()) {
user.attack(enemy);
if ( !enemy.isalive() ) break;
enemy.attack(user);
System.out.println("------------------------------");
}
if (user.isalive()) {
System.out.println("The monster is dead.");
System.out.println("------------------------------");
user.money+=enemy.money;
// System.out.println(player.money);
System.out.println("I got 100 won");
System.out.println("total won : "+user.money+"won");
enemy.hp=50;
}
else {
System.out.println("I'm dead and the game is over.");
break;
}return;
}
}
</code></pre>
| 0debug
|
static void mpc8544ds_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
PCIBus *pci_bus;
CPUState *env;
uint64_t elf_entry;
uint64_t elf_lowaddr;
target_phys_addr_t entry=0;
target_phys_addr_t loadaddr=UIMAGE_LOAD_BASE;
target_long kernel_size=0;
target_ulong dt_base=DTB_LOAD_BASE;
target_ulong initrd_base=INITRD_LOAD_BASE;
target_long initrd_size=0;
void *fdt;
int i=0;
unsigned int pci_irq_nrs[4] = {1, 2, 3, 4};
qemu_irq *irqs, *mpic, *pci_irqs;
SerialState * serial[2];
env = cpu_ppc_init("e500v2_v30");
if (!env) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
ram_size &= ~(RAM_SIZES_ALIGN - 1);
cpu_register_physical_memory(0, ram_size, qemu_ram_alloc(ram_size));
irqs = qemu_mallocz(sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
irqs[OPENPIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPCE500_INPUT_INT];
irqs[OPENPIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPCE500_INPUT_CINT];
mpic = mpic_init(MPC8544_MPIC_REGS_BASE, 1, &irqs, NULL);
if (serial_hds[0])
serial[0] = serial_mm_init(MPC8544_SERIAL0_REGS_BASE,
0, mpic[12+26], 399193,
serial_hds[0], 1);
if (serial_hds[1])
serial[0] = serial_mm_init(MPC8544_SERIAL1_REGS_BASE,
0, mpic[12+26], 399193,
serial_hds[0], 1);
pci_irqs = qemu_malloc(sizeof(qemu_irq) * 4);
pci_irqs[0] = mpic[pci_irq_nrs[0]];
pci_irqs[1] = mpic[pci_irq_nrs[1]];
pci_irqs[2] = mpic[pci_irq_nrs[2]];
pci_irqs[3] = mpic[pci_irq_nrs[3]];
pci_bus = ppce500_pci_init(pci_irqs, MPC8544_PCI_REGS_BASE);
if (!pci_bus)
printf("couldn't create PCI controller!\n");
isa_mmio_init(MPC8544_PCI_IO, MPC8544_PCI_IOLEN);
if (pci_bus) {
for (i = 0; i < nb_nics; i++) {
pci_nic_init_nofail(&nd_table[i], "virtio", NULL);
}
}
if (kernel_filename) {
kernel_size = load_uimage(kernel_filename, &entry, &loadaddr, NULL);
if (kernel_size < 0) {
kernel_size = load_elf(kernel_filename, 0, &elf_entry, &elf_lowaddr,
NULL, 1, ELF_MACHINE, 0);
entry = elf_entry;
loadaddr = elf_lowaddr;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
}
if (initrd_filename) {
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
}
if (kernel_filename) {
fdt = mpc8544_load_device_tree(dt_base, ram_size,
initrd_base, initrd_size, kernel_cmdline);
if (fdt == NULL) {
fprintf(stderr, "couldn't load device tree\n");
exit(1);
}
cpu_synchronize_state(env);
env->gpr[1] = (16<<20) - 8;
env->gpr[3] = dt_base;
env->nip = entry;
}
if (kvm_enabled())
kvmppc_init();
return;
}
| 1threat
|
static void iscsi_timed_set_events(void *opaque)
{
IscsiLun *iscsilun = opaque;
iscsi_set_events(iscsilun);
}
| 1threat
|
Input number with "+" and pointer : I have this simple input:
<input type="number" step="0.01">
This all inputs make success outputs:<br>
a) 2.00<br>
b) 2,00<br>
c) +2,00<br>
But input "+2.00" fail.
I want to know why it happens.
Js recognize "+2.00" as a number.
| 0debug
|
Android expandable/collapable layout : Please i need a way to design an expandable layout that change its hieght and elements position and state(GONE,VISIBLE) with an animation just like the pictures below
[Minimum height][1]
[Medium heght][2]
[Full height (match_parent)][2]
[1]: https://drive.google.com/file/d/1F6EPr8onnhE8clAm87N1RZhRg5yoIi9K/view?usp=drivesdk
[2]: https://drive.google.com/file/d/1_uLwZ5NPuLJJ7W5c1qISgCs6yZOFgjH7/view?usp=drivesdk
| 0debug
|
static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len)
{
unsigned int crc;
unsigned char packet[TS_PACKET_SIZE];
const unsigned char *buf_ptr;
unsigned char *q;
int first, b, len1, left;
crc = av_bswap32(av_crc(av_crc_get_table(AV_CRC_32_IEEE),
-1, buf, len - 4));
buf[len - 4] = (crc >> 24) & 0xff;
buf[len - 3] = (crc >> 16) & 0xff;
buf[len - 2] = (crc >> 8) & 0xff;
buf[len - 1] = crc & 0xff;
buf_ptr = buf;
while (len > 0) {
first = buf == buf_ptr;
q = packet;
*q++ = 0x47;
b = s->pid >> 8;
if (first)
b |= 0x40;
*q++ = b;
*q++ = s->pid;
s->cc = s->cc + 1 & 0xf;
*q++ = 0x10 | s->cc;
if (first)
*q++ = 0;
len1 = TS_PACKET_SIZE - (q - packet);
if (len1 > len)
len1 = len;
memcpy(q, buf_ptr, len1);
q += len1;
left = TS_PACKET_SIZE - (q - packet);
if (left > 0)
memset(q, 0xff, left);
s->write_packet(s, packet);
buf_ptr += len1;
len -= len1;
| 1threat
|
import math
def get_First_Set_Bit_Pos(n):
return math.log2(n&-n)+1
| 0debug
|
static int vfio_ccw_handle_request(ORB *orb, SCSW *scsw, void *data)
{
S390CCWDevice *cdev = data;
VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev);
struct ccw_io_region *region = vcdev->io_region;
int ret;
QEMU_BUILD_BUG_ON(sizeof(region->orb_area) != sizeof(ORB));
QEMU_BUILD_BUG_ON(sizeof(region->scsw_area) != sizeof(SCSW));
QEMU_BUILD_BUG_ON(sizeof(region->irb_area) != sizeof(IRB));
memset(region, 0, sizeof(*region));
memcpy(region->orb_area, orb, sizeof(ORB));
memcpy(region->scsw_area, scsw, sizeof(SCSW));
again:
ret = pwrite(vcdev->vdev.fd, region,
vcdev->io_region_size, vcdev->io_region_offset);
if (ret != vcdev->io_region_size) {
if (errno == EAGAIN) {
goto again;
}
error_report("vfio-ccw: wirte I/O region failed with errno=%d", errno);
return -errno;
}
return region->ret_code;
}
| 1threat
|
void MPV_decode_mb_internal(MpegEncContext *s, int16_t block[12][64],
int is_mpeg12)
{
const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration){
ff_xvmc_decode_mb(s);
return;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
int i,j;
av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
for(i=0; i<6; i++){
for(j=0; j<64; j++){
av_log(s->avctx, AV_LOG_DEBUG, "%5d", block[i][s->dsp.idct_permutation[j]]);
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
}
s->current_picture.qscale_table[mb_xy] = s->qscale;
if (!s->mb_intra) {
if (!is_mpeg12 && (s->h263_pred || s->h263_aic)) {
if(s->mbintra_table[mb_xy])
ff_clean_intra_table_entries(s);
} else {
s->last_dc[0] =
s->last_dc[1] =
s->last_dc[2] = 128 << s->intra_dc_precision;
}
}
else if (!is_mpeg12 && (s->h263_pred || s->h263_aic))
s->mbintra_table[mb_xy]=1;
if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==AV_PICTURE_TYPE_B) && s->avctx->mb_decision != FF_MB_DECISION_RD)) {
uint8_t *dest_y, *dest_cb, *dest_cr;
int dct_linesize, dct_offset;
op_pixels_func (*op_pix)[4];
qpel_mc_func (*op_qpix)[16];
const int linesize = s->current_picture.f.linesize[0];
const int uvlinesize = s->current_picture.f.linesize[1];
const int readable= s->pict_type != AV_PICTURE_TYPE_B || s->encoding || s->avctx->draw_horiz_band;
const int block_size = 8;
if(!s->encoding){
uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
if (s->mb_skipped) {
s->mb_skipped= 0;
assert(s->pict_type!=AV_PICTURE_TYPE_I);
*mbskip_ptr = 1;
} else if(!s->current_picture.reference) {
*mbskip_ptr = 1;
} else{
*mbskip_ptr = 0;
}
}
dct_linesize = linesize << s->interlaced_dct;
dct_offset = s->interlaced_dct ? linesize : linesize * block_size;
if(readable){
dest_y= s->dest[0];
dest_cb= s->dest[1];
dest_cr= s->dest[2];
}else{
dest_y = s->b_scratchpad;
dest_cb= s->b_scratchpad+16*linesize;
dest_cr= s->b_scratchpad+32*linesize;
}
if (!s->mb_intra) {
if(!s->encoding){
if(HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) {
if (s->mv_dir & MV_DIR_FORWARD) {
ff_thread_await_progress(&s->last_picture_ptr->tf,
ff_MPV_lowest_referenced_row(s, 0),
0);
}
if (s->mv_dir & MV_DIR_BACKWARD) {
ff_thread_await_progress(&s->next_picture_ptr->tf,
ff_MPV_lowest_referenced_row(s, 1),
0);
}
}
op_qpix= s->me.qpel_put;
if ((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){
op_pix = s->hdsp.put_pixels_tab;
}else{
op_pix = s->hdsp.put_no_rnd_pixels_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f.data, op_pix, op_qpix);
op_pix = s->hdsp.avg_pixels_tab;
op_qpix= s->me.qpel_avg;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
ff_MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.f.data, op_pix, op_qpix);
}
}
if(s->avctx->skip_idct){
if( (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B)
||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I)
|| s->avctx->skip_idct >= AVDISCARD_ALL)
goto skip_idct;
}
if(s->encoding || !( s->msmpeg4_version || s->codec_id==AV_CODEC_ID_MPEG1VIDEO || s->codec_id==AV_CODEC_ID_MPEG2VIDEO
|| (s->codec_id==AV_CODEC_ID_MPEG4 && !s->mpeg_quant))){
add_dequant_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale);
add_dequant_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale);
add_dequant_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale);
add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
if (s->chroma_y_shift){
add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
}else{
dct_linesize >>= 1;
dct_offset >>=1;
add_dequant_dct(s, block[4], 4, dest_cb, dct_linesize, s->chroma_qscale);
add_dequant_dct(s, block[5], 5, dest_cr, dct_linesize, s->chroma_qscale);
add_dequant_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
add_dequant_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
}
}
} else if(is_mpeg12 || (s->codec_id != AV_CODEC_ID_WMV2)){
add_dct(s, block[0], 0, dest_y , dct_linesize);
add_dct(s, block[1], 1, dest_y + block_size, dct_linesize);
add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize);
add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
if(s->chroma_y_shift){
add_dct(s, block[4], 4, dest_cb, uvlinesize);
add_dct(s, block[5], 5, dest_cr, uvlinesize);
}else{
dct_linesize = uvlinesize << s->interlaced_dct;
dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize * 8;
add_dct(s, block[4], 4, dest_cb, dct_linesize);
add_dct(s, block[5], 5, dest_cr, dct_linesize);
add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
if(!s->chroma_x_shift){
add_dct(s, block[8], 8, dest_cb+8, dct_linesize);
add_dct(s, block[9], 9, dest_cr+8, dct_linesize);
add_dct(s, block[10], 10, dest_cb+8+dct_offset, dct_linesize);
add_dct(s, block[11], 11, dest_cr+8+dct_offset, dct_linesize);
}
}
}
}
else if (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) {
ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
}
} else {
if(s->encoding || !(s->codec_id==AV_CODEC_ID_MPEG1VIDEO || s->codec_id==AV_CODEC_ID_MPEG2VIDEO)){
put_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale);
put_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale);
put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale);
put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
if(s->chroma_y_shift){
put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
}else{
dct_offset >>=1;
dct_linesize >>=1;
put_dct(s, block[4], 4, dest_cb, dct_linesize, s->chroma_qscale);
put_dct(s, block[5], 5, dest_cr, dct_linesize, s->chroma_qscale);
put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
}
}
}else{
s->dsp.idct_put(dest_y , dct_linesize, block[0]);
s->dsp.idct_put(dest_y + block_size, dct_linesize, block[1]);
s->dsp.idct_put(dest_y + dct_offset , dct_linesize, block[2]);
s->dsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
if(s->chroma_y_shift){
s->dsp.idct_put(dest_cb, uvlinesize, block[4]);
s->dsp.idct_put(dest_cr, uvlinesize, block[5]);
}else{
dct_linesize = uvlinesize << s->interlaced_dct;
dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize * 8;
s->dsp.idct_put(dest_cb, dct_linesize, block[4]);
s->dsp.idct_put(dest_cr, dct_linesize, block[5]);
s->dsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
s->dsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
if(!s->chroma_x_shift){
s->dsp.idct_put(dest_cb + 8, dct_linesize, block[8]);
s->dsp.idct_put(dest_cr + 8, dct_linesize, block[9]);
s->dsp.idct_put(dest_cb + 8 + dct_offset, dct_linesize, block[10]);
s->dsp.idct_put(dest_cr + 8 + dct_offset, dct_linesize, block[11]);
}
}
}
}
}
skip_idct:
if(!readable){
s->hdsp.put_pixels_tab[0][0](s->dest[0], dest_y , linesize,16);
s->hdsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[1], dest_cb, uvlinesize,16 >> s->chroma_y_shift);
s->hdsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[2], dest_cr, uvlinesize,16 >> s->chroma_y_shift);
}
}
}
| 1threat
|
document.write('<script src="evil.js"></script>');
| 1threat
|
static void libschroedinger_decode_frame_free(void *frame)
{
schro_frame_unref(frame);
}
| 1threat
|
Django REST Framework : "This field is required." with required=False and unique_together : <p>I want to save a simple model with Django REST Framework. The only requirement is that <code>UserVote.created_by</code> is set automatically within the <code>perform_create()</code> method. This fails with this exception:</p>
<pre><code>{
"created_by": [
"This field is required."
]
}
</code></pre>
<p>I guess it is because of the unique_together index.</p>
<p>models.py:</p>
<pre><code>class UserVote(models.Model):
created_by = models.ForeignKey(User, related_name='uservotes')
rating = models.ForeignKey(Rating)
class Meta:
unique_together = ('created_by', 'rating')
</code></pre>
<p>serializers.py</p>
<pre><code>class UserVoteSerializer(serializers.ModelSerializer):
id = serializers.IntegerField(read_only=True)
created_by = UserSerializer(read_only=True)
class Meta:
model = UserVote
fields = ('id', 'rating', 'created_by')
</code></pre>
<p>views.py</p>
<pre><code>class UserVoteViewSet(viewsets.ModelViewSet):
queryset = UserVote.objects.all()
serializer_class = UserVoteSerializer
permission_classes = (IsCreatedByOrReadOnly, )
def perform_create(self, serializer):
serializer.save(created_by=self.request.user)
</code></pre>
<p>How can I save my model in DRF without having the user to supply <code>created_by</code> and instead set this field automatically in code?</p>
<p>Thanks in advance!</p>
| 0debug
|
How can I download php file with source? : <p>This is my demo url
<a href="http://www.example.com/example.php" rel="nofollow noreferrer">http://www.example.com/example.php</a></p>
<p>If we want to download example.php file with source code how can we do it?Is it possible?</p>
| 0debug
|
Python Help. Need to verify username password off csv file : Doing a python project where I have to verify my username and password from a csv file where the first two rows and columns have the username and password as 'hi'. Please help ASAP.
Current Code:
answer = input("Do you have an account?(yes or no) ")
if answer == 'yes' :
login = False
csvfile = open("Username password.csv","r")
reader = csv.reader('Username password.csv')
username = input("Player One Username: ")
password = input("Player One Password: ")
for row in reader:
if row[0]== username and row[1] == password:
login = True
else:
login = False
if login == True:
print("Incorrect. Game Over.")
exit()
else:
print("You are now logged in!")
else:
print('Only Valid Usernames can play. Game Over.')
exit()
| 0debug
|
TypeError: Object(...) is not a function reactjs : <p>I was trying to clean up this react component by extracting <code>fillCalendar()</code> from being a method of the component into it's own js file and importing it instead. Originally this.state.datesArray was set in a componentWillMount() lifecycle method. Now I'm trying to directly initialize it inside the constructor because this is what the react docs <a href="https://reactjs.org/docs/react-component.html#unsafe_componentwillmount" rel="noreferrer">recommends</a>. Doing it this way now throws a "TypeError: Object(...) is not a function" error and I don't know why. Here is what Calendar.js use to look like <a href="https://github.com/ryansaam/calendar-v3.0.0/blob/master/src/App.js" rel="noreferrer">see here</a>.</p>
<p>Calendar.js</p>
<pre><code>import React, { Component } from 'react';
import { fillCalendar } from '../calendar.tools'
class Calendar extends Component {
constructor(props) {
super(props)
this.state = {
datesArray: fillCalendar(7, 2018),
date: new Date(),
monthIsOffset: false,
monthOffset: new Date().getMonth(),
yearOffset: new Date().getFullYear()
}
}
render() {
return (
...
)
}
}
</code></pre>
<p>calendar.tools.js</p>
<pre><code>let fillCalendar = (month, year) => {
let datesArray = []
let monthStart = new Date(year,month,1).getDay()
let yearType = false;
let filledNodes = 0;
// Check for leap year
(year%4 === 0) ?
(year%100 === 0) ?
(year%400) ? yearType = true : yearType = false :
yearType = true :
yearType = false
const monthArrays = yearType ? [31,29,31,30,31,30,31,31,30,31,30,31] : [31,28,31,30,31,30,31,31,30,31,30,31]
if (month === 0) { month = 12; }
let leadDayStart = monthArrays[month-1] - monthStart + 1
// Loop out lead date numbers
for (let i = 0; i < monthStart; i++) {
datesArray.push({date: leadDayStart, type: "leadDate", id: "leadDate" + i})
leadDayStart++
filledNodes++
}
if (month === 12) { month = 0; }
// Loop out month's date numbers
for (let i = 0; i < monthArrays[month]; i++) {
datesArray.push({date: i + 1, type: "monthDate", id: "monthDate" + i})
filledNodes++
}
// fill the empty remaining cells in the calendar
let remainingNodes = 42 - filledNodes;
for (let i = 0; i < remainingNodes; i++) {
datesArray.push({date: i + 1, type: "postDate", id: "postDate" + i})
}
return datesArray
}
</code></pre>
| 0debug
|
What is the difference between annotation and decorator? : <p>I am confused when to use term annotation and when to use decorator ? </p>
<pre><code> @Component({
selector: 'tabs',
template: `
`
})
export class Tabs {
}
</code></pre>
| 0debug
|
How to ensure my CustomPaint widget painting is stored in the raster cache? : <p>I have an app that displays a black dot at the point where the user touches the screen like this:</p>
<p><a href="https://i.stack.imgur.com/YpTDS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YpTDS.png" alt="enter image description here"></a></p>
<p>The black dot can be moved by the user as he/she drags his finger on the screen.</p>
<p>The background is an expensive paint operation, so I have created two separate widgets in a stack, hoping that the background widget painting will be stored in the Flutter raster cache. But it's not stored - Flutter calls my expensive paint method every time the black dot moves.</p>
<p>What am I doing wrong?</p>
<p>Here's my code:</p>
<pre><code>import 'package:flutter/material.dart';
import 'dart:math';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
State createState() => new MyHomePageState();
}
class MyHomePageState extends State<MyHomePage> {
GlobalKey _paintKey = new GlobalKey();
Offset _offset;
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Stack(
fit: StackFit.expand,
children: <Widget>[
new CustomPaint(
painter: new ExpensivePainter(),
isComplex: true,
willChange: false,
),
new Listener(
onPointerDown: _updateOffset,
onPointerMove: _updateOffset,
child: new CustomPaint(
key: _paintKey,
painter: new MyCustomPainter(_offset),
child: new ConstrainedBox(
constraints: new BoxConstraints.expand(),
),
),
)
],
),
);
}
_updateOffset(PointerEvent event) {
RenderBox referenceBox = _paintKey.currentContext.findRenderObject();
Offset offset = referenceBox.globalToLocal(event.position);
setState(() {
_offset = offset;
});
}
}
class ExpensivePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
print("Doing expensive paint job");
Random rand = new Random(12345);
List<Color> colors = [
Colors.red,
Colors.blue,
Colors.yellow,
Colors.green,
Colors.white,
];
for (int i = 0; i < 5000; i++) {
canvas.drawCircle(
new Offset(
rand.nextDouble() * size.width, rand.nextDouble() * size.height),
10 + rand.nextDouble() * 20,
new Paint()
..color = colors[rand.nextInt(colors.length)].withOpacity(0.2));
}
}
@override
bool shouldRepaint(ExpensivePainter other) => false;
}
class MyCustomPainter extends CustomPainter {
final Offset _offset;
MyCustomPainter(this._offset);
@override
void paint(Canvas canvas, Size size) {
if (_offset == null) return;
canvas.drawCircle(_offset, 10.0, new Paint()..color = Colors.black);
}
@override
bool shouldRepaint(MyCustomPainter other) => other._offset != _offset;
}
</code></pre>
| 0debug
|
How does and&or work in print() function? : <p>Saw this while searching and I couldn't understand the logic behind. How does and & or methods work in print()?</p>
<pre class="lang-py prettyprint-override"><code>T=[int(s) for s in input().split()]
print(T and sorted(sorted(T,reverse=True),key=abs)[0] or 0)
</code></pre>
<p>I've tried simplifying it to understand how it handles different inputs.</p>
<pre class="lang-py prettyprint-override"><code>print(A and B or C)
</code></pre>
<p>Returns B when B is not 0, and returns C when B is 0 but never gets to A.</p>
| 0debug
|
Python splitting code into functions : <p>Sorry about the length of this but I figured more info is better than not enough!!</p>
<p>I'm trying to split the (working) piece of Python code into functions to make it clearer / easier to use but am coming unstuck as soon as i move stuff into functions. It's basically a password generator which tries to only output a password to the user once the password qualifies as having a character from all 4 categories in it. (Lowercase, uppercase, numbers and symbols).</p>
<hr>
<pre><code>import random
import string
lowerasciis = string.ascii_letters[0:26]
upperasciis = string.ascii_letters[26:]
numberedstrings = str(1234567809)
symbols = "!@$%^&*()[]"
password_length = int(raw_input("Please enter a password length: "))
while True:
lowerasscii_score = 0
upperascii_score = 0
numberedstring_score = 0
symbol_score = 0
password_as_list = []
while len(password_as_list) < password_length:
char = random.choice(lowerasciis+upperasciis+numberedstrings+symbols)
password_as_list.append(char)
for x in password_as_list:
if x in lowerasciis:
lowerasscii_score +=1
elif x in upperasciis:
upperascii_score +=1
elif x in numberedstrings:
numberedstring_score +=1
elif x in symbols:
symbol_score +=1
# a check for the screen. Each cycle of the loop should display a new score:
print lowerasscii_score, upperascii_score, numberedstring_score, symbol_score
if lowerasscii_score >= 1 and upperascii_score >= 1 and numberedstring_score >= 1 and symbol_score >=1:
password = "".join(password_as_list)
print password
break
</code></pre>
<p>And here is my attempt at splitting it. When i try to run the below it complains of "UnboundLocalError: local variable 'upperascii_score' referenced before assignment" in the scorepassword_as_a_list() function</p>
<pre><code>import random
import string
lowerasciis = string.ascii_letters[0:26]
upperasciis = string.ascii_letters[26:]
numberedstrings = str(1234567809)
symbols = "!@$%^&*()[]"
password_length = int(raw_input("Please enter a password length: "))
lowerasscii_score = 0
upperascii_score = 0
numberedstring_score = 0
symbol_score = 0
password_as_list = []
def genpassword_as_a_list():
while len(password_as_list) < password_length:
char = random.choice(lowerasciis+upperasciis+numberedstrings+symbols)
password_as_list.append(char)
def scorepassword_as_a_list():
for x in password_as_list:
if x in lowerasciis:
lowerasscii_score +=1
elif x in upperasciis:
upperascii_score +=1
elif x in numberedstrings:
numberedstring_score +=1
elif x in symbols:
symbol_score +=1
# give user feedback about password's score in 4 categories
print lowerasscii_score, upperascii_score, numberedstring_score, symbol_score
def checkscore():
if lowerasscii_score >= 1 and upperascii_score >= 1 and numberedstring_score >= 1 and symbol_score >=1:
return 1
else:
return 0
def join_and_printpassword():
password = "".join(password_as_list)
print password
while True:
genpassword_as_a_list()
scorepassword_as_a_list()
if checkscore() == 1:
join_and_printpassword()
break
</code></pre>
| 0debug
|
static void spitz_common_init(ram_addr_t ram_size, int vga_ram_size,
const char *kernel_filename,
const char *kernel_cmdline, const char *initrd_filename,
const char *cpu_model, enum spitz_model_e model, int arm_id)
{
struct pxa2xx_state_s *cpu;
struct scoop_info_s *scp0, *scp1 = NULL;
if (!cpu_model)
cpu_model = (model == terrier) ? "pxa270-c5" : "pxa270-c0";
if (ram_size < SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE) {
fprintf(stderr, "This platform requires %i bytes of memory\n",
SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE);
exit(1);
}
cpu = pxa270_init(spitz_binfo.ram_size, cpu_model);
sl_flash_register(cpu, (model == spitz) ? FLASH_128M : FLASH_1024M);
cpu_register_physical_memory(0, SPITZ_ROM,
qemu_ram_alloc(SPITZ_ROM) | IO_MEM_ROM);
spitz_keyboard_register(cpu);
spitz_ssp_attach(cpu);
scp0 = scoop_init(cpu, 0, 0x10800000);
if (model != akita) {
scp1 = scoop_init(cpu, 1, 0x08800040);
}
spitz_scoop_gpio_setup(cpu, scp0, scp1);
spitz_gpio_setup(cpu, (model == akita) ? 1 : 2);
spitz_i2c_setup(cpu);
if (model == akita)
spitz_akita_i2c_setup(cpu);
if (model == terrier)
spitz_microdrive_attach(cpu, 1);
else if (model != akita)
spitz_microdrive_attach(cpu, 0);
cpu->env->regs[15] = spitz_binfo.loader_start;
spitz_binfo.kernel_filename = kernel_filename;
spitz_binfo.kernel_cmdline = kernel_cmdline;
spitz_binfo.initrd_filename = initrd_filename;
spitz_binfo.board_id = arm_id;
arm_load_kernel(cpu->env, &spitz_binfo);
sl_bootparam_write(SL_PXA_PARAM_BASE);
}
| 1threat
|
Force IntersectionObserver update : <p>Is there any way to force an update/run of an <code>IntersectionObserver</code> instance? The callback will be executed by default, when the viewport has changed. But I'm looking for a way to to execute it when other events happen, like a change of elements.</p>
<p>An Example:</p>
<p>On initialization everything works as expected. But when you change the position of the <code>#red</code> element, nothing happens.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>// elements
let green = document.querySelector('#green');
let red = document.querySelector('#red');
// observer callback
let callback = entries => {
entries.forEach(entry => {
let isInside = entry.intersectionRatio >= 1 ? "fully" : "NOT";
console.log("#" + entry.target.id + " is " + isInside + " inside #container");
});
};
// start observer
let options = {root: document.querySelector('#container')};
let observer = new IntersectionObserver(callback, options);
observer.observe(green);
observer.observe(red);
// button action
document.querySelector('button').addEventListener('click', () => {
red.style.right = red.style.right == "" ? "0px" : "";
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>#container {
width: 100px;
height: 100px;
background: blue;
position: relative;
}
#green, #red {
width: 50px;
height: 50px;
background: green;
position: absolute;
}
#red {
background: red;
right: -10px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><button>move #red</button>
<br /><br />
<div id="container">
<div id="green"></div>
<div id="red"></div>
</div></code></pre>
</div>
</div>
</p>
<p>Is there any way to make this working? Only thing that would work is to <code>unobserve</code> the element and start <code>observing</code> it again. This may be work for an single element, but not if the Observer has hundreds of elements to watch.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>// elements
let green = document.querySelector('#green');
let red = document.querySelector('#red');
// observer callback
let callback = entries => {
entries.forEach(entry => {
let isInside = entry.intersectionRatio >= 1 ? "fully" : "NOT";
console.log("#" + entry.target.id + " is " + isInside + " inside #container");
});
};
// start observer
let options = {root: document.querySelector('#container')};
let observer = new IntersectionObserver(callback, options);
observer.observe(green);
observer.observe(red);
// button action
document.querySelector('button').addEventListener('click', () => {
red.style.right = red.style.right == "" ? "0px" : "";
observer.unobserve(red);
observer.observe(red);
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>#container {
width: 100px;
height: 100px;
background: blue;
position: relative;
}
#green, #red {
width: 50px;
height: 50px;
background: green;
position: absolute;
}
#red {
background: red;
right: -10px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><button>move #red</button>
<br /><br />
<div id="container">
<div id="green"></div>
<div id="red"></div>
</div></code></pre>
</div>
</div>
</p>
| 0debug
|
Use one python script to pass command line variable to another for batch processing : <p>I have a python script I did not write that accepts command line inputs via switches. I have the need to run this command a lot. Is there a way to use a second python script read a file with the variables and pass them to the first script. Once the first script completes then go to the next line in the file?</p>
| 0debug
|
Stop IEnumerable from enumerating through all elements : <p>How do I stop <code>IEnumberable</code> from enumerating through all the elements in the variable in question.
I have a function which I pass an <code>IEnumerable</code> list to, and it will always have only two elements. I however, need the function to only run for the first element, no more, no less. How do I get it to only go through the first element?</p>
<p>Note: Since there are only two elements, I've tried passing them in separately (e.g <code>double</code> <code>double</code>), but it still runs through both.</p>
| 0debug
|
GSource *aio_get_g_source(AioContext *ctx)
{
g_source_ref(&ctx->source);
return &ctx->source;
}
| 1threat
|
How To Can I Restrict The User From Entering More Than 1 Digit In Python 3 : <p>In,</p>
<pre><code>a=int(input("Enter A Integer: "))
</code></pre>
<p>How Can I Prevent The User From Entering More Than 4 Digits In This Input</p>
| 0debug
|
Circular dependencies in ES6/7 : <p>I was surprised to find that in Babel, I could have two modules <code>import</code> each other without any issues. I have found a few places that refer to this as a known and expected behaviour in Babel. I know that this is widely considered an anti-pattern by a lot of (I'm guessing most) people, but please ignore that for this question:</p>
<p>Does anyone know if this is (or will be) correct behaviour in ES6/7? </p>
<p>The closest thing I can find to an official answer (and technical explanation) is <a href="http://www.2ality.com/2014/09/es6-modules-final.html#comment-2855933496" rel="noreferrer">this comment on 2ality.com</a></p>
| 0debug
|
PHP -- using an anonymous function while concatenating : Does PHP allow an anonymous function during concatenating?
If so, what is the proper syntax?
Here's an example I can't get to work:
$final_text = $some_initial_string
. function ($array_of_strings) {
$out = '';
foreach($array_of_strings as $this_particular_string) {
$out .= $this_particular_string;
}
return $out_string;
};
| 0debug
|
Login, Register and Password reset in same page : <p>I put login, register and password reset in same page and use java script on make only one available at a time. Is it bad coding?</p>
| 0debug
|
void qemu_set_dfilter_ranges(const char *filter_spec)
{
gchar **ranges = g_strsplit(filter_spec, ",", 0);
if (ranges) {
gchar **next = ranges;
gchar *r = *next++;
debug_regions = g_array_sized_new(FALSE, FALSE,
sizeof(Range), g_strv_length(ranges));
while (r) {
char *range_op = strstr(r, "-");
char *r2 = range_op ? range_op + 1 : NULL;
if (!range_op) {
range_op = strstr(r, "+");
r2 = range_op ? range_op + 1 : NULL;
if (!range_op) {
range_op = strstr(r, "..");
r2 = range_op ? range_op + 2 : NULL;
if (range_op) {
const char *e = NULL;
uint64_t r1val, r2val;
if ((qemu_strtoull(r, &e, 0, &r1val) == 0) &&
(qemu_strtoull(r2, NULL, 0, &r2val) == 0) &&
r2val > 0) {
struct Range range;
g_assert(e == range_op);
switch (*range_op) {
case '+':
{
range.begin = r1val;
range.end = r1val + (r2val - 1);
break;
case '-':
{
range.end = r1val;
range.begin = r1val - (r2val - 1);
break;
case '.':
range.begin = r1val;
range.end = r2val;
break;
default:
g_assert_not_reached();
g_array_append_val(debug_regions, range);
} else {
g_error("Failed to parse range in: %s", r);
} else {
g_error("Bad range specifier in: %s", r);
r = *next++;
g_strfreev(ranges);
| 1threat
|
Execute a function until 5 minutes WPF : In a WPF form I'm calling doSomeFunction() method in a while loop. This will run until x = y. This is working fine.
while (x != y)
{
doSomeFunction();
}
I need to add additional function, that need to check this condition until 5 minutes only. After the 5 minutes if x != y I need to return.
How can I do this in WPF?
| 0debug
|
How to extend timeout for tests in circleci? : <p>Im running some tests in circleci and some of the tests are taking longer then 10 min cause its ui tests that run on a headless browser that Im installing in my circle.yml</p>
<p>How can I extend the time of the timeout?</p>
<p>thanks</p>
| 0debug
|
intrinsicContentSize() - Method does not override any method from its superclass : <p>I updated to Xcode 8 beta 5, and now get the following error on a class that inherits from UIView:</p>
<pre><code>Method does not override any method from its superclass
override public func intrinsicContentSize() -> CGSize
{
...
}
</code></pre>
<p>Is there a workaround?</p>
| 0debug
|
Disable pipeline for every commit in Gitlab and only run it on open merge request : <p>The CI pipeline runs on every commit in my Gitlab repository at work. Is there way to disable that and only run the CI pipeline on an open merge request to the master branch?</p>
<p>Any help is appreciated. Thanks.</p>
| 0debug
|
Can I give a class name as an XML element? : <p>I'm looking to use XML to fill in some definitions of objects. I really want the file to be able to give a class name in a property itself:</p>
<pre class="lang-xml prettyprint-override"><code><Object>
<Name>Something</Name>
<ObjClass>SomeClass</ObjClass>
</Object>
</code></pre>
<p>where <code>SomeClass</code> is the name of a class defined in code somewhere else that gets instantiated when the file is deserialized (or the class is static, I haven't decided). Is that possible?</p>
| 0debug
|
Swift MKMapView Drop a Pin Annotation to Current Location : <p>I am looking to be able to ask the app user for his/her current location and a pin to be automatically dropped on that location. Here is my code for grabbing the current location, but I am having trouble understanding how I can drop a pin for the current location. </p>
<pre><code>import UIKit
import MapKit
import CoreLocation
class MapVC: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
@IBOutlet weak var map: MKMapView!
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
// User's location
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
if #available(iOS 8.0, *) {
locationManager.requestAlwaysAuthorization()
} else {
// Fallback on earlier versions
}
locationManager.startUpdatingLocation()
// add gesture recognizer
let longPress = UILongPressGestureRecognizer(target: self, action: #selector(MapVC.mapLongPress(_:))) // colon needs to pass through info
longPress.minimumPressDuration = 1.5 // in seconds
//add gesture recognition
map.addGestureRecognizer(longPress)
}
// func called when gesture recognizer detects a long press
func mapLongPress(_ recognizer: UIGestureRecognizer) {
print("A long press has been detected.")
let touchedAt = recognizer.location(in: self.map) // adds the location on the view it was pressed
let touchedAtCoordinate : CLLocationCoordinate2D = map.convert(touchedAt, toCoordinateFrom: self.map) // will get coordinates
let newPin = MKPointAnnotation()
newPin.coordinate = touchedAtCoordinate
map.addAnnotation(newPin)
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations.last! as CLLocation
let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))
//set region on the map
self.map.setRegion(region, animated: true)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
</code></pre>
| 0debug
|
muti output regression in xgboost : <p>Is it possible to train a model in Xgboost that have multiple continuous outputs (multi regression)?
What would be the objective to train such a model?</p>
<p>Thanks in advance for any suggestions</p>
| 0debug
|
int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
uint8_t *buf, int buf_size)
{
int size, i;
uint8_t *ppcm[4] = { 0 };
if (buf_size < DV_PROFILE_BYTES ||
!(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||
buf_size < c->sys->frame_size) {
return -1;
}
size = dv_extract_audio_info(c, buf);
for (i = 0; i < c->ach; i++) {
c->audio_pkt[i].size = size;
c->audio_pkt[i].pts = c->abytes * 30000 * 8 /
c->ast[i]->codec->bit_rate;
ppcm[i] = c->audio_buf[i];
}
if (c->ach)
dv_extract_audio(buf, ppcm, c->sys);
if (c->sys->height == 720) {
if (buf[1] & 0x0C) {
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
} else {
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
c->abytes += size;
}
} else {
c->abytes += size;
}
size = dv_extract_video_info(c, buf);
av_init_packet(pkt);
pkt->data = buf;
pkt->size = size;
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->stream_index = c->vst->index;
pkt->pts = c->frames;
c->frames++;
return size;
}
| 1threat
|
Returning pointer to array doesn't give expected output in c : <pre><code>#include <stdio.h>
int* createReverseArray(int *array, int size)
{
int i;
int newArray[size];
for(i=size-1; i>=0; i--)
{
newArray[i] = array[size-i-1];
}
return newArray;
}
int main(void) {
int myArray[] = {1,2,3,5,1};
int myArray2[] = {1,2,3,4,2,1};
int i;
int size = sizeof(myArray)/sizeof(int);
printf("Size: %d\n", size);
int* newArray = createReverseArray(myArray, size);
for(i=0; i<size; i++)
{
printf("%d, ", newArray[i]);
}
return 0;
}
</code></pre>
<p>I printed the array within the createReverseArray function and got the correct output, but when I return the pointer to the array and then try to print the results, I think it's printing pointers to each array spot? I'm not quite sure.</p>
<p>This returns:</p>
<p>Size: 5</p>
<p>12341002, 1, -10772231820, -1077231812, 1074400845,</p>
| 0debug
|
static void max_x86_cpu_initfn(Object *obj)
{
X86CPU *cpu = X86_CPU(obj);
CPUX86State *env = &cpu->env;
KVMState *s = kvm_state;
cpu->max_features = true;
if (kvm_enabled()) {
X86CPUDefinition host_cpudef = { };
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
host_vendor_fms(host_cpudef.vendor, &host_cpudef.family,
&host_cpudef.model, &host_cpudef.stepping);
cpu_x86_fill_model_id(host_cpudef.model_id);
x86_cpu_load_def(cpu, &host_cpudef, &error_abort);
env->cpuid_min_level =
kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);
env->cpuid_min_xlevel =
kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);
env->cpuid_min_xlevel2 =
kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
if (lmce_supported()) {
object_property_set_bool(OBJECT(cpu), true, "lmce", &error_abort);
}
} else {
object_property_set_str(OBJECT(cpu), CPUID_VENDOR_AMD,
"vendor", &error_abort);
object_property_set_int(OBJECT(cpu), 6, "family", &error_abort);
object_property_set_int(OBJECT(cpu), 6, "model", &error_abort);
object_property_set_int(OBJECT(cpu), 3, "stepping", &error_abort);
object_property_set_str(OBJECT(cpu),
"QEMU TCG CPU version " QEMU_HW_VERSION,
"model-id", &error_abort);
}
object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort);
}
| 1threat
|
how to union two tables with group values : **How to union two tables with group values**
-----------------------------------------
My Query:
SELECT
table1.holder,table1.bene_type,table1.bene_stype,employee.employee_name,
count(employee.employee_name) as count,sum(table1.position)
as totalshares FROM erom_kmch.table1 LEFT OUTER JOIN erom.employee ON
employee.bene_type_table1=table1.bene_type
AND employee.bene_stype_table1=table1.bene_stype WHERE table1.date =
'2016-04-15' group by employee.employee_name UNION
SELECT
table2.cust_name, table2.type,table2.bo_substat,employee.employee_name,
count(employee.employee_name) as count,sum(table2.shares) as totalshares
FROM erom_kmch.table2 LEFT OUTER JOIN erom.employee
ON employee.type_table2=table2.type
AND employee.bo_substat_table2=table2.bo_substat WHERE table2.date =
'2016-04-15' group by employee.employee_name
----------------------------------------------------------
I am joining and union two tables and i need to group the values of two tables ,i am getting two output i need the sum and count of two tables as one output
| 0debug
|
Java 9 - Can I add the MainClass attribute to module-info.class in the archive? : <p>In Java 9, you can create a JAR file with</p>
<pre><code>jar --create --file=mlib/com.greetings.jar --main-class=com.greetings.Main -C mods/com.greetings .
</code></pre>
<p>Which has the side effect of adding the MainClass attribute to the module-info.class file in the .jar file.</p>
<p>Do any of the plugins support this yet, or do I need to invoke the Java 9 'jar' command directly?</p>
<p>Is this the right forum to be asking these questions, or is there a better place?</p>
<p>Cheers, Eric</p>
| 0debug
|
how to query in SQL with those multi condition? : ### table data(part)
```
| user_id | count | create_time |
| ------- | ----- | ----------- |
| 10 | 20 | 2018-08-08 |
| 10 | 19 | 2018-08-09 |
| 2 | 15 | 2018-08-04 |
| 5 | 30 | 2018-08-10 |
```
### query conditions
**condition 1**: query result must order_by `count` desc
**condition 2**: `user_id` maybe repeat(for example: user_id=10)
**condition 3**: Each `user_id` has only one piece of data after the query
**condition 4**: the only one data from "condition 3" should be the one which `create_time` is most recent. In example, when `user_id=10`, the data's `create_time` should be "2018-08-09". (*this condition is optional*)
**condition 5**: limit 100
| 0debug
|
static void test_validate_fail_union_flat_no_discrim(TestInputVisitorData *data,
const void *unused)
{
UserDefFlatUnion2 *tmp = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(data, "{ 'integer': 42, 'string': 'c', 'string1': 'd', 'string2': 'e' }");
visit_type_UserDefFlatUnion2(v, &tmp, NULL, &err);
g_assert(err);
error_free(err);
qapi_free_UserDefFlatUnion2(tmp);
}
| 1threat
|
av_cold void ff_dsputil_init_alpha(DSPContext *c, AVCodecContext *avctx)
{
const int high_bit_depth = avctx->bits_per_raw_sample > 8;
if (amask(AMASK_MVI) == 0) {
c->put_pixels_clamped = put_pixels_clamped_mvi_asm;
c->add_pixels_clamped = add_pixels_clamped_mvi_asm;
if (!high_bit_depth)
c->get_pixels = get_pixels_mvi;
c->diff_pixels = diff_pixels_mvi;
c->sad[0] = pix_abs16x16_mvi_asm;
c->sad[1] = pix_abs8x8_mvi;
c->pix_abs[0][0] = pix_abs16x16_mvi_asm;
c->pix_abs[1][0] = pix_abs8x8_mvi;
c->pix_abs[0][1] = pix_abs16x16_x2_mvi;
c->pix_abs[0][2] = pix_abs16x16_y2_mvi;
c->pix_abs[0][3] = pix_abs16x16_xy2_mvi;
}
put_pixels_clamped_axp_p = c->put_pixels_clamped;
add_pixels_clamped_axp_p = c->add_pixels_clamped;
if (!avctx->lowres && avctx->bits_per_raw_sample <= 8 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEALPHA)) {
c->idct_put = ff_simple_idct_put_axp;
c->idct_add = ff_simple_idct_add_axp;
c->idct = ff_simple_idct_axp;
}
}
| 1threat
|
Nginx + PHP-FPM 7.1 - 504 Gateway Time-out : <p>I'm running a nginx 1.12 and a php-fpm 7.1 as seperate docker containers on a synology nas and i get a 504 Gateway error if the php-script runs longer than 60s. I've tried already several nginx configuration parameters but the error still exists. </p>
<p>Here is my actual nginx config: </p>
<pre><code>#user www-data;
#group http
worker_processes 1;
error_log /opt/data/logs/nginx_error.log notice;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#keepalive_timeout 30s;
sendfile on;
#tcp_nopush off;
tcp_nodelay on;
#gzip off;
send_timeout 300
server {
listen 80;
server_name "";
root /opt/php;
index index.php;
location /data/ {
sendfile on;
root /opt;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
# Mitigate https://httpoxy.org/ vulnerabilities
fastcgi_param HTTP_PROXY "";
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 300;
#fastcgi_buffering off;
#fastcgi_keep_conn on;
#fastcgi_intercept_errors on;
#fastcgi_cache off;
#fastcgi_ignore_client_abort on;
}
location ~ ^/(status|ping)$ {
access_log off;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php:9000;
}
}
}
</code></pre>
<p>The php-testscript:</p>
<pre><code><?php
sleep(65);
echo "done!";
file_put_contents("/opt/data/timetest.txt", "\nEnd", FILE_APPEND);
</code></pre>
<p>After 60s the browser shows up the 504 Gateway Time-out. The php-script is still running and is also writing the text to the file.</p>
<p>Nginx errorlog: </p>
<pre><code>2017/07/22 08:16:32 [error] 8#8: *10 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 172.17.0.1, server: , request: "GET /timetest.php HTTP/1.1", upstream: "fastcgi://172.17.0.3:9000", host: "192.168.0.100:8081"
</code></pre>
<p>Has anyone an idea?</p>
| 0debug
|
static void skip_input(DBEContext *s, int nb_words)
{
s->input += nb_words * s->word_bytes;
s->input_size -= nb_words;
}
| 1threat
|
Why is Python's modulus operation broken? : I'm getting the wrong answer for this:
long(math.factorial(100)) % long(math.pow(12, 48))
The answer should be 0, but Python gives:
3533293188234793495632656292699172292923858530336768L
- Why does this happen?
- How do I calculate that correctly?
| 0debug
|
Prevent pushing to master on GitHub? : <p>GitHub allows you to configure your repository so that <a href="https://github.com/blog/2051-protected-branches-and-required-status-checks" rel="noreferrer">users can't force push to master</a>, but is there a way to prevent pushing to master entirely? I'm hoping to make it so that the only way of adding to commits to master is through the GitHub pull request UI.</p>
| 0debug
|
Iterating through an array of arrays in java : <p>I am simply trying to iterate through every variable in an array of arrays:</p>
<p>Here's the working code:</p>
<pre><code> int[][] mArray;
mArray = new int[2][2];
mArray[0][0] = 1;
mArray[0][1] = 2;
mArray[1][0] = 3;
mArray[1][1] = 4;
for (int i = 0; i < mArray.length; i++)
{
for (int x = 0; x < mArray[i].length; x++)
{
System.out.println(mArray[i][x]);
}
}
</code></pre>
<p>This prints out:</p>
<p>1
2
3
4</p>
<p>So Everything's fine.</p>
<p>However if I replace</p>
<p>"for (int x = 0; x < <strong>mArray[i].length</strong>; x++)"</p>
<p>with</p>
<p>"for (int x = 0; x < <strong>mArray[x].length</strong>; x++)"</p>
<p>It get the following error: "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2".</p>
<p>Can anyone explain why this error happens to occur? Both mArray[i].length and mArray[x].length result in a value of "2", so why does the second option not work?</p>
<p>Thanks in advance :)</p>
| 0debug
|
Returning 3 greatest value using While loop : <p>How can i return the 3 greatest values using while loop based on the list of data given below:</p>
<pre><code>list_of_numbers = [
['A',12.0],
['B',52.0],
['C',5.5],
['D',77.0],
['E',55.0],
['F',3.7,]
]
</code></pre>
<p>desired output:</p>
<pre><code>[
['D',77.0],
['E',55.0],
['B',52.0]
]
</code></pre>
| 0debug
|
Difference between spring JSP MVC and Thymeleaf MVC : <p>What is the difference between spring JSP MVC and Thymeleaf MVC? Which one is best way for spring web design ?</p>
| 0debug
|
static int g723_1_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
G723_1_Context *p = avctx->priv_data;
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int dec_mode = buf[0] & 3;
PPFParam ppf[SUBFRAMES];
int16_t cur_lsp[LPC_ORDER];
int16_t lpc[SUBFRAMES * LPC_ORDER];
int16_t acb_vector[SUBFRAME_LEN];
int16_t *out;
int bad_frame = 0, i, j, ret;
int16_t *audio = p->audio;
if (buf_size < frame_size[dec_mode]) {
if (buf_size)
av_log(avctx, AV_LOG_WARNING,
"Expected %d bytes, got %d - skipping packet\n",
frame_size[dec_mode], buf_size);
*got_frame_ptr = 0;
return buf_size;
}
if (unpack_bitstream(p, buf, buf_size) < 0) {
bad_frame = 1;
if (p->past_frame_type == ACTIVE_FRAME)
p->cur_frame_type = ACTIVE_FRAME;
else
p->cur_frame_type = UNTRANSMITTED_FRAME;
}
frame->nb_samples = FRAME_LEN;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
out = (int16_t *)frame->data[0];
if (p->cur_frame_type == ACTIVE_FRAME) {
if (!bad_frame)
p->erased_frames = 0;
else if (p->erased_frames != 3)
p->erased_frames++;
ff_g723_1_inverse_quant(cur_lsp, p->prev_lsp, p->lsp_index, bad_frame);
ff_g723_1_lsp_interpolate(lpc, cur_lsp, p->prev_lsp);
memcpy(p->prev_lsp, cur_lsp, LPC_ORDER * sizeof(*p->prev_lsp));
memcpy(p->excitation, p->prev_excitation,
PITCH_MAX * sizeof(*p->excitation));
if (!p->erased_frames) {
int16_t *vector_ptr = p->excitation + PITCH_MAX;
p->interp_gain = fixed_cb_gain[(p->subframe[2].amp_index +
p->subframe[3].amp_index) >> 1];
for (i = 0; i < SUBFRAMES; i++) {
gen_fcb_excitation(vector_ptr, &p->subframe[i], p->cur_rate,
p->pitch_lag[i >> 1], i);
ff_g723_1_gen_acb_excitation(acb_vector,
&p->excitation[SUBFRAME_LEN * i],
p->pitch_lag[i >> 1],
&p->subframe[i], p->cur_rate);
for (j = 0; j < SUBFRAME_LEN; j++) {
int v = av_clip_int16(vector_ptr[j] << 1);
vector_ptr[j] = av_clip_int16(v + acb_vector[j]);
}
vector_ptr += SUBFRAME_LEN;
}
vector_ptr = p->excitation + PITCH_MAX;
p->interp_index = comp_interp_index(p, p->pitch_lag[1],
&p->sid_gain, &p->cur_gain);
if (p->postfilter) {
i = PITCH_MAX;
for (j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++)
comp_ppf_coeff(p, i, p->pitch_lag[j >> 1],
ppf + j, p->cur_rate);
for (i = 0, j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++)
ff_acelp_weighted_vector_sum(p->audio + LPC_ORDER + i,
vector_ptr + i,
vector_ptr + i + ppf[j].index,
ppf[j].sc_gain,
ppf[j].opt_gain,
1 << 14, 15, SUBFRAME_LEN);
} else {
audio = vector_ptr - LPC_ORDER;
}
memcpy(p->prev_excitation, p->excitation + FRAME_LEN,
PITCH_MAX * sizeof(*p->excitation));
} else {
p->interp_gain = (p->interp_gain * 3 + 2) >> 2;
if (p->erased_frames == 3) {
memset(p->excitation, 0,
(FRAME_LEN + PITCH_MAX) * sizeof(*p->excitation));
memset(p->prev_excitation, 0,
PITCH_MAX * sizeof(*p->excitation));
memset(frame->data[0], 0,
(FRAME_LEN + LPC_ORDER) * sizeof(int16_t));
} else {
int16_t *buf = p->audio + LPC_ORDER;
residual_interp(p->excitation, buf, p->interp_index,
p->interp_gain, &p->random_seed);
memcpy(p->prev_excitation, buf + (FRAME_LEN - PITCH_MAX),
PITCH_MAX * sizeof(*p->excitation));
}
}
p->cng_random_seed = CNG_RANDOM_SEED;
} else {
if (p->cur_frame_type == SID_FRAME) {
p->sid_gain = sid_gain_to_lsp_index(p->subframe[0].amp_index);
ff_g723_1_inverse_quant(p->sid_lsp, p->prev_lsp, p->lsp_index, 0);
} else if (p->past_frame_type == ACTIVE_FRAME) {
p->sid_gain = estimate_sid_gain(p);
}
if (p->past_frame_type == ACTIVE_FRAME)
p->cur_gain = p->sid_gain;
else
p->cur_gain = (p->cur_gain * 7 + p->sid_gain) >> 3;
generate_noise(p);
ff_g723_1_lsp_interpolate(lpc, p->sid_lsp, p->prev_lsp);
memcpy(p->prev_lsp, p->sid_lsp, LPC_ORDER * sizeof(*p->prev_lsp));
}
p->past_frame_type = p->cur_frame_type;
memcpy(p->audio, p->synth_mem, LPC_ORDER * sizeof(*p->audio));
for (i = LPC_ORDER, j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++)
ff_celp_lp_synthesis_filter(p->audio + i, &lpc[j * LPC_ORDER],
audio + i, SUBFRAME_LEN, LPC_ORDER,
0, 1, 1 << 12);
memcpy(p->synth_mem, p->audio + FRAME_LEN, LPC_ORDER * sizeof(*p->audio));
if (p->postfilter) {
formant_postfilter(p, lpc, p->audio, out);
} else {
for (i = 0; i < FRAME_LEN; i++)
out[i] = av_clip_int16(p->audio[LPC_ORDER + i] << 1);
}
*got_frame_ptr = 1;
return frame_size[dec_mode];
}
| 1threat
|
cpu_mips_check_sign_extensions (CPUMIPSState *env, FILE *f,
fprintf_function cpu_fprintf,
int flags)
{
int i;
if (!SIGN_EXT_P(env->active_tc.PC))
cpu_fprintf(f, "BROKEN: pc=0x" TARGET_FMT_lx "\n", env->active_tc.PC);
if (!SIGN_EXT_P(env->active_tc.HI[0]))
cpu_fprintf(f, "BROKEN: HI=0x" TARGET_FMT_lx "\n", env->active_tc.HI[0]);
if (!SIGN_EXT_P(env->active_tc.LO[0]))
cpu_fprintf(f, "BROKEN: LO=0x" TARGET_FMT_lx "\n", env->active_tc.LO[0]);
if (!SIGN_EXT_P(env->btarget))
cpu_fprintf(f, "BROKEN: btarget=0x" TARGET_FMT_lx "\n", env->btarget);
for (i = 0; i < 32; i++) {
if (!SIGN_EXT_P(env->active_tc.gpr[i]))
cpu_fprintf(f, "BROKEN: %s=0x" TARGET_FMT_lx "\n", regnames[i], env->active_tc.gpr[i]);
}
if (!SIGN_EXT_P(env->CP0_EPC))
cpu_fprintf(f, "BROKEN: EPC=0x" TARGET_FMT_lx "\n", env->CP0_EPC);
if (!SIGN_EXT_P(env->lladdr))
cpu_fprintf(f, "BROKEN: LLAddr=0x" TARGET_FMT_lx "\n", env->lladdr);
}
| 1threat
|
what is x-Application-Context header? : <p>What is this response header (x-Application-Context) stands for? is it specific to Spring framework?</p>
<p>what does the below header means?</p>
<pre><code>X-Application-Context airtel-project-service:aws:27094
</code></pre>
<p>does it reveals any senstive information like hostname or port number?</p>
| 0debug
|
Express Repeating jquery codes into looping : <p>Recently i was working with the UX of forms someting like login and registration form for just inspiration.I just coded in a row format without applying any logic to shorten it.</p>
<h2>Below is how i coded :</h2>
<pre><code>$('.form-content.minimized a').click(function(event) {
event.preventDefault();
$('.form-content.minimized').addClass('first_step',
setTimeout(function(){
$('.form-content.minimized').addClass('second_step',
setTimeout(function(){
$('.form-content.minimized').addClass('third_step',
setTimeout(function(){
$('.form-content.minimized').addClass('fourth_step',
setTimeout(function(){
$('.form-content.minimized').addClass('fifth_step ' + fifth_step ,
setTimeout(function(){
$('.form-content.minimized').addClass('opened');
}, 100)
)
}, 600)
);
}, 400)
);
}, 200)
);
}, 200)
);
});
</code></pre>
<p>Here we can see there is happening something with stepping like staircase. <code>first_step</code> , <code>second_step</code> .....
And also a time interval is happening between every steps.</p>
<p>What about if we do something like <code>i=0</code> , <code>i++</code>, <code>i<= something</code> in a loop.Then i think it would be more readable and maintainable. </p>
| 0debug
|
Why is my while loop triggering all the time no matter what I input? : <p>I'm a beginner and I'm trying to do an assignment using a while loop in order to count how many tickets come through a gate and how log what color ticket it is. I thought I coded it correctly but then I got runtime errors and tried to single each mistake out and then 1 by 1 get it to work but I can't even get my while loop to not just trigger on anything the user puts in. Any help would be appreciated, I'm totally lost and I'm aware that this is very beginner. </p>
<pre><code> #include <iostream>
using namespace std;
int main()
{
char answer;
cout << "start counting tickets? (y/n)" << endl;
cin >> answer;
while (answer = 'y')
{
cout << "ok" << endl;
cin >> answer;
}
return 0;
}
</code></pre>
| 0debug
|
No templates Visual Studio 2017 RC on win 7 : I installed VS2017 RC on windows 7 64bits, all components
[there's no templates][1]
[1]: https://i.stack.imgur.com/cAWMY.png
but there's no templates to start a proyect even if i search in new Main Page and explore
what could be?
| 0debug
|
Docker - Ubuntu - bash: ping: command not found : <p>I've got a Docker container running Ubuntu which I did as follows:</p>
<pre><code>docker run -it ubuntu /bin/bash
</code></pre>
<p>however it doesn't seem to have <code>ping</code>. E.g.</p>
<pre><code>bash: ping: command not found
</code></pre>
<p>Do I need to install that?</p>
<p>Seems a pretty basic command to be missing. I tried <code>whereis ping</code> which doesn't report anything.</p>
| 0debug
|
static av_always_inline void dnxhd_decode_dct_block(const DNXHDContext *ctx,
RowContext *row,
int n,
int index_bits,
int level_bias,
int level_shift)
{
int i, j, index1, index2, len, flags;
int level, component, sign;
const int *scale;
const uint8_t *weight_matrix;
const uint8_t *ac_level = ctx->cid_table->ac_level;
const uint8_t *ac_flags = ctx->cid_table->ac_flags;
int16_t *block = row->blocks[n];
const int eob_index = ctx->cid_table->eob_index;
OPEN_READER(bs, &row->gb);
ctx->bdsp.clear_block(block);
if (!ctx->is_444) {
if (n & 2) {
component = 1 + (n & 1);
scale = row->chroma_scale;
weight_matrix = ctx->cid_table->chroma_weight;
} else {
component = 0;
scale = row->luma_scale;
weight_matrix = ctx->cid_table->luma_weight;
}
} else {
component = (n >> 1) % 3;
if (component) {
scale = row->chroma_scale;
weight_matrix = ctx->cid_table->chroma_weight;
} else {
scale = row->luma_scale;
weight_matrix = ctx->cid_table->luma_weight;
}
}
UPDATE_CACHE(bs, &row->gb);
GET_VLC(len, bs, &row->gb, ctx->dc_vlc.table, DNXHD_DC_VLC_BITS, 1);
if (len) {
level = GET_CACHE(bs, &row->gb);
LAST_SKIP_BITS(bs, &row->gb, len);
sign = ~level >> 31;
level = (NEG_USR32(sign ^ level, len) ^ sign) - sign;
row->last_dc[component] += level;
}
block[0] = row->last_dc[component];
i = 0;
UPDATE_CACHE(bs, &row->gb);
GET_VLC(index1, bs, &row->gb, ctx->ac_vlc.table,
DNXHD_VLC_BITS, 2);
while (index1 != eob_index) {
level = ac_level[index1];
flags = ac_flags[index1];
sign = SHOW_SBITS(bs, &row->gb, 1);
SKIP_BITS(bs, &row->gb, 1);
if (flags & 1) {
level += SHOW_UBITS(bs, &row->gb, index_bits) << 7;
SKIP_BITS(bs, &row->gb, index_bits);
}
if (flags & 2) {
UPDATE_CACHE(bs, &row->gb);
GET_VLC(index2, bs, &row->gb, ctx->run_vlc.table,
DNXHD_VLC_BITS, 2);
i += ctx->cid_table->run[index2];
}
if (++i > 63) {
av_log(ctx->avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", n, i);
break;
}
j = ctx->scantable.permutated[i];
level *= scale[i];
if (level_bias < 32 || weight_matrix[i] != level_bias)
level += level_bias;
level >>= level_shift;
block[j] = (level ^ sign) - sign;
UPDATE_CACHE(bs, &row->gb);
GET_VLC(index1, bs, &row->gb, ctx->ac_vlc.table,
DNXHD_VLC_BITS, 2);
}
CLOSE_READER(bs, &row->gb);
}
| 1threat
|
What is faster to find in jQuery - ID's that start with X or a class? : <p>If you have html and throughout you have span elements like this:</p>
<pre><code><span id="element-1" class="elements"></span>
<span id="element-2" class="elements"></span>
<span id="element-3" class="elements"></span>
</code></pre>
<p>What is faster to find them:</p>
<pre><code>$('.elements')
</code></pre>
<p>or</p>
<pre><code>$('[id^="element-"]')
</code></pre>
| 0debug
|
dplyr: access current group variable : <p>After using data.table for quite some time I now thought it's time to try dplyr. It's fun, but I wasn't able to figure out how to access
- the current grouping variable
- returning multiple values per group</p>
<p>The following example shows is working fine with data.table. How would you write this with dplyr</p>
<pre><code>foo <- matrix(c(1, 2, 3, 4), ncol = 2)
dt <- data.table(a = c(1, 1, 2), b = c(4, 5, 6))
# data.table (expected)
dt[, .(c = foo[, a]), by = a]
a c
1: 1 1
2: 1 2
3: 2 3
4: 2 4
# dplyr (?)
dt %>%
group_by(a) %>%
summarize(c = foo[a])
</code></pre>
| 0debug
|
passing variables to map function : I'm trying to send a few longitude and latitude variables to a function that will then generate a google map.
Starting with a datatable that retrieves various information stored in a database, I'm using data-attributes to store the lng and lat for each record. When a record is selected, a modal opens and the map is displayed.
I was able to get the map to display with default lng and lat points. But now I need to create a new map every time a record is selected.
Starting with the onclick event that triggers the modal to open (shortened as much as possible):
$('#example1').on('click', 'tr > td > a.actionMatch', function(e)
{
e.preventDefault();
var actimpbill = $(this).attr('data-actimpbill'); // random record info
var actramplat = $(this).attr('data-actramplat'); // first lat
var actramplng = $(this).attr('data-actramplng'); // first lng
var actdellat = $(this).attr('data-actdellat'); // second lat
var actdellng = $(this).attr('data-actdellng'); // second lng
// my map was opening in a grey box. this next piece of code fixed that
$("#actionMatchbackModal").on("shown.bs.modal", function () {
google.maps.event.trigger(map, "resize");
});
initMap(actramplat, actramplng, actdellat, actdellng); // my attempt to call a function and the variables to it
$('#actionMatchbackModal').modal('show'); // show the modal
});
Here is the function that sets the map. This is located outside of the initial onclick event that opens the modal (I'm not sure if that's a problem). This is where I'm trying to pass the variables that I created inside the onclick event:
function initMap(dellat, dellng, reclat, reclng)
{
// map options
var options = {
zoom: 8,
center: {dellat, dellng}
}
// new map
var map = new google.maps.Map(document.getElementById('map'), options);
// add marker
var marker = new google.maps.Marker({
position:{reclat, reclng},
map: map
});
}
I am probably butchering the function call. The function once housed the default lat and lng numbers and I was able to properly generate a map.
Please help me fix this error, and thank you in advance.
| 0debug
|
solve this error why i am getting this in python gui : I had created simple calculator in page gui then i copy that code and run it in python 3.6.3 but it give me this error
import sys
try:
from Tkinter import *
except ImportError:
from tkinter import *
try:
import ttk
py3 = False
except ImportError:
import tkinter.ttk as ttk
py3 = True
import _support
def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root
root = Tk()
top = Simple_Calculator (root)
_support.init(root, top)
root.mainloop()
w = None
def create_Simple_Calculator(root, *args, **kwargs):
'''Starting point when module is imported by another program.'''
global w, w_win, rt
rt = root
w = Toplevel (root)
top = Simple_Calculator (w)
_support.init(w, top, *args, **kwargs)
return (w, top)
def destroy_Simple_Calculator():
global w
w.destroy()
w = None
class Simple_Calculator:
def __init__(self, top=None):
'''This class configures and populates the toplevel window.
top is the toplevel containing window.'''
_bgcolor = '#d9d9d9' # X11 color: 'gray85'
_fgcolor = '#000000' # X11 color: 'black'
_compcolor = '#d9d9d9' # X11 color: 'gray85'
_ana1color = '#d9d9d9' # X11 color: 'gray85'
_ana2color = '#d9d9d9' # X11 color: 'gray85'
top.geometry("346x238+495+156")
top.title("Simple Calculator")
top.configure(background="#d9d9d9")
self.but40 = Button(top)
self.but40.place(relx=0.14, rely=0.38, height=24, width=67)
self.but40.configure(activebackground="#d9d9d9")
self.but40.configure(activeforeground="#000000")
self.but40.configure(background="#7d83d8")
self.but40.configure(disabledforeground="#a3a3a3")
self.but40.configure(foreground="#000000")
self.but40.configure(highlightbackground="#d9d9d9")
self.but40.configure(highlightcolor="black")
self.but40.configure(pady="0")
self.but40.configure(text='''Add''')
self.but40.configure(width=67)
self.but41 = Button(top)
self.but41.place(relx=0.38, rely=0.38, height=24, width=67)
self.but41.configure(activebackground="#d9d9d9")
self.but41.configure(activeforeground="#000000")
self.but41.configure(background="#7d83d8")
self.but41.configure(disabledforeground="#a3a3a3")
self.but41.configure(foreground="#000000")
self.but41.configure(highlightbackground="#d9d9d9")
self.but41.configure(highlightcolor="black")
self.but41.configure(pady="0")
self.but41.configure(text='''Sub''')
self.but42 = Button(top)
self.but42.place(relx=0.14, rely=0.55, height=24, width=67)
self.but42.configure(activebackground="#d9d9d9")
self.but42.configure(activeforeground="#000000")
self.but42.configure(background="#7d83d8")
self.but42.configure(disabledforeground="#a3a3a3")
self.but42.configure(foreground="#000000")
self.but42.configure(highlightbackground="#d9d9d9")
self.but42.configure(highlightcolor="black")
self.but42.configure(pady="0")
self.but42.configure(text='''Multiply''')
self.but43 = Button(top)
self.but43.place(relx=0.38, rely=0.55, height=24, width=67)
self.but43.configure(activebackground="#d9d9d9")
self.but43.configure(activeforeground="#000000")
self.but43.configure(background="#7d83d8")
self.but43.configure(disabledforeground="#a3a3a3")
self.but43.configure(foreground="#000000")
self.but43.configure(highlightbackground="#d9d9d9")
self.but43.configure(highlightcolor="black")
self.but43.configure(pady="0")
self.but43.configure(text='''Divide''')
self.but43.configure(width=67)
self.Button2 = Button(top)
self.Button2.place(relx=0.72, rely=0.71, height=24, width=49)
self.Button2.configure(activebackground="#d9d9d9")
self.Button2.configure(activeforeground="#000000")
self.Button2.configure(background="#9a63d8")
self.Button2.configure(disabledforeground="#a3a3a3")
self.Button2.configure(foreground="#000000")
self.Button2.configure(highlightbackground="#d9d9d9")
self.Button2.configure(highlightcolor="black")
self.Button2.configure(pady="0")
self.Button2.configure(text='''Display''')
self.Entry1 = Entry(top)
self.Entry1.place(relx=0.12, rely=0.13,height=30, relwidth=0.47)
self.Entry1.configure(background="#a6c1ff")
self.Entry1.configure(disabledforeground="#a3a3a3")
self.Entry1.configure(font="TkFixedFont")
self.Entry1.configure(foreground="#000000")
self.Entry1.configure(insertbackground="black")
self.Entry1.configure(width=164)
if __name__ == '__main__':
vp_start_gui()
Traceback (most recent call last):
File "C:/Users/Zeeshan Khalid/AppData/Local/Programs/Python/Python36-32/tkinter initial chec.py", line 22, in <module>
import _support
ModuleNotFoundError: No module named '_support'
| 0debug
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
void monitor_flush(Monitor *mon)
{
int i;
if (term_outbuf_index > 0) {
for (i = 0; i < MAX_MON; i++)
if (monitor_hd[i] && monitor_hd[i]->focus == 0)
qemu_chr_write(monitor_hd[i], term_outbuf, term_outbuf_index);
term_outbuf_index = 0;
}
}
| 1threat
|
react-navigation - navigating from child component : <p>I have a leaderboard which calls a component and passes it data to it like so:</p>
<pre><code> _renderItem =({item}) => (
<childComponent
key={item._id}
id={item._id}
name={item.name}
/>
);
</code></pre>
<p>And inside the childComponent I try do this:</p>
<pre><code> <TouchableOpacity onPress={() => this.props.navigation.navigate("Profile", { id: this.props.id})} >
<View>
<Right>
{arrowIcon}
</Right>
</View>
</TouchableOpacity>
</code></pre>
<p>Where I am hoping that it will then go to the profile page and grab the correct data based on the id passed to it. The issue is that when I click the arrow to go to the profile page I get the error <strong>Cannot read property 'navigate of undefined</strong>. I have put both the leaderboard and childComponent in my HomeDrawerrRoutes.js and MainStackRouter.js. Any help would be great, thanks.</p>
| 0debug
|
static av_always_inline int check_block(SnowContext *s, int mb_x, int mb_y, int p[3], int intra, const uint8_t *obmc_edged, int *best_rd){
const int b_stride= s->b_width << s->block_max_depth;
BlockNode *block= &s->block[mb_x + mb_y * b_stride];
BlockNode backup= *block;
int rd, index, value;
assert(mb_x>=0 && mb_y>=0);
assert(mb_x<b_stride);
if(intra){
block->color[0] = p[0];
block->color[1] = p[1];
block->color[2] = p[2];
block->type |= BLOCK_INTRA;
}else{
index= (p[0] + 31*p[1]) & (ME_CACHE_SIZE-1);
value= s->me_cache_generation + (p[0]>>10) + (p[1]<<6) + (block->ref<<12);
if(s->me_cache[index] == value)
return 0;
s->me_cache[index]= value;
block->mx= p[0];
block->my= p[1];
block->type &= ~BLOCK_INTRA;
}
rd= get_block_rd(s, mb_x, mb_y, 0, obmc_edged);
if(rd < *best_rd){
*best_rd= rd;
return 1;
}else{
*block= backup;
return 0;
}
}
| 1threat
|
Is there a way to make a console application run using only a single file in .NET Core? : <p>In .NET framework, you can make a single <code>.EXE</code> file that will run from the command line without having any extra config files (and if using ILMerge, you can put all <code>.DLL</code> references into the 1 <code>.EXE</code> assembly).</p>
<p>I am taking a stab at using .NET Core to accomplish the same thing, but so far without success. Even the simplest <code>Hello World</code> application with no dependencies requires there to be a file named <code><MyApp>.runtimeconfig.json</code> in order to run using <code>dotnet.exe</code>.</p>
<pre><code>dotnet F:\temp\MyApp.dll
</code></pre>
<p>The contents of the <code><MyApp>.runtimeconfig.json</code> are as follows:</p>
<pre><code>{
"runtimeOptions": {
"framework": {
"name": "Microsoft.NETCore.App",
"version": "1.1.1"
}
}
}
</code></pre>
<p>Without this config file in the same folder as the <code>.DLL</code>, I get the following error:</p>
<pre><code>A fatal error was encountered. The library 'hostpolicy.dll' required to
execute the application was not found in 'F:\temp'.
</code></pre>
<p>My question is: Is there some way to change the application so it doesn't <em>require</em> this config file to be present, so that the defaults of this information are compiled within the <code>.DLL</code> but can be overridden by adding the config file?</p>
<blockquote>
<p>NOTE: I also want to ensure it "just works" regardless of the platform it is installed on it provided the platform has the right version of .NET Core.</p>
</blockquote>
<h1>Background</h1>
<p>I am trying to get a smooth user experience for running some utilities that are useful sometimes, but are rarely ever needed. Since it <a href="https://stackoverflow.com/questions/44830430/is-it-possible-to-make-the-same-dll-into-both-a-console-application-and-a-nuget">doesn't appear to be possible to use the same <code>.DLL</code> that is referenced from a client application</a> as a console application, the next best thing would be to have a <em>single file</em> that could be downloaded and run without any dependencies.</p>
<p>For example, in Java you can simply download a <code>.jar</code> file on any supported platform and run:</p>
<pre><code>java <package>.jar <namespace>.SomeClass [args]
</code></pre>
<p>and it will "just work" without any extra files. How can I get a similar user experience using .NET Core?</p>
<p>In a nutshell, I want to try to avoid the extra step of "unzip to a directory first"...</p>
| 0debug
|
Why is code 1 not producing 10 rows of circles on my browser? But the code(1) is producing the output : The code 1 is working and giving 10 lines of circles of radius 10.
The code 2 is not working as expected, it just gives a single line of circles of radius 10.
I think the logic is correct but still there is something i am most probably missing when it comes to paper js documentation. Please help me out. This is bugging me. *No pun intended :p*
[1]: https://i.stack.imgur.com/inVh9.png
| 0debug
|
bool aio_dispatch(AioContext *ctx)
{
bool progress;
progress = aio_bh_poll(ctx);
progress |= aio_dispatch_handlers(ctx, INVALID_HANDLE_VALUE);
progress |= timerlistgroup_run_timers(&ctx->tlg);
return progress;
}
| 1threat
|
static void monitor_protocol_emitter(Monitor *mon, QObject *data,
QError *err)
{
QDict *qmp;
trace_monitor_protocol_emitter(mon);
if (!err) {
qmp = qdict_new();
if (data) {
qobject_incref(data);
qdict_put_obj(qmp, "return", data);
} else {
qdict_put(qmp, "return", qdict_new());
}
} else {
qmp = build_qmp_error_dict(err);
}
if (mon->mc->id) {
qdict_put_obj(qmp, "id", mon->mc->id);
mon->mc->id = NULL;
}
monitor_json_emitter(mon, QOBJECT(qmp));
QDECREF(qmp);
}
| 1threat
|
import collections
def freq_count(list1):
freq_count= collections.Counter(list1)
return freq_count
| 0debug
|
store jason values in javascript var : i have this code for my geolocation and i am trying to get the address values and store them in to javascript var
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.watchPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
var lat = position.coords.latitude;
var lag = position.coords.longitude;
$("#latit").val(lat);
$("#lang").val(lag);
var settings = {
"async": true,
"crossDomain": true,
"url": "https://us1.locationiq.com/v1/reverse.php?key=//////////&lat="+lat+"&lon="+lag+"&format=json",
"method": "POST"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
}
and this is the result i get from the json response in my console:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
{place_id: "192741603", licence: "https://locationiq.com/attribution", osm_type: "way", osm_id: "548559489", lat: "32.2814427", …}
address:
city: "קדימה - צורן"
country: "ישראל"
country_code: "il"
postcode: "NO"
state: "מחוז המרכז"
suburb: "שיכון יציב"
__proto__: Object
boundingbox: (4) ["32.2808557", "32.2814427", "34.9092769", "34.9114099"]
display_name: "שיכון יציב, קדימה - צורן, מחוז המרכז, NO, ישראל"
lat: "32.2814427"
licence: "https://locationiq.com/attribution"
lon: "34.9094007"
osm_id: "548559489"
osm_type: "way"
place_id: "192741603"
__proto__: Object
<!-- end snippet -->
how can i get values from the address and store them in javascript var?
| 0debug
|
int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
{
CPUState *cpu = ENV_GET_CPU(env);
TaskState *ts = cpu->opaque;
struct emulated_sigtable *k;
struct sigqueue *q, **pq;
abi_ulong handler;
int queue;
trace_user_queue_signal(env, sig);
k = &ts->sigtab[sig - 1];
queue = gdb_queuesig ();
handler = sigact_table[sig - 1]._sa_handler;
if (ts->sigsegv_blocked && sig == TARGET_SIGSEGV) {
handler = TARGET_SIG_DFL;
}
if (!queue && handler == TARGET_SIG_DFL) {
if (sig == TARGET_SIGTSTP || sig == TARGET_SIGTTIN || sig == TARGET_SIGTTOU) {
kill(getpid(),SIGSTOP);
return 0;
} else
if (sig != TARGET_SIGCHLD &&
sig != TARGET_SIGURG &&
sig != TARGET_SIGWINCH &&
sig != TARGET_SIGCONT) {
force_sig(sig);
} else {
return 0;
}
} else if (!queue && handler == TARGET_SIG_IGN) {
return 0;
} else if (!queue && handler == TARGET_SIG_ERR) {
force_sig(sig);
} else {
pq = &k->first;
if (sig < TARGET_SIGRTMIN) {
if (!k->pending)
q = &k->info;
else
return 0;
} else {
if (!k->pending) {
q = &k->info;
} else {
q = alloc_sigqueue(env);
if (!q)
return -EAGAIN;
while (*pq != NULL)
pq = &(*pq)->next;
}
}
*pq = q;
q->info = *info;
q->next = NULL;
k->pending = 1;
ts->signal_pending = 1;
return 1;
}
}
| 1threat
|
React-Native Packager Failure: Duplicate module name : <p>This happened seemingly randomly during development. When trying to run <code>npm start</code> or <code>react-native run-ios</code>, I get the following error:</p>
<pre><code>Failed to build DependencyGraph: @providesModule naming collision:
Duplicate module name: react-native-vector-icons
Paths: /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json collides with /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/Libraries/Animated/release/package.json
This error is caused by a @providesModule declaration with the same name accross two different files.
Error: @providesModule naming collision:
Duplicate module name: react-native-vector-icons
Paths: /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json collides with /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/Libraries/Animated/release/package.json
This error is caused by a @providesModule declaration with the same name accross two different files.
at HasteMap._updateHasteMap (/Users/chandlervdw/Repos/Relay/mobile/node_modules/node-haste/lib/DependencyGraph/HasteMap.js:162:15)
at /Users/chandlervdw/Repos/Relay/mobile/node_modules/node-haste/lib/DependencyGraph/HasteMap.js:140:25
</code></pre>
<p>Strangely, <code>/Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json</code> actually does list <code>react-native-vector-icons</code> as the name for the module???</p>
<p>If I delete that file, the error no longer happens but the packager gets stuck at 93% and complains about a completely irrelevent library not being found.</p>
<p>I blew away my repo and even reinstalled everything, including <code>npm</code>, <code>rnpm</code>, and even upgrading <code>node</code>. I'm running the same versions of everything as my teammates, who are able to run the packager without issues.</p>
| 0debug
|
static int config_input(AVFilterLink *link)
{
AVFilterContext *ctx = link->dst;
CropContext *s = ctx->priv;
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(link->format);
int ret;
const char *expr;
double res;
s->var_values[VAR_E] = M_E;
s->var_values[VAR_PHI] = M_PHI;
s->var_values[VAR_PI] = M_PI;
s->var_values[VAR_IN_W] = s->var_values[VAR_IW] = ctx->inputs[0]->w;
s->var_values[VAR_IN_H] = s->var_values[VAR_IH] = ctx->inputs[0]->h;
s->var_values[VAR_X] = NAN;
s->var_values[VAR_Y] = NAN;
s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = NAN;
s->var_values[VAR_OUT_H] = s->var_values[VAR_OH] = NAN;
s->var_values[VAR_N] = 0;
s->var_values[VAR_T] = NAN;
av_image_fill_max_pixsteps(s->max_step, NULL, pix_desc);
s->hsub = pix_desc->log2_chroma_w;
s->vsub = pix_desc->log2_chroma_h;
if ((ret = av_expr_parse_and_eval(&res, (expr = s->ow_expr),
var_names, s->var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto fail_expr;
s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = res;
if ((ret = av_expr_parse_and_eval(&res, (expr = s->oh_expr),
var_names, s->var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto fail_expr;
s->var_values[VAR_OUT_H] = s->var_values[VAR_OH] = res;
if ((ret = av_expr_parse_and_eval(&res, (expr = s->ow_expr),
var_names, s->var_values,
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
goto fail_expr;
s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = res;
if (normalize_double(&s->w, s->var_values[VAR_OUT_W]) < 0 ||
normalize_double(&s->h, s->var_values[VAR_OUT_H]) < 0) {
av_log(ctx, AV_LOG_ERROR,
"Too big value or invalid expression for out_w/ow or out_h/oh. "
"Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
s->ow_expr, s->oh_expr);
return AVERROR(EINVAL);
}
s->w &= ~((1 << s->hsub) - 1);
s->h &= ~((1 << s->vsub) - 1);
if ((ret = av_expr_parse(&s->x_pexpr, s->x_expr, var_names,
NULL, NULL, NULL, NULL, 0, ctx)) < 0 ||
(ret = av_expr_parse(&s->y_pexpr, s->y_expr, var_names,
NULL, NULL, NULL, NULL, 0, ctx)) < 0)
return AVERROR(EINVAL);
av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d -> w:%d h:%d\n",
link->w, link->h, s->w, s->h);
if (s->w <= 0 || s->h <= 0 ||
s->w > link->w || s->h > link->h) {
av_log(ctx, AV_LOG_ERROR,
"Invalid too big or non positive size for width '%d' or height '%d'\n",
s->w, s->h);
return AVERROR(EINVAL);
}
s->x = (link->w - s->w) / 2;
s->y = (link->h - s->h) / 2;
s->x &= ~((1 << s->hsub) - 1);
s->y &= ~((1 << s->vsub) - 1);
return 0;
fail_expr:
av_log(NULL, AV_LOG_ERROR, "Error when evaluating the expression '%s'\n", expr);
return ret;
}
| 1threat
|
C# how to prevent doublication while adding record using oledb : private void button1_Click(object sender, EventArgs e)
{
{
System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\H3.mdb";
con.Open();
String DDate = DDD.Text.ToString();
String my_querry = "INSERT INTO DailyReport(DDate)VALUES('" + DDate + "')";
OleDbCommand cmd = new OleDbCommand(my_querry, con);
cmd.ExecuteNonQuery();
MessageBox.Show("Data saved successfuly...!");
if(count>0)
con.Close();
| 0debug
|
static av_cold int v410_decode_init(AVCodecContext *avctx)
{
avctx->pix_fmt = PIX_FMT_YUV444P10;
avctx->bits_per_raw_sample = 10;
if (avctx->width & 1) {
av_log(avctx, AV_LOG_ERROR, "v410 requires width to be even.\n");
return AVERROR_INVALIDDATA;
}
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame) {
av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
return AVERROR(ENOMEM);
}
return 0;
}
| 1threat
|
So I have this question in my algo class. Any help will be appreciated. The question is as follows. : Whenever you compare 3 no. it end up in 6 results and similarly 4 no it goes for 24 no. making permutation of no. of inputs.
The task is to compare n no. of sequence showing their comparison which leads to the
particular sequence
For example your input is a,b,c
If a<b
If b<c
Abc
Else
If a<c
Acb
Else a>c
cab
Else b>c
Cba
Else
If a<c
Bac
Else
Bca
Else
Cba
The task is to print all the comparisons which took place to lead that sequence for n no.s and
confirm that there is no duplication.
| 0debug
|
Is there a way to create a box plot for attributes in a data frame using the plot() command in R? : I am trying to create a box plot for 2 binary (yes/no) attributes from a large data frame in R using the `plot()` command and wondering if this is possible?
(I am specifically trying to use the `plot()` command but if this is not possible I am interested in hearing alternatives.)
| 0debug
|
Improve PySpark DataFrame.show output to fit Jupyter notebook : <p>Using PySpark in a Jupyter notebook, the output of Spark's <code>DataFrame.show</code> is low-tech compared to how Pandas DataFrames are displayed. I thought "Well, it does the job", until I got this:</p>
<p><a href="https://i.stack.imgur.com/1k6OP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1k6OP.png" alt="enter image description here"></a></p>
<p>The output is not adjusted to the width of the notebook, so that the lines wrap in an ugly way. Is there a way to customize this? Even better, is there a way to get output Pandas-style (without converting to <code>pandas.DataFrame</code> obviously)?</p>
| 0debug
|
How to Remove special characters at the end and at the begging of the string : <p>I have a string:</p>
<pre><code>String str = " line0\n" +
"line1\n" +
"line2 line0\n" +
"line3\n" +
"line4 \n"
</code></pre>
<p>How can I get the following script:</p>
<pre><code>String formatedStr = "line0\n" +
"line1\n" +
"line2 line0\n" +
"line3\n" +
"line4"
</code></pre>
| 0debug
|
document.write('<script src="evil.js"></script>');
| 1threat
|
AutoIT Counting Words In Text Selection : I have written a function in AutoIT to count the number of words, characters with and without spaces, lines, and estimated speaking time (assuming a speaking speed of two words per second) in a segment of text selected by the user. This selected text is highlighted in blue.
It works just great 90% of the time. However, if the starting position for the selection is 0 in the input string (at the upper left-hand corner of the top of the file), the function returns 0 for the number of characters, 0 for the number of words, 0 for everything, even when the main function that calculates the number of words in the file from start to finish works perfectly. I cannot figure out why. Here is the code:
$input_str = GUICtrlRead($Textbox)
$selpos = _GUICtrlEdit_GetSel($Textbox)
MsgBox($MB_OK, $selpos[0], $selpos[1])
$selstring = StringMid($input_str, $selpos[0], ($selpos[1]-$selpos[0]))
$WordArray = StringRegExp($selstring, "[\s\.:;,]*([a-zA-Z0-9-_]+)[\s\.:;,]*", 3)
$SingleQuotes = StringRegExp($selstring, "'", 3)
$Result = ""
$Seconds = (UBound($WordArray) - UBound($SingleQuotes)) / 2
If $Seconds >= 3600 Then
If $Seconds / 3600 >= 2 Then
$Result = $Result & Int($Seconds/3600) & " hours "
Else
$Result = $Result & Int($Seconds/3600) & " hour "
EndIf
EndIf
If Mod($Seconds, 3600) >= 60 Then
If $Seconds / 60 >= 2 Then
$Result = $Result & Int(Mod($Seconds, 3600) / 60) & " minutes "
Else
$Result = $Result & Int(Mod($Seconds, 3600) / 60) & " minute "
EndIf
EndIf
If Mod($Seconds, 60) > 0 Then
If Mod($Seconds, 60) >= 2 Then
$Result = $Result & Int(Mod($Seconds, 60)) & " seconds "
Else
$Result = $Result & Int(Mod($Seconds, 60)) & " second "
EndIf
EndIf
MsgBox($MB_OK, "Selection Properties", "Number of characters (with spaces): " & StringLen($selstring) & @CRLF & "Number of Characters (without spaces): " & StringLen(StringStripWS($selstring, 8)) & @CRLF & "Number of words: " & (UBound($WordArray) - UBound($SingleQuotes)) & @CRLF & "Number of lines: " & _GUICtrlEdit_GetLineCount($selstring) & @CRLF & "Estimated speaking time: " & $Result)
Any assistance anyone can provide me would be greatly appreciated.
| 0debug
|
Change column names of data.frame based on column number and text : <p>In the data.frame <code>run</code></p>
<pre><code>run <- data.frame(1:4,2:5,3:6)
X1.4 X2.5 X3.6
1 1 2 3
2 2 3 4
3 3 4 5
4 4 5 6
</code></pre>
<p>I want to change the column names to</p>
<pre><code>> colnames(run) <- c("runner1", "runner2", "runner3")
</code></pre>
<p>Is there a way to do this in R code (imagine I have hundreds of columns) by combining a similar text <code>runner</code> with a serial number <code>1, 2, 3...</code></p>
<p>I started with
<code>c(rbind(rep(c("runner"), each=3), c(1:3)))</code> which does not work and is probably way too complicated.</p>
<p>I suppose there is a easy solution?</p>
| 0debug
|
Getting today date in this formart Sat Aug 22 2016 00:00:00 GMT+0400 : How can i get today date in this format
`Sat Aug 22 2016 00:00:00 GMT+0400`
| 0debug
|
SearchView hint not showing : <p>I'm trying to display hint text in a search view in my Main Activity. The onqueryTextSubmit launches another activity called SearchResultsActivity which will display the results of the query. My problem is that I cannot display the hint text. My searchable.xml code</p>
<pre><code><searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/search_hint"
android:label="@string/app_name"
/>
</code></pre>
<p>and the manifest code
</p>
<pre><code><application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.SEARCH"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data
android:name="android.app.default_searchable1"
android:value=".SearchResultsActivity"
android:resource="@xml/searchable"/>
</activity>
<activity android:name=".SearchResultsActivity">
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable">
</meta-data>
</activity>
</application>
</manifest>
</code></pre>
<p>and finaly my onQueryTextSubmit code</p>
<pre><code>@Override
public boolean onQueryTextSubmit(String query)
{
Anniversaries tempResults;
tempResults = mainAnniversariesManager.searchManager.searchAnniversaries(query);
if (tempResults.entries.size() == 0)
{
snackbar = Snackbar.make(findViewById(R.id.coordinator), getString(R.string.no_results_found) + query, Snackbar.LENGTH_INDEFINITE);
snackbar.show();
return true;
} else
{
snackbar = null;
if (!searchView.isIconified())
{
searchView.setIconified(true);
}
menuItem.collapseActionView();
Intent intent=new Intent(getApplicationContext(),SearchResultsActivity.class);
Bundle args=new Bundle();
args.putSerializable("serialized_Anniversaries",tempResults);
intent.putExtra("args",args);
startActivity(intent);
return false;
}
}
</code></pre>
<p>Thanks in advance</p>
| 0debug
|
How can design like this in html css : [Click on this to show demo image what I actually want][1]
[1]: https://i.stack.imgur.com/A1eUh.png
I want 3 section one cover half part of the screen to show image slider and in half part, there is two section right now that part I'm done but now I want to add half part of the screen on top but it does not show image slider section, please help me.
right now my code:
<head runat="server">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body {
font-family: Arial;
color: white;
}
.split {
height: 100%;
width: 50%;
position: fixed;
z-index: 1;
top: 0;
overflow-x: hidden;
padding-top: 20px;
}
.left {
left: 0;
background-color: #ff6a00;
}
.right {
right: 0;
background-color: #ffd800;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.centered img {
width: 150px;
border-radius: 50%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="split left">
<div class="centered">
<h2>Blood Donor</h2>
<p><a href="../BloodDonor/Registration/Registration.aspx">Go To Registration</a></p>
</div>
</div>
<div class="split right">
<div class="centered">
<h2>Blood Seeker</h2>
<p><a href="../BloodSeeker/Registration/Registration.aspx">Go To Registration</a></p>
</div>
</div>
</form>
</body>
please help me,
Thank You for your time.
| 0debug
|
static int cris_mmu_segmented_addr(int seg, uint32_t rw_mm_cfg)
{
return (1 << seg) & rw_mm_cfg;
}
| 1threat
|
Swift find all occurrences of a substring : <p>I have an extension here of the String class in Swift that returns the index of the first letter of a given substring.</p>
<p>Can anybody please help me make it so it will return an array of all occurrences instead of just the first one?</p>
<p>Thank you. </p>
<pre><code>extension String {
func indexOf(string : String) -> Int {
var index = -1
if let range = self.range(of : string) {
if !range.isEmpty {
index = distance(from : self.startIndex, to : range.lowerBound)
}
}
return index
}
}
</code></pre>
<p>For example instead of a return value of <code>50</code> I would like something like <code>[50, 74, 91, 103]</code></p>
| 0debug
|
Cannot uninstall Microsoft SQL server 2008 R2 : When I'm trying to uninstall Microsoft SQL server 2008 R2, the window with "Please wait while SQL Server 2008 R2 Setup processes the current operation" pops up and stays forever.
I've found solutions to this problem but it was when someone was trying to install server, but not uninstall.
Have anyone faced the similar problem and managed to fix it?
Thank you.
| 0debug
|
int ff_h263_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s = avctx->priv_data;
int ret;
AVFrame *pict = data;
s->flags= avctx->flags;
s->flags2= avctx->flags2;
if (buf_size == 0) {
if (s->low_delay==0 && s->next_picture_ptr) {
if ((ret = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0)
return ret;
s->next_picture_ptr= NULL;
*got_frame = 1;
}
return 0;
}
if(s->flags&CODEC_FLAG_TRUNCATED){
int next;
if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4){
next= ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size);
}else if(CONFIG_H263_DECODER && s->codec_id==AV_CODEC_ID_H263){
next= ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
}else if(CONFIG_H263P_DECODER && s->codec_id==AV_CODEC_ID_H263P){
next= ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
}else{
av_log(s->avctx, AV_LOG_ERROR, "this codec does not support truncated bitstreams\n");
return AVERROR(EINVAL);
}
if( ff_combine_frame(&s->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 )
return buf_size;
}
retry:
if(s->divx_packed && s->bitstream_buffer_size){
int i;
for(i=0; i<buf_size-3; i++){
if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1){
if(buf[i+3]==0xB0){
av_log(s->avctx, AV_LOG_WARNING, "Discarding excessive bitstream in packed xvid\n");
s->bitstream_buffer_size=0;
}
break;
}
}
}
if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){
init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8);
}else
init_get_bits(&s->gb, buf, buf_size*8);
s->bitstream_buffer_size=0;
if (!s->context_initialized) {
if ((ret = ff_MPV_common_init(s)) < 0)
return ret;
}
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
int i= ff_find_unused_picture(s, 0);
if (i < 0)
return i;
s->current_picture_ptr= &s->picture[i];
}
if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5) {
ret= ff_wmv2_decode_picture_header(s);
} else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) {
ret = ff_msmpeg4_decode_picture_header(s);
} else if (CONFIG_MPEG4_DECODER && s->h263_pred) {
if(s->avctx->extradata_size && s->picture_number==0){
GetBitContext gb;
init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
ret = ff_mpeg4_decode_picture_header(s, &gb);
}
ret = ff_mpeg4_decode_picture_header(s, &s->gb);
} else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
ret = ff_intel_h263_decode_picture_header(s);
} else if (CONFIG_FLV_DECODER && s->h263_flv) {
ret = ff_flv_decode_picture_header(s);
} else {
ret = ff_h263_decode_picture_header(s);
}
if (ret < 0 || ret==FRAME_SKIPPED) {
if ( s->width != avctx->coded_width
|| s->height != avctx->coded_height) {
av_log(s->avctx, AV_LOG_WARNING, "Reverting picture dimensions change due to header decoding failure\n");
s->width = avctx->coded_width;
s->height= avctx->coded_height;
}
}
if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_size);
if (ret < 0){
av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
return ret;
}
avctx->has_b_frames= !s->low_delay;
if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
if(s->stream_codec_tag == AV_RL32("XVID") ||
s->codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVIX") ||
s->codec_tag == AV_RL32("RMP4") || s->codec_tag == AV_RL32("ZMP4") ||
s->codec_tag == AV_RL32("SIPP")
)
s->xvid_build= 0;
#if 0
if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==1
&& s->padding_bug_score > 0 && s->low_delay)
s->xvid_build= 0;
#endif
}
if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==0)
s->divx_version= 400;
}
if(s->xvid_build>=0 && s->divx_version>=0){
s->divx_version=
s->divx_build= -1;
}
if(s->workaround_bugs&FF_BUG_AUTODETECT){
if(s->codec_tag == AV_RL32("XVIX"))
s->workaround_bugs|= FF_BUG_XVID_ILACE;
if(s->codec_tag == AV_RL32("UMP4")){
s->workaround_bugs|= FF_BUG_UMP4;
}
if(s->divx_version>=500 && s->divx_build<1814){
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
}
if(s->divx_version>502 && s->divx_build<1814){
s->workaround_bugs|= FF_BUG_QPEL_CHROMA2;
}
if(s->xvid_build<=3U)
s->padding_bug_score= 256*256*256*64;
if(s->xvid_build<=1U)
s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
if(s->xvid_build<=12U)
s->workaround_bugs|= FF_BUG_EDGE;
if(s->xvid_build<=32U)
s->workaround_bugs|= FF_BUG_DC_CLIP;
#define SET_QPEL_FUNC(postfix1, postfix2) \
s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\
s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\
s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2;
if(s->lavc_build<4653U)
s->workaround_bugs|= FF_BUG_STD_QPEL;
if(s->lavc_build<4655U)
s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
if(s->lavc_build<4670U){
s->workaround_bugs|= FF_BUG_EDGE;
}
if(s->lavc_build<=4712U)
s->workaround_bugs|= FF_BUG_DC_CLIP;
if(s->divx_version>=0)
s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
if(s->divx_version==501 && s->divx_build==20020416)
s->padding_bug_score= 256*256*256*64;
if(s->divx_version<500U){
s->workaround_bugs|= FF_BUG_EDGE;
}
if(s->divx_version>=0)
s->workaround_bugs|= FF_BUG_HPEL_CHROMA;
#if 0
if(s->divx_version==500)
s->padding_bug_score= 256*256*256*64;
if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==-1
&& s->codec_id==AV_CODEC_ID_MPEG4 && s->vo_type==0)
s->workaround_bugs|= FF_BUG_NO_PADDING;
if(s->lavc_build<4609U)
s->workaround_bugs|= FF_BUG_NO_PADDING;
#endif
}
if(s->workaround_bugs& FF_BUG_STD_QPEL){
SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c)
}
if(avctx->debug & FF_DEBUG_BUGS)
av_log(s->avctx, AV_LOG_DEBUG, "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
s->workaround_bugs, s->lavc_build, s->xvid_build, s->divx_version, s->divx_build,
s->divx_packed ? "p" : "");
#if HAVE_MMX
if (s->codec_id == AV_CODEC_ID_MPEG4 && s->xvid_build>=0 && avctx->idct_algo == FF_IDCT_AUTO && (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
avctx->idct_algo= FF_IDCT_XVIDMMX;
ff_dct_common_init(s);
goto retry;
}
#endif
if (s->width != avctx->coded_width ||
s->height != avctx->coded_height ||
s->context_reinit) {
s->context_reinit = 0;
avcodec_set_dimensions(avctx, s->width, s->height);
if ((ret = ff_MPV_common_frame_size_change(s)))
return ret;
}
if((s->codec_id==AV_CODEC_ID_H263 || s->codec_id==AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_H263I))
s->gob_index = ff_h263_get_gob_height(s);
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if (s->last_picture_ptr == NULL &&
(s->pict_type == AV_PICTURE_TYPE_B || s->droppable))
return get_consumed_bytes(s, buf_size);
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B)
|| (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I)
|| avctx->skip_frame >= AVDISCARD_ALL)
return get_consumed_bytes(s, buf_size);
if(s->next_p_frame_damaged){
if(s->pict_type==AV_PICTURE_TYPE_B)
return get_consumed_bytes(s, buf_size);
else
s->next_p_frame_damaged=0;
}
if((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){
s->me.qpel_put= s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
}else{
s->me.qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
}
if ((ret = ff_MPV_frame_start(s, avctx)) < 0)
return ret;
if (!s->divx_packed && !avctx->hwaccel)
ff_thread_finish_setup(avctx);
if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) {
ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);
goto frame_end;
}
if (avctx->hwaccel) {
if ((ret = avctx->hwaccel->start_frame(avctx, s->gb.buffer, s->gb.buffer_end - s->gb.buffer)) < 0)
return ret;
}
ff_mpeg_er_frame_start(s);
if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5){
ret = ff_wmv2_decode_secondary_picture_header(s);
if(ret<0) return ret;
if(ret==1) goto frame_end;
}
s->mb_x=0;
s->mb_y=0;
ret = decode_slice(s);
while(s->mb_y<s->mb_height){
if(s->msmpeg4_version){
if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_left(&s->gb)<0)
break;
}else{
int prev_x=s->mb_x, prev_y=s->mb_y;
if(ff_h263_resync(s)<0)
break;
if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x)
s->er.error_occurred = 1;
}
if(s->msmpeg4_version<4 && s->h263_pred)
ff_mpeg4_clean_buffers(s);
if (decode_slice(s) < 0) ret = AVERROR_INVALIDDATA;
}
if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I)
if(!CONFIG_MSMPEG4_DECODER || ff_msmpeg4_decode_ext_header(s, buf_size) < 0){
s->er.error_status_table[s->mb_num - 1] = ER_MB_ERROR;
}
av_assert1(s->bitstream_buffer_size==0);
frame_end:
ff_er_frame_end(&s->er);
if (avctx->hwaccel) {
if ((ret = avctx->hwaccel->end_frame(avctx)) < 0)
return ret;
}
ff_MPV_frame_end(s);
if(s->codec_id==AV_CODEC_ID_MPEG4 && s->divx_packed){
int current_pos= s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb)>>3);
int startcode_found=0;
if(buf_size - current_pos > 7){
int i;
for(i=current_pos; i<buf_size-4; i++){
if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){
startcode_found=!(buf[i+4]&0x40);
break;
}
}
}
if(startcode_found){
av_fast_malloc(
&s->bitstream_buffer,
&s->allocated_bitstream_buffer_size,
buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE);
if (!s->bitstream_buffer)
return AVERROR(ENOMEM);
memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos);
s->bitstream_buffer_size= buf_size - current_pos;
}
}
if (!s->divx_packed && avctx->hwaccel)
ff_thread_finish_setup(avctx);
av_assert1(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
av_assert1(s->current_picture.f.pict_type == s->pict_type);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);
} else if (s->last_picture_ptr != NULL) {
if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->last_picture_ptr, pict);
ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1);
}
if(s->last_picture_ptr || s->low_delay){
if ( pict->format == AV_PIX_FMT_YUV420P
&& (s->codec_tag == AV_RL32("GEOV") || s->codec_tag == AV_RL32("GEOX"))) {
int x, y, p;
av_frame_make_writable(pict);
for (p=0; p<3; p++) {
int w = FF_CEIL_RSHIFT(pict-> width, !!p);
int h = FF_CEIL_RSHIFT(pict->height, !!p);
int linesize = pict->linesize[p];
for (y=0; y<(h>>1); y++)
for (x=0; x<w; x++)
FFSWAP(int,
pict->data[p][x + y*linesize],
pict->data[p][x + (h-1-y)*linesize]);
}
}
*got_frame = 1;
}
return (ret && (avctx->err_recognition & AV_EF_EXPLODE))?ret:get_consumed_bytes(s, buf_size);
}
| 1threat
|
changing background with CSS : I really need your help please guys. I am a completely beginner on this field, and I am stuck with my school project which has to be done in a few days. I've coded a page which has a white background taking the full width of the screen, what I want, is to have the left side and the right side of my page with a grey background, with the background of my content remaining white and pushed a little bit to the centre. Also, the bottom and the top has to remain the same, and as I said, I only need the right and left side to be changed.
To be more specific, the sides with grey background needs to be something like 95pixels width (which is about 2-3 centimetres). So how do I do that with CSS? [these are my html][2][this is the end of my html although I couldn't screenshot the closing divs][3].
Many thanks in advance
[1]: https://i.stack.imgur.com/mHYq0.png
[2]: https://i.stack.imgur.com/jLP1V.png
[3]: https://i.stack.imgur.com/dCKM4.png
| 0debug
|
how to set a value with span tag capyabara : Does anyone know how to set a value to span tag?
I tried using element.set or element.send_keys, they only selected the targeted element without modifing the previous value
<div data-offset-key="bbpvo-0-0" class="_1mf _1mj"><span data-offset-key="bbpvo-0-0"><span data-text="true">aa</span></span></div>
html snippet as above, I want to set aa to bb. can anyone help me out? thanks
| 0debug
|
How to get the claims from a JWT in my Flutter Application : <p>I am writing a Flutter/Dart application and am getting a JWT back from an auth server that has some claims I need to use. I have looked at various (4 so far) Dart JWT libraries -- but all are either too old and no longer work with Dart 2, etc. or they need the secret to decode the JWT which makes no sense and isn't correct (or possible since I have no access ).</p>
<p>So -- how can one get a JWT and get the claims from it within a "modern" Dart/Flutter application? </p>
| 0debug
|
static void pcie_pci_bridge_reset(DeviceState *qdev)
{
PCIDevice *d = PCI_DEVICE(qdev);
pci_bridge_reset(qdev);
msi_reset(d);
shpc_reset(d);
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.