problem
stringlengths
26
131k
labels
class label
2 classes
static void setup_frame(int sig, struct emulated_sigaction * ka, target_sigset_t *set, CPUState *regs) { struct sigframe *frame; abi_ulong frame_addr; int i; frame_addr = get_sigframe(ka, regs, sizeof(*frame)); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) goto give_sigsegv; install_sigtramp(frame->sf_code, TARGET_NR_sigreturn); if(setup_sigcontext(regs, &frame->sf_sc)) goto give_sigsegv; for(i = 0; i < TARGET_NSIG_WORDS; i++) { if(__put_user(set->sig[i], &frame->sf_mask.sig[i])) goto give_sigsegv; } regs->gpr[ 4][regs->current_tc] = sig; regs->gpr[ 5][regs->current_tc] = 0; regs->gpr[ 6][regs->current_tc] = h2g(&frame->sf_sc); regs->gpr[29][regs->current_tc] = h2g(frame); regs->gpr[31][regs->current_tc] = h2g(frame->sf_code); regs->PC[regs->current_tc] = regs->gpr[25][regs->current_tc] = ka->sa._sa_handler; unlock_user_struct(frame, frame_addr, 1); return; give_sigsegv: unlock_user_struct(frame, frame_addr, 1); force_sig(TARGET_SIGSEGV); return; }
1threat
Android Studio - Assigning multiple value to ManifestPlaceholders in Gradle : <p>I have two environment of my project one <strong>Prod</strong> another one is <strong>Staging</strong>. So whenever I have to build any of the environment, I have to change multiple keys like map key, label name and other things in manifest. So I have searched and find out some of the solutions and <strong>manifestPlaceholders</strong> is one of them. </p> <p>Now what I want to do is to assign multiple value in <strong>manifestPlaceholders</strong>. So can I put multiple values in it and yes then how to put multiple values in it. Here is the code for the <strong>manifestPlaceholders</strong></p> <pre><code>buildTypes { debug { manifestPlaceholders = [ google_map_key:"your_dev_key"] } release { manifestPlaceholders = [ google_map_key:"prod_key"] } } </code></pre>
0debug
static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset) { MXFDescriptor *descriptor = arg; descriptor->pix_fmt = AV_PIX_FMT_NONE; switch(tag) { case 0x3F01: descriptor->sub_descriptors_count = avio_rb32(pb); if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID)) return AVERROR_INVALIDDATA; descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID)); if (!descriptor->sub_descriptors_refs) return AVERROR(ENOMEM); avio_skip(pb, 4); avio_read(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID)); break; case 0x3004: avio_read(pb, descriptor->essence_container_ul, 16); break; case 0x3006: descriptor->linked_track_id = avio_rb32(pb); break; case 0x3201: avio_read(pb, descriptor->essence_codec_ul, 16); break; case 0x3203: descriptor->width = avio_rb32(pb); break; case 0x3202: descriptor->height = avio_rb32(pb); break; case 0x320C: descriptor->frame_layout = avio_r8(pb); break; case 0x320E: descriptor->aspect_ratio.num = avio_rb32(pb); descriptor->aspect_ratio.den = avio_rb32(pb); break; case 0x3301: descriptor->component_depth = avio_rb32(pb); break; case 0x3302: descriptor->horiz_subsampling = avio_rb32(pb); break; case 0x3308: descriptor->vert_subsampling = avio_rb32(pb); break; case 0x3D03: descriptor->sample_rate.num = avio_rb32(pb); descriptor->sample_rate.den = avio_rb32(pb); break; case 0x3D06: avio_read(pb, descriptor->essence_codec_ul, 16); break; case 0x3D07: descriptor->channels = avio_rb32(pb); break; case 0x3D01: descriptor->bits_per_sample = avio_rb32(pb); break; case 0x3401: mxf_read_pixel_layout(pb, descriptor); break; default: if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) { descriptor->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); if (!descriptor->extradata) return AVERROR(ENOMEM); descriptor->extradata_size = size; avio_read(pb, descriptor->extradata, size); } break; } return 0; }
1threat
Do I need bcsymbolmap files created by Carthage : <p>I am using Carthage dependency manager in my iOS project. I have the <code>Carthage/build</code> folder in my repository to always have ready to go built frameworks when checking out the repo.</p> <p>I am wondering what the <code>bcsymbolmap</code> files in the build folder are for. Quite a few of them are created with every <code>carthage update</code>. </p> <p>Do I need to keep these files? Should I have them in my repository? </p>
0debug
Flexbox -how to get first child 50% widht and 100% height while stacking remaining children? : <p>I can't do much with the markup, if I could I'd just add 2 containers side by side. Basically it is a UL that looks like this:</p> <pre><code>&lt;ul&gt; &lt;li&gt;one&lt;/li&gt; &lt;li&gt;two&lt;/li&gt; &lt;li&gt;three&lt;/li&gt; &lt;li&gt;four&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I need the first child to fill the height of the container at 50% width. The remaining children should have 50% width but auto height and stack on the right side of the container.</p> <p><a href="https://i.stack.imgur.com/KVJiQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KVJiQ.jpg" alt="enter image description here"></a></p>
0debug
static void define_debug_regs(ARMCPU *cpu) { int i; define_arm_cp_regs(cpu, debug_cp_reginfo); if (arm_feature(&cpu->env, ARM_FEATURE_LPAE)) { define_arm_cp_regs(cpu, debug_lpae_cp_reginfo); } for (i = 0; i < 16; i++) { ARMCPRegInfo dbgregs[] = { { .name = "DBGBVR", .state = ARM_CP_STATE_BOTH, .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 4, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.dbgbvr[i]) }, { .name = "DBGBCR", .state = ARM_CP_STATE_BOTH, .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 5, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]) }, { .name = "DBGWVR", .state = ARM_CP_STATE_BOTH, .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 6, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.dbgwvr[i]) }, { .name = "DBGWCR", .state = ARM_CP_STATE_BOTH, .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 7, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]) }, REGINFO_SENTINEL }; define_arm_cp_regs(cpu, dbgregs); } }
1threat
How can dynamically generate some values in php? : <p>I want to store these values in an array</p> <pre><code>$hours = array("06:00", "06:15", "06:30"....etc ); </code></pre> <p>The last value is <code>23:45</code> </p> <p>I wish it to be stored in ascending order.</p> <p>My question is ... how I can automatically generate these values and add them in array?</p> <p>If you manually add them .... they are many and it is not good.</p> <p>You tell me please a method by which I could dynamically generate these values?</p> <p>Thanks in advance!</p>
0debug
golang string.ToLower not working : <p>I have a simple input string which I need to read and count the repeated words.</p> <p>But, while doing that I need to convert the string to lower case, but some how the func ToLower is not working.</p> <p>I have attached the golang link, Please, help me understand what can be the issue. </p> <p><a href="https://play.golang.org/p/OnQW-pgQxqq" rel="nofollow noreferrer">https://play.golang.org/p/OnQW-pgQxqq</a></p> <p>Also pasting the code.</p> <pre><code>func main() { input := ` one two Two three Three Three; four four four, four five? five. five, five Five` countwords(input) } type kv struct { key string val int } type kvlist []kv // need to define custome interface to make this work: func (kv kvlist) Less(i, j int) bool { return kv[i].val &lt; kv[j].val } func (kv kvlist) Swap(i, j int) { kv[i], kv[j] = kv[j], kv[i] } func (kv kvlist) Len() int { return len(kv) } //sort the words by value func sortmap(wordmap map[string]int) []kv { list := make(kvlist, len(wordmap)) i := 0 for k, v := range wordmap { list[i] = kv{k, v} i++ } // we need to make few more modification to change this but, // for now lets assume it works. sort.Sort(sort.Reverse(list)) return list } func countwords(str string) []kv { count := make(map[string]int) reg, err := regexp.Compile("[^a-zA-Z0-9 ]+") if err != nil { log.Fatal(err) } lines := strings.Split(str, "\n") for _, line := range lines { line := reg.ReplaceAllString(line, "") strings.ToLower(string(line)) repeatwords := strings.Fields(line) // count the repeated words fmt.Println(repeatwords) for _, word := range repeatwords { if _, ok := count[word]; ok { count[word]++ } else { count[word] = 1 } } } //once counted now sort the map based on values(repeated words). ret := sortmap(count) fmt.Println(count) return ret } </code></pre>
0debug
why can't I import geopandas? : <p>My only line of code is </p> <pre><code>import geopandas </code></pre> <p>and it gives me the error </p> <pre><code>OSError: Could not find libspatialindex_c library file </code></pre> <p>has anyone encountered this before? my script was working just fine until this error came up. </p> <p>**Note that rtree module not found was an issue fisrt, and upon installation I received the above error instead.</p>
0debug
Live video streaming with HTML 5? : <p>I want to make <strong>live video streaming</strong>. For example there is discussion. And somebody is recording it. I want the video record to appear on my web page. I want to do this with <strong>HTML 5</strong>. I don't know if it's possible, but has anyone tried ? <strong><em>Thank you in advance!</em></strong></p>
0debug
Java script and php code is not working : I have simple code wirh html, javascript and php. I am trying to pass variable from html to php through ajax. A text box appears on screen with button . user inputs in the text field and clicks the button. field text should appear beloe the field then. But in my case nothing happens on clicking the button. I am posting my code below . There are three files i have made.
0debug
Dinamic memory leak c++ : bool CPythonNonPlayer::LoadNonPlayerData(const char *c_szFileName) { DWORD dwElements; TMobTable *pTable = (TMobTable *) zObj.GetBuffer(); for(DWORD i = 0; i < dwElements; ++i, ++pTable) { TMobTable *pNonPlayerData = new TMobTable; memcpy(pNonPlayerData, pTable, sizeof(TMobTable)); m_NonPlayerDataMap.insert(TNonPlayerDataMap::value_type(pNonPlayerData->dwVnum, pNonPlayerData)); } return true; } My questtion what i do wrong? This leak me memory so much. After each call of this function application usage increase with 10MB. Sorry if is not enought information just reply and i add more.
0debug
static void unimp_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = unimp_realize; dc->props = unimp_properties; }
1threat
How to completely delete a commit from GitHub? : <p>On GitHub, I forked a repositary and cloned on my PC. Then, for testing purpose, I edited a file, made a commit and pushed it to GitHub. But now I would like to completely delete this commit.</p> <p>I did the following:</p> <pre><code>git reset --hard &lt;sha1_of_previous_commit&gt; git push --force </code></pre> <p>It looked OK, but my commit was still accessible on GitHub by URL with SHA1 of my commit. So I deleted the repositary on GitHub, then the URL was saying Not Found. </p> <p>But if I fork the same repositary again, my commit is again accessible by this URL. Please help me, how the hell I can get rid of this commit?</p>
0debug
static int read_block_types(AVCodecContext *avctx, GetBitContext *gb, Bundle *b) { int t, v; int last = 0; const uint8_t *dec_end; CHECK_READ_VAL(gb, b, t); dec_end = b->cur_dec + t; if (dec_end > b->data_end) { av_log(avctx, AV_LOG_ERROR, "Too many block type values\n"); return -1; } if (get_bits1(gb)) { v = get_bits(gb, 4); memset(b->cur_dec, v, t); b->cur_dec += t; } else { do { v = GET_HUFF(gb, b->tree); if (v < 12) { last = v; *b->cur_dec++ = v; } else { int run = bink_rlelens[v - 12]; memset(b->cur_dec, last, run); b->cur_dec += run; } } while (b->cur_dec < dec_end); } return 0; }
1threat
int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { IVI45DecContext *ctx = avctx->priv_data; const uint8_t *buf = avpkt->data; AVFrame *frame = data; int buf_size = avpkt->size; int result, p, b; init_get_bits(&ctx->gb, buf, buf_size * 8); ctx->frame_data = buf; ctx->frame_size = buf_size; result = ctx->decode_pic_hdr(ctx, avctx); if (result) { av_log(avctx, AV_LOG_ERROR, "Error while decoding picture header: %d\n", result); return result; } if (ctx->gop_invalid) return AVERROR_INVALIDDATA; if (avctx->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == IVI4_FRAMETYPE_NULL_LAST) { if (ctx->got_p_frame) { av_frame_move_ref(data, ctx->p_frame); *got_frame = 1; ctx->got_p_frame = 0; } else { *got_frame = 0; } return buf_size; } if (ctx->gop_flags & IVI5_IS_PROTECTED) { avpriv_report_missing_feature(avctx, "Password-protected clip!\n"); return AVERROR_PATCHWELCOME; } if (!ctx->planes[0].bands) { av_log(avctx, AV_LOG_ERROR, "Color planes not initialized yet\n"); return AVERROR_INVALIDDATA; } ctx->switch_buffers(ctx); if (ctx->is_nonnull_frame(ctx)) { for (p = 0; p < 3; p++) { for (b = 0; b < ctx->planes[p].num_bands; b++) { result = decode_band(ctx, &ctx->planes[p].bands[b], avctx); if (result < 0) { av_log(avctx, AV_LOG_ERROR, "Error while decoding band: %d, plane: %d\n", b, p); return result; } } } } else { if (ctx->is_scalable) return AVERROR_INVALIDDATA; for (p = 0; p < 3; p++) { if (!ctx->planes[p].bands[0].buf) return AVERROR_INVALIDDATA; } } result = ff_set_dimensions(avctx, ctx->planes[0].width, ctx->planes[0].height); if (result < 0) return result; if ((result = ff_get_buffer(avctx, frame, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return result; } if (ctx->is_scalable) { if (avctx->codec_id == AV_CODEC_ID_INDEO4) ff_ivi_recompose_haar(&ctx->planes[0], frame->data[0], frame->linesize[0]); else ff_ivi_recompose53 (&ctx->planes[0], frame->data[0], frame->linesize[0]); } else { ivi_output_plane(&ctx->planes[0], frame->data[0], frame->linesize[0]); } ivi_output_plane(&ctx->planes[2], frame->data[1], frame->linesize[1]); ivi_output_plane(&ctx->planes[1], frame->data[2], frame->linesize[2]); *got_frame = 1; if (avctx->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == IVI4_FRAMETYPE_INTRA) { int left; while (get_bits(&ctx->gb, 8)); left = get_bits_count(&ctx->gb) & 0x18; skip_bits_long(&ctx->gb, 64 - left); if (get_bits_left(&ctx->gb) > 18 && show_bits_long(&ctx->gb, 21) == 0xBFFF8) { AVPacket pkt; pkt.data = avpkt->data + (get_bits_count(&ctx->gb) >> 3); pkt.size = get_bits_left(&ctx->gb) >> 3; ff_ivi_decode_frame(avctx, ctx->p_frame, &ctx->got_p_frame, &pkt); } } return buf_size; }
1threat
void qmp_blockdev_change_medium(bool has_device, const char *device, bool has_id, const char *id, const char *filename, bool has_format, const char *format, bool has_read_only, BlockdevChangeReadOnlyMode read_only, Error **errp) { BlockBackend *blk; BlockDriverState *medium_bs = NULL; int bdrv_flags; int rc; QDict *options = NULL; Error *err = NULL; blk = qmp_get_blk(has_device ? device : NULL, has_id ? id : NULL, errp); if (!blk) { goto fail; } if (blk_bs(blk)) { blk_update_root_state(blk); } bdrv_flags = blk_get_open_flags_from_root_state(blk); bdrv_flags &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_PROTOCOL); if (!has_read_only) { read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN; } switch (read_only) { case BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN: break; case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_ONLY: bdrv_flags &= ~BDRV_O_RDWR; break; case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_WRITE: bdrv_flags |= BDRV_O_RDWR; break; default: abort(); } if (has_format) { options = qdict_new(); qdict_put(options, "driver", qstring_from_str(format)); } medium_bs = bdrv_open(filename, NULL, options, bdrv_flags, errp); if (!medium_bs) { goto fail; } bdrv_add_key(medium_bs, NULL, &err); if (err) { error_propagate(errp, err); goto fail; } rc = do_open_tray(has_device ? device : NULL, has_id ? id : NULL, false, &err); if (rc && rc != -ENOSYS) { error_propagate(errp, err); goto fail; } error_free(err); err = NULL; qmp_x_blockdev_remove_medium(has_device, device, has_id, id, &err); if (err) { error_propagate(errp, err); goto fail; } qmp_blockdev_insert_anon_medium(blk, medium_bs, &err); if (err) { error_propagate(errp, err); goto fail; } blk_apply_root_state(blk, medium_bs); qmp_blockdev_close_tray(has_device, device, has_id, id, errp); fail: bdrv_unref(medium_bs); }
1threat
Can you save the data from the Visual Studio Diagnostic Tools Windows to review after application is done processing? : <p>When using Visual Studio 2015 Enterprise Edition, can you save the data that is accumulated in all the windows (Timeline, CPU Usage, Memory Usage, etc) of the Diagnostic Tools to review after the application completes?</p>
0debug
C scanf ignored when invalid input : <p>I wrote this code, and all it meant to do is input ints until a negative is entered:</p> <pre><code>int result = 0, input_number = 0; while(input_number &gt;= 0){ printf("Please enter students IDs(negetive to stop)= "); result = scanf("%d", &amp;input_number); if(result != 1){ printf("Invalid input! try again...\n"); continue; } } </code></pre> <p>When the input is an int- everything works fine,</p> <p>But when entering a char (any char the is not int),</p> <p>The loop becomes endlessly and scanf doesn't request any input anymore.</p> <p>DO NOT suggest I use a replacement for scanf cause it's a work for school, and scanf must be used.</p> <p>After entering char output:</p> <pre><code>Please enter students IDs(negetive to stop)= 4 Please enter students IDs(negetive to stop)= 5 Please enter students IDs(negetive to stop)= r Please enter students IDs(negetive to stop)= Invalid input! try again... Please enter students IDs(negetive to stop)= Invalid input! try again... Please enter students IDs(negetive to stop)= Invalid input! try again... Please enter students IDs(negetive to stop)= Invalid input! try again... Please enter students IDs(negetive to stop)= Invalid input! try again... Please enter students IDs(negetive to stop)= Invalid input! try again... ... </code></pre>
0debug
Can I make the pytest doctest module ignore a file? : <p>We use pytest to test our project and have enabled <code>--doctest-modules</code> by default to collect all of our doctests from across the project.</p> <p>However there is one <code>wsgi.py</code> which may not be imported during test collection, but I cant get pytest to ignore it.</p> <p>I tried putting it in the <code>collect_ignore</code> list in <code>conftest.py</code> but apparently the doctest module does not use this list.</p> <p>The only thing that does work is putting the whole directory of <code>wsgi.py</code> into <code>norecursedirs</code> in the pytest config file, but this obviously hides the whole directory, which I don't want.</p> <p>Is there a way to make the doctest module ignore just a certain file?</p>
0debug
error TS2339: Property 'x' does not exist on type 'Y' : <p>I don't understand why this code generates TypeScript error. (It's not the original code and is a bit derived, so please ignore the non-sense in the example):</p> <pre class="lang-js prettyprint-override"><code>interface Images { [key:string]: string; } function getMainImageUrl(images: Images): string { return images.main; } </code></pre> <p>I'm getting error (using TypeScript 1.7.5):</p> <blockquote> <p>error TS2339: Property 'main' does not exist on type 'Images'.</p> </blockquote> <p>Of course I could get rid of the error when writing:</p> <pre><code>return images["main"]; </code></pre> <p>I'd prefer not using string to access the property. What can I do?</p>
0debug
PHP Предупреждение: недопустимое смещение строки в Wordpress : There is a warning: Warning: Illegal string offset 'alt' in /home/procsi/galina3000.ru/wp-content/themes/memoir/epanel/custom_functions.php on line 112 Warning: Illegal string offset 'title' in /home/procsi/galina3000.ru/wp-content/themes/memoir/epanel/custom_functions.php on line 113 The code is shown below: if ( function_exists('has_post_thumbnail') ) { if ( has_post_thumbnail( $post->ID ) ) { $thumb_array['use_timthumb'] = false; $args=''; if ($class <> '') $args['class'] = $class; if ($alttext <> '') $args['alt'] = $alttext; if ($titletext <> '') $args['title'] = $titletext; $thumb_array['thumb'] = get_the_post_thumbnail( $post->ID, array($width,$height), $args ); if ($fullpath) { $thumb_array['fullpath'] = get_the_post_thumbnail( $post->ID ); if ($thumb_array['fullpath'] <> '') { $thumb_array['fullpath'] = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $thumb_array['fullpath'], $matches); $thumb_array['fullpath'] = trim($matches[1][0]); } } } How to fix it? Thank you.
0debug
int ffurl_open(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options) { int ret = ffurl_alloc(puc, filename, flags, int_cb); if (ret < 0) return ret; if (options && (*puc)->prot->priv_data_class && (ret = av_opt_set_dict((*puc)->priv_data, options)) < 0) goto fail; if ((ret = av_opt_set_dict(*puc, options)) < 0) goto fail; ret = ffurl_connect(*puc, options); if (!ret) return 0; fail: ffurl_close(*puc); *puc = NULL; return ret; }
1threat
static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { int64_t total_sectors; int64_t n; int64_t ret, ret2; total_sectors = bdrv_nb_sectors(bs); if (total_sectors < 0) { return total_sectors; } if (sector_num >= total_sectors) { *pnum = 0; return BDRV_BLOCK_EOF; } n = total_sectors - sector_num; if (n < nb_sectors) { nb_sectors = n; } if (!bs->drv->bdrv_co_get_block_status) { *pnum = nb_sectors; ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED; if (sector_num + nb_sectors == total_sectors) { ret |= BDRV_BLOCK_EOF; } if (bs->drv->protocol_name) { ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE); } return ret; } *file = NULL; bdrv_inc_in_flight(bs); ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum, file); if (ret < 0) { *pnum = 0; goto out; } if (ret & BDRV_BLOCK_RAW) { assert(ret & BDRV_BLOCK_OFFSET_VALID); ret = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS, *pnum, pnum, file); goto out; } if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) { ret |= BDRV_BLOCK_ALLOCATED; } else { if (bdrv_unallocated_blocks_are_zero(bs)) { ret |= BDRV_BLOCK_ZERO; } else if (bs->backing) { BlockDriverState *bs2 = bs->backing->bs; int64_t nb_sectors2 = bdrv_nb_sectors(bs2); if (nb_sectors2 >= 0 && sector_num >= nb_sectors2) { ret |= BDRV_BLOCK_ZERO; } } } if (*file && *file != bs && (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) && (ret & BDRV_BLOCK_OFFSET_VALID)) { BlockDriverState *file2; int file_pnum; ret2 = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS, *pnum, &file_pnum, &file2); if (ret2 >= 0) { if (ret2 & BDRV_BLOCK_EOF && (!file_pnum || ret2 & BDRV_BLOCK_ZERO)) { ret |= BDRV_BLOCK_ZERO; } else { *pnum = file_pnum; ret |= (ret2 & BDRV_BLOCK_ZERO); } } } out: bdrv_dec_in_flight(bs); if (ret >= 0 && sector_num + *pnum == total_sectors) { ret |= BDRV_BLOCK_EOF; } return ret; }
1threat
C++ Iterating through files in a directory: Is it bad practice? : <p>The question has been asked many times here: "How do I iterate through files in a directory in c++?"</p> <p>I've seen the responses, typically suggesting to use an external library (usually boost filesystem) to handle this and the OS differences in implementation.</p> <p>My question is: why? Why is this so difficult? I'm new to the language and can't help but feel that I'm trying to overstep the bounds of idiomatic c++.</p> <p>Is it more appropriate to implement a single file solution and use another language to implement the file iteration?</p>
0debug
Setting the Color of a TextView Drawable : <p>Im trying to change the color of a TextView Drawable in Xamarin.</p> <p>In Java you can do it like this:</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView txt = (TextView) findViewById(R.id.my_textview); setTextViewDrawableColor(txt, R.color.my_color); } private void setTextViewDrawableColor(TextView textView, int color) { for (Drawable drawable : textView.getCompoundDrawables()) { if (drawable != null) { drawable.setColorFilter(new PorterDuffColorFilter(getColor(color), PorterDuff.Mode.SRC_IN)); } } } </code></pre> <p>How i can do something like this in Xamarin.Android?</p>
0debug
Importing html files with es6 template string loader : <p>I want to import my templates into my js with <a href="https://www.npmjs.com/package/es6-template-string-loader" rel="noreferrer">es6 template string loader</a>. The only difference in my case is that I don't want to include css, only html. My code is as follows:</p> <pre><code>import app from '../../bootstrap.js'; import template from './header.html'; app.component('siteHeader', { template }); </code></pre> <p>and my error is <code>Uncaught SyntaxError: Unexpected token export</code>. </p>
0debug
About a book application program in Java using linked list : This is book Application code. I am making a code in which the program shows some options like insert Book, delete Book etc. Program asks us to enter certain details about a book by Insert method. Once I enter details it goes back and show the options again. When I choose search method it asks me search by title or search by ISBN or search by author? I choose an option and program works perfectly. I made a method updateBook. It works fine but when I search for my UPDATED INFORMATION it shows nothing. How to resolve this problem?? import java.util.Scanner; public class BookApplication { static Book head, pointer; static Scanner scan = new Scanner(System.in); public static void main(String[] args) { System.out.println("Welcome to Smart Book Store"); System.out.println("Please choose an option from the list below"); int choice = 0; do { System.out.println("1. Insert Book\n2. Delete Book\n3. Search Book\n4. Update Book\n5. View Book\n6. Exit"); choice = scan.nextInt(); try { choice = Integer.parseInt(scan.nextLine()); } catch (Exception e) { switch (choice) { case 1: addBook(); break; case 2: case 3: searchBook(); break; case 4: updateBook(); break; case 5: break; case 6: scan.close(); System.exit(0); break; default: System.out.println("Please choose from 1 to 5"); break; } } } while (true); } static void addBook() { if (head == null) { String details[] = enterDetails(); pointer = new Book(details[0], details[1], details[2]); head = pointer; pointer.next = null; } else { String details[] = enterDetails(); pointer.next = new Book(details[0], details[1], details[2]); pointer = (Book) pointer.next; } } static String[] enterDetails() { String[] details = new String[4]; try { String title; String ISBN; String authors; System.out.println("Please enter Book title"); title = scan.nextLine(); System.out.println("Please enter ISBN of book"); ISBN = scan.nextLine(); System.out.println("Please enter book's Author(s)"); authors = scan.nextLine(); details[0] = title; details[1] = ISBN; details[2] = authors; } catch (Exception e) { e.printStackTrace(); } return details; } private static void searchBook() { System.out.println(); System.out.println("1. Search by TITLE"); System.out.println("2. Search by ISBN"); System.out.println("3. Search by AUTHOR"); int choice = 0; choice: try { choice = Integer.parseInt(scan.nextLine()); } catch (Exception e) { System.out.println(); System.out.println("PLEASE ENTER VALUE BETWEEN 1 - 3"); break choice; } switch (choice) { case 1: System.out.println("Please enter Title of BOOK"); String title = scan.nextLine(); if (head == null) { System.out.println("List is EMPTY !"); return; } else { System.out.println(); System.out.println("BOOK(S) IN THE SYSTEM ARE: "); System.out.println(); pointer = head; while (pointer != null) { if (pointer.title.equals(title)) { System.out.println(pointer.getBook()); } pointer = (Book) pointer.next; } } break; case 2: System.out.println("Please enter ISBN of BOOK"); String ISBN = scan.nextLine(); if (head == null) { System.out.println("List is EMPTY !"); return; } else { System.out.println(); System.out.println("BOOK(S) IN THE SYSTEM ARE: "); System.out.println(); pointer = head; while (pointer != null) { if (pointer.ISBN.equals(ISBN)) { System.out.println(pointer.getBook()); break; } pointer = (Book) pointer.next; } } break; case 3: System.out.println("Please enter Author(s) of BOOK"); String authors = scan.nextLine(); if (head == null) { System.out.println("List is EMPTY !"); return; } else { System.out.println(); System.out.println("BOOK(S) IN THE SYSTEM ARE: "); System.out.println(); pointer = head; while (pointer != null) { if (pointer.authors.contains(authors)) { System.out.println(pointer.getBook()); break; } pointer = (Book) pointer.next; } } break; default: System.out.println("PLEASE ENTER VALUE BETWEEN 1 - 5"); } } static void updateBook() { System.out.println(); System.out.println("1. Update TITLE"); System.out.println("2. Update ISBN"); System.out.println("3. Update AUTHOR"); int choice = 0; choice: try { choice = Integer.parseInt(scan.nextLine()); } catch (Exception e) { System.out.println(); System.out.println("PLEASE ENTER VALUE BETWEEN 1 - 3"); break choice; } switch (choice) { case 1: System.out.println("Please update Title of BOOK"); String another1 = scan.nextLine(); if (head == null) { System.out.println("Title not Updated !"); return; } else { System.out.println(); System.out.println("Your new title is: " + another1); System.out.println(); pointer = head; while (pointer != null) { if (pointer.title.equals(another1)) { System.out.println(pointer.getBook()); break; } pointer = (Book) pointer.next; } } case 2: System.out.println("Please update ISBN of BOOK"); String ISBN = scan.nextLine(); if (head == null) { System.out.println("Isbn not updated !"); return; } else { System.out.println(); int aISBN = Integer.parseInt(ISBN.trim()); System.out.println("Your book's updated ISBN is: " + aISBN); System.out.println(); pointer = head; while (pointer != null) { if (pointer.ISBN.equals(aISBN)) { System.out.println(pointer.getBook()); break; } pointer = (Book) pointer.next; } } case 3: System.out.println("Please enter Author(s) of BOOK"); String upauthor1 = scan.nextLine(); if (head == null) { System.out.println("List is EMPTY !"); return; } else { System.out.println(); System.out.println("Book's Updated author is: " + upauthor1); System.out.println(); pointer = head; while (pointer != null) { if (pointer.authors.contains(upauthor1)) { System.out.println(pointer.getBook()); break; } pointer = (Book) pointer.next; } break; } } } } Here is my another class. public class Book { String authors; final String ISBN; final String title; public Object next; Book(String title, String ISBN, String authors) { this.title = title; this.authors = authors; this.ISBN = ISBN ; } public String getBook() { return "Book Title: " + this.title + "\n" + "Book ISBN: " + this.ISBN + "\n" + "Book Authors: " + this.authors + "\n" ; } }
0debug
How can I remove duplicated code between classes? : <p>I have 2 class: RecursiveFibonacci and MemorizedRecursiveFibonacci. This is what I have so far. </p> <p><strong>RecursiveFibonacci Class</strong></p> <pre><code>public class SimpleRecursiveFibonacci { public BigInteger fibonacci(int n) { if(n &lt; 2) { return BigInteger.ONE; } return fibonacci(n - 2).add(fibonacci(n - 1)); } } </code></pre> <p><strong>and MemorizedRecursiveFibonacci Class</strong></p> <pre><code>public class MemoizedRecursiveFibonacci { private Map&lt;Integer, BigInteger&gt; cache = new HashMap&lt;&gt;(); public BigInteger fibonacci(int n) { if(n &lt; 2) { return BigInteger.ONE; } if(!cache.containsKey(n)){ BigInteger currentFibonacci = fibonacci(n - 2).add(fibonacci(n - 1)); cache.put(n, currentFibonacci); } return cache.get(n); } } </code></pre> <p>As I see, there are some duplicated code in MemorizedRecursiveFibonacci Class</p> <pre><code> if(n &lt; 2) { return BigInteger.ONE; </code></pre> <p>and </p> <pre><code> BigInteger currentFibonacci = fibonacci(n - 2).add(fibonacci(n - 1)); </code></pre> <p>How can I keep it DRY? remove duplicated code?</p>
0debug
Landing Page Redirect Based on Location Choice (Cookies?) : <p>Before someone gets upset that I haven't included code, please understand that it is because I am not sure what the best practice would be.</p> <p>I have a site that operates in 3 cities specifically, and also a nation-wide version. This is an eCommerce site that has different subdomains (essentially 3 different sites, but the ability to manage products specifically based on location.)</p> <p>What I need is for the user to select their city or location preference (say New York, Chicago, Detroit or Entire US) and have that information stored so that the next time they return they don't have to reselect their preferred location.</p> <p>Of course, for UX purposes the ability to change location is available in a Top Nav menu bar should they temporarily be in the other city.</p> <p>Can IPs be targeted accurately to exact city? Should this be automated or should they be able to choose?</p> <p>My question is : What is the best practice for this? Are there any consequences to this setup? What should be used? JavaScript? JQuery? PHP?</p> <p>If there are no major negatives, where should I start to implement this?</p>
0debug
solve recurrence relation in which there is a separate relation for even and odd values : [enter image description here][1] [1]: https://i.stack.imgur.com/wjjWw.png Can someone help me how to solve these type of questions? What kind of approach should I follow?
0debug
def power(a,b): if b==0: return 1 elif a==0: return 0 elif b==1: return a else: return a*power(a,b-1)
0debug
When nodeType() used in object behaves different in jQuery versions '1.11.2' and '3.1.1' : <p>I am eager to know why the jQuery versions '1.11.2' and '3.1.1' behaves in two different ways while using nodeType() function in jQuery object.</p> <p>To illustrate this, I have two fiddle links for these two versions. </p> <p>jquery-1.11.2<br> <a href="https://jsfiddle.net/38z9m9j9/9/" rel="noreferrer">https://jsfiddle.net/38z9m9j9/9/</a></p> <p>jquery-3.1.1<br> <a href="https://jsfiddle.net/38z9m9j9/8/" rel="noreferrer">https://jsfiddle.net/38z9m9j9/8/</a></p> <p>And in this, I have an condition that, </p> <pre><code>this.options.data == data.colors[0]; </code></pre> <p>This gets equal only in version '1.11.2' on using '<strong>nodeType()</strong>' function for object 'this.options.data.colors[0]' where as not working in '3.1.1'. So, how does the 'nodeType()' works here in '1.11.2'?</p> <p>Thanks in advance.</p>
0debug
What is the best augmented reality SDK that supports Android to use for monuments detection and recognition in a museum? : <p>I'm new to AR and there seems to be many SDKs for Android and I don't which is best to use and which ones to avoid.</p>
0debug
Simple code help needed for " http://12.13.14.15/table1.php?Name=Billy&Number=6 " : I am in need of some help, please? I can successfully do a MySQL query using: IP_Address/fund_list.php?Id_Number=555666 $ID = $_GET['Id_Number']; $sql = "SELECT * FROM fund_list WHERE Number = ".$ID; ----------------------------------------- Now I want to use 2 different things in my web call. Like: IP_Address/fund_list.php?Id_Number=555666&Name=Billy But I don't know how to write the 'get' line below. $ID = $_GET['Id_Number'] & $Name = $_GET['Name']; <-- Does not work I would think the SQL select statement would be: $sql = "SELECT * FROM fund_list WHERE TheNumber = .$ID AND TheName = .$Name"; All the things I look up online, the syntax is overly confusing, I can't dissect it and make something work. Thank you.
0debug
static int tta_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TTAContext *s = avctx->priv_data; int i, ret; int cur_chan = 0, framelen = s->frame_length; int32_t *p; init_get_bits(&s->gb, buf, buf_size*8); s->total_frames--; if (!s->total_frames && s->last_frame_length) framelen = s->last_frame_length; s->frame.nb_samples = framelen; if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } if (s->bps == 3) s->decode_buffer = (int32_t *)s->frame.data[0]; for (i = 0; i < s->channels; i++) { s->ch_ctx[i].predictor = 0; ttafilter_init(&s->ch_ctx[i].filter, ttafilter_configs[s->bps-1][0], ttafilter_configs[s->bps-1][1]); rice_init(&s->ch_ctx[i].rice, 10, 10); } for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) { int32_t *predictor = &s->ch_ctx[cur_chan].predictor; TTAFilter *filter = &s->ch_ctx[cur_chan].filter; TTARice *rice = &s->ch_ctx[cur_chan].rice; uint32_t unary, depth, k; int32_t value; unary = tta_get_unary(&s->gb); if (unary == 0) { depth = 0; k = rice->k0; } else { depth = 1; k = rice->k1; unary--; } if (get_bits_left(&s->gb) < k) return -1; if (k) { if (k > MIN_CACHE_BITS) return -1; value = (unary << k) + get_bits(&s->gb, k); } else value = unary; switch (depth) { case 1: rice->sum1 += value - (rice->sum1 >> 4); if (rice->k1 > 0 && rice->sum1 < shift_16[rice->k1]) rice->k1--; else if(rice->sum1 > shift_16[rice->k1 + 1]) rice->k1++; value += shift_1[rice->k0]; default: rice->sum0 += value - (rice->sum0 >> 4); if (rice->k0 > 0 && rice->sum0 < shift_16[rice->k0]) rice->k0--; else if(rice->sum0 > shift_16[rice->k0 + 1]) rice->k0++; } #define UNFOLD(x) (((x)&1) ? (++(x)>>1) : (-(x)>>1)) *p = UNFOLD(value); ttafilter_process(filter, p, 0); #define PRED(x, k) (int32_t)((((uint64_t)x << k) - x) >> k) switch (s->bps) { case 1: *p += PRED(*predictor, 4); break; case 2: case 3: *p += PRED(*predictor, 5); break; case 4: *p += *predictor; break; } *predictor = *p; if (cur_chan < (s->channels-1)) cur_chan++; else { if (s->channels > 1) { int32_t *r = p - 1; for (*p += *r / 2; r > p - s->channels; r--) *r = *(r + 1) - *r; } cur_chan = 0; } } if (get_bits_left(&s->gb) < 32) return -1; skip_bits_long(&s->gb, 32); if (s->bps == 2) { int16_t *samples = (int16_t *)s->frame.data[0]; for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) *samples++ = *p; } else { int32_t *samples = (int32_t *)s->frame.data[0]; for (i = 0; i < framelen * s->channels; i++) *samples++ <<= 8; s->decode_buffer = NULL; } *got_frame_ptr = 1; *(AVFrame *)data = s->frame; return buf_size; }
1threat
In robot framework how to create object of class and call the methods in corresponding class? : this is code snippet. *** Settings *** Documentation A resource file with reusable keywords and variables. ... Use keywords in this file in testcases directory. Library /home/kirti/src/Helper/utilities.py Library /home/kirti/src/Helper/config_parser.py #Library /home/kirti/qa/src/executor/cleanup.CleanUp Library /home/kirti/qa/src/executor/cleanup.py *** Variables *** ${RESULT} 0 *** Keywords *** Read Json Config Values Log To Console "Setting up the config values globally" config_parser.Json Config Parser Import Variables /home/kirti/src/Helper/variables.py Log Variables INFO Check Machines Reachability utilities.Check All Machines Status Check SNMP Counter utilities.Get Snmp 192.178.1.2 PPSessionCount Call Clean Up #${cleanupobj}= cleanup.create cleanup #${name}= ${cleanupobj.cc()} Import Library /home/kirti/src/executor/cleanup.py ${cmp}= Get library instance CleanUp Log To Console ${cmp}.__class__.__name__ #${name}= Call method ${cmp} Create cleanup ${name}= Call method ${cmp} cc #${name}= Call method ${cleanupobj} env cleanup #Log To Console "${name}" #Log Variables INFO utilities.Check All Machines Status
0debug
Convert html/css file to pdf file : <p>I just designed CV with html/css. Is there a way to convert my CV to pdf ? Or can you recommend me to write a CV by any tool? please help me !</p>
0debug
VueJS - Object Props validation : <p>In VueJS, how can I validate Object type props in order to ensure that the object has some specific fields defined?</p> <p>For example, i want to ensure that the user prop will have the fields 'name', 'birthDate', and so on.</p> <p>Thanks in advance.</p>
0debug
how to use play/pause in one button on ionic3 : <p>I Developing a New mobile Musical app in ionic3</p> <p>Now In my Project, I Have a Two buttons </p> <p>1.<code>play</code>button</p> <p>2.<code>pause</code> button</p> <p>Here I need some help</p> <p>When user click <code>play</code> button then <code>play</code>button will get hide and show <code>pause</code> button.If users again click <code>pause</code> button then need to show <code>play</code> button </p> <p>How to do this in ionic3??</p>
0debug
static int qemu_signal_init(void) { int sigfd; sigset_t set; #ifdef CONFIG_IOTHREAD sigemptyset(&set); sigaddset(&set, SIGUSR2); pthread_sigmask(SIG_UNBLOCK, &set, NULL); sigemptyset(&set); sigaddset(&set, SIG_IPI); pthread_sigmask(SIG_BLOCK, &set, NULL); sigemptyset(&set); sigaddset(&set, SIGIO); sigaddset(&set, SIGALRM); sigaddset(&set, SIGBUS); #else sigemptyset(&set); sigaddset(&set, SIGBUS); if (kvm_enabled()) { sigaddset(&set, SIGIO); sigaddset(&set, SIGALRM); } #endif pthread_sigmask(SIG_BLOCK, &set, NULL); sigfd = qemu_signalfd(&set); if (sigfd == -1) { fprintf(stderr, "failed to create signalfd\n"); return -errno; } fcntl_setfl(sigfd, O_NONBLOCK); qemu_set_fd_handler2(sigfd, NULL, sigfd_handler, NULL, (void *)(intptr_t)sigfd); return 0; }
1threat
Sublime Text 3 - Limit images to viewsize : <p>I'm working on a Sublime Text 3 plugin, which displays images in a view. Those images are created by an jupyter kernel, therefore the size of the images depend on the code producing them. Since I create really big images, they are to big to fit in the view.</p> <p>I would like to limit the size to the image to the size of the view, like scale it to 100% of the view size. Is there any way to get the size of the current view and add this to the minihtml implementation of ST3?</p> <p>I've tested width: 100% which just used a fraction of the actual views size. </p>
0debug
int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* frame) { V4L2Buffer* avbuf = NULL; avbuf = v4l2_dequeue_v4l2buf(ctx, ctx_to_m2mctx(ctx)->draining ? 200 : -1); if (!avbuf) { if (ctx->done) return AVERROR_EOF; return AVERROR(EAGAIN); } return ff_v4l2_buffer_buf_to_avframe(frame, avbuf); }
1threat
Protractor: Support for the Firefox >=48 : For quite sometime now I have been trying to run protractor with Firefox(Windows) v48 and above to run my AngularJS application. However, as per [protractor docs][1] > WebDriver support fr Firefox has changed recently, and FireFox version > 48 does not work properly with the current tools. For the moment, we > recommend testing against FireFox 47 This information was updated 3 years ago and nothing seems to have been done afterwards. **Versions** - OS - Windows 10 64-bit - Protractor - 5.4.2 - Firefox - 68 - selenium-stanalone-server: 2.53.1 - AngularJS - 1.6.9 I did raise an issue recently on [github][2] for the same, but it has not received traction yet. I would like to know if anyone has been able to get around the issue for Windows. [1]: https://github.com/angular/protractor/blob/master/docs/browser-support.md [2]: https://github.com/angular/protractor/issues/5299
0debug
Visual Studio 2017 References vs Dependencies : <p>I have a .NET Core solution in visual studio 2017 that is building against the .NET 4.7 framework. </p> <p>In the main web application there is a dependencies menu that breaks down references into logical categories (Analyzers, Assemblies, NuGet, Projects).</p> <p><a href="https://i.stack.imgur.com/twf7f.png" rel="noreferrer"><img src="https://i.stack.imgur.com/twf7f.png" alt="Dependencies Menu"></a></p> <p>In the helper project it only has a references menu with everything jumbled inside. Is there a way to get the same treatment here as the web application got?</p> <p><a href="https://i.stack.imgur.com/bF0Mh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bF0Mh.png" alt="enter image description here"></a></p>
0debug
I am using r code to extract the statistics of some youtube channels. I am using the package tuber and specifically get_all_video_stats : I am using r code to extract the statistics of some youtube channels. I am using the package tuber and specifically get_all_video_stats. My problem is that i only want the statistics published for the last 6 months and since the creation of the channel. is it possible to do? Thanks a lot^^
0debug
How to return from python function : <p>This is my first programming practice. I have a python function like this: </p> <pre><code>sum = 0 def summation(a,b): sum = a+b return sum </code></pre> <p>and when I call function as </p> <pre><code>summation(3,4) </code></pre> <p>It does not return anything. Why?</p>
0debug
The average of a field in array of objects : <p>I have the following array of objects:</p> <pre><code>[ { items: { "1554038371930_ajhnms9ft" : { "mark" : 5 }, "1554038905938_le34li2cg" : { "mark" : 2 }, "1554039157958_kwab8rj5f" : { "mark" : 4 }, "1554039174126_p47ugwkbv" : { "mark" : 1 } } }, { items: { "1554038371930_ajhnms9ft" : { "mark" : 1 }, "1554038905938_le34li2cg" : { "mark" : 5 }, "1554039157958_kwab8rj5f" : { "mark" : 5 }, "1554039174126_p47ugwkbv" : { "mark" : 2 } } }, { items: { "1554038371930_ajhnms9ft" : { "mark" : 4 }, "1554038905938_le34li2cg" : { "mark" : 3 }, "1554039157958_kwab8rj5f" : { "mark" : 3 }, "1554039174126_p47ugwkbv" : { "mark" : 4 } } }, { items: { "1554038371930_ajhnms9ft" : { "mark" : 1 }, "1554038905938_le34li2cg" : { "mark" : 2 }, "1554039157958_kwab8rj5f" : { "mark" : 5 }, "1554039174126_p47ugwkbv" : { "mark" : 4 } } } ] </code></pre> <p>and i want to get the average of chack item, so the result will be the following:</p> <pre><code>{ items: { "1554038371930_ajhnms9ft" : { "mark" : 2.75 }, "1554038905938_le34li2cg" : { "mark" : 3 }, "1554039157958_kwab8rj5f" : { "mark" : 4.25 }, "1554039174126_p47ugwkbv" : { "mark" : 2.75 } } } </code></pre> <p>which is the best way to achieve that?</p>
0debug
static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { BinkDemuxContext *bink = s->priv_data; AVStream *vst = s->streams[0]; if (!s->pb->seekable) return -1; if (avio_seek(s->pb, vst->index_entries[0].pos, SEEK_SET) < 0) return -1; bink->video_pts = 0; memset(bink->audio_pts, 0, sizeof(bink->audio_pts)); bink->current_track = -1; return 0; }
1threat
static int rm_write_packet(AVFormatContext *s, AVPacket *pkt) { if (s->streams[pkt->stream_index]->codec.codec_type == CODEC_TYPE_AUDIO) return rm_write_audio(s, pkt->data, pkt->size); else return rm_write_video(s, pkt->data, pkt->size); }
1threat
void mips_cpu_do_interrupt(CPUState *cs) { #if !defined(CONFIG_USER_ONLY) MIPSCPU *cpu = MIPS_CPU(cs); CPUMIPSState *env = &cpu->env; bool update_badinstr = 0; target_ulong offset; int cause = -1; const char *name; if (qemu_loglevel_mask(CPU_LOG_INT) && cs->exception_index != EXCP_EXT_INTERRUPT) { if (cs->exception_index < 0 || cs->exception_index > EXCP_LAST) { name = "unknown"; } else { name = excp_names[cs->exception_index]; } qemu_log("%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " %s exception\n", __func__, env->active_tc.PC, env->CP0_EPC, name); } if (cs->exception_index == EXCP_EXT_INTERRUPT && (env->hflags & MIPS_HFLAG_DM)) { cs->exception_index = EXCP_DINT; } offset = 0x180; switch (cs->exception_index) { case EXCP_DSS: env->CP0_Debug |= 1 << CP0DB_DSS; env->CP0_DEPC = env->active_tc.PC | !!(env->hflags & MIPS_HFLAG_M16); goto enter_debug_mode; case EXCP_DINT: env->CP0_Debug |= 1 << CP0DB_DINT; goto set_DEPC; case EXCP_DIB: env->CP0_Debug |= 1 << CP0DB_DIB; goto set_DEPC; case EXCP_DBp: env->CP0_Debug |= 1 << CP0DB_DBp; goto set_DEPC; case EXCP_DDBS: env->CP0_Debug |= 1 << CP0DB_DDBS; goto set_DEPC; case EXCP_DDBL: env->CP0_Debug |= 1 << CP0DB_DDBL; set_DEPC: env->CP0_DEPC = exception_resume_pc(env); env->hflags &= ~MIPS_HFLAG_BMASK; enter_debug_mode: if (env->insn_flags & ISA_MIPS3) { env->hflags |= MIPS_HFLAG_64; if (!(env->insn_flags & ISA_MIPS64R6) || env->CP0_Status & (1 << CP0St_KX)) { env->hflags &= ~MIPS_HFLAG_AWRAP; } } env->hflags |= MIPS_HFLAG_DM | MIPS_HFLAG_CP0; env->hflags &= ~(MIPS_HFLAG_KSU); if (!(env->CP0_Status & (1 << CP0St_EXL))) env->CP0_Cause &= ~(1U << CP0Ca_BD); env->active_tc.PC = (int32_t)0xBFC00480; set_hflags_for_handler(env); break; case EXCP_RESET: cpu_reset(CPU(cpu)); break; case EXCP_SRESET: env->CP0_Status |= (1 << CP0St_SR); memset(env->CP0_WatchLo, 0, sizeof(env->CP0_WatchLo)); goto set_error_EPC; case EXCP_NMI: env->CP0_Status |= (1 << CP0St_NMI); set_error_EPC: env->CP0_ErrorEPC = exception_resume_pc(env); env->hflags &= ~MIPS_HFLAG_BMASK; env->CP0_Status |= (1 << CP0St_ERL) | (1 << CP0St_BEV); if (env->insn_flags & ISA_MIPS3) { env->hflags |= MIPS_HFLAG_64; if (!(env->insn_flags & ISA_MIPS64R6) || env->CP0_Status & (1 << CP0St_KX)) { env->hflags &= ~MIPS_HFLAG_AWRAP; } } env->hflags |= MIPS_HFLAG_CP0; env->hflags &= ~(MIPS_HFLAG_KSU); if (!(env->CP0_Status & (1 << CP0St_EXL))) env->CP0_Cause &= ~(1U << CP0Ca_BD); env->active_tc.PC = (int32_t)0xBFC00000; set_hflags_for_handler(env); break; case EXCP_EXT_INTERRUPT: cause = 0; if (env->CP0_Cause & (1 << CP0Ca_IV)) { uint32_t spacing = (env->CP0_IntCtl >> CP0IntCtl_VS) & 0x1f; if ((env->CP0_Status & (1 << CP0St_BEV)) || spacing == 0) { offset = 0x200; } else { uint32_t vector = 0; uint32_t pending = (env->CP0_Cause & CP0Ca_IP_mask) >> CP0Ca_IP; if (env->CP0_Config3 & (1 << CP0C3_VEIC)) { vector = pending; } else { pending &= (env->CP0_Status >> CP0St_IM) & 0xff; while (pending >>= 1) { vector++; } } offset = 0x200 + (vector * (spacing << 5)); } } goto set_EPC; case EXCP_LTLBL: cause = 1; update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL); goto set_EPC; case EXCP_TLBL: cause = 2; update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL); if ((env->error_code & EXCP_TLB_NOMATCH) && !(env->CP0_Status & (1 << CP0St_EXL))) { #if defined(TARGET_MIPS64) int R = env->CP0_BadVAddr >> 62; int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0; int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0; int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0; if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) && (!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)))) offset = 0x080; else #endif offset = 0x000; } goto set_EPC; case EXCP_TLBS: cause = 3; update_badinstr = 1; if ((env->error_code & EXCP_TLB_NOMATCH) && !(env->CP0_Status & (1 << CP0St_EXL))) { #if defined(TARGET_MIPS64) int R = env->CP0_BadVAddr >> 62; int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0; int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0; int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0; if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) && (!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)))) offset = 0x080; else #endif offset = 0x000; } goto set_EPC; case EXCP_AdEL: cause = 4; update_badinstr = !(env->error_code & EXCP_INST_NOTAVAIL); goto set_EPC; case EXCP_AdES: cause = 5; update_badinstr = 1; goto set_EPC; case EXCP_IBE: cause = 6; goto set_EPC; case EXCP_DBE: cause = 7; goto set_EPC; case EXCP_SYSCALL: cause = 8; update_badinstr = 1; goto set_EPC; case EXCP_BREAK: cause = 9; update_badinstr = 1; goto set_EPC; case EXCP_RI: cause = 10; update_badinstr = 1; goto set_EPC; case EXCP_CpU: cause = 11; update_badinstr = 1; env->CP0_Cause = (env->CP0_Cause & ~(0x3 << CP0Ca_CE)) | (env->error_code << CP0Ca_CE); goto set_EPC; case EXCP_OVERFLOW: cause = 12; update_badinstr = 1; goto set_EPC; case EXCP_TRAP: cause = 13; update_badinstr = 1; goto set_EPC; case EXCP_MSAFPE: cause = 14; update_badinstr = 1; goto set_EPC; case EXCP_FPE: cause = 15; update_badinstr = 1; goto set_EPC; case EXCP_C2E: cause = 18; goto set_EPC; case EXCP_TLBRI: cause = 19; update_badinstr = 1; goto set_EPC; case EXCP_TLBXI: cause = 20; goto set_EPC; case EXCP_MSADIS: cause = 21; update_badinstr = 1; goto set_EPC; case EXCP_MDMX: cause = 22; goto set_EPC; case EXCP_DWATCH: cause = 23; goto set_EPC; case EXCP_MCHECK: cause = 24; goto set_EPC; case EXCP_THREAD: cause = 25; goto set_EPC; case EXCP_DSPDIS: cause = 26; goto set_EPC; case EXCP_CACHE: cause = 30; if (env->CP0_Status & (1 << CP0St_BEV)) { offset = 0x100; } else { offset = 0x20000100; } set_EPC: if (!(env->CP0_Status & (1 << CP0St_EXL))) { env->CP0_EPC = exception_resume_pc(env); if (update_badinstr) { set_badinstr_registers(env); } if (env->hflags & MIPS_HFLAG_BMASK) { env->CP0_Cause |= (1U << CP0Ca_BD); } else { env->CP0_Cause &= ~(1U << CP0Ca_BD); } env->CP0_Status |= (1 << CP0St_EXL); if (env->insn_flags & ISA_MIPS3) { env->hflags |= MIPS_HFLAG_64; if (!(env->insn_flags & ISA_MIPS64R6) || env->CP0_Status & (1 << CP0St_KX)) { env->hflags &= ~MIPS_HFLAG_AWRAP; } } env->hflags |= MIPS_HFLAG_CP0; env->hflags &= ~(MIPS_HFLAG_KSU); } env->hflags &= ~MIPS_HFLAG_BMASK; if (env->CP0_Status & (1 << CP0St_BEV)) { env->active_tc.PC = (int32_t)0xBFC00200; } else { env->active_tc.PC = (int32_t)(env->CP0_EBase & ~0x3ff); } env->active_tc.PC += offset; set_hflags_for_handler(env); env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (cause << CP0Ca_EC); break; default: abort(); } if (qemu_loglevel_mask(CPU_LOG_INT) && cs->exception_index != EXCP_EXT_INTERRUPT) { qemu_log("%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n" " S %08x C %08x A " TARGET_FMT_lx " D " TARGET_FMT_lx "\n", __func__, env->active_tc.PC, env->CP0_EPC, cause, env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr, env->CP0_DEPC); } #endif cs->exception_index = EXCP_NONE; }
1threat
Can anyone help me with my SQL statement? : I assigned the code below to an commandbutton. When i execute it, it returns an error(3061) CurrentDb.Execute "INSERT INTO tblVerlof(Aanmaakdatum, VerlofDatum, VerlofReden, Aantal, me.VerlofPoule, Notitie, Status)VALUES(now(), me.startdatum, 2, me.txturen, me.verlofpoule, me.txttitel, 2)" Is someone able to assist me in this endevor
0debug
Dagger 2 injection in non Activity Java class : <p>I am trying to use Dagger2 for DI, it works perfectly fine for Activity/Fragment related classes where there is a onCreate lifecycle event. Now I have a plain Java class which I want to be injected. Any ideas as to how to go about it would be appreciated. The code I have looks like this :</p> <p>BasicMoviesUsecaseComponent.java - </p> <pre><code>@PerActivity @Component(dependencies = AppComponent.class, modules = BasicMoviesUsecasesModule.class) public interface BasicMoviesUsecasesComponent { void inject(PaymentsManager paymentsManager); } </code></pre> <p>DatabaseModule.java - </p> <pre><code> @Module public class DatabaseModule { @Provides @Singleton Realm provideRealmInstance(Context context) { return Realm.getInstance(context); } @Provides @Singleton DatabaseProvider provideDatabaseInstance(Realm realm) { return new DatabaseProvider(realm); } @Provides @Singleton SharedPreferences provideSharedPrefs(Context context) { return context.getSharedPreferences(context.getPackageName()+"_prefs", Context.MODE_PRIVATE); } @Provides @Singleton SharedPreferencesManager provideSharedPreferencesManager(SharedPreferences sharedPreferences) { return new SharedPreferencesManager(sharedPreferences); } @Provides @Singleton PaymentsManager providePaymentsManager(SharedPreferencesManager sharedPreferencesManager) { return new PaymentsManager(sharedPreferencesManager); } } </code></pre> <p>AppComponent.java - </p> <pre><code> @Singleton @Component(modules = { ApplicationModule.class, DomainModule.class, DatabaseModule.class }) public interface AppComponent { Bus bus(); Realm realm(); DatabaseProvider dbProvider(); SharedPreferencesManager sharedPreferencesManager(); } </code></pre> <p>Here is the class I need to inject the SharedPreferencesManager into and I am unable to do so :</p> <p>MyManager.java - </p> <pre><code> private class MyManager { private SharedPreferencesManager manager; @Inject MyManager(SharedPreferencesManager manager){ this.manager = manager; } private void initializeDependencyInjector() { BMSApplication app = BMSApplication.getInstance(); DaggerBasicMoviesUsecasesComponent.builder() .appComponent(app.getAppComponent()) .basicMoviesUsecasesModule(new BasicMoviesUsecasesModule()) .build().inject(PaymentsManager.this); } } </code></pre> <p>How do I call initializeDependencyInjector() ? </p>
0debug
static av_cold int libgsm_init(AVCodecContext *avctx) { if (avctx->channels > 1) { av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n", avctx->channels); return -1; } if(avctx->codec->decode){ if(!avctx->channels) avctx->channels= 1; if(!avctx->sample_rate) avctx->sample_rate= 8000; avctx->sample_fmt = AV_SAMPLE_FMT_S16; }else{ if (avctx->sample_rate != 8000) { av_log(avctx, AV_LOG_ERROR, "Sample rate 8000Hz required for GSM, got %dHz\n", avctx->sample_rate); if(avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) return -1; } if (avctx->bit_rate != 13000 && avctx->bit_rate != 13200 && avctx->bit_rate != 0 ) { av_log(avctx, AV_LOG_ERROR, "Bitrate 13000bps required for GSM, got %dbps\n", avctx->bit_rate); if(avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) return -1; } } avctx->priv_data = gsm_create(); switch(avctx->codec_id) { case CODEC_ID_GSM: avctx->frame_size = GSM_FRAME_SIZE; avctx->block_align = GSM_BLOCK_SIZE; break; case CODEC_ID_GSM_MS: { int one = 1; gsm_option(avctx->priv_data, GSM_OPT_WAV49, &one); avctx->frame_size = 2*GSM_FRAME_SIZE; avctx->block_align = GSM_MS_BLOCK_SIZE; } } avctx->coded_frame= avcodec_alloc_frame(); avctx->coded_frame->key_frame= 1; return 0; }
1threat
static unsigned char get_ref_idx(AVFrame *frame) { FrameDecodeData *fdd; NVDECFrame *cf; if (!frame || !frame->private_ref) return 255; fdd = (FrameDecodeData*)frame->private_ref->data; cf = (NVDECFrame*)fdd->hwaccel_priv; return cf->idx; }
1threat
how to connect an android application to MySQL database? : <p>I am developing an android application,and I have create a MySQL database in my computer,and I want to know how can I get the information in android application from the database ?</p>
0debug
static void sd_set_ocr(SDState *sd) { sd->ocr = 0x80ffff00; }
1threat
In SQL How to convert time intoUNIX_timestamp : In hive there is some data I have. Now I want to convert the start_timestamp into unix_timestamp in second. How to do? Because the start_timestamp has two format. start_timestamp First format : 2018-03-22 02:54:35 , Second Format: May 15 2018 5:15PM Any help? Appreciate your help. Thanks
0debug
Empty constructor function : <p>In a code i've come across a class which had this function at the start: </p> <pre><code>private function __construct() { } </code></pre> <p>Why would there be an empty function at the top? Is there any purpose to this? Or does this depend on the rest of the code? If it does could anyone give me an example in which this would be useful. </p>
0debug
Android Sudio - Basic Calculator - app shows unfortunately stopped : I am a newbie at android studio. Tried this code and builded and generated an unsigned apk. I tried in on Samsung galaxy trend GT-s7392 and Asus Zenfone 5, also tried in bluestacks. But when the app is opened , It shows - " Unfortunately Calculator has stopped.?" Additionally, It never asks for for any permission upon installation. Should i need to modify the android manifest.xml or any other file <!-- begin snippet: js hide: false --> <!-- language: lang-html --> package in.harisree.calculator; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public abstract class MainActivity extends AppCompatActivity implements OnClickListener { public Button btnAdd,btnSub,btnMul,btnDiv; public TextView tvResult; public EditText etNum1,etNum2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); init(); } private void init() { btnAdd=(Button)findViewById(R.id.btnAdd); btnSub=(Button)findViewById(R.id.btnSub); btnMul=(Button)findViewById(R.id.btnMul); btnDiv=(Button)findViewById(R.id.btnDiv); etNum1=(EditText)findViewById(R.id.etNum1); etNum2=(EditText)findViewById(R.id.etNum2); tvResult=(TextView)findViewById(R.id.tvResult); btnAdd.setOnClickListener(this); btnSub.setOnClickListener(this); btnMul.setOnClickListener(this); btnDiv.setOnClickListener(this); } public void onClick(View view) { String a= String.valueOf(etNum1.getText()); String b= String.valueOf(etNum1.getText()); switch (view.getId()) { case R.id.btnAdd: tvResult.setText(String.valueOf(Integer.parseInt(a)+Integer.parseInt(b))); break; case R.id.btnSub: tvResult.setText(String.valueOf(Integer.parseInt(a)-Integer.parseInt(b))); break; case R.id.btnMul: tvResult.setText(String.valueOf(Integer.parseInt(a)*Integer.parseInt(b))); break; case R.id.btnDiv: tvResult.setText(String.valueOf(Integer.parseInt(a)/Integer.parseInt(b))); break; } } } <!-- end snippet -->
0debug
SKStoreKitReviewController and Darkmode : <p>Is there any way to alter the colors/tint of an SKStoreKitReviewController? When I am modifying my apps to support DarkMode, when in dark mode, the presented viewController does not look good.</p> <p><a href="https://i.stack.imgur.com/iishh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iishh.png" alt="enter image description here"></a></p>
0debug
static gnutls_anon_server_credentials_t vnc_tls_initialize_anon_cred(void) { gnutls_anon_server_credentials_t anon_cred; int ret; if ((ret = gnutls_anon_allocate_server_credentials(&anon_cred)) < 0) { VNC_DEBUG("Cannot allocate credentials %s\n", gnutls_strerror(ret)); return NULL; } gnutls_anon_set_server_dh_params(anon_cred, dh_params); return anon_cred; }
1threat
ggplot - grouped marplot for 2x2 table : Given a contingency table 2x2 with the counted numbers in cells, how can I get a grouped bar plot with stacked percentages? Here is an example code specie=c(rep("sorgho" , 1) , rep("poacee" , 1) ) condition=rep(c("normal" , "stress") ,1) value=abs(rnorm(4 , 0 , 4)) data2=data.frame(specie,condition,value) # Stacked Percent ggplot(data2, aes(fill=condition, y=value, x=specie)) + geom_bar( stat="identity", position="fill") But my data looks like: A B Group C 4 5 D 1 2 The plot should tell me: What's the percentage of A is in Group C? What's the percentage of B is in Group D? Thanks.
0debug
int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const AVPacket *avpkt) { AVCodecInternal *avci = avctx->internal; int ret = 0; *got_frame_ptr = 0; if (!avpkt->data && avpkt->size) { av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n"); return AVERROR(EINVAL); } if (!avctx->codec) return AVERROR(EINVAL); if (avctx->codec->type != AVMEDIA_TYPE_AUDIO) { av_log(avctx, AV_LOG_ERROR, "Invalid media type for audio\n"); return AVERROR(EINVAL); } av_frame_unref(frame); if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type & FF_THREAD_FRAME)) { uint8_t *side; int side_size; uint32_t discard_padding = 0; AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(&tmp); ret = apply_param_change(avctx, &tmp); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error applying parameter changes.\n"); if (avctx->err_recognition & AV_EF_EXPLODE) goto fail; } avctx->internal->pkt = &tmp; if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) ret = ff_thread_decode_frame(avctx, frame, got_frame_ptr, &tmp); else { ret = avctx->codec->decode(avctx, frame, got_frame_ptr, &tmp); frame->pkt_dts = avpkt->dts; } if (ret >= 0 && *got_frame_ptr) { add_metadata_from_side_data(avctx, frame); avctx->frame_number++; av_frame_set_best_effort_timestamp(frame, guess_correct_pts(avctx, frame->pkt_pts, frame->pkt_dts)); if (frame->format == AV_SAMPLE_FMT_NONE) frame->format = avctx->sample_fmt; if (!frame->channel_layout) frame->channel_layout = avctx->channel_layout; if (!av_frame_get_channels(frame)) av_frame_set_channels(frame, avctx->channels); if (!frame->sample_rate) frame->sample_rate = avctx->sample_rate; } side= av_packet_get_side_data(avctx->internal->pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size); if(side && side_size>=10) { avctx->internal->skip_samples = AV_RL32(side); av_log(avctx, AV_LOG_DEBUG, "skip %d samples due to side data\n", avctx->internal->skip_samples); discard_padding = AV_RL32(side + 4); } if (avctx->internal->skip_samples && *got_frame_ptr) { if(frame->nb_samples <= avctx->internal->skip_samples){ *got_frame_ptr = 0; avctx->internal->skip_samples -= frame->nb_samples; av_log(avctx, AV_LOG_DEBUG, "skip whole frame, skip left: %d\n", avctx->internal->skip_samples); } else { av_samples_copy(frame->extended_data, frame->extended_data, 0, avctx->internal->skip_samples, frame->nb_samples - avctx->internal->skip_samples, avctx->channels, frame->format); if(avctx->pkt_timebase.num && avctx->sample_rate) { int64_t diff_ts = av_rescale_q(avctx->internal->skip_samples, (AVRational){1, avctx->sample_rate}, avctx->pkt_timebase); if(frame->pkt_pts!=AV_NOPTS_VALUE) frame->pkt_pts += diff_ts; if(frame->pkt_dts!=AV_NOPTS_VALUE) frame->pkt_dts += diff_ts; if (av_frame_get_pkt_duration(frame) >= diff_ts) av_frame_set_pkt_duration(frame, av_frame_get_pkt_duration(frame) - diff_ts); } else { av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for skipped samples.\n"); } av_log(avctx, AV_LOG_DEBUG, "skip %d/%d samples\n", avctx->internal->skip_samples, frame->nb_samples); frame->nb_samples -= avctx->internal->skip_samples; avctx->internal->skip_samples = 0; } } if (discard_padding > 0 && discard_padding <= frame->nb_samples && *got_frame_ptr) { if (discard_padding == frame->nb_samples) { *got_frame_ptr = 0; } else { if(avctx->pkt_timebase.num && avctx->sample_rate) { int64_t diff_ts = av_rescale_q(frame->nb_samples - discard_padding, (AVRational){1, avctx->sample_rate}, avctx->pkt_timebase); if (av_frame_get_pkt_duration(frame) >= diff_ts) av_frame_set_pkt_duration(frame, av_frame_get_pkt_duration(frame) - diff_ts); } else { av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for discarded samples.\n"); } av_log(avctx, AV_LOG_DEBUG, "discard %d/%d samples\n", discard_padding, frame->nb_samples); frame->nb_samples -= discard_padding; } } fail: avctx->internal->pkt = NULL; if (did_split) { av_packet_free_side_data(&tmp); if(ret == tmp.size) ret = avpkt->size; } if (ret >= 0 && *got_frame_ptr) { if (!avctx->refcounted_frames) { int err = unrefcount_frame(avci, frame); if (err < 0) return err; } } else av_frame_unref(frame); } return ret; }
1threat
Fetching size of object's list - Optional.get() without .ifPresent : <p>I have method that return <code>Optional</code> of Book object (do not mind with names as it is just a sample of code). I want to fetch the size of list which is inside Book class:</p> <pre><code>public class Book { Integer b; DateTime dateOfCreation; Integer a; List&lt;Integer&gt; bookList; } </code></pre> <p>So it goes like this: </p> <pre><code>public class Main { public static void main(String[] args) { Optional&lt;Book&gt; book = getBookObject(); int sizeOfList = book.get().bookList.size(); } static Optional&lt;Book&gt; getBookObject() { return Optional.of(new Book()); } } </code></pre> <p>I have warning within the <code>get()</code> which goes like <code>Optional.get() without .ifPresent</code> what is the proper approach to fetch this size of the list?</p>
0debug
static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s) { AVCodecContext *VideoCodec = s->streams[0]->codec; AVCodecContext *AudioCodec = s->streams[1]->codec; int AudioRate = AudioCodec->sample_rate; int FrameRate = ((VideoCodec->time_base.den) * (0x10000))/ (VideoCodec->time_base.num); int audio_kbitrate= AudioCodec->bit_rate / 1000; int video_kbitrate= FFMIN(VideoCodec->bit_rate / 1000, 800 - audio_kbitrate); put_be32(pb, 0x94 ); put_tag(pb, "uuid"); put_tag(pb, "PROF"); put_be32(pb, 0x21d24fce ); put_be32(pb, 0xbb88695c ); put_be32(pb, 0xfac9c740 ); put_be32(pb, 0x0 ); put_be32(pb, 0x3 ); put_be32(pb, 0x14 ); put_tag(pb, "FPRF"); put_be32(pb, 0x0 ); put_be32(pb, 0x0 ); put_be32(pb, 0x0 ); put_be32(pb, 0x2c ); put_tag(pb, "APRF"); put_be32(pb, 0x0 ); put_be32(pb, 0x2 ); put_tag(pb, "mp4a"); put_be32(pb, 0x20f ); put_be32(pb, 0x0 ); put_be32(pb, audio_kbitrate); put_be32(pb, audio_kbitrate); put_be32(pb, AudioRate ); put_be32(pb, AudioCodec->channels ); put_be32(pb, 0x34 ); put_tag(pb, "VPRF"); put_be32(pb, 0x0 ); put_be32(pb, 0x1 ); put_tag(pb, "mp4v"); put_be32(pb, 0x103 ); put_be32(pb, 0x0 ); put_be32(pb, video_kbitrate); put_be32(pb, video_kbitrate); put_be32(pb, FrameRate); put_be32(pb, FrameRate); put_be16(pb, VideoCodec->width); put_be16(pb, VideoCodec->height); put_be32(pb, 0x010001); }
1threat
two counts with differents status in one group in mysql? : > <i>SELECT services, COUNT( * ) AS Total_queue, COUNT( * ) AS balance_queue FROM tqueue WHERE STATUS IN ('8','4') and STATUS ('4') AND get_tiket BETWEEN '2016-11-10 00:00:01' AND '2016-11-10 23:59:59' GROUP BY services</i> but not working, if just 1 status is working I Want to have 2 result Total_queue with 2 number status (8 and 4) but balance_queue with just one status (4), DATA TABLE ----------------------------------- Total_queue | balance_queue .------------------------------------- ___ 7 __ | ___5_____ - Amount 7 in total_queue is produces by two status ( 8 and 4 ) amount 5 in balance_queue is produced by one status ( 4 ) note: status 4 mean queuing----------------- status 8 mean be called because of that in total_queue produced by all status ( 8 and 4) queuing and called
0debug
static int decode_wdlt(GetByteContext *gb, uint8_t *frame, int width, int height) { const uint8_t *frame_end = frame + width * height; uint8_t *line_ptr; int count, i, v, lines, segments; lines = bytestream2_get_le16(gb); if (lines > height) return -1; while (lines--) { if (bytestream2_get_bytes_left(gb) < 2) return -1; segments = bytestream2_get_le16u(gb); while ((segments & 0xC000) == 0xC000) { unsigned delta = -((int16_t)segments * width); if (frame_end - frame <= delta) return -1; frame += delta; segments = bytestream2_get_le16(gb); } if (segments & 0x8000) { frame[width - 1] = segments & 0xFF; segments = bytestream2_get_le16(gb); } line_ptr = frame; frame += width; while (segments--) { if (frame - line_ptr <= bytestream2_peek_byte(gb)) return -1; line_ptr += bytestream2_get_byte(gb); count = (int8_t)bytestream2_get_byte(gb); if (count >= 0) { if (frame - line_ptr < count * 2) return -1; if (bytestream2_get_buffer(gb, line_ptr, count * 2) != count * 2) return -1; line_ptr += count * 2; } else { count = -count; if (frame - line_ptr < count * 2) return -1; v = bytestream2_get_le16(gb); for (i = 0; i < count; i++) bytestream_put_le16(&line_ptr, v); } } } return 0; }
1threat
Remove last value in an array elements : <?php $values = "aaa,bbb,ccc,ddd,";//Remove last comma $values = "aaa,bbb,,,";//Remove all commas before bbb like aaa,bbb ?> How to remove commas in this example
0debug
Value-initialization of class containing std::queue : <p>Here is a MCVE:</p> <pre><code>#include &lt;queue&gt; struct S { std::queue&lt;int&gt; q; int r; }; int main() { S s{}; } </code></pre> <p>With gcc 6.x <code>-std=c++14 -pedantic</code> I get warnings </p> <pre><code>&lt;source&gt;:11:9: warning: converting to 'std::queue&lt;int&gt;' from initializer list would use explicit constructor 'std::queue&lt;_Tp, _Sequence&gt;::queue(_Sequence&amp;&amp;) [with _Tp = int; _Sequence = std::deque&lt;int, std::allocator&lt;int&gt; &gt;]' S s{}; ^ &lt;source&gt;:11:9: note: in C++11 and above a default constructor can be explicit ^ </code></pre> <p>In gcc 7.x, or clang , there are no warnings. </p> <p>My question is: Is this code actually correct or not; and if it is correct, what are the warnings trying to warn me about exactly?</p>
0debug
Java OpenCV from Maven : <p>Is there any way to get OpenCV from repository? Which artifact should I add to <code>pom.xml</code>? Every tutorial I'd found is from '14 and it seems like something changed - they say it is'nt in official Maven repository yet, but I've found entry:</p> <pre><code>&lt;!-- https://mvnrepository.com/artifact/nu.pattern/opencv --&gt; &lt;dependency&gt; &lt;groupId&gt;nu.pattern&lt;/groupId&gt; &lt;artifactId&gt;opencv&lt;/artifactId&gt; &lt;version&gt;2.4.9-7&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>Sadly, I get error</p> <pre><code>Caused by: java.lang.UnsatisfiedLinkError: no opencv_java249 in java.library.path </code></pre> <p>when I'm using <code>System.loadLibrary(Core.NATIVE_LIBRARY_NAME)</code>. Can I add this library in a way that would make my project include it and 'forget' about manually adding it to classpath?</p>
0debug
Get invalid value from input type number : <p>I am using input type number. How can I get the value from this when its not valid. For example using type number and printing just 'e' thats not valid by itself.</p> <p>I am using React but I think this question is very general. </p> <pre><code>onChange(event) { console.log(event.target.value) //is empty string when not using number } &lt;form novalidate&gt; &lt;input type="number" onChange={this.onChange}&gt; &lt;/form&gt; </code></pre>
0debug
hello,a = np.array([[1,2],[3,4],[5,6]]).What is the difference between a[:,:-1] and a[:,-1]? : a = np.array([[1,2],[3,4],[5,6]]) How to understand the difference between a[:,:-1] and a[:,-1]? [enter image description here][1] [1]: https://i.stack.imgur.com/AiyI6.png
0debug
static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffset) { int coeff = dirac_get_se_golomb(gb); const int sign = FFSIGN(coeff); if (coeff) coeff = sign*((sign * coeff * qfactor + qoffset) >> 2); return coeff; }
1threat
Mysterious Cipher appeared in my news feed : <p>SMK XKL JVWW JWDTDVQVW DWXCC WV GFY</p> <p>I have been trying to decipher this for past hours, but I am not anywhere close to finding the solution. I'd appreciate a clue or starting point, or perhaps a spoilery solution if anyone figures it out. This is seriously getting in the way of my productivity!</p>
0debug
static int parse_pixel_format(AVCodecContext *avctx) { DDSContext *ctx = avctx->priv_data; GetByteContext *gbc = &ctx->gbc; char buf[32]; uint32_t flags, fourcc, gimp_tag; enum DDSDXGIFormat dxgi; int size, bpp, r, g, b, a; int alpha_exponent, ycocg_classic, ycocg_scaled, normal_map, array; bytestream2_skip(gbc, 4 * 3); gimp_tag = bytestream2_get_le32(gbc); alpha_exponent = gimp_tag == MKTAG('A', 'E', 'X', 'P'); ycocg_classic = gimp_tag == MKTAG('Y', 'C', 'G', '1'); ycocg_scaled = gimp_tag == MKTAG('Y', 'C', 'G', '2'); bytestream2_skip(gbc, 4 * 7); size = bytestream2_get_le32(gbc); if (size != 32) { av_log(avctx, AV_LOG_ERROR, "Invalid pixel format header %d.\n", size); return AVERROR_INVALIDDATA; flags = bytestream2_get_le32(gbc); ctx->compressed = flags & DDPF_FOURCC; ctx->paletted = flags & DDPF_PALETTE; normal_map = flags & DDPF_NORMALMAP; fourcc = bytestream2_get_le32(gbc); bpp = bytestream2_get_le32(gbc); r = bytestream2_get_le32(gbc); g = bytestream2_get_le32(gbc); b = bytestream2_get_le32(gbc); a = bytestream2_get_le32(gbc); bytestream2_skip(gbc, 4); bytestream2_skip(gbc, 4); 2 bytestream2_skip(gbc, 4); 3 bytestream2_skip(gbc, 4); 4 bytestream2_skip(gbc, 4); av_get_codec_tag_string(buf, sizeof(buf), fourcc); av_log(avctx, AV_LOG_VERBOSE, "fourcc %s bpp %d " "r 0x%x g 0x%x b 0x%x a 0x%x\n", buf, bpp, r, g, b, a); if (gimp_tag) { av_get_codec_tag_string(buf, sizeof(buf), gimp_tag); av_log(avctx, AV_LOG_VERBOSE, "and GIMP-DDS tag %s\n", buf); if (ctx->compressed) avctx->pix_fmt = AV_PIX_FMT_RGBA; if (ctx->compressed) { switch (fourcc) { case MKTAG('D', 'X', 'T', '1'): ctx->tex_ratio = 8; ctx->tex_funct = ctx->texdsp.dxt1a_block; break; case MKTAG('D', 'X', 'T', '2'): ctx->tex_ratio = 16; ctx->tex_funct = ctx->texdsp.dxt2_block; break; case MKTAG('D', 'X', 'T', '3'): ctx->tex_ratio = 16; ctx->tex_funct = ctx->texdsp.dxt3_block; break; case MKTAG('D', 'X', 'T', '4'): ctx->tex_ratio = 16; ctx->tex_funct = ctx->texdsp.dxt4_block; break; case MKTAG('D', 'X', 'T', '5'): ctx->tex_ratio = 16; if (ycocg_scaled) ctx->tex_funct = ctx->texdsp.dxt5ys_block; else if (ycocg_classic) ctx->tex_funct = ctx->texdsp.dxt5y_block; else ctx->tex_funct = ctx->texdsp.dxt5_block; break; case MKTAG('R', 'X', 'G', 'B'): ctx->tex_ratio = 16; ctx->tex_funct = ctx->texdsp.dxt5_block; ctx->postproc = DDS_SWIZZLE_RXGB; normal_map = 0; break; case MKTAG('A', 'T', 'I', '1'): case MKTAG('B', 'C', '4', 'U'): ctx->tex_ratio = 8; ctx->tex_funct = ctx->texdsp.rgtc1u_block; break; case MKTAG('B', 'C', '4', 'S'): ctx->tex_ratio = 8; ctx->tex_funct = ctx->texdsp.rgtc1s_block; break; case MKTAG('A', 'T', 'I', '2'): ctx->tex_ratio = 16; ctx->tex_funct = ctx->texdsp.dxn3dc_block; break; case MKTAG('B', 'C', '5', 'U'): ctx->tex_ratio = 16; ctx->tex_funct = ctx->texdsp.rgtc2u_block; break; case MKTAG('B', 'C', '5', 'S'): ctx->tex_ratio = 16; ctx->tex_funct = ctx->texdsp.rgtc2s_block; break; case MKTAG('U', 'Y', 'V', 'Y'): ctx->compressed = 0; avctx->pix_fmt = AV_PIX_FMT_UYVY422; break; case MKTAG('Y', 'U', 'Y', '2'): ctx->compressed = 0; avctx->pix_fmt = AV_PIX_FMT_YUYV422; break; case MKTAG('P', '8', ' ', ' '): ctx->compressed = 0; ctx->paletted = 1; avctx->pix_fmt = AV_PIX_FMT_PAL8; break; case MKTAG('D', 'X', '1', '0'): dxgi = bytestream2_get_le32(gbc); bytestream2_skip(gbc, 4); bytestream2_skip(gbc, 4); array = bytestream2_get_le32(gbc); bytestream2_skip(gbc, 4); 2 if (array != 0) av_log(avctx, AV_LOG_VERBOSE, "Found array of size %d (ignored).\n", array); ctx->compressed = (dxgi >= 70) && (dxgi <= 84); av_log(avctx, AV_LOG_VERBOSE, "DXGI format %d.\n", dxgi); switch (dxgi) { case DXGI_FORMAT_R16G16B16A16_TYPELESS: case DXGI_FORMAT_R16G16B16A16_FLOAT: case DXGI_FORMAT_R16G16B16A16_UNORM: case DXGI_FORMAT_R16G16B16A16_UINT: case DXGI_FORMAT_R16G16B16A16_SNORM: case DXGI_FORMAT_R16G16B16A16_SINT: avctx->pix_fmt = AV_PIX_FMT_BGRA64; break; case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: avctx->colorspace = AVCOL_SPC_RGB; case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R8G8B8A8_UNORM: case DXGI_FORMAT_R8G8B8A8_UINT: case DXGI_FORMAT_R8G8B8A8_SNORM: case DXGI_FORMAT_R8G8B8A8_SINT: avctx->pix_fmt = AV_PIX_FMT_BGRA; break; case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: avctx->colorspace = AVCOL_SPC_RGB; case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_UNORM: avctx->pix_fmt = AV_PIX_FMT_RGBA; break; case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: avctx->colorspace = AVCOL_SPC_RGB; case DXGI_FORMAT_B8G8R8X8_TYPELESS: case DXGI_FORMAT_B8G8R8X8_UNORM: avctx->pix_fmt = AV_PIX_FMT_RGBA; break; case DXGI_FORMAT_B5G6R5_UNORM: avctx->pix_fmt = AV_PIX_FMT_RGB565LE; break; case DXGI_FORMAT_BC1_UNORM_SRGB: avctx->colorspace = AVCOL_SPC_RGB; case DXGI_FORMAT_BC1_TYPELESS: case DXGI_FORMAT_BC1_UNORM: ctx->tex_ratio = 8; ctx->tex_funct = ctx->texdsp.dxt1a_block; break; case DXGI_FORMAT_BC2_UNORM_SRGB: avctx->colorspace = AVCOL_SPC_RGB; case DXGI_FORMAT_BC2_TYPELESS: case DXGI_FORMAT_BC2_UNORM: ctx->tex_ratio = 16; ctx->tex_funct = ctx->texdsp.dxt3_block; break; case DXGI_FORMAT_BC3_UNORM_SRGB: avctx->colorspace = AVCOL_SPC_RGB; case DXGI_FORMAT_BC3_TYPELESS: case DXGI_FORMAT_BC3_UNORM: ctx->tex_ratio = 16; ctx->tex_funct = ctx->texdsp.dxt5_block; break; case DXGI_FORMAT_BC4_TYPELESS: case DXGI_FORMAT_BC4_UNORM: ctx->tex_ratio = 8; ctx->tex_funct = ctx->texdsp.rgtc1u_block; break; case DXGI_FORMAT_BC4_SNORM: ctx->tex_ratio = 8; ctx->tex_funct = ctx->texdsp.rgtc1s_block; break; case DXGI_FORMAT_BC5_TYPELESS: case DXGI_FORMAT_BC5_UNORM: ctx->tex_ratio = 16; ctx->tex_funct = ctx->texdsp.rgtc2u_block; break; case DXGI_FORMAT_BC5_SNORM: ctx->tex_ratio = 16; ctx->tex_funct = ctx->texdsp.rgtc2s_block; break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported DXGI format %d.\n", dxgi); return AVERROR_INVALIDDATA; break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported %s fourcc.\n", buf); return AVERROR_INVALIDDATA; } else if (ctx->paletted) { if (bpp == 8) { avctx->pix_fmt = AV_PIX_FMT_PAL8; } else { av_log(avctx, AV_LOG_ERROR, "Unsupported palette bpp %d.\n", bpp); return AVERROR_INVALIDDATA; } else { if (bpp == 8 && r == 0xff && g == 0 && b == 0 && a == 0) avctx->pix_fmt = AV_PIX_FMT_GRAY8; else if (bpp == 16 && r == 0xff && g == 0 && b == 0 && a == 0xff00) avctx->pix_fmt = AV_PIX_FMT_YA8; else if (bpp == 16 && r == 0xffff && g == 0 && b == 0 && a == 0) avctx->pix_fmt = AV_PIX_FMT_GRAY16LE; else if (bpp == 16 && r == 0xf800 && g == 0x7e0 && b == 0x1f && a == 0) avctx->pix_fmt = AV_PIX_FMT_RGB565LE; else if (bpp == 24 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0) avctx->pix_fmt = AV_PIX_FMT_BGR24; else if (bpp == 32 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0) avctx->pix_fmt = AV_PIX_FMT_BGRA; else if (bpp == 32 && r == 0xff && g == 0xff00 && b == 0xff0000 && a == 0) avctx->pix_fmt = AV_PIX_FMT_RGBA; else if (bpp == 32 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0xff000000) avctx->pix_fmt = AV_PIX_FMT_BGRA; else if (bpp == 32 && r == 0xff && g == 0xff00 && b == 0xff0000 && a == 0xff000000) avctx->pix_fmt = AV_PIX_FMT_RGBA; else { av_log(avctx, AV_LOG_ERROR, "Unknown pixel format " "[bpp %d r 0x%x g 0x%x b 0x%x a 0x%x].\n", bpp, r, g, b, a); return AVERROR_INVALIDDATA; if (alpha_exponent) ctx->postproc = DDS_ALPHA_EXP; else if (normal_map) ctx->postproc = DDS_NORMAL_MAP; else if (ycocg_classic && !ctx->compressed) ctx->postproc = DDS_RAW_YCOCG; else if (avctx->pix_fmt == AV_PIX_FMT_YA8) ctx->postproc = DDS_SWAP_ALPHA; switch (bpp) { case MKTAG('A', '2', 'X', 'Y'): ctx->postproc = DDS_SWIZZLE_A2XY; break; case MKTAG('x', 'G', 'B', 'R'): ctx->postproc = DDS_SWIZZLE_XGBR; break; case MKTAG('x', 'R', 'B', 'G'): ctx->postproc = DDS_SWIZZLE_XRBG; break; case MKTAG('R', 'B', 'x', 'G'): ctx->postproc = DDS_SWIZZLE_RBXG; break; case MKTAG('R', 'G', 'x', 'B'): ctx->postproc = DDS_SWIZZLE_RGXB; break; case MKTAG('R', 'x', 'B', 'G'): ctx->postproc = DDS_SWIZZLE_RXBG; break; case MKTAG('x', 'G', 'x', 'R'): ctx->postproc = DDS_SWIZZLE_XGXR; break; case MKTAG('A', '2', 'D', '5'): ctx->postproc = DDS_NORMAL_MAP; break; return 0;
1threat
How do you output a String, integer, and double from an array? : <p>I am trying to print out names with their associated information. I want their age, salary, insurance, etc. I am trying to use a for loop to accomplish this, but I'm obviously missing something. I also don't want it to total the ages, I want it individually. I just can't find a way to print all of my information.</p> <pre><code>public static double printArray(int[] noclue, String[] name, double[] age, double[] salary, double[] insurance, double[] expense, double[] savings) { int total = 0; String names = ""; for (int i = 0; i &lt; noclue.length; i++) { total = total + noclue[i] names = name[i]; } return total; return names; } } </code></pre> <p>In the main:</p> <pre><code>System.out.println(array.printArray(noclue, name, age, salary,insurance, expenses, savings)); </code></pre>
0debug
Python - ValueError: Cannot index with vector containing NA / NaN values : <p>I'm trying to get the average price of products containing any substrings from a wordlist from a dataframe. I've been able to do so with the following code on multiple spreadsheets - </p> <pre><code>dframe['Product'].fillna('', inplace=True) dframe['Price'].fillna(0, inplace=True) total_count = 0 total_price = 0 for word in ransomware_wordlist: mask = dframe.Product.str.contains(word, case=False) total_count += mask.sum() total_price += dframe.loc[mask, 'Price'].sum() average_price = total_price / total_count print(average_price) </code></pre> <p>However, one of the spreadsheets throws an error at line -</p> <pre><code>dframe['Product'].fillna('', inplace=True) </code></pre> <p>with</p> <pre><code>ValueError: cannot index with vector containing NA / NaN values </code></pre> <p>I fail to understand why <code>dframe['Product'].fillna('', inplace=True)</code> isn't handling this problem.</p> <p>In desperate need of some help! Thanks!</p>
0debug
dataframe.describe() suppress scientific notation : <p>How do I suppress scientific notation output from dataframe.describe(): </p> <pre><code>contrib_df["AMNT"].describe() count 1.979680e+05 mean 5.915134e+02 std 1.379618e+04 min -1.750000e+05 25% 4.000000e+01 50% 1.000000e+02 75% 2.500000e+02 max 3.000000e+06 Name: AMNT, dtype: float64 </code></pre> <p>My data is of type float64:</p> <pre><code>contrib_df["AMNT"].dtypes dtype('float64') </code></pre>
0debug
static BlockStats *bdrv_query_stats(const BlockDriverState *bs, bool query_backing) { BlockStats *s; s = g_malloc0(sizeof(*s)); if (bdrv_get_device_name(bs)[0]) { s->has_device = true; s->device = g_strdup(bdrv_get_device_name(bs)); } if (bdrv_get_node_name(bs)[0]) { s->has_node_name = true; s->node_name = g_strdup(bdrv_get_node_name(bs)); } s->stats = g_malloc0(sizeof(*s->stats)); if (bs->blk) { BlockAcctStats *stats = blk_get_stats(bs->blk); s->stats->rd_bytes = stats->nr_bytes[BLOCK_ACCT_READ]; s->stats->wr_bytes = stats->nr_bytes[BLOCK_ACCT_WRITE]; s->stats->rd_operations = stats->nr_ops[BLOCK_ACCT_READ]; s->stats->wr_operations = stats->nr_ops[BLOCK_ACCT_WRITE]; s->stats->failed_rd_operations = stats->failed_ops[BLOCK_ACCT_READ]; s->stats->failed_wr_operations = stats->failed_ops[BLOCK_ACCT_WRITE]; s->stats->failed_flush_operations = stats->failed_ops[BLOCK_ACCT_FLUSH]; s->stats->invalid_rd_operations = stats->invalid_ops[BLOCK_ACCT_READ]; s->stats->invalid_wr_operations = stats->invalid_ops[BLOCK_ACCT_WRITE]; s->stats->invalid_flush_operations = stats->invalid_ops[BLOCK_ACCT_FLUSH]; s->stats->rd_merged = stats->merged[BLOCK_ACCT_READ]; s->stats->wr_merged = stats->merged[BLOCK_ACCT_WRITE]; s->stats->flush_operations = stats->nr_ops[BLOCK_ACCT_FLUSH]; s->stats->wr_total_time_ns = stats->total_time_ns[BLOCK_ACCT_WRITE]; s->stats->rd_total_time_ns = stats->total_time_ns[BLOCK_ACCT_READ]; s->stats->flush_total_time_ns = stats->total_time_ns[BLOCK_ACCT_FLUSH]; s->stats->has_idle_time_ns = stats->last_access_time_ns > 0; if (s->stats->has_idle_time_ns) { s->stats->idle_time_ns = block_acct_idle_time_ns(stats); } } s->stats->wr_highest_offset = bs->wr_highest_offset; if (bs->file) { s->has_parent = true; s->parent = bdrv_query_stats(bs->file->bs, query_backing); } if (query_backing && bs->backing) { s->has_backing = true; s->backing = bdrv_query_stats(bs->backing->bs, query_backing); } return s; }
1threat
Change order of (sub-) strings in dataframe column based on white spaces : I have a dataframe with a column in python: ``` df columnA Apple Banana Orange Citron Pineapple ``` How can I reserve the order of the substrings based on the white spaces? The outcome should be: ``` columnA Banana Apple Pineapple Citron Orange ``` Right now, I am only using: ``` df['columnA'] = df['columnA'].replace(r'(\s+).(\s+).(\s+)',r'\3\2\1',regex=True) ``` but this only works if I know the number of substrings, this I do not know upfront.
0debug
How to continue programm after first iteration with input : After the end of the first round of my program (Collatz function) i want my program to continue to calculate from the previous result I wrote a program with the possibility of one iteration, which starts from the input def collatz(number): if number % 2 == 0: #parity conditions value return number // 2 if number % 2 == 1: #parity oddness value return 3 * number + 1 result = 5 while True: print ('Type your number') result = int(input()) print (collatz(result))
0debug
static int find_vdi_name(BDRVSheepdogState *s, char *filename, uint32_t snapid, char *tag, uint32_t *vid, int for_snapshot) { int ret, fd; SheepdogVdiReq hdr; SheepdogVdiRsp *rsp = (SheepdogVdiRsp *)&hdr; unsigned int wlen, rlen = 0; char buf[SD_MAX_VDI_LEN + SD_MAX_VDI_TAG_LEN]; fd = connect_to_sdog(s->addr, s->port); if (fd < 0) { return fd; } memset(buf, 0, sizeof(buf)); strncpy(buf, filename, SD_MAX_VDI_LEN); strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN); memset(&hdr, 0, sizeof(hdr)); if (for_snapshot) { hdr.opcode = SD_OP_GET_VDI_INFO; } else { hdr.opcode = SD_OP_LOCK_VDI; } wlen = SD_MAX_VDI_LEN + SD_MAX_VDI_TAG_LEN; hdr.proto_ver = SD_PROTO_VER; hdr.data_length = wlen; hdr.snapid = snapid; hdr.flags = SD_FLAG_CMD_WRITE; ret = do_req(fd, (SheepdogReq *)&hdr, buf, &wlen, &rlen); if (ret) { goto out; } if (rsp->result != SD_RES_SUCCESS) { error_report("cannot get vdi info, %s, %s %d %s", sd_strerror(rsp->result), filename, snapid, tag); if (rsp->result == SD_RES_NO_VDI) { ret = -ENOENT; } else { ret = -EIO; } goto out; } *vid = rsp->vdi_id; ret = 0; out: closesocket(fd); return ret; }
1threat
If input says x and y then print : Hi I'm trying to get this example code to work: a = ("good ") b = ("morning") z = input("Hi: ") z if z == "hello": print("good day!") elif z == a and b: print("Good Night") else: print("nope") so I want it to print "Good Night" if the typed input is good morning (a and b) but it's not doing that, instead it's printing "nope", what's the mistake I'm doing?
0debug
docker version number confusion: 17.06 vs 1.13? : <p>I am confused by the version number of <code>docker</code></p> <p>Some documentation refers to version numbers like <code>17.06</code> E.g. (from <a href="https://docs.docker.com/engine/admin/volumes/volumes/" rel="noreferrer">here</a>)</p> <blockquote> <p>However, starting with Docker 17.06, you can also use <code>--mount</code> with standalone containers</p> </blockquote> <p>But some other documentation refers to version number like <code>1.13</code> E.g. (from <a href="https://docs.docker.com/get-started/#container-diagram" rel="noreferrer">here</a>)</p> <blockquote> <p>Note: version 1.13 or higher is required</p> </blockquote> <p>Was the version numbering convention changed at some point in time?</p>
0debug
alert('Hello ' + user_input);
1threat
Regex match any character except given prefix : <p>I am looking for a regex pattern with can do as the title, it's mean with 3 given prefixs "#,@,+", the following character will be ignore until it is whitespace. Example:</p> <blockquote> <p>"+20 @facebook #hashtag with my love"</p> </blockquote> <p>will return</p> <blockquote> <p>"with my love"</p> </blockquote>
0debug
Toggle pages backgroundcolor in html/css : <p>On my HTML/CSS page I need to have a switch to toggle the background color and text color. (for example black theme to white theme). Is there any way to do this?</p>
0debug
How to play flv video on mobile web browsers? : <p>Is it possible to view .flv format video movies with standard android web browsers fromm my web page? I tried to watch using videojs, but get an error "no compatible source was found for this video". </p>
0debug
static void mips_cpu_realizefn(DeviceState *dev, Error **errp) { MIPSCPU *cpu = MIPS_CPU(dev); MIPSCPUClass *mcc = MIPS_CPU_GET_CLASS(dev); cpu_reset(CPU(cpu)); mcc->parent_realize(dev, errp); }
1threat
Is there a way to make .NET Core GetHashCode deterministic : <p>I just wasted few hours of debugging before realizing that contrary to .NET, in .NET Core, GetHashCode returns a different value every time you run your code. I totally understand the rationale for this. Relying on hash code values is a very bad idea (like serializing them). I even remember that internal builds of .NET at Microsoft (prior to Core) would change the behavior of GetHashCode for every build so that nobody gets too comfortable with it.</p> <p>Having said all this, I’m currently debugging complex code that makes heavy use of GetHashCode. I know the bug is my own doing and has nothing to do with GetHashCode but each time I run it, it fails elsewhere. Very annoying. Is there a way to force GetHashCode to behave like in .NET (while I’m debugging) without having to write my own hash function and having to replace it everywhere in my code?</p>
0debug
How to test navigation via Navigator in Flutter : <p>Let's say, I have a test for a screen in Flutter using <code>WidgetTester</code>. There is a button, which executes a navigation via <code>Navigator</code>. I would like to test behavior of that button. </p> <p><strong>Widget/Screen</strong></p> <pre><code>class MyScreen extends StatefulWidget { MyScreen({Key key}) : super(key: key); @override _MyScreenState createState() =&gt; _MyScreenScreenState(); } class _MyScreenState extends State&lt;MyScreen&gt; { @override Widget build(BuildContext context) { return Scaffold( body: Center( child: RaisedButton( onPressed: () { Navigator.of(context).pushNamed("/nextscreen"); }, child: Text(Strings.traktTvUrl) ) ) ); } } </code></pre> <p><strong>Test</strong></p> <pre><code>void main() { testWidgets('Button is present and triggers navigation after tapped', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp(home: MyScreen())); expect(find.byType(RaisedButton), findsOneWidget); await tester.tap(find.byType(RaisedButton)); //how to test navigator? }); } </code></pre> <p>I there a proper way how to check, that Navigator was called? Or is there a way to mock and replace navigator?</p> <p>Pleas note, that code above will actually fail with an exception, because there is no named route <code>'/nextscreen'</code> declared in application. That's simple to solve and you don't need to point it out.</p> <p>My main concern is how to correctly approach this test scenario in Flutter.</p>
0debug
How can I echo it properly? HTML+PHP issue : <p>I have a problem with this line,is there any solution for a line which must contain both single and double quotation marks?</p> <pre><code>echo "&lt;a href='/ad/.$row['id_ad']'&gt;".$row['title']; </code></pre> <p>I get this error:</p> <pre><code>Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) </code></pre>
0debug
static void ne2000_cleanup(NetClientState *nc) { NE2000State *s = qemu_get_nic_opaque(nc); s->nic = NULL; }
1threat
How can I check if a string with a comma if bigger than 232.68 : I have an input with a decimal number (comma used instead of a dot): <input id="amount" name="amount" maxlength="7" type="text" value="0,00" /> I want to check if the amount is higher than 232.68 I tested: $('#amount').change(function(){ var myamount = parseFloat($("#amount").text().replace(',', '.')); if(myamount > 232.68){ alert("The amount is too high!"); } }) 1. I want to replace the comma with a dot only in the var 2. I want to check it the amount is higher than 232.68 3. I want to alert if higher than 232.68
0debug
Swift 3: Cannot convert value of type 'NSMutableDictionary' to expected argument type '[AnyHashable : Any]!' : <p>This code worked before Swift 3. (Curse you Swift 3!)</p> <p>Now it's showing this error against the <code>Flurry.logEvent(eventName, withParameters: userData!)</code> line:</p> <blockquote> <p>Cannot convert value of type 'NSMutableDictionary' to expected argument type '[AnyHashable : Any]!'</p> </blockquote> <p>Casting <code>userData!</code> to <code>[AnyHashable : Any]</code> produces this error:</p> <blockquote> <p>Cannot convert value of type 'NSMutableDictionary' to type '[AnyHashable : Any]' in coercion</p> </blockquote> <pre><code>func logEvent(_ eventName: String, userData: NSMutableDictionary?) { // Use &lt;userData&gt; or create new one? var userData = userData if userData == nil { userData = NSMutableDictionary() } // Set base properties userData!.setObject(gUser.tofus.count, forKey: "Num Tofus" as NSCopying) userData!.setObject(gUser.getLifetimeTofus(), forKey: "Num Lifetime Tofus" as NSCopying) // Call Flurry DispatchQueue.main.async { Flurry.logEvent(eventName, withParameters: userData! as [AnyHashable:Any]) } } </code></pre> <p>What's the right syntax for Swift 3?</p>
0debug
Equivalent of C#'s Array.GetUpperBound() in java : <p>I am trying to translate C#'s <code>GetUpperBound()</code> in java. Let's say we have a 2D array in java:</p> <pre><code>int[][] array = new int[2][3] { {1, 2, 3}, {4, 5, 6} }; </code></pre> <p>I understand that in C# <code>array.GetUpperBound(0)</code> would return <code>1</code> (the last index of the first dimension) and <code>array.GetUpperBound(1)</code> would return <code>2</code> (the last index of the second dimension).</p> <p>How someone could implement this functionality in java? Is C#'s <code>array.GetUpperBound(0)</code> the same as Java's <code>array[0].length - 1</code> or <code>array.length - 1</code>?</p>
0debug
Do I need to call next() after res.send()? : <p>If I called <code>res.send()</code>, but didn't call <code>next()</code>:</p> <ol> <li>Any middleware after this middleware won't be executed.</li> <li>If this middleware is not the last middleware, then the request will "hang" forever, and will not be garbage collected, because It is still waiting for the <code>next()</code> to be called.</li> </ol> <p>The above is my attempt to argue that I should always call <code>next()</code>, is it true?</p>
0debug
Cannot run the macro 'Main'. error occurred in "invoke vba" uipath : I am trying to retrieve some cell addresses from excel sheet with uipath invoke VBA activity. I am new to VB script, here i have written a function to retrieve cell address array and i have written a sub procedure to call that function. I am calling the sub in uipath activity named' invoke VBA. So when i run this it says > Invoke VBA : Cannot run the macro 'Main'. The macro may not be > available in this workbook or all macros may be disabled. So Please help me to get over with this? Sub Main(Amount As Integer) Call findcellFunction(Amount) End Sub Function findcellFunction(Amount As Integer)As Collection On Error Resume Next Dim rngX As Range Dim WS As Worksheet Dim datax As Range Dim cellAddress As Variant Dim index As Integer Dim iTotal As Integer Dim CellArray iTotal = 0 Set CellArray = New Collection 'Iterate until all cell values are found For index=1 To Amount Set rngX = Worksheets("rptBOMColorPrint").Range("A1:EZ50").Find("Colour Name", lookat:=xlPart) If Not rngX Is Nothing Then MsgBox "Found at " & rngX.Address CellArray.Add rngX.Address End If Cells(rngX.Row,rngX.Column).Delete iTotel =iTotal + index Next index 'shows list that has been populated with cell addresses For Each cellAddress In CellArray MsgBox "list populated " & cellAddress Range(cellAddress).Value = "Colour Name" Next CellArray = findcellFunction(Amount) End Function
0debug
looping through javascript object : <p>How do you access properties of a javascript object like the following? Please explain each step if possible.</p> <pre><code>var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", "number": "0994372684", "likes": ["Hogwarts", "Magic", "Hagrid"] }, { "firstName": "Sherlock", "lastName": "Holmes", "number": "0487345643", "likes": ["Intriguing Cases", "Violin"] }, { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] } ]; function lookUp(firstName, prop){ //code here } </code></pre> <p>I would like to be able to access the name of a contact. So for example</p> <pre><code> lookUp("Akira", "likes") </code></pre> <p>should give me the name and the likes. And also lookUp("Drew", "like") should give me back "No such contact".</p> <p>Thanks a lot in advance!</p>
0debug