problem
stringlengths
26
131k
labels
class label
2 classes
static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, int point_transform, int nb_components) { int i, mb_x, mb_y, mask; int bits= (s->bits+7)&~7; int resync_mb_y = 0; int resync_mb_x = 0; point_transform += bits - s->bits; mask = ((1 << s->bits) - 1) << point_transform; av_assert0(nb_components>=1 && nb_components<=4); for (mb_y = 0; mb_y < s->mb_height; mb_y++) { for (mb_x = 0; mb_x < s->mb_width; mb_x++) { if (get_bits_left(&s->gb) < 1) { av_log(s->avctx, AV_LOG_ERROR, "bitstream end in yuv_scan\n"); return AVERROR_INVALIDDATA; } if (s->restart_interval && !s->restart_count){ s->restart_count = s->restart_interval; resync_mb_x = mb_x; resync_mb_y = mb_y; } if(!mb_x || mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x || s->interlaced){ int toprow = mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x; int leftcol = !mb_x || mb_y == resync_mb_y && mb_x == resync_mb_x; for (i = 0; i < nb_components; i++) { uint8_t *ptr; uint16_t *ptr16; int n, h, v, x, y, c, j, linesize; n = s->nb_blocks[i]; c = s->comp_index[i]; h = s->h_scount[i]; v = s->v_scount[i]; x = 0; y = 0; linesize= s->linesize[c]; if(bits>8) linesize /= 2; for(j=0; j<n; j++) { int pred, dc; dc = mjpeg_decode_dc(s, s->dc_index[i]); if(dc == 0xFFFFF) return -1; if ( h * mb_x + x >= s->width || v * mb_y + y >= s->height) { } else if (bits<=8) { ptr = s->picture_ptr->data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); if(y==0 && toprow){ if(x==0 && leftcol){ pred= 1 << (bits - 1); }else{ pred= ptr[-1]; } }else{ if(x==0 && leftcol){ pred= ptr[-linesize]; }else{ PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor); } } if (s->interlaced && s->bottom_field) ptr += linesize >> 1; pred &= mask; *ptr= pred + ((unsigned)dc << point_transform); }else{ ptr16 = (uint16_t*)(s->picture_ptr->data[c] + 2*(linesize * (v * mb_y + y)) + 2*(h * mb_x + x)); if(y==0 && toprow){ if(x==0 && leftcol){ pred= 1 << (bits - 1); }else{ pred= ptr16[-1]; } }else{ if(x==0 && leftcol){ pred= ptr16[-linesize]; }else{ PREDICT(pred, ptr16[-linesize-1], ptr16[-linesize], ptr16[-1], predictor); } } if (s->interlaced && s->bottom_field) ptr16 += linesize >> 1; pred &= mask; *ptr16= pred + (dc << point_transform); } if (++x == h) { x = 0; y++; } } } } else { for (i = 0; i < nb_components; i++) { uint8_t *ptr; uint16_t *ptr16; int n, h, v, x, y, c, j, linesize, dc; n = s->nb_blocks[i]; c = s->comp_index[i]; h = s->h_scount[i]; v = s->v_scount[i]; x = 0; y = 0; linesize = s->linesize[c]; if(bits>8) linesize /= 2; for (j = 0; j < n; j++) { int pred; dc = mjpeg_decode_dc(s, s->dc_index[i]); if(dc == 0xFFFFF) return -1; if ( h * mb_x + x >= s->width || v * mb_y + y >= s->height) { } else if (bits<=8) { ptr = s->picture_ptr->data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor); pred &= mask; *ptr = pred + (dc << point_transform); }else{ ptr16 = (uint16_t*)(s->picture_ptr->data[c] + 2*(linesize * (v * mb_y + y)) + 2*(h * mb_x + x)); PREDICT(pred, ptr16[-linesize-1], ptr16[-linesize], ptr16[-1], predictor); pred &= mask; *ptr16= pred + (dc << point_transform); } if (++x == h) { x = 0; y++; } } } } if (s->restart_interval && !--s->restart_count) { align_get_bits(&s->gb); skip_bits(&s->gb, 16); } } } return 0; }
1threat
static struct mmsghdr *build_l2tpv3_vector(NetL2TPV3State *s, int count) { int i; struct iovec *iov; struct mmsghdr *msgvec, *result; msgvec = g_malloc(sizeof(struct mmsghdr) * count); result = msgvec; for (i = 0; i < count ; i++) { msgvec->msg_hdr.msg_name = NULL; msgvec->msg_hdr.msg_namelen = 0; iov = g_malloc(sizeof(struct iovec) * IOVSIZE); msgvec->msg_hdr.msg_iov = iov; iov->iov_base = g_malloc(s->header_size); iov->iov_len = s->header_size; iov++ ; iov->iov_base = qemu_memalign(BUFFER_ALIGN, BUFFER_SIZE); iov->iov_len = BUFFER_SIZE; msgvec->msg_hdr.msg_iovlen = 2; msgvec->msg_hdr.msg_control = NULL; msgvec->msg_hdr.msg_controllen = 0; msgvec->msg_hdr.msg_flags = 0; msgvec++; } return result; }
1threat
if input is abcdexyzbwqpoolj the output should be b.find first repeating character : #include<stdio.h> #include <stdlib.h> #include<string.h> int main() { int i,j; char str[1000]; scanf("%s",str);//input the string for( i=0;i<strlen(str);i++) { for(j=i+1;j<strlen(str);j++) { if(str[i]==str[j])//compare { printf("%c",str[i]); } } } } This is printing all the repeating characters.Please correct this code
0debug
updating the label from changing the value from rating : how do i code peer to peer textboxes connected to label, it is a rating system in asp.net using vb codes, when i rate "1" to textbox1, the textbox2 will appear in the label1 then when i rate 2 in textbox1 the textbox2 value will appear in label2, the same in textbox3, when i rate "1", textbox4 will appear to label 1, the problem is... when i changed the value of textbox1 from "1" to "3", then the value of label is not clearing, but it goes to label 3... how can i possibly update the recent label from changing the value of rate!
0debug
THEN ARRAY EMPTY PROMISSE : <p>Create a method to fetch time in the firestore by calling the promise, but the array comes empty because the promise has not yet been resolved. How to resolve to call the array only when a getTime () call terminates.</p> <p>Angular Cli 8</p> <pre><code>example.service.ts teste: []; getTime() { this.userCollection.ref.get() .then(res =&gt; { if (res.docs.length == 0) { alert('Não existem marcacoes até o momento por favor aguarde') } else { res.forEach(ponto =&gt; { console.log(ponto.id); console.log(ponto.data().time.seconds * 1000); this.time.push(new Date((ponto.data().time.seconds * 1000))); }) } }).catch(err =&gt; { console.log(err); }) } </code></pre> <pre><code>example.component.ts ngOnInit() { this.mainService.getTime(); console.log(this.mainService.time); } </code></pre> <p>I hope the array variable is already complete when I call it.</p>
0debug
detecting if a text is non-English : What is the most accurate method for detecting if a text (specifically Instagram comments) are non-English? Your code could be in any language prefferably Python, php, etc. $ sudo pip2 install guess_language >>> from guess_language import guessLanguage >>> guessLanguage('la vita e bella') 'UNKNOWN' >>> guessLanguage('today is a good day') 'UNKNOWN' >>> guessLanguage('ボウリング・フォー・コロンバイン(字幕版)') 'ja' and with $ sudo apt-get install php5.6-mbstring if(strlen($comment->text) == mb_strlen($comment->text, 'utf-8')) { echo '- '.$comment->text."\n"; } I get many things with English character which are not English: examples: - Khoda be khanevadehashon sabr bede tahamol konan - Akhey... - Eshghi - K - :-) - Ey khodaa - ... - @samaneaghazamani1990 vaaaaay khoda chejoori payam dadan? - :( - Elahiiiii - May Allah please with them and grant higher rank of jannah salutes to the bravehearts @taraneh_alidoosti @fanpagemostafazamani - Elaaaahiii - Roohetoon shad. - :'( - Roheshon shad!! Yadeshon gerami!! - .:'( - :-( - Oooo - Awli I don't want to use something like Google Translate as I am dealing with lots of data.
0debug
static void vda_decoder_callback(void *vda_hw_ctx, CFDictionaryRef user_info, OSStatus status, uint32_t infoFlags, CVImageBufferRef image_buffer) { struct vda_context *vda_ctx = vda_hw_ctx; if (!image_buffer) return; if (vda_ctx->cv_pix_fmt_type != CVPixelBufferGetPixelFormatType(image_buffer)) return; vda_ctx->cv_buffer = CVPixelBufferRetain(image_buffer); }
1threat
Loop ignores limits: How can I handle this corrupt c++ program? : <p>When I execute my program it doesn't terminate. I haven't changed anything and it has been working before. There is clearly something wrong but I don't understand what and why.</p> <p>In the screenshot you can see the line</p> <pre><code>for ( size_t n = 0; n &lt;= (size_t)maxState; n++ ) nodes.push_back(nullptr); </code></pre> <p>You can also see that <code>maxState</code> is -1, so <code>(size_t)maxState</code> should be 0. On the right side of the image you can see the values for n and the size of the <code>nodes</code> vector.</p> <p><a href="https://i.stack.imgur.com/IaPrO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IaPrO.png" alt="n goes to infitiny"></a></p> <p>I've taken the screenshot after pausing execution. When I resume it doesn't terminate. I've read some things about heap corruption, but without working solutions. Also I'm not sure if heap corruption is the real cause for this strange effect.</p> <p>I already tried to clean and rebuild.</p>
0debug
static void guess_palette(DVDSubContext* ctx, uint32_t *rgba_palette, uint32_t subtitle_color) { static const uint8_t level_map[4][4] = { {0xff}, {0x00, 0xff}, {0x00, 0x80, 0xff}, {0x00, 0x55, 0xaa, 0xff}, }; uint8_t color_used[16] = { 0 }; int nb_opaque_colors, i, level, j, r, g, b; uint8_t *colormap = ctx->colormap, *alpha = ctx->alpha; if(ctx->has_palette) { for(i = 0; i < 4; i++) rgba_palette[i] = (ctx->palette[colormap[i]] & 0x00ffffff) | ((alpha[i] * 17U) << 24); return; } for(i = 0; i < 4; i++) rgba_palette[i] = 0; nb_opaque_colors = 0; for(i = 0; i < 4; i++) { if (alpha[i] != 0 && !color_used[colormap[i]]) { color_used[colormap[i]] = 1; nb_opaque_colors++; } } if (nb_opaque_colors == 0) return; j = 0; memset(color_used, 0, 16); for(i = 0; i < 4; i++) { if (alpha[i] != 0) { if (!color_used[colormap[i]]) { level = level_map[nb_opaque_colors - 1][j]; r = (((subtitle_color >> 16) & 0xff) * level) >> 8; g = (((subtitle_color >> 8) & 0xff) * level) >> 8; b = (((subtitle_color >> 0) & 0xff) * level) >> 8; rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17) << 24); color_used[colormap[i]] = (i + 1); j++; } else { rgba_palette[i] = (rgba_palette[color_used[colormap[i]] - 1] & 0x00ffffff) | ((alpha[i] * 17) << 24); } } } }
1threat
void HELPER(ipte)(CPUS390XState *env, uint64_t pto, uint64_t vaddr, uint32_t m4) { CPUState *cs = CPU(s390_env_get_cpu(env)); uint64_t page = vaddr & TARGET_PAGE_MASK; uint64_t pte_addr, pte; pte_addr = (pto & _SEGMENT_ENTRY_ORIGIN); pte_addr += (vaddr & VADDR_PX) >> 9; pte = ldq_phys(cs->as, pte_addr); pte |= _PAGE_INVALID; stq_phys(cs->as, pte_addr, pte); if (m4 & 1) { tlb_flush_page(cs, page); } else { tlb_flush_page_all_cpus_synced(cs, page); } if (m4 & 1) { tlb_flush_page(cs, page ^ 0x80000000); } else { tlb_flush_page_all_cpus_synced(cs, page ^ 0x80000000); } }
1threat
Date and time in 24 hours format : <p>I have a date in this format <code>Fri, 15 Jan 2016 15:14:10 +0800</code>, and I want to display time like this <code>2016-01-15 15:14:10</code>.</p> <p>What I tried is:</p> <pre><code>$test = 'Fri, 15 Jan 2016 15:14:10 +0800'; $t = date('Y-m-d G:i:s',strtotime($test)); echo $t; </code></pre> <p>But it is displaying date in this format: <code>2016-01-15 7:14:10</code>, it should be <code>2016-01-15 15:14:10</code>.</p> <p>How can i do this?</p>
0debug
Ruby 1.9.3 Digest::SHA1.hexdigest equivalent in Golang : <p>How can I replicate this method from Ruby 1.9.3 to Golang 1.7?</p> <pre><code>require 'digest/sha2' text = Digest::SHA1.hexdigest("Hello world") </code></pre>
0debug
static void apply_delogo(uint8_t *dst, int dst_linesize, uint8_t *src, int src_linesize, int w, int h, AVRational sar, int logo_x, int logo_y, int logo_w, int logo_h, unsigned int band, int show, int direct) { int x, y; uint64_t interp, weightl, weightr, weightt, weightb; uint8_t *xdst, *xsrc; uint8_t *topleft, *botleft, *topright; unsigned int left_sample, right_sample; int xclipl, xclipr, yclipt, yclipb; int logo_x1, logo_x2, logo_y1, logo_y2; xclipl = FFMAX(-logo_x, 0); xclipr = FFMAX(logo_x+logo_w-w, 0); yclipt = FFMAX(-logo_y, 0); yclipb = FFMAX(logo_y+logo_h-h, 0); logo_x1 = logo_x + xclipl; logo_x2 = logo_x + logo_w - xclipr; logo_y1 = logo_y + yclipt; logo_y2 = logo_y + logo_h - yclipb; topleft = src+logo_y1 * src_linesize+logo_x1; topright = src+logo_y1 * src_linesize+logo_x2-1; botleft = src+(logo_y2-1) * src_linesize+logo_x1; if (!direct) av_image_copy_plane(dst, dst_linesize, src, src_linesize, w, h); dst += (logo_y1 + 1) * dst_linesize; src += (logo_y1 + 1) * src_linesize; for (y = logo_y1+1; y < logo_y2-1; y++) { left_sample = topleft[src_linesize*(y-logo_y1)] + topleft[src_linesize*(y-logo_y1-1)] + topleft[src_linesize*(y-logo_y1+1)]; right_sample = topright[src_linesize*(y-logo_y1)] + topright[src_linesize*(y-logo_y1-1)] + topright[src_linesize*(y-logo_y1+1)]; for (x = logo_x1+1, xdst = dst+logo_x1+1, xsrc = src+logo_x1+1; x < logo_x2-1; x++, xdst++, xsrc++) { weightl = (uint64_t) (logo_x2-1-x) * (y-logo_y1) * (logo_y2-1-y) * sar.den; weightr = (uint64_t)(x-logo_x1) * (y-logo_y1) * (logo_y2-1-y) * sar.den; weightt = (uint64_t)(x-logo_x1) * (logo_x2-1-x) * (logo_y2-1-y) * sar.num; weightb = (uint64_t)(x-logo_x1) * (logo_x2-1-x) * (y-logo_y1) * sar.num; interp = left_sample * weightl + right_sample * weightr + (topleft[x-logo_x1] + topleft[x-logo_x1-1] + topleft[x-logo_x1+1]) * weightt + (botleft[x-logo_x1] + botleft[x-logo_x1-1] + botleft[x-logo_x1+1]) * weightb; interp /= (weightl + weightr + weightt + weightb) * 3U; if (y >= logo_y+band && y < logo_y+logo_h-band && x >= logo_x+band && x < logo_x+logo_w-band) { *xdst = interp; } else { unsigned dist = 0; if (x < logo_x+band) dist = FFMAX(dist, logo_x-x+band); else if (x >= logo_x+logo_w-band) dist = FFMAX(dist, x-(logo_x+logo_w-1-band)); if (y < logo_y+band) dist = FFMAX(dist, logo_y-y+band); else if (y >= logo_y+logo_h-band) dist = FFMAX(dist, y-(logo_y+logo_h-1-band)); *xdst = (*xsrc*dist + interp*(band-dist))/band; if (show && (dist == band-1)) *xdst = 0; } } dst += dst_linesize; src += src_linesize; } }
1threat
How do I make my code look for a name in my list instead of a number? : <p>I have a file called classgrades.txt and it contains student data from a sample class. Each line in the file consists of a student's last name, a space, and a sequence of integers (separated by spaces), which represent scores on assignments.</p> <p>I am trying to write a Python program to read the data from this file and to write a new file called classscores.txt . Each line of classscores.txt should consist of a student's last name and their average score on the assignments, rounded <strong>down</strong> to the nearest integer.</p> <p>I've tried to find a way using the length of the list to go through it and once it reaches a name, it stops and takes all the previous numbers and finds the average and puts it next to the name.</p> <pre class="lang-py prettyprint-override"><code>inFile = open('classgrades.txt','r') lines = inFile.read() outFile = open('classcores.txt','w') fix_list = lines.replace('\n',' ') new_list = fix_list.split(' ') length_list = len(new_list) - 1 </code></pre> <p>Here is what my current list looks like after this code:</p> <p><code>['Chapman', '90', '100', '85', '66', '80', '55', 'Cleese', '80', '90', '85', '88', 'Gilliam', '78', '82', '80', '80', '75', '77', 'Idle', '91', 'Jones', '68', '90', '22', '100', '0', '80', '85', 'Palin', '80', '90', '80', '90', '']</code></p> <p>It should output everything nicely in classscores.txt</p>
0debug
Is there a shortcut way to create a new object if an object is null? : <p>I have some simple code:</p> <pre><code> public static void InitializeScreenTimeStopwatch() { if (ScreenTimeStopwatch == null) ScreenTimeStopwatch = new Stopwatch(); } </code></pre> <p>Is there a simple way that this code can be refactored using the ? operator that's now with the latest version of C#</p>
0debug
Making TabLayout text bold : <p>I'm using the TabLayout from the Android Design Support library and want to style its text (title). Specifically making it bold. How to achieve that in <strong>XML</strong> only?</p> <pre><code>&lt;android.support.design.widget.TabLayout android:id="@+id/sliding_tabs" android:layout_width="match_parent" app:tabTextColor="@color/white" app:tabSelectedTextColor="@color/white" app:tabIndicatorColor="@color/accent" android:layout_height="wrap_content" app:tabIndicatorHeight="3dp" /&gt; </code></pre>
0debug
static void pmac_ide_writeb (void *opaque, target_phys_addr_t addr, uint32_t val) { MACIOIDEState *d = opaque; addr = (addr & 0xFFF) >> 4; switch (addr) { case 1 ... 7: ide_ioport_write(&d->bus, addr, val); break; case 8: case 22: ide_cmd_write(&d->bus, 0, val); break; default: break; } }
1threat
static void single_quote_string(void) { int i; struct { const char *encoded; const char *decoded; } test_cases[] = { { "'hello world'", "hello world" }, { "'the quick brown fox \\' jumped over the fence'", "the quick brown fox ' jumped over the fence" }, {} }; for (i = 0; test_cases[i].encoded; i++) { QObject *obj; QString *str; obj = qobject_from_json(test_cases[i].encoded, NULL); str = qobject_to_qstring(obj); g_assert(str); g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0); QDECREF(str); } }
1threat
static void mirror_set_speed(BlockJob *job, int64_t speed, Error **errp) { MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); if (speed < 0) { error_setg(errp, QERR_INVALID_PARAMETER, "speed"); return; } ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME); }
1threat
Adding buttons to toolbar programmatically in swift : <p>I'm having a hard time adding a button to the toolbar in swift, below you can see an image of the toolbar that I'm after, unfortunately even though I have it designed in my Storyboard file, it doesn't show up when setting the toolbar to be visible.</p> <p>The way that I have designed this is two items, the first being a <code>flexable space</code> element, and the second being an <code>add</code> element. It looks like this:</p> <p><a href="https://i.stack.imgur.com/tPFXA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tPFXA.png" alt="enter image description here"></a></p> <p>Here's the code that I've used to attempt to replicate this in code:</p> <pre><code>self.navigationController?.toolbarHidden = false self.navigationController?.toolbarItems = [UIBarButtonItem]() self.navigationController?.toolbarItems?.append( UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: self, action: nil) ) self.navigationController?.toolbarItems?.append( UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "onClickedToolbeltButton:") ) </code></pre> <p>As you can see I'm setting the toolbar to be visible, initializing (and clearing) the toolbarItems array of UIBarButtonItem, and then adding two UIBarButtonItem's to the array, in the proper order.</p> <p>However, the toolbelt remains empty, why is this? </p>
0debug
static int rtmp_open(URLContext *s, const char *uri, int flags) { RTMPContext *rt = s->priv_data; char proto[8], hostname[256], path[1024], auth[100], *fname; char *old_app, *qmark, fname_buffer[1024]; uint8_t buf[2048]; int port; AVDictionary *opts = NULL; int ret; if (rt->listen_timeout > 0) rt->listen = 1; rt->is_input = !(flags & AVIO_FLAG_WRITE); av_url_split(proto, sizeof(proto), auth, sizeof(auth), hostname, sizeof(hostname), &port, path, sizeof(path), s->filename); if (strchr(path, ' ')) { av_log(s, AV_LOG_WARNING, "Detected librtmp style URL parameters, these aren't supported " "by the libavformat internal RTMP handler currently enabled. " "See the documentation for the correct way to pass parameters.\n"); } if (auth[0]) { char *ptr = strchr(auth, ':'); if (ptr) { *ptr = '\0'; av_strlcpy(rt->username, auth, sizeof(rt->username)); av_strlcpy(rt->password, ptr + 1, sizeof(rt->password)); } } if (rt->listen && strcmp(proto, "rtmp")) { av_log(s, AV_LOG_ERROR, "rtmp_listen not available for %s\n", proto); return AVERROR(EINVAL); } if (!strcmp(proto, "rtmpt") || !strcmp(proto, "rtmpts")) { if (!strcmp(proto, "rtmpts")) av_dict_set(&opts, "ffrtmphttp_tls", "1", 1); ff_url_join(buf, sizeof(buf), "ffrtmphttp", NULL, hostname, port, NULL); } else if (!strcmp(proto, "rtmps")) { if (port < 0) port = RTMPS_DEFAULT_PORT; ff_url_join(buf, sizeof(buf), "tls", NULL, hostname, port, NULL); } else if (!strcmp(proto, "rtmpe") || (!strcmp(proto, "rtmpte"))) { if (!strcmp(proto, "rtmpte")) av_dict_set(&opts, "ffrtmpcrypt_tunneling", "1", 1); ff_url_join(buf, sizeof(buf), "ffrtmpcrypt", NULL, hostname, port, NULL); rt->encrypted = 1; } else { if (port < 0) port = RTMP_DEFAULT_PORT; if (rt->listen) ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, "?listen&listen_timeout=%d", rt->listen_timeout * 1000); else ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); } reconnect: if ((ret = ffurl_open(&rt->stream, buf, AVIO_FLAG_READ_WRITE, &s->interrupt_callback, &opts)) < 0) { av_log(s , AV_LOG_ERROR, "Cannot open connection %s\n", buf); goto fail; } if (rt->swfverify) { if ((ret = rtmp_calc_swfhash(s)) < 0) goto fail; } rt->state = STATE_START; if (!rt->listen && (ret = rtmp_handshake(s, rt)) < 0) goto fail; if (rt->listen && (ret = rtmp_server_handshake(s, rt)) < 0) goto fail; rt->out_chunk_size = 128; rt->in_chunk_size = 128; rt->state = STATE_HANDSHAKED; old_app = rt->app; rt->app = av_malloc(APP_MAX_LENGTH); if (!rt->app) { ret = AVERROR(ENOMEM); goto fail; } qmark = strchr(path, '?'); if (qmark && strstr(qmark, "slist=")) { char* amp; av_strlcpy(rt->app, path + 1, FFMIN(qmark - path, APP_MAX_LENGTH)); fname = strstr(path, "slist=") + 6; amp = strchr(fname, '&'); if (amp) { av_strlcpy(fname_buffer, fname, FFMIN(amp - fname + 1, sizeof(fname_buffer))); fname = fname_buffer; } } else if (!strncmp(path, "/ondemand/", 10)) { fname = path + 10; memcpy(rt->app, "ondemand", 9); } else { char *next = *path ? path + 1 : path; char *p = strchr(next, '/'); if (!p) { fname = next; rt->app[0] = '\0'; } else { char *c = strchr(p + 1, ':'); fname = strchr(p + 1, '/'); if (!fname || (c && c < fname)) { fname = p + 1; av_strlcpy(rt->app, path + 1, FFMIN(p - path, APP_MAX_LENGTH)); } else { fname++; av_strlcpy(rt->app, path + 1, FFMIN(fname - path - 1, APP_MAX_LENGTH)); } } } if (old_app) { if (strlen(old_app) >= APP_MAX_LENGTH) { ret = AVERROR(EINVAL); goto fail; } av_free(rt->app); rt->app = old_app; } if (!rt->playpath) { int len = strlen(fname); rt->playpath = av_malloc(PLAYPATH_MAX_LENGTH); if (!rt->playpath) { ret = AVERROR(ENOMEM); goto fail; } if (!strchr(fname, ':') && len >= 4 && (!strcmp(fname + len - 4, ".f4v") || !strcmp(fname + len - 4, ".mp4"))) { memcpy(rt->playpath, "mp4:", 5); } else { if (len >= 4 && !strcmp(fname + len - 4, ".flv")) fname[len - 4] = '\0'; rt->playpath[0] = 0; } av_strlcat(rt->playpath, fname, PLAYPATH_MAX_LENGTH); } if (!rt->tcurl) { rt->tcurl = av_malloc(TCURL_MAX_LENGTH); if (!rt->tcurl) { ret = AVERROR(ENOMEM); goto fail; } ff_url_join(rt->tcurl, TCURL_MAX_LENGTH, proto, NULL, hostname, port, "/%s", rt->app); } if (!rt->flashver) { rt->flashver = av_malloc(FLASHVER_MAX_LENGTH); if (!rt->flashver) { ret = AVERROR(ENOMEM); goto fail; } if (rt->is_input) { snprintf(rt->flashver, FLASHVER_MAX_LENGTH, "%s %d,%d,%d,%d", RTMP_CLIENT_PLATFORM, RTMP_CLIENT_VER1, RTMP_CLIENT_VER2, RTMP_CLIENT_VER3, RTMP_CLIENT_VER4); } else { snprintf(rt->flashver, FLASHVER_MAX_LENGTH, "FMLE/3.0 (compatible; %s)", LIBAVFORMAT_IDENT); } } rt->client_report_size = 1048576; rt->bytes_read = 0; rt->has_audio = 0; rt->has_video = 0; rt->received_metadata = 0; rt->last_bytes_read = 0; rt->server_bw = 2500000; av_log(s, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n", proto, path, rt->app, rt->playpath); if (!rt->listen) { if ((ret = gen_connect(s, rt)) < 0) goto fail; } else { if ((ret = read_connect(s, s->priv_data)) < 0) goto fail; } do { ret = get_packet(s, 1); } while (ret == AVERROR(EAGAIN)); if (ret < 0) goto fail; if (rt->do_reconnect) { int i; ffurl_close(rt->stream); rt->stream = NULL; rt->do_reconnect = 0; rt->nb_invokes = 0; for (i = 0; i < 2; i++) memset(rt->prev_pkt[i], 0, sizeof(**rt->prev_pkt) * rt->nb_prev_pkt[i]); free_tracked_methods(rt); goto reconnect; } if (rt->is_input) { int err; rt->flv_size = 13; if ((err = av_reallocp(&rt->flv_data, rt->flv_size)) < 0) return err; rt->flv_off = 0; memcpy(rt->flv_data, "FLV\1\0\0\0\0\011\0\0\0\0", rt->flv_size); while (!rt->has_audio && !rt->has_video && !rt->received_metadata) { if ((ret = get_packet(s, 0)) < 0) return ret; } if (rt->has_audio) { rt->flv_data[4] |= FLV_HEADER_FLAG_HASAUDIO; } if (rt->has_video) { rt->flv_data[4] |= FLV_HEADER_FLAG_HASVIDEO; } } else { rt->flv_size = 0; rt->flv_data = NULL; rt->flv_off = 0; rt->skip_bytes = 13; } s->max_packet_size = rt->stream->max_packet_size; s->is_streamed = 1; return 0; fail: av_dict_free(&opts); rtmp_close(s); return ret; }
1threat
static void RENAME(yuv2rgb555_1)(SwsContext *c, const uint16_t *buf0, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, enum PixelFormat dstFormat, int flags, int y) { const uint16_t *buf1= buf0; if (uvalpha < 2048) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5) "pxor %%mm7, %%mm7 \n\t" #ifdef DITHER1XBPP "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t" "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif WRITERGB15(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5) "pxor %%mm7, %%mm7 \n\t" #ifdef DITHER1XBPP "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t" "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif WRITERGB15(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); } }
1threat
def ap_sum(a,n,d): total = (n * (2 * a + (n - 1) * d)) / 2 return total
0debug
Do without look error : When running this code I get a error that is "loop without do". I want if "case vbno" is selected then it returns to the original input box. If it the user selects "case vbyes" I want it to highlight then cell then loop back to do and return to original input box. If cancel is selected I want it to exit completely. Sub find_highlight3() Dim w As Variant Dim FoundCell As Range Dim ans As String Do w = InputBox("What to find?") Cells.Find(What:=(w), After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate With Selection.Interior Select Case MsgBox("Hellow", vbYesNoCancel) Case vbNo Loop Case vbYes .ColorIndex = 6 .Pattern = xlSolid .PatternColorIndex = xlAutomatic Loop Case vbCancel End Select End With End Sub
0debug
void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) { BdrvChild *child; Error *local_err = NULL; int ret; if (!bs->drv) { return; } if (!(bs->open_flags & BDRV_O_INACTIVE)) { return; } bs->open_flags &= ~BDRV_O_INACTIVE; if (bs->drv->bdrv_invalidate_cache) { bs->drv->bdrv_invalidate_cache(bs, &local_err); if (local_err) { bs->open_flags |= BDRV_O_INACTIVE; error_propagate(errp, local_err); return; } } QLIST_FOREACH(child, &bs->children, next) { bdrv_invalidate_cache(child->bs, &local_err); if (local_err) { bs->open_flags |= BDRV_O_INACTIVE; error_propagate(errp, local_err); return; } } ret = refresh_total_sectors(bs, bs->total_sectors); if (ret < 0) { bs->open_flags |= BDRV_O_INACTIVE; error_setg_errno(errp, -ret, "Could not refresh total sector count"); return; } }
1threat
static void mcf_fec_do_tx(mcf_fec_state *s) { uint32_t addr; mcf_fec_bd bd; int frame_size; int len; uint8_t frame[FEC_MAX_FRAME_SIZE]; uint8_t *ptr; DPRINTF("do_tx\n"); ptr = frame; frame_size = 0; addr = s->tx_descriptor; while (1) { mcf_fec_read_bd(&bd, addr); DPRINTF("tx_bd %x flags %04x len %d data %08x\n", addr, bd.flags, bd.length, bd.data); if ((bd.flags & FEC_BD_R) == 0) { break; } len = bd.length; if (frame_size + len > FEC_MAX_FRAME_SIZE) { len = FEC_MAX_FRAME_SIZE - frame_size; s->eir |= FEC_INT_BABT; } cpu_physical_memory_read(bd.data, ptr, len); ptr += len; frame_size += len; if (bd.flags & FEC_BD_L) { DPRINTF("Sending packet\n"); qemu_send_packet(qemu_get_queue(s->nic), frame, len); ptr = frame; frame_size = 0; s->eir |= FEC_INT_TXF; } s->eir |= FEC_INT_TXB; bd.flags &= ~FEC_BD_R; mcf_fec_write_bd(&bd, addr); if ((bd.flags & FEC_BD_W) != 0) { addr = s->etdsr; } else { addr += 8; } } s->tx_descriptor = addr; }
1threat
Swift's JSONDecoder with multiple date formats in a JSON string? : <p>Swift's <code>JSONDecoder</code> offers a <code>dateDecodingStrategy</code> property, which allows us to define how to interpret incoming date strings in accordance with a <code>DateFormatter</code> object.</p> <p>However, I am currently working with an API that returns both date strings (<code>yyyy-MM-dd</code>) and datetime strings (<code>yyyy-MM-dd HH:mm:ss</code>), depending on the property. Is there a way to have the <code>JSONDecoder</code> handle this, since the provided <code>DateFormatter</code> object can only deal with a single <code>dateFormat</code> at a time?</p> <p>One ham-handed solution is to rewrite the accompanying <code>Decodable</code> models to just accept strings as their properties and to provide public <code>Date</code> getter/setter variables, but that seems like a poor solution to me. Any thoughts?</p>
0debug
returning a number to it's double value : i'm creating a program to evaluate the number inputted for example i inputted 5 the function should be able to return the number 5 = 500 or 4 = 400, 6 = 600, 10 = 1000 and so on. this is what i've done so far. public int NumberEval(int theNumber) { int theResult = 0; switch (theNumber) { case 0: theResult = 1; break; case 1: theResult = 1; break; case 2: theResult = 200; break; case 3: theResult = 300; break; case 4: theResult = 400; break; case 5: theResult = 500; break; case 6: theResult = 600; break; case 7: theResult = 700; break; case 8: theResult = 800; break; case 9: theResult = 900; break; case 10: theResult = 1000; break; case 11: theResult = 1100; break; case 12: theResult = 1200; break; case 13: theResult = 1300; break; case 14: theResult = 1400; break; case 15: theResult = 1500; break; case 16: theResult = 1600; break; case 17: theResult = 1700; break; case 18: theResult = 1800; break; case 19: theResult = 1900; break; case 20: theResult = 2000; break; default: break; } return theResult; } but my problem is that what if i entered 50 then it should be 5000..is there a way to shortcut this method because i dont want to manually encode every in switch case. or even a mathematical equation for this?. thank you for any help.
0debug
void HELPER(wsr_lbeg)(uint32_t v) { if (env->sregs[LBEG] != v) { tb_invalidate_phys_page_range( env->sregs[LEND] - 1, env->sregs[LEND], 0); env->sregs[LBEG] = v; } }
1threat
What programming languages used to create terminal apps? : <p>What are the languages that used to build apps like: ls, curl, nmap, htop and other homebrew apps like: youtube-dl.</p> <p>I'm wonder about; if I want to build an app to run it through terminal and published in homebrew, what language should I used?</p>
0debug
static int quant_psnr8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2, ptrdiff_t stride, int h) { LOCAL_ALIGNED_16(int16_t, temp, [64 * 2]); int16_t *const bak = temp + 64; int sum = 0, i; av_assert2(h == 8); s->mb_intra = 0; s->pdsp.diff_pixels(temp, src1, src2, stride); memcpy(bak, temp, 64 * sizeof(int16_t)); s->block_last_index[0 ] = s->fast_dct_quantize(s, temp, 0 , s->qscale, &i); s->dct_unquantize_inter(s, temp, 0, s->qscale); ff_simple_idct_8(temp); for (i = 0; i < 64; i++) sum += (temp[i] - bak[i]) * (temp[i] - bak[i]); return sum; }
1threat
How to verify the mouse hover message in selenium : I have tried to print the mouse hover message by using below code **Code used** 'WebElement element = driver.findElement(By.xpath("/html/body/div/form/div/div/div/div/div[1]/div/div/div")); Actions action = new Actions(driver); action.moveToElement(element).build().perform(); WebElement toolTipElement = driver.findElement(By.xpath("/html/body/div/form/div/div/div/div/div[1]/div/div/div")); String toolTipTxt = toolTipElement.getText(); System.out.println(toolTipTxt);' **Actual Result** Hovered on the icon,not printing the hover message and it's get skipped to next
0debug
How do you make the computer select random elements from an array? : <p>I tried looking at other similar topics about this issue, but none of them solved my issue. I have basically made an array, that consists of animal names, and I am trying to tell the computer to select a random animal name, but I don't know how to do that.</p> <p>I've already tried to use math.random, but it always sends back a random index value which is just a number. I don't want it to send a random number, but a random string.</p> <pre><code> String[] animalNames = {"Raven","Chameleon","Lion","Cheetah"}; </code></pre> <p>So, I want to learn code that can allow the computer to randomely select an animal name. I expect it to input the animal name which is the element but not the index, which is just a number.</p>
0debug
int bdrv_can_snapshot(BlockDriverState *bs) { BlockDriver *drv = bs->drv; if (!drv || bdrv_is_removable(bs) || bdrv_is_read_only(bs)) { return 0; } if (!drv->bdrv_snapshot_create) { if (bs->file != NULL) { return bdrv_can_snapshot(bs->file); } return 0; } return 1; }
1threat
How to force class template argument deduction when constructing a class in its own member functions? : <p>Consider following code:</p> <pre><code>struct A {}; template &lt;typename T&gt; struct B { B(T) {} auto foo() {return B(A{});} // error: no matching function for call to 'B&lt;int&gt;::B(A)' }; auto foo() {return B(A{});} // compiles int main() { foo(); B b(0); b.foo(); } </code></pre> <p><kbd><a href="https://godbolt.org/g/f1sRuk" rel="noreferrer">Try it live</a></kbd></p> <p>I understand why <code>B::foo()</code> doesn't compile: Inside of <code>struct B&lt;T&gt;</code>, <code>B</code> (as an injected-class-name) means <code>B&lt;T&gt;</code> unless it's explicitly used as a template. Which in this case prevents class template argument deduction.</p> <p>Let's say I can't do <code>auto foo() {return B&lt;A&gt;(A{});}</code> since my actual code relies on slightly elaborate user-provided deduction guides.</p> <p>The question is: How do I force class template argument deduction when constructing <code>B</code> inside of <code>B::foo</code>?</p> <p><sub>I hope I'm not missing something obvious.</sub></p>
0debug
wiremock equivalent for websockets? : <p>I have used wiremock for testing http calls, but my current work requires websockets and I was wondering if anyone has found/used a library for standing up a localhost that will create a websocket connection that you can mock responses. </p> <p>I have googled it but nothing seems to be a stand alone server, but yet just libraries that require you to add to the project. This will not work as I'm looking for something I can test across all mobile platforms/desktops. </p>
0debug
WordPress post tiles in custom PHP application : Is it possible to pull tiles of blog posts into my php based website outside of the directory i'm hosting wordpress in? Can i use WordPress Post Title and Post Content in my PHP applications. I have tried this one: <?php include('/wordpress/wp-load.php'); ?> <?php $recent_posts = wp_get_recent_posts(array( 'numberposts' => 5 )); foreach($recent_posts as $post) { echo '<a href="', get_permalink($post['ID']), '">', $post['post_title'], } ?>
0debug
Google API Client "refresh token must be passed in or set as part of setAccessToken" : <p>I am currently facing a very strange problem, indeed I've been following this very same guide (<a href="https://developers.google.com/google-apps/calendar/quickstart/php" rel="noreferrer">https://developers.google.com/google-apps/calendar/quickstart/php</a>) from Google API documentation. I tried it twice, at the first time it work like a charm but after the access token had expire the script provided straight by Google API Doc was unable to refresh it.</p> <p>TL;DR</p> <p>Here is the error message:</p> <pre><code>sam@ssh:~$ php www/path/to/app/public/quickstart.php Fatal error: Uncaught exception 'LogicException' with message 'refresh token must be passed in or set as part of setAccessToken' in /home/pueblo/www/path/to/app/vendor/google/apiclient/src/Google/Client.php:258 Stack trace: #0 /home/pueblo/www/path/to/app/public/quickstart.php(55): Google_Client-&gt;fetchAccessTokenWithRefreshToken(NULL) #1 /home/pueblo/www/path/to/app/public/quickstart.php(76): getClient() #2 {main} thrown in /home/pueblo/www/path/to/app/vendor/google/apiclient/src/Google/Client.php on line 258 </code></pre> <p>Here is the part of the php script from google I've modified:</p> <pre><code>require_once __DIR__ . '/../vendor/autoload.php'; // I don't want the creds to be in my home folder, I prefer them in the app's root define('APPLICATION_NAME', 'LRS API Calendar'); define('CREDENTIALS_PATH', __DIR__ . '/../.credentials/calendar-php-quickstart.json'); define('CLIENT_SECRET_PATH', __DIR__ . '/../client_secret.json'); </code></pre> <p>I also modified the <code>expandHomeDirectory</code> so I could "disable" it without modifying too much code:</p> <pre><code>function expandHomeDirectory($path) { $homeDirectory = getenv('HOME'); if (empty($homeDirectory)) { $homeDirectory = getenv('HOMEDRIVE') . getenv('HOMEPATH'); } return $path; // return str_replace('~', realpath($homeDirectory), $path); } </code></pre> <p>So to check if I was wrong or if Google was, I did an experiment: yesterday night I launch the quickstart script from ssh to check if it was working, and indeed it was, so I decided to check this morning if it still working just as it was before I slept and it wasn't so I think there's something wrong with Google's <code>quickstart.php</code>.</p> <p>I hope someone could help me, I already checked all the other posts about the subject but they are all outdated.</p>
0debug
How to index a pdf file in Elasticsearch 5.0.0 with ingest-attachment plugin? : <p>I'm new to Elasticsearch and I read here <a href="https://www.elastic.co/guide/en/elasticsearch/plugins/master/mapper-attachments.html">https://www.elastic.co/guide/en/elasticsearch/plugins/master/mapper-attachments.html</a> that the mapper-attachments plugin is deprecated in elasticsearch 5.0.0.</p> <p>I now try to index a pdf file with the new ingest-attachment plugin and upload the attachment. </p> <p>What I've tried so far is</p> <pre><code>curl -H 'Content-Type: application/pdf' -XPOST localhost:9200/test/1 -d @/cygdrive/c/test/test.pdf </code></pre> <p>but I get the following error:</p> <pre><code>{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"not_x_content_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"}},"status":400} </code></pre> <p>I would expect that the pdf file will be indexed and uploaded. What am I doing wrong?</p> <p>I also tested Elasticsearch 2.3.3 but the mapper-attachments plugin is not valid for this version and I don't want to use any older version of Elasticsearch.</p>
0debug
Diagnostic Tools in Visual Studio 2017 : <p>I've installed Visual Studio 2017 and I was playing with Diagnostic Tools. suddenly, after some restarts, the window does not open anymore and I don't figure out how to do it. Anyone knows how can I open it again ?</p>
0debug
'System.Drawing.Color' does not contain a definition for 'FromARgb' : <p>I have added System.Drawing as a reference, yet this code seems to fail on the line where I declare the new color</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Drawing; using System.Windows.Forms; using System.IO; namespace BitmapParser { class Program { static void Main(string[] args) { Color a = Color.FromARgb(0, 255, 0); } } } </code></pre> <p>So what is going on here? I looked up System.Drawing.Color and it does have a 3-int constructor <a href="https://msdn.microsoft.com/en-us/library/system.drawing.color.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/system.drawing.color.aspx</a></p>
0debug
Need HTML & CSS for simple 3 buttons in a DIV : <p>I have created a webpage with a google map embedded and need some code for 3 buttons in a div below the map, i have tried a few things yet nothing seems to work, they need to be inline e.g [BUTTON 1] [BUTTON 2] [BUTTON 3]</p>
0debug
For what is the method openFileOutput() used for Android Studio? : I have this snippet of code. Can someone please help what '0' attribute in openFileOutput stands for in the following code? `public void Save(String fileName) { try { OutputStreamWriter out = new OutputStreamWriter(openFileOutput(fileName, 0)); out.write(EditText1.); out.close(); Toast.makeText(this, "Note Saved!", Toast.LENGTH_SHORT).show(); } catch (Throwable t) { Toast.makeText(this, "Exception: " + t.toString(), Toast.LENGTH_LONG).show(); } }`
0debug
static inline int check_physical(CPUPPCState *env, mmu_ctx_t *ctx, target_ulong eaddr, int rw) { int in_plb, ret; ctx->raddr = eaddr; ctx->prot = PAGE_READ | PAGE_EXEC; ret = 0; switch (env->mmu_model) { case POWERPC_MMU_32B: case POWERPC_MMU_601: case POWERPC_MMU_SOFT_6xx: case POWERPC_MMU_SOFT_74xx: case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_REAL: case POWERPC_MMU_BOOKE: ctx->prot |= PAGE_WRITE; break; #if defined(TARGET_PPC64) case POWERPC_MMU_620: case POWERPC_MMU_64B: case POWERPC_MMU_2_06: ctx->raddr &= 0x0FFFFFFFFFFFFFFFULL; ctx->prot |= PAGE_WRITE; break; #endif case POWERPC_MMU_SOFT_4xx_Z: if (unlikely(msr_pe != 0)) { in_plb = (env->pb[0] < env->pb[1] && eaddr >= env->pb[0] && eaddr < env->pb[1]) || (env->pb[2] < env->pb[3] && eaddr >= env->pb[2] && eaddr < env->pb[3]) ? 1 : 0; if (in_plb ^ msr_px) { if (rw == 1) { ret = -2; } } else { ctx->prot |= PAGE_WRITE; } } break; case POWERPC_MMU_MPC8xx: cpu_abort(env, "MPC8xx MMU model is not implemented\n"); break; case POWERPC_MMU_BOOKE206: cpu_abort(env, "BookE 2.06 MMU doesn't have physical real mode\n"); break; default: cpu_abort(env, "Unknown or invalid MMU model\n"); return -1; } return ret; }
1threat
void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins, const char *name, int n) { NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name); assert(gpio_list->num_in == 0 || !name); assert(gpio_list->num_out == 0); gpio_list->num_out = n; gpio_list->out = pins;
1threat
Get length of json array in SQL Server 2016 : <p>You know about the new JSON_ support in SQL Server 2016 so let's say I have this data in a row</p> <pre><code>{ "BaseBoarding": 1, "PriceLineStrategy": "PerPersonPerNight", "Currency": "EUR", "BasePriceLineList": [ { "RoomTypeId": 1, "PeriodId": 1, "Price": 10.0 }, { "RoomTypeId": 1, "PeriodId": 2, "Price": 100.0 }, { "RoomTypeId": 1, "PeriodId": 3, "Price": 190.0 }, { "RoomTypeId": 2, "PeriodId": 1, "Price": 280.0 }, { "RoomTypeId": 2, "PeriodId": 2, "Price": 310.0 }, { "RoomTypeId": 2, "PeriodId": 3, "Price": 340.0 } ] } </code></pre> <p>How do I get the number of items of "BasePriceLineList" in the most performant way, preferably using the built-in JSON support?</p> <p>Need to write something like this:</p> <pre><code>SELECT JSON_ARRLEN(JsonDataCol, '$.BasePriceline') FROM MyTable WHERE Id = 1 </code></pre> <p>and get 6 as the result.</p>
0debug
static int ipvideo_decode_block_opcode_0x8(IpvideoContext *s, AVFrame *frame) { int x, y; unsigned char P[4]; unsigned int flags = 0; P[0] = bytestream2_get_byte(&s->stream_ptr); P[1] = bytestream2_get_byte(&s->stream_ptr); if (P[0] <= P[1]) { for (y = 0; y < 16; y++) { if (!(y & 3)) { if (y) { P[0] = bytestream2_get_byte(&s->stream_ptr); P[1] = bytestream2_get_byte(&s->stream_ptr); flags = bytestream2_get_le16(&s->stream_ptr); for (x = 0; x < 4; x++, flags >>= 1) *s->pixel_ptr++ = P[flags & 1]; s->pixel_ptr += s->stride - 4; if (y == 7) s->pixel_ptr -= 8 * s->stride - 4; } else { flags = bytestream2_get_le32(&s->stream_ptr); P[2] = bytestream2_get_byte(&s->stream_ptr); P[3] = bytestream2_get_byte(&s->stream_ptr); if (P[2] <= P[3]) { for (y = 0; y < 16; y++) { for (x = 0; x < 4; x++, flags >>= 1) *s->pixel_ptr++ = P[flags & 1]; s->pixel_ptr += s->stride - 4; if (y == 7) { s->pixel_ptr -= 8 * s->stride - 4; P[0] = P[2]; P[1] = P[3]; flags = bytestream2_get_le32(&s->stream_ptr); } else { for (y = 0; y < 8; y++) { if (y == 4) { P[0] = P[2]; P[1] = P[3]; flags = bytestream2_get_le32(&s->stream_ptr); for (x = 0; x < 8; x++, flags >>= 1) *s->pixel_ptr++ = P[flags & 1]; s->pixel_ptr += s->line_inc; return 0;
1threat
static size_t save_page_header(RAMState *rs, RAMBlock *block, ram_addr_t offset) { size_t size, len; if (block == rs->last_sent_block) { offset |= RAM_SAVE_FLAG_CONTINUE; } qemu_put_be64(rs->f, offset); size = 8; if (!(offset & RAM_SAVE_FLAG_CONTINUE)) { len = strlen(block->idstr); qemu_put_byte(rs->f, len); qemu_put_buffer(rs->f, (uint8_t *)block->idstr, len); size += 1 + len; rs->last_sent_block = block; } return size; }
1threat
Can not insert data codeigniter : Why i can't insert data use form? im sorry i can't share my code in here, because my coding is too long **My View Form** <form method="post" enctype="multipart/form-data" action="<?php echo base_url(); ?>admin/Ca_pendaftar/tambah" data-parsley-validate class="form-horizontal form-label-left" id="demo_form2">
0debug
static void notdirty_mem_writel(void *opaque, target_phys_addr_t ram_addr, uint32_t val) { int dirty_flags; dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS]; if (!(dirty_flags & CODE_DIRTY_FLAG)) { #if !defined(CONFIG_USER_ONLY) tb_invalidate_phys_page_fast(ram_addr, 4); dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS]; #endif } stl_p(qemu_get_ram_ptr(ram_addr), val); dirty_flags |= (0xff & ~CODE_DIRTY_FLAG); phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] = dirty_flags; if (dirty_flags == 0xff) tlb_set_dirty(cpu_single_env, cpu_single_env->mem_io_vaddr); }
1threat
C# Sorting String Array Items by the numbers inside : I'm trying to sort string array items which includes numbers. You can also think about it for ListBox items. For example, our items are: London 4, Berlin 6, Paris 2, Roma 7, Istanbul 5. Sorting codes will return to us: Roma 7, Berlin 6, Istanbul 5, London 4, Paris 2.
0debug
Gradle - add directory to classpath : <p>My application requires that a <code>\config</code> directory be available on the classpath when it looks for configurations files under the directory. I currently have dependencies configured like so, though this is probably not the correct way to make a directory available to my application:</p> <pre><code>dependencies { ... //runtime, compile dependencies pulled from repositories runtime files('config') } </code></pre> <p>I am using the <code>application</code> plugin to create a standalone zip for my project. If my <code>\config</code> directory has <code>\config\subdir</code>, <code>file1</code>, <code>file2</code>, then the plugin produces a <code>build\install</code> directory with the following structure:</p> <pre><code>| build | --|install | ----|bin | ------ projectName | ------ projectName.bat | ----|lib | ------ dependency1.jar | ------ dependency2.jar | ------|subdir | ------ file1 | ------ file2 </code></pre> <p>This does not work for my application because it explicitly expects a <code>\config</code> directory</p> <p>However, this is the directory structure that I need:</p> <pre><code>| build | --|install | ----|bin | ------ projectName | ------ projectName.bat | ----|lib | ------ dependency1.jar | ------ dependency2.jar | ----|config | ------|subdir | ------ file1 | ------ file2 </code></pre> <p>How can I make gradle add another directory to the build and specify it as part of the classpath for the generated startup scripts?</p>
0debug
I'm trying to write VB code in Excel such when I paste a image in worksheet1 is automatically pastes is to worksheet2 : I would like a user to paste an image into a worksheet and automatically have it pasted to a second worksheet. I have found some VB code that gets me close, but can't figure out how to finish it. The image will change from user to user, but I'd like the action to occur as soon as the user pastes the image into E4. I found this code, which helps, but its is not automatic. Sub InsertLogo2() Dim strPath As String Dim shtSheet As Worksheet strPath = "C:\GraphicFolder\PictureName.bmp" For Each shtSheet In Worksheets shtSheet.Activate Range("A1").Select ActiveSheet.Pictures.Insert (strPath) Next shtSheet Set shtSheet = Nothing End Sub I'm new to VB, so really struggling with this. Thanks!
0debug
How to apply on click action on images in javascript/jquery? : <p>I have a <a href="https://jsfiddle.net/hpmawvy0/embedded/result/" rel="nofollow noreferrer">fiddle</a> which I have replicated by seeing the screenshot below:</p> <p><a href="https://i.stack.imgur.com/D4nY5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D4nY5.png" alt="enter image description here"></a></p> <p>At this moment, I am able to replicate everything in <a href="https://jsfiddle.net/hpmawvy0/embedded/result/" rel="nofollow noreferrer">fiddle</a> from the design. </p> <p>The snippets of CSS codes which I have used in order to align images in a straight line are:</p> <pre><code> .product-contents { display: flex; justify-content: space-between; align-items: center; padding: 1rem; } </code></pre> <p><br><br><br> <strong>Problem Statement:</strong> </p> <p>In the <a href="https://jsfiddle.net/hpmawvy0/embedded/result/" rel="nofollow noreferrer">fiddle</a>, now if I click on <strong>any square images from the screenshot (Franchise Hub,Business Analytics, Tech Support, etc)</strong> apart from the <strong>Cloud Based &amp; Mobile Image</strong> then A <strong>TV screen image(means a different image)</strong> should appear as present in the <a href="https://jsfiddle.net/vvn3wq7w/7/embedded/result/" rel="nofollow noreferrer">fiddle</a>.</p> <p>And if I click on <strong>Cloud Based and Mobile</strong> image then a phone image should appear <strong>(as shown in the current screenshot above)</strong></p> <p>I am not sure how to apply that logic. I am pretty sure I need to use Javascript but I am not sure how to use that. </p>
0debug
void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared) { size_t total = size + align; void *ptr = mmap(0, total, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); size_t offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr; void *ptr1; if (ptr == MAP_FAILED) { return NULL; } assert(!(align & (align - 1))); assert(align >= getpagesize()); ptr1 = mmap(ptr + offset, size, PROT_READ | PROT_WRITE, MAP_FIXED | (fd == -1 ? MAP_ANONYMOUS : 0) | (shared ? MAP_SHARED : MAP_PRIVATE), fd, 0); if (ptr1 == MAP_FAILED) { munmap(ptr, total); return NULL; } ptr += offset; total -= offset; if (offset > 0) { munmap(ptr - offset, offset); } if (total > size + getpagesize()) { munmap(ptr + size + getpagesize(), total - size - getpagesize()); } return ptr; }
1threat
What's the meaning of function eval() in torch.nn module : <p>Official comment shows that "This has any effect only on modules such as Dropout or BatchNorm." But I don't understand its implementation.</p>
0debug
Enforcing the type of medium on a Virtual Memory system : <p>Suppose I'm designing a software application that requires high bandwidth / low latency memory transfers to operate properly. My OS uses Virtual Memory addressing.</p> <p>Is there a way to enforce the variables (that I choose) to be located in DDR and not on the hard drive for example? </p>
0debug
Difference between <script async> and $.ajax : <p>Is there any major difference? </p> <p>Does one allow additional functionality?</p>
0debug
datables alert with aLengthMenu : I use the plugin https://datatables.net/ i want to add onclick on aLengthMenu and show the chosen value with alert here is my code: $(document).ready(function() { var oTable = $('# Table_id').DataTable({ 'iDisplayLength': '50', "aLengthMenu": [ [20, 50, 100, 200], [20, 50, 100, 200] ] }); var oSettings = oTable.fnSettings(); var x = oSettings._iDisplayLength; });
0debug
segmentation of an image using frequencies (c++ or python) : I would like to segment this image [image to segment][1] (I want only the bees, I have 100 images like that not labelled). I think that the best way to do that is to use frenquency domai because the bees seems to have specific frequencies. But I'm not sure how to do that. How to find the reght frequencies ? Or maybe you think of a better way to do that ? Thanks in advance ! [1]: https://i.stack.imgur.com/zS8X6.jpg
0debug
static int init_filters(const char *filters_descr) { char args[512]; int ret; AVFilter *abuffersrc = avfilter_get_by_name("abuffer"); AVFilter *abuffersink = avfilter_get_by_name("abuffersink"); AVFilterInOut *outputs = avfilter_inout_alloc(); AVFilterInOut *inputs = avfilter_inout_alloc(); const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 }; const int packing_fmts[] = { AVFILTER_PACKED, -1 }; const int64_t *chlayouts = avfilter_all_channel_layouts; AVABufferSinkParams *abuffersink_params; const AVFilterLink *outlink; filter_graph = avfilter_graph_alloc(); if (!dec_ctx->channel_layout) dec_ctx->channel_layout = av_get_default_channel_layout(dec_ctx->channels); snprintf(args, sizeof(args), "%d:%d:0x%"PRIx64":packed", dec_ctx->sample_rate, dec_ctx->sample_fmt, dec_ctx->channel_layout); ret = avfilter_graph_create_filter(&buffersrc_ctx, abuffersrc, "in", args, NULL, filter_graph); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer source\n"); return ret; } abuffersink_params = av_abuffersink_params_alloc(); abuffersink_params->sample_fmts = sample_fmts; abuffersink_params->channel_layouts = chlayouts; abuffersink_params->packing_fmts = packing_fmts; ret = avfilter_graph_create_filter(&buffersink_ctx, abuffersink, "out", NULL, abuffersink_params, filter_graph); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer sink\n"); return ret; } outputs->name = av_strdup("in"); outputs->filter_ctx = buffersrc_ctx; outputs->pad_idx = 0; outputs->next = NULL; inputs->name = av_strdup("out"); inputs->filter_ctx = buffersink_ctx; inputs->pad_idx = 0; inputs->next = NULL; if ((ret = avfilter_graph_parse(filter_graph, filter_descr, &inputs, &outputs, NULL)) < 0) return ret; if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0) return ret; outlink = buffersink_ctx->inputs[0]; av_get_channel_layout_string(args, sizeof(args), -1, outlink->channel_layout); av_log(NULL, AV_LOG_INFO, "Output: srate:%dHz fmt:%s chlayout:%s\n", (int)outlink->sample_rate, (char *)av_x_if_null(av_get_sample_fmt_name(outlink->format), "?"), args); return 0; }
1threat
I want to increment the value of age in a table every 24hours : <p>I have a column "age" in my database.table So here it goes the moment i input a name the age will increment every day so ill get its day old as age Pls help</p>
0debug
BlockAIOCB *bdrv_aio_ioctl(BlockDriverState *bs, unsigned long int req, void *buf, BlockCompletionFunc *cb, void *opaque) { BlockAIOCBCoroutine *acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque); Coroutine *co; acb->need_bh = true; acb->req.error = -EINPROGRESS; acb->req.req = req; acb->req.buf = buf; co = qemu_coroutine_create(bdrv_co_aio_ioctl_entry); qemu_coroutine_enter(co, acb); bdrv_co_maybe_schedule_bh(acb); return &acb->common; }
1threat
Applicative is to monad what X is to comonad : <p>Can we solve this equation for X ?</p> <blockquote> <p>Applicative is to monad what X is to comonad</p> </blockquote>
0debug
static void pc_init1(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model, int pci_enabled) { char *filename; int ret, linux_boot, i; ram_addr_t ram_addr, bios_offset, option_rom_offset; ram_addr_t below_4g_mem_size, above_4g_mem_size = 0; int bios_size, isa_bios_size; PCIBus *pci_bus; ISADevice *isa_dev; int piix3_devfn = -1; CPUState *env; qemu_irq *cpu_irq; qemu_irq *isa_irq; qemu_irq *i8259; IsaIrqState *isa_irq_state; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DriveInfo *fd[MAX_FD]; void *fw_cfg; if (ram_size >= 0xe0000000 ) { above_4g_mem_size = ram_size - 0xe0000000; below_4g_mem_size = 0xe0000000; } else { below_4g_mem_size = ram_size; } linux_boot = (kernel_filename != NULL); if (cpu_model == NULL) { #ifdef TARGET_X86_64 cpu_model = "qemu64"; #else cpu_model = "qemu32"; #endif } for (i = 0; i < smp_cpus; i++) { env = pc_new_cpu(cpu_model); } vmport_init(); ram_addr = qemu_ram_alloc(0xa0000); cpu_register_physical_memory(0, 0xa0000, ram_addr); ram_addr = qemu_ram_alloc(0x100000 - 0xa0000); ram_addr = qemu_ram_alloc(below_4g_mem_size - 0x100000); cpu_register_physical_memory(0x100000, below_4g_mem_size - 0x100000, ram_addr); if (above_4g_mem_size > 0) { #if TARGET_PHYS_ADDR_BITS == 32 hw_error("To much RAM for 32-bit physical address"); #else ram_addr = qemu_ram_alloc(above_4g_mem_size); cpu_register_physical_memory(0x100000000ULL, above_4g_mem_size, ram_addr); #endif } if (bios_name == NULL) bios_name = BIOS_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = get_image_size(filename); } else { bios_size = -1; } if (bios_size <= 0 || (bios_size % 65536) != 0) { goto bios_error; } bios_offset = qemu_ram_alloc(bios_size); ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size)); if (ret != 0) { bios_error: fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name); exit(1); } if (filename) { qemu_free(filename); } isa_bios_size = bios_size; if (isa_bios_size > (128 * 1024)) isa_bios_size = 128 * 1024; cpu_register_physical_memory(0x100000 - isa_bios_size, isa_bios_size, (bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM); rom_enable_driver_roms = 1; option_rom_offset = qemu_ram_alloc(PC_ROM_SIZE); cpu_register_physical_memory(PC_ROM_MIN_VGA, PC_ROM_SIZE, option_rom_offset); cpu_register_physical_memory((uint32_t)(-bios_size), bios_size, bios_offset | IO_MEM_ROM); fw_cfg = bochs_bios_init(); if (linux_boot) { load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size); } for (i = 0; i < nb_option_roms; i++) { rom_add_option(option_rom[i]); } cpu_irq = qemu_allocate_irqs(pic_irq_request, NULL, 1); i8259 = i8259_init(cpu_irq[0]); isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state)); isa_irq_state->i8259 = i8259; isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24); if (pci_enabled) { pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq); } else { pci_bus = NULL; isa_bus_new(NULL); } isa_bus_irqs(isa_irq); ferr_irq = isa_reserve_irq(13); register_ioport_write(0x80, 1, 1, ioport80_write, NULL); register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL); if (cirrus_vga_enabled) { if (pci_enabled) { pci_cirrus_vga_init(pci_bus); } else { isa_cirrus_vga_init(); } } else if (vmsvga_enabled) { if (pci_enabled) pci_vmsvga_init(pci_bus); else fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__); } else if (std_vga_enabled) { if (pci_enabled) { pci_vga_init(pci_bus, 0, 0); } else { isa_vga_init(); } } rtc_state = rtc_init(2000); qemu_register_boot_set(pc_boot_set, rtc_state); register_ioport_read(0x92, 1, 1, ioport92_read, NULL); register_ioport_write(0x92, 1, 1, ioport92_write, NULL); if (pci_enabled) { isa_irq_state->ioapic = ioapic_init(); } pit = pit_init(0x40, isa_reserve_irq(0)); pcspk_init(pit); if (!no_hpet) { hpet_init(isa_irq); } for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { serial_isa_init(i, serial_hds[i]); } } for(i = 0; i < MAX_PARALLEL_PORTS; i++) { if (parallel_hds[i]) { parallel_init(i, parallel_hds[i]); } } for(i = 0; i < nb_nics; i++) { NICInfo *nd = &nd_table[i]; if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0)) pc_init_ne2k_isa(nd); else pci_nic_init_nofail(nd, "e1000", NULL); } if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { fprintf(stderr, "qemu: too many IDE bus\n"); exit(1); } for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); } if (pci_enabled) { pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); } else { for(i = 0; i < MAX_IDE_BUS; i++) { isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i], hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); } } isa_dev = isa_create_simple("i8042"); DMA_init(0); #ifdef HAS_AUDIO audio_init(pci_enabled ? pci_bus : NULL, isa_irq); #endif for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } floppy_controller = fdctrl_init_isa(fd); cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, hd); if (pci_enabled && usb_enabled) { usb_uhci_piix3_init(pci_bus, piix3_devfn + 2); } if (pci_enabled && acpi_enabled) { uint8_t *eeprom_buf = qemu_mallocz(8 * 256); i2c_bus *smbus; smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, isa_reserve_irq(9)); for (i = 0; i < 8; i++) { DeviceState *eeprom; eeprom = qdev_create((BusState *)smbus, "smbus-eeprom"); qdev_prop_set_uint8(eeprom, "address", 0x50 + i); qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256)); qdev_init_nofail(eeprom); } piix4_acpi_system_hot_add_init(pci_bus); } if (i440fx_state) { i440fx_init_memory_mappings(i440fx_state); } if (pci_enabled) { int max_bus; int bus; max_bus = drive_get_max_bus(IF_SCSI); for (bus = 0; bus <= max_bus; bus++) { pci_create_simple(pci_bus, -1, "lsi53c895a"); } } if (pci_enabled) { for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) { if (virtcon_hds[i]) { pci_create_simple(pci_bus, -1, "virtio-console-pci"); } } } rom_load_fw(fw_cfg); }
1threat
int qemu_sem_timedwait(QemuSemaphore *sem, int ms) { int rc = WaitForSingleObject(sem->sema, ms); if (rc == WAIT_OBJECT_0) { return 0; } if (rc != WAIT_TIMEOUT) { error_exit(GetLastError(), __func__); } return -1; }
1threat
java.util.HashMap cannot be cast to java.util.Date : <p>I am trying to get a timestamp from cloud firestore and store it in a date variable but I am getting this exception :</p> <pre><code>java.util.HashMap cannot be cast to java.util.Date </code></pre> <p>this is the code for getting the value from the cloud firestore : </p> <pre><code>Date timeStamp = (Date) dataSnapshot.get("date"); </code></pre> <p>and this is the code for storing the date in the database :</p> <pre><code>map.put("date", ServerValue.TIMESTAMP); </code></pre> <p>I can't figure out how to solve this error</p>
0debug
Will it cause any issue if I use multiple Facebook Pixel in one page? : <p>I would like to include both my Facebook Pixel id and customer's Facebook Pixel id in one page, so both of us can have some insight about users, and customer can also create ADs for the page if he or she wants to.</p> <p>I already test tracking and it seems to work fine. However I do receive warnings from Pixel SDK about "Multiple different pixels were detected on this page".</p> <p>Since I cannot find any information about this scenario, I would like to know whether it is okay to do so ?</p> <p>Thanks</p>
0debug
static int decode_info_header(NUTContext *nut) { AVFormatContext *s = nut->avf; AVIOContext *bc = s->pb; uint64_t tmp, chapter_start, chapter_len; unsigned int stream_id_plus1, count; int chapter_id, i; int64_t value, end; char name[256], str_value[1024], type_str[256]; const char *type; int *event_flags; AVChapter *chapter = NULL; AVStream *st = NULL; AVDictionary **metadata = NULL; int metadata_flag = 0; end = get_packetheader(nut, bc, 1, INFO_STARTCODE); end += avio_tell(bc); GET_V(stream_id_plus1, tmp <= s->nb_streams); chapter_id = get_s(bc); chapter_start = ffio_read_varlen(bc); chapter_len = ffio_read_varlen(bc); count = ffio_read_varlen(bc); if (chapter_id && !stream_id_plus1) { int64_t start = chapter_start / nut->time_base_count; chapter = avpriv_new_chapter(s, chapter_id, nut->time_base[chapter_start % nut->time_base_count], start, start + chapter_len, NULL); metadata = &chapter->metadata; } else if (stream_id_plus1) { st = s->streams[stream_id_plus1 - 1]; metadata = &st->metadata; event_flags = &st->event_flags; metadata_flag = AVSTREAM_EVENT_FLAG_METADATA_UPDATED; } else { metadata = &s->metadata; event_flags = &s->event_flags; metadata_flag = AVFMT_EVENT_FLAG_METADATA_UPDATED; } for (i = 0; i < count; i++) { get_str(bc, name, sizeof(name)); value = get_s(bc); if (value == -1) { type = "UTF-8"; get_str(bc, str_value, sizeof(str_value)); } else if (value == -2) { get_str(bc, type_str, sizeof(type_str)); type = type_str; get_str(bc, str_value, sizeof(str_value)); } else if (value == -3) { type = "s"; value = get_s(bc); } else if (value == -4) { type = "t"; value = ffio_read_varlen(bc); } else if (value < -4) { type = "r"; get_s(bc); } else { type = "v"; } if (stream_id_plus1 > s->nb_streams) { av_log(s, AV_LOG_ERROR, "invalid stream id for info packet\n"); continue; } if (!strcmp(type, "UTF-8")) { if (chapter_id == 0 && !strcmp(name, "Disposition")) { set_disposition_bits(s, str_value, stream_id_plus1 - 1); continue; } if (metadata && av_strcasecmp(name, "Uses") && av_strcasecmp(name, "Depends") && av_strcasecmp(name, "Replaces")) { *event_flags |= metadata_flag; av_dict_set(metadata, name, str_value, 0); } } } if (skip_reserved(bc, end) || ffio_get_checksum(bc)) { av_log(s, AV_LOG_ERROR, "info header checksum mismatch\n"); return AVERROR_INVALIDDATA; } return 0; }
1threat
Matplotlib: how to adjust space between legend markers and labels? : <p>I want to adjust space between legend markers and labels. Sometime the space is too much as default. Does anyone know how to do this? </p> <p>Thanks.</p>
0debug
void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src) { dst->pts = src->pts; dst->pos = src->pos; switch (src->type) { case AVMEDIA_TYPE_VIDEO: { if (dst->video->qp_table) av_freep(&dst->video->qp_table); copy_video_props(dst->video, src->video); break; } case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break; default: break; } }
1threat
Quorum Blockchain Chat Forum : <p>I am new to Quorum blockchain. I have tried to find Quorum's online discussion forums where I can clarify Quorum related queries, but I could not find any. Please someone provide the URLs for the same. Thanks</p>
0debug
HOW TO: Tell a module which region the view to register to at runtime : Is it possible to pass in the regionname to the module so it know which region the view should register with? I see in many code example that the regionName is hardcoded in the module initialize method. What I want to do is have the SHELL pass in the region name when the module is registering the view to a region. If this is not possible or not recommended, why would this be a bad or good thing?
0debug
Obtaining the value of SON query into PHP : Hi please am trying to assign the value of town_B to a variable in PHP. I tried using the mothod below but no success. Please any suggestions will be appreciated $varx = $update["result"]["parameters"]["town_two"]; Below is the JSON response { "id": "86726c74-cb52-4f1e-983d-1bc68d8c4f9c", "timestamp": "2018-02-22T18:03:12.964Z", "lang": "en", "result": { "source": "agent", "resolvedQuery": "Disneyworld CA", "action": "sayHello", "actionIncomplete": false, "parameters": { "town_B": [ "CA" ], "town_A": "Disneyworld" }, "contexts": [], "metadata": { "intentId": "65bc2f1f-e127-44de-bd3b-915c8865f472", "webhookUsed": "true", "webhookForSlotFillingUsed": "false", "webhookResponseTime": 1047, "intentName": "Geo" }, "fulfillment": { "source": "agent", "messages": [ { "type": 0, "speech": "Please check for correct input" } ] }, "score": 1 }, "status": { "code": 200, "errorType": "success", "webhookTimedOut": false }, "sessionId": "c3de9b17-6cd6-43dc-bf12-6844a6b0930e" }
0debug
Viewing Unit Test and Coverage Reports Generated in AWS CodeBuild : <p>I am using AWS CodeBuild to run unit tests for my python project using pytest. I am using the --junitxml argument and the pytest-cov package to generate test reports and coverage reports that I've listed as artifacts in my buildspec.yml.</p> <p>I've used Jenkins in the past to do this and Jenkins provides some nice graphs and tables showing test result history and coverage history as well as results from the most recent test.</p> <p>Is there a good way to view the reports generated by my CodeBuild project? I haven't found anything in CodeBuild or CodePipeline directly. Do I have to use a separate tool that can ingest the report files? If so, what are some tools for this?</p>
0debug
how to use multiple if conditions in AWK? : i am quite new to awk so i have a following query. i have below input file which i need to parse. input.csv "11111","TRUE","aa" "456789","TRUE","aa;bb;cc" "2345","TRUE","bb" "434566","","cc" **i am trying to create an awk command which should give me following output.** output.csv "11111","TRUE","aa,," "456789","TRUE","aa,bb,cc" "2345","TRUE",",bb," "434566","",",,cc" so i have created following command. **awk 'BEGIN{FS=",";OFS=","} { if( $3 ~ /aa/ ) { value="aa" } else { value="," }; if( $3 ~ /bb/ ) { value="$value,bb" } else { value="$value," }; if( $3 ~ /cc/ ) { value="$value,cc" } else { value="$value,"}; print $1 , $2 , $value}' input.csv > output.csv** But it is giving me following output. **"11111","TRUE","11111","TRUE","aa" "456789","TRUE","456789","TRUE","aa;bb;cc" "2345","TRUE","2345","TRUE","bb" "434566","","434566","","cc"** i am not sure why it is print first two atrributes twice and then printing the third value. Can someone please help me out as i am quite new to awk although i am able to do it in shell script but i need to do it using awk.
0debug
WPF String formatting the contents of a list : <p>I have a list box which I populate with a list of type Foo, which contains the following properties: Name and ID.</p> <p>I am binding it to a list box control. The problem is that I am getting "<strong>MyNamespace.Model.Foo</strong>" over an over in my list box. Is it possible for me to do extract the contents of my Foo list and display them in my view? How would I go doing something like that?</p> <p>Here is where I am populating my list:</p> <p>Window.Main:</p> <pre><code> void Load() { var result = my_model.GetData(); foreach (var x in result) { Foo foo = new Foo{ Id = x.ID, Name = x.Name }; ViewModel.Foo.Add(foo); } } </code></pre> <p>My View:</p> <pre><code>&lt;ListBox x:Name="lbMyCollection" Grid.Column="1" Grid.Row="2" ItemsSource="{Binding Source={StaticResource Foo}}"&gt; &lt;/ListBox&gt; </code></pre>
0debug
int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) { int count, i; if (avctx->bits_per_coded_sample > 8) { av_log(avctx, AV_LOG_ERROR, "bit_per_coded_sample > 8 not supported\n"); return AVERROR_INVALIDDATA; } count = 1 << avctx->bits_per_coded_sample; if (avctx->extradata_size < count * 3) { av_log(avctx, AV_LOG_ERROR, "palette data underflow\n"); return AVERROR_INVALIDDATA; } for (i=0; i < count; i++) { pal[i] = 0xFF000000 | AV_RB24( avctx->extradata + i*3 ); } return 0; }
1threat
iOS - How to ignore the duplicates in NSMutableArray. : <p>For example I have an array = [12,13,13,13,14,15,16,16,17];</p> <p>and my output will be 12,13,14,15,16,17.</p> <p>Please help me on this.</p>
0debug
static int jpeg_read_close(AVFormatContext *s1) { JpegContext *s = s1->priv_data; av_free(s); return 0; }
1threat
How to handle errors in fetch() responses with Redux-Saga? : <p>I try to handle <code>Unauthorized</code> error from server using redux-saga. This is my saga:</p> <pre><code>function* logIn(action) { try { const user = yield call(Api.logIn, action); yield put({type: types.LOG_IN_SUCCEEDED, user}); } catch (error) { yield put({type: types.LOG_IN_FAILED, error}); } } </code></pre> <p>I fetch data like this:</p> <pre><code>fetchUser(action) { const {username, password} = action.user; const body = {username, password}; return fetch(LOGIN_URL, { method, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify(body) }) .then(res =&gt; { res.json().then(json =&gt; { if (res.status &gt;= 200 &amp;&amp; res.status &lt; 300) { return json } else { throw res } }) }) .catch(error =&gt; {throw error}); } </code></pre> <p>But anyway result is <code>{type: 'LOG_IN_SUCCEEDED', user: undefined}</code> when I expect <code>{type: 'LOG_IN_FAILED', error: 'Unauthorized'}</code>. Where is my mistake? How to handle errors right using Redux-Saga?</p>
0debug
static int mov_write_udta_tag(ByteIOContext *pb, MOVContext* mov, AVFormatContext *s) { int pos = url_ftell(pb); int i; put_be32(pb, 0); put_tag(pb, "udta"); mov_write_meta_tag(pb, mov, s); for (i=0; i<MAX_STREAMS; i++) { if(mov->tracks[i].entry <= 0) continue; if (mov->tracks[i].enc->codec_id == CODEC_ID_AAC || mov->tracks[i].enc->codec_id == CODEC_ID_MPEG4) { int pos = url_ftell(pb); put_be32(pb, 0); put_tag(pb, "\251req"); put_be16(pb, sizeof("QuickTime 6.0 or greater") - 1); put_be16(pb, 0); put_buffer(pb, "QuickTime 6.0 or greater", sizeof("QuickTime 6.0 or greater") - 1); updateSize(pb, pos); break; } } if(!(mov->tracks[0].enc->flags & CODEC_FLAG_BITEXACT)) { int pos = url_ftell(pb); put_be32(pb, 0); put_tag(pb, "\251enc"); put_be16(pb, sizeof(LIBAVFORMAT_IDENT) - 1); put_be16(pb, 0); put_buffer(pb, LIBAVFORMAT_IDENT, sizeof(LIBAVFORMAT_IDENT) - 1); updateSize(pb, pos); } if( s->title[0] ) { int pos = url_ftell(pb); put_be32(pb, 0); put_tag(pb, "\251nam"); put_be16(pb, strlen(s->title)); put_be16(pb, 0); put_buffer(pb, s->title, strlen(s->title)); updateSize(pb, pos); } if( s->author[0] ) { int pos = url_ftell(pb); put_be32(pb, 0); put_tag(pb, "\251day" ); put_be16(pb, strlen(s->author)); put_be16(pb, 0); put_buffer(pb, s->author, strlen(s->author)); updateSize(pb, pos); } if( s->comment[0] ) { int pos = url_ftell(pb); put_be32(pb, 0); put_tag(pb, "\251des"); put_be16(pb, strlen(s->comment)); put_be16(pb, 0); put_buffer(pb, s->comment, strlen(s->comment)); updateSize(pb, pos); } return updateSize(pb, pos); }
1threat
def lateralsurface_cuboid(l,w,h): LSA = 2*h*(l+w) return LSA
0debug
rgb48funcs(rgb, LE, PIX_FMT_RGB48LE) rgb48funcs(rgb, BE, PIX_FMT_RGB48BE) rgb48funcs(bgr, LE, PIX_FMT_BGR48LE) rgb48funcs(bgr, BE, PIX_FMT_BGR48BE) #define input_pixel(i) ((origin == PIX_FMT_RGBA || origin == PIX_FMT_BGRA || \ origin == PIX_FMT_ARGB || origin == PIX_FMT_ABGR) ? AV_RN32A(&src[(i)*4]) : \ (isBE(origin) ? AV_RB16(&src[(i)*2]) : AV_RL16(&src[(i)*2]))) static av_always_inline void rgb16_32ToY_c_template(uint8_t *dst, const uint8_t *src, int width, enum PixelFormat origin, int shr, int shg, int shb, int shp, int maskr, int maskg, int maskb, int rsh, int gsh, int bsh, int S) { const int ry = RY << rsh, gy = GY << gsh, by = BY << bsh, rnd = 33 << (S - 1); int i; for (i = 0; i < width; i++) { int px = input_pixel(i) >> shp; int b = (px & maskb) >> shb; int g = (px & maskg) >> shg; int r = (px & maskr) >> shr; dst[i] = (ry * r + gy * g + by * b + rnd) >> S; } }
1threat
static int rv30_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t *dst) { int i, j, k; for(i = 0; i < 4; i++, dst += r->intra_types_stride - 4){ for(j = 0; j < 4; j+= 2){ int code = svq3_get_ue_golomb(gb) << 1; if(code >= 81*2){ av_log(r->s.avctx, AV_LOG_ERROR, "Incorrect intra prediction code\n"); return -1; } for(k = 0; k < 2; k++){ int A = dst[-r->intra_types_stride] + 1; int B = dst[-1] + 1; *dst++ = rv30_itype_from_context[A * 90 + B * 9 + rv30_itype_code[code + k]]; if(dst[-1] == 9){ av_log(r->s.avctx, AV_LOG_ERROR, "Incorrect intra prediction mode\n"); return -1; } } } } return 0; }
1threat
PHP: Get the days name in lowercase? : <p>I'm trying to get the days name in PHP which suppose to be a simple task.</p> <p>I can simply do this:</p> <pre><code>echo date('L'); </code></pre> <p>This will print <code>Sunday</code> &lt;-- Today's name.</p> <p>However, I need to know if its possible to get the same day's name but in Lowercase like: <code>sunday</code> ?</p>
0debug
static void fd_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int size) { QEMUFileFD *s = opaque; ssize_t len; do { len = write(s->fd, buf, size); } while (len == -1 && errno == EINTR); if (len == -1) len = -errno; if (len == -EAGAIN) qemu_set_fd_handler2(s->fd, NULL, NULL, fd_put_notify, s); }
1threat
Angular *ngIf variable with async pipe multiple conditions : <p>There's quite good doc of using *ngIf in Angular: <a href="https://angular.io/api/common/NgIf" rel="noreferrer">https://angular.io/api/common/NgIf</a> But, is that possible to have *ngIf async variable and multiple checks on that? Something like:</p> <pre><code>&lt;div *ngIf="users$ | async as users &amp;&amp; users.length &gt; 1"&gt; ... &lt;/div&gt; </code></pre> <p>Of course, it's possible to use nested *ngIf, like:</p> <pre><code>&lt;div *ngIf="users$ | async as users"&gt; &lt;ng-container *ngIf="users.length &gt; 1"&gt; ... &lt;/ng-container&gt; &lt;/div&gt; </code></pre> <p>but it'd be really nice to use only one container, not two.</p>
0debug
static void bonito_writel(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { PCIBonitoState *s = opaque; uint32_t saddr; int reset = 0; saddr = (addr - BONITO_REGBASE) >> 2; DPRINTF("bonito_writel "TARGET_FMT_plx" val %x saddr %x\n", addr, val, saddr); switch (saddr) { case BONITO_BONPONCFG: case BONITO_IODEVCFG: case BONITO_SDCFG: case BONITO_PCIMAP: case BONITO_PCIMEMBASECFG: case BONITO_PCIMAP_CFG: case BONITO_GPIODATA: case BONITO_GPIOIE: case BONITO_INTEDGE: case BONITO_INTSTEER: case BONITO_INTPOL: case BONITO_PCIMAIL0: case BONITO_PCIMAIL1: case BONITO_PCIMAIL2: case BONITO_PCIMAIL3: case BONITO_PCICACHECTRL: case BONITO_PCICACHETAG: case BONITO_PCIBADADDR: case BONITO_PCIMSTAT: case BONITO_TIMECFG: case BONITO_CPUCFG: case BONITO_DQCFG: case BONITO_MEMSIZE: s->regs[saddr] = val; break; case BONITO_BONGENCFG: if (!(s->regs[saddr] & 0x04) && (val & 0x04)) { reset = 1; } s->regs[saddr] = val; if (reset) { qemu_system_reset_request(); } break; case BONITO_INTENSET: s->regs[BONITO_INTENSET] = val; s->regs[BONITO_INTEN] |= val; break; case BONITO_INTENCLR: s->regs[BONITO_INTENCLR] = val; s->regs[BONITO_INTEN] &= ~val; break; case BONITO_INTEN: case BONITO_INTISR: DPRINTF("write to readonly bonito register %x\n", saddr); break; default: DPRINTF("write to unknown bonito register %x\n", saddr); break; } }
1threat
static void scsi_generic_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass); sc->realize = scsi_generic_realize; sc->unrealize = scsi_unrealize; sc->alloc_req = scsi_new_request; sc->parse_cdb = scsi_generic_parse_cdb; dc->fw_name = "disk"; dc->desc = "pass through generic scsi device (/dev/sg*)"; dc->reset = scsi_generic_reset; dc->props = scsi_generic_properties; dc->vmsd = &vmstate_scsi_device; }
1threat
int s390_ccw_cmd_request(ORB *orb, SCSW *scsw, void *data) { S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(data); if (cdc->handle_request) { return cdc->handle_request(orb, scsw, data); } else { return -ENOSYS; } }
1threat
how to get data from API in vuex using axios? : <p>I have data taken from API laravel, and here is my code in state.js</p> <pre><code>import axios from 'axios' import {apiPostGet} from '../api/api' export default { data: axios({ method: 'GET', url: apiPostGet('Kategori') }).then( response =&gt; { return response.data.kategori } ).catch( error =&gt; { return error.response } ) } </code></pre> <p>and this is my code in gteeters.js</p> <pre><code>export default { datas: state =&gt; { return state.data } } </code></pre> <p>and this is my code in index.js</p> <pre><code>import Vue from 'vue' import Vuex from 'vuex' import state from './state' import getters from './getters' Vue.use(Vuex) export default new Vuex.Store({ state, getters }) </code></pre> <p><a href="https://i.stack.imgur.com/UhBNw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UhBNw.png" alt="and this picture from dev tool vue js"></a></p>
0debug
def move_zero(num_list): a = [0 for i in range(num_list.count(0))] x = [ i for i in num_list if i != 0] x.extend(a) return (x)
0debug
JNI How to allocate memory for object array dynamically : I am working on JNI with C language. Here i have created a object array of size 4000. According to my requirements the array size has to grown dynamically. How can i allocate memory dynamically. I have tried using malloc. But i cant achieve this. OriginalArray = (*env)->NewObjectArray(env, 4000, tradeObject, NULL);
0debug
static bool kvmppc_is_pr(KVMState *ks) { return kvm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0; }
1threat
AppCompatSpinner vs android.widget.Spinner for app with min SDK version 14 : <p>I am developing application with minimum SDK version 14 Ice-cream sandwitch and targeted version is Android Marshmallow.</p> <p>DO I need to use AppCompatSpinner or normal spinner will work on ICS devices with all material look and feel?</p>
0debug
how to access the rows and able to move back and forth in spark dataframes sing scala : I am trying to solve following problem: input dataframe : +------+------+------------+ |emp |Group |Spouse | +------+------+------------+ |John |L1 |Dana | |Mary |L1 |Rick | |***Harry*** |L3 |Dana | |Linda |L3 |***Harry*** | |Jim |L3 |Mary | +------+------+------------+ Logic: The spouse of an employee must not belong to the same group as the employee(must remove those spouse's row from the list) output dataframe: +------+------+------------+ |Emp |Group |Spouse | +------+------+------------+ |John |L1 |Dana | |Mary |L1 |Rick | |Linda |L3 |Harry | |Jim |L3 |Mary | +------+------+------------+ Would anyone please help me in resolving this?
0debug
static Visitor *validate_test_init_internal(TestInputVisitorData *data, const char *json_string, va_list *ap) { validate_teardown(data, NULL); data->obj = qobject_from_jsonv(json_string, ap); g_assert(data->obj); data->qiv = qmp_input_visitor_new(data->obj, true); g_assert(data->qiv); return data->qiv; }
1threat
static void vfio_intp_interrupt(VFIOINTp *intp) { int ret; VFIOINTp *tmp; VFIOPlatformDevice *vdev = intp->vdev; bool delay_handling = false; qemu_mutex_lock(&vdev->intp_mutex); if (intp->state == VFIO_IRQ_INACTIVE) { QLIST_FOREACH(tmp, &vdev->intp_list, next) { if (tmp->state == VFIO_IRQ_ACTIVE || tmp->state == VFIO_IRQ_PENDING) { delay_handling = true; break; } } } if (delay_handling) { intp->state = VFIO_IRQ_PENDING; trace_vfio_intp_interrupt_set_pending(intp->pin); QSIMPLEQ_INSERT_TAIL(&vdev->pending_intp_queue, intp, pqnext); ret = event_notifier_test_and_clear(&intp->interrupt); qemu_mutex_unlock(&vdev->intp_mutex); return; } trace_vfio_platform_intp_interrupt(intp->pin, event_notifier_get_fd(&intp->interrupt)); ret = event_notifier_test_and_clear(&intp->interrupt); if (!ret) { error_report("Error when clearing fd=%d (ret = %d)", event_notifier_get_fd(&intp->interrupt), ret); } intp->state = VFIO_IRQ_ACTIVE; vfio_mmap_set_enabled(vdev, false); qemu_set_irq(intp->qemuirq, 1); if (vdev->mmap_timeout) { timer_mod(vdev->mmap_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + vdev->mmap_timeout); } qemu_mutex_unlock(&vdev->intp_mutex); }
1threat
static int format_name(char *buf, int buf_len, int index) { const char *proto, *dir; char *orig_buf_dup = NULL, *mod_buf_dup = NULL; int ret = 0; if (!av_stristr(buf, "%v")) return ret; orig_buf_dup = av_strdup(buf); if (!orig_buf_dup) { ret = AVERROR(ENOMEM); goto fail; } if (replace_int_data_in_filename(buf, buf_len, orig_buf_dup, 'v', index) < 1) { ret = AVERROR(EINVAL); goto fail; } proto = avio_find_protocol_name(orig_buf_dup); dir = av_dirname(orig_buf_dup); if (av_stristr(dir, "%v") && proto && !strcmp(proto, "file")) { mod_buf_dup = av_strdup(buf); if (!mod_buf_dup) { ret = AVERROR(ENOMEM); goto fail; } dir = av_dirname(mod_buf_dup); if (mkdir_p(dir) == -1 && errno != EEXIST) { ret = AVERROR(errno); goto fail; } } fail: av_freep(&orig_buf_dup); av_freep(&mod_buf_dup); return ret; }
1threat