problem
stringlengths
26
131k
labels
class label
2 classes
int kvm_has_pit_state2(void) { return 0; }
1threat
static void gen_slbmte(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); return; } gen_helper_store_slb(cpu_env, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); #endif }
1threat
static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int buf_size2) { MpegEncContext *s = avctx->priv_data; int mb_count, mb_pos, left, start_mb_x; init_get_bits(&s->gb, buf, buf_size*8); if(s->codec_id ==CODEC_ID_RV10) mb_count = rv10_decode_picture_header(s); else mb_count = rv20_decode_picture_header(s); if (mb_count < 0) { av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n"); return -1; } if (s->mb_x >= s->mb_width || s->mb_y >= s->mb_height) { av_log(s->avctx, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y); return -1; } mb_pos = s->mb_y * s->mb_width + s->mb_x; left = s->mb_width * s->mb_height - mb_pos; if (mb_count > left) { av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n"); return -1; } if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) { if(s->current_picture_ptr){ ff_er_frame_end(s); ff_MPV_frame_end(s); s->mb_x= s->mb_y = s->resync_mb_x = s->resync_mb_y= 0; } if(ff_MPV_frame_start(s, avctx) < 0) return -1; ff_er_frame_start(s); } else { if (s->current_picture_ptr->f.pict_type != s->pict_type) { av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n"); return -1; } } av_dlog(avctx, "qscale=%d\n", s->qscale); if(s->codec_id== CODEC_ID_RV10){ if(s->mb_y==0) s->first_slice_line=1; }else{ s->first_slice_line=1; s->resync_mb_x= s->mb_x; } start_mb_x= s->mb_x; s->resync_mb_y= s->mb_y; if(s->h263_aic){ s->y_dc_scale_table= s->c_dc_scale_table= ff_aic_dc_scale_table; }else{ s->y_dc_scale_table= s->c_dc_scale_table= ff_mpeg1_dc_scale_table; } if(s->modified_quant) s->chroma_qscale_table= ff_h263_chroma_qscale_table; ff_set_qscale(s, s->qscale); s->rv10_first_dc_coded[0] = 0; s->rv10_first_dc_coded[1] = 0; s->rv10_first_dc_coded[2] = 0; s->block_wrap[0]= s->block_wrap[1]= s->block_wrap[2]= s->block_wrap[3]= s->b8_stride; s->block_wrap[4]= s->block_wrap[5]= s->mb_stride; ff_init_block_index(s); for(s->mb_num_left= mb_count; s->mb_num_left>0; s->mb_num_left--) { int ret; ff_update_block_index(s); av_dlog(avctx, "**mb x=%d y=%d\n", s->mb_x, s->mb_y); s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; ret=ff_h263_decode_mb(s, s->block); if (ret != SLICE_ERROR && s->gb.size_in_bits < get_bits_count(&s->gb) && 8*buf_size2 >= get_bits_count(&s->gb)){ av_log(avctx, AV_LOG_DEBUG, "update size from %d to %d\n", s->gb.size_in_bits, 8*buf_size2); s->gb.size_in_bits= 8*buf_size2; ret= SLICE_OK; } if (ret == SLICE_ERROR || s->gb.size_in_bits < get_bits_count(&s->gb)) { av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y); return -1; } if(s->pict_type != AV_PICTURE_TYPE_B) ff_h263_update_motion_val(s); ff_MPV_decode_mb(s, s->block); if(s->loop_filter) ff_h263_loop_filter(s); if (++s->mb_x == s->mb_width) { s->mb_x = 0; s->mb_y++; ff_init_block_index(s); } if(s->mb_x == s->resync_mb_x) s->first_slice_line=0; if(ret == SLICE_END) break; } ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END); return s->gb.size_in_bits; }
1threat
accept number of files html : I use these codes for creating a form which accept one or more files. not zero files. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Problem</title> </head> <body> <!-- Insert form here --> <form id="uploader"> <input type="file"> <button type="submit"></button> </form> </body> </html> but it's not working. How can i do that? thanks a lot
0debug
What is the best language to use for coding a bot for Disord? : <p>I do not have experience with any particular language, but I wish to create a fetching Bot for my discord server.</p> <p>I want people on my server to be able to type: !CharacterName, and have a bot respond with that character's stats and attributes. </p> <p>What is the best coding language to use for the creation of such a bot, and do you know of any tutorials for it?</p> <p>Thank you for the help in advance.</p>
0debug
What does putting "value:" before a string in C# do? : <p>When I write something like <code>Console.WriteLine("Insert 2 numbers");</code></p> <p>The Quick Actions and Refactorings says "Add argument name 'value'"</p> <p><code>Console.WriteLine(value: "Insert 2 numbers");</code></p> <p>What difference does this make?</p>
0debug
AVFilterFormats *ff_make_format_list(const int *fmts) { AVFilterFormats *formats; int count; for (count = 0; fmts[count] != -1; count++) ; formats = av_mallocz(sizeof(*formats)); if (count) formats->formats = av_malloc(sizeof(*formats->formats) * count); formats->nb_formats = count; memcpy(formats->formats, fmts, sizeof(*formats->formats) * count); return formats; }
1threat
Read a structured txt file in r : I am still on a basic beginner level with r. I am currently working on some natural language stuff and I use the ProQuest Newsstand database. Even though the database allows to download txt files, I don't need everything they provide. The files you can download there look like this: ############################################################################### ____________________________________________________________ Report Information from ProQuest 16 July 2016 09:58 ____________________________________________________________ ____________________________________________________________ Inhaltsverzeichnis 1. Savills cracks Granite deal to establish US presence ; COMMERCIAL PROPERTY ____________________________________________________________ Dokument 1 von 1 Savills cracks Granite deal to establish US presence ; COMMERCIAL PROPERTY http:... Kurzfassung: Savills said that as part of its plans to build... Links: ... Volltext: Property agency Savills yesterday snapped up US real estate banking firm Granite Partners... Unternehmen/Organisation: Name: Granite Partners LP; NAICS: 525910 Titel: Savills cracks Granite deal to establish US presence; COMMERCIAL PROPERTY:   [FIRST Edition] Autor: Steve Pain Commercial Property Editor Titel der Publikation: Birmingham Post Seiten: 30 Seitenanzahl: 0 Erscheinungsjahr: 2007 Publikationsdatum: Aug 2, 2007 Jahr: 2007 Bereich: Business Herausgeber: Mirror Regional Newspapers Verlagsort: Birmingham (UK) Publikationsland: United Kingdom Publikationsthema: General Interest Periodicals--Great Britain Quellentyp: Newspapers Publikationssprache: English Dokumententyp: NEWSPAPER ProQuest-Dokument-ID: 324215031 Dokument-URL: ... Copyright: (Copyright 2007 Birmingham Post and Mail Ltd.) Zuletzt aktualisiert: 2010-06-19 Datenbank: UK Newsstand ____________________________________________________________ Kontaktieren Sie uns unter: http... Copyright © 2016 ProQuest LLC. Alle Rechte vorbehalten. Allgemeine Geschäftsbedingungen: ... ############################################################################### What I need is a way to extract only the full text to a csv file. The reason is, when I download hundreds of articles within one file it is quite difficult to copy and paste them manually and I think the file is quite structured. However, the length of text varies. Nevertheless, one could use the next header after the full text as a stop sign (I guess). Is there any way to do this? I really would appreciate some help. Kind regards, Steffen
0debug
How to create Azure AD user programmatically? : <p>I understand there is azure portal to manage groups, user and etc.</p> <p>Are there any ways to do it programmatically (either using web-api or sdk in C#)?</p> <p>Thanks in advance.</p>
0debug
image with id in its name? image-name-93943.jpg : <p>I have a website that I have some news there and photos.</p> <p>So, for example:</p> <blockquote> <p>Barack Obama out in NY.</p> </blockquote> <p>for this I have some pictures:</p> <pre><code>mywebsite.com/barack-obama-out-in-NY-157475445.jpg mywebsite.com/barack-obama-out-in-NY-257475445.jpg mywebsite.com/barack-obama-out-in-NY-357475445.jpg </code></pre> <p>image title and after it the image number (1, 2, 3) with post_id (57475445).</p> <p>Is it ok for SEO or the id in the image name could be a bad practise?</p>
0debug
static void draw_bar(TestSourceContext *test, const uint8_t color[4], unsigned x, unsigned y, unsigned w, unsigned h, AVFrame *frame) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); uint8_t *p, *p0; int plane; x = FFMIN(x, test->w - 1); y = FFMIN(y, test->h - 1); w = FFMIN(w, test->w - x); h = FFMIN(h, test->h - y); av_assert0(x + w <= test->w); av_assert0(y + h <= test->h); for (plane = 0; frame->data[plane]; plane++) { const int c = color[plane]; const int linesize = frame->linesize[plane]; int i, px, py, pw, ph; if (plane == 1 || plane == 2) { px = x >> desc->log2_chroma_w; pw = w >> desc->log2_chroma_w; py = y >> desc->log2_chroma_h; ph = h >> desc->log2_chroma_h; } else { px = x; pw = w; py = y; ph = h; } p0 = p = frame->data[plane] + py * linesize + px; memset(p, c, pw); p += linesize; for (i = 1; i < ph; i++, p += linesize) memcpy(p, p0, pw); } }
1threat
static MemoryRegion *acpi_add_rom_blob(AcpiBuildState *build_state, GArray *blob, const char *name, uint64_t max_size) { return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1, name, virt_acpi_build_update, build_state); }
1threat
Reference c# class library in my Azure Function : <p>Is it possible to reference a c# class library in an Azure Function visual studio project?</p> <p>I am aware of the possibilities to reference external libraries and Nuget packages. Currently I am using shared .csx files as described <a href="https://docs.microsoft.com/nl-nl/azure/azure-functions/functions-reference-csharp#reusing-csx-code" rel="noreferrer">here</a>. These .csx files now contain a copy of my DTO's which are also used in the Service Agents which I use to consume the functions.</p> <p>Ideally I want to add a reference in Visual Studio from a Function to a class library project and that Visual Studio is adding this dll to the bin folder.</p>
0debug
Use custom domain for Google Cloud Function : <p>I can't see any option anywhere to set up a custom domain for my Google Cloud Function when using HTTP Triggers. Seems like a fairly major omission. Is there any way to use a custom domain instead of their <code>location-project.cloudfunctions.net</code> domain or some workaround to the same effect?</p> <p>I read an article suggesting using a CDN in front of the function with the function URL specified as the pull zone. This would work, but would introduce unnecessary cost - and in my scenario none of the content is able to be cached so using a CDN is far from ideal.</p>
0debug
Set default error level to WARN : <p>It seems that default error level for all eslint rules are <code>"error"</code>. This is annoying as my app doesn't compile even for an omitted semicolon. </p> <p>How can I set it to <code>"warn"</code> so that my app compiles but shows warnings?</p> <p>I know I can set each rule to warn manually but I'd prefer to do it globally. In the official docs I haven't found such option.</p> <p>This my config in <code>.eslingtrc.js</code>:</p> <pre><code>// http://eslint.org/docs/user-guide/configuring module.exports = { root: true, parser: 'babel-eslint', parserOptions: { sourceType: 'module' }, env: { browser: true, }, // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style extends: 'standard', // required to lint *.vue files plugins: [ 'html' ], // add your custom rules here 'rules': { // allow paren-less arrow functions 'arrow-parens': 0, 'indent': 1, // allow async-await 'generator-star-spacing': 0, // allow debugger during development 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, 'padded-blocks': [1, {classes: 'always'}], 'semi': 1 } } </code></pre>
0debug
What is the expected syntax for http_request put request : http_request 'some request' do url 'https://'"#{node[:chef][:node_name]}"'/v1/xyz' headers ({ 'AUTHORIZATION' => "Basic #{Base64.encode64('#{node[\'user\']}:#{node[\'password\']')}", }) action :get end
0debug
int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice) { MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp; int mmco_index = 0, i = 0; assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count); if (h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count && !(FIELD_PICTURE(h) && !h->first_field && h->cur_pic_ptr->reference)) { mmco[0].opcode = MMCO_SHORT2UNUSED; mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num; mmco_index = 1; if (FIELD_PICTURE(h)) { mmco[0].short_pic_num *= 2; mmco[1].opcode = MMCO_SHORT2UNUSED; mmco[1].short_pic_num = mmco[0].short_pic_num + 1; mmco_index = 2; } } if (first_slice) { h->mmco_index = mmco_index; } else if (!first_slice && mmco_index >= 0 && (mmco_index != h->mmco_index || (i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) { av_log(h->avctx, AV_LOG_ERROR, "Inconsistent MMCO state between slices [%d, %d, %d]\n", mmco_index, h->mmco_index, i); return AVERROR_INVALIDDATA; } return 0; }
1threat
Python List comprehension execution order : <pre><code>matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] squared = [[x**2 for x in row] for row in matrix] print(squared) </code></pre> <p>In the preceding data structure and list comprehension, what is the order of execution? </p> <p>Visually it appears to process from right to left. Considering the nested list first has to be access before each of its individual items can be squared.</p>
0debug
int qemu_input_key_value_to_scancode(const KeyValue *value, bool down, int *codes) { int keycode = qemu_input_key_value_to_number(value); int count = 0; if (value->type == KEY_VALUE_KIND_QCODE && value->u.qcode == Q_KEY_CODE_PAUSE) { int v = down ? 0 : 0x80; codes[count++] = 0xe1; codes[count++] = 0x1d | v; codes[count++] = 0x45 | v; return count; } if (keycode & SCANCODE_GREY) { codes[count++] = SCANCODE_EMUL0; keycode &= ~SCANCODE_GREY; } if (!down) { keycode |= SCANCODE_UP; } codes[count++] = keycode; return count; }
1threat
static void rtsp_close_streams(RTSPState *rt) { int i; RTSPStream *rtsp_st; for(i=0;i<rt->nb_rtsp_streams;i++) { rtsp_st = rt->rtsp_streams[i]; if (rtsp_st) { if (rtsp_st->transport_priv) { if (rt->transport == RTSP_TRANSPORT_RDT) ff_rdt_parse_close(rtsp_st->transport_priv); else rtp_parse_close(rtsp_st->transport_priv); } if (rtsp_st->rtp_handle) url_close(rtsp_st->rtp_handle); if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context) rtsp_st->dynamic_handler->close(rtsp_st->dynamic_protocol_context); } } av_free(rt->rtsp_streams); if (rt->asf_ctx) { av_close_input_stream (rt->asf_ctx); rt->asf_ctx = NULL; } av_freep(&rt->auth_b64); }
1threat
Differentiate between error and standard terminal log with ffmpeg - nodejs : <p>I'm using <code>ffmpeg</code> in node js. Both the standard terminal output and the error seems to be sent to stdout, so I don't know how to differentiate between error and success... Here's my code:</p> <pre><code>var convertToMp3 = function(filePath) { var ffmpeg = child_process.spawn('ffmpeg',['-i', filePath, '-y', 'output.mp3']); var err = ''; ffmpeg.stderr .on('data', function(c) { err += c; }) .on('end', function() { console.log('stderr:', err); }); var d = ''; ffmpeg.stdout .on('data', function(c){d +=c;}) .on('end', function(){ console.log('stdout', d); }); } </code></pre> <p>wether the conversion succeeds or fails, stdout is empty and stderr contains what I'd get if I'd run the corresponding command in the terminal</p>
0debug
Why don't complex-number literals work in clang? : <p>When I run this code <a href="https://ideone.com/HdviA2">on ideone.com</a>, it prints <code>(2,3)</code>:</p> <pre><code>#include &lt;iostream&gt; #include &lt;complex&gt; int main() { std::complex&lt;double&gt; val = 2 + 3i; std::cout &lt;&lt; val &lt;&lt; std::endl; return 0; } </code></pre> <p>But when I use clang on macOS 10.11.6, I get no errors or warnings, but the output is <code>(2,0)</code>:</p> <pre class="lang-none prettyprint-override"><code>$ clang --version Apple LLVM version 7.3.0 (clang-703.0.31) Target: x86_64-apple-darwin15.6.0 $ clang -lc++ test.cpp &amp;&amp; ./a.out (2,0) </code></pre> <p>What happened to the imaginary part? Am I doing something wrong?</p>
0debug
static void coroutine_delete(Coroutine *co) { if (CONFIG_COROUTINE_POOL) { qemu_mutex_lock(&pool_lock); if (pool_size < pool_max_size) { QSLIST_INSERT_HEAD(&pool, co, pool_next); co->caller = NULL; pool_size++; qemu_mutex_unlock(&pool_lock); return; } qemu_mutex_unlock(&pool_lock); } qemu_coroutine_delete(co); }
1threat
static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { BC_STATUS ret; BC_DTS_STATUS decoder_status; CopyRet rec_ret; CHDContext *priv = avctx->priv_data; HANDLE dev = priv->dev; int len = avpkt->size; uint8_t pic_type = 0; av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: decode_frame\n"); if (len) { int32_t tx_free = (int32_t)DtsTxFreeSize(dev); if (priv->parser) { uint8_t *pout; int psize = len; H264Context *h = priv->parser->priv_data; while (psize) ret = av_parser_parse2(priv->parser, avctx, &pout, &psize, avpkt->data, len, avctx->pkt->pts, avctx->pkt->dts, len - psize); av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: parser picture type %d\n", h->s.picture_structure); pic_type = h->s.picture_structure; } if (len < tx_free - 1024) { uint64_t pts = opaque_list_push(priv, avctx->pkt->pts, pic_type); if (!pts) { return AVERROR(ENOMEM); } av_log(priv->avctx, AV_LOG_VERBOSE, "input \"pts\": %"PRIu64"\n", pts); ret = DtsProcInput(dev, avpkt->data, len, pts, 0); if (ret == BC_STS_BUSY) { av_log(avctx, AV_LOG_WARNING, "CrystalHD: ProcInput returned busy\n"); usleep(BASE_WAIT); return AVERROR(EBUSY); } else if (ret != BC_STS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "CrystalHD: ProcInput failed: %u\n", ret); return -1; } avctx->has_b_frames++; } else { av_log(avctx, AV_LOG_WARNING, "CrystalHD: Input buffer full\n"); len = 0; } } else { av_log(avctx, AV_LOG_INFO, "CrystalHD: No more input data\n"); } if (priv->skip_next_output) { av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Skipping next output.\n"); priv->skip_next_output = 0; avctx->has_b_frames--; return len; } ret = DtsGetDriverStatus(dev, &decoder_status); if (ret != BC_STS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "CrystalHD: GetDriverStatus failed\n"); return -1; } if (priv->output_ready < 2) { if (decoder_status.ReadyListCount != 0) priv->output_ready++; usleep(BASE_WAIT); av_log(avctx, AV_LOG_INFO, "CrystalHD: Filling pipeline.\n"); return len; } else if (decoder_status.ReadyListCount == 0) { usleep(BASE_WAIT); priv->decode_wait += WAIT_UNIT; av_log(avctx, AV_LOG_INFO, "CrystalHD: No frames ready. Returning\n"); return len; } do { rec_ret = receive_frame(avctx, data, data_size, 0); if (rec_ret == RET_OK && *data_size == 0) { av_log(avctx, AV_LOG_VERBOSE, "Returning after first field.\n"); avctx->has_b_frames--; } else if (rec_ret == RET_COPY_NEXT_FIELD) { av_log(avctx, AV_LOG_VERBOSE, "Trying to get second field.\n"); while (1) { usleep(priv->decode_wait); ret = DtsGetDriverStatus(dev, &decoder_status); if (ret == BC_STS_SUCCESS && decoder_status.ReadyListCount > 0) { rec_ret = receive_frame(avctx, data, data_size, 1); if ((rec_ret == RET_OK && *data_size > 0) || rec_ret == RET_ERROR) break; } } av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Got second field.\n"); } else if (rec_ret == RET_SKIP_NEXT_COPY) { av_log(avctx, AV_LOG_VERBOSE, "Don't output on next decode call.\n"); priv->skip_next_output = 1; } } while (rec_ret == RET_COPY_AGAIN); usleep(priv->decode_wait); return len; }
1threat
static void timer_start(SpiceTimer *timer, uint32_t ms) { qemu_mod_timer(timer->timer, qemu_get_clock(rt_clock) + ms); }
1threat
static int vhost_net_set_vnet_endian(VirtIODevice *dev, NetClientState *peer, bool set) { int r = 0; if (virtio_has_feature(dev, VIRTIO_F_VERSION_1) || (virtio_legacy_is_cross_endian(dev) && !virtio_is_big_endian(dev))) { r = qemu_set_vnet_le(peer, set); if (r) { error_report("backend does not support LE vnet headers"); } } else if (virtio_legacy_is_cross_endian(dev)) { r = qemu_set_vnet_be(peer, set); if (r) { error_report("backend does not support BE vnet headers"); } } return r; }
1threat
static int xen_pt_register_regions(XenPCIPassthroughState *s) { int i = 0; XenHostPCIDevice *d = &s->real_device; for (i = 0; i < PCI_ROM_SLOT; i++) { XenHostPCIIORegion *r = &d->io_regions[i]; uint8_t type; if (r->base_addr == 0 || r->size == 0) { continue; } s->bases[i].access.u = r->base_addr; if (r->type & XEN_HOST_PCI_REGION_TYPE_IO) { type = PCI_BASE_ADDRESS_SPACE_IO; } else { type = PCI_BASE_ADDRESS_SPACE_MEMORY; if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH) { type |= PCI_BASE_ADDRESS_MEM_PREFETCH; } if (r->type & XEN_HOST_PCI_REGION_TYPE_MEM_64) { type |= PCI_BASE_ADDRESS_MEM_TYPE_64; } } memory_region_init_io(&s->bar[i], OBJECT(s), &ops, &s->dev, "xen-pci-pt-bar", r->size); pci_register_bar(&s->dev, i, type, &s->bar[i]); XEN_PT_LOG(&s->dev, "IO region %i registered (size=0x%08"PRIx64 " base_addr=0x%08"PRIx64" type: %#x)\n", i, r->size, r->base_addr, type); } if (d->rom.base_addr && d->rom.size) { uint32_t bar_data = 0; if (xen_host_pci_get_long(d, PCI_ROM_ADDRESS, &bar_data)) { return 0; } if ((bar_data & PCI_ROM_ADDRESS_MASK) == 0) { bar_data |= d->rom.base_addr & PCI_ROM_ADDRESS_MASK; xen_host_pci_set_long(d, PCI_ROM_ADDRESS, bar_data); } s->bases[PCI_ROM_SLOT].access.maddr = d->rom.base_addr; memory_region_init_rom_device(&s->rom, OBJECT(s), NULL, NULL, "xen-pci-pt-rom", d->rom.size); pci_register_bar(&s->dev, PCI_ROM_SLOT, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->rom); XEN_PT_LOG(&s->dev, "Expansion ROM registered (size=0x%08"PRIx64 " base_addr=0x%08"PRIx64")\n", d->rom.size, d->rom.base_addr); } return 0; }
1threat
Perl misses lines while reading a file : I'm doing a large (8000 lines) library data conversion. I read in a file and want to modify it line by line. Reading the file stops before reaching the end of the file. open(my $infh, "<", 'infile.pica') || die('Could not open pica file'); open(my $outfh, ">", 'infile.pica.norm') || die('Could not open pica file'); my $counter = 0; while (my $line = <$infh>) { $counter++; # for debugging - this is the last line being read. # infile actually has 7857 lines if ($counter >= 7691) { say $line; } # modification commented out for debugging print $outfh $line; } close $infh; close $outfh; My first thought was that there is a strange character in this line but there is nothing 006X $cEBC$03564211 (original) 006X $cEBC$035642 (being read, thats what the say prints)
0debug
Kotlin on Android - is there a minimum API level requirement? : <p>I am seriously considering using Kotlin on a greenfield Android project, but am concerned about knock-on implications, the most significant of which is a minimum required API level.</p> <p>On other platforms, new languages have required a certain OS version (e.g. Swift requiring iOS 7) and I wondered whether there were similar requirements here?</p> <p>I've been searching through various Kotlin/Android FAQs and Stackoverflow but have not been able to find this information.</p>
0debug
static inline int mpeg2_decode_block_intra(MpegEncContext *s, int16_t *block, int n) { int level, dc, diff, i, j, run; int component; RLTable *rl; uint8_t * const scantable = s->intra_scantable.permutated; const uint16_t *quant_matrix; const int qscale = s->qscale; int mismatch; if (n < 4) { quant_matrix = s->intra_matrix; component = 0; } else { quant_matrix = s->chroma_intra_matrix; component = (n & 1) + 1; } diff = decode_dc(&s->gb, component); if (diff >= 0xffff) return -1; dc = s->last_dc[component]; dc += diff; s->last_dc[component] = dc; block[0] = dc << (3 - s->intra_dc_precision); av_dlog(s->avctx, "dc=%d\n", block[0]); mismatch = block[0] ^ 1; i = 0; if (s->intra_vlc_format) rl = &ff_rl_mpeg2; else rl = &ff_rl_mpeg1; { OPEN_READER(re, &s->gb); for (;;) { UPDATE_CACHE(re, &s->gb); GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); if (level == 127) { break; } else if (level != 0) { i += run; j = scantable[i]; level = (level * qscale * quant_matrix[j]) >> 4; level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); } else { run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6); UPDATE_CACHE(re, &s->gb); level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12); i += run; j = scantable[i]; if (level < 0) { level = (-level * qscale * quant_matrix[j]) >> 4; level = -level; } else { level = (level * qscale * quant_matrix[j]) >> 4; } } if (i > 63) { av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y); return -1; } mismatch ^= level; block[j] = level; } CLOSE_READER(re, &s->gb); } block[63] ^= mismatch & 1; s->block_last_index[n] = i; return 0; }
1threat
How to customize Material-ui Table Row and Columns (Sticky) : <p>I have a unique situation in which I need not only the header but the first row and first three columns to persist when scrolling down and/or to the right due to an overflow of columns.</p> <p>Material-UI Table allows for me to keep the header sticky when scrolling down without negatively affecting overflow, like in this example: <a href="https://codesandbox.io/s/209r3p0l3y" rel="noreferrer">https://codesandbox.io/s/209r3p0l3y</a></p> <p>In my table the header does stick, but the first row must stick when scrolling down but not stick when scrolling left (the same behavior). This is to keep the overflow of values remaining consistent with the header labels. The first row (although not a header) will be compared to the rest of the rows of data when scrolling down and to the right. Also, this is the case for the first 3 columns. The other columns must remain matching with the header labels and first-row content, but the first 3 columns remain fixed to the left as this is done.</p> <p>Is overlapping multiple MUI tables truly the best and/or only plausible solution? I cannot think of a less hacky solution and wonder if anyone has encountered this when limited to MUI Tables or developing unique table behavior.</p>
0debug
Error in merge sorting of linked list : <p>I am trying to do a merge sorting practice on linked list sort and I couldn't figure the reason that the code doesn't work, my compiler doesn't give any useful error message. Can't someone point it out for me? thanks!</p> <pre><code> #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;iostream&gt; using namespace std; struct listnode { struct listnode * next; int key; }; //function prototypes void seperate(struct listnode * node, struct listnode ** front, struct listnode ** back); struct listnode * merge(struct listnode * node_1, struct listnode * node_2); //merge sorted seperated linked list void mergeSort(struct listnode ** node) { struct listnode * head = * node; struct listnode * node_1; struct listnode * node_2; if ((head == NULL) || (head-&gt;next == NULL)) { return; } seperate(head, &amp;node_1, &amp;node_2); mergeSort(&amp;node_1); mergeSort(&amp;node_2); * node = merge(node_1, node_2); } //sort sepearted linked list struct listnode * merge(struct listnode * node_1, listnode * node_2) { struct listnode * return_result = NULL; if (node_1 == NULL) { return (node_2); } else if (node_2 = NULL) { return (node_1); } if (node_1-&gt;key &lt;= node_2-&gt;key) { return_result = node_1; return_result-&gt;next = merge(node_1-&gt;next, node_2); } else { return_result = node_2; return_result-&gt;next = merge(node_1, node_2-&gt;next); } return return_result; } //function to seperate linked list void seperate(struct listnode * node, struct listnode ** front, struct listnode ** back) { struct listnode * fast; struct listnode * slow; if (node == NULL || node-&gt;next == NULL) { *front = node; * back = NULL; } else { slow = node; fast = node-&gt;next; while (fast != NULL) { fast = fast-&gt;next; if (fast != NULL) { slow = slow-&gt;next; fast = fast-&gt;next; } } * front = node; * back = slow-&gt;next; slow-&gt;next = NULL; } }// merge sort of linked list completed //test functions to push and print the linked list void push(struct listnode ** head, int data) { struct listnode * added_node = (struct listnode * )malloc(sizeof(struct listnode)); added_node-&gt;key = data; added_node-&gt;next = (*head); (*head) = added_node; } void printList(struct listnode * node) { while (node != NULL) { cout &lt;&lt; node-&gt;key; node = node-&gt;next; } } int main() { struct listnode * node1 = NULL; push(&amp;node1, 3); push(&amp;node1, 30); push(&amp;node1, 23); push(&amp;node1, 1); push(&amp;node1, 0); push(&amp;node1, 9); mergeSort(&amp;node1); cout &lt;&lt; endl; printList(node1); return 0; } </code></pre>
0debug
Boost Program Options dependent options : <p>Is there any way of making program options dependent on other options using <code>boost::program_options</code>?</p> <p>For example, my program can accept the following sample arguments:</p> <pre><code>wifi --scan --interface=en0 wifi --scan --interface=en0 --ssid=network wifi --do_something_else </code></pre> <p>In this example, the <code>interface</code> and <code>ssid</code> arguments are only valid if they are accompanied by <code>scan</code>. They are dependent on the <code>scan</code> argument.</p> <p>Is there any way to enforce this automatically with <code>boost::program_options</code>? It can of course be implemented manually but it seems like there must be a better way.</p>
0debug
Using getline for a constant string : How can I use getline() function to read words form a line that I have stored in a string ? For example: `char ch[100],w[20]; cin.getline(ch,100);` Now can I use getline to count the number of words in ch. I dont want to use a delimeter to directly count words from ch. I want to read words from ch and store them in w. I have tried using ch in getline function as a parameter. Please help me.
0debug
static void dequantization_float(int x, int y, Jpeg2000Cblk *cblk, Jpeg2000Component *comp, Jpeg2000T1Context *t1, Jpeg2000Band *band) { int i, j; int w = cblk->coord[0][1] - cblk->coord[0][0]; for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) { float *datap = &comp->f_data[(comp->coord[0][1] - comp->coord[0][0]) * (y + j) + x]; int *src = t1->data[j]; for (i = 0; i < w; ++i) datap[i] = src[i] * band->f_stepsize; } }
1threat
No such external account . Stripe Payout not working using php? : **I am transferring fund from stripe account to connect account using payout api ** my code is: $payout = \Stripe\Payout::create([ 'amount' => 500, 'currency' => 'aud', 'description' => 'first payout payment transfer on stripe', 'destination' => 'bank_id', 'method' => 'instant', 'source_type' => 'bank_account', 'statement_descriptor' => 'first payout payment transfer on stripe ', ]); after hit this api show error: Stripe\Exception\InvalidRequestException: No such external account: ba_1G497bAoBoRegJgCC1jj2UE2 in file /var/www/html/ultimateFitness/app/Stripe/lib/Exception/ApiErrorException.php on line 38 Also i am follow stripe documentation: [https://stripe.com/docs/api/payouts/creat][1]e [1]: https://stripe.com/docs/api/payouts/create
0debug
Do C++ Concepts allow for my class at declaration/definition to specify it satisfies certain concept? : <p>Currently best way I can think of is to use static_assert, but I would prefer nicer way.</p> <pre><code>#include &lt;set&gt; #include &lt;forward_list&gt; using namespace std; template&lt;typename C&gt; concept bool SizedContainer = requires (C c){ c.begin(); c.end(); {c.size()} -&gt; size_t; }; static_assert(SizedContainer&lt;std::set&lt;int&gt;&gt;); static_assert(!SizedContainer&lt;std::forward_list&lt;int&gt;&gt;); static_assert(!SizedContainer&lt;float&gt;); class MyContainer{ public: void begin(){}; void end(){}; size_t size(){return 42;}; }; static_assert(SizedContainer&lt;MyContainer&gt;); int main() { } </code></pre>
0debug
void spapr_vio_bus_register_withprop(VIOsPAPRDeviceInfo *info) { info->qdev.init = spapr_vio_busdev_init; info->qdev.bus_info = &spapr_vio_bus_info; assert(info->qdev.size >= sizeof(VIOsPAPRDevice)); qdev_register(&info->qdev); }
1threat
How to give date time format in android data : i am fetching date time from my api in which i am facing problem how i can set this date time to textView. I want to show this dateTime in this format how i can do this 9 Sep,2018. here is my snapshot in which date format is given. that format is coming from my API. [Date time Format in API snapshot][1] i hve uploaded the snapshot of textView [1]: https://i.stack.imgur.com/FCdtf.png how i can set the review date to text View. Thank you in advance how i can set this to my textView
0debug
static void qmp_input_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp) { QmpInputVisitor *qiv = to_qiv(v); QObject *qobj = qmp_input_get_object(qiv, name, true); if (!qobj || qobject_type(qobj) != QTYPE_QINT) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "integer"); return; } *obj = qint_get_int(qobject_to_qint(qobj)); }
1threat
how to use InteractionManager.runAfterInteractions make navigator transitions faster : <p>Because of complex logic, I have to render many components when <code>this.props.navigator.push()</code>, slow navigator transitions make app unavailable.</p> <p><a href="https://i.stack.imgur.com/XI9Is.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/XI9Is.jpg" alt="enter image description here"></a></p> <p>then I notice <a href="http://facebook.github.io/react-native/docs/performance.html#slow-navigator-transitions" rel="noreferrer">here</a> provide <code>InteractionManager.runAfterInteractions</code> api to solve this problem, </p> <p>I need bring most of components which consumed long time to callback after navigator animation finished, but I don't know where should I call it, </p> <p>maybe a simple example is enough,</p> <p>thanks for your time.</p>
0debug
How to configure Flume to listen a web api http petitions : <p>I have built an api web application, which is published on IIS Server, I am trying to configure Apache Flume to listen that web api and to save the response of http petitions in HDFS, this is the post method that I need to listen:</p> <pre><code> [HttpPost] public IEnumerable&lt;Data&gt; obtenerValores(arguments arg) { Random rdm = new Random(); int ano = arg.ano; int rdmInt; decimal rdmDecimal; int anoActual = DateTime.Now.Year; int mesActual = DateTime.Now.Month; List&lt;Data&gt; ano_mes_sales = new List&lt;Data&gt;(); while (ano &lt;= anoActual) { int mes = 1; while ((anoActual == ano &amp;&amp; mes &lt;= mesActual) || (ano &lt; anoActual &amp;&amp; mes &lt;= 12)) { rdmInt = rdm.Next(); rdmDecimal = (decimal)rdm.NextDouble(); Data anoMesSales = new Data(ano, mes,(rdmInt * rdmDecimal)); ano_mes_sales.Add(anoMesSales); mes++; } ano++; } return ano_mes_sales; } </code></pre> <p>Flume is running over a VMware Virtual Machine CentOs, this is my attempt to configure flume to listen that application:</p> <pre><code># Sources, channels, and sinks are defined per # agent name, in this case 'tier1'. a1.sources = source1 a1.channels = channel1 a1.sinks = sink1 a1.sources.source1.interceptors = i1 i2 a1.sources.source1.interceptors.i1.type = host a1.sources.source1.interceptors.i1.preserveExisting = false a1.sources.source1.interceptors.i1.hostHeader = host a1.sources.source1.interceptors.i2.type = timestamp # For each source, channel, and sink, set # standard properties. a1.sources.source1.type = org.apache.flume.source.http.HTTPSource a1.sources.source1.bind = transacciones.misionempresarial.com/CSharpFlume a1.sources.source1.port = 80 # JSONHandler is the default for the httpsource # a1.sources.source1.handler = org.apache.flume.source.http.JSONHandler a1.sources.source1.channels = channel1 a1.channels.channel1.type = memory a1.sinks.sink1.type = hdfs a1.sinks.sink1.hdfs.path = /monthSales a1.sinks.sink1.hdfs.filePrefix = event-file-prefix- a1.sinks.sink1.hdfs.round = false a1.sinks.sink1.channel = channel1 # Other properties are specific to each type of # source, channel, or sink. In this case, we # specify the capacity of the memory channel. a1.channels.channel1.capacity = 1000 </code></pre> <p>I am using curl to post, here is my attempt:</p> <pre><code>curl -X POST -H 'Content-Type: application/json; charset=UTF-8' -d '[{"ano":"2010"}]' http://transacciones.misionempresarial.com/CSharpFlume/api/SourceFlume/ObtenerValores </code></pre> <p>I only get this error:</p> <pre><code>{"Message":"Error."} </code></pre> <p>My question are, which is the right way to configure flume to listen http petitions to my web api, what I am missing?</p>
0debug
Failed at the node-sass@4.7.2 postinstall script : <p>I just downloaded the latest version of <code>node.js</code> and I've been trying to do <code>npm install</code> on one of my projects but saying:</p> <blockquote> <p>Failed at the node-sass@4.7.2 postinstall script.</p> </blockquote> <p>I tried doing: <code>npm rebuild node-sass --force</code> which didn't do anything either. </p> <p><a href="https://i.stack.imgur.com/xYygY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xYygY.png" alt="enter image description here"></a></p> <p>The error log returns this: </p> <pre><code>3209 warn angularfire2@5.0.0-rc.10 requires a peer of @angular/common@^6.0.0 but none is installed. You must install peer dependencies yourself. 3210 warn angularfire2@5.0.0-rc.10 requires a peer of @angular/core@^6.0.0 but none is installed. You must install peer dependencies yourself. 3211 warn angularfire2@5.0.0-rc.10 requires a peer of @angular/platform-browser@^6.0.0 but none is installed. You must install peer dependencies yourself. 3212 warn angularfire2@5.0.0-rc.10 requires a peer of @angular/platform-browser-dynamic@^6.0.0 but none is installed. You must install peer dependencies yourself. 3213 warn angularfire2@5.0.0-rc.10 requires a peer of firebase@^5.0.3 but none is installed. You must install peer dependencies yourself. 3214 warn angularfire2@5.0.0-rc.10 requires a peer of rxjs@^6.0.0 but none is installed. You must install peer dependencies yourself. 3215 warn geofire@4.1.2 requires a peer of firebase@^2.4.0 || 3.x.x but none is installed. You must install peer dependencies yourself. 3216 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents): 3217 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) 3218 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin 3218 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any 3218 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: win32 3218 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64 3219 verbose stack Error: node-sass@4.7.2 postinstall: `node scripts/build.js` 3219 verbose stack Exit status 1 3219 verbose stack at EventEmitter.&lt;anonymous&gt; (C:\Users\Simon K\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:283:16) 3219 verbose stack at emitTwo (events.js:126:13) 3219 verbose stack at EventEmitter.emit (events.js:214:7) 3219 verbose stack at ChildProcess.&lt;anonymous&gt; (C:\Users\Simon K\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 3219 verbose stack at emitTwo (events.js:126:13) 3219 verbose stack at ChildProcess.emit (events.js:214:7) 3219 verbose stack at maybeClose (internal/child_process.js:925:16) 3219 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) 3220 verbose pkgid node-sass@4.7.2 3221 verbose cwd C:\xampp\htdocs\project x\projectx 3222 verbose Windows_NT 10.0.16299 3223 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Simon K\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" 3224 verbose node v8.11.2 3225 verbose npm v6.0.1 3226 error code ELIFECYCLE 3227 error errno 1 3228 error node-sass@4.7.2 postinstall: `node scripts/build.js` 3228 error Exit status 1 3229 error Failed at the node-sass@4.7.2 postinstall script. 3229 error This is probably not a problem with npm. There is likely additional logging output above. 3230 verbose exit [ 1, true ] </code></pre> <p>and my npm and node versions are:</p> <pre><code>2 info using npm@6.0.1 3 info using node@v8.11.2 </code></pre> <p>I've also tried completely deleting my <code>node_modules</code> folder and running <code>npm install</code> again but that didn't work.</p> <p>One possible reason for this could be that <em>before</em> I updated node I followed this persons suggestion: <a href="https://github.com/angular/angular-cli/issues/10527" rel="noreferrer">https://github.com/angular/angular-cli/issues/10527</a></p> <p>Where he says:</p> <blockquote> <ol> <li>Download and save a local copy of the correct version of node-sass binary - win32-x64-64_binding.node. For example download it to the following location: C:\node-sass\win32-x64-64_binding.node </li> <li>Provide reference to the full path of the node-sass binary file in the sass_binary_path npm configuration parameter (in the ~/.npmrc file): npm config set sass_binary_path For example, npm config set sass_binary_path C:\node-sass\win32-x64-64_binding.node </li> <li>Run the npm install command again to install @angular/cli correctly. </li> <li>Execute ng serve or npm start and your should be past the problem.</li> </ol> </blockquote> <p>I don't know if this is related.. I wouldn't think so since I've updated node, tried to force <code>node-sass</code> rebuild but I don't know.</p> <p>Any ideas/advice on how to fix this? Thank you!</p>
0debug
Genymotion virtualization engine not found/plugin loading aborted on Mac : <p>I downloaded Genymotion but cannot get it to work. I keep on getting "virtualization engine not found, plugin loading aborted". I have uninstalled and reinstalled it, force quit and restarted it, and looked at other solutions to no avail. It seems to hit a snag <a href="https://i.stack.imgur.com/whAtk.png" rel="noreferrer">here</a>.</p> <p>I am running on a Mac, OSX Yosemite version 10.10.5.</p>
0debug
how to solve following sexmachine anaconda python error? : (base) C:\Users\sujit>pip install SexMachine Collecting SexMachine Using cached https://files.pythonhosted.org/packages/dd/01/cc5b32af2b3658079736bd865019aeb8db04f9c5764eac72185c276 c/SexMachine-0.1.1.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Windows\TEMP\pip-install-wlnebm4x\SexMachine\setup.py", line 14, in <module> long_description=open('README.rst').read(), File "c:\users\sujit\anaconda3\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 835: character maps to <undefined> ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in C:\Windows\TEMP\pip-install-wlnebm4x\SexMachine\ I updated setuptools but it is not solving this problem. please help. thanks in advance.
0debug
static int decode_dvd_subtitles(AVSubtitle *sub_header, const uint8_t *buf, int buf_size) { int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos; int big_offsets, offset_size, is_8bit = 0; const uint8_t *yuv_palette = 0; uint8_t colormap[4], alpha[256]; int date; int i; int is_menu = 0; if (buf_size < 10) return -1; memset(sub_header, 0, sizeof(*sub_header)); if (AV_RB16(buf) == 0) { big_offsets = 1; offset_size = 4; cmd_pos = 6; } else { big_offsets = 0; offset_size = 2; cmd_pos = 2; } cmd_pos = READ_OFFSET(buf + cmd_pos); while (cmd_pos > 0 && cmd_pos < buf_size - 2 - offset_size) { date = AV_RB16(buf + cmd_pos); next_cmd_pos = READ_OFFSET(buf + cmd_pos + 2); av_dlog(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n", cmd_pos, next_cmd_pos, date); pos = cmd_pos + 2 + offset_size; offset1 = -1; offset2 = -1; x1 = y1 = x2 = y2 = 0; while (pos < buf_size) { cmd = buf[pos++]; av_dlog(NULL, "cmd=%02x\n", cmd); switch(cmd) { case 0x00: is_menu = 1; break; case 0x01: sub_header->start_display_time = (date << 10) / 90; break; case 0x02: sub_header->end_display_time = (date << 10) / 90; break; case 0x03: if ((buf_size - pos) < 2) goto fail; colormap[3] = buf[pos] >> 4; colormap[2] = buf[pos] & 0x0f; colormap[1] = buf[pos + 1] >> 4; colormap[0] = buf[pos + 1] & 0x0f; pos += 2; break; case 0x04: if ((buf_size - pos) < 2) goto fail; alpha[3] = buf[pos] >> 4; alpha[2] = buf[pos] & 0x0f; alpha[1] = buf[pos + 1] >> 4; alpha[0] = buf[pos + 1] & 0x0f; pos += 2; av_dlog(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]); break; case 0x05: case 0x85: if ((buf_size - pos) < 6) goto fail; x1 = (buf[pos] << 4) | (buf[pos + 1] >> 4); x2 = ((buf[pos + 1] & 0x0f) << 8) | buf[pos + 2]; y1 = (buf[pos + 3] << 4) | (buf[pos + 4] >> 4); y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5]; if (cmd & 0x80) is_8bit = 1; av_dlog(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2); pos += 6; break; case 0x06: if ((buf_size - pos) < 4) goto fail; offset1 = AV_RB16(buf + pos); offset2 = AV_RB16(buf + pos + 2); av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2); pos += 4; break; case 0x86: if ((buf_size - pos) < 8) goto fail; offset1 = AV_RB32(buf + pos); offset2 = AV_RB32(buf + pos + 4); av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2); pos += 8; break; case 0x83: if ((buf_size - pos) < 768) goto fail; yuv_palette = buf + pos; pos += 768; break; case 0x84: if ((buf_size - pos) < 256) goto fail; for (i = 0; i < 256; i++) alpha[i] = 0xFF - buf[pos+i]; pos += 256; break; case 0xff: goto the_end; default: av_dlog(NULL, "unrecognised subpicture command 0x%x\n", cmd); goto the_end; } } the_end: if (offset1 >= 0) { int w, h; uint8_t *bitmap; w = x2 - x1 + 1; if (w < 0) w = 0; h = y2 - y1; if (h < 0) h = 0; if (w > 0 && h > 0) { if (sub_header->rects != NULL) { for (i = 0; i < sub_header->num_rects; i++) { av_freep(&sub_header->rects[i]->pict.data[0]); av_freep(&sub_header->rects[i]->pict.data[1]); av_freep(&sub_header->rects[i]); } av_freep(&sub_header->rects); sub_header->num_rects = 0; } bitmap = av_malloc(w * h); sub_header->rects = av_mallocz(sizeof(*sub_header->rects)); sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect)); sub_header->num_rects = 1; sub_header->rects[0]->pict.data[0] = bitmap; decode_rle(bitmap, w * 2, w, (h + 1) / 2, buf, offset1, buf_size, is_8bit); decode_rle(bitmap + w, w * 2, w, h / 2, buf, offset2, buf_size, is_8bit); sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE); if (is_8bit) { if (yuv_palette == 0) goto fail; sub_header->rects[0]->nb_colors = 256; yuv_a_to_rgba(yuv_palette, alpha, (uint32_t*)sub_header->rects[0]->pict.data[1], 256); } else { sub_header->rects[0]->nb_colors = 4; guess_palette((uint32_t*)sub_header->rects[0]->pict.data[1], colormap, alpha, 0xffff00); } sub_header->rects[0]->x = x1; sub_header->rects[0]->y = y1; sub_header->rects[0]->w = w; sub_header->rects[0]->h = h; sub_header->rects[0]->type = SUBTITLE_BITMAP; sub_header->rects[0]->pict.linesize[0] = w; } } if (next_cmd_pos == cmd_pos) break; cmd_pos = next_cmd_pos; } if (sub_header->num_rects > 0) return is_menu; fail: if (sub_header->rects != NULL) { for (i = 0; i < sub_header->num_rects; i++) { av_freep(&sub_header->rects[i]->pict.data[0]); av_freep(&sub_header->rects[i]->pict.data[1]); av_freep(&sub_header->rects[i]); } av_freep(&sub_header->rects); sub_header->num_rects = 0; } return -1; }
1threat
Fill NaN based on previous value of row : <p>I have a data frame (sample, not real):</p> <p>df = </p> <pre><code> A B C D E F 0 3 4 NaN NaN NaN NaN 1 9 8 NaN NaN NaN NaN 2 5 9 4 7 NaN NaN 3 5 7 6 3 NaN NaN 4 2 6 4 3 NaN NaN </code></pre> <p>Now I want to fill NaN values with previous couple(!!!) values of row (fill Nan with left existing couple of numbers and apply to the whole row) and apply this to the whole dataset.</p> <ul> <li>There are a lot of answers concerning filling the columns. But in this case I need to fill based on rows.</li> <li>There are also answers related to fill NaN based on other column, but in my case number of columns are more than 2000. This is sample data</li> </ul> <p>Desired output is:</p> <p>df = </p> <pre><code> A B C D E F 0 3 4 3 4 3 4 1 9 8 9 8 9 8 2 5 9 4 7 4 7 3 5 7 6 3 6 3 4 2 6 4 3 4 3 </code></pre>
0debug
How to detect noise in images : <p>How to detect noise in images?</p> <p>I need to do some preprocessing before OCR and I need to detect if there are areas with noise? How to detect these areas? They are typically in rectangular areas</p> <p>Below is an example. There are some noise in the last column to the right. I need the bounding boxes for all the areas with noise</p> <p><a href="https://i.stack.imgur.com/wKPCp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wKPCp.png" alt="enter image description here"></a></p>
0debug
How to explode string after \ in php : <p>I have a requirement where username is entered as <strong>textdev\userid</strong></p> <p>I need to get the userid from this string,I have tried using explode but it's not working with "\".</p> <p>Can anybody suggest me how to extract the userid from this string in php.</p>
0debug
static void gen_tlbre_440(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } switch (rB(ctx->opcode)) { case 0: case 1: case 2: { TCGv_i32 t0 = tcg_const_i32(rB(ctx->opcode)); gen_helper_440_tlbre(cpu_gpr[rD(ctx->opcode)], cpu_env, t0, cpu_gpr[rA(ctx->opcode)]); tcg_temp_free_i32(t0); } break; default: gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); break; } #endif }
1threat
Javascript Instanciate new Object with dynamic parameter from String : I would like to instantiate a new object with dynamic parameters coming from an exernal String. Here is the code: const editorInstance = new Editor('#edit', placeholderText: null, theme: 'dark', language: 'en', linkList:[{text: 'test',href: 'test',target: '_blank'}], events: { initialized: function () { const editor = this this.el.closest('form').addEventListener('submit', function (e) { jQuery('#gs_editor_content').hide(); jQuery(this).append('<div class="loadingDiv">&nbsp;</div>'); o.script}); texta = jQuery('#myeditor').find('textarea'); targetFile = texta.attr('rel'); content = editor.$oel.val(); e.preventDefault(); var fd = new FormData(); fd.append( 'name' ,targetFile); fd.append( 'html', editor.$oel.val() ); $.ajax({ url : 'http://localhost/Update', type : 'POST', data: fd, processData : false, contentType : false, async : false, success : function(data, textStatus, request) { } }); jQuery('#myeditor').dialog("close"); }) } } }) I would need to modify the parameters `linkList` before instantiating my object as I receive a new list received from my server. I tried to use eval or parseFunction but I encounter an unexpected identifier error. any idea how I can achieve this ?
0debug
int avformat_network_deinit(void) { #if CONFIG_NETWORK ff_network_close(); ff_tls_deinit(); ff_network_inited_globally = 0; #endif return 0; }
1threat
C# Parent and Child class - picking the child out of a parent class : <p>Does anyone know, why this underlines(error) Suit (Child class of Stock)in the part that says "stock is Suit"?</p> <pre><code>//Picking Suit out of the Stock public System.Collections.ArrayList Suit() { System.Collections.ArrayList array = new System.Collections.ArrayList(); //looping through Persons array foreach (Stock stock in allStock)//using code snippets { if (stock is Suit) //if it is a customer, display value, if not, return to the array list { array.Add(stock); } } return array; } </code></pre>
0debug
static void softusb_usbdev_datain(void *opaque) { MilkymistSoftUsbState *s = opaque; USBPacket p; p.pid = USB_TOKEN_IN; p.devep = 1; p.data = s->kbd_usb_buffer; p.len = sizeof(s->kbd_usb_buffer); s->usbdev->info->handle_data(s->usbdev, &p); softusb_kbd_changed(s); }
1threat
why self invoking function throws error without enclosing parenthesis : <p>I have two code snippet. First one is working fine but the second one is giving error.</p> <pre><code>var b = function abc() { alert(a); }() </code></pre> <p>Here I am getting the alert message.</p> <pre><code>function abc() { alert(a); }() </code></pre> <p>Here I am getting error."Uncaught SyntaxError: Unexpected token )" I am using chrome browser.</p> <p>Again the following is working. </p> <pre><code>(function abc() { alert(a); })() </code></pre> <p>What is the purpose of the enclosing parentheses?</p>
0debug
from collections import defaultdict def max_occurrences(nums): dict = defaultdict(int) for i in nums: dict[i] += 1 result = max(dict.items(), key=lambda x: x[1]) return result
0debug
Can we convert .class file into .exe file : <p>**Is there any way to convert class file into exe file ? Suppose i created a java desktop application and want to convert into exe **</p>
0debug
Connecting each column for each row in r ggplot2 scatter plot : <p>I have three columns: "original", "pos1", "pos2". Each row is an individual. I want to create a scatterplot where "original" is on the x-axis, and pos1 and pos2 values are on the y-axis. So each original will have a pos1 dot and a pos2 dot. I can create two different colors to distinguish pos1 and pos2 dots. But what I want is to add a line between pos1 and pos2 for each individual. If I have 100 individual, there will be 100 short lines, connecting each pos1 and pos2. Is there any way I can do this in ggplot?</p> <p>Thank you! </p>
0debug
Importing pb.go file in a golang project? : How can i import my generated `pb.go` file so I can call the methods in them? I visited all the examples for go and they all seem to import with `github.com/...` **Example.go** ``` import ( "github.com/go-chi/chi" chiMiddleware "github.com/go-chi/chi/middleware" "google.golang.org/grpc" "net/http" "github.com/easyCZ/grpc-web-hacker-news/server/hackernews" hackernews_pb "github.com/easyCZ/grpc-web-hacker-news/server/proto" // Proto directory. "google.golang.org/grpc/grpclog" "github.com/improbable-eng/grpc-web/go/grpcweb" "github.com/go-chi/cors" "github.com/easyCZ/grpc-web-hacker-news/server/proxy" "github.com/easyCZ/grpc-web-hacker-news/server/middleware" ) func main() { grpcServer := grpc.NewServer() hackernewsService := hackernews.NewHackerNewsService(nil) hackernews_pb.RegisterHackerNewsServiceServer(grpcServer, hackernewsService) ... ``` **Directory Structure** ``` 📦athena-server ┣ 📂proto ┃ ┣ 📜athena.pb.go ┃ ┗ 📜athena.proto ┣ 📂server ┃ ┗ 📜server.go ┣ 📜.DS_Store ┣ 📜docker-compose.yml ┣ 📜generated.go ┣ 📜go.mod ┣ 📜go.sum ┣ 📜google_service.json ┣ 📜gqlgen.yml ┣ 📜models_gen.go ┣ 📜resolver.go ┣ 📜schema.graphql ┗ 📜todo.go ``` **Main.go** ``` import ( "bytes" "flag" "fmt" "log" "net/http" "os" "google.golang.org/grpc" "google.golang.org/grpc/grpclog" "github.com/improbable-eng/grpc-web/go/grpcweb" auth "../proto" // Proto directory but doesn't work. ) ... ``` **Error** ``` cannot find module for path _/Users/xxx/go/src/athena-server/proto ``` I tried all sort both absolute and relative path as well as shifting files around but nothing seems to work.
0debug
ACF conditional logic for Google maps fields not Working : I am using ACF google Maps to give direction to a Tender briefing location to clients. Everything is working perfectly fine with the code below. I am using a Conditional logic of "Compulsory Briefing" YES/NO. if Compulsory briefing is YES i show the Get direction link that opens on Google Maps. Now When Compulsury Briefing is NO, i dont want to show the Link "Get Direction". <span class="font-weight-bold"><b>Compulsory Briefing:</b></span> <?php the_field('compulsory_briefing') ?><br/> <span class="font-weight-bold"><b>Address [Google Maps] <a class="directions" target="_blank" href="https://www.google.com/maps?saddr=My+Location&daddr=<?php $location = the_field('briefing_address'); echo $location['lat'] . ',' . $location['lng']; ?>"> <?php _e(' Get Directions','roots'); ?></a>
0debug
void ff_vp3_idct_dc_add_c(uint8_t *dest, int line_size, const DCTELEM *block){ int i, dc = (block[0] + 15) >> 5; for(i = 0; i < 8; i++){ dest[0] = av_clip_uint8(dest[0] + dc); dest[1] = av_clip_uint8(dest[1] + dc); dest[2] = av_clip_uint8(dest[2] + dc); dest[3] = av_clip_uint8(dest[3] + dc); dest[4] = av_clip_uint8(dest[4] + dc); dest[5] = av_clip_uint8(dest[5] + dc); dest[6] = av_clip_uint8(dest[6] + dc); dest[7] = av_clip_uint8(dest[7] + dc); dest += line_size; } }
1threat
static void pci_realview_class_init(ObjectClass *class, void *data) { DeviceClass *dc = DEVICE_CLASS(class); dc->cannot_destroy_with_object_finalize_yet = true; }
1threat
how to make values as keys and push it in json object : I have json like 0:{columnName:"gender",seedValues:["M","F"]} 1:{columnName:"entity_type",seedValues:["O","I"]} I want json like { "gender":["M","F"], "entity_type":["O","I"] } In Angular 6 or javascript
0debug
Is it possible to host telegram on my own server? : <p><a href="https://telegram.org/" rel="noreferrer">Telegram</a> is a cloud based chat service. All of their clients are open source. I was wondering if there's a way to host a 'private' telegram service on my own server. </p> <p>If not, is there anything out there that can provide all or almost all features that telegram provides?</p>
0debug
In R, Python or Stata: How to delete all files in all subfolders : <p>I have a folder with multiple subfolders (with more subfolders in those) where different specifications of datasets are saved (sometimes sliced and diced). </p> <p>I am afraid that some legacy files in there will mess things up when I aggregate files together. So I am looking for a command to delete all files in all subfolders of a given folders (but not the subfolders them selves). Is there a simple way of doing this in <code>R</code>, <code>Python</code> or <code>Stata</code> without having to create a list of all applicable subfolders first? </p>
0debug
How do I turn off syntax highlighting for txt files in notepad++? : <p>Notepad recently began applying a greyed-out color to anything in quotes in my txt files. I don't know what started this and I can't find way to undo it in the settings. How do I change it back?</p>
0debug
Displaying the date : <p>I trying to only show the date so for example <code>2018-04-09</code> and not the time. After that I want it to make it like <code>9 april 2018</code> but I can't change the database because I need the hours/seconds/minutes for an other thing. I did not found on the internet what I need in my case and what works for me. I hope someone has a tip how to make this with some kind of code.</p> <p>I am new to asking questions so if I miss something to make this question work tell me.</p> <p><a href="https://i.stack.imgur.com/xQOJI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xQOJI.png" alt="My database"></a></p>
0debug
How can I measure pixels in Chrome without an extension? : <p>Due to security limitations at work, I am not allowed to install Chrome extensions. Chrome has a ruler built in to the developer tools, but I can't figure out how to define start and end points like a ruler would permit.</p> <p>Are there any tools or techniques for measuring pixels that don't require installing a Chrome extension?</p>
0debug
static void test_submit_aio(void) { WorkerTestData data = { .n = 0, .ret = -EINPROGRESS }; data.aiocb = thread_pool_submit_aio(worker_cb, &data, done_cb, &data); active = 1; g_assert_cmpint(data.ret, ==, -EINPROGRESS); qemu_aio_flush(); g_assert_cmpint(active, ==, 0); g_assert_cmpint(data.n, ==, 1); g_assert_cmpint(data.ret, ==, 0); }
1threat
How can I customise navigation bar using xcoe 9 in iOS : I can I customise navigation bar like this in Xcode 9. [enter image description here][1] [1]: https://i.stack.imgur.com/GazRn.png
0debug
Typescript compiler "cannot find module" when using Webpack require for CSS/image assets : <p>I am writing <strong>vanilla Javascript</strong> but using the Typescript compiler's <code>checkJs</code> option to do type checking in VSCode. I have Webpack set up to load various asset types (CSS, images, etc), which works fine for builds, but Code is treating these statements as an error. For example, in this code</p> <pre><code>require("bootstrap"); require("bootstrap/dist/css/bootstrap.css"); var img = require("../img/image.png"); </code></pre> <p>the first line is fine but the next two both show an error under the (string) argument to <code>require()</code>, with the tooltip "Cannot find module (name)".</p> <p>I have installed <code>@types/webpack</code> and <code>@types/webpack-env</code>, which fixed <code>resolve()</code> and <code>resolve.context()</code>. Am I missing another typings package or is this an issue I need to take up on <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/issues/" rel="noreferrer">the DT issue tracker</a>?</p>
0debug
ajax posting NAN valie : Im posting a variable via ajax however when I use it in php I get NAN why is that ? its supposed to be a number //in js var variableToSend = 1; $.post('ajax.php', {variable: variableToSend}); <?php echo $_POST['variable']?>;
0debug
static inline void vring_set_avail_event(VirtQueue *vq, uint16_t val) { VRingMemoryRegionCaches *caches; hwaddr pa; if (!vq->notification) { return; } caches = atomic_rcu_read(&vq->vring.caches); pa = offsetof(VRingUsed, ring[vq->vring.num]); virtio_stw_phys_cached(vq->vdev, &caches->used, pa, val); address_space_cache_invalidate(&caches->used, pa, sizeof(val)); }
1threat
PHP array_search not working (returns empty string) : <p>I'm trying to check if a filename of an image contains "cover". Somehow this stopped working for me (Pretty sure it worked already). I copied the part of my function not working. </p> <pre><code>$name=array("_IMG8555.jpg", "_IMG7769.jpg", "_IMG8458.jpg", "Cover.jpg", "_IMG7184.jpg"); $cov=array("Cover.png","Cover.jpg","Cover.jpeg", "cover.png","cover.jpg","cover.jpeg"); </code></pre> <p>This does not work for me:</p> <pre><code>print_r(array_search($cov, $name)); //Returns empty String print_r($name[array_search($cov, $name)]); //Returns first element of the name Array </code></pre> <p>Also I added a test Strings to make sure this is not result the searched string is the same as the search value.</p> <pre><code>print_r($name[3]===$cov[1]); //Returns true(1) </code></pre> <p>Can anyone help? Why does this simple script not work?</p> <p>I also tried using <code>in_array()</code> but this is not working either.</p>
0debug
enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag) { while (tags->id != 0) { if( toupper((tag >> 0)&0xFF) == toupper((tags->tag >> 0)&0xFF) && toupper((tag >> 8)&0xFF) == toupper((tags->tag >> 8)&0xFF) && toupper((tag >>16)&0xFF) == toupper((tags->tag >>16)&0xFF) && toupper((tag >>24)&0xFF) == toupper((tags->tag >>24)&0xFF)) return tags->id; tags++; } return CODEC_ID_NONE; }
1threat
Rewrite C-style for loop in Swift 3 : <p>I have a C-style for loop that's no longer supported in Swift 3. It looks something like this:</p> <pre><code>for (var x = 0; x &lt; foo.length &amp;&amp; x &lt; bar.length; x++) {} </code></pre> <p>What's the equivalent of this that's available now in Swift 3?</p>
0debug
static void blend_image_rgba_pm(AVFilterContext *ctx, AVFrame *dst, const AVFrame *src, int x, int y) { blend_image_packed_rgb(ctx, dst, src, 1, x, y, 1); }
1threat
How do I add a background image to flutter app? : <p>I am trying to add a Background image to my Flutter App, and I have gone through all similar questions on SO. The app m runs fine but the image does not appear.</p> <p>here is my widget code:</p> <pre><code> @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( // Here we take the value from the MyHomePage object that was created by // the App.build method, and use it to set our appbar title. title: Text(widget.title), actions: &lt;Widget&gt;[ new IconButton(icon: const Icon(Icons.list), onPressed: _loadWeb) ], ), body: new Stack( children: &lt;Widget&gt;[ Container( child: new DecoratedBox( decoration: new BoxDecoration( image: new DecorationImage( image: new AssetImage("images/logo.png"), fit: BoxFit.fill, ), ), ), ), Center( child: _authList(), ) ], ), floatingActionButton: FloatingActionButton( onPressed: getFile, tooltip: 'Select file', child: Icon(Icons.sd_storage), ), // This trailing comma makes auto-formatting nicer for build methods. )); } </code></pre> <p>The app runs fine and the second widget on the stack, which is a listView works normally but the image does not show up.</p> <p>Any ideas?</p>
0debug
Powershell script for PC and Monitor Make/Model and Serial number : I found this great script, however I require assistance with editing it to also include the PC Serial Number, would anyone be able to assist please? I am able to get it to work as is, however i really require the PC Serial Number to be included with the output as well, If it did include the Logged In User that would be great as well, but really require PC Name/Serial Number, Monitor Make/Model and Serial Numbers. Thanks ==========****** <# .SYNOPSIS Generate a report in multiple formats (if requested) of monitors that are connected to computers. .DESCRIPTION This script will take a list of computers (from a txt file or from AD) and will query each computer through WMI, asking what the serial number and manufacturer is. It can then generate multiple types of reports, CSV, HTML, or e-mail the HTML as the body of the message. .PARAMETER CSVReport Switch, used to define wether you want a CSV report generated or not. .PARAMETER CSVOutputFile The location where you want the CSV report to be stored, if the CSVReport switch is true. .PARAMETER HTMLReport Switch, used to define wether you want an HTML report generated or not. .PARAMETER HTMLOutputFile The location where you want the HTML report to be stored, if the HTMLReport switch is true. .PARAMETER EmailReportAsHTML Switch, used to indicate weather you want to send the report via e-mail with the body formatted as HTML. .PARAMTER LinkToComputer Switch, this is a work in progress (I am figuring out the API's to call to make this work), essentially it will be used in conjunction with the ImportToSpiceworks switch and it will define wether you want to link the monitors found, to the computers that they were found to be connected to. .PARAMETER FromAD Switch, used to define wether you want to use AD to define the array or computers to scan if monitors are connected to them or not. .PARAMTER FromFile Switch, used to define wether you want to use a txt file to define the array list of computers to be scanned if there is a monitor connected or not. .PARAMETER FromFileLocation The location where the txt file is located that has the list of computers to be scanned for monitors attached. This file should have 1 computer name of each new row. .PARAMETER Test Switch, this switch is used to test the functionality of the script, against the localhost only. .EXAMPLE Get-AttachedMoritorInventory.ps1 -FromFile -FromFileLocation "C:\Test\Servers.txt" -HTMLReport -HTMLOutputFile "C:\Test\AttachedMonitors.html" .EXAMPLE Get-AttachedMoritorInventory.ps1 -FromAD -CSVReport -CSVOutputFile "C:\Test\AttachedMonitors.csv" .EXAMPLE Get-AttachedMoritorInventory.ps1 -FromAD -EmailReportAsHTML .NOTES Author: Matt Bergeron Spiceworks: Chamele0n Blog: www.chamele0n.com Changelog: 1.4 Better detection of Virtual Machines, to support Microsoft Surface tablets. 1.3 Fix bug for displaying year of manufacture 1.2 Fixed bug where it was prompting for credentials where it shouldn't have been. 1.1 Fixed bug that caused -Test parameter not to work. 1.0 Initial release .LINK http://community.spiceworks.com/scripts/show/2962-inventory-monitors-connected-to-physical-computers #> Param( [switch]$CSVReport, [string]$CSVOutputFile = "C:\Test\AttachedMonitors.csv", [switch]$HTMLReport = $true, [string]$HTMLOutputFile = "C:\Test\AttachedMonitors.htm", [switch]$EmailReportAsHTML, [switch]$FromAD, [switch]$FromFile, [string]$FromFileLocation = "C:\Test\Servers.txt", [switch]$Test ) SMTP Mail Settings $SMTPProperties = @{ To = "ToUser@domain.com" From = "FromUser@Domain.com" Subject = "Monitor Inventory" SMTPServer = "mail.domain.com" } $Results = @() $Count = 0 if ($FromAD) { ### Attempts to Import ActiveDirectory Module. Produces error if fails. Try { Import-Module ActiveDirectory -ErrorAction Stop } Catch { Write-Host "Unable to load Active Directory module, is RSAT installed?"; Break } } HTML Header $Header = @" <center> <style> TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;margin-left: auto;margin-right: auto;} TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #808080;} TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;} .odd { background-color:#ffffff; } .even { background-color:#dddddd; } </style> </center> <title> Attached Monitor Inventory Report </title> "@ Function ConvertTo-Char ($Array) { $Output = "" ForEach($char in $Array) { $Output += [char]$char -join "" } return $Output } Function Detect-VirtualMachine { Param ( [string]$ComputerName ) $VMModels = @("Virtual Machine","VMware Virtual Platform","Xen","VirtualBox") $CheckPhysicalOrVMQuery = Get-WmiObject -ComputerName $ComputerName -Query "Select * FROM Win32_ComputerSystem" -Namespace "root\CIMV2" -ErrorAction Stop if ($VMModels -contains $CheckPhysicalOrVMQuery.Model) { $IsVM = $True } Else { $IsVM = $False } Return $IsVM } Function Set-AlternatingRows { <# .SYNOPSIS Simple function to alternate the row colors in an HTML table .DESCRIPTION This function accepts pipeline input from ConvertTo-HTML or any string with HTML in it. It will then search for <tr> and replace it with <tr class=(something)>. With the combination of CSS it can set alternating colors on table rows. CSS requirements: .odd { background-color:#ffffff; } .even { background-color:#dddddd; } Classnames can be anything and are configurable when executing the function. Colors can, of course, be set to your preference. This function does not add CSS to your report, so you must provide the style sheet, typically part of the ConvertTo-HTML cmdlet using the -Head parameter. .PARAMETER Line String containing the HTML line, typically piped in through the pipeline. .PARAMETER CSSEvenClass Define which CSS class is your "even" row and color. .PARAMETER CSSOddClass Define which CSS class is your "odd" row and color. .EXAMPLE $Report | ConvertTo-HTML -Head $Header | Set-AlternateRows -CSSEvenClass even -CSSOddClass odd | Out-File HTMLReport.html $Header can be defined with a here-string as: $Header = @" <style> TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;} TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;} TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;} .odd { background-color:#ffffff; } .even { background-color:#dddddd; } </style> "@ This will produce a table with alternating white and grey rows. Custom CSS is defined in the $Header string and included with the table thanks to the -Head parameter in ConvertTo-HTML. .NOTES Author: Martin Pugh Twitter: @thesurlyadm1n Spiceworks: Martin9700 Blog: www.thesurlyadmin.com Changelog: 1.0 Initial function release #> [CmdletBinding()] Param( [Parameter(Mandatory=$True,ValueFromPipeline=$True)] [string]$Line, [Parameter(Mandatory=$True)] [string]$CSSEvenClass, [Parameter(Mandatory=$True)] [string]$CSSOddClass ) Begin { $ClassName = $CSSEvenClass } Process { If ($Line.Contains("<tr><td>")) { $Line = $Line.Replace("<tr>","<tr class=""$ClassName"">") If ($ClassName -eq $CSSEvenClass) { $ClassName = $CSSOddClass } Else { $ClassName = $CSSEvenClass } } Return $Line } }# End Set-AlternatingRows Function if ($FromAD){ $Computers = Get-ADComputer -Filter * -Properties Name } if ($FromFile){ $Computers = Get-Content $FromFileLocation } ForEach ($Computer in $Computers) { $progress = @{ Activity = "Querying Connected Monitors on $ComputerName" Status = "$Count of $($Computers.Count) completed" PercentComplete = $Count / $($Computers.Count) * 100 Id = 0 } Write-Progress @progress $Count++ if ($FromAD) { $ComputerName = $Computer.DNSHostName } ElseIf ($FromFile) { $ComputerName = $Computer } ElseIf ($Test) { Write-Host "Test Mode Enabled" -ForegroundColor Yellow $ComputerName = $Env:ComputerName } Try { if (-not ($Test)) { $IsPhysicalMachine = Detect-VirtualMachine -ComputerName $ComputerName } Else { $IsPhysicalMachine = Detect-VirtualMachine -ComputerName "localhost" } } Catch { if (-not ($Test)) { Write-Host "ComputerName: $($ComputerName), caught an error checking if the computer was physical or virtual: $($Error[0])" -ForegroundColor Red -BackgroundColor Black } Else { Write-Host "ComputerName: $($ComputerName), caught an error checking if the computer was physical or virtual: $($Error[0])" -ForegroundColor Red -BackgroundColor Black } $Results += New-Object PSObject -Property @{ ComputerName = $ComputerName Active = "N/A" Manufacturer = "N/A" UserFriendlyName = "N/A" SerialNumber = "N/A" WeekOfManufacture = "N/A" YearOfManufacture = "N/A" Status = "2 – Warning" Message = "There was a problem checking if the computer was physical or virtual: $($Error[0])" } Continue } If ($IsPhysicalMachine -eq $false) { Try { if (-not ($Test)) { $Query = Get-WmiObject -ComputerName $ComputerName -Query "Select * FROM WMIMonitorID" -Namespace root\wmi -ErrorAction Stop } Else { $Query = Get-WmiObject -Query "Select * FROM WMIMonitorID" -Namespace root\wmi -ErrorAction Stop } ForEach ($Monitor in $Query) { $Results += New-Object PSObject -Property @{ ComputerName = $ComputerName Active = $Monitor.Active Manufacturer = ConvertTo-Char($Monitor.ManufacturerName) UserFriendlyName = ConvertTo-Char($Monitor.userfriendlyname) SerialNumber = ConvertTo-Char($Monitor.serialnumberid) WeekOfManufacture = $Monitor.WeekOfManufacture YearOfManufacture = $Monitor.YearOfManufacture Status = "0 – OK" Message = "N/A" } } Continue } Catch { $Results += New-Object PSObject -Property @{ ComputerName = $ComputerName Active = "N/A" Manufacturer = "N/A" UserFriendlyName = "N/A" SerialNumber = "N/A" WeekOfManufacture = "N/A" YearOfManufacture = "N/A" Status = "1 – Error" Message = "Error: $($Error[0])" } } } Else { Write-Host "ComputerName: $($ComputerName) was a virtual machine. Skipping monitor inventory." -ForegroundColor Yellow $Results += New-Object PSObject -Property @{ ComputerName = $ComputerName Active = $false Manufacturer = "N/A" UserFriendlyName = "N/A" SerialNumber = "N/A" WeekOfManufacture = "N/A" YearOfManufacture = "N/A" Status = "N/A – Informational" Message = "Virtual Machine, skipped monitor inventory." } } } Debugging to make sure there are results. #Write-Host "Results Count: $($Results.count)" If ($Results.count -gt 0) { $Results = $Results | Select ComputerName,Active,Manufacturer,UserFriendlyName,SerialNumber,WeekOfManufacture,YearOfManufacture,Status,Message if ($CSVReport) { $Results | Sort Status,ComputerName | Export-CSV -Path $CSVOutputFile -NoTypeInformation } if ($HTMLReport) { $Results | Sort Status,ComputerName | ConvertTo-HTML -Head $Header | Out-File $HTMLOutputFile } if ($EmailReportAsHTML) { $Body = $Results | Sort Status,ComputerName | ConvertTo-HTML -Head $Header | Out-String Send-MailMessage @SMTPProperties -Body $Body -BodyAsHTML } } Else { Write-Output "There were 0 results in the `$Results array." } *********
0debug
Aml *init_aml_allocator(void) { Aml *var; assert(!alloc_list); alloc_list = g_ptr_array_new(); var = aml_alloc(); return var; }
1threat
static av_cold int XAVS_init(AVCodecContext *avctx) { XavsContext *x4 = avctx->priv_data; x4->sei_size = 0; xavs_param_default(&x4->params); x4->params.pf_log = XAVS_log; x4->params.p_log_private = avctx; x4->params.i_keyint_max = avctx->gop_size; if (avctx->bit_rate) { x4->params.rc.i_bitrate = avctx->bit_rate / 1000; x4->params.rc.i_rc_method = XAVS_RC_ABR; } x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000; x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000; x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1; if (avctx->flags & CODEC_FLAG_PASS2) { x4->params.rc.b_stat_read = 1; } else { if (x4->crf >= 0) { x4->params.rc.i_rc_method = XAVS_RC_CRF; x4->params.rc.f_rf_constant = x4->crf; } else if (x4->cqp >= 0) { x4->params.rc.i_rc_method = XAVS_RC_CQP; x4->params.rc.i_qp_constant = x4->cqp; } } if (x4->aud >= 0) x4->params.b_aud = x4->aud; if (x4->mbtree >= 0) x4->params.rc.b_mb_tree = x4->mbtree; if (x4->direct_pred >= 0) x4->params.analyse.i_direct_mv_pred = x4->direct_pred; if (x4->fast_pskip >= 0) x4->params.analyse.b_fast_pskip = x4->fast_pskip; if (x4->mixed_refs >= 0) x4->params.analyse.b_mixed_references = x4->mixed_refs; if (x4->b_bias != INT_MIN) x4->params.i_bframe_bias = x4->b_bias; if (x4->cplxblur >= 0) x4->params.rc.f_complexity_blur = x4->cplxblur; x4->params.i_bframe = avctx->max_b_frames; x4->params.b_cabac = 0; x4->params.i_bframe_adaptive = avctx->b_frame_strategy; avctx->has_b_frames = !!avctx->max_b_frames; x4->params.i_keyint_min = avctx->keyint_min; if (x4->params.i_keyint_min > x4->params.i_keyint_max) x4->params.i_keyint_min = x4->params.i_keyint_max; x4->params.i_scenecut_threshold = avctx->scenechange_threshold; x4->params.rc.i_qp_min = avctx->qmin; x4->params.rc.i_qp_max = avctx->qmax; x4->params.rc.i_qp_step = avctx->max_qdiff; x4->params.rc.f_qcompress = avctx->qcompress; x4->params.rc.f_qblur = avctx->qblur; x4->params.i_frame_reference = avctx->refs; x4->params.i_width = avctx->width; x4->params.i_height = avctx->height; x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num; x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den; x4->params.i_fps_num = avctx->time_base.den; x4->params.i_fps_den = avctx->time_base.num; x4->params.analyse.inter = XAVS_ANALYSE_I8x8 |XAVS_ANALYSE_PSUB16x16| XAVS_ANALYSE_BSUB16x16; switch (avctx->me_method) { case ME_EPZS: x4->params.analyse.i_me_method = XAVS_ME_DIA; break; case ME_HEX: x4->params.analyse.i_me_method = XAVS_ME_HEX; break; case ME_UMH: x4->params.analyse.i_me_method = XAVS_ME_UMH; break; case ME_FULL: x4->params.analyse.i_me_method = XAVS_ME_ESA; break; case ME_TESA: x4->params.analyse.i_me_method = XAVS_ME_TESA; break; default: x4->params.analyse.i_me_method = XAVS_ME_HEX; } x4->params.analyse.i_me_range = avctx->me_range; x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA; x4->params.analyse.b_transform_8x8 = 1; x4->params.analyse.i_trellis = avctx->trellis; x4->params.analyse.i_noise_reduction = avctx->noise_reduction; if (avctx->level > 0) x4->params.i_level_idc = avctx->level; x4->params.rc.f_rate_tolerance = (float)avctx->bit_rate_tolerance/avctx->bit_rate; if ((avctx->rc_buffer_size) && (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) { x4->params.rc.f_vbv_buffer_init = (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size; } else x4->params.rc.f_vbv_buffer_init = 0.9; x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor); x4->params.rc.f_pb_factor = avctx->b_quant_factor; x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR; x4->params.i_log_level = XAVS_LOG_DEBUG; x4->params.i_threads = avctx->thread_count; x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT; if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) x4->params.b_repeat_headers = 0; x4->enc = xavs_encoder_open(&x4->params); if (!x4->enc) return -1; if (!(x4->pts_buffer = av_mallocz_array((avctx->max_b_frames+1), sizeof(*x4->pts_buffer)))) return AVERROR(ENOMEM); avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER && 0) { xavs_nal_t *nal; int nnal, s, i, size; uint8_t *p; s = xavs_encoder_headers(x4->enc, &nal, &nnal); avctx->extradata = p = av_malloc(s); for (i = 0; i < nnal; i++) { if (nal[i].i_type == NAL_SEI) { x4->sei = av_malloc( 5 + nal[i].i_payload * 4 / 3 ); if (xavs_nal_encode(x4->sei, &x4->sei_size, 1, nal + i) < 0) return -1; continue; } size = xavs_nal_encode(p, &s, 1, nal + i); if (size < 0) return -1; p += size; } avctx->extradata_size = p - avctx->extradata; } return 0; }
1threat
Android Image upload/download with Base64 into JSON causes Out of memory error : <p>I currently encode and decode images to Base64. I overcame the initial issue with OOM's with the use of streams to encode the images into strings.</p> <p>My issue now is that I cannot fathom how to add multiple Base64 encoded strings for multiple resolutions images (5620 x 3747 - 4.92MB or 3264 x 1836 - 1.35MB) to a JSON Object via Gson. Currently Gson throws an OOM exception only with 2 Base64 Strings from a 5312 x 2988 - 4.95 MB Image.</p> <p>I understand that android may only be able to spare 16/20Mb per application, so this conversion must be way over the limit.</p> <p>How can I write the Base64 String in a stream to a JSON object that will contain the specific values needed to post into my server?</p> <p>Would it be easier to change my server to accept a Multi-Part request instead of a JSON based POJO with multiple Base64 Strings? I currently use Volley and there isn't an official Multi-Part Request as well as IO streaming.</p> <p>If it's a matter of compression, how much compression should I apply to the image before encoding into a Base64 String? I ideally want to lose barely any quality but have optimal compression levels.</p> <p><strong>Bit more Information</strong></p> <p>I am uploading multiple different resolution images as it is a test for compatibility. For example, all the images that I am sending up have been taken on low resolution and extremely high resolution devices as my App relies on these images for functionality. I am trying to prove that any image (to a certain extent, mainly images captured on mobile devices) can be handled by my application.</p> <p>I understand that some images may be so large that by loading them into memory will cause exceptions. This is something I will try and handle later.</p> <p>In some cases the images that will be uploaded can span from 1 to 200.</p> <p>I'm trying to look for the most optimal solution that will scale well.</p>
0debug
static int ehci_state_advqueue(EHCIQueue *q, int async) { #if 0 if (I-bit set) { ehci_set_state(ehci, async, EST_HORIZONTALQH); goto out; } #endif if (((q->qh.token & QTD_TOKEN_TBYTES_MASK) != 0) && (q->qh.altnext_qtd > 0x1000) && (NLPTR_TBIT(q->qh.altnext_qtd) == 0)) { q->qtdaddr = q->qh.altnext_qtd; ehci_set_state(q->ehci, async, EST_FETCHQTD); } else if ((q->qh.next_qtd > 0x1000) && (NLPTR_TBIT(q->qh.next_qtd) == 0)) { q->qtdaddr = q->qh.next_qtd; ehci_set_state(q->ehci, async, EST_FETCHQTD); } else { ehci_set_state(q->ehci, async, EST_HORIZONTALQH); } return 1; }
1threat
How do I run a local command with fabric 2? : <p>I want to use Fabric and run a command on local, without having to establish any additional connections.</p> <p>How do I do this in <strong>fabric 2</strong>? ... <a href="http://docs.fabfile.org/en/2.3/api/connection.html?highlight=local" rel="noreferrer">documentation</a> seems to miss to give any example.</p>
0debug
def adjac(ele, sub = []): if not ele: yield sub else: yield from [idx for j in range(ele[0] - 1, ele[0] + 2) for idx in adjac(ele[1:], sub + [j])] def get_coordinates(test_tup): res = list(adjac(test_tup)) return (res)
0debug
int ff_rle_encode(uint8_t *outbuf, int out_size, const uint8_t *ptr , int bpp, int w, int add_rep, int xor_rep, int add_raw, int xor_raw) { int count, x; uint8_t *out = outbuf; for(x = 0; x < w; x += count) { if((count = count_pixels(ptr, w-x, bpp, 1)) > 1) { if(out + bpp + 1 > outbuf + out_size) return -1; *out++ = (count ^ xor_rep) + add_rep; memcpy(out, ptr, bpp); out += bpp; } else { count = count_pixels(ptr, w-x, bpp, 0); *out++ = (count ^ xor_raw) + add_raw; if(out + bpp*count > outbuf + out_size) return -1; memcpy(out, ptr, bpp * count); out += bpp * count; } ptr += count * bpp; } return out - outbuf; }
1threat
Python Converting Two Lists into Dynamic Nested Dict then to JSON, possible? : I have to go through a list of "colors": `list1 = ["red","green","other"]` for each one I need to go through a list of possible matches for each one: `list2 = ["cherries","rasperries","guava","apple","watermelon","grapes","banana"]` if the criteria of the item of list2 is good, then I'd need to create a dict to then write the output to JSON file. `for x in list1:` `print x` `for y in list2:` `if y == criteria:` `myDict = {'list1-item': 'fruit1':'apple'}` my expected output would be something like: `data = {'red': {'fruit1': 'cherries', 'fruit2': 'rasperries', 'fruit3': 'guava'}, 'green': {'fruit1': 'apple'}, 'other': {'fruit1': 'watermelon', 'fruit2': 'grapes', 'fruit3': 'banana'}}` #writing to JSON 'with open("data_file.json", "w") as write_file:' ` json.dump(data, write_file)` not really familiar to build a dynamic dictionary as need, any suggestion is appreciated.
0debug
API Gateway + Lambda + Python: Handling Exceptions : <p>I'm invoking a Python-based AWS Lambda method from API Gateway in non-proxy mode. How should I properly handle exceptions, so that an appropriate HTTP status code is set along with a JSON body using parts of the exception.</p> <p>As an example, I have the following handler:</p> <pre><code>def my_handler(event, context): try: s3conn.head_object(Bucket='my_bucket', Key='my_filename') except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == "404": raise ClientException("Key '{}' not found".format(filename)) # or: return "Key '{}' not found".format(filename) ? class ClientException(Exception): pass </code></pre> <p>Should I throw an exception or return a string? Then how should I configure the Integration Response? Obviously I've RTFM but the FM is FU.</p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Parcelable OR Serializable : Which is better option to communicate between two activities? : <p>I have bunch of data like Model classes, Array list &amp; some other data type based on requirements. </p> <p>Now, I am planning to start flexible &amp; light weight way to communicate with activities &amp; fragments with heavy data which should not be affect to UI.</p>
0debug
Activity crash while launching third party application : I am trying to start new application on certain Action click and suppose for any reason that application get crashed and doesn't launch,why is it crashing my current activity which started that application. launchmode for current activity is singleTask and same for other app as well and care has been taken to addFlag of NEW_TASK while launching the other application. I want behavior in such a way that even launching application get crashed then it should redirect the user to current activity(launcher activity) rather than crashing the current activity.
0debug
av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation) { const int isRgb = c->dstFormat == AV_PIX_FMT_RGB32 || c->dstFormat == AV_PIX_FMT_RGB32_1 || c->dstFormat == AV_PIX_FMT_BGR24 || c->dstFormat == AV_PIX_FMT_RGB565BE || c->dstFormat == AV_PIX_FMT_RGB565LE || c->dstFormat == AV_PIX_FMT_RGB555BE || c->dstFormat == AV_PIX_FMT_RGB555LE || c->dstFormat == AV_PIX_FMT_RGB444BE || c->dstFormat == AV_PIX_FMT_RGB444LE || c->dstFormat == AV_PIX_FMT_RGB8 || c->dstFormat == AV_PIX_FMT_RGB4 || c->dstFormat == AV_PIX_FMT_RGB4_BYTE || c->dstFormat == AV_PIX_FMT_MONOBLACK; const int isNotNe = c->dstFormat == AV_PIX_FMT_NE(RGB565LE, RGB565BE) || c->dstFormat == AV_PIX_FMT_NE(RGB555LE, RGB555BE) || c->dstFormat == AV_PIX_FMT_NE(RGB444LE, RGB444BE) || c->dstFormat == AV_PIX_FMT_NE(BGR565LE, BGR565BE) || c->dstFormat == AV_PIX_FMT_NE(BGR555LE, BGR555BE) || c->dstFormat == AV_PIX_FMT_NE(BGR444LE, BGR444BE); const int bpp = c->dstFormatBpp; uint8_t *y_table; uint16_t *y_table16; uint32_t *y_table32; int i, base, rbase, gbase, bbase, abase, needAlpha; const int yoffs = fullRange ? 384 : 326; int64_t crv = inv_table[0]; int64_t cbu = inv_table[1]; int64_t cgu = -inv_table[2]; int64_t cgv = -inv_table[3]; int64_t cy = 1 << 16; int64_t oy = 0; int64_t yb = 0; if (!fullRange) { cy = (cy * 255) / 219; oy = 16 << 16; } else { crv = (crv * 224) / 255; cbu = (cbu * 224) / 255; cgu = (cgu * 224) / 255; cgv = (cgv * 224) / 255; } cy = (cy * contrast) >> 16; crv = (crv * contrast * saturation) >> 32; cbu = (cbu * contrast * saturation) >> 32; cgu = (cgu * contrast * saturation) >> 32; cgv = (cgv * contrast * saturation) >> 32; oy -= 256 * brightness; c->uOffset = 0x0400040004000400LL; c->vOffset = 0x0400040004000400LL; c->yCoeff = roundToInt16(cy * 8192) * 0x0001000100010001ULL; c->vrCoeff = roundToInt16(crv * 8192) * 0x0001000100010001ULL; c->ubCoeff = roundToInt16(cbu * 8192) * 0x0001000100010001ULL; c->vgCoeff = roundToInt16(cgv * 8192) * 0x0001000100010001ULL; c->ugCoeff = roundToInt16(cgu * 8192) * 0x0001000100010001ULL; c->yOffset = roundToInt16(oy * 8) * 0x0001000100010001ULL; c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy << 13); c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9); c->yuv2rgb_v2r_coeff = (int16_t)roundToInt16(crv << 13); c->yuv2rgb_v2g_coeff = (int16_t)roundToInt16(cgv << 13); c->yuv2rgb_u2g_coeff = (int16_t)roundToInt16(cgu << 13); c->yuv2rgb_u2b_coeff = (int16_t)roundToInt16(cbu << 13); crv = ((crv << 16) + 0x8000) / cy; cbu = ((cbu << 16) + 0x8000) / cy; cgu = ((cgu << 16) + 0x8000) / cy; cgv = ((cgv << 16) + 0x8000) / cy; av_free(c->yuvTable); switch (bpp) { case 1: c->yuvTable = av_malloc(1024); y_table = c->yuvTable; yb = -(384 << 16) - oy; for (i = 0; i < 1024 - 110; i++) { y_table[i + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7; yb += cy; } fill_table(c->table_gU, 1, cgu, y_table + yoffs); fill_gv_table(c->table_gV, 1, cgv); break; case 4: case 4 | 128: rbase = isRgb ? 3 : 0; gbase = 1; bbase = isRgb ? 0 : 3; c->yuvTable = av_malloc(1024 * 3); y_table = c->yuvTable; yb = -(384 << 16) - oy; for (i = 0; i < 1024 - 110; i++) { int yval = av_clip_uint8((yb + 0x8000) >> 16); y_table[i + 110] = (yval >> 7) << rbase; y_table[i + 37 + 1024] = ((yval + 43) / 85) << gbase; y_table[i + 110 + 2048] = (yval >> 7) << bbase; yb += cy; } fill_table(c->table_rV, 1, crv, y_table + yoffs); fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024); fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048); fill_gv_table(c->table_gV, 1, cgv); break; case 8: rbase = isRgb ? 5 : 0; gbase = isRgb ? 2 : 3; bbase = isRgb ? 0 : 6; c->yuvTable = av_malloc(1024 * 3); y_table = c->yuvTable; yb = -(384 << 16) - oy; for (i = 0; i < 1024 - 38; i++) { int yval = av_clip_uint8((yb + 0x8000) >> 16); y_table[i + 16] = ((yval + 18) / 36) << rbase; y_table[i + 16 + 1024] = ((yval + 18) / 36) << gbase; y_table[i + 37 + 2048] = ((yval + 43) / 85) << bbase; yb += cy; } fill_table(c->table_rV, 1, crv, y_table + yoffs); fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024); fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048); fill_gv_table(c->table_gV, 1, cgv); break; case 12: rbase = isRgb ? 8 : 0; gbase = 4; bbase = isRgb ? 0 : 8; c->yuvTable = av_malloc(1024 * 3 * 2); y_table16 = c->yuvTable; yb = -(384 << 16) - oy; for (i = 0; i < 1024; i++) { uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16); y_table16[i] = (yval >> 4) << rbase; y_table16[i + 1024] = (yval >> 4) << gbase; y_table16[i + 2048] = (yval >> 4) << bbase; yb += cy; } if (isNotNe) for (i = 0; i < 1024 * 3; i++) y_table16[i] = av_bswap16(y_table16[i]); fill_table(c->table_rV, 2, crv, y_table16 + yoffs); fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024); fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048); fill_gv_table(c->table_gV, 2, cgv); break; case 15: case 16: rbase = isRgb ? bpp - 5 : 0; gbase = 5; bbase = isRgb ? 0 : (bpp - 5); c->yuvTable = av_malloc(1024 * 3 * 2); y_table16 = c->yuvTable; yb = -(384 << 16) - oy; for (i = 0; i < 1024; i++) { uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16); y_table16[i] = (yval >> 3) << rbase; y_table16[i + 1024] = (yval >> (18 - bpp)) << gbase; y_table16[i + 2048] = (yval >> 3) << bbase; yb += cy; } if (isNotNe) for (i = 0; i < 1024 * 3; i++) y_table16[i] = av_bswap16(y_table16[i]); fill_table(c->table_rV, 2, crv, y_table16 + yoffs); fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024); fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048); fill_gv_table(c->table_gV, 2, cgv); break; case 24: case 48: c->yuvTable = av_malloc(1024); y_table = c->yuvTable; yb = -(384 << 16) - oy; for (i = 0; i < 1024; i++) { y_table[i] = av_clip_uint8((yb + 0x8000) >> 16); yb += cy; } fill_table(c->table_rV, 1, crv, y_table + yoffs); fill_table(c->table_gU, 1, cgu, y_table + yoffs); fill_table(c->table_bU, 1, cbu, y_table + yoffs); fill_gv_table(c->table_gV, 1, cgv); break; case 32: base = (c->dstFormat == AV_PIX_FMT_RGB32_1 || c->dstFormat == AV_PIX_FMT_BGR32_1) ? 8 : 0; rbase = base + (isRgb ? 16 : 0); gbase = base + 8; bbase = base + (isRgb ? 0 : 16); needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat); if (!needAlpha) abase = (base + 24) & 31; c->yuvTable = av_malloc(1024 * 3 * 4); y_table32 = c->yuvTable; yb = -(384 << 16) - oy; for (i = 0; i < 1024; i++) { unsigned yval = av_clip_uint8((yb + 0x8000) >> 16); y_table32[i] = (yval << rbase) + (needAlpha ? 0 : (255u << abase)); y_table32[i + 1024] = yval << gbase; y_table32[i + 2048] = yval << bbase; yb += cy; } fill_table(c->table_rV, 4, crv, y_table32 + yoffs); fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + 1024); fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2048); fill_gv_table(c->table_gV, 4, cgv); break; default: c->yuvTable = NULL; if(!isPlanar(c->dstFormat) || bpp <= 24) av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp); return -1; } return 0; }
1threat
What happen to SketchFlow and what we should use instead? : <p>What is the new <strong>Microsoft way</strong> of UI prototyping since VS2015 doesn't support SketchFlow projects. <em>(I'm having hard time to accept that they removed such a useful tool without providing alternative)</em></p> <blockquote> <p>I know we still have <em>PowerPoint StoryBoards</em> for basic UI mock-ups but I would like to use interactive prototypes through Visual Studio. <em><strong>Therefore please do not suggest alternative products</strong></em></p> </blockquote>
0debug
about creating array with 0s and 1s, and making the content in random order : <p>In java, what I should do the create an array with half of data is 0s, half 1s? And what I should do to use Randomize (shuffle) the contents of the array</p>
0debug
static void con_disconnect(struct XenDevice *xendev) { struct XenConsole *con = container_of(xendev, struct XenConsole, xendev); if (!xendev->dev) { return; } if (con->chr) { qemu_chr_add_handlers(con->chr, NULL, NULL, NULL, NULL); qemu_chr_fe_release(con->chr); } xen_be_unbind_evtchn(&con->xendev); if (con->sring) { if (!xendev->gnttabdev) { munmap(con->sring, XC_PAGE_SIZE); } else { xc_gnttab_munmap(xendev->gnttabdev, con->sring, 1); } con->sring = NULL; } }
1threat
Mocha only running one test file : <p>My Mocha tests were working fine, but when I added a new module (and test), mocha stopped running all of my test files and now only runs the single new test.</p> <p>My test script:</p> <pre><code>env NODE_PATH=$NODE_PATH:$PWD/src mocha --recursive --compilers js:babel-core/register src/**/*.test.js --require babel-polyfill </code></pre> <p>My project is structured like this:</p> <pre><code>/src /components /component-name index.js component.js component-name.test.js style.scss /util /module-name index.js module-name.test.js /some-other-module index.js some-other-module.test.js </code></pre> <p>I had several tests in <code>/components</code> and <code>/util</code> and everything worked fine, but when I place a module into <code>/src</code> (like <code>/some-other-module</code>) with a <code>.test.js</code> file in it, Mocha only runs that test file and none of the others.</p>
0debug
tcp_listen(Slirp *slirp, u_int32_t haddr, u_int hport, u_int32_t laddr, u_int lport, int flags) { struct sockaddr_in addr; struct socket *so; int s, opt = 1; socklen_t addrlen = sizeof(addr); DEBUG_CALL("tcp_listen"); DEBUG_ARG("haddr = %x", haddr); DEBUG_ARG("hport = %d", hport); DEBUG_ARG("laddr = %x", laddr); DEBUG_ARG("lport = %d", lport); DEBUG_ARG("flags = %x", flags); so = socreate(slirp); if (!so) { return NULL; } if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL) { free(so); return NULL; } insque(so, &slirp->tcb); if (flags & SS_FACCEPTONCE) so->so_tcpcb->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT*2; so->so_state &= SS_PERSISTENT_MASK; so->so_state |= (SS_FACCEPTCONN | flags); so->so_lport = lport; so->so_laddr.s_addr = laddr; addr.sin_family = AF_INET; addr.sin_addr.s_addr = haddr; addr.sin_port = hport; if (((s = socket(AF_INET,SOCK_STREAM,0)) < 0) || (setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)) < 0) || (bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) || (listen(s,1) < 0)) { int tmperrno = errno; close(s); sofree(so); #ifdef _WIN32 WSASetLastError(tmperrno); #else errno = tmperrno; #endif return NULL; } setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int)); getsockname(s,(struct sockaddr *)&addr,&addrlen); so->so_fport = addr.sin_port; if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr) so->so_faddr = slirp->vhost_addr; else so->so_faddr = addr.sin_addr; so->s = s; return so; }
1threat
In which situations a finally block is not executed in C#? : <p>How to skip finally block in C#?</p> <p>Is it possible to skip the 'finally' block even though its present after a try And catch block.</p>
0debug
Change the favicon of the Sphinx Read The Docs theme? : <p>I'm already using a custom css to override some of the styles of the theme using </p> <pre><code>def setup(app): app.add_css_file('custom.css') </code></pre> <p>This works fine. What other app. functions are available? I can't find any documentation.</p> <p>I'm looking for the function to override the favicon.</p>
0debug
How to print floats with for loop without other functions BUT range() : <p>I want to Print all the numbers between 5 to 8, with jumps of 0.3. I got 2 problems doing it:</p> <ol> <li><p>It's not very accurate (I know the reason, what I dont know is how to get 5.89999999999 to become 5.9)</p></li> <li><p>I dont know how to do it without any imports and functions (without numpy and without xrange which btw does not exist in python 3.x anymore as I understood)</p></li> </ol> <p>This is just for a Homework question, I'm a new python learner, so I dont realy know ALL the tools and tricks of python.</p> <pre><code>max = 9 min = 5 step = 0.3 while min &lt;= max: min += step print(min) Expected: 5, 5.3, 5.6, 5.9, 6.2, ... Actual reasults: 5.3, 5.6, 5.89999999995, 6.1999999999, 6.4999999999, ... </code></pre>
0debug