problem
stringlengths
26
131k
labels
class label
2 classes
static uint64_t pxa2xx_rtc_read(void *opaque, hwaddr addr, unsigned size) { PXA2xxRTCState *s = (PXA2xxRTCState *) opaque; switch (addr) { case RTTR: return s->rttr; case RTSR: return s->rtsr; case RTAR: return s->rtar; case RDAR1: return s->rdar1; case RDAR2: return s->rdar2; case RYAR1: return s->ryar1; case RYAR2: return s->ryar2; case SWAR1: return s->swar1; case SWAR2: return s->swar2; case PIAR: return s->piar; case RCNR: return s->last_rcnr + ((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) / (1000 * ((s->rttr & 0xffff) + 1)); case RDCR: return s->last_rdcr + ((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) / (1000 * ((s->rttr & 0xffff) + 1)); case RYCR: return s->last_rycr; case SWCR: if (s->rtsr & (1 << 12)) return s->last_swcr + (qemu_clock_get_ms(rtc_clock) - s->last_sw) / 10; else return s->last_swcr; default: printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr); break; } return 0; }
1threat
Python: Copying all despite of one attributes/fields of one to another named tuple : What's the shortest way to copy all despite of one attribute/field from one to another named tuple? This question is related to the question [Python: Copying named tuples with same attributes / fields](https://stackoverflow.com/questions/40980775/python-copying-named-tuples-with-same-attributes-fields).
0debug
static int decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile) { int compno, reslevelno, bandno; int x, y, *src[4]; uint8_t *line; Jpeg2000T1Context t1; for (compno = 0; compno < s->ncomponents; compno++) { Jpeg2000Component *comp = tile->comp + compno; Jpeg2000CodingStyle *codsty = tile->codsty + compno; for (reslevelno = 0; reslevelno < codsty->nreslevels2decode; reslevelno++) { Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; for (bandno = 0; bandno < rlevel->nbands; bandno++) { int nb_precincts, precno; Jpeg2000Band *band = rlevel->band + bandno; int cblkx, cblky, cblkno=0, bandpos; bandpos = bandno + (reslevelno > 0); if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1]) continue; nb_precincts = rlevel->num_precincts_x * rlevel->num_precincts_y; for (precno = 0; precno < nb_precincts; precno++) { Jpeg2000Prec *prec = band->prec + precno; for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) { int x, y; int i, j; Jpeg2000Cblk *cblk = prec->cblk + cblkno; decode_cblk(s, codsty, &t1, cblk, cblk->coord[0][1] - cblk->coord[0][0], cblk->coord[1][1] - cblk->coord[1][0], bandpos); x = cblk->coord[0][0]; y = cblk->coord[1][0]; dequantization_int(x, y, cblk, comp, &t1, band); } } } } ff_dwt_decode(&comp->dwt, comp->data); src[compno] = comp->data; } if (tile->codsty[0].mct) mct_decode(s, tile); if (s->precision <= 8) { for (compno = 0; compno < s->ncomponents; compno++) { y = tile->comp[compno].coord[1][0] - s->image_offset_y; line = s->picture->data[0] + y * s->picture->linesize[0]; for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) { uint8_t *dst; x = tile->comp[compno].coord[0][0] - s->image_offset_x; dst = line + x * s->ncomponents + compno; for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) { int val = *src[compno]++ << (8 - s->cbps[compno]); val += 1 << 7; val = av_clip(val, 0, (1 << 8) - 1); *dst = val; dst += s->ncomponents; } line += s->picture->linesize[0]; } } } else { for (compno = 0; compno < s->ncomponents; compno++) { y = tile->comp[compno].coord[1][0] - s->image_offset_y; line = s->picture->data[0] + y * s->picture->linesize[0]; for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) { uint16_t *dst; x = tile->comp[compno].coord[0][0] - s->image_offset_x; dst = (uint16_t *)(line + (x * s->ncomponents + compno) * 2); for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s-> cdx[compno]) { int32_t val; val = *src[compno]++ << (16 - s->cbps[compno]); val += 1 << 15; val = av_clip(val, 0, (1 << 16) - 1); *dst = val; dst += s->ncomponents; } line += s->picture->linesize[0]; } } } return 0; }
1threat
passing multiple params in route angular 4 : <p>Hello I want to pass some params with routing in angular 4</p> <p>app-routing.module.ts</p> <pre><code>import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { StartGameComponent } from './start-game/start-game.component'; import { GameComponent } from './game/game.component'; const appRoutes: Routes = [ { path: '', redirectTo: '/first', pathMatch: 'full' }, { path: 'startGame', component: StartGameComponent }, {path: 'game/:width/:height',component: GameComponent } ]; @NgModule({ imports: [RouterModule.forRoot(appRoutes)], exports: [RouterModule] }) export class AppRoutingModule { } </code></pre> <p>in component <strong>StartGameComponent</strong> </p> <pre><code> goToGameComponent(width:string,height:string){ this.router.navigate(['game', {width:width,height:height}]); } </code></pre> <p>in component <strong>GameComponent</strong></p> <pre><code> ngOnInit() { this.route.params.forEach((urlParams) =&gt; { this.width= urlParams['width']; this.height=urlParams['height']; }); </code></pre> <p>in app.component.html</p> <pre><code>&lt;div&gt; &lt;md-toolbar color="primary"&gt; &lt;span&gt;MineSweeper Wix&lt;/span&gt; &lt;/md-toolbar&gt; &lt;router-outlet&gt;&lt;/router-outlet&gt; &lt;span class="done"&gt; &lt;button md-fab&gt; &lt;md-icon&gt;check circle&lt;/md-icon&gt; &lt;/button&gt; &lt;/span&gt; &lt;/div&gt; </code></pre> <p>it's throws my an error</p> <blockquote> <p>Cannot match any routes. URL Segment: 'game;width=10;height=10'</p> </blockquote>
0debug
Regex with HTML : In this scenario, I would like to capture dgdhyt2464t6ubvf through regex. Please can you help me. Thank you so much! <br />For API key "fnt56urkehicdvd", use API key secret: <br /> <br /> dgdhyt2464t6ubvf <br /> <br />Note that it's normal to
0debug
static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc, vorbis_floor_data *vfu, float *vec) { vorbis_floor0 *vf = &vfu->t0; float *lsp = vf->lsp; uint_fast32_t amplitude; uint_fast32_t book_idx; uint_fast8_t blockflag = vc->modes[vc->mode_number].blockflag; amplitude = get_bits(&vc->gb, vf->amplitude_bits); if (amplitude > 0) { float last = 0; uint_fast16_t lsp_len = 0; uint_fast16_t idx; vorbis_codebook codebook; book_idx = get_bits(&vc->gb, ilog(vf->num_books)); if (book_idx >= vf->num_books) { av_log(vc->avccontext, AV_LOG_ERROR, "floor0 dec: booknumber too high!\n"); book_idx = 0; } AV_DEBUG("floor0 dec: booknumber: %u\n", book_idx); codebook = vc->codebooks[vf->book_list[book_idx]]; while (lsp_len<vf->order) { int vec_off; AV_DEBUG("floor0 dec: book dimension: %d\n", codebook.dimensions); AV_DEBUG("floor0 dec: maximum depth: %d\n", codebook.maxdepth); vec_off = get_vlc2(&vc->gb, codebook.vlc.table, codebook.nb_bits, codebook.maxdepth) * codebook.dimensions; AV_DEBUG("floor0 dec: vector offset: %d\n", vec_off); for (idx = 0; idx < codebook.dimensions; ++idx) lsp[lsp_len+idx] = codebook.codevectors[vec_off+idx] + last; last = lsp[lsp_len+idx-1]; lsp_len += codebook.dimensions; } #ifdef V_DEBUG { int idx; for (idx = 0; idx < lsp_len; ++idx) AV_DEBUG("floor0 dec: coeff at %d is %f\n", idx, lsp[idx]); } #endif { int i; int order = vf->order; float wstep = M_PI / vf->bark_map_size; for (i = 0; i < order; i++) lsp[i] = 2.0f * cos(lsp[i]); AV_DEBUG("floor0 synth: map_size = %d; m = %d; wstep = %f\n", vf->map_size, order, wstep); i = 0; while (i < vf->map_size[blockflag]) { int j, iter_cond = vf->map[blockflag][i]; float p = 0.5f; float q = 0.5f; float two_cos_w = 2.0f * cos(wstep * iter_cond); for (j = 0; j + 1 < order; j += 2) { q *= lsp[j] - two_cos_w; p *= lsp[j + 1] - two_cos_w; } if (j == order) { p *= p * (2.0f - two_cos_w); q *= q * (2.0f + two_cos_w); } else { q *= two_cos_w-lsp[j]; p *= p * (4.f - two_cos_w * two_cos_w); q *= q; } { q = exp((((amplitude*vf->amplitude_offset) / (((1 << vf->amplitude_bits) - 1) * sqrt(p + q))) - vf->amplitude_offset) * .11512925f); } do { vec[i] = q; ++i; } while (vf->map[blockflag][i] == iter_cond); } } } else { return 1; } AV_DEBUG(" Floor0 decoded\n"); return 0; }
1threat
static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y) { int P[6][2]; const int mot_stride = s->mb_width + 2; const int mot_xy = (mb_y + 1)*mot_stride + mb_x + 1; int dmin, dmin2; int motion_fx, motion_fy, motion_bx, motion_by, motion_bx0, motion_by0; int motion_dx, motion_dy; const int motion_px= s->p_mv_table[mot_xy][0]; const int motion_py= s->p_mv_table[mot_xy][1]; const int time_pp= s->pp_time; const int time_bp= s->bp_time; const int time_pb= time_pp - time_bp; int bx, by; int mx, my, mx2, my2; uint8_t *ref_picture= s->me_scratchpad - (mb_x + 1 + (mb_y + 1)*s->linesize)*16; int16_t (*mv_table)[2]= s->b_direct_mv_table; uint16_t *mv_penalty= s->mv_penalty[s->f_code] + MAX_MV; motion_fx= (motion_px*time_pb)/time_pp; motion_fy= (motion_py*time_pb)/time_pp; motion_bx0= (-motion_px*time_bp)/time_pp; motion_by0= (-motion_py*time_bp)/time_pp; motion_dx= motion_dy=0; dmin2= check_bidir_mv(s, mb_x, mb_y, motion_fx, motion_fy, motion_bx0, motion_by0, motion_fx, motion_fy, motion_bx0, motion_by0) - s->qscale; motion_bx= motion_fx - motion_px; motion_by= motion_fy - motion_py; for(by=-1; by<2; by++){ for(bx=-1; bx<2; bx++){ uint8_t *dest_y = s->me_scratchpad + (by+1)*s->linesize*16 + (bx+1)*16; uint8_t *ptr; int dxy; int src_x, src_y; const int width= s->width; const int height= s->height; dxy = ((motion_fy & 1) << 1) | (motion_fx & 1); src_x = (mb_x + bx) * 16 + (motion_fx >> 1); src_y = (mb_y + by) * 16 + (motion_fy >> 1); src_x = clip(src_x, -16, width); if (src_x == width) dxy &= ~1; src_y = clip(src_y, -16, height); if (src_y == height) dxy &= ~2; ptr = s->last_picture[0] + (src_y * s->linesize) + src_x; put_pixels_tab[dxy](dest_y , ptr , s->linesize, 16); put_pixels_tab[dxy](dest_y + 8, ptr + 8, s->linesize, 16); dxy = ((motion_by & 1) << 1) | (motion_bx & 1); src_x = (mb_x + bx) * 16 + (motion_bx >> 1); src_y = (mb_y + by) * 16 + (motion_by >> 1); src_x = clip(src_x, -16, width); if (src_x == width) dxy &= ~1; src_y = clip(src_y, -16, height); if (src_y == height) dxy &= ~2; avg_pixels_tab[dxy](dest_y , ptr , s->linesize, 16); avg_pixels_tab[dxy](dest_y + 8, ptr + 8, s->linesize, 16); } } P[0][0] = mv_table[mot_xy ][0]; P[0][1] = mv_table[mot_xy ][1]; P[1][0] = mv_table[mot_xy - 1][0]; P[1][1] = mv_table[mot_xy - 1][1]; if ((mb_y == 0 || s->first_slice_line || s->first_gob_line)) { P[4][0] = P[1][0]; P[4][1] = P[1][1]; } else { P[2][0] = mv_table[mot_xy - mot_stride ][0]; P[2][1] = mv_table[mot_xy - mot_stride ][1]; P[3][0] = mv_table[mot_xy - mot_stride + 1 ][0]; P[3][1] = mv_table[mot_xy - mot_stride + 1 ][1]; P[4][0]= mid_pred(P[1][0], P[2][0], P[3][0]); P[4][1]= mid_pred(P[1][1], P[2][1], P[3][1]); } dmin = epzs_motion_search(s, &mx, &my, P, 0, 0, -16, -16, 15, 15, ref_picture); if(mx==0 && my==0) dmin=99999999; if(dmin2<dmin){ dmin= dmin2; mx=0; my=0; } #if 1 mx2= mx= mx*2; my2= my= my*2; for(by=-1; by<2; by++){ if(my2+by < -32) continue; for(bx=-1; bx<2; bx++){ if(bx==0 && by==0) continue; if(mx2+bx < -32) continue; dmin2= check_bidir_mv(s, mb_x, mb_y, mx2+bx+motion_fx, my2+by+motion_fy, mx2+bx+motion_bx, my2+by+motion_by, mx2+bx+motion_fx, my2+by+motion_fy, motion_bx, motion_by) - s->qscale; if(dmin2<dmin){ dmin=dmin2; mx= mx2 + bx; my= my2 + by; } } } #else mx*=2; my*=2; #endif if(mx==0 && my==0){ motion_bx= motion_bx0; motion_by= motion_by0; } s->b_direct_mv_table[mot_xy][0]= mx; s->b_direct_mv_table[mot_xy][1]= my; s->b_direct_forw_mv_table[mot_xy][0]= motion_fx + mx; s->b_direct_forw_mv_table[mot_xy][1]= motion_fy + my; s->b_direct_back_mv_table[mot_xy][0]= motion_bx + mx; s->b_direct_back_mv_table[mot_xy][1]= motion_by + my; return dmin; }
1threat
Combining two String Arrays into an ArrayList in Java : I am working on a sample android app. I have two string arrays: private String[] titles = { "Manufacturer ", "Model ", "Product", "Android Version ", "API Level ", "Board ", "Bootloader ", "Device ", "Hardware ", "CPU ", "Display " , "Serial Number ", "Type ", "User ", "Language ", "Rooted " }; private String[] details = { Build.MANUFACTURER, android.os.Build.MODEL , Build.PRODUCT , Build.VERSION.RELEASE, version1, Build.BOARD, Build.BOOTLOADER, Build.DEVICE, Build.HARDWARE,Build.CPU_ABI, Build.DISPLAY, Build.SERIAL,Build.TYPE, Build.USER, Locale.getDefault().toString(), rooted()}; And need to combine them into an ArrayList. This is the sample one they included: private ArrayList<DataObject> mess() { ArrayList results = new ArrayList<>(); for (int index = 0; index < 20; index++) { DataObject obj = new DataObject("Titles " + index, "Details " + index); results.add(index, obj); } return results; } It passes to a RecyclerViewAdapter after
0debug
Numeric TextField for Integers in JavaFX 8 with TextFormatter and/or UnaryOperator : <p>I am trying to create a numeric TextField for Integers by using the TextFormatter of JavaFX 8.</p> <p><strong>Solution with UnaryOperator:</strong></p> <pre><code>UnaryOperator&lt;Change&gt; integerFilter = change -&gt; { String input = change.getText(); if (input.matches("[0-9]*")) { return change; } return null; }; myNumericField.setTextFormatter(new TextFormatter&lt;String&gt;(integerFilter)); </code></pre> <p><strong>Solution with IntegerStringConverter:</strong></p> <pre><code>myNumericField.setTextFormatter(new TextFormatter&lt;&gt;(new IntegerStringConverter())); </code></pre> <p>Both solutions have their own problems. With the UnaryOperator, I can only enter digits from 0 to 9 like intended, but I also need to enter negative values like "-512", where the sign is only allowed at the first position. Also I don't want numbers like "00016" which is still possible.</p> <p>The IntegerStringConverter method works way better: Every invalid number like "-16-123" is not accepted and numbers like "0123" get converted to "123". But the conversion only happens when the text is commited (via pressing enter) or when the TextField loses its focus.</p> <p>Is there a way to enforce the conversion of the second method with the IntegerStringConverter every time the value of the TextField is updated?</p>
0debug
void OPPROTO op_int_im(void) { EIP = PARAM1; raise_exception(EXCP0D_GPF); }
1threat
static int libschroedinger_encode_close(AVCodecContext *avctx) { SchroEncoderParams *p_schro_params = avctx->priv_data; schro_encoder_free(p_schro_params->encoder); ff_schro_queue_free(&p_schro_params->enc_frame_queue, libschroedinger_free_frame); if (p_schro_params->enc_buf_size) av_freep(&p_schro_params->enc_buf); av_freep(&p_schro_params->format); av_frame_free(&avctx->coded_frame); return 0; }
1threat
void qpci_iounmap(QPCIDevice *dev, void *data) { }
1threat
How can I remove a value from array in java script? : <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;code&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Java Script Array methods&lt;/title&gt; &lt;script type="text/javascript"&gt; var ArrStr = ["Yallappa","Rajesh","Kiran"]; function LoadArr(){ document.getElementById("Arr").innerHTML = ArrStr; } function But1Click(){ ArrStr.push(document.getElementById("TxtBox").value); document.getElementById("Arr").innerHTML = ArrStr; } function But2Click(){ var Indx = ArrStr.indexOf(document.getElementById("Arr").value); alert(Indx); if(indx &gt; -1){ arrstr.splice(document.getelementbyid("arr").value,1); } document.getelementbyid("arr").innerhtml = arrstr; } &lt;/script&gt; &lt;/head&gt; &lt;body onLoad="LoadArr()"&gt; &lt;h2 id="Arr"&gt;&lt;/h2&gt;&lt;br&gt; &lt;input type="text" id="TxtBox"/&gt;&lt;br&gt; &lt;input type="button" onclick="But1Click()" text="Push into Array" value="Push into Array"/&gt;&lt;br&gt; &lt;input type="button" onclick="But2Click()" text="Remove from Array" value="Remove From Array"/&gt; &lt;/body&gt; &lt;/html&gt; &lt;/code&gt;</code></pre> </div> </div> I wanted to add and remove text from the textbox based on the button click events. And display the array of strings in h2 tag. In this I am able to add a new string in array, but I am not able to remove string. Why please explain me?</p>
0debug
Why is my C++ program not working? : <p>I am trying to build a program that reads numbers from "bac.txt" and returns the 2 digit number/numbers (10,11,12,...,99) that appear most frequently. For example if the file "bac.txt" contains 393 17775787 72194942 12121774 it will return 77 and 21. I have managed to build a working function <code>counter(int n)</code> that can count how many times <code>n</code> is found in the file and returns <code>i</code> which is the number of times <code>n</code> has been found. Now I can't seem to find a way to print to the screen the number/numbers that are found most often. I tried to use some kind of for loop but it doesn't work. Here is my code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;string&gt; using namespace std; int counter(int n){ int i=0,j=0; char x1=n/10+'0'; char x2=n%10+'0'; char a; char b=NULL; fstream fisier("bac.txt", fstream::in); while (fisier &gt;&gt; noskipws &gt;&gt; a) { if(b==x1&amp;&amp;a==x2) i++; b=a; } return i; } int main() { int v[90]; int v1[90]; int i,maxim=0,nr; for(i=10;i&lt;100;i++) { v[i]=counter(i); if(v[i]&gt;maxim)maxim=v[i]; } for(i=10;i&lt;100;i++) if(v[i]==maxim) cout&lt;&lt;i; } </code></pre>
0debug
How to find the element using selenium webdriver : I have attached the DOM.. How to identify the highlighted text message using selenium web driver. PS I m new to selenium, Thanks[enter image description here][1] [1]: http://i.stack.imgur.com/tmXgr.jpg
0debug
fibonacci sequence using list comprehension : I want to write a list comprehension that will give out Fibonacci number until the number 4 milliom. I want to add that to list comprehension and sum evenly spaced terms. from math import sqrt Phi = (1 + sqrt(5)) / 2 phi = (1 - sqrt(5)) / 2 series = [int((Phi**n - phi**n) / sqrt(5)) for n in range(1, 10)] print(series) [1, 1, 2, 3, 5, 8, 13, 21, 34] This is a sample code that works and I want to write similar code using list comprehension. Please do help. a, b = 1, 1 total = 0 while a <= 4000000: if a % 2 == 0: total += a a, b = b, a+b print(total)
0debug
Allow utorrent download on college LAN : <p>I have my college LAN connected to my notebook. It is proxied already, i.e. the LAN works only if we are connected to that proxy network...! I want to use utorrent and download from it, but it does not connect to peers at all...! What should I do...?</p>
0debug
Flutter Bug in Andriod Studio : [Console][1] Error while Building Flutter Project i have upgraded gradle version as well reinstall andriod studio [1]: https://i.stack.imgur.com/jTdep.png
0debug
is "from flask import request" identical to "import requests"? : <p>In other words, is the flask request class identical to the requests library?</p> <p>I consulted:</p> <p><a href="http://flask.pocoo.org/docs/0.11/api/" rel="noreferrer">http://flask.pocoo.org/docs/0.11/api/</a></p> <p><a href="http://docs.python-requests.org/en/master/" rel="noreferrer">http://docs.python-requests.org/en/master/</a></p> <p>but cannot tell for sure. I see code examples where people seem to use them interchangeably.</p>
0debug
Does python all() function iterate over all elements? : <p>I'm wondering if the all() Python function iterates over all elements of the iterable passed by param. </p>
0debug
static int peer_has_ufo(VirtIONet *n) { if (!peer_has_vnet_hdr(n)) return 0; n->has_ufo = qemu_peer_has_ufo(qemu_get_queue(n->nic)); return n->has_ufo; }
1threat
Flask "Error: The file/path provided does not appear to exist" although the file does exist : <p>I use <code>export FLASK_APP=flask_app</code> and then do <code>flask run</code> but I get the error:</p> <blockquote> <p>Error: The file/path provided (flask_app) does not appear to exist. Please verify the path is correct. If app is not on PYTHONPATH, ensure the extension is .py</p> </blockquote> <p>However, the file <em>does</em> exist and is even in the present working directory. Using the complete path to the file does not work either.</p>
0debug
static int seg_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt) { SegmentContext *seg = s->priv_data; AVFormatContext *oc = seg->avf; if (oc->oformat->check_bitstream) { int ret = oc->oformat->check_bitstream(oc, pkt); if (ret == 1) { AVStream *st = s->streams[pkt->stream_index]; AVStream *ost = oc->streams[pkt->stream_index]; st->internal->bsfcs = ost->internal->bsfcs; st->internal->nb_bsfcs = ost->internal->nb_bsfcs; ost->internal->bsfcs = NULL; ost->internal->nb_bsfcs = 0; } return ret; } return 1; }
1threat
How to get lifecycle.coroutineScope with new androidx.lifecycle:*:2.2.0-alpha01 : <p>On 7th May, 2019 <code>androidx.lifecycle:*:2.2.0-alpha01</code> was released announcing:</p> <blockquote> <p>This release adds new features that adds support for Kotlin coroutines for Lifecycle and LiveData. Detailed documentation on them can be found here.</p> </blockquote> <p>On <a href="https://developer.android.com/topic/libraries/architecture/coroutines#lifecyclescope" rel="noreferrer">documentation</a> it's mentioned that I can get the <code>LifecycleScope</code>:</p> <blockquote> <p>either via <code>lifecycle.coroutineScope</code> or <code>lifecycleOwner.lifecycleScope</code> properties</p> </blockquote> <p>But it seems that I'm not able to find none of them. My current dependencises are:</p> <pre><code>def lifecycle_ver = "2.2.0-alpha01" implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_ver" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_ver" implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_ver" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1' </code></pre> <p>What may be the cause and how do get these apis?</p>
0debug
static CharDriverState *qemu_chr_open_pty(const char *id, ChardevReturn *ret) { CharDriverState *chr; PtyCharDriver *s; int master_fd, slave_fd; char pty_name[PATH_MAX]; master_fd = qemu_openpty_raw(&slave_fd, pty_name); if (master_fd < 0) { return NULL; } close(slave_fd); qemu_set_nonblock(master_fd); chr = qemu_chr_alloc(); chr->filename = g_strdup_printf("pty:%s", pty_name); ret->pty = g_strdup(pty_name); ret->has_pty = true; fprintf(stderr, "char device redirected to %s (label %s)\n", pty_name, id); s = g_malloc0(sizeof(PtyCharDriver)); chr->opaque = s; chr->chr_write = pty_chr_write; chr->chr_update_read_handler = pty_chr_update_read_handler; chr->chr_close = pty_chr_close; chr->chr_add_watch = pty_chr_add_watch; chr->explicit_be_open = true; s->fd = io_channel_from_fd(master_fd); s->timer_tag = 0; return chr; }
1threat
def Check_Vow(string, vowels): final = [each for each in string if each in vowels] return(len(final))
0debug
How to get Yoga places nearby me in android : I am using google places api to search nearby places around.As per that document there is no place_types to search Yoga places.How to find nearby places which are not the in the list.Thanks https://developers.google.com/places/supported_types
0debug
executenonquery commandtext property has not been initialized : when i click on this button , i face with this error > executenonquery commandtext property has not been initialized private void button_FirstStep_Click(object sender, EventArgs e) { SqlConnection Conn = new SqlConnection(Yahya.strcon); Conn.Open(); int CurrentCount = Convert.ToInt32(label_CurrentCount.Text); string strcom1 = "select * from vm1 where count = '" + (CurrentCount - 1) + "' and benchmarkid = '" + Structure.BenchmarkID + "' "; SqlCommand cmd = new SqlCommand(strcom1, Conn); SqlDataReader reader = cmd.ExecuteReader(); string strcom = ""; while (reader.Read()) { if (reader["vmid"].ToString() != "") { string vmid = reader["vmid"].ToString(); strcom += "update vm1 set pmid = (select pmid from vm1 as VM2 where benchmarkid = '" + Structure.BenchmarkID + "' and vm2.count ='" + (CurrentCount - 1) + "' and vm2.vmid ='" + vmid + "' ) where count = '" + CurrentCount + "' and vmid = '" + vmid + "' and benchmarkid = '" + Structure.BenchmarkID + "' \n"; } }//end of while reader.Close(); cmd.CommandText = strcom; cmd.ExecuteNonQuery();
0debug
Multiple Includes() in EF Core : <p>I have an extension method that lets you generically include data in EF:</p> <pre><code>public static IQueryable&lt;T&gt; IncludeMultiple&lt;T&gt;(this IQueryable&lt;T&gt; query, params Expression&lt;Func&lt;T, object&gt;&gt;[] includes) where T : class { if (includes != null) { query = includes.Aggregate(query, (current, include) =&gt; current.Include(include)); } return query; } </code></pre> <p>This allows me to have methods in my repository like this:</p> <pre><code>public Patient GetById(int id, params Expression&lt;Func&lt;Patient, object&gt;&gt;[] includes) { return context.Patients .IncludeMultiple(includes) .FirstOrDefault(x =&gt; x.PatientId == id); } </code></pre> <p>I believe the extension method worked before EF Core, but now including "children" is done like this:</p> <pre><code>var blogs = context.Blogs .Include(blog =&gt; blog.Posts) .ThenInclude(post =&gt; post.Author); </code></pre> <p>Is there a way to alter my generic extension method to support EF Core's new <code>ThenInclude()</code> practice?</p>
0debug
Wait until two different users click a button and then go to a page : <p>Hi working on a website project where I want to wait until two separate users click a button and then have them both go to the same page. These users will be each in their own browser window. I have searched the internet and went to research ajax but found that is not what I am looking for because I want the page to automatically detect when the other user in a different browser clicked the button, instead of having a user repeatedly click a button to see if another user has clicked there button such as with ajax. Please help thanks.</p> <p><strong>Goal: Have a user be automatically redirected to another page once a <em>different</em> user clicks the same button in a different window</strong></p> <blockquote> <p>Example:</p> <p>user 1 and user 2 are both on a website</p> <p>user 1 clicks on a button. user 1 is now waiting on a waiting page until another person clicks on the button in a different browser window.</p> <p>user 2 now clicks on the button in their own browser window</p> <p>user 1 and user 2 now get automatically redirected to the same page.</p> </blockquote>
0debug
Export CSV PowerShell : I have to export my result in an Excel table but everything goes in one cell. I would like to have a table with columns and rows. The current excel file (Excel table): <pre> Column1 Column2 Column3 Column4 infra-12 infra-88 infra-52 infra-55 infra-2 infra-3 infra-2 infra-12 infra-8 infra-71 infra-45 infra-71 infra-45 infra-2 infra-3 infra-52 infra-3 infra-27 infra-99 infra-2 </pre> Output without the export (in PowerShell ISE): <pre> Column1 Column2 Column3 Column4 ------- ------- ------- ------- infra-12 infra-88 infra-52 infra-55 infra-2 infra-71 infra-99 infra-71 infra-8 infra-27 infra-52 infra-45 infra-3 </pre> Result when I export in an Excel table (this is in the table and everything is in one cell): <pre> Column1,"Column2","Column3","Column4" infra-12,"infra-88","infra-52","infra-55" infra-2,"infra-71","infra-99","infra-71" infra-8,"infra-27",,"infra-52" infra-45,,, infra-3,,, </pre> Code: $csv = Import-Csv .\test1.csv -Delimiter ';' $ref = [ordered]@{} $columns = foreach ($i in 0..7) { ,[Collections.ArrayList]@() } foreach ($row in $csv) { $value = $row.Column1 $ref[$value] = $true $columns[0].add($value) >$null } foreach ($row in $csv) { $i = 1 foreach ($col in 'Column2', 'Column3', 'Column4') { $value = $row.$col if (!$ref[$value]) { $columns[$i].add($value) >$null } $i++ } } $maxLine = ($columns | select -expand Count | measure -Maximum).Maximum - 1 $csv = foreach ($i in 0..$maxLine) { [PSCustomObject]@{ Column1 = $columns[0][$i] Column2 = $columns[1][$i] Column3 = $columns[2][$i] Column4 = $columns[3][$i] } } $csv | Export-CSV -Path ".\test1.csv" -NoTypeInformation The code allow to remove cells which are matching (same values) and get display the others.
0debug
static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { Mpeg1Context *s1 = avctx->priv_data; MpegEncContext *s = &s1->mpeg_enc_ctx; int ref, f_code, vbv_delay; if(mpeg_decode_postinit(s->avctx) < 0) return -2; init_get_bits(&s->gb, buf, buf_size*8); ref = get_bits(&s->gb, 10); s->pict_type = get_bits(&s->gb, 3); vbv_delay= get_bits(&s->gb, 16); if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) { s->full_pel[0] = get_bits1(&s->gb); f_code = get_bits(&s->gb, 3); if (f_code == 0) return -1; s->mpeg_f_code[0][0] = f_code; s->mpeg_f_code[0][1] = f_code; } if (s->pict_type == B_TYPE) { s->full_pel[1] = get_bits1(&s->gb); f_code = get_bits(&s->gb, 3); if (f_code == 0) return -1; s->mpeg_f_code[1][0] = f_code; s->mpeg_f_code[1][1] = f_code; } s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == I_TYPE; s->y_dc_scale = 8; s->c_dc_scale = 8; s->first_slice = 1; return 0; }
1threat
ssize_t nbd_receive_reply(QIOChannel *ioc, NBDReply *reply, Error **errp) { uint8_t buf[NBD_REPLY_SIZE]; uint32_t magic; ssize_t ret; ret = read_sync_eof(ioc, buf, sizeof(buf), errp); if (ret <= 0) { return ret; } if (ret != sizeof(buf)) { error_setg(errp, "read failed"); return -EINVAL; } magic = ldl_be_p(buf); reply->error = ldl_be_p(buf + 4); reply->handle = ldq_be_p(buf + 8); reply->error = nbd_errno_to_system_errno(reply->error); if (reply->error == ESHUTDOWN) { error_setg(errp, "server shutting down"); return -EINVAL; } TRACE("Got reply: { magic = 0x%" PRIx32 ", .error = % " PRId32 ", handle = %" PRIu64" }", magic, reply->error, reply->handle); if (magic != NBD_REPLY_MAGIC) { error_setg(errp, "invalid magic (got 0x%" PRIx32 ")", magic); return -EINVAL; } return sizeof(buf); }
1threat
int ff_nvdec_decode_init(AVCodecContext *avctx) { NVDECContext *ctx = avctx->internal->hwaccel_priv_data; NVDECFramePool *pool; AVHWFramesContext *frames_ctx; const AVPixFmtDescriptor *sw_desc; CUVIDDECODECREATEINFO params = { 0 }; int cuvid_codec_type, cuvid_chroma_format; int ret = 0; sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt); if (!sw_desc) return AVERROR_BUG; cuvid_codec_type = map_avcodec_id(avctx->codec_id); if (cuvid_codec_type < 0) { av_log(avctx, AV_LOG_ERROR, "Unsupported codec ID\n"); return AVERROR_BUG; } cuvid_chroma_format = map_chroma_format(avctx->sw_pix_fmt); if (cuvid_chroma_format < 0) { av_log(avctx, AV_LOG_ERROR, "Unsupported chroma format\n"); return AVERROR(ENOSYS); } if (!avctx->hw_frames_ctx) { ret = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_CUDA); if (ret < 0) return ret; } frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; params.ulWidth = avctx->coded_width; params.ulHeight = avctx->coded_height; params.ulTargetWidth = avctx->coded_width; params.ulTargetHeight = avctx->coded_height; params.bitDepthMinus8 = sw_desc->comp[0].depth - 8; params.OutputFormat = params.bitDepthMinus8 ? cudaVideoSurfaceFormat_P016 : cudaVideoSurfaceFormat_NV12; params.CodecType = cuvid_codec_type; params.ChromaFormat = cuvid_chroma_format; params.ulNumDecodeSurfaces = frames_ctx->initial_pool_size; params.ulNumOutputSurfaces = 1; ret = nvdec_decoder_create(&ctx->decoder_ref, frames_ctx->device_ref, &params, avctx); if (ret < 0) return ret; pool = av_mallocz(sizeof(*pool)); if (!pool) { ret = AVERROR(ENOMEM); goto fail; } pool->dpb_size = frames_ctx->initial_pool_size; ctx->decoder_pool = av_buffer_pool_init2(sizeof(int), pool, nvdec_decoder_frame_alloc, av_free); if (!ctx->decoder_pool) { ret = AVERROR(ENOMEM); goto fail; } return 0; fail: ff_nvdec_decode_uninit(avctx); return ret; }
1threat
Writing Applications with C : <p>I took a lot of time to learn about C, and pointers and arrays and strings. But now I want to know how to apply all this. The title says Applications, but I also want to know how to write firmware, and device drivers and kernels. If you could point me to books,on line resources, and things of this nature.</p>
0debug
Python: data Structures inside another : <p>In Perl you can do stuff like this:</p> <pre><code>my $data-&gt;[texts}-&gt;{text1} = "hey"; print data-&gt;{texts}-&gt;{text1}; </code></pre> <p>and it will print "hey". It is like a data structure (sort of array) inside another data structure...</p> <p>Obviously this is possible in Python:</p> <pre><code>data = { 'jack': 4098, 'sape': 4139 } print data['jack']; </code></pre> <p>But I want something like: data['texts']['text1'] like it was done in Perl.</p> <p>And I need to be able to easily remove and add to this structure...</p> <p>Help?</p>
0debug
How to display all session variables in django? : <p>How to display all session variables ? i know that a variable can be accessed using <code>request.session['variable']</code> but i wanted to know if there other variables that are set by others or set automatically during user logins or similar other events..</p>
0debug
static void rv40_h_strong_loop_filter(uint8_t *src, const int stride, const int alpha, const int lims, const int dmode, const int chroma) { rv40_strong_loop_filter(src, stride, 1, alpha, lims, dmode, chroma); }
1threat
uint64_t helper_fctiw(CPUPPCState *env, uint64_t arg) { CPU_DoubleU farg; farg.ll = arg; if (unlikely(float64_is_signaling_nan(farg.d))) { farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI); } else if (unlikely(float64_is_quiet_nan(farg.d) || float64_is_infinity(farg.d))) { farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXCVI); } else { farg.ll = float64_to_int32(farg.d, &env->fp_status); farg.ll |= 0xFFF80000ULL << 32; } return farg.ll; }
1threat
Python - Invalid Syntax for simple if/else statement : <p>I am using a very simple if/else statement within a for loop and I keep getting invalid syntax. All the indenting is correct. </p> <p>I have a pandas dataframe with 2 columns. One column is a string of times in the form of mm:ss and I want to convert this to seconds. This column also has some NaN values. The second column is true/false determining if the first column is NaN.</p> <pre><code>temp = [] temp_dF = pd.concat([data["Reading Time"], pd.isnull(data["Reading Time"])], axis=1) for row in temp_dF.itertuples(index=False): if row[1] == False: sec = int(float(row[0][:2]) * 60 + int(float(row[0][-2:])) else: sec = None temp.append(sec) data["Reading Time"] = temp </code></pre> <p>Here is the error:</p> <pre><code> File "&lt;ipython-input-23-e06720dbae3c&gt;", line 8 else: ^ SyntaxError: invalid syntax </code></pre>
0debug
java simple output of name and age : <p>Im kind of new to java and im struggling very hard at this one. I just want to make a syso with the age and name of Stefan</p> <pre><code> public class Person { public int alter; public String placeofbirth; public Person(int alter, String placeofbirth) { this.alter = alter; this.placeofbirth = placeofbirth; } Person stefan = new Person(19, "Berlin"); public String toString() { return "test" + stefan; } public static void main(String[] args) { System.out.println(stefan); } } </code></pre> <p>What am i doing wrong?</p> <p>Would be very grateful to get help</p>
0debug
Can I move app from current project to another project with current data in Firebase Console of the same account : <p>I have a project in firebase console, this project has two apps both android. I had only integrated Analytics, Notifications and Crashlytics. I had thought of just deleting the app and add it afresh to the new project in firebase I have created for it but I don't know what will happen to the current users with app installed. Is there anyway I can just migrate this app to the new project apart from deleting it and re-adding it to the new project. I have tried to google and look for a solution but all solutions direct me to migrating the app to another account not to another project in the same account. If you have any idea or advise, help me please. Thanks.</p>
0debug
int qdev_unplug(DeviceState *dev) { if (!dev->parent_bus->allow_hotplug) { qemu_error("Bus %s does not support hotplugging\n", dev->parent_bus->name); return -1; } return dev->info->unplug(dev); }
1threat
static always_inline void gen_ext_l(void (*tcg_gen_ext_i64)(TCGv t0, TCGv t1), int ra, int rb, int rc, int islit, uint8_t lit) { if (unlikely(rc == 31)) return; if (ra != 31) { if (islit) { tcg_gen_shri_i64(cpu_ir[rc], cpu_ir[ra], (lit & 7) * 8); } else { TCGv tmp = tcg_temp_new(TCG_TYPE_I64); tcg_gen_andi_i64(tmp, cpu_ir[rb], 7); tcg_gen_shli_i64(tmp, tmp, 3); tcg_gen_shr_i64(cpu_ir[rc], cpu_ir[ra], tmp); tcg_temp_free(tmp); } if (tcg_gen_ext_i64) tcg_gen_ext_i64(cpu_ir[rc], cpu_ir[rc]); } else tcg_gen_movi_i64(cpu_ir[rc], 0); }
1threat
Get the contents between the 2 given strings : How do I get the contents between the 2 given strings? There is no output. keyword_01=’Serial\s\+Number’; keyword_02='Signature\s\+Algorithm'; openssl s_client -servername example.com -connect example.com:443 </dev/null 2>/dev/null | openssl x509 -text | grep -i -o -P --color=auto '(?<=$keyword_01).*(?=$keyword_02)' The basic recommendations work, but when it is pieced as above, it doesn't. echo "Here is a string" | grep -o -P --color=auto '(?<=Here).*(?=string)'
0debug
what's the full name "printf, scanf, seekg : C (printf, scanf) C++(seekg) I can't find above function's full name from MSDN. these guys seem to be like below ▼ printf - print format - print format string - print function scanf - scan foramt - scan foramt string - scan function seekg - seekGlobalFileStreamCursor (What the..?) above function guys drive me crazy. really- wonder!
0debug
static void piix3_ide_xen_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->init = pci_piix_ide_initfn; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1; k->class_id = PCI_CLASS_STORAGE_IDE; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); dc->no_user = 1; dc->unplug = pci_piix3_xen_ide_unplug; }
1threat
How to merge two array value with Javascript? : I looking for some answers , i just find `concat()` It will become `['A', 'B', 'C', 'a', 'b', 'c']` that is not what i want. var one = ['A', 'B', 'C']; var two = ['a', 'b', 'c']; I want it becomes to this: var three = ['Aa', 'Bb', 'Cc']; How would i do this ? Thanks in advance.
0debug
How do i get JavaScript to show number instead of strings : <p>So i'm quite new to javascript and im trying to make this thing where i enter 2 values and it will either plus, multiply, divide etc. from what i enter in the code. But somehow when i try to multiply 5*2 it will show 10 but when i try 5+2 it will show 52, how do i fix this? I tried parseInt() but it didnt work</p> <p>[Output][1]</p> <p>Code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function myfunction() { var x = document.getElementById("fname").value; var y = document.getElementById("lname").value; var z = x + y; document.getElementById("output").innerHTML = z;</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form&gt; &lt;input type="Number" id="fname" value="" &gt;&lt;br&gt;&lt;br&gt; &lt;input type="number" id="lname" value="" &gt;&lt;br&gt;&lt;br&gt; &lt;/form&gt; &lt;button type="button" onclick="myfunction()"&gt;submit&lt;/button&gt; &lt;p id="output"&gt;&lt;/p&gt;</code></pre> </div> </div> </p>
0debug
Match multiple lines inside files from pattern ? (Python) : <p>I am trying to verify if inside a file there is the same section as given as pattern inside my script.</p> <p>I tried to open the file and readlines into a list, but it was not successful when i tried to match the pattern with the file.</p> <p>Example: Input file:</p> <ol> <li>This is the first line </li> <li>Second line </li> <li>Third line</li> </ol> <p>pattern : </p> <ol> <li>Second line </li> <li>Third line</li> </ol> <p>How can i match if the pattern is in my file ?</p> <p>Thank you</p>
0debug
How do i Reset the headset icon in my phone Programmatically : <p>I am using LG E410 running on android 4.1 and the phone has an headphone icon at the notification bar even if the headphone is not connected. This means for me to answer a call, i have to put loud speaker on.</p>
0debug
What is the scoop of percompile variable in c++? : Is the scoop of the precompile variable the file where it defined? for example: three files test1.hpp/test1.cpp test2.hpp/test2.cpp test3.hpp/test3.cpp #ifndef test1_hpp #define test1_hpp // dosomething #endif // In test2.hpp and test.hpp both #include test1.hpp. If the scoop of test1_hpp is the whole application,in my opinion, there can only one include test1.hpp success. Because once included, test1.hpp defined.
0debug
av_cold void ff_wmv2_common_init(Wmv2Context *w) { MpegEncContext *const s = &w->s; ff_blockdsp_init(&s->bdsp, s->avctx); ff_wmv2dsp_init(&w->wdsp); s->idsp.perm_type = w->wdsp.idct_perm; ff_init_scantable_permutation(s->idsp.idct_permutation, w->wdsp.idct_perm); ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[0], ff_wmv2_scantableA); ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[1], ff_wmv2_scantableB); ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_wmv1_scantable[1]); ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_wmv1_scantable[2]); ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_wmv1_scantable[3]); ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_wmv1_scantable[0]); s->idsp.idct_put = w->wdsp.idct_put; s->idsp.idct_add = w->wdsp.idct_add; s->idsp.idct = NULL; }
1threat
Laravel 5.5 ajax call 419 (unknown status) : <p>I do an ajax call but I keep getting this error:</p> <blockquote> <p>419 (unknown status)</p> </blockquote> <p>No idea what is causing this I saw on other posts it has to do something with csrf token but I have no form so I dont know how to fix this.</p> <p>my call:</p> <pre><code>$('.company-selector li &gt; a').click(function(e) { e.preventDefault(); var companyId = $(this).data("company-id"); $.ajax({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, url: '/fetch-company/' + companyId, dataType : 'json', type: 'POST', data: {}, contentType: false, processData: false, success:function(response) { console.log(response); } }); }); </code></pre> <p>My route:</p> <pre><code>Route::post('fetch-company/{companyId}', 'HomeController@fetchCompany'); </code></pre> <p>My controller method</p> <pre><code>/** * Fetches a company * * @param $companyId * * @return array */ public function fetchCompany($companyId) { $company = Company::where('id', $companyId)-&gt;first(); return response()-&gt;json($company); } </code></pre> <p>The ultimate goal is to display something from the response in a html element.</p>
0debug
GCC 9.1 returns void& as result type for an explicit destructor call. Is this a bug? : <p>I'm trying to get <a href="https://stackoverflow.com/a/10722840/4694124">this is-class-defined-check</a> to work, which relies on the fact that <code>decltype(std::declval&lt;Foo&gt;().~Foo())</code> is <code>void</code> if <code>Foo</code> has a destructor (which it has if it is defined…) and is ill-formed otherwise, invoking SFINAE in this case.</p> <p>However, I can't get the code to work with GCC 9.1, and that is because GCC 9.1 seems to consider that type to be <code>void &amp;</code> <em>if the destructor is defaulted</em>, consider this example:</p> <pre><code>#include &lt;type_traits&gt; class Foo { public: // With this, the DestructorReturnType below becomes "void" // ~Foo () {} }; // … unless I specify the user-defined destructor above, in which case it is "void" using DestructorReturnType = decltype(std::declval&lt;Foo&gt;().~Foo()); template&lt;class T&gt; class TD; // Says: aggregate 'TD&lt;void&amp;&gt; t' has incomplete type and cannot be defined TD&lt;DestructorReturnType&gt; t; </code></pre> <p>(available at <a href="https://gcc.godbolt.org/z/K1TjOP" rel="noreferrer">https://gcc.godbolt.org/z/K1TjOP</a> ) </p> <p>If I user-define an empty destructor, the type jumps back to <code>void</code>. Also if I switch back to GCC 8.x.</p> <p>The C++17 standard states in [expr.call]:</p> <blockquote> <p>If the postfix-expression designates a destructor, the type of the function call expression is void; […]</p> </blockquote> <p>Because of all this, I suspect that GCC 8.x (and clang, …) are correct, and GCC 9.1 is just wrong. Or am I missing something?</p>
0debug
Is Database will get affect by using POSTMAN tool : Is Database will get affect by passing API url by POSTMAN. I didn't tried yet. But I need to try with that. So Could anybody help me for this.
0debug
Is there a way to count elements of a JSON column in MySQL? : <p>I have the table <code>answers</code> below corresponding to every new survey submission.</p> <p><a href="https://i.stack.imgur.com/LuZZw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LuZZw.png" alt="enter image description here"></a></p> <p>I would like to get the results as:</p> <pre><code>| rst_id | school_id | q_4_1 | q_4_2 | ... | q_4_43 | +--------+-----------+-------+-------+-----+--------+ | 9 | 101 | 3 | 0 | ... | 3 | </code></pre> <p>Is this even possible in MySQL 5.8?</p> <p>Same question: <a href="https://stackoverflow.com/questions/51464696/count-occurrences-of-items-in-a-mysql-json-field">Count occurrences of items in a MySQL JSON field</a></p>
0debug
document.write('<script src="evil.js"></script>');
1threat
Ceasers Cipher in Javascript : I am trying to write a program to solve the following problem in javascript (Written below this paragraph). I don't know why my code isn't working. Could someone help me? I'm new to javascript; this is a free code camp question. "A common modern use is the ROT13 cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on. Write a function which takes a ROT13 encoded string as input and returns a decoded string." <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> function rot13(str) { // LBH QVQ VG! var string = ""; for(var i = 0; i < str.length; i++) { var temp = str.charAt(i); if(temp !== " " || temp!== "!" || temp!== "?") { string += String.fromCharCode(13 + String.prototype.charCodeAt(temp)); } else { string += temp; } } return string; } // Change the inputs below to test rot13("SERR PBQR PNZC"); //should decode to "FREE CODE CAMP" <!-- end snippet -->
0debug
iscsi_aio_cancel(BlockDriverAIOCB *blockacb) { IscsiAIOCB *acb = (IscsiAIOCB *)blockacb; IscsiLun *iscsilun = acb->iscsilun; acb->common.cb(acb->common.opaque, -ECANCELED); acb->canceled = 1; iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task, iscsi_abort_task_cb, NULL); iscsi_scsi_task_cancel(iscsilun->iscsi, acb->task); }
1threat
How to filter a vector of custom structs in Rust? : <p>I am trying to filter a <code>Vec&lt;Vocabulary&gt;</code> where <code>Vocabulary</code> is a custom <code>struct</code>, which itself contains a <code>struct</code> <code>VocabularyMetadata</code> and a <code>Vec&lt;Word&gt;</code>:</p> <pre><code>#[derive(Serialize, Deserialize)] pub struct Vocabulary { pub metadata: VocabularyMetadata, pub words: Vec&lt;Word&gt; } </code></pre> <p>This is for handling a route in a web application, where the route looks like this: <code>/word/&lt;vocabulary_id&gt;/&lt;word_id&gt;</code>.</p> <p>Here is my current code trying to <code>filter</code> the <code>Vec&lt;Vocabulary&gt;</code>:</p> <pre><code>let the_vocabulary: Vec&lt;Vocabulary&gt; = vocabulary_context.vocabularies.iter() .filter(|voc| voc.metadata.identifier == vocabulary_id) .collect::&lt;Vec&lt;Vocabulary&gt;&gt;(); </code></pre> <p>This does not work. The error I get is:</p> <pre><code> the trait `std::iter::FromIterator&lt;&amp;app_structs::Vocabulary&gt;` is not implemented for `std::vec::Vec&lt;app_structs::Vocabulary&gt;` [E0277] </code></pre> <p>I don't know how to implement any <code>FromIterator</code>, nor why that would be necessary. In another route in the same web app, same file I do the following, which works:</p> <pre><code>let result: Vec&lt;String&gt; = vocabulary_context.vocabularies.iter() .filter(|voc| voc.metadata.identifier.as_str().contains(vocabulary_id)) .map(encode_to_string) .collect::&lt;Vec&lt;String&gt;&gt;(); result.join("\n\n") // returning </code></pre> <p>So it seems that <code>String</code> implements <code>FromIterator</code>.</p> <p>However, I don't get, why I cannot simple get back the Elements of the <code>Vec</code> from the <code>filter</code> or <code>collect</code> method.</p> <p>How can I <code>filter</code> my <code>Vec</code> and simply get the elements of the <code>Vec&lt;Vocabulary&gt;</code>, for which the condition is true?</p>
0debug
Code for "fizzbuzz" doesn't work properly, it only return "fizzbuzz" throught out the string as answer : Can someone please explain why the following code does not work properly? It only returns "fizzbuzz" 100 times as the answer. Thank you. def fizzbuzz(number) idx = 0 while idx <= number num = number[idx] if num % 3 == 0 && num % 5 == 0 puts 'fizzbuzz' elsif num % 5 == 0 puts 'buzz' elsif num % 3 == 0 puts 'fizz' else puts num end idx += 1 end end fizzbuzz(100)
0debug
Angular : how to call finally() with RXJS 6 : <p>I was using RXJS 5, now as I upgraded it to 6, I am facing some problems.</p> <p>Previously I was able to use catch and finally but as per update catch is replaced with catchError (with in the pipe) now how to use finally?</p> <p>Also I have some questions :</p> <p>Do I need to change throw->throwError (in below code Observable.throw(err);)</p> <pre><code>import { Observable, Subject, EMPTY, throwError } from "rxjs"; import { catchError } from 'rxjs/operators'; return next.handle(clonedreq).pipe( catchError((err: HttpErrorResponse) =&gt; { if ((err.status == 400) || (err.status == 401)) { this.interceptorRedirectService.getInterceptedSource().next(err.status); return Observable.empty(); } else { return Observable.throw(err); } }) //, finally(() =&gt; { // this.globalEventsManager.showLoader.emit(false); //}); ); </code></pre> <p>Also how to use publish().refCount() now ?</p>
0debug
static int64_t get_dts(AVFormatContext *s, int64_t pos) { AVIOContext *pb = s->pb; int64_t dts; ffm_seek1(s, pos); avio_skip(pb, 4); dts = avio_rb64(pb); av_dlog(s, "dts=%0.6f\n", dts / 1000000.0); return dts; }
1threat
Are std::tuple and std::tuple<std::tuple> considered same type by std::vector? : <p>I have a variable defined like this</p> <pre><code>auto drum = std::make_tuple ( std::make_tuple ( 0.3f , ExampleClass , [](ExampleClass&amp; instance) {return instance.eGetter ();} ) ); </code></pre> <p>I expect <code>drum</code> to be a tuple of tuple. (i.e. <code>((a, b, c))</code>).</p> <p>And I have another variable defined like this</p> <pre><code>auto base = std::make_tuple ( 0.48f , ExampleClass , [](ExampleClass&amp; instance) {return instance.eGetter ();} ); </code></pre> <p>which I expect to be just a tuple of three elements (i.e <code>(a, b, c)</code>)</p> <p>I also have a vector defined as follows</p> <pre><code>std::vector&lt;std::tuple&lt;std::tuple&lt; float , ExampleClass , std::function&lt;float (ExampleClass&amp;)&gt; &gt;&gt;&gt; listOfInstruments; </code></pre> <p>Now if I add <code>drum</code> to <code>listOfInstruments</code> I expect no errors.</p> <p>Which was indeed the case with <code>listOfInstruments.push_back(drum);</code></p> <p>Where I expected an error was here <code>listOfInstuments.push_back(base);</code> but the code compiles just fine.</p> <p>Since <code>listOfInstruments</code> has type 'tuple of tuples', should't adding just 'tuple' cause some error? Unless both <code>()</code> and <code>(())</code> are considered same types by <code>std::vector</code>. Or am I completely wrong and there's something else at work here?</p> <p>Can't seem to figure it out.</p>
0debug
static uint64_t omap_mpui_read(void *opaque, target_phys_addr_t addr, unsigned size) { struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; if (size != 4) { return omap_badwidth_read32(opaque, addr); } switch (addr) { case 0x00: return s->mpui_ctrl; case 0x04: return 0x01ffffff; case 0x08: return 0xffffffff; case 0x0c: return 0x00000800; case 0x10: return 0x00000000; case 0x14: case 0x18: return 0x00000000; case 0x1c: return 0x0000ffff; } OMAP_BAD_REG(addr); return 0; }
1threat
static int parse_interval(Interval *interval, int interval_count, const char **buf, void *log_ctx) { char *intervalstr; int ret; *buf += strspn(*buf, SPACES); if (!**buf) return 0; memset(interval, 0, sizeof(Interval)); interval->index = interval_count; intervalstr = av_get_token(buf, DELIMS); if (intervalstr && intervalstr[0]) { char *start, *end; start = av_strtok(intervalstr, "-", &end); if ((ret = av_parse_time(&interval->start_ts, start, 1)) < 0) { "Invalid start time specification '%s' in interval #%d\n", start, interval_count); if (end) { if ((ret = av_parse_time(&interval->end_ts, end, 1)) < 0) { "Invalid end time specification '%s' in interval #%d\n", end, interval_count); } else { interval->end_ts = INT64_MAX; if (interval->end_ts < interval->start_ts) { "Invalid end time '%s' in interval #%d: " "cannot be lesser than start time '%s'\n", end, interval_count, start); } else { "No interval specified for interval #%d\n", interval_count); ret = parse_commands(&interval->commands, &interval->nb_commands, interval_count, buf, log_ctx); end: av_free(intervalstr); return ret;
1threat
How to simply pass numbers and equations across view controllers? : <p>I want to have 3 View Controllers; A, B, and C. View Controller A will be where the final value gets displayed, or the Main View Controller. View Controller B and View Controller C will have simple Text Fields as inputs. The values you put into the Text Fields in View Controller B and C will be added together and shown in View Controller A. You will also need to have buttons to implement the action. How can this be done?</p> <p>For instance, if the user inputs the number 2 in View Controller B and the number 3 in View Controller C text fields, then View Controller A will show the number 5.</p>
0debug
int32_t idiv32(int32_t *q_ptr, int64_t num, int32_t den) { *q_ptr = num / den; return num % den; }
1threat
static void tgen_movcond(TCGContext *s, TCGType type, TCGCond c, TCGReg dest, TCGReg c1, TCGArg c2, int c2const, TCGReg r3) { int cc; if (facilities & FACILITY_LOAD_ON_COND) { cc = tgen_cmp(s, type, c, c1, c2, c2const, false); tcg_out_insn(s, RRF, LOCGR, dest, r3, cc); } else { c = tcg_invert_cond(c); cc = tgen_cmp(s, type, c, c1, c2, c2const, false); tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1); tcg_out_insn(s, RRE, LGR, dest, r3); } }
1threat
ff_yuv2packedX_altivec(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int dstY) { int i,j; vector signed short X,X0,X1,Y0,U0,V0,Y1,U1,V1,U,V; vector signed short R0,G0,B0,R1,G1,B1; vector unsigned char R,G,B; vector unsigned char *out,*nout; vector signed short RND = vec_splat_s16(1<<3); vector unsigned short SCL = vec_splat_u16(4); DECLARE_ALIGNED(16, unsigned int, scratch)[16]; vector signed short *YCoeffs, *CCoeffs; YCoeffs = c->vYCoeffsBank+dstY*lumFilterSize; CCoeffs = c->vCCoeffsBank+dstY*chrFilterSize; out = (vector unsigned char *)dest; for (i=0; i<dstW; i+=16) { Y0 = RND; Y1 = RND; for (j=0; j<lumFilterSize; j++) { X0 = vec_ld (0, &lumSrc[j][i]); X1 = vec_ld (16, &lumSrc[j][i]); Y0 = vec_mradds (X0, YCoeffs[j], Y0); Y1 = vec_mradds (X1, YCoeffs[j], Y1); } U = RND; V = RND; for (j=0; j<chrFilterSize; j++) { X = vec_ld (0, &chrUSrc[j][i/2]); U = vec_mradds (X, CCoeffs[j], U); X = vec_ld (0, &chrVSrc[j][i/2]); V = vec_mradds (X, CCoeffs[j], V); } Y0 = vec_sra (Y0, SCL); Y1 = vec_sra (Y1, SCL); U = vec_sra (U, SCL); V = vec_sra (V, SCL); Y0 = vec_clip_s16 (Y0); Y1 = vec_clip_s16 (Y1); U = vec_clip_s16 (U); V = vec_clip_s16 (V); U0 = vec_mergeh (U,U); V0 = vec_mergeh (V,V); U1 = vec_mergel (U,U); V1 = vec_mergel (V,V); cvtyuvtoRGB (c, Y0,U0,V0,&R0,&G0,&B0); cvtyuvtoRGB (c, Y1,U1,V1,&R1,&G1,&B1); R = vec_packclp (R0,R1); G = vec_packclp (G0,G1); B = vec_packclp (B0,B1); switch(c->dstFormat) { case PIX_FMT_ABGR: out_abgr (R,G,B,out); break; case PIX_FMT_BGRA: out_bgra (R,G,B,out); break; case PIX_FMT_RGBA: out_rgba (R,G,B,out); break; case PIX_FMT_ARGB: out_argb (R,G,B,out); break; case PIX_FMT_RGB24: out_rgb24 (R,G,B,out); break; case PIX_FMT_BGR24: out_bgr24 (R,G,B,out); break; default: { static int printed_error_message; if (!printed_error_message) { av_log(c, AV_LOG_ERROR, "altivec_yuv2packedX doesn't support %s output\n", sws_format_name(c->dstFormat)); printed_error_message=1; } return; } } } if (i < dstW) { i -= 16; Y0 = RND; Y1 = RND; for (j=0; j<lumFilterSize; j++) { X0 = vec_ld (0, &lumSrc[j][i]); X1 = vec_ld (16, &lumSrc[j][i]); Y0 = vec_mradds (X0, YCoeffs[j], Y0); Y1 = vec_mradds (X1, YCoeffs[j], Y1); } U = RND; V = RND; for (j=0; j<chrFilterSize; j++) { X = vec_ld (0, &chrUSrc[j][i/2]); U = vec_mradds (X, CCoeffs[j], U); X = vec_ld (0, &chrVSrc[j][i/2]); V = vec_mradds (X, CCoeffs[j], V); } Y0 = vec_sra (Y0, SCL); Y1 = vec_sra (Y1, SCL); U = vec_sra (U, SCL); V = vec_sra (V, SCL); Y0 = vec_clip_s16 (Y0); Y1 = vec_clip_s16 (Y1); U = vec_clip_s16 (U); V = vec_clip_s16 (V); U0 = vec_mergeh (U,U); V0 = vec_mergeh (V,V); U1 = vec_mergel (U,U); V1 = vec_mergel (V,V); cvtyuvtoRGB (c, Y0,U0,V0,&R0,&G0,&B0); cvtyuvtoRGB (c, Y1,U1,V1,&R1,&G1,&B1); R = vec_packclp (R0,R1); G = vec_packclp (G0,G1); B = vec_packclp (B0,B1); nout = (vector unsigned char *)scratch; switch(c->dstFormat) { case PIX_FMT_ABGR: out_abgr (R,G,B,nout); break; case PIX_FMT_BGRA: out_bgra (R,G,B,nout); break; case PIX_FMT_RGBA: out_rgba (R,G,B,nout); break; case PIX_FMT_ARGB: out_argb (R,G,B,nout); break; case PIX_FMT_RGB24: out_rgb24 (R,G,B,nout); break; case PIX_FMT_BGR24: out_bgr24 (R,G,B,nout); break; default: av_log(c, AV_LOG_ERROR, "altivec_yuv2packedX doesn't support %s output\n", sws_format_name(c->dstFormat)); return; } memcpy (&((uint32_t*)dest)[i], scratch, (dstW-i)/4); } }
1threat
C++ badly initialized std::set : <p>I have a public variable inside a class, declared as</p> <pre><code>std::set&lt;int&gt; test; </code></pre> <p>and never explicitly initialized. When I try to access it from a shared pointer <code>c</code> of an instance of the object:</p> <pre><code>std::set&lt;int&gt;&amp; myset = c-&gt;test; </code></pre> <p>I see in the debugger that <code>myset</code> is badly initialized: it has both fields <code>_Myhead</code> and <code>_Mysize</code> null. Could you please explain why that happens?</p>
0debug
static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stride, int scale, int dc){ int i; dc*= 0x10001; switch(log2w){ case 0: for(i=0; i<h; i++){ dst[0] = scale*src[0] + dc; if(scale) src += stride; dst += stride; } break; case 1: for(i=0; i<h; i++){ LE_CENTRIC_MUL(dst, src, scale, dc); if(scale) src += stride; dst += stride; } break; case 2: for(i=0; i<h; i++){ LE_CENTRIC_MUL(dst, src, scale, dc); LE_CENTRIC_MUL(dst + 2, src + 2, scale, dc); if(scale) src += stride; dst += stride; } break; case 3: for(i=0; i<h; i++){ LE_CENTRIC_MUL(dst, src, scale, dc); LE_CENTRIC_MUL(dst + 2, src + 2, scale, dc); LE_CENTRIC_MUL(dst + 4, src + 4, scale, dc); LE_CENTRIC_MUL(dst + 6, src + 6, scale, dc); if(scale) src += stride; dst += stride; } break; default: assert(0); } }
1threat
geom_smooth in ggplot2 not working/showing up : <p>I am trying to add a linear regression line to my graph, but when it's run, it's not showing up. The code below is simplified. There are usually multiple points on each day. The graph comes out fine other than that. </p> <pre><code> b&lt;-data.frame(day=c('05/22','05/23','05/24','05/25','05/26','05/27','05/28','05/29','05/30','05/31','06/01','06/02','06/03','06/04','06/05','06/06','06/07','06/08','06/09','06/10','06/11','06/12','06/13','06/14','06/15','06/16','06/17','06/18','06/19','06/20','06/21','06/22','06/23','06/24','06/25'), temp=c(10.1,8.7,11.4,11.4,11.6,10.7,9.6,11.0,10.0,10.7,9.5,10.3,8.4,9.0,10.3,11.3,12.7,14.5,12.5,13.2,16.5,19.1,14.6,14.0,15.3,13.0,10.1,8.4,4.6,4.3,4.7,2.7,1.6,1.8,1.9)) gg2 &lt;- ggplot(b, aes(x=day, y=temp, color=temp)) + geom_point(stat='identity', position='identity', aes(colour=temp),size=3) gg2&lt;- gg2 + geom_smooth(method='lm') + scale_colour_gradient(low='yellow', high='#de2d26') gg2 &lt;-gg2 + labs(title=filenames[s], x='Date', y='Temperture (Celsius)') + theme(axis.text.x=element_text(angle=-45, vjust=0.5)) gg2 </code></pre> <p>It's probably something really simple, but I can't seem to figure it out. Or it's the fact I am using a date for the x-axis, but I'm not receiving any errors. If it is due to the date, I'm not sure how to approach it. Thanks.</p>
0debug
CUMILATIVE SUM BASED ON COLUMNS : I Have a table with values [![enter image description here][1]][1] I want it to have cumilative Sum based on the ID and year i.e it should like [![enter image description here][2]][2] [1]: https://i.stack.imgur.com/tYRmP.png [2]: https://i.stack.imgur.com/s5sd7.png
0debug
mutex.lock vs unique_lock : <p>When should I prefer the first piece of code to the second, and do they have fundamental differences</p> <pre><code>std::mutex mtx; mtx.lock(); ... //protected stuff mtx.unlock(); ... //non-protected stuff mtx.lock(); ... //etc </code></pre> <p>and</p> <pre><code>std::mutex mtx; std::unique_lock&lt;std::mutex&gt; lck(mtx); ... //protected stuff lck.unlock(); ... //non-protected stuff lck.lock(); ... //etc </code></pre> <p>I do understand that lock_guard is basically a unique_lock without the lock and unlock functions, but I'm having hard time differentiating a mutex and a lock using a mutex. </p>
0debug
document.write('<script src="evil.js"></script>');
1threat
static void vncws_tls_handshake_io(void *opaque) { struct VncState *vs = (struct VncState *)opaque; VNC_DEBUG("Handshake IO continue\n"); vncws_start_tls_handshake(vs); }
1threat
Javascript append with TMDB api : I have this script i need to fix append abd remove old info when click, also i need to show episode info on third column how to? i need same result to this : https://popcorntime-online.tv/game-of-thrones-season-1-episode-0-15-minute-preview.html?imdb=0944947-1-0 (sorry for my english) <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> $(document).ready(function() { console.log('jQuery'); var baseUrl = "https://api.themoviedb.org/3/tv/"; var apikey = "6b4357c41d9c606e4d7ebe2f4a8850ea"; var appendToResponse = "credits"; var id = 1399; var dataUrl = baseUrl + id + "?api_key=" + apikey + "&append_to_response=" + appendToResponse; $.getJSON(dataUrl, function(data) { console.log(data); var filmtitle = data.name; var filmlength = data.episode_run_time; var plot = data.overview; var release = new Date(data.last_air_date); var year = release.getFullYear(); var seasons = data.seasons.length; for (var i = 0; i < data.seasons.length; i++) { $(".seasons").append("<div class='row season' data-season='" + data.seasons[i].season_number + "' onclick='seriesInfo(" + id + "," + data.seasons[i].season_number + ")' value='" + data.seasons[i].season_number + "'><a href='#'>Season " + data.seasons[i].season_number + "</a></div>"); $('.row.season').click(function(e) { e.preventDefault(); $('.season').removeClass('activated'); $(this).addClass('activated'); }); } }); }); function seriesInfo(id, num) { var seriesURL = "https://api.themoviedb.org/3/tv/" + id + "/season/" + num + "?&api_key=6b4357c41d9c606e4d7ebe2f4a8850ea"; $.getJSON(seriesURL, function(data) { console.log(data); for (var i = 0; i < data.episodes.length; i++) { var seasonname = data.name; var seasonoverview = data.overview; var episode = data.episodes[i].name; var number = data.episodes[i].episode_number; var overview = data.episodes[i].overview; var airdate = data.episodes[i].air_date; $(".episodes").append("<div data-episode_id='" + number + "' data-episode_num='" + number + "' onclick='seriesShow(" + id + "," + data.episodes[i].episode_number + ")' value='" + data.episodes[i].episode_number + "'class='row episode'><a href='#'><span class='episode_num'>" + number + "</span>&nbsp;&nbsp;<span class='episode_title'>" + episode + "</span><div class='pseudo_click_listener'></div></a></div>"); } }); } function seriesShow(id, num) { var episodeURL = "https://api.themoviedb.org/3/tv/" + id + "/season/" + num + "/episode/" + num + "?&api_key=6b4357c41d9c606e4d7ebe2f4a8850ea"; $.getJSON(episodeURL, function(data) { console.log(data); for (var i = 0; i < data.episodes.length; i++) { var seasonoverview = data.overview; var episode = data.episodes[i].name; var number = data.episodes[i].episode_number; var overview = data.episodes[i].overview; var airdate = data.episodes[i].air_date; $(".show").prepend("<div class='column content'><div class='episode_name'>" + episode + "</div><div class='episode_info'><b class='episode_number'>Episode " + number + "</b></div><div class='episode_overview'>" + overview + "</div>"); } }); } <!-- language: lang-css --> .synopsis { font-size: 13px; line-height: 18px; color: rgba(255, 255, 255, 0.65); padding-right: 20px; height: 120px; overflow: auto; } .head { color: #fff; width: 100%; height: 240px; position: absolute; top: 65px; left: 0; border-bottom: 1px rgba(255, 255, 255, 0.05) solid; z-index: 9; } .info_cont { position: absolute; top: 20px; left: 185px } .runtime_cont { display: none; } .poster { position: absolute; top: 25px; left: -200px; width: 135px; height: 197px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 1); border: 1px rgba(255, 255, 255, 0.18) solid; background-repeat: no-repeat; background-position: center center; background-size: cover; opacity: 0; transition-property: all; transition-duration: 0.21s; transition-timing-function: ease-out; } .poster.fadein { opacity: 1; left: 20px; } .body { position: absolute; width: 100%; height: 100%; left: 0; bottom: 0; z-index: 9; box-sizing: border-box; background: linear-gradient(to right, rgba(0, 0, 0, 0.27) 0%, rgba(0, 0, 0, 0.75) 100%); /* W3C */ } .column { float: left; height: 100%; box-sizing: border-box; padding: 20px; position: relative; } .column.seasons { width: 15%; overflow: hidden; } .column.episodes { width: 40%; overflow: hidden; } .column.content { width: 45%; } .row { height: 35px; border-bottom: 1px rgba(255, 255, 255, 0.045) solid; font-size: 14px; color: #fff; line-height: 35px; padding: 0 6px; box-sizing: border-box; cursor: pointer; position: relative; overflow: hidden; transition-property: padding; transition-duration: 0.1s; transition-timing-function: linear; } .row * { cursor: pointer !important; } .row:hover, .row.khover { padding: 0 12px; border-left: 3px rgba(255, 255, 255, 0.4) solid; } .row.activated { padding: 0 12px !important; border-left: 3px rgba(255, 255, 255, 0.8) solid !important; } .row:nth-child(odd) { background: linear-gradient(to right, rgba(255, 255, 255, 0.125) 0%, rgba(255, 255, 255, 0) 100%); /* W3C */ } .row.episode .pseudo_click_listener { position: absolute; width: 16px; height: 100%; right: 0; top: 0; z-index: 9; } .row .episode_title { opacity: 0.4; } .row:hover .episode_title, .row.activated .episode_title { opacity: 0.68; } .row .episode_num { font-family: opensansbold } .scroller_cont { padding-bottom: 15px; } .episode_name { text-shadow: 2px 2px 2px rgba(0, 0, 0, 1); font-size: 22px; color: #fff; font-family: opensansbold; } .episode_info { font-size: 13px; color: rgba(255, 255, 255, 0.4); padding: 2px 0 15px; } .episode_overview { height: calc(100% - 135px); overflow: auto; color: rgba(255, 255, 255, 0.64); font-size: 12px; line-height: 16px; } .toolbox_content { height: 60px; position: absolute; bottom: 10px; left: 20px; z-index: 9; width: 100%; } .selector { margin-bottom: 5px; width: 160px !important; } .sep { margin-right: 15px !important; } .row.episode.watched:after { content: "\e601"; color: rgba(255, 255, 255, 0.4); } .row.episode:after { font-family: icomoon; content: "\e60d"; position: absolute; right: 0; font-size: 11px; color: rgba(255, 255, 255, 0.12); } <!-- language: lang-html --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="body"> <div class="column seasons"></div> <div class='column episodes'></div> <div class='show'></div> <!-- end snippet --> (sorry for my english)
0debug
def min_of_two( x, y ): if x < y: return x return y
0debug
how to combine try in the if condition : <p>first code</p> <pre><code>try { InputStream is = getAssets().open("read_asset.txt"); int size = is.available(); byte[] buffer = new byte[size]; is.read(buffer); is.close(); String text = new String(buffer); TextView tv = (TextView)findViewById(R.id.text); tv.setText(text); } catch (IOException e) { throw new RuntimeException(e); } </code></pre> <p>and this second code</p> <pre><code>if(txtweb.getText().toString().equals("Google Plus")) { setContentView(R.layout.google); } else if(txtweb.getText().toString().equals("Twitter")){ setContentView(R.layout.google); } </code></pre> <p>i want to combine try code into if condition , please help</p>
0debug
How can i convert a dictionnary values to string in python : dict={(0, 0): 'S', (1, 1): 'T', (2, 2): 'A', (3, 3): 'C', (4, 4): 'K', (5, 5): 'O', (6, 6): 'V', (5, 7): 'E', (4, 8): 'R', (3, 9): 'F', (2, 10): 'L', (1, 11): 'O', (0, 12): 'W', (1, 13): 'T', (2, 14): 'E', (3, 15): 'S', (4, 16): 'T'} if i want to convert the values of this dictionnary to an str how can i do it ? also if i want to show the string in special order like : (0, 0), (0, 12),(1, 1),(1, 11) .... Thank You
0debug
static always_inline void check_mips_mt(CPUState *env, DisasContext *ctx) { if (unlikely(!(env->CP0_Config3 & (1 << CP0C3_MT)))) generate_exception(ctx, EXCP_RI); }
1threat
TWO QUERIES AND DIFFERENCE OF THEIR SUMS : BELOW ARE TWO SIMPLE/SIMILAR QUERIES THAT I WOULD LIKE TO JOIN INTO ONE. I ALSO WANT TO HAVE A COLUMN CONTAINING THE DIFFERENCE BETWEEN THE TWO SUMS IN EITHER QUERY. (I've found help on the join of two queries but I think there is a simpler solution and I am new to SQL) I want my output to be 4 columns: 1)Post_Date 2)All_Payments 3)CCP_Payments 4)All_Payments - CCP_Payments (SUBTRACT THE TWO) QUERY 1: SELECT TDL.POST_DATE , SUM(CASE WHEN TDL.DETAIL_TYPE IN(2,5,11,20,22,32,33) THEN TDL.AMOUNT*-1 ELSE 0 END) PAYMENTS FROM STG_OJDT.STG_CL.CLARITY_TDL_TRAN TDL WHERE TDL.POST_DATE = '2018-08-01 00:00:00' AND TDL.SERV_AREA_ID = 10 GROUP BY TDL.POST_DATE QUERY 2: SELECT TDL.POST_DATE , SUM(CASE WHEN TDL.DETAIL_TYPE IN(2,5,11,20,22,32,33) THEN TDL.AMOUNT*-1 ELSE 0 END) CCP_PAYMENTS FROM STG_OJDT.STG_CL.CLARITY_TDL_TRAN TDL WHERE TDL.POST_DATE = '2018-08-01 00:00:00' AND TDL.SERV_AREA_ID = 10 AND TDL.BILL_AREA_ID IN (810000020, 810000025, 810000030) GROUP BY TDL.POST_DATE
0debug
static uint32_t scsi_init_iovec(SCSIDiskReq *r, size_t size) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); if (!r->iov.iov_base) { r->buflen = size; r->iov.iov_base = qemu_blockalign(s->qdev.conf.bs, r->buflen); } r->iov.iov_len = MIN(r->sector_count * 512, r->buflen); qemu_iovec_init_external(&r->qiov, &r->iov, 1); return r->qiov.size / 512; }
1threat
Render a View inside a View in Asp.Net mvc : <p>How do I render a full fledged view (not partial view) inside another view?</p> <p>Scenario, I have different controller and want the exactly same view to render which is already there under other controller with different layout.</p> <p>I have Wishlist page in Home Controller which shows list of added products, and when user logged in , when I click on wish list it also show me navigation when user is signed in. </p> <p>How would I do that??</p>
0debug
int bdrv_snapshot_load_tmp(BlockDriverState *bs, const char *snapshot_name) { BlockDriver *drv = bs->drv; if (!drv) { return -ENOMEDIUM; } if (!bs->read_only) { return -EINVAL; } if (drv->bdrv_snapshot_load_tmp) { return drv->bdrv_snapshot_load_tmp(bs, snapshot_name); } return -ENOTSUP; }
1threat
static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){ int hours, minutes, seconds; if(!show_bits(gb, 18)){ av_log(s->avctx, AV_LOG_WARNING, "GOP header invalid\n"); return -1; } hours= get_bits(gb, 5); minutes= get_bits(gb, 6); skip_bits1(gb); seconds= get_bits(gb, 6); s->time_base= seconds + 60*(minutes + 60*hours); skip_bits1(gb); skip_bits1(gb); return 0; }
1threat
Scikit-learn: preprocessing.scale() vs preprocessing.StandardScalar() : <p>I understand that scaling means centering the mean(mean=0) and making unit variance(variance=1).</p> <p>But, What is the difference between <code>preprocessing.scale(x)</code>and <code>preprocessing.StandardScalar()</code> in scikit-learn?</p>
0debug
query to write the details of a person whose earning in a day is greater than or equal to their earning in the previous day : Table: Info [Table][1] [Sample Output][2] [1]: https://i.stack.imgur.com/UEpyh.jpg [2]: https://i.stack.imgur.com/yQi6p.jpg This is a college exercise. I have just started learning SQL and don't understand how can you select data from two different rows of a column and create different columns in the sample output. My attemp is completely useless so I'm not putting it here as I only know how to select separate columns. Thank you in advance
0debug
int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, uint8_t *buf, int buf_size) { int ret; if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){ av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n"); return -1; } if(*frame_size_ptr < FF_MIN_BUFFER_SIZE || *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t) || *frame_size_ptr < buf_size){ av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr); return -1; } if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){ ret = avctx->codec->decode(avctx, samples, frame_size_ptr, buf, buf_size); avctx->frame_number++; }else{ ret= 0; *frame_size_ptr=0; } return ret; }
1threat
void vga_common_init(VGACommonState *s, int vga_ram_size) { int i, j, v, b; for(i = 0;i < 256; i++) { v = 0; for(j = 0; j < 8; j++) { v |= ((i >> j) & 1) << (j * 4); } expand4[i] = v; v = 0; for(j = 0; j < 4; j++) { v |= ((i >> (2 * j)) & 3) << (j * 4); } expand2[i] = v; } for(i = 0; i < 16; i++) { v = 0; for(j = 0; j < 4; j++) { b = ((i >> j) & 1); v |= b << (2 * j); v |= b << (2 * j + 1); } expand4to8[i] = v; } #ifdef CONFIG_BOCHS_VBE s->is_vbe_vmstate = 1; #else s->is_vbe_vmstate = 0; #endif s->vram_offset = qemu_ram_alloc(vga_ram_size); s->vram_ptr = qemu_get_ram_ptr(s->vram_offset); s->vram_size = vga_ram_size; s->get_bpp = vga_get_bpp; s->get_offsets = vga_get_offsets; s->get_resolution = vga_get_resolution; s->update = vga_update_display; s->invalidate = vga_invalidate_display; s->screen_dump = vga_screen_dump; s->text_update = vga_update_text; switch (vga_retrace_method) { case VGA_RETRACE_DUMB: s->retrace = vga_dumb_retrace; s->update_retrace_info = vga_dumb_update_retrace_info; break; case VGA_RETRACE_PRECISE: s->retrace = vga_precise_retrace; s->update_retrace_info = vga_precise_update_retrace_info; break; } vga_reset(s); }
1threat
MAX=1000; def replace_spaces(string): string=string.strip() i=len(string) space_count=string.count(' ') new_length = i + space_count*2 if new_length > MAX: return -1 index = new_length-1 string=list(string) for f in range(i-2, new_length-2): string.append('0') for j in range(i-1, 0, -1): if string[j] == ' ': string[index] = '0' string[index-1] = '2' string[index-2] = '%' index=index-3 else: string[index] = string[j] index -= 1 return ''.join(string)
0debug
how do i move the + sign to the left? : how can I move the + sign to the left? `enter code here` *{ margin: 0; padding: 0;}.content{ justify-content: center; align-items: center; height:100vh; }details{ font-family: 'Raleway', sans-serif;}summary { transition: background .75s ease; width: 960px; outline: 0; text-lign: center; font-size: 85%; display: flex; align-items: center; justify-content: space-between; cursor: pointer; border-bottom: 1px solid black;}h50 { color: rgb(0, 0, 255); text-align: left; margin-bottom: 0; padding: 15px; text-shadow: none;font-size: small; font-weight: bold;}details p { padding: 0 25px 15px 25px; margin: 0; text-shadow: none; text-align: justify; line-height: 1.3em;}summary::after { font-family: "Font Awesome 5 Free"; font-weight: 900; content: '\02795'; /* Unicode character for "plus" sign (+) */ font-size: 13px; color: #777; float: right; margin-left: 5px; display: inline-block; padding-right: 15px; font-size: 90%; color: rgb(0, 0, 255);}details[open] summary::after { content: "\2796"; /* Unicode character for "minus" sign (-) */ display: inline-block; padding-right: 15px; font-size: 90%;}details[open] summary:hover { background:none;}summary:hover { background: #d3d3d3;}details summary::-webkit-details-marker { display:none;}`enter code here`
0debug
static int parse_uri(const char *filename, QDict *options, Error **errp) { URI *uri = NULL; QueryParams *qp = NULL; int i; uri = uri_parse(filename); if (!uri) { return -EINVAL; } if (strcmp(uri->scheme, "ssh") != 0) { error_setg(errp, "URI scheme must be 'ssh'"); goto err; } if (!uri->server || strcmp(uri->server, "") == 0) { error_setg(errp, "missing hostname in URI"); goto err; } if (!uri->path || strcmp(uri->path, "") == 0) { error_setg(errp, "missing remote path in URI"); goto err; } qp = query_params_parse(uri->query); if (!qp) { error_setg(errp, "could not parse query parameters"); goto err; } if(uri->user && strcmp(uri->user, "") != 0) { qdict_put(options, "user", qstring_from_str(uri->user)); } qdict_put(options, "host", qstring_from_str(uri->server)); if (uri->port) { qdict_put(options, "port", qint_from_int(uri->port)); } qdict_put(options, "path", qstring_from_str(uri->path)); for (i = 0; i < qp->n; ++i) { if (strcmp(qp->p[i].name, "host_key_check") == 0) { qdict_put(options, "host_key_check", qstring_from_str(qp->p[i].value)); } } query_params_free(qp); uri_free(uri); return 0; err: if (qp) { query_params_free(qp); } if (uri) { uri_free(uri); } return -EINVAL; }
1threat
Retrieve the data from DB and store each Resultset in a excel sheet : <p>I have to retrieve the data from various tables in a DB and store each table value as ResultSet. Then I need to populate each ResultSet values in each sheet of single excel file. So I need to write each table values with column name in a separate sheet of a excel file. Thanks in advance</p>
0debug
UIImage(contentsOfFile:) returning nil despite file existing in caches directory : <p>I'm trying to save a snapshot of a map with an overlay in the caches directory and retrieve it when it exists. However, despite the file being created, UIImage(contentsOfFile:) returns nil when I try to retrieve it. I've printed the file paths for both write and read and they are the same and have verified the file exists by downloading the container and checking the directory and the file definitely exists.</p> <p>Any idea what the problem here is?</p> <pre><code>let cachesDirectory: URL = { let urls = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask) return urls[urls.endIndex - 1] }() let mapCachesDirectory = cachesDirectory.appendingPathComponent("map-snapshots", isDirectory: true) func configureMap(data: NSSet?) { mapView.isZoomEnabled = false mapView.isScrollEnabled = false mapView.isUserInteractionEnabled = false guard let data = data as? Set&lt;SessionData&gt;, data.count &gt; 0 else { return } activityIndicatorView.isHidden = false activityIndicatorView.startAnimating() DispatchQueue.global(qos: .userInitiated).async { var points = [CLLocationCoordinate2D]() for object in data { guard object.locationLatitude != 0, object.locationLatitude != 0 else { continue } points.append(CLLocationCoordinate2DMake(object.locationLatitude, object.locationLongitude)) } DispatchQueue.main.async(execute: { self.createOverlay(points: points) self.activityIndicatorView.stopAnimating() self.activityIndicatorView.isHidden = true self.cacheMapImage(view: self.mapView) }) } } func cacheMapImage(view: UIView) { UIGraphicsBeginImageContextWithOptions(view.bounds.size, true, 0) view.drawHierarchy(in: view.bounds, afterScreenUpdates: true) let compositeImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() DispatchQueue.global(qos: .userInitiated).async { if let compositeImage = compositeImage, let info = self.info { let data = UIImagePNGRepresentation(compositeImage) do { var isDirectory: ObjCBool = false let fileManager = FileManager.default if fileManager.fileExists(atPath: self.mapCachesDirectory.absoluteString, isDirectory: &amp;isDirectory) == false { try fileManager.createDirectory(at: self.mapCachesDirectory, withIntermediateDirectories: true, attributes: nil) } let fileURL = self.mapCachesDirectory.appendingPathComponent(info.uid).appendingPathExtension("png") try data?.write(to: fileURL) print("\(fileURL.absoluteString) Saved") } catch { log.error(error) } } } } func cachedMapImage() -&gt; UIImage? { guard let info = info else { return nil } let filePath = mapCachesDirectory.appendingPathComponent(info.uid).appendingPathExtension("png").absoluteString let image = UIImage(contentsOfFile: filePath) print("\(filePath): \(image)") return image } func createOverlay(points: [CLLocationCoordinate2D]) { guard points.count &gt; 0 else { return } let overlay = MKGeodesicPolyline(coordinates: points, count: points.count) mapView.add(overlay) let inset: CGFloat = 50.0 mapView.setVisibleMapRect(overlay.boundingMapRect, edgePadding: UIEdgeInsetsMake(inset,inset,inset,inset), animated: true) } </code></pre>
0debug
How to pass an array to a function that uses sizeof? : <p>This is what I use to get the length of an array:</p> <pre><code>sizeof(counts) / sizeof(unsigned long) </code></pre> <p>Now I want to make a simple function out of it like:</p> <pre><code>int length(unsigned long* input) { return (sizeof(input) / sizeof(unsigned long)); } unsigned long array[3]; sizeof(array) = 12 sizeof(unsigned long) = 4 sizeof(array) / sizeof(unsigned long) = 3 lenght(array) = 1 </code></pre> <p>Inside length() sizeof(array) returns 4</p> <p>The compiler will complain when I change the function to:</p> <pre><code>int length(unsigned long input) { return (sizeof(input) / sizeof(unsigned long)); } </code></pre> <p>I'm either stoned or just dumb, what am I doing wrong?</p>
0debug
clk_setup_cb ppc_emb_timers_init (CPUState *env, uint32_t freq) { ppc_tb_t *tb_env; ppcemb_timer_t *ppcemb_timer; tb_env = qemu_mallocz(sizeof(ppc_tb_t)); env->tb_env = tb_env; ppcemb_timer = qemu_mallocz(sizeof(ppcemb_timer_t)); tb_env->tb_freq = freq; tb_env->decr_freq = freq; tb_env->opaque = ppcemb_timer; LOG_TB("%s freq %" PRIu32 "\n", __func__, freq); if (ppcemb_timer != NULL) { tb_env->decr_timer = qemu_new_timer(vm_clock, &cpu_4xx_pit_cb, env); ppcemb_timer->fit_timer = qemu_new_timer(vm_clock, &cpu_4xx_fit_cb, env); ppcemb_timer->wdt_timer = qemu_new_timer(vm_clock, &cpu_4xx_wdt_cb, env); } return &ppc_emb_set_tb_clk; }
1threat
int vnc_display_password(DisplayState *ds, const char *password) { VncDisplay *vs = vnc_display; if (!vs) { return -EINVAL; } if (!password) { return vnc_display_disable_login(ds); } if (vs->password) { g_free(vs->password); vs->password = NULL; } vs->password = g_strdup(password); if (vs->auth == VNC_AUTH_NONE) { vs->auth = VNC_AUTH_VNC; } return 0; }
1threat