problem
stringlengths
26
131k
labels
class label
2 classes
update nested dictionary from another nested dictionary based on mapping provided in dictionary : I need to write down a method to transform existing nested dictionary values from another nested dictionary , and mapping in between these two dictionary is in another third dictionary. source = { "s0" : { "s1_f1":"s1_v1", "s1_f2" : "s1_v2" }, { "s2_f1":"s2_v1", "s2_f2" : "s2_v2", "s2_f3" : { "s3_f1":"s3_v1" } } } destinatin = { "d0" : { "d1_f1":"d1_v1", "d3_f1" :"d3_v1" } } mapping = { "s1_f1":"d1_f1", "s3_f1" : "d3_f1" } result = { "d0" : { "d1_f1":"s1_v1", "d3_f1" :"s3_v1" } } I already checked couple of libraries for transformation but i want to write down the custom code for this.
0debug
static int tight_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) { int max_rows; if (vs->clientds.pf.bytes_per_pixel == 4 && vs->clientds.pf.rmax == 0xFF && vs->clientds.pf.bmax == 0xFF && vs->clientds.pf.gmax == 0xFF) { vs->tight.pixel24 = true; } else { vs->tight.pixel24 = false; } if (vs->tight.quality != -1) { double freq = vnc_update_freq(vs, x, y, w, h); if (freq > tight_jpeg_conf[vs->tight.quality].jpeg_freq_threshold) { return send_rect_simple(vs, x, y, w, h, false); } } if (w * h < VNC_TIGHT_MIN_SPLIT_RECT_SIZE) { return send_rect_simple(vs, x, y, w, h, true); } max_rows = tight_conf[vs->tight.compression].max_rect_size; max_rows /= MIN(tight_conf[vs->tight.compression].max_rect_width, w); return find_large_solid_color_rect(vs, x, y, w, h, max_rows); }
1threat
static void readline_printf_func(void *opaque, const char *fmt, ...) { va_list ap; va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); }
1threat
static inline int onenand_prog_spare(OneNANDState *s, int sec, int secn, void *src) { int result = 0; if (secn > 0) { const uint8_t *sp = (const uint8_t *)src; uint8_t *dp = 0, *dpp = 0; if (s->bdrv_cur) { dp = g_malloc(512); if (!dp || bdrv_read(s->bdrv_cur, s->secs_cur + (sec >> 5), dp, 1) < 0) { result = 1; } else { dpp = dp + ((sec & 31) << 4); } } else { if (sec + secn > s->secs_cur) { result = 1; } else { dpp = s->current + (s->secs_cur << 9) + (sec << 4); } } if (!result) { uint32_t i; for (i = 0; i < (secn << 4); i++) { dpp[i] &= sp[i]; } if (s->bdrv_cur) { result = bdrv_write(s->bdrv_cur, s->secs_cur + (sec >> 5), dp, 1) < 0; } } g_free(dp); } return result; }
1threat
Beginner - Not getting output in my textbook : I'm a student and have a question. I'm not getting the correct output in our textbook. first = 'I' second = 'love' third = 'Python' sentence = first + '' + second + '' + third + '.' Output: I love Python. When I run it, nothing happens. Can someone explain why? Thanks in advance!
0debug
hide/show fab with scale animation : <p>I'm using custom floatingactionmenu. I need to implement scale animation on show/hide menu button like here <a href="https://material-design.storage.googleapis.com/publish/material_v_4/material_ext_publish/0B6Okdz75tqQsZU1kZWhRYWZpUDg/components-buttons-fab-behavior_01_xhdpi_012.mp4" rel="noreferrer">floating action button behaviour</a></p> <p>Is there any way to do this ?</p>
0debug
void *qemu_blockalign(BlockDriverState *bs, size_t size) { return qemu_memalign((bs && bs->buffer_alignment) ? bs->buffer_alignment : 512, size); }
1threat
void do_info_usernet(Monitor *mon) { SlirpState *s; TAILQ_FOREACH(s, &slirp_stacks, entry) { monitor_printf(mon, "VLAN %d (%s):\n", s->vc->vlan->id, s->vc->name); slirp_connection_info(s->slirp, mon); } }
1threat
PHP - simple array to multiple array : I have an array with contry list like this $array = array('country1' => CountryOne, 'country2' => Country Two); How i can transform this array in a multiple array like: array(2) { [0] => array(2) { ["code"] => "country1",["name"] => "CountryOne"} [1] => array(2) { ["code"] => "country2",["name"] => "CountryTwo"} }}
0debug
Is there third party package repository for Swift? : <p>I came from web development/design (still are) and I started to learn Swift 5 for iOS app development. In web development, there's a lot of sites or repo where I can download pre-written codes for the web like packagist.org. My question is, is there a similar site where I can pull pre-written code in Swift so I can extend the functionality of an iOS app? Thank you!</p>
0debug
How can i change this code for multiplication? : i have this code and i am using for addition of inputs. How can i change this code for multiplication? function sumIt() { var total = 0, val; $('.inst_amount').each(function() { val = $(this).val(); val = isNaN(val) || $.trim(val) === "" ? 0 : parseFloat(val); total += val; }); $('#total_price').html(Math.round(total)); $('#total_amount').val(Math.round(total)); } $(function() { $("#add").on("click", function() { $("#container input").last() .before($("<input />").prop("class","inst_amount").val(0)) .before("<br/>"); sumIt(); }); $(document).on('input', '.inst_amount', sumIt); sumIt() // run when loading });
0debug
void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number) { mpeg1_encode_sequence_header(s); put_header(s, PICTURE_START_CODE); put_bits(&s->pb, 10, (s->picture_number - s->gop_picture_number) & 0x3ff); s->fake_picture_number++; put_bits(&s->pb, 3, s->pict_type); s->vbv_delay_ptr= s->pb.buf + get_bit_count(&s->pb)/8; put_bits(&s->pb, 16, 0xFFFF); if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) { put_bits(&s->pb, 1, 0); if(s->codec_id == CODEC_ID_MPEG1VIDEO) put_bits(&s->pb, 3, s->f_code); else put_bits(&s->pb, 3, 7); } if (s->pict_type == B_TYPE) { put_bits(&s->pb, 1, 0); if(s->codec_id == CODEC_ID_MPEG1VIDEO) put_bits(&s->pb, 3, s->b_code); else put_bits(&s->pb, 3, 7); } put_bits(&s->pb, 1, 0); s->frame_pred_frame_dct = 1; if(s->codec_id == CODEC_ID_MPEG2VIDEO){ put_header(s, EXT_START_CODE); put_bits(&s->pb, 4, 8); if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) { put_bits(&s->pb, 4, s->f_code); put_bits(&s->pb, 4, s->f_code); }else{ put_bits(&s->pb, 8, 255); } if (s->pict_type == B_TYPE) { put_bits(&s->pb, 4, s->b_code); put_bits(&s->pb, 4, s->b_code); }else{ put_bits(&s->pb, 8, 255); } put_bits(&s->pb, 2, s->intra_dc_precision); put_bits(&s->pb, 2, s->picture_structure= PICT_FRAME); if (s->progressive_sequence) { put_bits(&s->pb, 1, 0); } else { put_bits(&s->pb, 1, s->current_picture_ptr->top_field_first); } s->frame_pred_frame_dct = s->progressive_sequence; put_bits(&s->pb, 1, s->frame_pred_frame_dct); put_bits(&s->pb, 1, s->concealment_motion_vectors); put_bits(&s->pb, 1, s->q_scale_type); put_bits(&s->pb, 1, s->intra_vlc_format); put_bits(&s->pb, 1, s->alternate_scan); put_bits(&s->pb, 1, s->repeat_first_field); put_bits(&s->pb, 1, s->chroma_420_type=1); s->progressive_frame = s->progressive_sequence; put_bits(&s->pb, 1, s->progressive_frame); put_bits(&s->pb, 1, 0); } if(s->flags & CODEC_FLAG_SVCD_SCAN_OFFSET){ int i; put_header(s, USER_START_CODE); for(i=0; i<sizeof(svcd_scan_offset_placeholder); i++){ put_bits(&s->pb, 8, svcd_scan_offset_placeholder[i]); } } s->mb_y=0; ff_mpeg1_encode_slice_header(s); }
1threat
static int wma_decode_init(AVCodecContext * avctx) { WMADecodeContext *s = avctx->priv_data; int i, flags1, flags2; float *window; uint8_t *extradata; float bps1, high_freq; volatile float bps; int sample_rate1; int coef_vlc_table; s->sample_rate = avctx->sample_rate; s->nb_channels = avctx->channels; s->bit_rate = avctx->bit_rate; s->block_align = avctx->block_align; if (avctx->codec->id == CODEC_ID_WMAV1) { s->version = 1; } else { s->version = 2; } flags1 = 0; flags2 = 0; extradata = avctx->extradata; if (s->version == 1 && avctx->extradata_size >= 4) { flags1 = extradata[0] | (extradata[1] << 8); flags2 = extradata[2] | (extradata[3] << 8); } else if (s->version == 2 && avctx->extradata_size >= 6) { flags1 = extradata[0] | (extradata[1] << 8) | (extradata[2] << 16) | (extradata[3] << 24); flags2 = extradata[4] | (extradata[5] << 8); } s->use_exp_vlc = flags2 & 0x0001; s->use_bit_reservoir = flags2 & 0x0002; s->use_variable_block_len = flags2 & 0x0004; if (s->sample_rate <= 16000) { s->frame_len_bits = 9; } else if (s->sample_rate <= 22050 || (s->sample_rate <= 32000 && s->version == 1)) { s->frame_len_bits = 10; } else { s->frame_len_bits = 11; } s->frame_len = 1 << s->frame_len_bits; if (s->use_variable_block_len) { int nb_max, nb; nb = ((flags2 >> 3) & 3) + 1; if ((s->bit_rate / s->nb_channels) >= 32000) nb += 2; nb_max = s->frame_len_bits - BLOCK_MIN_BITS; if (nb > nb_max) nb = nb_max; s->nb_block_sizes = nb + 1; } else { s->nb_block_sizes = 1; } s->use_noise_coding = 1; high_freq = s->sample_rate * 0.5; sample_rate1 = s->sample_rate; if (s->version == 2) { if (sample_rate1 >= 44100) sample_rate1 = 44100; else if (sample_rate1 >= 22050) sample_rate1 = 22050; else if (sample_rate1 >= 16000) sample_rate1 = 16000; else if (sample_rate1 >= 11025) sample_rate1 = 11025; else if (sample_rate1 >= 8000) sample_rate1 = 8000; } bps = (float)s->bit_rate / (float)(s->nb_channels * s->sample_rate); s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0)) + 2; bps1 = bps; if (s->nb_channels == 2) bps1 = bps * 1.6; if (sample_rate1 == 44100) { if (bps1 >= 0.61) s->use_noise_coding = 0; else high_freq = high_freq * 0.4; } else if (sample_rate1 == 22050) { if (bps1 >= 1.16) s->use_noise_coding = 0; else if (bps1 >= 0.72) high_freq = high_freq * 0.7; else high_freq = high_freq * 0.6; } else if (sample_rate1 == 16000) { if (bps > 0.5) high_freq = high_freq * 0.5; else high_freq = high_freq * 0.3; } else if (sample_rate1 == 11025) { high_freq = high_freq * 0.7; } else if (sample_rate1 == 8000) { if (bps <= 0.625) { high_freq = high_freq * 0.5; } else if (bps > 0.75) { s->use_noise_coding = 0; } else { high_freq = high_freq * 0.65; } } else { if (bps >= 0.8) { high_freq = high_freq * 0.75; } else if (bps >= 0.6) { high_freq = high_freq * 0.6; } else { high_freq = high_freq * 0.5; } } dprintf("flags1=0x%x flags2=0x%x\n", flags1, flags2); dprintf("version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n", s->version, s->nb_channels, s->sample_rate, s->bit_rate, s->block_align); dprintf("bps=%f bps1=%f high_freq=%f bitoffset=%d\n", bps, bps1, high_freq, s->byte_offset_bits); dprintf("use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n", s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes); { int a, b, pos, lpos, k, block_len, i, j, n; const uint8_t *table; if (s->version == 1) { s->coefs_start = 3; } else { s->coefs_start = 0; } for(k = 0; k < s->nb_block_sizes; k++) { block_len = s->frame_len >> k; if (s->version == 1) { lpos = 0; for(i=0;i<25;i++) { a = wma_critical_freqs[i]; b = s->sample_rate; pos = ((block_len * 2 * a) + (b >> 1)) / b; if (pos > block_len) pos = block_len; s->exponent_bands[0][i] = pos - lpos; if (pos >= block_len) { i++; break; } lpos = pos; } s->exponent_sizes[0] = i; } else { table = NULL; a = s->frame_len_bits - BLOCK_MIN_BITS - k; if (a < 3) { if (s->sample_rate >= 44100) table = exponent_band_44100[a]; else if (s->sample_rate >= 32000) table = exponent_band_32000[a]; else if (s->sample_rate >= 22050) table = exponent_band_22050[a]; } if (table) { n = *table++; for(i=0;i<n;i++) s->exponent_bands[k][i] = table[i]; s->exponent_sizes[k] = n; } else { j = 0; lpos = 0; for(i=0;i<25;i++) { a = wma_critical_freqs[i]; b = s->sample_rate; pos = ((block_len * 2 * a) + (b << 1)) / (4 * b); pos <<= 2; if (pos > block_len) pos = block_len; if (pos > lpos) s->exponent_bands[k][j++] = pos - lpos; if (pos >= block_len) break; lpos = pos; } s->exponent_sizes[k] = j; } } s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k; s->high_band_start[k] = (int)((block_len * 2 * high_freq) / s->sample_rate + 0.5); n = s->exponent_sizes[k]; j = 0; pos = 0; for(i=0;i<n;i++) { int start, end; start = pos; pos += s->exponent_bands[k][i]; end = pos; if (start < s->high_band_start[k]) start = s->high_band_start[k]; if (end > s->coefs_end[k]) end = s->coefs_end[k]; if (end > start) s->exponent_high_bands[k][j++] = end - start; } s->exponent_high_sizes[k] = j; #if 0 tprintf("%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ", s->frame_len >> k, s->coefs_end[k], s->high_band_start[k], s->exponent_high_sizes[k]); for(j=0;j<s->exponent_high_sizes[k];j++) tprintf(" %d", s->exponent_high_bands[k][j]); tprintf("\n"); #endif } } #ifdef TRACE { int i, j; for(i = 0; i < s->nb_block_sizes; i++) { tprintf("%5d: n=%2d:", s->frame_len >> i, s->exponent_sizes[i]); for(j=0;j<s->exponent_sizes[i];j++) tprintf(" %d", s->exponent_bands[i][j]); tprintf("\n"); } } #endif for(i = 0; i < s->nb_block_sizes; i++) ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1); for(i = 0; i < s->nb_block_sizes; i++) { int n, j; float alpha; n = 1 << (s->frame_len_bits - i); window = av_malloc(sizeof(float) * n); alpha = M_PI / (2.0 * n); for(j=0;j<n;j++) { window[n - j - 1] = sin((j + 0.5) * alpha); } s->windows[i] = window; } s->reset_block_lengths = 1; if (s->use_noise_coding) { if (s->use_exp_vlc) s->noise_mult = 0.02; else s->noise_mult = 0.04; #ifdef TRACE for(i=0;i<NOISE_TAB_SIZE;i++) s->noise_table[i] = 1.0 * s->noise_mult; #else { unsigned int seed; float norm; seed = 1; norm = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult; for(i=0;i<NOISE_TAB_SIZE;i++) { seed = seed * 314159 + 1; s->noise_table[i] = (float)((int)seed) * norm; } } #endif init_vlc(&s->hgain_vlc, 9, sizeof(hgain_huffbits), hgain_huffbits, 1, 1, hgain_huffcodes, 2, 2); } if (s->use_exp_vlc) { init_vlc(&s->exp_vlc, 9, sizeof(scale_huffbits), scale_huffbits, 1, 1, scale_huffcodes, 4, 4); } else { wma_lsp_to_curve_init(s, s->frame_len); } coef_vlc_table = 2; if (s->sample_rate >= 32000) { if (bps1 < 0.72) coef_vlc_table = 0; else if (bps1 < 1.16) coef_vlc_table = 1; } init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0], &coef_vlcs[coef_vlc_table * 2]); init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1], &coef_vlcs[coef_vlc_table * 2 + 1]); return 0; }
1threat
Why there is no floating point type smaller in byte-size than 'float' in C# : <p>Hopefully it is the 1st question of its type on SO. C# has 4 integral types:</p> <p><code>byte</code>: 1 byte</p> <p><code>short</code>: 2 bytes</p> <p><code>int</code>: 4 bytes</p> <p><code>long</code>: 8 bytes</p> <p>But just two floating point types: <code>float</code> and <code>double</code>. Why did the creators did not feel a need to come up with a tiny float? There is a Wikipedia <a href="https://en.wikipedia.org/wiki/Minifloat" rel="nofollow noreferrer">article</a> about Minifloats.</p>
0debug
int cpu_x86_handle_mmu_fault(CPUX86State *env, uint32_t addr, int is_write, int is_user, int is_softmmu) { uint8_t *pde_ptr, *pte_ptr; uint32_t pde, pte, virt_addr, ptep; int error_code, is_dirty, prot, page_size, ret; unsigned long paddr, vaddr, page_offset; #if defined(DEBUG_MMU) printf("MMU fault: addr=0x%08x w=%d u=%d eip=%08x\n", addr, is_write, is_user, env->eip); #endif if (env->user_mode_only) { error_code = 0; goto do_fault; } if (!(env->cr[0] & CR0_PG_MASK)) { pte = addr; virt_addr = addr & TARGET_PAGE_MASK; prot = PROT_READ | PROT_WRITE; page_size = 4096; goto do_mapping; } pde_ptr = phys_ram_base + (((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) & a20_mask); pde = ldl_raw(pde_ptr); if (!(pde & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { if (is_user) { if (!(pde & PG_USER_MASK)) goto do_fault_protect; if (is_write && !(pde & PG_RW_MASK)) goto do_fault_protect; } else { if ((env->cr[0] & CR0_WP_MASK) && (pde & PG_USER_MASK) && is_write && !(pde & PG_RW_MASK)) goto do_fault_protect; } is_dirty = is_write && !(pde & PG_DIRTY_MASK); if (!(pde & PG_ACCESSED_MASK) || is_dirty) { pde |= PG_ACCESSED_MASK; if (is_dirty) pde |= PG_DIRTY_MASK; stl_raw(pde_ptr, pde); } pte = pde & ~0x003ff000; ptep = pte; page_size = 4096 * 1024; virt_addr = addr & ~0x003fffff; } else { if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_raw(pde_ptr, pde); } pte_ptr = phys_ram_base + (((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & a20_mask); pte = ldl_raw(pte_ptr); if (!(pte & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } ptep = pte & pde; if (is_user) { if (!(ptep & PG_USER_MASK)) goto do_fault_protect; if (is_write && !(ptep & PG_RW_MASK)) goto do_fault_protect; } else { if ((env->cr[0] & CR0_WP_MASK) && (ptep & PG_USER_MASK) && is_write && !(ptep & PG_RW_MASK)) goto do_fault_protect; } is_dirty = is_write && !(pte & PG_DIRTY_MASK); if (!(pte & PG_ACCESSED_MASK) || is_dirty) { pte |= PG_ACCESSED_MASK; if (is_dirty) pte |= PG_DIRTY_MASK; stl_raw(pte_ptr, pte); } page_size = 4096; virt_addr = addr & ~0xfff; } prot = PROT_READ; if (pte & PG_DIRTY_MASK) { if (is_user) { if (ptep & PG_RW_MASK) prot |= PROT_WRITE; } else { if (!(env->cr[0] & CR0_WP_MASK) || !(ptep & PG_USER_MASK) || (ptep & PG_RW_MASK)) prot |= PROT_WRITE; } } do_mapping: pte = pte & a20_mask; page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1); paddr = (pte & TARGET_PAGE_MASK) + page_offset; vaddr = virt_addr + page_offset; ret = tlb_set_page(env, vaddr, paddr, prot, is_user, is_softmmu); return ret; do_fault_protect: error_code = PG_ERROR_P_MASK; do_fault: env->cr[2] = addr; env->error_code = (is_write << PG_ERROR_W_BIT) | error_code; if (is_user) env->error_code |= PG_ERROR_U_MASK; return 1; }
1threat
Reading Sequences in Python : I'm new to python and I'm trying to help out a friend with her code. The code receives input from a user until the input is 0, using a while loop. I'm not used to the python syntax, so I'm a little confused as to how to receive user input. I don't know what I'm doing wrong. Here's my code: sum = 0 number = input() while number != 0: number = input() sum += number if user == 0: break
0debug
ruby check if a jpeg is readable : Ruby newby here<br /> I am downloading pictures with open-Uri and sometimes, the downloaded picture is corrupted and cannot be opened with a picture viewer (or another program capable of displaying pictures)<br /> Is there a simple method to determine if the downloaded picture is corrupted an cannot be read by other programs?<br /> Thanks<br />
0debug
How to Zip Two Lists, of Which One Only Has One Element or More (Combine Elements One by One From Two List) : <p>Here is an example of two lists:</p> <pre><code>scala&gt; val hosts = List("host1", "host2") hosts: List[String] = List(host1, host2) scala&gt; val ports = List("port1") ports: List[String] = List(port1) </code></pre> <p>What I want to achieve is:</p> <pre><code>scala&gt; hosts zip ports List[(String, String)] = List((host1,port1), (host2,port1)) </code></pre> <p>Result below is what I get, which may be expected but I am still in the process of learning. would appreciate any help. </p> <pre><code>scala&gt; hosts zip ports res20: List[(String, String)] = List((host1,port1)) </code></pre> <p>Note: at least one element on each list any time but it varies. regardless I would like to achieve one by one pairing.</p>
0debug
when i am clicking on the upload button in document web part, then inside that section master page is showing(which should not show) : continued..... Kindly let me know how to remove that either in SharePoint designer or SharePoint 2013 itself. Also site settings is showing up in home page(but it should show in seperate new page). screenshots attached for the reference. [enter image description here][1] [enter image description here][2] [1]: https://i.stack.imgur.com/f5Lqp.png [2]: https://i.stack.imgur.com/5U0Wg.png
0debug
how to compare two strings in IF condition (if the words are similar from each strings) inside for loop in python? : I want to compare two strings after changed from list. if the word from d1 is similar with d2, then it returns the similar words. here's my codes : d1 = [['learn'],['car']] d2 = [['learn'],['motor']] str1 = ', '.join(str(i) for i in d1) str2 = ', '.join(str(j) for j in d2) for i in str1: for j in str2: if i == j: print str1, str2 but the output is : ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] ['learn'], ['car'] ['learn'], ['motor'] I expect the output to be: ['learn','learn'] ^ it comes from the similar words in str1 and str2. anyone can help? thanks
0debug
int ff_get_cpu_flags_x86(void) { int rval = 0; int eax, ebx, ecx, edx; int max_std_level, max_ext_level, std_caps=0, ext_caps=0; int family=0, model=0; union { int i[3]; char c[12]; } vendor; #if ARCH_X86_32 x86_reg a, c; __asm__ volatile ( "pushfl\n\t" "pop %0\n\t" "mov %0, %1\n\t" "xor $0x200000, %0\n\t" "push %0\n\t" "popfl\n\t" "pushfl\n\t" "pop %0\n\t" : "=a" (a), "=c" (c) : : "cc" ); if (a == c) return 0; #endif cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]); if(max_std_level >= 1){ cpuid(1, eax, ebx, ecx, std_caps); family = ((eax>>8)&0xf) + ((eax>>20)&0xff); model = ((eax>>4)&0xf) + ((eax>>12)&0xf0); if (std_caps & (1<<23)) rval |= AV_CPU_FLAG_MMX; if (std_caps & (1<<25)) rval |= AV_CPU_FLAG_MMX2 #if HAVE_SSE | AV_CPU_FLAG_SSE; if (std_caps & (1<<26)) rval |= AV_CPU_FLAG_SSE2; if (ecx & 1) rval |= AV_CPU_FLAG_SSE3; if (ecx & 0x00000200 ) rval |= AV_CPU_FLAG_SSSE3; if (ecx & 0x00080000 ) rval |= AV_CPU_FLAG_SSE4; if (ecx & 0x00100000 ) rval |= AV_CPU_FLAG_SSE42; #if HAVE_AVX if ((ecx & 0x18000000) == 0x18000000) { xgetbv(0, eax, edx); if ((eax & 0x6) == 0x6) rval |= AV_CPU_FLAG_AVX; } #endif #endif ; } cpuid(0x80000000, max_ext_level, ebx, ecx, edx); if(max_ext_level >= 0x80000001){ cpuid(0x80000001, eax, ebx, ecx, ext_caps); if (ext_caps & (1<<31)) rval |= AV_CPU_FLAG_3DNOW; if (ext_caps & (1<<30)) rval |= AV_CPU_FLAG_3DNOWEXT; if (ext_caps & (1<<23)) rval |= AV_CPU_FLAG_MMX; if (ext_caps & (1<<22)) rval |= AV_CPU_FLAG_MMX2; if (!strncmp(vendor.c, "AuthenticAMD", 12) && rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x00000040)) { rval |= AV_CPU_FLAG_SSE2SLOW; } } if (!strncmp(vendor.c, "GenuineIntel", 12)) { if (family == 6 && (model == 9 || model == 13 || model == 14)) { if (rval & AV_CPU_FLAG_SSE2) rval ^= AV_CPU_FLAG_SSE2SLOW|AV_CPU_FLAG_SSE2; if (rval & AV_CPU_FLAG_SSE3) rval ^= AV_CPU_FLAG_SSE3SLOW|AV_CPU_FLAG_SSE3; } if (family == 6 && model == 28) rval |= AV_CPU_FLAG_ATOM; } return rval; }
1threat
static Coroutine *coroutine_new(void) { const size_t stack_size = 1 << 20; CoroutineUContext *co; CoroutineThreadState *coTS; struct sigaction sa; struct sigaction osa; struct sigaltstack ss; struct sigaltstack oss; sigset_t sigs; sigset_t osigs; jmp_buf old_env; co = g_malloc0(sizeof(*co)); co->stack = g_malloc(stack_size); co->base.entry_arg = &old_env; coTS = coroutine_get_thread_state(); coTS->tr_handler = co; sigemptyset(&sigs); sigaddset(&sigs, SIGUSR2); pthread_sigmask(SIG_BLOCK, &sigs, &osigs); sa.sa_handler = coroutine_trampoline; sigfillset(&sa.sa_mask); sa.sa_flags = SA_ONSTACK; if (sigaction(SIGUSR2, &sa, &osa) != 0) { abort(); } ss.ss_sp = co->stack; ss.ss_size = stack_size; ss.ss_flags = 0; if (sigaltstack(&ss, &oss) < 0) { abort(); } coTS->tr_called = 0; kill(getpid(), SIGUSR2); sigfillset(&sigs); sigdelset(&sigs, SIGUSR2); while (!coTS->tr_called) { sigsuspend(&sigs); } sigaltstack(NULL, &ss); ss.ss_flags = SS_DISABLE; if (sigaltstack(&ss, NULL) < 0) { abort(); } sigaltstack(NULL, &ss); if (!(oss.ss_flags & SS_DISABLE)) { sigaltstack(&oss, NULL); } sigaction(SIGUSR2, &osa, NULL); pthread_sigmask(SIG_SETMASK, &osigs, NULL); if (!setjmp(old_env)) { longjmp(coTS->tr_reenter, 1); } return &co->base; }
1threat
Why I get wrong result with std::pow and std::fmod? : <p>The following lines of code end up returning a wrong result after a calculation, could this be caused by the approximation of the "double" type?</p> <pre><code> int base = 20, exp = 27, mod = 123; std::fmod(std::pow(base, exp), mod) </code></pre> <p>Is there a way to get the right calculation? (also with base = 128, Exp >= 50 mod >= 200?) Sorry for my bad English </p>
0debug
static int coroutine_fn nfs_co_flush(BlockDriverState *bs) { NFSClient *client = bs->opaque; NFSRPC task; nfs_co_init_task(client, &task); if (nfs_fsync_async(client->context, client->fh, nfs_co_generic_cb, &task) != 0) { return -ENOMEM; } while (!task.complete) { nfs_set_events(client); qemu_coroutine_yield(); } return task.ret; }
1threat
Google permission restriction for SMS and CALL_LOG : <p>My app during testing has RECEIVE_SMS permission. A month ago I receive warning from Google for restrictions about receiving SMS since 9 January 2019. After warning I removed this permission from manifest, but warning is still displayed. Now my manifest permissions:</p> <pre><code>&lt;uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt; &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /&gt; </code></pre> <p>Also I changed minSdkVersion to</p> <pre><code>ext { buildToolsVersion = "26.0.3" minSdkVersion = 17 compileSdkVersion = 26 targetSdkVersion = 26 supportLibVersion = "26.1.0" } </code></pre> <p>Do I need to do something else?</p>
0debug
Identify Return Key action in React Native : <p>I have a <code>TextInput</code> which I have enabled <code>multiline</code> as true. Thing is the Keyboard won't hide after Return is pressed. It goes to a new line. So I was hoping to use <a href="https://www.npmjs.com/package/react-native-dismiss-keyboard" rel="noreferrer">react-native-dismiss-keyboard</a>. To exploit this I need to identify the Return key action. How to do this?</p> <pre><code>&lt;TextInput style={styles.additionalTextInput} multiline={true} autoCapitalize="sentences" autoCorrect={true} onChangeText={(text) =&gt; this.setState({text})} keyboardType="default" returnKeyType="done" onKeyPress={(keyPress) =&gt; console.log(keyPress)} placeholder="Enter text here..." /&gt; </code></pre>
0debug
void gen_intermediate_code_internal(LM32CPU *cpu, TranslationBlock *tb, bool search_pc) { CPUState *cs = CPU(cpu); CPULM32State *env = &cpu->env; struct DisasContext ctx, *dc = &ctx; uint16_t *gen_opc_end; uint32_t pc_start; int j, lj; uint32_t next_page_start; int num_insns; int max_insns; pc_start = tb->pc; dc->features = cpu->features; dc->num_breakpoints = cpu->num_breakpoints; dc->num_watchpoints = cpu->num_watchpoints; dc->tb = tb; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; dc->pc = pc_start; dc->singlestep_enabled = cs->singlestep_enabled; if (pc_start & 3) { qemu_log_mask(LOG_GUEST_ERROR, "unaligned PC=%x. Ignoring lowest bits.\n", pc_start); pc_start &= ~3; } next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; lj = -1; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } gen_tb_start(); do { check_breakpoint(env, dc); if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (lj < j) { lj++; while (lj < j) { tcg_ctx.gen_opc_instr_start[lj++] = 0; } } tcg_ctx.gen_opc_pc[lj] = dc->pc; tcg_ctx.gen_opc_instr_start[lj] = 1; tcg_ctx.gen_opc_icount[lj] = num_insns; } LOG_DIS("%8.8x:\t", dc->pc); if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) { gen_io_start(); } decode(dc, cpu_ldl_code(env, dc->pc)); dc->pc += 4; num_insns++; } while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end && !cs->singlestep_enabled && !singlestep && (dc->pc < next_page_start) && num_insns < max_insns); if (tb->cflags & CF_LAST_IO) { gen_io_end(); } if (unlikely(cs->singlestep_enabled)) { if (dc->is_jmp == DISAS_NEXT) { tcg_gen_movi_tl(cpu_pc, dc->pc); } t_gen_raise_exception(dc, EXCP_DEBUG); } else { switch (dc->is_jmp) { case DISAS_NEXT: gen_goto_tb(dc, 1, dc->pc); break; default: case DISAS_JUMP: case DISAS_UPDATE: tcg_gen_exit_tb(0); break; case DISAS_TB_JUMP: break; } } gen_tb_end(tb, num_insns); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (search_pc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; lj++; while (lj <= j) { tcg_ctx.gen_opc_instr_start[lj++] = 0; } } else { tb->size = dc->pc - pc_start; tb->icount = num_insns; } #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("\n"); log_target_disas(env, pc_start, dc->pc - pc_start, 0); qemu_log("\nisize=%d osize=%td\n", dc->pc - pc_start, tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf); } #endif }
1threat
Why JVM doesn't throw any compile time error for not initializing local variable if a local variable is declared like this int a=10,b=3,m;? : I am trying to execute the below code: public class HelloWorld{ public static void main(String []args){ int a=10,b=3,m; System.out.println("Hello World "+a+" " + b); } } I was expecting a compilation error for not initializing local variable 'm' but the program ran successfully and gave me the output. Why is it so ? I was thinking in all the cases if the local variable is not initialized JVM will throw an error. When I try to execute the code given below public class HelloWorld{ public static void main(String []args){ int a=10,b=3,m; System.out.println("Hello World "+a+" " + b + " " +m); } } Here I am calling the value of 'm' and I am getting error for not initializing local variable. But why doesn't java throw error in the first case?
0debug
What does this means, why is the (int) in the sentence? : I don't know why is the "int" in parenthesis next to the *Predicator typedef bool (*Predicate)(int);
0debug
static void fft(AC3MDCTContext *mdct, IComplex *z, int ln) { int j, l, np, np2; int nblocks, nloops; register IComplex *p,*q; int tmp_re, tmp_im; np = 1 << ln; for (j = 0; j < np; j++) { int k = av_reverse[j] >> (8 - ln); if (k < j) FFSWAP(IComplex, z[k], z[j]); } p = &z[0]; j = np >> 1; do { BF(p[0].re, p[0].im, p[1].re, p[1].im, p[0].re, p[0].im, p[1].re, p[1].im); p += 2; } while (--j); p = &z[0]; j = np >> 2; do { BF(p[0].re, p[0].im, p[2].re, p[2].im, p[0].re, p[0].im, p[2].re, p[2].im); BF(p[1].re, p[1].im, p[3].re, p[3].im, p[1].re, p[1].im, p[3].im, -p[3].re); p+=4; } while (--j); nblocks = np >> 3; nloops = 1 << 2; np2 = np >> 1; do { p = z; q = z + nloops; for (j = 0; j < nblocks; j++) { BF(p->re, p->im, q->re, q->im, p->re, p->im, q->re, q->im); p++; q++; for(l = nblocks; l < np2; l += nblocks) { CMUL(tmp_re, tmp_im, mdct->costab[l], -mdct->sintab[l], q->re, q->im); BF(p->re, p->im, q->re, q->im, p->re, p->im, tmp_re, tmp_im); p++; q++; } p += nloops; q += nloops; } nblocks = nblocks >> 1; nloops = nloops << 1; } while (nblocks); }
1threat
void omap_badwidth_write8(void *opaque, target_phys_addr_t addr, uint32_t value) { uint8_t val8 = value; OMAP_8B_REG(addr); cpu_physical_memory_write(addr, (void *) &val8, 1); }
1threat
Length of each string in a NumPy array : <p>Is there any builtin operation in NumPy that returns the length of each string in an array?</p> <p>I don't think any of the <a href="https://docs.scipy.org/doc/numpy-1.12.0/reference/routines.char.html" rel="noreferrer">NumPy string operations</a> does that, is this correct?</p> <p>I can do it with a <code>for</code> loop, but maybe there's something more efficient?</p> <pre><code>import numpy as np arr = np.array(['Hello', 'foo', 'and', 'whatsoever'], dtype='S256') sizes = [] for i in arr: sizes.append(len(i)) print(sizes) [5, 3, 3, 10] </code></pre>
0debug
How to insert/update information in SqlServer using C# : Hello I am trying to insert new information into my already created table where id = 2019; I get the error incorrect syntax near WHERE private void button6_Click(object sender, EventArgs e) { xcon.Open(); SqlDataAdapter xadapter = new SqlDataAdapter(); xadapter.InsertCommand = new SqlCommand("INSERT into dbo.SysX VALUES (@fpp, @sdd, @sff) WHERE id = 2019", xcon); xadapter.InsertCommand.Parameters.Add("@fpp", SqlDbType.Int).Value = Convert.ToInt32(textBox1.Text); xadapter.InsertCommand.Parameters.Add("@sdd", SqlDbType.Int).Value = Convert.ToInt32(textBox2.Text); xadapter.InsertCommand.Parameters.Add("@sff", SqlDbType.Int).Value = Convert.ToInt32(textBox3.Text); xadapter.InsertCommand.ExecuteNonQuery(); xcon.Close(); } How can I insert new information on click of button where ID = 2019 thanks
0debug
Kestrel with IIS - libuv.dll missing on run : <p>We're setting up an existing Web API server to serve site(s) alongside an existing API. I have been loosely following <a href="http://miniml.ist/dotnet/how-to-serve-a-static-site-plus-a-web-api-in-aspnetcore/" rel="noreferrer">this article</a>.</p> <p>Here's what my Global.asax.cs looks like:</p> <pre><code>public class WebApiApplication : System.Web.HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); AutoMapperConfig.RegisterMappings(); var host = new WebHostBuilder() .UseKestrel() .UseWebRoot("wwwroot") .UseIISIntegration() .UseStartup&lt;Startup&gt;() .Build(); host.Run(); } } </code></pre> <p>and Startup.cs:</p> <pre><code>public partial class Startup { public void Configure(IApplicationBuilder app) { app.UseDefaultFiles(); app.UseStaticFiles(); } } </code></pre> <p>When I run the project, I get the error</p> <blockquote> <p>Unable to load DLL 'libuv': The specified module could not be found. (Exception from HRESULT: 0x8007007E)</p> </blockquote> <p>libuv is a dependency of Kestrel. If I manually copy it from the packages folder to the bin folder, it works. That seems to make sense with this <a href="https://github.com/aspnet/KestrelHttpServer/issues/735#issuecomment-247220516" rel="noreferrer">GitHub Issue comment</a>. Now that project.json is being moved away from, how can I get it to copy automatically?</p> <p>Some have posited that it does not know whether to use 32 or 64 bit version of libuv because the Platform is set to Any CPU in the project properties. I have tried setting it to x64 in both the solution and project settings and the problem persists.</p> <p><strong>How can I make libuv.dll copy directly to the build directory automatically?</strong></p> <p>I do not consider including the file in the project (instead of in the packages folder) and setting it to copy to the output directory a real solution, only a workaround. I'm hoping to find a solution, not a workaround.</p>
0debug
static void uhci_fill_queue(UHCIState *s, UHCI_TD *td) { uint32_t int_mask = 0; uint32_t plink = td->link; uint32_t token = uhci_queue_token(td); UHCI_TD ptd; int ret; while (is_valid(plink)) { pci_dma_read(&s->dev, plink & ~0xf, &ptd, sizeof(ptd)); le32_to_cpus(&ptd.link); le32_to_cpus(&ptd.ctrl); le32_to_cpus(&ptd.token); le32_to_cpus(&ptd.buffer); if (!(ptd.ctrl & TD_CTRL_ACTIVE)) { break; } if (uhci_queue_token(&ptd) != token) { break; } trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token); ret = uhci_handle_td(s, plink, &ptd, &int_mask, true); if (ret == TD_RESULT_ASYNC_CONT) { break; } assert(ret == TD_RESULT_ASYNC_START); assert(int_mask == 0); if (ptd.ctrl & TD_CTRL_SPD) { break; } plink = ptd.link; } }
1threat
Websocket : javascript as client and python as server, and web host on Linux : I need to build the website and use the javascript as client language to communicate with python server. BTW, the webpage need to be host on Linux. and for now, I just only use the command "python -m SimpleHTTPServer" to build a simple server. and the server is also on the Linux and use the python. could anyone kindly to teach me how to build this system. thanks you!
0debug
Can I inspect a sqlalchemy query object to find the already joined tables? : <p>I'm trying to programmatically build a search query, and to do so, I'm joining a table.</p> <pre><code>class User(db.Model): id = db.Column(db.Integer(), primary_key=True) class Tag(db.Model): id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('user.id')) title = db.Column(db.String(128)) description = db.Column(db.String(128)) </code></pre> <p>This is a bit of a contrived example - I hope it makes sense.</p> <p>Say my search function looks something like:</p> <pre><code>def search(title_arg, desc_arg): query = User.query if title_arg: query = query.join(Tag) query = query.filter(Tag.title.contains(title_arg)) if desc_arg: query = query.join(Tag) query = query.filter(Tag.description.contains(desc_arg)) return query </code></pre> <p>Previously, I’ve kept track of what tables that have already been joined in a list, and if the table is in the list, assume it’s already joined, and just add the filter.</p> <p>It would be cool if I could look at the query object, see that <code>Tag</code> is already joined, and skip it if so. I have some more complex query building that would really benefit from this.</p> <p>If there’s a completely different strategy for query building for searches that I’ve missed, that would be great too. Or, if the above code is fine if I join the table twice, that's great info as well. Any help is incredibly appreciated!!!</p>
0debug
Kotlin reflect proguard SmallSortedMap : <pre><code>Warning: kotlin.reflect.jvm.internal.KClassImpl: can't find referenced class kotlin.reflect.jvm.internal.KClassImpl$kotlin.reflect.jvm.internal.KClassImpl$Data Warning: kotlin.reflect.jvm.internal.KClassImpl: can't find referenced class kotlin.reflect.jvm.internal.KClassImpl$kotlin.reflect.jvm.internal.KClassImpl$Data Warning: kotlin.reflect.jvm.internal.KClassImpl$data$1: can't find referenced class kotlin.reflect.jvm.internal.KClassImpl$kotlin.reflect.jvm.internal.KClassImpl$Data Warning: kotlin.reflect.jvm.internal.KClassImpl$data$1: can't find referenced class kotlin.reflect.jvm.internal.KClassImpl$kotlin.reflect.jvm.internal.KClassImpl$Data Warning: kotlin.reflect.jvm.internal.impl.protobuf.SmallSortedMap: can't find referenced class kotlin.reflect.jvm.internal.impl.protobuf.SmallSortedMap$kotlin.reflect.jvm.internal.impl.protobuf.SmallSortedMap$Entry Warning: kotlin.reflect.jvm.internal.impl.protobuf.SmallSortedMap: can't find referenced class kotlin.reflect.jvm.internal.impl.protobuf.SmallSortedMap$kotlin.reflect.jvm.internal.impl.protobuf.SmallSortedMap$EntrySet Warning: kotlin.reflect.jvm.internal.impl.protobuf.SmallSortedMap$Entry: can't find referenced class kotlin.reflect.jvm.internal.impl.protobuf.SmallSortedMap$kotlin.reflect.jvm.internal.impl.protobuf.SmallSortedMap$Entry Warning: kotlin.reflect.jvm.internal.impl.protobuf.SmallSortedMap$Entry: can't find referenced class kotlin.reflect.jvm.internal.impl.protobuf.SmallSortedMap$kotlin.reflect.jvm.internal.impl.protobuf.SmallSortedMap$Entry </code></pre> <p>I'm getting these warnings which break my release build on the task <code>transformClassesAndResourcesWithProguardForAppRelease</code>.</p> <p>I know I can just ignore the warnings or inform proguard to not warn by using <code>-dontwarn</code> but I was wondering if anyone else had come across this and had actually found the correct fix.</p> <p>I'm using Kotlin version <code>1.1.4-2</code></p>
0debug
Web Scrapping code review : from bs4 import BeautifulSoup import requests import pandas as pd records=[] keep_looking = True url = 'https://www.tapology.com/fightcenter' while keep_looking: re = requests.get(url) soup = BeautifulSoup(re.text,'html.parser') data = soup.find_all('section',attrs={'class':'fcListing'}) for d in data: event = d.find('a').text date = d.find('span',attrs={'class':'datetime'}).text[1:-4] location = d.find('span',attrs={'class':'venue-location'}).text mainEvent = first.find('span',attrs={'class':'bout'}).text url_tag = soup.find('div',attrs={'class':'fightcenterEvents'}) if not url_tag: keep_looking = False else: url = "https://www.tapology.com" + url_tag.find('a')['href'] i am wondering if there are any errors in my code? It is running, but it is taking a very long time to finish and i am afraid it might be an infinity loop. Please any feedback would be helpful. Please do not rewrite all of this and post, as i would like to keep this format, as i am learning and want to improve. thank you.
0debug
Why do we have to forcefully use the bootstrap navbar? : <p>I believe that this component is very problematic, it has many classes, and it is easily disbanded. Would not it be much easier to use div with col and rows to control it in a simpler way?</p> <p>Of course we could use some indispensable classes like fixed, but actually I think that navbar is very complicated. Are browsers very sensitive and could cause errors if there is no nav tag?</p> <p>Excuse me if my question is very basic, but I try to learn on my own, and there are concepts that I do not know how to find them. Again an apology</p>
0debug
java.util.ConcurrentModificationException in fragment : <p>I am developing android app I have implemented searchview but when I start to search news in search bar </p> <pre><code>I am getting following exception </code></pre> <blockquote> <p>Process: edgar.yodgorbek.sportnews, PID: 5146 java.util.ConcurrentModificationException at java.util.ArrayList$Itr.next(ArrayList.java:860) at edgar.yodgorbek.sportnews.sportactivities.BBCSportFragment.doFilter(BBCSportFragment.java:126) at edgar.yodgorbek.sportnews.MainActivity$1.onQueryTextChange(MainActivity.java:126)</p> </blockquote> <p>below BBCSportFragment.java</p> <pre><code>public class BBCSportFragment extends Fragment implements ArticleAdapter.ClickListener { public static List&lt;Article&gt; articleList = new ArrayList&lt;&gt;(); public List&lt;Search&gt; searchList = new ArrayList&lt;&gt;(); @ActivityContext public Context activityContext; Search search; @ApplicationContext public Context mContext; @BindView(R.id.recycler_view) RecyclerView recyclerView; BBCSportFragmentComponent bbcSportFragmentComponent; BBCFragmentContextModule bbcFragmentContextModule; private SportNews sportNews; private static ArticleAdapter articleAdapter; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_bbcsport, container, false); ButterKnife.bind(this, view); SportInterface sportInterface = SportClient.getApiService(); Call&lt;SportNews&gt; call = sportInterface.getArticles(); call.enqueue(new Callback&lt;SportNews&gt;() { @Override public void onResponse(Call&lt;SportNews&gt; call, Response&lt;SportNews&gt; response) { if (response == null) { sportNews = response.body(); if (sportNews != null &amp;&amp; sportNews.getArticles() != null) { articleList.addAll(sportNews.getArticles()); } articleAdapter = new ArticleAdapter(articleList, sportNews); ApplicationComponent applicationComponent; applicationComponent = (ApplicationComponent) MyApplication.get(Objects.requireNonNull(getActivity())).getApplicationContext(); bbcSportFragmentComponent = (BBCSportFragmentComponent) DaggerApplicationComponent.builder().contextModule(new ContextModule(getContext())).build(); bbcSportFragmentComponent.injectBBCSportFragment(BBCSportFragment.this); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext(applicationComponent)); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(articleAdapter); } } @Override public void onFailure(Call&lt;SportNews&gt; call, Throwable t) { } }); SportInterface searchInterface = SportClient.getApiService(); Call&lt;Search&gt; searchCall = searchInterface.getSearchViewArticles("q"); searchCall.enqueue(new Callback&lt;Search&gt;() { @Override public void onResponse(Call&lt;Search&gt; call, Response&lt;Search&gt; response) { search = response.body(); if (search != null &amp;&amp; search.getArticles() != null) { articleList.addAll(search.getArticles()); } articleAdapter = new ArticleAdapter(articleList, search); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext()); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(articleAdapter); } @Override public void onFailure(Call&lt;Search&gt; call, Throwable t) { } }); return view; } private Context getContext(ApplicationComponent applicationComponent) { return null; } public static void doFilter(String searchQuery) { searchQuery = searchQuery.toLowerCase(); for(Article article: articleList){ final String text = ""; if (text.equals(searchQuery)) articleList.add(article); } articleList.clear(); if(articleList.isEmpty()) articleAdapter.notifyDataSetChanged(); } } </code></pre> <p>below MainActivity.java</p> <pre><code>public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawer; private Toolbar toolbar; private NavigationView nvDrawer; private ActionBarDrawerToggle drawerToggle; Context mContext; // Default active navigation menu int mActiveMenu; // TAGS public static final int MENU_FIRST = 0; public static final int MENU_SECOND = 1; public static final int MENU_THIRD = 2; public static final int MENU_FOURTH = 3; public static final int MENU_FIFTH = 3; public static final String TAG = "crash"; // Action bar search widget SearchView searchView; String searchQuery = ""; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set a Toolbar to replace the ActionBar. toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Find our drawer view mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = setupDrawerToggle(); // Tie DrawerLayout events to the ActionBarToggle mDrawer.addDrawerListener(drawerToggle); nvDrawer = (NavigationView) findViewById(R.id.nvView); // Inflate the header view at runtime View headerLayout = nvDrawer.inflateHeaderView(R.layout.nav_header); // We can now look up items within the header if needed ImageView ivHeaderPhoto = (ImageView) headerLayout.findViewById((R.id.header_image)); ivHeaderPhoto.setImageResource(R.drawable.ic_sportnews); setupDrawerContent(nvDrawer); FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.flContent, new BBCSportFragment()).commit(); fragmentManager.beginTransaction().replace(R.id.flContent, new FoxSportsFragment()).commit(); fragmentManager.beginTransaction().replace(R.id.flContent, new TalkSportsFragment()).commit(); } @Override public boolean onOptionsItemSelected(MenuItem item) { // The action bar home/up action should open or close the drawer. switch (item.getItemId()) { case android.R.id.home: mDrawer.openDrawer(GravityCompat.START); return true; } return super.onOptionsItemSelected(item); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu, menu); // Getting search action from action bar and setting up search view MenuItem searchItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) searchItem.getActionView(); // Setup searchView setupSearchView(searchView); Log.e(TAG,"crash"); return true; } public void setupSearchView(SearchView searchView) { SearchManager searchManager = (SearchManager) this.getSystemService(Context.SEARCH_SERVICE); if (searchManager != null) { SearchableInfo info = searchManager.getSearchableInfo(getComponentName()); searchView.setSearchableInfo(info); } searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { searchQuery = newText; // Load search data on respective fragment if (mActiveMenu == MENU_FIRST) // First { BBCSportFragment.doFilter(newText); } if (mActiveMenu == MENU_SECOND) // First { BBCSportFragment.doFilter(newText); } if (mActiveMenu == MENU_THIRD) // First { BBCSportFragment.doFilter(newText); } if (mActiveMenu == MENU_FOURTH) // First { BBCSportFragment.doFilter(newText); } else if (mActiveMenu == MENU_FIFTH) // Second { ESPNFragment.doFilter(newText); } return true; } @Override public boolean onQueryTextSubmit(String query) { //searchView.clearFocus(); return false; } }); // Handling focus change of search view searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { // Focus changed after pressing back key or pressing done in keyboard if (!hasFocus) { searchQuery = ""; } } }); } private void setupDrawerContent(NavigationView navigationView) { navigationView.setNavigationItemSelectedListener( menuItem -&gt; { selectDrawerItem(menuItem); return true; }); } public void selectDrawerItem(MenuItem menuItem) { // Create a new fragment and specify the fragment to show based on nav item clicked Fragment fragment = null; Class fragmentClass = null; switch (menuItem.getItemId()) { case R.id.bbcsports_fragment: fragmentClass = BBCSportFragment.class; break; case R.id.talksports_fragment: fragmentClass = TalkSportsFragment.class; break; case R.id.foxsports_fragment: fragmentClass = FoxSportsFragment.class; break; case R.id.footballitalia_fragment: fragmentClass = FootballItaliaFragment.class; break; case R.id.espn_fragment: fragmentClass = ESPNFragment.class; break; default: } try { fragment = (Fragment) fragmentClass.newInstance(); } catch (Exception e) { e.printStackTrace(); } // Insert the fragment by replacing any existing fragment FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit(); // Highlight the selected item has been done by NavigationView menuItem.setChecked(true); // Set action bar title setTitle(menuItem.getTitle()); // Close the navigation drawer mDrawer.closeDrawers(); } private ActionBarDrawerToggle setupDrawerToggle() { // NOTE: Make sure you pass in a valid toolbar reference. ActionBarDrawToggle() does not require it // and will not render the hamburger icon without it. return new ActionBarDrawerToggle(this, mDrawer, toolbar, R.string.drawer_open, R.string.drawer_close); } @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. drawerToggle.syncState(); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles drawerToggle.onConfigurationChanged(newConfig); } } </code></pre>
0debug
void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset) { c->frames= frame_offset; if (c->ach) c->abytes= av_rescale_q(c->frames, c->sys->time_base, (AVRational){8, c->ast[0]->codec->bit_rate}); c->audio_pkt[0].size = c->audio_pkt[1].size = 0; c->audio_pkt[2].size = c->audio_pkt[3].size = 0; }
1threat
Merge DataFrames with Matching Values From Two Different Columns - Pandas : <p>I have two different DataFrames that I want to merge with <code>date</code> and <code>hours</code> columns. I saw some <a href="https://stackoverflow.com/questions/28097222/pandas-merge-two-dataframes-with-different-columns">threads</a> that are there, but I could not find the solution for my issue. I also read <a href="https://pandas.pydata.org/pandas-docs/stable/merging.html" rel="noreferrer">this</a> document and tried different combinations, however, did not work well.</p> <p>Example of my two different DataFrames,</p> <p><code>DF1</code></p> <pre><code> date hours var1 var2 0 2013-07-10 00:00:00 150.322617 52.225920 1 2013-07-10 01:00:00 155.250917 53.365296 2 2013-07-10 02:00:00 124.918667 51.158249 3 2013-07-10 03:00:00 143.839217 53.138251 ..... 9 2013-09-10 09:00:00 148.135818 86.676341 10 2013-09-10 10:00:00 147.833517 53.658016 11 2013-09-10 12:00:00 149.580233 69.745368 12 2013-09-10 13:00:00 163.715317 14.524894 13 2013-09-10 14:00:00 168.856650 10.762779 </code></pre> <p><code>DF2</code></p> <pre><code> date hours myvar1 myvar2 0 2013-07-10 09:00:00 1.617 98.56 1 2013-07-10 10:00:00 2.917 23.60 2 2013-07-10 12:00:00 19.667 36.15 3 2013-07-10 13:00:00 14.217 45.16 ..... 20 2013-09-10 20:00:00 1.517 53.56 21 2013-09-10 21:00:00 5.233 69.47 22 2013-09-10 22:00:00 13.717 14.25 23 2013-09-10 23:00:00 18.850 10.69 </code></pre> <p>As you can see in both DataFrames, <code>DF2</code> starts with <code>09:00:00</code> and I want to join with <code>DF1</code> <code>09:00:00</code>, which is basically the matchind dates and times. So far, I tried many different combination using previous threads and the documentation mentioned above. An example,</p> <pre><code>merged_df = DF2.merge(DF1, how = 'left', on = ['date', 'hours']) </code></pre> <p>This was introduces <code>NAN</code> values for right <code>right</code> DataFrame. I know, I do not have to use both <code>date</code> and <code>hours</code> columns, however, still getting the same result. I tried <code>R</code> quick like this, which works perfectly fine.</p> <pre><code>merged_df &lt;- left_join(DF1, DF2, by = 'date') </code></pre> <p>Is there anyway in <code>pandas</code> to merge DatFrames just with matching values without getting <code>NaN</code> values? </p>
0debug
static void avc_luma_midv_qrt_16w_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, int32_t height, uint8_t vert_offset) { uint32_t multiple8_cnt; for (multiple8_cnt = 2; multiple8_cnt--;) { avc_luma_midv_qrt_8w_msa(src, src_stride, dst, dst_stride, height, vert_offset); src += 8; dst += 8; } }
1threat
why is golang http server failing with "broken pipe" when response exceeds 8kb? : <p>I have a example web server below where if you call <code>curl localhost:3000 -v</code> then <code>^C</code> (cancel) it immediately (before 1 second), it will report <code>write tcp 127.0.0.1:3000-&gt;127.0.0.1:XXXXX: write: broken pipe</code>.</p> <pre><code>package main import ( "fmt" "net/http" "time" ) func main() { log.Fatal(http.ListenAndServe(":3000", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { time.Sleep(1 * time.Second) // Why 8061 bytes? Because the response header on my computer // is 132 bytes, adding up the entire response to 8193 (1 byte // over 8kb) if _, err := w.Write(make([]byte, 8061)); err != nil { fmt.Println(err) return } }))) } </code></pre> <p>Based on my debugging, I have been able to conclude that this will only happen if the entire response is writing more than 8192 bytes (or 8kb). If my entire response write less than 8192, the <code>broken pipe</code> error is not returned.</p> <p>My question is <strong>where is this 8192 bytes (or 8kb) buffer limit set?</strong> Is this a limit in Golang's HTTP write buffer? Is this related to the response being chunked? Is this only related to the <code>curl</code> client or the browser client? How can I change this limit so I can have a bigger buffer written before the connection is closed (for debugging purposes)?</p> <p>Thanks!</p>
0debug
exercise in python 3 with wrapper : I have issue with following exercise:https://pythonprogramming.net/decorators-intermediate-python-tutorial/ Here is code I wanted to write: def add_wrapping(item): def wrapped_item(): return 'a wrapped up box of {}'.format(str(item())) return wrapped_item @add_wrapping def new_gpu(): return 'a new Tesla P100 GPU!' print(new_gpu()) Here is my code: def add_wrapping(item): def wrapped_item(): return "a wrapped up box of {}".format(str(item())) return wrapped_item() @add_wrapping def new_gpu(): return "new car!" print(new_gpu()) I work in PyCharm, here is error that it gives me: line 17, in <module> print(new_gpu()) TypeError: 'str' object is not callable I am stuckk at this point, can't figure what went wrong, any help is appreciated!
0debug
static void migration_state_notifier(Notifier *notifier, void *data) { MigrationState *s = data; if (migration_is_active(s)) { #ifdef SPICE_INTERFACE_MIGRATION spice_server_migrate_start(spice_server); #endif } else if (migration_has_finished(s)) { #if SPICE_SERVER_VERSION >= 0x000701 #ifndef SPICE_INTERFACE_MIGRATION spice_server_migrate_switch(spice_server); #else spice_server_migrate_end(spice_server, true); } else if (migration_has_failed(s)) { spice_server_migrate_end(spice_server, false); #endif #endif } }
1threat
static void ff_h264_idct_add8_sse2(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){ int i; for(i=16; i<16+8; i+=2){ if(nnzc[ scan8[i+0] ]|nnzc[ scan8[i+1] ]) ff_x264_add8x4_idct_sse2 (dest[(i&4)>>2] + block_offset[i], block + i*16, stride); else if(block[i*16]|block[i*16+16]) ff_h264_idct_dc_add8_mmx2(dest[(i&4)>>2] + block_offset[i], block + i*16, stride); } }
1threat
static void omap_eac_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { struct omap_eac_s *s = (struct omap_eac_s *) opaque; if (size != 2) { return omap_badwidth_write16(opaque, addr, value); } switch (addr) { case 0x098: case 0x09c: case 0x0a0: case 0x0a4: case 0x0a8: case 0x0ac: case 0x0b0: case 0x0b8: case 0x0d0: case 0x0d8: case 0x0e4: case 0x0ec: case 0x100: case 0x108: OMAP_RO_REG(addr); return; case 0x000: s->config[0] = value & 0xff; omap_eac_format_update(s); break; case 0x004: s->config[1] = value & 0xff; omap_eac_format_update(s); break; case 0x008: s->config[2] = value & 0xff; omap_eac_format_update(s); break; case 0x00c: s->config[3] = value & 0xff; omap_eac_format_update(s); break; case 0x010: s->control = value & 0x5f; omap_eac_interrupt_update(s); break; case 0x014: s->address = value & 0xff; break; case 0x018: s->data &= 0xff00; s->data |= value & 0xff; break; case 0x01c: s->data &= 0x00ff; s->data |= value << 8; break; case 0x020: s->vtol = value & 0xf8; break; case 0x024: s->vtsl = value & 0x9f; break; case 0x040: s->modem.control = value & 0x8f; break; case 0x044: s->modem.config = value & 0x7fff; break; case 0x060: s->bt.control = value & 0x8f; break; case 0x064: s->bt.config = value & 0x7fff; break; case 0x080: s->mixer = value & 0x0fff; break; case 0x084: s->gain[0] = value & 0xffff; break; case 0x088: s->gain[1] = value & 0xff7f; break; case 0x08c: s->gain[2] = value & 0xff7f; break; case 0x090: s->gain[3] = value & 0xff7f; break; case 0x094: s->att = value & 0xff; break; case 0x0b4: s->codec.txbuf[s->codec.txlen ++] = value; if (unlikely(s->codec.txlen == EAC_BUF_LEN || s->codec.txlen == s->codec.txavail)) { if (s->codec.txavail) omap_eac_out_empty(s); s->codec.txlen = 0; } break; case 0x0bc: s->codec.config[0] = value & 0x07ff; omap_eac_format_update(s); break; case 0x0c0: s->codec.config[1] = value & 0x780f; omap_eac_format_update(s); break; case 0x0c4: s->codec.config[2] = value & 0x003f; omap_eac_format_update(s); break; case 0x0c8: s->codec.config[3] = value & 0xffff; omap_eac_format_update(s); break; case 0x0cc: case 0x0d4: case 0x0e0: case 0x0e8: case 0x0f0: break; case 0x104: if (value & (1 << 1)) omap_eac_reset(s); s->sysconfig = value & 0x31d; break; default: OMAP_BAD_REG(addr); return; } }
1threat
static void test_wait_event_notifier_noflush(void) { EventNotifierTestData data = { .n = 0 }; EventNotifierTestData dummy = { .n = 0, .active = 1 }; event_notifier_init(&data.e, false); aio_set_event_notifier(ctx, &data.e, event_ready_cb, NULL); g_assert(!aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 0); event_notifier_set(&data.e); g_assert(!aio_poll(ctx, true)); data.n = 0; event_notifier_init(&dummy.e, false); aio_set_event_notifier(ctx, &dummy.e, event_ready_cb, event_active_cb); event_notifier_set(&data.e); g_assert(aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 1); g_assert(aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 1); event_notifier_set(&data.e); g_assert(aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 2); g_assert(aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 2); event_notifier_set(&dummy.e); wait_for_aio(); g_assert_cmpint(data.n, ==, 2); g_assert_cmpint(dummy.n, ==, 1); g_assert_cmpint(dummy.active, ==, 0); aio_set_event_notifier(ctx, &dummy.e, NULL, NULL); event_notifier_cleanup(&dummy.e); aio_set_event_notifier(ctx, &data.e, NULL, NULL); g_assert(!aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 2); event_notifier_cleanup(&data.e); }
1threat
static void backward_filter(RA288Context *ractx) { float temp1[37]; float temp2[11]; do_hybrid_window(36, 40, 35, ractx->sp_block, temp1, ractx->sp_hist, ractx->sp_rec, syn_window); if (!eval_lpc_coeffs(temp1, ractx->sp_lpc, 36)) colmult(ractx->sp_lpc, ractx->sp_lpc, syn_bw_tab, 36); do_hybrid_window(10, 8, 20, ractx->gain_block, temp2, ractx->gain_hist, ractx->gain_rec, gain_window); if (!eval_lpc_coeffs(temp2, ractx->gain_lpc, 10)) colmult(ractx->gain_lpc, ractx->gain_lpc, gain_bw_tab, 10); }
1threat
javascript sum with parseFloat giving wronge value : <pre><code>function myFunction() { var c = parseFloat("10.81") +parseFloat("10.00"); alert(c); } </code></pre> <p>//output is 20.810000000000002 why?</p>
0debug
Even the file system is full, Then to linux system will work fine. How it is happening? : <p>Even the file system is full, Then to linux system will work fine. How it is happening ?</p>
0debug
Jenkinsfile get current tag : <p>Is there a way to get the current tag ( or null if there is none ) for a job in a Jenkinsfile? The background is that I only want to build some artifacts ( android APKs ) when this commit has a tag. I tried:</p> <pre><code>env.TAG_NAME </code></pre> <p>and</p> <pre><code>binding.variables.get("TAG_NAME") </code></pre> <p>both are always null - even though this ( <a href="https://issues.jenkins-ci.org/browse/JENKINS-34520" rel="noreferrer">https://issues.jenkins-ci.org/browse/JENKINS-34520</a> ) indicates otherwise </p>
0debug
Urgent Help: Recycle View : I have used combination of recycle view E,g When we open Google play store we can scroll them horizontally and vertically to find an application, My problem: When i click on parent view it gives me the position of parent however when i click on child view,i get child position (Note: when i click on child view i need parent position please help with this), Again: I want my functionality should work same as Google play store in mobile so when i click on child view it must give me parent position, Help will really appreciated, Thanks
0debug
A weird error occurring when trying to implement useEffect : <p>I am trying to use useEffect inside of my cockpit function that returns a couple of elements, but I get this weird error saying that "Line 6: React Hook "useEffect" is called in function "cockpit" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks".</p> <p>But surely my cockpit component is a function?</p> <pre><code>import React, { useEffect } from 'react' import classes from './Cockpit.css' const cockpit = (props) =&gt; { useEffect(() =&gt; { console.log('I work!') }) const assignedClasses = [] let btnClass = '' if (props.showPersons) { btnClass = classes.Red; } if (props.persons.length &lt;= 2) { assignedClasses.push(classes.red) } if (props.persons.length &lt;= 1) { assignedClasses.push(classes.bold) } return ( &lt;div className={classes.Cockpit}&gt; &lt;h1&gt;{props.title}&lt;/h1&gt; &lt;p className={assignedClasses.join(' ')}&gt;HELLO, HELLO!&lt;/p&gt; &lt;button className={btnClass} onClick={props.clicked}&gt;Click me!&lt;/button&gt; &lt;/div&gt; ) } export default cockpit </code></pre>
0debug
moment().add() only works with literal values : <p>I'm using Moment.js in TypeScript (under Angular 2 if that matters). When I use the add() method with literal values as arguments, it works fine:</p> <pre><code>moment().add(1, 'month'); </code></pre> <p>However, if I try to replace the units with a string, it fails:</p> <pre><code>let units:string = 'month'; moment().add(1, units); </code></pre> <p>with this error:</p> <pre><code>Argument of type '1' is not assignable to parameter of type 'DurationConstructor'. </code></pre> <p>What am I doing wrong here?</p>
0debug
Shell Script to find string of file A in File B and print Yes or No in front of particular string : <p>I have two file A &amp; B. File A contains some strings. I wanted to find strings in file B &amp; if a string is there in file B. Print Yes in front of string in file A otherwise print NO.</p> <p>Propose any solution.</p>
0debug
InputEvent *qemu_input_event_new_btn(InputButton btn, bool down) { InputEvent *evt = g_new0(InputEvent, 1); evt->btn = g_new0(InputBtnEvent, 1); evt->kind = INPUT_EVENT_KIND_BTN; evt->btn->button = btn; evt->btn->down = down; return evt; }
1threat
Vba code to auto serial number in column A after my userform entered data in column B : I have a userform which user can insert data and data will insert in column B to M. I need a code,either in worksheet or in userform to auto fill serial number starting with "RD 00001" which will fill in column A everytime data has enter.Please someone give me an idea
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
ASAuthorizationAppleIDButton not responding to touchUpInside events : <p>I've experienced strange bug in Latest Xcode 11.0 My code:</p> <pre><code>let button = ASAuthorizationAppleIDButton(type: .default, style: .black) button.translatesAutoresizingMaskIntoConstraints = false button.cornerRadius = 10 button.addTarget(self, action: #selector(appleSignInButtonSelected(_:)), for: .touchUpInside) </code></pre> <p>Selector never called, but if I change event to touchDown, everything works. </p>
0debug
How to include XML documentation file in NuGet package built from a project file? : <p>I consider it generally good practice to include the XML documentation file generated by the C# build in NuGet packages alongside the DLLs to provide intellisense documentation for consumers.</p> <p>However, it's not clear to me how this can be done when building a package using VS 2017's project file format.</p> <p>Is this possible?</p> <p>Obviously I could switch over to maintaining a nuspec file but the VS2017 format is very convenient for keeping versions and dependencies all in one place.</p>
0debug
void qmp_cont(Error **errp) { Error *local_err = NULL; BlockBackend *blk; BlockDriverState *bs; BdrvNextIterator it; if (dump_in_progress()) { error_setg(errp, "There is a dump in process, please wait."); return; } if (runstate_needs_reset()) { error_setg(errp, "Resetting the Virtual Machine is required"); return; } else if (runstate_check(RUN_STATE_SUSPENDED)) { return; } for (blk = blk_next(NULL); blk; blk = blk_next(blk)) { blk_iostatus_reset(blk); } for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { bdrv_add_key(bs, NULL, &local_err); if (local_err) { error_propagate(errp, local_err); return; } } bdrv_invalidate_cache_all(&local_err); if (local_err) { error_propagate(errp, local_err); return; } blk_resume_after_migration(&local_err); if (local_err) { error_propagate(errp, local_err); return; } if (runstate_check(RUN_STATE_INMIGRATE)) { autostart = 1; } else { vm_start(); } }
1threat
String.Replace() will not change the source string of the variable : <p>I have the following code inside my c# application:-</p> <pre><code> string[] excludechar = { "|", "\\", "\"", "'", "/", "[", " ]", ":", "&lt;", " &gt;", "+", "=", ",", ";", "?", "*", " @" }; var currentgroupname = curItemSiteName; for (int i = 0; i &lt; excludechar.Length; i++) { if (currentgroupname.Contains(excludechar[i])) currentgroupname.Replace(excludechar[i], ""); } site.RootWeb.SiteGroups.Add(currentgroupname) </code></pre> <p>now in my abive code the <code>currentgroupname</code> variable which i am passing inside the <code>.ADD</code> function will have all the special characters i have replaced inside my for loop. so can anyone adivce if i can modify my code so the .Replace will be actually replacing the original string of the <code>currentgroupname</code> ...</p>
0debug
How to turn off interval loop : <p>How would I stop this loop? The loop is necessary, I'm just not sure how I stop it when I need to. </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>setInterval(function(){ console.log("Loop running"); }, 6000);</code></pre> </div> </div> </p>
0debug
C programming book code : So I am reading the "C programming book" and I understand how this program functions, but, I don't understand one thing. I don't understand how fahr is functioning as a variable. does fahr have two values or one? Cause I thought once you write a value for a variable you can't change it unless you do the command strcpy. Maybe I am wrong, can some one help me clarify? Thanks~ Source: #include <stdio.h> #include <stdlib.h> int main() { float fahr, celsius; int lower,upper, step; lower = 0; upper = 700; step = 2; fahr = lower; printf("Fahrenheit\tCelsius\n"); while (fahr <= upper) { celsius = (5.0/9.0) * (fahr-32.0); printf("%3.0f \t %6.1f\n", fahr, celsius); fahr = fahr + step; } }
0debug
static void omap_mcbsp_writeh(void *opaque, hwaddr addr, uint32_t value) { struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; int offset = addr & OMAP_MPUI_REG_MASK; switch (offset) { case 0x00: case 0x02: OMAP_RO_REG(addr); return; case 0x04: if (((s->xcr[0] >> 5) & 7) < 3) return; case 0x06: if (s->tx_req > 1) { s->tx_req -= 2; if (s->codec && s->codec->cts) { s->codec->out.fifo[s->codec->out.len ++] = (value >> 8) & 0xff; s->codec->out.fifo[s->codec->out.len ++] = (value >> 0) & 0xff; } if (s->tx_req < 2) omap_mcbsp_tx_done(s); } else printf("%s: Tx FIFO overrun\n", __FUNCTION__); return; case 0x08: s->spcr[1] &= 0x0002; s->spcr[1] |= 0x03f9 & value; s->spcr[1] |= 0x0004 & (value << 2); if (~value & 1) s->spcr[1] &= ~6; omap_mcbsp_req_update(s); return; case 0x0a: s->spcr[0] &= 0x0006; s->spcr[0] |= 0xf8f9 & value; if (value & (1 << 15)) printf("%s: Digital Loopback mode enable attempt\n", __FUNCTION__); if (~value & 1) { s->spcr[0] &= ~6; s->rx_req = 0; omap_mcbsp_rx_done(s); } omap_mcbsp_req_update(s); return; case 0x0c: s->rcr[1] = value & 0xffff; return; case 0x0e: s->rcr[0] = value & 0x7fe0; return; case 0x10: s->xcr[1] = value & 0xffff; return; case 0x12: s->xcr[0] = value & 0x7fe0; return; case 0x14: s->srgr[1] = value & 0xffff; omap_mcbsp_req_update(s); return; case 0x16: s->srgr[0] = value & 0xffff; omap_mcbsp_req_update(s); return; case 0x18: s->mcr[1] = value & 0x03e3; if (value & 3) printf("%s: Tx channel selection mode enable attempt\n", __FUNCTION__); return; case 0x1a: s->mcr[0] = value & 0x03e1; if (value & 1) printf("%s: Rx channel selection mode enable attempt\n", __FUNCTION__); return; case 0x1c: s->rcer[0] = value & 0xffff; return; case 0x1e: s->rcer[1] = value & 0xffff; return; case 0x20: s->xcer[0] = value & 0xffff; return; case 0x22: s->xcer[1] = value & 0xffff; return; case 0x24: s->pcr = value & 0x7faf; return; case 0x26: s->rcer[2] = value & 0xffff; return; case 0x28: s->rcer[3] = value & 0xffff; return; case 0x2a: s->xcer[2] = value & 0xffff; return; case 0x2c: s->xcer[3] = value & 0xffff; return; case 0x2e: s->rcer[4] = value & 0xffff; return; case 0x30: s->rcer[5] = value & 0xffff; return; case 0x32: s->xcer[4] = value & 0xffff; return; case 0x34: s->xcer[5] = value & 0xffff; return; case 0x36: s->rcer[6] = value & 0xffff; return; case 0x38: s->rcer[7] = value & 0xffff; return; case 0x3a: s->xcer[6] = value & 0xffff; return; case 0x3c: s->xcer[7] = value & 0xffff; return; } OMAP_BAD_REG(addr); }
1threat
int qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time) { if (!timer_head) return 0; return (timer_head->expire_time <= current_time); }
1threat
Why isn't my String being detected in my Set? : I am having a very specific problem I am currently trying to find a string in a set. But for some reason it can't be found and its not triggering the code properly. while program_running: load_reddit() if not image_found: for images in hot_images: current_image = images.url if not images.stickied: if str(current_image).__contains__(".jpg"): if not str(current_image) in past_images: # Issue is here. for pastimages in past_images: print(pastimages) print(current_image) image_found = True time.sleep(600) [The string I'm searching for and the list][1] [1]: https://i.stack.imgur.com/EZrOo.png as you can see the "current_image" variable is returning exactly what is in "past_images". So why is the code running? This is extremely frustrating as the result directly contradicts itself. With this coding statement the print() shouldn't even run. But it is.
0debug
sharing a single service across multiple angular 5 applications : <p>I'm running multiple small angular 5 applications as widgets inside my backbase application. Now I'm trying to write a global service, which is at window level, and share across all applications.</p> <p>Currently, I'm making the service static and using in each widget and using webpack to create widget specific bundle. Here I was able to achieve http caching with rxjs operators.</p> <p>But I feel this might not be the right way to implement it. Is there any better way to share a singleton service across multiple angular 5 applications in a single project.</p>
0debug
how to increment a const without calling/creating a listerner function : In javascript we have addEventlister, this listens to an even and calls a function called a listener function. Is an alternate approach possible where we increment the value of a const without using a function to do this in case of event being triggered? **Instead of this** const clickVar = 0; x.addEventListener("click", RespondClick); function RespondClick() { clickVar++; } **Sample Alternate implementation** x.addEventListner(click); if (event == true){ clickVar++; }
0debug
How to prevent class instantiation with dependency injection? : <p>I had an interview question that asked roughly the following: with dependency injection, how do you prevent all of the classes from being instantiated? What if you only want a few, but not all? There are good reasons, they said, for example to avoid them all being in memory at the same time...</p> <p>I've tried to research this question but it's hard to even figure out the best search term is. And no answers could I find. </p>
0debug
Using static variables and methods vs. non-static : <p>I am developing an ASP/c# webform where I am using JQuery as well. I came into a scenario where I need to call. C# function from JQuery. In order to that, I found that function in c# has to be a static method (web method). </p> <p>The problem is that I need to access all variables, arrays, etc which I used to populat some data and these are not stated c variables. Also, from the web method I need to re-use some the functions which are not static. I ended up gradually just changing all methods and variables to static. </p> <p>I would like to know if the approach I am taking is correct, and whether there is any pitfall of using static variables/methods and what in simple words makes a difference between static/none-static.</p>
0debug
Bash script to return correct value on Updates statement : <p>I've written a small script to check for Updates. I'm looking for it to output 1 of 3 answers:</p> <ol> <li>If there are no updates, return "Your system is up to date"</li> <li>If there is only one update avaiable, return "There is 1 Update available"</li> <li>If there is more than one update, return "There are $NUMOFUPDATES Updates available"</li> </ol> <p>Here is what I have so far:</p> <pre><code>#!/bin/bash # Check for Updates # Variables NUMOFUPDATES=$(LANG=C apt-get upgrade -s |grep -P '^\d+ upgraded'|cut -d" " -f1) UPDATEY1="There is 1 Update available" UPDATEY2="There are $NUMOFUPDATES Updates available" UPDATEN="Your system is up to date" if [ $NUMOFUPDATES -gt 0 ]; then echo "\${color3}"$UPDATEY2 # Number of updates available elif [ $NUMOFUPDATES -eq 1 ]; then echo "\${color3}"$UPDATEY1 # Number of updates available else echo "\${color2}"$UPDATEN # System is up to date fi exit 0 </code></pre> <p>What it is not doing, is showing if there is only 1 update, it's not returning "There is 1 Update available" it's returning "There are $NUMOFUPDATES Updates available"</p> <p>I feel like I'm close to the solution. Can someone please help me find a solution to this?</p> <p>Thank you.</p>
0debug
Datasets not joining : <p>I'm having trouble joining FBI crime data with school districts. </p> <p>There are some cities/towns that have the same name in the same state, so county is given as a way to separate these values. For the years 2003-2017 there are roughly 1700 values that also have counties. However, when I try to join this dataset with another school district dataset, limited values join (if I inner join, I'll get 200 out of the 1700). On this forum, with another question (<a href="https://stackoverflow.com/questions/57715121/issues-with-character-values/57727781#57727781">Issues with Character Values</a>), other members helped me solve an issue with whitespace, but oddly, this didn't help the joining of the datasets. Below is a dput for Adams county in Pennsylvania for both the crime data and the school districts. </p> <p>A simple left_join should work, but you'll see that I don't get any of the district values. Inner_join yields zero rows, so there's some issue in the data where something isn't being recognized. STATE, COUNTY, and CITY are all character, year is numeric. These are the variables by which the two columns are joined.</p> <p>I tried trimming white space around all categorical variables. No dice.</p> <p>As a rule of thumb, I join by district_ids, place_ids, etc., but the FBI crime data is clunky, and doesn't have any of that, so categorical it is.</p> <p>crime data</p> <pre><code>structure(list(CITY = c("conewago", "conewago", "cumberland", "conewago", "cumberland", "liberty", "conewago", "liberty", "conewago", "cumberland", "liberty", "conewago", "cumberland", "liberty", "conewago", "cumberland", "liberty", "conewago", "cumberland", "conewago", "cumberland", "conewago", "cumberland", "conewago", "cumberland", "conewago", "cumberland", "liberty", "conewago", "cumberland"), COUNTY = c("adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county"), STATE = c("pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania"), year = c(2006, 2007, 2007, 2008, 2008, 2008, 2009, 2009, 2010, 2010, 2010, 2011, 2011, 2011, 2012, 2012, 2012, 2013, 2013, 2014, 2014, 2015, 2015, 2016, 2016, 2017, 2017, 2017, 2003, 2003)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -30L)) </code></pre> <p>district data</p> <pre><code>structure(list(CITY = c("east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "east berlin", "york springs", "abbottstown", "bonneauville", "mcsherrystown", "new oxford", "carroll valley", "fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville", "bendersville", "biglerville", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock", "hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale", "gardners", "heidlersburg", "table rock"), COUNTY = c("adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county", "adams county"), STATE = c("pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania"), year = c(2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017)), class = c("spec_tbl_df", "tbl_df", "tbl", "data.frame"), row.names = c(NA, -450L)) </code></pre>
0debug
remove plus symbol from email regex php : <p>I want to remove + symbol from email please help me to write a regex that doesn't accept + symbol in email.</p> <pre><code>abc@xyz.com - valid email abc123@xyz.com - valid email abc.def@xyz.com - valid email abc+123@xyz.com - Invalid email </code></pre>
0debug
JS lodash [1, 2] => {1: 'test', 2: 'test'} : <p>There is an array:</p> <pre><code>var array = [{test: 1}, {test: 2}, {test: 3}] </code></pre> <p>I need to get:</p> <pre><code>{1: 'random_value', 2: 'random_value', 3: 'random_value'} </code></pre> <p>I'm doing:</p> <pre><code>var values_test = _.map(array, 'test'); </code></pre> <p>What to do next?</p>
0debug
PHP -- Unsyntax error, unexpected 'echo' (T_ECHO) on line 58 : <pre><code> else if (isset($id) &amp;&amp; isset($street_address) &amp;&amp; isset($price) ){ echo '&lt;p&gt;Are you sure you want to delete the following product?&lt;/p&gt;'; echo '&lt;p&gt;&lt;strong&gt;Street Address: &lt;/strong&gt;' . $street_address '&lt;br/&gt;&lt;strong&gt;Price: &lt;/strong&gt;' . $price .; // '&lt;br /&gt;&lt;strong&gt;Price: &lt;/strong&gt;' . $pPrice . '&lt;/p&gt;'; echo '&lt;form method="post" action="removehome.php"&gt;'; &lt;-- (line 58) </code></pre> <p>I've tryed adding an ending semicolon to the line above but end up getting an "unexpected ";" error. How do I fix this? </p>
0debug
void copy_picture_field(TInterlaceContext *tinterlace, uint8_t *dst[4], int dst_linesize[4], const uint8_t *src[4], int src_linesize[4], enum AVPixelFormat format, int w, int src_h, int src_field, int interleave, int dst_field, int flags) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format); int hsub = desc->log2_chroma_w; int plane, vsub = desc->log2_chroma_h; int k = src_field == FIELD_UPPER_AND_LOWER ? 1 : 2; int h; for (plane = 0; plane < desc->nb_components; plane++) { int lines = plane == 1 || plane == 2 ? AV_CEIL_RSHIFT(src_h, vsub) : src_h; int cols = plane == 1 || plane == 2 ? AV_CEIL_RSHIFT( w, hsub) : w; uint8_t *dstp = dst[plane]; const uint8_t *srcp = src[plane]; int srcp_linesize = src_linesize[plane] * k; int dstp_linesize = dst_linesize[plane] * (interleave ? 2 : 1); lines = (lines + (src_field == FIELD_UPPER)) / k; if (src_field == FIELD_LOWER) srcp += src_linesize[plane]; if (interleave && dst_field == FIELD_LOWER) dstp += dst_linesize[plane]; if (flags & TINTERLACE_FLAG_VLPF || flags & TINTERLACE_FLAG_CVLPF) { int x = 0; if (flags & TINTERLACE_FLAG_CVLPF) x = 1; for (h = lines; h > 0; h--) { ptrdiff_t pref = src_linesize[plane]; ptrdiff_t mref = -pref; if (h >= (lines - x)) mref = 0; else if (h <= (1 + x)) pref = 0; tinterlace->lowpass_line(dstp, cols, srcp, mref, pref); dstp += dstp_linesize; srcp += srcp_linesize; } } else { av_image_copy_plane(dstp, dstp_linesize, srcp, srcp_linesize, cols, lines); } } }
1threat
Position:absolute, position:relative doesnt work : I want announce on the top and header in the bottom but this is the output in every browser what am i doing wrong here [enter image description here][1] [1]: https://i.stack.imgur.com/ZsoSf.png this is my html code: https://hastebin.com/bocacehoka.js this is my css code: https://hastebin.com/zapegulomu.css
0debug
Scrabble Description Assume that you are trying to complete a crossword puzzle : In a crossword puzzle, some letters are given and you have to figure out which complete word can you make out of it. For example, given letters "cwd"in the same order, you can make the word "crossword" or "cr I have written a code : x = re.search(letters, guess) if (x): print("yes") else: print("no") but when not getting correct output
0debug
Add two JSON s in Javascript : I have two JSON s, I want to add two JSON s in Javascript, JSON A :- { "data": [{ "id": 1, "subgroup": "1", "power": "2", "grp": "1" }, { "id": 1, "subgroup": "1", "power": "1", "grp": "1" }, { "id": 2, "subgroup": "1", "power": "1", "grp": "2" }, { "id": 3, "subgroup": "2", "power": "1", "grp": "2" }, { "id": 4, "subgroup": "1", "power": "1", "grp": "3" }, { "id": 5, "subgroup": "2", "power": "1", "grp": "2" }, { "id": 6, "subgroup": "2", "power": "1", "grp": "1" }, { "id": 7, "subgroup": "1", "power": "1", "grp": "4" }, { "id": 1, "subgroup": "3", "power": "2", "grp": "4" } } JSON B :- { "data": [{ "id": 1, "subgroup": "3", "power": "2", "grp": "4" }, { "id": 1, "subgroup": "4", "power": "1", "grp": "3" } } Key names are similar in JSON A and JSON B . We can see, `subgroup 3` and `subgroup 4` are only present in `grp 4` and `grp 3` respectively (look into JSON B). I want to add each `subgroup` from JSON B into each `grp` in JSON A (except the `grp` s where those `subgroup` s are already present. Like in JSON A there is an entry with `subgroup 3` and `grp 4`, we will skip that.). Value of `Id`, `power` will be similar respectively. So, we want to add `subgroup 3` in the `grp 1, 2, 3` and add `subgroup 4` in the `group 1, 2, 4` . For `subgroup 3`, `power` and `id` value will be `2, 1` respectively and for `subgroup 4`, `power` and `id` value will be `1, 1` respectively. Final JSON A output should be, { "data": [{ "id": 1, "subgroup": "1", "power": "2", "grp": "1" }, { "id": 1, "subgroup": "1", "power": "1", "grp": "1" }, { "id": 2, "subgroup": "1", "power": "1", "grp": "2" }, { "id": 3, "subgroup": "2", "power": "1", "grp": "2" }, { "id": 4, "subgroup": "1", "power": "1", "grp": "3" }, { "id": 5, "subgroup": "2", "power": "1", "grp": "2" }, { "id": 6, "subgroup": "2", "power": "1", "grp": "1" }, { "id": 7, "subgroup": "1", "power": "1", "grp": "4" }, { "id": 1, "subgroup": "3", "power": "2", "grp": "4" }, { "id": 1, "subgroup": "3", "power": "2", "grp": "1" }, { "id": 1, "subgroup": "3", "power": "2", "grp": "2" }, { "id": 1, "subgroup": "3", "power": "2", "grp": "3" }, { "id": 1, "subgroup": "4", "power": "1", "grp": "1" }, { "id": 1, "subgroup": "4", "power": "1", "grp": "2" }, { "id": 1, "subgroup": "4", "power": "1", "grp": "4" } }
0debug
Randomly generating obstacles in Unity : <p>Currently I'm creating game in which whole level is generated when player moves. I have working script for that, but now I want to generate obstacles in front of the player. My idea is to add empty object to my terrain segment(these are dynamically generated) and then instantiate random obstacles at their position at runtime. The only thing i don't know is how this script should pick random empty object(empty object is child of the segment) to instantiate this obstacle? The script which generates level is attached to player.</p>
0debug
How to convert number to scientific notation in Codeigniter? : I am working on web-based application build with Codeigniter. My question is how to convert number to scientific notation? For some reason, I need to display number from user input from **250** to **2.5 x 10<sup>2</sup>** and **25** to **2.5 x 10<sup>1</sup>**, etc.
0debug
Lazarus. I get FileSize error : I get error: unit1.pas(91,31) Error: Incompatible type for arg no. 1: Got "File Of Byte", expected "AnsiString" var f : file of byte; ... AssignFile(f, FileName); Reset(f); try TotalBytes := FileSize(f); // line 93 finally CloseFile(f); end; Someone can me help ?
0debug
Hubot/CoffeeScript combine spawned process outputs : While the following code works great to call a python script and get the output: s = spawn 'python', ['-u', 'foo.py'] s.stdout.on 'data', (data) -> msg.send data.toString() s.stderr.on 'data', (data) -> msg.send data.toString() foo.py returns many different responses (it returns updates as it runs). For instance: def function1(): return "Function 1 complete" def function2(): return "Function 2 complete" function1() function2() Hubot does not display those results in a consistent order. I know this can happen if `msg.send`is called multiple times. While I know I could re-write foo.py to behave differently, other processes depend on foo.py and I can't alter its behavior. I was wondering what the process might be to collect the responses as they come and send a single `msg.send` in hopes that a single call to msg.send will preserve the order of the process outputs.
0debug
Understanding MetaData() from SQLAlchemy in Python : <p>I am trying to understand what the MetaData() created object is in essence. It is used when reflecting and creating databases in Python (using SQLAlchemy package). </p> <p>Consider the following working code:</p> <p>/ with preloaded Engine(sqlite:///chapter5.sqlite) and metadata = MetaData(): when I call metadata in the console, it returns 'MetaData(bind=None)' /</p> <pre><code># Import Table, Column, String, and Integer from sqlalchemy import Table, Column, String, Integer # Build a census table: census census = Table('census', metadata, Column('state', String(30)), Column('sex', String(1)), Column('age', Integer()), Column('pop2000', Integer()), Column('pop2008',Integer())) # Create the table in the database metadata.create_all(engine) </code></pre> <p>Of course by typing type(metadata) I get exactly what type of object metadata is: sqlalchemy.sql.schema.MetaData. In <a href="http://docs.sqlalchemy.org/en/latest/core/metadata.html" rel="noreferrer">SQLAlchemy documentation</a> it is written</p> <blockquote> <p>MetaData is a container object that keeps together many different features of a database (or multiple databases) being described.</p> </blockquote> <p>However, I am confused, because in the code we only create a table that "points" to metadata. After that, when we call the create_all method on metadata (empty by far), pointing to the database (which is pointed by engine). </p> <p>Probably my question is silly, but:</p> <p>How does python exactly connect these instances? Probably the declaration of the census table links metadata to the column names in a two-sided way. </p> <hr> <p>Note: The code is from an exercise from <a href="http://datacamp.com" rel="noreferrer">datacamp</a> course.</p>
0debug
BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, BlockDriverState *bs, QDict *options, int flags) { assert(bs != NULL); BlockReopenQueueEntry *bs_entry; BdrvChild *child; QDict *old_options; if (bs_queue == NULL) { bs_queue = g_new0(BlockReopenQueue, 1); QSIMPLEQ_INIT(bs_queue); } if (!options) { options = qdict_new(); } old_options = qdict_clone_shallow(bs->options); qdict_join(options, old_options, false); QDECREF(old_options); flags &= ~BDRV_O_PROTOCOL; QLIST_FOREACH(child, &bs->children, next) { int child_flags; if (child->bs->inherits_from != bs) { continue; } child_flags = child->role->inherit_flags(flags); bdrv_reopen_queue(bs_queue, child->bs, NULL, child_flags); } bs_entry = g_new0(BlockReopenQueueEntry, 1); QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry); bs_entry->state.bs = bs; bs_entry->state.options = options; bs_entry->state.flags = flags; return bs_queue; }
1threat
how to overwrite two dataframe in get the result like below : i have two dataframes DF1 and DF2 through pyspark, i want output like below. DF1 Id|field_A|field_B|field_C|field_D 1 |cat |12 |black |1 2 |dog |128 |white |2 DF2 Id|field_A|field_B|field_C 1 |cat |13 |blue OutPut required:- DF3 Id|field_A|field_B|field_C|field_D 1 |cat |13 |blue |1 2 |dog |128 |white |2 i have tried through the join concept, but its not working through the below joins. 'inner', 'outer', 'full', 'fullouter', 'full_outer', 'leftouter', 'left', 'left_outer', 'rightouter', 'right', 'right_outer', 'leftsemi', 'left_semi', 'leftanti', 'left_anti', 'cross'. DF3 = DF2.join(DF1, DF1.ID == DF2.ID,"leftouter")
0debug
copy array of pointers and print the copy : <p>I'm trying to copy a pointers of arrays and print the values from the copied array, but I got a Segmentation fault.</p> <pre><code>void kosomo(char * test[10]) { int j=0; char * test2[10]; while (test[j] != NULL) { test2[j]=&amp;test[j]; // test[j] is the string, so with &amp; it's the address j++; } printf("%d ",*test2[0]); // trying to do * in order to print the string } int main() { char * test[] = {"abc","def",NULL}; kosomo(test); } </code></pre>
0debug
--recurse ERROR: Insufficient Permission: Request had insufficient authentication scopes : <p>I'm trying to copy a directory from my vm to my local machine's Desktop with the following command:</p> <pre><code>gcloud compute scp --recurse instance-1:~/directory ~/Desktop/ </code></pre> <p>I tried reauthenticating with "gcloud auth login" however it still says </p> <pre><code>ERROR: (gcloud.compute.scp) Could not fetch resource: - Insufficient Permission: Request had insufficient authentication scopes. </code></pre>
0debug
static void test_machine(const void *data) { const testdef_t *test = data; char tmpname[] = "/tmp/qtest-boot-serial-XXXXXX"; int fd; fd = mkstemp(tmpname); g_assert(fd != -1); global_qtest = qtest_startf("-M %s,accel=tcg:kvm " "-chardev file,id=serial0,path=%s " "-no-shutdown -serial chardev:serial0 %s", test->machine, tmpname, test->extra); unlink(tmpname); check_guest_output(test, fd); qtest_quit(global_qtest); close(fd); }
1threat
Python set __contains__ is not finding objects contained in the set : <p>(python 3.7.1 on linux)</p> <p>I am observing some strange behavior storing user-defined objects in a set. The objects are highly complex so a minimal example is not in the cards-- but I am hoping the observed behavior will elicit an explanation from someone wiser than myself. Here it is:</p> <pre><code>&gt;&gt;&gt; from mycode import MyObject &gt;&gt;&gt; a = MyObject(*args1) &gt;&gt;&gt; b = MyObject(*args2) &gt;&gt;&gt; a == b False &gt;&gt;&gt; z = {a, b} &gt;&gt;&gt; len(z) 2 &gt;&gt;&gt; a in z False </code></pre> <p>My understanding was that an object is "in" a set if (1) its hash matches the hash of an object in the set and (2) it equals that object. But those expectations are violated here:</p> <pre><code>&gt;&gt;&gt; [hash(t) for t in z] [1013724486348463466, -1852733432963649245] &gt;&gt;&gt; hash(a) 1013724486348463466 &gt;&gt;&gt; [(hash(t) == hash(a), t == a) for t in z] [(True, True), (False, False)] &gt;&gt;&gt; [t is a for t in z] [True, False] </code></pre> <p>And the strangest (syntactically) of all:</p> <pre><code>&gt;&gt;&gt; [t in z for t in z] [False, False] </code></pre> <p>What might be up with <code>MyObject</code> to cause it to behave this way? To recap: it has a sane <code>__hash__</code> and <code>__eq__</code> function, <code>set</code> is just a stock python set. </p> <p>Here they are specifically:</p> <pre><code>class MyObject(object): ... def __hash__(self): return hash(self.link) def __eq__(self, other): """ two entities are equal if their types, origins, and external references are the same. internal refs do not need to be equal; reference entities do not need to be equal :return: """ if other is None: return False try: is_eq = (self.external_ref == other.external_ref and self.origin == other.origin and self.entity_type == other.entity_type) except AttributeError: is_eq = False return is_eq </code></pre> <p>All of those properties are defined on these objects. As demonstrated above, <code>a == t</code> evaluates to <code>True</code> for one of the objects in the set. Thanks for any suggestions.</p>
0debug
Why doesn't For loop iterate without compound assignment operators : Sorry for noob question, I am trying to replace every character of source string with "🥃". If I remove += from my code For loop iterates only once, can't seem to follow logic behind this? However, if I use '+=' For loop iterates. Shouldn't iterations have equalled number of characters in String? I mean my understanding always was "For every “item” in “items”, execute this code." ``` let stringExample = "Hello, Playground" var emptyString = "" for _ in stringExample { emptyString = "🥃" } print(emptyString) ``` 🥃
0debug
Could not find any available provisioning profiles for iOS : <p>We are developing a iOS shopping cart application in c# and visual studio 2017 for xamarin. I have an iPad Air iOS 10.3, when I try to publish to real device, I am getting the following error message: "Could not find any available provisioning profiles for iOS", I have tried to restart my Mac - without result. Give me any suggestion to resolve this issue?</p>
0debug
static int pcm_encode_frame(AVCodecContext *avctx, unsigned char *frame, int buf_size, void *data) { int n, sample_size, v; const short *samples; unsigned char *dst; const uint8_t *srcu8; const int16_t *samples_int16_t; const int32_t *samples_int32_t; const int64_t *samples_int64_t; const uint16_t *samples_uint16_t; const uint32_t *samples_uint32_t; sample_size = av_get_bits_per_sample(avctx->codec->id)/8; n = buf_size / sample_size; samples = data; dst = frame; if (avctx->sample_fmt!=avctx->codec->sample_fmts[0]) { av_log(avctx, AV_LOG_ERROR, "invalid sample_fmt\n"); return -1; } switch(avctx->codec->id) { case CODEC_ID_PCM_U32LE: ENCODE(uint32_t, le32, samples, dst, n, 0, 0x80000000) break; case CODEC_ID_PCM_U32BE: ENCODE(uint32_t, be32, samples, dst, n, 0, 0x80000000) break; case CODEC_ID_PCM_S24LE: ENCODE(int32_t, le24, samples, dst, n, 8, 0) break; case CODEC_ID_PCM_S24BE: ENCODE(int32_t, be24, samples, dst, n, 8, 0) break; case CODEC_ID_PCM_U24LE: ENCODE(uint32_t, le24, samples, dst, n, 8, 0x800000) break; case CODEC_ID_PCM_U24BE: ENCODE(uint32_t, be24, samples, dst, n, 8, 0x800000) break; case CODEC_ID_PCM_S24DAUD: for(;n>0;n--) { uint32_t tmp = av_reverse[(*samples >> 8) & 0xff] + (av_reverse[*samples & 0xff] << 8); tmp <<= 4; bytestream_put_be24(&dst, tmp); samples++; } break; case CODEC_ID_PCM_U16LE: ENCODE(uint16_t, le16, samples, dst, n, 0, 0x8000) break; case CODEC_ID_PCM_U16BE: ENCODE(uint16_t, be16, samples, dst, n, 0, 0x8000) break; case CODEC_ID_PCM_S8: srcu8= data; for(;n>0;n--) { v = *srcu8++; *dst++ = v - 128; } break; #if HAVE_BIGENDIAN case CODEC_ID_PCM_F64LE: ENCODE(int64_t, le64, samples, dst, n, 0, 0) break; case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_F32LE: ENCODE(int32_t, le32, samples, dst, n, 0, 0) break; case CODEC_ID_PCM_S16LE: ENCODE(int16_t, le16, samples, dst, n, 0, 0) break; case CODEC_ID_PCM_F64BE: case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_S16BE: #else case CODEC_ID_PCM_F64BE: ENCODE(int64_t, be64, samples, dst, n, 0, 0) break; case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: ENCODE(int32_t, be32, samples, dst, n, 0, 0) break; case CODEC_ID_PCM_S16BE: ENCODE(int16_t, be16, samples, dst, n, 0, 0) break; case CODEC_ID_PCM_F64LE: case CODEC_ID_PCM_F32LE: case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S16LE: #endif case CODEC_ID_PCM_U8: memcpy(dst, samples, n*sample_size); dst += n*sample_size; break; case CODEC_ID_PCM_ZORK: for(;n>0;n--) { v= *samples++ >> 8; if(v<0) v = -v; else v+= 128; *dst++ = v; } break; case CODEC_ID_PCM_ALAW: for(;n>0;n--) { v = *samples++; *dst++ = linear_to_alaw[(v + 32768) >> 2]; } break; case CODEC_ID_PCM_MULAW: for(;n>0;n--) { v = *samples++; *dst++ = linear_to_ulaw[(v + 32768) >> 2]; } break; default: return -1; } return dst - frame; }
1threat
php, create 1 array from another 2 : <p>I have two arrays like this:</p> <pre><code>$a1 = ['A','B']; $a2 = ['1','2']; </code></pre> <p>I need to have this new one (with the _ between the values):</p> <pre><code>$a3 = ['A_1','B_2']; </code></pre> <p>I know isn't difficult, but I'm pretty stucked, using <code>array_combine</code> and stuff.</p> <p>Any help? thanks</p>
0debug
Get array of string literal type values : <p>I need to get a full list of all possible values for a string literal.</p> <pre><code>type YesNo = "Yes" | "No"; let arrayOfYesNo : Array&lt;string&gt; = someMagicFunction(YesNo); //["Yes", "No"] </code></pre> <p>Is there any way of achiving this?</p>
0debug
static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t stnr, bool output, uint8_t *buf, uint32_t len) { HDACodecBus *bus = DO_UPCAST(HDACodecBus, qbus, dev->qdev.parent_bus); IntelHDAState *d = container_of(bus, IntelHDAState, codecs); target_phys_addr_t addr; uint32_t s, copy, left; IntelHDAStream *st; bool irq = false; st = output ? d->st + 4 : d->st; for (s = 0; s < 4; s++) { if (stnr == ((st[s].ctl >> 20) & 0x0f)) { st = st + s; break; } } if (s == 4) { return false; } if (st->bpl == NULL) { return false; } if (st->ctl & (1 << 26)) { return false; } left = len; while (left > 0) { copy = left; if (copy > st->bsize - st->lpib) copy = st->bsize - st->lpib; if (copy > st->bpl[st->be].len - st->bp) copy = st->bpl[st->be].len - st->bp; dprint(d, 3, "dma: entry %d, pos %d/%d, copy %d\n", st->be, st->bp, st->bpl[st->be].len, copy); pci_dma_rw(&d->pci, st->bpl[st->be].addr + st->bp, buf, copy, !output); st->lpib += copy; st->bp += copy; buf += copy; left -= copy; if (st->bpl[st->be].len == st->bp) { if (st->bpl[st->be].flags & 0x01) { irq = true; } st->bp = 0; st->be++; if (st->be == st->bentries) { st->be = 0; st->lpib = 0; } } } if (d->dp_lbase & 0x01) { addr = intel_hda_addr(d->dp_lbase & ~0x01, d->dp_ubase); stl_le_pci_dma(&d->pci, addr + 8*s, st->lpib); } dprint(d, 3, "dma: --\n"); if (irq) { st->ctl |= (1 << 26); intel_hda_update_irq(d); } return true; }
1threat