problem
stringlengths
26
131k
labels
class label
2 classes
Grid System Horizontal Order : <p>Is there any way I can accomplish the following order without adding any div's?</p> <p><strong>t1 t2 t3</strong></p> <p><strong>d1 d2 d3</strong></p> <pre><code>&lt;dl&gt; &lt;dt&gt;t1&lt;/dt&gt; &lt;dd&gt;d1&lt;/dd&gt; &lt;dt&gt;t2&lt;/dt&gt; &lt;dd&gt;d2&lt;/dd&gt; &lt;dt&gt;t3&lt;/dt&gt; &lt;dd&gt;d3&lt;/dd&gt; &lt;/dl&gt; </code></pre>
0debug
Customise ng serve to proxy calls to /api? : <p>I created a new application with ng CLI, works like a charm: <code> ng new babysteps cd babysteps ng serve </code> ng serve uses webpack to assemble the app. To fully test it, I need to serve <code>/api...</code> from my API mock server (specifically the POST requests). How can I customise the web server used, to redirect that one URL pattern?</p> <p>The Webpack dev server has <a href="https://webpack.github.io/docs/webpack-dev-server.html" rel="noreferrer">a proxy setting</a>, but it seems (?) <code>ng serve</code> doesn't have a config file (or I didn't get).</p> <p>Do I need to create a <code>webpack.config.js</code> or create/edit some other file to proxy ?</p>
0debug
How to create a 3rd column based on 2 columns from two tables [inner and outer join] : <ul> <li>I have a lot of rows in 'table alpha' where some of these rows occurs in 'table beta' as well.</li> <li>Both row alpha and beta have a date column. <ul> <li>However, when i select both date columns the rows from table alpha <strong>that do not occur</strong> in row B will have a null-value assigned to them.</li> </ul></li> </ul> <blockquote> <p>My problem is that I want to make a third date-column that will use the dates from table <em>beta</em> <strong>if they are not null</strong>. If they are null, it should use the dates from table alpha.</p> </blockquote>
0debug
def amount_of_Chests () : : def amount_of_Chests () : chestCount = 0 amount_of_Chests_Display () while chestCount <4 : chestCount_string = input("Please Make Sure You Enter Enough Chests\nPlease Enter How Many Chests You Would Like (Min.4)") chestCount = int(chestCount_string) if chestCount < 4 : print ("\nThere Are Not Enough Chests, Please Try Again.") amount_of_Chests_Display () if chestCount > 3 : return chestCount amount_of_Bandits () else : print ("Sorry that input is not valid. Please try Again.\n") whenever I try this it does not work(input = 6), it sends me to the previous menu and says the input is invalid. [Coding on python that does not work][1] [1]: http://i.stack.imgur.com/aHVOi.png
0debug
Search for code or text in GitLab : <p>Is it possible to search for code or text in GitLab inside of files? I can search for files, issues, milestones, etc., but could not find a way to search for code in source files or text in the documentation i.e .doc files.</p>
0debug
static void simpleCopy(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, int srcSliceH, uint8_t* dstParam[], int dstStride[]){ int srcStride[3]; uint8_t *src[3]; uint8_t *dst[3]; if(c->srcFormat == IMGFMT_I420){ src[0]= srcParam[0]; src[1]= srcParam[2]; src[2]= srcParam[1]; srcStride[0]= srcStrideParam[0]; srcStride[1]= srcStrideParam[2]; srcStride[2]= srcStrideParam[1]; } else if(c->srcFormat==IMGFMT_YV12){ src[0]= srcParam[0]; src[1]= srcParam[1]; src[2]= srcParam[2]; srcStride[0]= srcStrideParam[0]; srcStride[1]= srcStrideParam[1]; srcStride[2]= srcStrideParam[2]; } else if(isPacked(c->srcFormat) || isGray(c->srcFormat)){ src[0]= srcParam[0]; src[1]= src[2]= NULL; srcStride[0]= srcStrideParam[0]; srcStride[1]= srcStride[2]= 0; } if(c->dstFormat == IMGFMT_I420){ dst[0]= dstParam[0]; dst[1]= dstParam[2]; dst[2]= dstParam[1]; }else{ dst[0]= dstParam[0]; dst[1]= dstParam[1]; dst[2]= dstParam[2]; } if(isPacked(c->srcFormat)) { if(dstStride[0]==srcStride[0]) memcpy(dst[0] + dstStride[0]*srcSliceY, src[0], srcSliceH*dstStride[0]); else { int i; uint8_t *srcPtr= src[0]; uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY; int length=0; while(length+c->srcW <= dstStride[0] && length+c->srcW <= srcStride[0]) length+= c->srcW; ASSERT(length!=0); for(i=0; i<srcSliceH; i++) { memcpy(dstPtr, srcPtr, length); srcPtr+= srcStride[0]; dstPtr+= dstStride[0]; } } } else { int plane; for(plane=0; plane<3; plane++) { int length= plane==0 ? c->srcW : ((c->srcW+1)>>1); int y= plane==0 ? srcSliceY: ((srcSliceY+1)>>1); int height= plane==0 ? srcSliceH: ((srcSliceH+1)>>1); if(dstStride[plane]==srcStride[plane]) memcpy(dst[plane] + dstStride[plane]*y, src[plane], height*dstStride[plane]); else { int i; uint8_t *srcPtr= src[plane]; uint8_t *dstPtr= dst[plane] + dstStride[plane]*y; for(i=0; i<height; i++) { memcpy(dstPtr, srcPtr, length); srcPtr+= srcStride[plane]; dstPtr+= dstStride[plane]; } } } } }
1threat
window.location.href = 'http://attack.com?user=' + user_input;
1threat
c++ : invoking tcl proc from c++ in multithreaded mode : I am working in c++. My function func() is being called by multiple threads. ( each thread will call this function only once) From inside the func(), I want each thread to call a TCL proc named tcl_proc_name ( which takes no arguments ) For this, I did like this Tcl_Eval( Tcl_CreateInterp() , “tcl_proc_name”); But it somehow this code is not able to invoke the tcl proc. Is I’am missing something. Please help. Regards
0debug
static void rv40_loop_filter(RV34DecContext *r, int row) { MpegEncContext *s = &r->s; int mb_pos, mb_x; int i, j, k; uint8_t *Y, *C; int alpha, beta, betaY, betaC; int q; int mbtype[4]; int mb_strong[4]; int clip[4]; int cbp[4]; int uvcbp[4][2]; unsigned mvmasks[4]; mb_pos = row * s->mb_stride; for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){ int mbtype = s->current_picture_ptr->mb_type[mb_pos]; if(IS_INTRA(mbtype) || IS_SEPARATE_DC(mbtype)) r->cbp_luma [mb_pos] = r->deblock_coefs[mb_pos] = 0xFFFF; if(IS_INTRA(mbtype)) r->cbp_chroma[mb_pos] = 0xFF; } mb_pos = row * s->mb_stride; for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){ int y_h_deblock, y_v_deblock; int c_v_deblock[2], c_h_deblock[2]; int clip_left; int avail[4]; unsigned y_to_deblock; int c_to_deblock[2]; q = s->current_picture_ptr->qscale_table[mb_pos]; alpha = rv40_alpha_tab[q]; beta = rv40_beta_tab [q]; betaY = betaC = beta * 3; if(s->width * s->height <= 176*144) betaY += beta; avail[0] = 1; avail[1] = row; avail[2] = mb_x; avail[3] = row < s->mb_height - 1; for(i = 0; i < 4; i++){ if(avail[i]){ int pos = mb_pos + neighbour_offs_x[i] + neighbour_offs_y[i]*s->mb_stride; mvmasks[i] = r->deblock_coefs[pos]; mbtype [i] = s->current_picture_ptr->mb_type[pos]; cbp [i] = r->cbp_luma[pos]; uvcbp[i][0] = r->cbp_chroma[pos] & 0xF; uvcbp[i][1] = r->cbp_chroma[pos] >> 4; }else{ mvmasks[i] = 0; mbtype [i] = mbtype[0]; cbp [i] = 0; uvcbp[i][0] = uvcbp[i][1] = 0; } mb_strong[i] = IS_INTRA(mbtype[i]) || IS_SEPARATE_DC(mbtype[i]); clip[i] = rv40_filter_clip_tbl[mb_strong[i] + 1][q]; } y_to_deblock = mvmasks[POS_CUR] | (mvmasks[POS_BOTTOM] << 16); y_h_deblock = y_to_deblock | ((cbp[POS_CUR] << 4) & ~MASK_Y_TOP_ROW) | ((cbp[POS_TOP] & MASK_Y_LAST_ROW) >> 12); y_v_deblock = y_to_deblock | ((cbp[POS_CUR] << 1) & ~MASK_Y_LEFT_COL) | ((cbp[POS_LEFT] & MASK_Y_RIGHT_COL) >> 3); if(!mb_x) y_v_deblock &= ~MASK_Y_LEFT_COL; if(!row) y_h_deblock &= ~MASK_Y_TOP_ROW; if(row == s->mb_height - 1 || (mb_strong[POS_CUR] | mb_strong[POS_BOTTOM])) y_h_deblock &= ~(MASK_Y_TOP_ROW << 16); for(i = 0; i < 2; i++){ c_to_deblock[i] = (uvcbp[POS_BOTTOM][i] << 4) | uvcbp[POS_CUR][i]; c_v_deblock[i] = c_to_deblock[i] | ((uvcbp[POS_CUR] [i] << 1) & ~MASK_C_LEFT_COL) | ((uvcbp[POS_LEFT][i] & MASK_C_RIGHT_COL) >> 1); c_h_deblock[i] = c_to_deblock[i] | ((uvcbp[POS_TOP][i] & MASK_C_LAST_ROW) >> 2) | (uvcbp[POS_CUR][i] << 2); if(!mb_x) c_v_deblock[i] &= ~MASK_C_LEFT_COL; if(!row) c_h_deblock[i] &= ~MASK_C_TOP_ROW; if(row == s->mb_height - 1 || (mb_strong[POS_CUR] | mb_strong[POS_BOTTOM])) c_h_deblock[i] &= ~(MASK_C_TOP_ROW << 4); } for(j = 0; j < 16; j += 4){ Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize; for(i = 0; i < 4; i++, Y += 4){ int ij = i + j; int clip_cur = y_to_deblock & (MASK_CUR << ij) ? clip[POS_CUR] : 0; int dither = j ? ij : i*4; if(y_h_deblock & (MASK_BOTTOM << ij)){ rv40_adaptive_loop_filter(&r->rdsp, Y+4*s->linesize, s->linesize, dither, y_to_deblock & (MASK_BOTTOM << ij) ? clip[POS_CUR] : 0, clip_cur, alpha, beta, betaY, 0, 0, 0); } if(y_v_deblock & (MASK_CUR << ij) && (i || !(mb_strong[POS_CUR] | mb_strong[POS_LEFT]))){ if(!i) clip_left = mvmasks[POS_LEFT] & (MASK_RIGHT << j) ? clip[POS_LEFT] : 0; else clip_left = y_to_deblock & (MASK_CUR << (ij-1)) ? clip[POS_CUR] : 0; rv40_adaptive_loop_filter(&r->rdsp, Y, s->linesize, dither, clip_cur, clip_left, alpha, beta, betaY, 0, 0, 1); } if(!j && y_h_deblock & (MASK_CUR << i) && (mb_strong[POS_CUR] | mb_strong[POS_TOP])){ rv40_adaptive_loop_filter(&r->rdsp, Y, s->linesize, dither, clip_cur, mvmasks[POS_TOP] & (MASK_TOP << i) ? clip[POS_TOP] : 0, alpha, beta, betaY, 0, 1, 0); } if(y_v_deblock & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] | mb_strong[POS_LEFT])){ clip_left = mvmasks[POS_LEFT] & (MASK_RIGHT << j) ? clip[POS_LEFT] : 0; rv40_adaptive_loop_filter(&r->rdsp, Y, s->linesize, dither, clip_cur, clip_left, alpha, beta, betaY, 0, 1, 1); } } } for(k = 0; k < 2; k++){ for(j = 0; j < 2; j++){ C = s->current_picture_ptr->f.data[k + 1] + mb_x*8 + (row*8 + j*4) * s->uvlinesize; for(i = 0; i < 2; i++, C += 4){ int ij = i + j*2; int clip_cur = c_to_deblock[k] & (MASK_CUR << ij) ? clip[POS_CUR] : 0; if(c_h_deblock[k] & (MASK_CUR << (ij+2))){ int clip_bot = c_to_deblock[k] & (MASK_CUR << (ij+2)) ? clip[POS_CUR] : 0; rv40_adaptive_loop_filter(&r->rdsp, C+4*s->uvlinesize, s->uvlinesize, i*8, clip_bot, clip_cur, alpha, beta, betaC, 1, 0, 0); } if((c_v_deblock[k] & (MASK_CUR << ij)) && (i || !(mb_strong[POS_CUR] | mb_strong[POS_LEFT]))){ if(!i) clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0; else clip_left = c_to_deblock[k] & (MASK_CUR << (ij-1)) ? clip[POS_CUR] : 0; rv40_adaptive_loop_filter(&r->rdsp, C, s->uvlinesize, j*8, clip_cur, clip_left, alpha, beta, betaC, 1, 0, 1); } if(!j && c_h_deblock[k] & (MASK_CUR << ij) && (mb_strong[POS_CUR] | mb_strong[POS_TOP])){ int clip_top = uvcbp[POS_TOP][k] & (MASK_CUR << (ij+2)) ? clip[POS_TOP] : 0; rv40_adaptive_loop_filter(&r->rdsp, C, s->uvlinesize, i*8, clip_cur, clip_top, alpha, beta, betaC, 1, 1, 0); } if(c_v_deblock[k] & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] | mb_strong[POS_LEFT])){ clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0; rv40_adaptive_loop_filter(&r->rdsp, C, s->uvlinesize, j*8, clip_cur, clip_left, alpha, beta, betaC, 1, 1, 1); } } } } } }
1threat
void xen_pt_msi_disable(XenPCIPassthroughState *s) { XenPTMSI *msi = s->msi; if (!msi) { return; } xen_pt_msi_set_enable(s, false); msi_msix_disable(s, msi_addr64(msi), msi->data, msi->pirq, false, msi->initialized); msi->flags = 0; msi->mapped = false; msi->pirq = XEN_PT_UNASSIGNED_PIRQ; }
1threat
Why there are two buttons in GUI Configure and Generate when CLI does all in one command : <p>I understand that cmake is build generator. It mean that it can generate appropriate builds (makefiles, Visual Studio project etc.) based on instructions from CMakeLists.txt. But I do not understand two things which I guess are related:</p> <ol> <li><p>Why there are two buttons "Configure" and "Generate" in cmake-gui? In command line tutorials that I've read (e.g. <a href="http://derekmolloy.ie/hello-world-introductions-to-cmake/" rel="noreferrer">this one</a>) usual process was done with one <code>cmake</code> command.</p></li> <li><p>What is cache in cmake world? AFAIK it is state when "Configure" button was pressed but "Generate" button was not pressed. But why is this useful? What all those variables that pops-up after pressing "Configure" mean? Why I'm supposed to edit them? Isn't the only allowed configuration done via CMakeLists.txt?</p></li> </ol> <p>Thanks</p>
0debug
Why is regex search slower with capturing groups in Python? : <p>I have an application code which generates regexes dynamically from a config for some parsing. When timing performance of two variations, the regex variation with each part of an OR regex being captured is noticably slow than a normal regex. The reason would be overhead of certain operations internally in regex module.</p> <pre><code>&gt;&gt;&gt; import timeit &gt;&gt;&gt; setup = ''' ... import re ... ''' #no capture group &gt;&gt;&gt; print(timeit.timeit("re.search(r'hello|bye|ola|cheers','some say hello,some say bye, or ola or cheers!')", setup=setup)) 0.922958850861 #with capture group &gt;&gt;&gt; print(timeit.timeit("re.search(r'(hello)|(bye)|(ola)|(cheers)','some say hello,some say bye, or ola or cheers!')", setup=setup)) 1.44321084023 #no capture group &gt;&gt;&gt; print(timeit.timeit("re.search(r'hello|bye|ola|cheers','some say hello,some say bye, or ola or cheers!')", setup=setup)) 0.913202047348 # capture group &gt;&gt;&gt; print(timeit.timeit("re.search(r'(hello)|(bye)|(ola)|(cheers)','some say hello,some say bye, or ola or cheers!')", setup=setup)) 1.41544604301 </code></pre> <p><strong>Question:</strong> What causes this considerable drop in performance when using capture groups ? </p>
0debug
how do i display the output from for loop as a table in php : my output is in the form of a 2d array. i have uploaded a sample file and the output is displayed like a paragraph. i want it to be displayed as a table. code: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <?php require("reader.php"); // php excel reader $file="sample.xls"; $connection=new Spreadsheet_Excel_Reader(); // our main object $connection->read($file); $startrow=1; $endrow=1000; for($i=$startrow;$i<$endrow;$i++){ // we read row to row for($j=1;$j<=30;$j++) { echo $connection->sheets[0]["cells"][$i][$j]; // so we get [2][3] and [3][3] echo "\n"; } echo "\n"; } ?> <!-- end snippet -->
0debug
How to Pass checked and unchecked Checkbox value to another Activity in Android..? : This is my working code for passing checked and unchecked Checkbox value to Another Activity..i hope it will be helpful for you g`enter code here`
0debug
CompletableFuture in the Android Support Library? : <p>So I was migrating an Android Studio project to Java 8, Android API level 24 and the Jack toolchain today to check out the new features, especially lambdas and <code>CompletableFuture</code>. </p> <p>Unfortunately, <code>CompletableFuture</code> seems to be available only from API level 24 on (my minimum API level for that project being 16). </p> <p>Do you know of any plans on bringing <code>CompletableFuture</code> to the Android support library? It looks like a nice solution for the Promises pattern.</p>
0debug
Excel VBA row to column : I want to trim my excel data from single row to multiple row using vba, after trying many tricks from other source, still no luck, so i open topic here hope someone will help me with vba script My Input data (Column A1): [Input][1] I wish my output (Column C1 and D1) [Output][2] Someone help please [1]: https://i.stack.imgur.com/mTUgp.png [2]: https://i.stack.imgur.com/Pss2z.png
0debug
static int encode_picture_ls(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ JpeglsContext * const s = avctx->priv_data; AVFrame *pict = data; AVFrame * const p= (AVFrame*)&s->picture; const int near = avctx->prediction_method; PutBitContext pb, pb2; GetBitContext gb; uint8_t *buf2, *zero, *cur, *last; JLSState *state; int i, size; int comps; buf2 = av_malloc(buf_size); init_put_bits(&pb, buf, buf_size); init_put_bits(&pb2, buf2, buf_size); *p = *pict; p->pict_type= FF_I_TYPE; p->key_frame= 1; if(avctx->pix_fmt == PIX_FMT_GRAY8 || avctx->pix_fmt == PIX_FMT_GRAY16) comps = 1; else comps = 3; put_marker(&pb, SOI); put_marker(&pb, SOF48); put_bits(&pb, 16, 8 + comps * 3); put_bits(&pb, 8, (avctx->pix_fmt == PIX_FMT_GRAY16) ? 16 : 8); put_bits(&pb, 16, avctx->height); put_bits(&pb, 16, avctx->width); put_bits(&pb, 8, comps); for(i = 1; i <= comps; i++) { put_bits(&pb, 8, i); put_bits(&pb, 8, 0x11); put_bits(&pb, 8, 0); } put_marker(&pb, SOS); put_bits(&pb, 16, 6 + comps * 2); put_bits(&pb, 8, comps); for(i = 1; i <= comps; i++) { put_bits(&pb, 8, i); put_bits(&pb, 8, 0); } put_bits(&pb, 8, near); put_bits(&pb, 8, (comps > 1) ? 1 : 0); put_bits(&pb, 8, 0); state = av_mallocz(sizeof(JLSState)); state->near = near; state->bpp = (avctx->pix_fmt == PIX_FMT_GRAY16) ? 16 : 8; reset_ls_coding_parameters(state, 0); ls_init_state(state); ls_store_lse(state, &pb); zero = av_mallocz(p->linesize[0]); last = zero; cur = p->data[0]; if(avctx->pix_fmt == PIX_FMT_GRAY8){ int t = 0; for(i = 0; i < avctx->height; i++) { ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 8); t = last[0]; last = cur; cur += p->linesize[0]; } }else if(avctx->pix_fmt == PIX_FMT_GRAY16){ int t = 0; for(i = 0; i < avctx->height; i++) { ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 16); t = *((uint16_t*)last); last = cur; cur += p->linesize[0]; } }else if(avctx->pix_fmt == PIX_FMT_RGB24){ int j, width; int Rc[3] = {0, 0, 0}; width = avctx->width * 3; for(i = 0; i < avctx->height; i++) { for(j = 0; j < 3; j++) { ls_encode_line(state, &pb2, last + j, cur + j, Rc[j], width, 3, j, 8); Rc[j] = last[j]; } last = cur; cur += s->picture.linesize[0]; } }else if(avctx->pix_fmt == PIX_FMT_BGR24){ int j, width; int Rc[3] = {0, 0, 0}; width = avctx->width * 3; for(i = 0; i < avctx->height; i++) { for(j = 2; j >= 0; j--) { ls_encode_line(state, &pb2, last + j, cur + j, Rc[j], width, 3, j, 8); Rc[j] = last[j]; } last = cur; cur += s->picture.linesize[0]; } } av_free(zero); av_free(state); flush_put_bits(&pb2); size = put_bits_count(&pb2) >> 3; init_get_bits(&gb, buf2, size); while(get_bits_count(&gb) < size * 8){ int v; v = get_bits(&gb, 8); put_bits(&pb, 8, v); if(v == 0xFF){ v = get_bits(&gb, 7); put_bits(&pb, 8, v); } } align_put_bits(&pb); av_free(buf2); put_marker(&pb, EOI); flush_put_bits(&pb); emms_c(); return put_bits_count(&pb) >> 3; }
1threat
What is the reached end of file while parsing error, and how can I avoid this error in the future? : My question is very simple. I am just wondering what the reached end of file while parsing error actually means / is. Why this error actually occurs. In addition, how I could avoid it. Before you say that this is a duplication of question it really isn't because most questions I looked at are just examples with code. That is not what I am looking for I am just looking for a clear cut answer of why this error happens what it is / means, and how to avoid it that is it. NOTE: Thank you very much, all help is appreciated! If you are thinking about downvoting because of the quality of the question, please ask the question or suggest how I could make this question better before going and downvoting the question. Thank you so much, I hope you have a very great evening. Hopefully, you can answer this question quickly and very efficiently!
0debug
Python pass by value : <p>I'm a beginner for Python. I want to know some cases to pass by values instead of references. Assume we have the class:</p> <pre><code>class myC(): def __init__(self, x): self.val = x </code></pre> <p>and the functions:</p> <pre><code>def myF1(myc): myc.val = 1 def myF2(myDict): myDict['a'] = 0 </code></pre> <p>if we define the variable and call the function:</p> <pre><code>a = myC(0) myDict = {} myF1(a) myF2(myDict) </code></pre> <p>The value of the variable a and myDict will change since both user defined class and dictionary are mutable types. Is there ant method that just pass the value of the variable so that the variable itself won't change? If there are multiple ways, please let me know all of them. Thank you very much.</p>
0debug
static void uart_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { LM32UartState *s = opaque; unsigned char ch = value; trace_lm32_uart_memory_write(addr, value); addr >>= 2; switch (addr) { case R_RXTX: if (s->chr) { qemu_chr_fe_write(s->chr, &ch, 1); } break; case R_IER: case R_LCR: case R_MCR: case R_DIV: s->regs[addr] = value; break; case R_IIR: case R_LSR: case R_MSR: error_report("lm32_uart: write access to read only register 0x" TARGET_FMT_plx, addr << 2); break; default: error_report("lm32_uart: write access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } uart_update_irq(s); }
1threat
GCC 7, -Wimplicit-fallthrough warnings, and portable way to clear them? : <p>We are catching warnings from GCC 7 for implicit fall through in a switch statement. Previously, we cleared them under Clang (that's the reason for the comment seen below):</p> <pre><code>g++ -DNDEBUG -g2 -O3 -std=c++17 -Wall -Wextra -fPIC -c authenc.cpp asn.cpp: In member function ‘void EncodedObjectFilter::Put(const byte*, size_t)’: asn.cpp:359:18: warning: this statement may fall through [-Wimplicit-fallthrough=] m_state = BODY; // fall through ^ asn.cpp:361:3: note: here case BODY: ^~~~ </code></pre> <p>The <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html" rel="noreferrer">GCC manual</a> states to use <code>__attribute__ ((fallthrough))</code>, but its not portable. The manual also states <em>"... it is also possible to add a fallthrough comment to silence the warning"</em>, but it only offer <code>FALLTHRU</code> (is this really the only choice?):</p> <pre><code>switch (cond) { case 1: bar (0); /* FALLTHRU */ default: … } </code></pre> <p>Is there a portable way to clear the fall through warning for both Clang and GCC? If so, then what is it?</p>
0debug
i wrote this code it all works until it comes to setting the color i dont know what is wrong pleaseee : from swampy.TurtleWorld import * import random world = TurtleWorld() Turtle_1 = Turtle() print('*****Welcome to Sehir Minesweeper*****') print('-----First Turtle-----') Turtle_1 = input('Please type the name of the first Turtle:') print('Turtle 1 is' +' ' + Turtle_1) T1_color = input('Please choose turtle color for' + ' ' + Turtle_1 +' '+'(red, blue or green):') Turtle_1.color(T1_color)
0debug
how to remove lines in OpenCV : I want to remove lines and keypoints. I just want to remain a green rectangular. Is there a function except for drawMatches or can I make lines and keypoints invisible in drawMatches? Mat img_matches; drawMatches( img_object, keypoints_object, img_scene, keypoints_scene, good_matches, img_matches, Scalar::all(-1), Scalar::all(-1), std::vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS ); [![A picture][1]][1] [1]: https://i.stack.imgur.com/srZni.jpg
0debug
how to get innerHTML value in java code : I want to change table <td> data by using innerHTML property. But after applying innerHTML property those values set in <TD> but not accessible in java code So is there any alternative to innerHTML property so that value can be set inv<td> and it can also be accessed in Java Code. in java script i am using following code. <script> var row=0,col=0,i=1;//can be used in loop document.getElementById("tableID").rows[row].cells[col].innerHTML=i; </script> not able to access the value in java
0debug
how to shortcut a coroutine in unity C#? : I write a coroutine to do a batch work every frame, I have no problem to start it, but, I want to short-cut the execution when specific condition meets. Such as : public IEnumerator workCoroutine(){ int i = 0; if(GLOBAL_LOCK){ return; //will not work here. //we will not execute this coroutine further more, ie,shortcut it; //but how to ? } while( i<=1000){ doingSomeWorkHere(i); i++; yield return null; } } I know maybe I could do this by: public IEnumerator workCoroutine(){ int i = 0; if(!GLOBAL_LOCK){ while( i<=1000){ doingSomeWorkHere(i); i++; yield return null; } } } But I think this way may cause the code to be ugly when there are multi conditions. So is there a way to shortcut the coroutine?
0debug
const char *bdrv_get_node_name(const BlockDriverState *bs) { return bs->node_name; }
1threat
static void vga_update_text(void *opaque, console_ch_t *chardata) { VGACommonState *s = opaque; int graphic_mode, i, cursor_offset, cursor_visible; int cw, cheight, width, height, size, c_min, c_max; uint32_t *src; console_ch_t *dst, val; char msg_buffer[80]; int full_update = 0; if (!(s->ar_index & 0x20)) { graphic_mode = GMODE_BLANK; } else { graphic_mode = s->gr[6] & 1; } if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; full_update = 1; } if (s->last_width == -1) { s->last_width = 0; full_update = 1; } switch (graphic_mode) { case GMODE_TEXT: full_update |= update_basic_params(s); cheight = (s->cr[9] & 0x1f) + 1; cw = 8; if (!(s->sr[1] & 0x01)) cw = 9; if (s->sr[1] & 0x08) cw = 16; width = (s->cr[0x01] + 1); if (s->cr[0x06] == 100) { height = 100; } else { height = s->cr[0x12] | ((s->cr[0x07] & 0x02) << 7) | ((s->cr[0x07] & 0x40) << 3); height = (height + 1) / cheight; } size = (height * width); if (size > CH_ATTR_SIZE) { if (!full_update) return; snprintf(msg_buffer, sizeof(msg_buffer), "%i x %i Text mode", width, height); break; } if (width != s->last_width || height != s->last_height || cw != s->last_cw || cheight != s->last_ch) { s->last_scr_width = width * cw; s->last_scr_height = height * cheight; s->ds->surface->width = width; s->ds->surface->height = height; dpy_resize(s->ds); s->last_width = width; s->last_height = height; s->last_ch = cheight; s->last_cw = cw; full_update = 1; } cursor_offset = ((s->cr[0x0e] << 8) | s->cr[0x0f]) - s->start_addr; if (cursor_offset != s->cursor_offset || s->cr[0xa] != s->cursor_start || s->cr[0xb] != s->cursor_end || full_update) { cursor_visible = !(s->cr[0xa] & 0x20); if (cursor_visible && cursor_offset < size && cursor_offset >= 0) dpy_cursor(s->ds, TEXTMODE_X(cursor_offset), TEXTMODE_Y(cursor_offset)); else dpy_cursor(s->ds, -1, -1); s->cursor_offset = cursor_offset; s->cursor_start = s->cr[0xa]; s->cursor_end = s->cr[0xb]; } src = (uint32_t *) s->vram_ptr + s->start_addr; dst = chardata; if (full_update) { for (i = 0; i < size; src ++, dst ++, i ++) console_write_ch(dst, VMEM2CHTYPE(le32_to_cpu(*src))); dpy_update(s->ds, 0, 0, width, height); } else { c_max = 0; for (i = 0; i < size; src ++, dst ++, i ++) { console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src))); if (*dst != val) { *dst = val; c_max = i; break; } } c_min = i; for (; i < size; src ++, dst ++, i ++) { console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src))); if (*dst != val) { *dst = val; c_max = i; } } if (c_min <= c_max) { i = TEXTMODE_Y(c_min); dpy_update(s->ds, 0, i, width, TEXTMODE_Y(c_max) - i + 1); } } return; case GMODE_GRAPH: if (!full_update) return; s->get_resolution(s, &width, &height); snprintf(msg_buffer, sizeof(msg_buffer), "%i x %i Graphic mode", width, height); break; case GMODE_BLANK: default: if (!full_update) return; snprintf(msg_buffer, sizeof(msg_buffer), "VGA Blank mode"); break; } s->last_width = 60; s->last_height = height = 3; dpy_cursor(s->ds, -1, -1); s->ds->surface->width = s->last_width; s->ds->surface->height = height; dpy_resize(s->ds); for (dst = chardata, i = 0; i < s->last_width * height; i ++) console_write_ch(dst ++, ' '); size = strlen(msg_buffer); width = (s->last_width - size) / 2; dst = chardata + s->last_width + width; for (i = 0; i < size; i ++) console_write_ch(dst ++, 0x00200100 | msg_buffer[i]); dpy_update(s->ds, 0, 0, s->last_width, height); }
1threat
Compare a tuple : I want to compare 2 tuple `T1` and `T2`, which are both three-element-tuple, by firstly comparing `T[0]`, if `T1[0]==T2[0]`, then compare `T1[1]` and `T2[1]`, if `T1[1]==T2[1]` then compare `T1[2]` and T2[2].
0debug
Delphi Tokyo exception prevents setting function result : <p>Found that exception handling in Delphi Tokyo behaves a little different than in previous Delphi versions.</p> <pre><code>function FuncTest: integer; begin Result := 1; try raise Exception.Create('Error Message'); finally Result := 2; end; end; function Test:integer; begin Result:=0; try Result:=FuncTest; finally ShowMessage(Result.ToString); end; end; </code></pre> <p>In earlier Delphi versions the message box shows here "2", Tokyo - "0". Is this a Tokyo bug or the exceptions should not be handled like this?</p>
0debug
How does the global variable behave inside function(Python) : <p>Case 1</p> <pre><code>A = '213' def wow(): print(A) wow() Output: '213' </code></pre> <p>Case 2</p> <pre><code>A = '213' def wow(): print(A) A = 12 wow() Output: UnboundLocalError: local variable 'A' referenced before assignment </code></pre> <p>I'd thought that the output in the case 2 would be identical to the case 1, since A is a global variable and I called "print(A)" <em>before</em> reassigning value to A within the function. So my question is, why in the case 1 calling A is perfectly fine, but case 2 throws error?</p>
0debug
Are all final variables captured by anonymous classes? : <p>I thought I knew the answer to this, but I can't find any confirmation after an hour or so of searching.</p> <p>In this code:</p> <pre><code>public class Outer { // other code private void method1() { final SomeObject obj1 = new SomeObject(...); final SomeObject obj2 = new SomeObject(...); someManager.registerCallback(new SomeCallbackClass() { @Override public void onEvent() { System.out.println(obj1.getName()); } }); } } </code></pre> <p>Assume that <code>registerCallback</code> saves its parameter somewhere, so that the object of the anonymous subclass will live for a while. Obviously this object has to maintain a reference to <code>obj1</code> so that <code>onEvent</code> will work if it is called.</p> <p>But given that the object doesn't use <code>obj2</code>, does it still maintain a reference to <code>obj2</code>, so that <code>obj2</code> can't be garbage-collected while the object lives? I was under the impression that <em>all</em> visible <code>final</code> (or effectively final) local variables and parameters were captured and thus couldn't be GC'ed as long as the object was alive, but I can't find anything that says one way or the other.</p> <p>Is it implementation-dependent?</p> <p>Is there a section in the JLS that answers this? I wasn't able to find the answer there.</p>
0debug
static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s) { Jpeg2000CodingStyle *codsty = s->codsty; Jpeg2000QuantStyle *qntsty = s->qntsty; uint8_t *properties = s->properties; for (;;) { int len, ret = 0; uint16_t marker; int oldpos; if (bytestream2_get_bytes_left(&s->g) < 2) { av_log(s->avctx, AV_LOG_ERROR, "Missing EOC\n"); break; } marker = bytestream2_get_be16u(&s->g); oldpos = bytestream2_tell(&s->g); if (marker == JPEG2000_EOC) break; if (bytestream2_get_bytes_left(&s->g) < 2) return AVERROR_INVALIDDATA; len = bytestream2_get_be16u(&s->g); switch (marker) { case JPEG2000_SIZ: ret = get_siz(s); break; case JPEG2000_COC: ret = get_coc(s, codsty, properties); break; case JPEG2000_COD: ret = get_cod(s, codsty, properties); break; case JPEG2000_QCC: ret = get_qcc(s, len, qntsty, properties); break; case JPEG2000_QCD: ret = get_qcd(s, len, qntsty, properties); break; case JPEG2000_SOT: ret = get_sot(s, len); break; case JPEG2000_COM: bytestream2_skip(&s->g, len - 2); break; case JPEG2000_TLM: ret = get_tlm(s, len); break; default: av_log(s->avctx, AV_LOG_ERROR, "unsupported marker 0x%.4X at pos 0x%X\n", marker, bytestream2_tell(&s->g) - 4); bytestream2_skip(&s->g, len - 2); break; } if (((bytestream2_tell(&s->g) - oldpos != len) && (marker != JPEG2000_SOT)) || ret) { av_log(s->avctx, AV_LOG_ERROR, "error during processing marker segment %.4x\n", marker); return ret ? ret : -1; } } return 0; }
1threat
AutoMapper Migrating from static API : <p><a href="https://github.com/AutoMapper/AutoMapper/wiki/Migrating-from-static-API" rel="noreferrer">https://github.com/AutoMapper/AutoMapper/wiki/Migrating-from-static-API</a></p> <p>this change breaks my system.</p> <p>Before update, I use:</p> <p>===> Startup.cs</p> <pre><code>public class Startup { public Startup(IHostingEnvironment env) { ... MyAutoMapperConfiguration.Configure(); } } </code></pre> <p>===> MyAutoMapperConfiguration.cs</p> <pre><code>public class MyAutoMapperConfiguration { public static void Configure() { Mapper.Initialize(a =&gt; { a.AddProfile&lt;AbcMappingProfile&gt;(); a.AddProfile&lt;XyzMappingProfile&gt;(); a.AddProfile&lt;QweMappingProfile&gt;(); }); } } </code></pre> <p>===> AbcMappingProfile.cs</p> <pre><code>public class AbcMappingProfile : Profile { protected override void Configure() { Mapper.CreateMap&lt;AbcEditViewModel, Abc&gt;(); Mapper.CreateMap&lt;Abc, AbcEditViewModel&gt;(); ... } } </code></pre> <p>ERROR:</p> <p>'Mapper.CreateMap()' is obsolete: 'The static API will be removed in version 5.0. Use a MapperConfiguration instance and store statically as needed. Use CreateMapper to create a mapper instanace.'</p> <p>I can use Mapper.Map. Now How can I use it</p>
0debug
Slow len function on dask distributed dataframe : <p>I have been testing how to use dask (cluster with 20 cores) and I am surprised by the speed that I get on calling a len function vs slicing through loc.</p> <pre><code>import dask.dataframe as dd from dask.distributed import Client client = Client('192.168.1.220:8786') log = pd.read_csv('800000test', sep='\t') logd = dd.from_pandas(log,npartitions=20) #This is the code than runs slowly #(2.9 seconds whilst I would expect no more than a few hundred millisencods) print(len(logd)) #Instead this code is actually running almost 20 times faster than pandas logd.loc[:'Host'].count().compute() </code></pre> <p>Any ideas why this could be happening? It isn't important for me that len runs fast, but I feel that by not understanding this behaviour there is something I am not grasping about the library.</p> <p><a href="https://i.stack.imgur.com/CBYgO.png"><img src="https://i.stack.imgur.com/CBYgO.png" alt="enter image description here"></a></p> <p>All of the green boxes correspond to "from_pandas" whilst in this article by Matthew Rocklin <a href="http://matthewrocklin.com/blog/work/2017/01/12/dask-dataframes">http://matthewrocklin.com/blog/work/2017/01/12/dask-dataframes</a> the call graph looks better (len_chunk is called which is significantly faster and the calls don't seem to be locked by and wait for one worker to finish his task before starting the other)</p> <p><a href="https://i.stack.imgur.com/HBrBV.png"><img src="https://i.stack.imgur.com/HBrBV.png" alt="enter image description here"></a></p>
0debug
How to count for each row using other table in SQL? : <p>I have two tables: book table and author table. I need to count for each author how many book is registered in book table. How to do that?</p>
0debug
Azure Function: Publish fails with message "Web Deploy cannot modify the file on the Destination because it is locked by an external process." : <p>I am developing an Azure Functions Project and when I publish first time, OK. Then I publish again, this Error appears:</p> <blockquote> <p>Web Deploy cannot modify the file 'FunctionApp5.dll' on the destination because it is locked by an external process. In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt. Learn more at: <a href="http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE" rel="noreferrer">http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE</a>.</p> </blockquote> <p>It only Publishes if I enter Azure portal, and Restart this Azure Function App</p> <p><a href="https://i.stack.imgur.com/D8OBX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/D8OBX.png" alt="Azure Portal and Visual Studio 2017"></a></p>
0debug
static int xvid_strip_vol_header(AVCodecContext *avctx, AVPacket *pkt, unsigned int header_len, unsigned int frame_len) { int vo_len = 0, i; for (i = 0; i < header_len - 3; i++) { if (pkt->data[i] == 0x00 && pkt->data[i + 1] == 0x00 && pkt->data[i + 2] == 0x01 && pkt->data[i + 3] == 0xB6) { vo_len = i; break; } } if (vo_len > 0) { if (!avctx->extradata) { avctx->extradata = av_malloc(vo_len); memcpy(avctx->extradata, pkt->data, vo_len); avctx->extradata_size = vo_len; } memmove(pkt->data, &pkt->data[vo_len], frame_len - vo_len); pkt->size = frame_len - vo_len; } return 0; }
1threat
void qvirtio_pci_device_disable(QVirtioPCIDevice *d) { qpci_iounmap(d->pdev, d->addr); d->addr = NULL; }
1threat
ff_rm_retrieve_cache (AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *ast, AVPacket *pkt) { RMDemuxContext *rm = s->priv_data; assert (rm->audio_pkt_cnt > 0); if (ast->deint_id == DEINT_ID_VBRF || ast->deint_id == DEINT_ID_VBRS) av_get_packet(pb, pkt, ast->sub_packet_lengths[ast->sub_packet_cnt - rm->audio_pkt_cnt]); else { av_new_packet(pkt, st->codec->block_align); memcpy(pkt->data, ast->pkt.data + st->codec->block_align * (ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt), st->codec->block_align); } rm->audio_pkt_cnt--; if ((pkt->pts = ast->audiotimestamp) != AV_NOPTS_VALUE) { ast->audiotimestamp = AV_NOPTS_VALUE; pkt->flags = AV_PKT_FLAG_KEY; } else pkt->flags = 0; pkt->stream_index = st->index; return rm->audio_pkt_cnt; }
1threat
Simple Temperature Converter : <p>Can someone tell me what's wrong with this program? </p> <p>-------- cut here -----------</p> <pre><code>import sys def temp_converter_2(degree): print("Do you want to convert to Celsius or Fahrenheit? Enter C or F") answer = str(sys.stdin.readline()) if answer == "C": converted_value = (degree - 32) * 5/9 elif answer == "F": converted_value = (degree * 9/5) + 32 else: print("That's not C or F") converted_value = -99; print(converted_value) def __main__(): print("Enter temp to convert:") temp = int(sys.stdin.readline()) temp_converter_2(temp) </code></pre> <p>------- cut here --------</p> <p>When I run it, I get nothing. I am hoping that it will ask me for input. What am I missing?</p> <p>MacBook-Pro-(9):stuff$ python temp_converter_2.py MacBook-Pro-(9):stuff$ </p>
0debug
static void address_space_update_ioeventfds(AddressSpace *as) { FlatRange *fr; unsigned ioeventfd_nb = 0; MemoryRegionIoeventfd *ioeventfds = NULL; AddrRange tmp; unsigned i; FOR_EACH_FLAT_RANGE(fr, &as->current_map) { for (i = 0; i < fr->mr->ioeventfd_nb; ++i) { tmp = addrrange_shift(fr->mr->ioeventfds[i].addr, int128_sub(fr->addr.start, int128_make64(fr->offset_in_region))); if (addrrange_intersects(fr->addr, tmp)) { ++ioeventfd_nb; ioeventfds = g_realloc(ioeventfds, ioeventfd_nb * sizeof(*ioeventfds)); ioeventfds[ioeventfd_nb-1] = fr->mr->ioeventfds[i]; ioeventfds[ioeventfd_nb-1].addr = tmp; } } } address_space_add_del_ioeventfds(as, ioeventfds, ioeventfd_nb, as->ioeventfds, as->ioeventfd_nb); g_free(as->ioeventfds); as->ioeventfds = ioeventfds; as->ioeventfd_nb = ioeventfd_nb; }
1threat
Tail command without permission in Linux : <p>When I try to use 'tail' command in a cloud server, I'm get a permission denied error:</p> <pre><code>$ ssh myUser@server :~$ tail /var/log/syslog tail: cannot open ‘/var/log/syslog’ for reading: Permission denied </code></pre> <p>How to get permission in tail command?</p>
0debug
static void test_visitor_in_fail_list_nested(TestInputVisitorData *data, const void *unused) { int64_t i64 = -1; Visitor *v; v = visitor_input_test_init(data, "[ 0, [ 1, 2, 3 ] ]"); visit_start_list(v, NULL, NULL, 0, &error_abort); visit_type_int(v, NULL, &i64, &error_abort); g_assert_cmpint(i64, ==, 0); visit_start_list(v, NULL, NULL, 0, &error_abort); visit_type_int(v, NULL, &i64, &error_abort); g_assert_cmpint(i64, ==, 1); visit_end_list(v, NULL); visit_end_list(v, NULL); }
1threat
static int setup_sigcontext(struct target_sigcontext *sc, CPUAlphaState *env, abi_ulong frame_addr, target_sigset_t *set) { int i, err = 0; __put_user(on_sig_stack(frame_addr), &sc->sc_onstack); __put_user(set->sig[0], &sc->sc_mask); __put_user(env->pc, &sc->sc_pc); __put_user(8, &sc->sc_ps); for (i = 0; i < 31; ++i) { __put_user(env->ir[i], &sc->sc_regs[i]); } __put_user(0, &sc->sc_regs[31]); for (i = 0; i < 31; ++i) { __put_user(env->fir[i], &sc->sc_fpregs[i]); } __put_user(0, &sc->sc_fpregs[31]); __put_user(cpu_alpha_load_fpcr(env), &sc->sc_fpcr); __put_user(0, &sc->sc_traparg_a0); __put_user(0, &sc->sc_traparg_a1); __put_user(0, &sc->sc_traparg_a2); return err; }
1threat
Do we need backend framework if user React or Angular : <p>So question is do we need backend framework e.g. Laverel etc. if we user Angular\React? Don't undestend why we need cuz i use baclend only for REST API, I can not understand why they can be useful if we do all job on froendend</p>
0debug
Can't make this work : <p>How can i change variable value?, i tried using "Promises" but it doesn't work it gaves me an error, i'm trying to load a data on a table</p> <pre><code> /* Formating function for row details */ function fnFormatDetails(oTable, nTr) { var aData = oTable.fnGetData(nTr); var sOut =''; $.post("http://localhost:3000/almuerzo/findIng", { nombre: aData[1]}, function(data, status){ sOut = '&lt;ul&gt;'; sOut += data.nombre; sOut += '&lt;/ul&gt;'; }); return sOut; } </code></pre> <p>As i said when i try to use promises de "datable.tabletools plugin" fails, said that there's an error on "show"</p>
0debug
Go (golang) access data inside memory location array : Im trying to parse the following type array in geth to "look inside" and get the info but cant figure out how to do it ``` txs []*types.Transaction ``` this type is declared elsewhere in geth as ``` type Transaction struct { data txdata hash atomic.Value size atomic.Value from atomic.Value } ``` and Im trying to access the data using the following loop but I cant seem to access any of these values. for _, tx := range *txs { fmt.Println(fmt.Sprintf("transactions in this block - hash: %s and data: ", tx.hash)) } can anyone point me in the righ tdirection as to how i can access the data in memory locations that is an array
0debug
Counting the number of elements associated with another value in R : <p>For example, In a dataset, I have three groups as 1,2,3 and each group can either assign to 0 or 1. What is the code in R that allows me to count how many 0 assigned to group 1?</p>
0debug
PCIBus *pci_register_bus(DeviceState *parent, const char *name, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, qemu_irq *pic, int devfn_min, int nirq) { PCIBus *bus; static int nbus = 0; bus = FROM_QBUS(PCIBus, qbus_create(&pci_bus_info, parent, name)); bus->set_irq = set_irq; bus->map_irq = map_irq; bus->irq_opaque = pic; bus->devfn_min = devfn_min; bus->nirq = nirq; bus->irq_count = qemu_malloc(nirq * sizeof(bus->irq_count[0])); bus->next = first_bus; first_bus = bus; register_savevm("PCIBUS", nbus++, 1, pcibus_save, pcibus_load, bus); qemu_register_reset(pci_bus_reset, bus); return bus; }
1threat
static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, ram_addr_t current_addr, RAMBlock *block, ram_addr_t offset, int cont, bool last_stage) { int encoded_len = 0, bytes_sent = -1; uint8_t *prev_cached_page; if (!cache_is_cached(XBZRLE.cache, current_addr)) { if (!last_stage) { if (cache_insert(XBZRLE.cache, current_addr, current_data) == -1) { return -1; } } acct_info.xbzrle_cache_miss++; return -1; } prev_cached_page = get_cached_data(XBZRLE.cache, current_addr); memcpy(XBZRLE.current_buf, current_data, TARGET_PAGE_SIZE); encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE, XBZRLE.encoded_buf, TARGET_PAGE_SIZE); if (encoded_len == 0) { DPRINTF("Skipping unmodified page\n"); return 0; } else if (encoded_len == -1) { DPRINTF("Overflow\n"); acct_info.xbzrle_overflows++; memcpy(prev_cached_page, current_data, TARGET_PAGE_SIZE); return -1; } if (!last_stage) { memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE); } bytes_sent = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_XBZRLE); qemu_put_byte(f, ENCODING_FLAG_XBZRLE); qemu_put_be16(f, encoded_len); qemu_put_buffer(f, XBZRLE.encoded_buf, encoded_len); bytes_sent += encoded_len + 1 + 2; acct_info.xbzrle_pages++; acct_info.xbzrle_bytes += bytes_sent; return bytes_sent; }
1threat
def floor_Min(A,B,N): x = max(B - 1,N) return (A*x) // B
0debug
How can I use all entities instead of listing them all individually (Symfony)? : In my Controller I list all entities I have: use App\Entity\Members; use App\Entity\Products; use App\Entity\Projects; But because new Entities will automatically be created, I need instead something like use AllEntities; Is this possible?
0debug
Is function declaration in Golang strict? : Why does this code work? The fuction `Introduce()` accept a pointer to `Person` but when we create `p` - it is an object (not a pointer). So is function declaration not strict? package main import "fmt" type Person struct { Name string } func (p *Person) Introduce() { fmt.Printf("Hi, I'm %s\n", p.Name) } func main() { p := Person{Name: "Fedya"} fmt.Println(p) p.Introduce() p1 := &Person{Name: "Fedya"} fmt.Println(p1) p1.Introduce() }
0debug
Unexpected error while using the len statement : <p>I am trying to solve one of the katas in codewars. The code gives an unexpected error while using len statement. Please can someone help with this.</p> <pre><code>def scramble(s1,s2): j1=[i for i in s2 if i in s1] j1=j1.sort() s1=[x for x in s1] s1=s1.sort() if len(s1)==len(j1): return True else: return False </code></pre>
0debug
wpf binding datagrid filled from MySQL : i have that code in my desktop application that fill the datagrid from mysql database var mA = new MySql.Data.MySqlClient.MySqlDataAdapter("SELECT * FROM items", DataHolder.MySqlConnection); var mT = new System.Data.DataTable(); mA.Fill(mT); dataGrid.ItemsSource = mT.DefaultView; but i can't figure out how to bind it to change certain cells in certain column to change it's background color when it's equl to certain values
0debug
Is there a PHP equivalent of JavaScript's Array.prototype.some() function : <p>In JavaScript, we can do:</p> <pre><code>function isBiggerThan10(element, index, array) { return element &gt; 10; } [2, 5, 8, 1, 4].some(isBiggerThan10); // false [12, 5, 8, 1, 4].some(isBiggerThan10); // true </code></pre> <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some" rel="noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some</a></p> <p>Is there a PHP equivalent of the some() function?</p>
0debug
Importance of original features after applying PCA : <p>Assume that I have 5 features A, B, C, D, E.</p> <p>I apply PCA to my data to reduce the dimensionality to 3. It means now I have 3 principal components where each PC is a new variable. Now I want to know which feature among A, B, C, D, E is most important, which is the 2nd most important feature and so on and by how much (such as in terms of score).</p> <p>I know that the first PC has the highest variance(importance), followed by 2nd, followed by 3rd and so on but I want the importance among original features A, B, C, D, E. Is there any method to find it?</p>
0debug
Self-signed SSL certificates not working with MAMP and Chrome : <p>SSL certificates created by MAMP are not working in Chrome. I'm getting a "Not secure" issue.</p> <p>Is there a workaround for this?</p> <p><a href="https://i.stack.imgur.com/kvI1U.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kvI1U.png" alt="enter image description here"></a></p>
0debug
How to make ffmpeg available inside my Docker container? : <p>I'm currently trying to run a <code>ffmpeg</code> Docker image inside my own container with <code>docker-compose</code> using the <code>depends_on</code> clause. But when I try to reach <code>ffmpeg</code> inside my code, it seems like it's not available system-wide and I get an error. I believe I'm misconfiguring Docker.</p> <p>My current <code>Dockerfile</code> is as follows:</p> <pre><code>FROM node:9 WORKDIR /usr/app COPY package*.json ./ RUN npm install --quiet COPY . . </code></pre> <p>And my <code>docker-compose.yml</code>:</p> <pre><code>version: '3' services: app: build: . command: npm run dev volumes: - .:/usr/app/ - /usr/app/node_modules ports: - "3000:3000" depends_on: - ffmpeg ffmpeg: image: jrottenberg/ffmpeg:3.3 </code></pre> <p>When I run <code>docker-compose up</code> I can see that the <code>ffmpeg</code> is actually working, but then my application proceeds to start and it seems that <code>ffmpeg</code> ceases to work.</p>
0debug
static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) { AVFilterContext *ctx = inlink->dst; int i, ret = 0; for (i = 0; i < ctx->nb_outputs; i++) { ret = ff_filter_samples(inlink->dst->outputs[i], avfilter_ref_buffer(samplesref, ~AV_PERM_WRITE)); if (ret < 0) break; } avfilter_unref_buffer(samplesref); return ret; }
1threat
2 arrays of object between difference : <p>I want to get the difference between the first array and the second array. As a result;</p> <pre><code>var arr1 = [{name: "Yesügey", lastName: "Yeşil", phone: "+90 333 9695395"}, {name: "Firdest", lastName: "Firdevis", phone: "+90 333 4234638"}, {name: "Pehlivan", lastName: "Pehlül", phone: "+90 333 9114821"}, {name: "Urbeyi", lastName: "Usberk", phone: "+90 333 1617245"}, {name: "Kâmile", lastName: "Kâşife", phone: "+90 333 6784334"}, {name: "Akdoruk", lastName: "Akdöl", phone: "+90 333 4687455"}] </code></pre> <p>and</p> <pre><code>var arr2 = [{name: "Yesügey", lastName: "Yeşil", phone: "+90 333 9695395"}, {name: "Firdest", lastName: "Firdevis", phone: "+90 333 4234638"}, {name: "Pehlivan", lastName: "Pehlül", phone: "+90 333 9114821"}, {name: "Urbeyi", lastName: "Usberk", phone: "+90 333 1617245"}] </code></pre> <p>arr1-arr2</p> <p>Result:</p> <pre><code>var result = [{name: "Kâmile", lastName: "Kâşife", phone: "+90 333 6784334"}, {name: "Akdoruk", lastName: "Akdöl", phone: "+90 333 4687455"}] </code></pre> <p>I want to get it.</p> <p>_.difference in Underscore does not make it. How can I follow a method?</p>
0debug
void imx_timerp_create(const target_phys_addr_t addr, qemu_irq irq, DeviceState *ccm) { IMXTimerPState *pp; DeviceState *dev; dev = sysbus_create_simple("imx_timerp", addr, irq); pp = container_of(dev, IMXTimerPState, busdev.qdev); pp->ccm = ccm; }
1threat
static void ehci_update_frindex(EHCIState *ehci, int uframes) { int i; if (!ehci_enabled(ehci) && ehci->pstate == EST_INACTIVE) { return; } for (i = 0; i < uframes; i++) { ehci->frindex++; if (ehci->frindex == 0x00002000) { ehci_raise_irq(ehci, USBSTS_FLR); } if (ehci->frindex == 0x00004000) { ehci_raise_irq(ehci, USBSTS_FLR); ehci->frindex = 0; if (ehci->usbsts_frindex >= 0x00004000) { ehci->usbsts_frindex -= 0x00004000; } else { ehci->usbsts_frindex = 0; } } } }
1threat
void configure_icount(QemuOpts *opts, Error **errp) { const char *option; char *rem_str = NULL; option = qemu_opt_get(opts, "shift"); if (!option) { if (qemu_opt_get(opts, "align") != NULL) { error_setg(errp, "Please specify shift option when using align"); } return; } icount_sleep = qemu_opt_get_bool(opts, "sleep", true); if (icount_sleep) { icount_warp_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL_RT, icount_dummy_timer, NULL); } icount_align_option = qemu_opt_get_bool(opts, "align", false); if (icount_align_option && !icount_sleep) { error_setg(errp, "align=on and sleep=off are incompatible"); } if (strcmp(option, "auto") != 0) { errno = 0; icount_time_shift = strtol(option, &rem_str, 0); if (errno != 0 || *rem_str != '\0' || !strlen(option)) { error_setg(errp, "icount: Invalid shift value"); } use_icount = 1; return; } else if (icount_align_option) { error_setg(errp, "shift=auto and align=on are incompatible"); } else if (!icount_sleep) { error_setg(errp, "shift=auto and sleep=off are incompatible"); } use_icount = 2; icount_time_shift = 3; icount_rt_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL_RT, icount_adjust_rt, NULL); timer_mod(icount_rt_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL_RT) + 1000); icount_vm_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, icount_adjust_vm, NULL); timer_mod(icount_vm_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + get_ticks_per_sec() / 10); }
1threat
static void vector_fmul_window_mips(float *dst, const float *src0, const float *src1, const float *win, int len) { float * dst_j, *win_j, *src0_i, *src1_j, *dst_i, *win_i; float temp, temp1, temp2, temp3; float s0, s01, s1, s11; float wi, wi1, wi2, wi3; float wj, wj1, wj2, wj3; const float * lp_end = win + len; win_i = (float *)win; win_j = (float *)(win + 2 * len -1); src1_j = (float *)(src1 + len - 1); src0_i = (float *)src0; dst_i = (float *)dst; dst_j = (float *)(dst + 2 * len -1); __asm__ volatile ( "1:" "lwc1 %[s1], 0(%[src1_j]) \n\t" "lwc1 %[wi], 0(%[win_i]) \n\t" "lwc1 %[wj], 0(%[win_j]) \n\t" "lwc1 %[s11], -4(%[src1_j]) \n\t" "lwc1 %[wi1], 4(%[win_i]) \n\t" "lwc1 %[wj1], -4(%[win_j]) \n\t" "lwc1 %[s0], 0(%[src0_i]) \n\t" "lwc1 %[s01], 4(%[src0_i]) \n\t" "mul.s %[temp], %[s1], %[wi] \n\t" "mul.s %[temp1], %[s1], %[wj] \n\t" "mul.s %[temp2], %[s11], %[wi1] \n\t" "mul.s %[temp3], %[s11], %[wj1] \n\t" "lwc1 %[s1], -8(%[src1_j]) \n\t" "lwc1 %[wi2], 8(%[win_i]) \n\t" "lwc1 %[wj2], -8(%[win_j]) \n\t" "lwc1 %[s11], -12(%[src1_j]) \n\t" "msub.s %[temp], %[temp], %[s0], %[wj] \n\t" "madd.s %[temp1], %[temp1], %[s0], %[wi] \n\t" "msub.s %[temp2], %[temp2], %[s01], %[wj1] \n\t" "madd.s %[temp3], %[temp3], %[s01], %[wi1] \n\t" "lwc1 %[wi3], 12(%[win_i]) \n\t" "lwc1 %[wj3], -12(%[win_j]) \n\t" "lwc1 %[s0], 8(%[src0_i]) \n\t" "lwc1 %[s01], 12(%[src0_i]) \n\t" "addiu %[src1_j],-16 \n\t" "addiu %[win_i], 16 \n\t" "addiu %[win_j], -16 \n\t" "addiu %[src0_i], 16 \n\t" "swc1 %[temp], 0(%[dst_i]) \n\t" "swc1 %[temp1], 0(%[dst_j]) \n\t" "swc1 %[temp2], 4(%[dst_i]) \n\t" "swc1 %[temp3], -4(%[dst_j]) \n\t" "mul.s %[temp], %[s1], %[wi2] \n\t" "mul.s %[temp1], %[s1], %[wj2] \n\t" "mul.s %[temp2], %[s11], %[wi3] \n\t" "mul.s %[temp3], %[s11], %[wj3] \n\t" "msub.s %[temp], %[temp], %[s0], %[wj2] \n\t" "madd.s %[temp1], %[temp1], %[s0], %[wi2] \n\t" "msub.s %[temp2], %[temp2], %[s01], %[wj3] \n\t" "madd.s %[temp3], %[temp3], %[s01], %[wi3] \n\t" "swc1 %[temp], 8(%[dst_i]) \n\t" "swc1 %[temp1], -8(%[dst_j]) \n\t" "swc1 %[temp2], 12(%[dst_i]) \n\t" "swc1 %[temp3], -12(%[dst_j]) \n\t" "addiu %[dst_i], 16 \n\t" "addiu %[dst_j], -16 \n\t" "bne %[win_i], %[lp_end], 1b \n\t" : [temp]"=&f"(temp), [temp1]"=&f"(temp1), [temp2]"=&f"(temp2), [temp3]"=&f"(temp3), [src0_i]"+r"(src0_i), [win_i]"+r"(win_i), [src1_j]"+r"(src1_j), [win_j]"+r"(win_j), [dst_i]"+r"(dst_i), [dst_j]"+r"(dst_j), [s0] "=&f"(s0), [s01]"=&f"(s01), [s1] "=&f"(s1), [s11]"=&f"(s11), [wi] "=&f"(wi), [wj] "=&f"(wj), [wi2]"=&f"(wi2), [wj2]"=&f"(wj2), [wi3]"=&f"(wi3), [wj3]"=&f"(wj3), [wi1]"=&f"(wi1), [wj1]"=&f"(wj1) : [lp_end]"r"(lp_end) : "memory" ); }
1threat
static inline void gen_intermediate_code_internal(SPARCCPU *cpu, TranslationBlock *tb, bool spc) { CPUState *cs = CPU(cpu); CPUSPARCState *env = &cpu->env; target_ulong pc_start, last_pc; uint16_t *gen_opc_end; DisasContext dc1, *dc = &dc1; CPUBreakpoint *bp; int j, lj = -1; int num_insns; int max_insns; unsigned int insn; memset(dc, 0, sizeof(DisasContext)); dc->tb = tb; pc_start = tb->pc; dc->pc = pc_start; last_pc = dc->pc; dc->npc = (target_ulong) tb->cs_base; dc->cc_op = CC_OP_DYNAMIC; dc->mem_idx = cpu_mmu_index(env); dc->def = env->def; dc->fpu_enabled = tb_fpu_enabled(tb->flags); dc->address_mask_32bit = tb_am_enabled(tb->flags); dc->singlestep = (cs->singlestep_enabled || singlestep); gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) max_insns = CF_COUNT_MASK; gen_tb_start(); do { if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { if (bp->pc == dc->pc) { if (dc->pc != pc_start) save_state(dc); gen_helper_debug(cpu_env); tcg_gen_exit_tb(0); dc->is_br = 1; goto exit_gen_loop; } } } if (spc) { qemu_log("Search PC...\n"); j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; if (lj < j) { lj++; while (lj < j) tcg_ctx.gen_opc_instr_start[lj++] = 0; tcg_ctx.gen_opc_pc[lj] = dc->pc; gen_opc_npc[lj] = dc->npc; tcg_ctx.gen_opc_instr_start[lj] = 1; tcg_ctx.gen_opc_icount[lj] = num_insns; } } if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) gen_io_start(); last_pc = dc->pc; insn = cpu_ldl_code(env, dc->pc); disas_sparc_insn(dc, insn); num_insns++; if (dc->is_br) break; if (dc->pc != (last_pc + 4)) break; if ((dc->pc & (TARGET_PAGE_SIZE - 1)) == 0) break; if (dc->singlestep) { break; } } while ((tcg_ctx.gen_opc_ptr < gen_opc_end) && (dc->pc - pc_start) < (TARGET_PAGE_SIZE - 32) && num_insns < max_insns); exit_gen_loop: if (tb->cflags & CF_LAST_IO) { gen_io_end(); } if (!dc->is_br) { if (dc->pc != DYNAMIC_PC && (dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) { gen_goto_tb(dc, 0, dc->pc, dc->npc); } else { if (dc->pc != DYNAMIC_PC) { tcg_gen_movi_tl(cpu_pc, dc->pc); } save_npc(dc); tcg_gen_exit_tb(0); } } gen_tb_end(tb, num_insns); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (spc) { j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; lj++; while (lj <= j) tcg_ctx.gen_opc_instr_start[lj++] = 0; #if 0 log_page_dump(); #endif gen_opc_jump_pc[0] = dc->jump_pc[0]; gen_opc_jump_pc[1] = dc->jump_pc[1]; } else { tb->size = last_pc + 4 - pc_start; tb->icount = num_insns; } #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("--------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(env, pc_start, last_pc + 4 - pc_start, 0); qemu_log("\n"); } #endif }
1threat
static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame) { AVCodecInternal *avci = avctx->internal; InternalBuffer *buf; int buf_size, ret; buf_size = av_samples_get_buffer_size(NULL, avctx->channels, frame->nb_samples, avctx->sample_fmt, 0); if (buf_size < 0) return AVERROR(EINVAL); if (!avci->buffer) { avci->buffer = av_mallocz(sizeof(InternalBuffer)); if (!avci->buffer) return AVERROR(ENOMEM); } buf = avci->buffer; if (buf->extended_data) { if (buf->extended_data[0] && buf_size > buf->audio_data_size) { av_free(buf->extended_data[0]); if (buf->extended_data != buf->data) av_free(buf->extended_data); buf->extended_data = NULL; buf->data[0] = NULL; } if (buf->nb_channels != avctx->channels) { if (buf->extended_data != buf->data) av_free(buf->extended_data); buf->extended_data = NULL; } } if (!buf->extended_data) { if (!buf->data[0]) { if (!(buf->data[0] = av_mallocz(buf_size))) return AVERROR(ENOMEM); buf->audio_data_size = buf_size; } if ((ret = avcodec_fill_audio_frame(frame, avctx->channels, avctx->sample_fmt, buf->data[0], buf->audio_data_size, 0))) return ret; if (frame->extended_data == frame->data) buf->extended_data = buf->data; else buf->extended_data = frame->extended_data; memcpy(buf->data, frame->data, sizeof(frame->data)); buf->linesize[0] = frame->linesize[0]; buf->nb_channels = avctx->channels; } else { frame->extended_data = buf->extended_data; frame->linesize[0] = buf->linesize[0]; memcpy(frame->data, buf->data, sizeof(frame->data)); } frame->type = FF_BUFFER_TYPE_INTERNAL; ff_init_buffer_info(avctx, frame); if (avctx->debug & FF_DEBUG_BUFFERS) av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on frame %p, " "internal audio buffer used\n", frame); return 0; }
1threat
Expecting class path separator ';' before '\Android\android-sdk\build-tools\23.0.1\lib\shrinkedAndroid.jar' in argument number 8 : <p>Using VS 2015 for Xamarin development, when I attempt to build an Android project which has Enable Multi-Dex checked, I get the following error :-</p> <blockquote> <p>Expecting class path separator ';' before '\Android\android-sdk\build-tools\23.0.1\lib\shrinkedAndroid.jar' in argument number 8</p> </blockquote> <p>Any idea why this might be happening and how to resolve it?</p>
0debug
static void test_co_queue(void) { Coroutine *c1; Coroutine *c2; c1 = qemu_coroutine_create(c1_fn); c2 = qemu_coroutine_create(c2_fn); qemu_coroutine_enter(c1, c2); memset(c1, 0xff, sizeof(Coroutine)); qemu_coroutine_enter(c2, NULL); }
1threat
QDict *qdict_new(void) { QDict *qdict; qdict = g_malloc0(sizeof(*qdict)); QOBJECT_INIT(qdict, &qdict_type); return qdict; }
1threat
document.write('<script src="evil.js"></script>');
1threat
Why is std::vector so much slower then array pointer : <p>Im creating a Opengl font batch draw.</p> <p>I want to know why my std::vector is so much slower then using a array pointer.</p> <p>I have tried adding vector reserve and everything i can think of.</p> <p>My FPS drops just over half when using vectors.</p> <p>Vectors seem easier to manage and look nicer in code, but im really stuck on this.</p> <p>Not sure if its something simple that i have missed?</p> <p>Or is it better to just use array pointers?</p> <pre><code>#ifdef USE_VECTORS std::vector&lt;Vertex&gt; m_vertices; #else Vertex *m_pVertex; Vertex m_vertices[MAX_VERTICES]; #endif </code></pre> <p>drawing char function</p> <pre><code> void GLFont::drawChar(char c, int x, int y) { // 1------4 // | | 1 = (x, y) // | | 2 = (x, y + charHeight) // | | 3 = (x + charWidth, y + charHeight) // | | 4 = (x + charWidth, y) // | | // | | // 2------3 // const Glyph &amp;glyph = getChar(c); int charWidth = glyph.width; int charHeight = m_charHeight; #ifdef USE_VECTORS Vertex vert[] = { x, y, glyph.upperLeft[0], glyph.upperLeft[1], m_color[0], m_color[1], m_color[2], m_color[3], x, y + charHeight, glyph.lowerLeft[0], glyph.lowerLeft[1], m_color[0], m_color[1], m_color[2], m_color[3], x + charWidth, y + charHeight, glyph.lowerRight[0], glyph.lowerRight[1], m_color[0], m_color[1], m_color[2], m_color[3], x + charWidth, y, glyph.upperRight[0], glyph.upperRight[1], m_color[0], m_color[1], m_color[2], m_color[3] }; //unsigned dataArraySize = sizeof(vert) / sizeof(Vertex); m_vertices.insert(m_vertices.end(), &amp;vert[0], &amp;vert[4]); ++m_numCharsToDraw; #else //1 m_pVertex-&gt;x = x; m_pVertex-&gt;y = y; m_pVertex-&gt;s = glyph.upperLeft[0]; m_pVertex-&gt;t = glyph.upperLeft[1]; m_pVertex-&gt;r = m_color[0]; m_pVertex-&gt;g = m_color[1]; m_pVertex-&gt;b = m_color[2]; m_pVertex-&gt;a = m_color[3]; ++m_pVertex; // 2 m_pVertex-&gt;x = x; m_pVertex-&gt;y = y + charHeight; m_pVertex-&gt;s = glyph.lowerLeft[0]; m_pVertex-&gt;t = glyph.lowerLeft[1]; m_pVertex-&gt;r = m_color[0]; m_pVertex-&gt;g = m_color[1]; m_pVertex-&gt;b = m_color[2]; m_pVertex-&gt;a = m_color[3]; ++m_pVertex; // 3 m_pVertex-&gt;x = x + charWidth; m_pVertex-&gt;y = y + charHeight; m_pVertex-&gt;s = glyph.lowerRight[0]; m_pVertex-&gt;t = glyph.lowerRight[1]; m_pVertex-&gt;r = m_color[0]; m_pVertex-&gt;g = m_color[1]; m_pVertex-&gt;b = m_color[2]; m_pVertex-&gt;a = m_color[3]; ++m_pVertex; // 4 m_pVertex-&gt;x = x + charWidth; m_pVertex-&gt;y = y; m_pVertex-&gt;s = glyph.upperRight[0]; m_pVertex-&gt;t = glyph.upperRight[1]; m_pVertex-&gt;r = m_color[0]; m_pVertex-&gt;g = m_color[1]; m_pVertex-&gt;b = m_color[2]; m_pVertex-&gt;a = m_color[3]; ++m_pVertex; if (++m_numCharsToDraw == MAX_CHARS_PER_BATCH) { drawTextEnd(); drawBatchOfChars(); drawTextBegin(); } #endif } void GLFont::drawBatchOfChars() { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_COLOR_ARRAY); #ifdef USE_VECTORS glVertexPointer(2, GL_INT, sizeof(Vertex), &amp;m_vertices[0].x); glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &amp;m_vertices[0].s); glColorPointer(4, GL_FLOAT, sizeof(Vertex), &amp;m_vertices[0].r); #else glVertexPointer(2, GL_INT, sizeof(Vertex), &amp;m_vertices-&gt;x); glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &amp;m_vertices-&gt;s); glColorPointer(4, GL_FLOAT, sizeof(Vertex), &amp;m_vertices-&gt;r); #endif glDrawArrays(GL_QUADS, 0, m_numCharsToDraw * 4); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); } </code></pre>
0debug
C# Declaration of Class for use as List : I'm trying to declare this item for use as a list. class Item { Public int Resource{ get;set; } Public long Offset{ get;set; } Public int Value{ get;set; } } I thought this would be ok, I copied it off someone else, but I don't understand what get and set do. I'm completely new to C#, but the tutorial I watched put their class declaration in a different file - do you have to do that? I get this error : "Line: 15 Column: 11 (CS1519) Invalid token 'int' in class, struct, or interface member declaration"
0debug
ModuleNotFoundError: No module named '_curses' : From where i can remove these error im using pycharm on windows Traceback (most recent call last): File "C:/Users/Charan/PycharmProjects/helloworld/snake.py", line 2, in <module> import curses File "C:\Users\Charan\AppData\Local\Programs\Python\Python37-32\lib\curses\__init__.py", line 13, in <module> from _curses import * ModuleNotFoundError: No module named '_curses'
0debug
static int smacker_decode_header_tree(SmackVContext *smk, BitstreamContext *bc, int **recodes, int *last, int size) { int res; HuffContext huff; HuffContext tmp1, tmp2; VLC vlc[2] = { { 0 } }; int escapes[3]; DBCtx ctx; int err = 0; if(size >= UINT_MAX>>4){ av_log(smk->avctx, AV_LOG_ERROR, "size too large\n"); return AVERROR_INVALIDDATA; } tmp1.length = 256; tmp1.maxlength = 0; tmp1.current = 0; tmp1.bits = av_mallocz(256 * 4); tmp1.lengths = av_mallocz(256 * sizeof(int)); tmp1.values = av_mallocz(256 * sizeof(int)); tmp2.length = 256; tmp2.maxlength = 0; tmp2.current = 0; tmp2.bits = av_mallocz(256 * 4); tmp2.lengths = av_mallocz(256 * sizeof(int)); tmp2.values = av_mallocz(256 * sizeof(int)); if (!tmp1.bits || !tmp1.lengths || !tmp1.values || !tmp2.bits || !tmp2.lengths || !tmp2.values) { err = AVERROR(ENOMEM); goto error; } if (bitstream_read_bit(bc)) { smacker_decode_tree(bc, &tmp1, 0, 0); bitstream_skip(bc, 1); res = init_vlc(&vlc[0], SMKTREE_BITS, tmp1.length, tmp1.lengths, sizeof(int), sizeof(int), tmp1.bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE); if(res < 0) { av_log(smk->avctx, AV_LOG_ERROR, "Cannot build VLC table\n"); err = res; goto error; } } else { av_log(smk->avctx, AV_LOG_ERROR, "Skipping low bytes tree\n"); } if (bitstream_read_bit(bc)) { smacker_decode_tree(bc, &tmp2, 0, 0); bitstream_skip(bc, 1); res = init_vlc(&vlc[1], SMKTREE_BITS, tmp2.length, tmp2.lengths, sizeof(int), sizeof(int), tmp2.bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE); if(res < 0) { av_log(smk->avctx, AV_LOG_ERROR, "Cannot build VLC table\n"); err = res; goto error; } } else { av_log(smk->avctx, AV_LOG_ERROR, "Skipping high bytes tree\n"); } escapes[0] = bitstream_read(bc, 8); escapes[0] |= bitstream_read(bc, 8) << 8; escapes[1] = bitstream_read(bc, 8); escapes[1] |= bitstream_read(bc, 8) << 8; escapes[2] = bitstream_read(bc, 8); escapes[2] |= bitstream_read(bc, 8) << 8; last[0] = last[1] = last[2] = -1; ctx.escapes[0] = escapes[0]; ctx.escapes[1] = escapes[1]; ctx.escapes[2] = escapes[2]; ctx.v1 = &vlc[0]; ctx.v2 = &vlc[1]; ctx.recode1 = tmp1.values; ctx.recode2 = tmp2.values; ctx.last = last; huff.length = ((size + 3) >> 2) + 4; huff.maxlength = 0; huff.current = 0; huff.values = av_mallocz(huff.length * sizeof(int)); if (!huff.values) { err = AVERROR(ENOMEM); goto error; } if ((res = smacker_decode_bigtree(bc, &huff, &ctx)) < 0) err = res; bitstream_skip(bc, 1); if(ctx.last[0] == -1) ctx.last[0] = huff.current++; if(ctx.last[1] == -1) ctx.last[1] = huff.current++; if(ctx.last[2] == -1) ctx.last[2] = huff.current++; if (ctx.last[0] >= huff.length || ctx.last[1] >= huff.length || ctx.last[2] >= huff.length) { av_log(smk->avctx, AV_LOG_ERROR, "Huffman codes out of range\n"); err = AVERROR_INVALIDDATA; } *recodes = huff.values; error: if(vlc[0].table) ff_free_vlc(&vlc[0]); if(vlc[1].table) ff_free_vlc(&vlc[1]); av_free(tmp1.bits); av_free(tmp1.lengths); av_free(tmp1.values); av_free(tmp2.bits); av_free(tmp2.lengths); av_free(tmp2.values); return err; }
1threat
C++ unique_ptr initialization through constructor : <p>I have simple (I suppose) problem with my C++ code. Each time I initialize unique_ptr through constructor I'm getting the same problem: </p> <blockquote> <p><strong>munmap_chunk(): invalid pointer: 0x00007ffc40ba6bf0</strong></p> </blockquote> <p>Here's the code:</p> <p>1) Private part of the class:</p> <pre><code>template&lt;typename T&gt; class Node{ typedef std::unique_ptr&lt;Node&gt; ptr; T value; ptr left, right; </code></pre> <p>2) Constructor initializing ptr left and ptr right:</p> <pre><code>explicit Node(const T value, Node* left = nullptr, Node* right = nullptr): value{value}, left{left}, right{right} {} </code></pre> <p>What is the problem here? Thanks for clarification or pointing me in the right direction. </p>
0debug
Can I install python 3.7 in ubuntu 18.04 without having python 3.6 in the system? : <p>Please read the question carefully before closing as duplicate, I believe the use case to be unique.</p> <p>I'm trying to create a docker image that <strong>only has python 3.7 installed</strong>, the problem is that if I try to install pip, the command also installs python 3.6 which <strong>I do not want</strong>.</p> <p>The relevant part of the ideal docker file I'm tinkering is as follows</p> <pre><code>FROM ubuntu:18.04 # Upgrade installed packages RUN apt-get update &amp;&amp; apt-get upgrade -y &amp;&amp; apt-get clean # (...) # Python package management and basic dependencies RUN apt-get install -y python3.7 python3.7-dev python3.7-pip # Register the version in alternatives RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1 # Set python 3 as the default python RUN update-alternatives --set python /usr/bin/python3.7 # Upgrade pip to latest version RUN python -m ensurepip --upgrade # (...) </code></pre> <p>This would fail as <em>python3.7-pip</em> doesn't seem to exist; only <em>python3-pip</em> does, which is what installs python 3.6 for some reason.</p> <p>I tried not installing pip at all and doing it manually, like so</p> <pre><code># (...) RUN apt-get install -y python3.7 python3.7-dev # (...) RUN curl 'https://bootstrap.pypa.io/get-pip.py' &gt; get-pip.py RUN python get-pip.py pip --no-setuptools --no-wheel </code></pre> <p>Which fails with this error:</p> <pre><code>Traceback (most recent call last): File "get-pip.py", line 21492, in &lt;module&gt; main() File "get-pip.py", line 197, in main bootstrap(tmpdir=tmpdir) File "get-pip.py", line 82, in bootstrap import pip._internal File "/tmp/tmpbez2vju9/pip.zip/pip/_internal/__init__.py", line 40, in &lt;module&gt; File "/tmp/tmpbez2vju9/pip.zip/pip/_internal/cli/autocompletion.py", line 8, in &lt;module&gt; File "/tmp/tmpbez2vju9/pip.zip/pip/_internal/cli/main_parser.py", line 8, in &lt;module&gt; File "/tmp/tmpbez2vju9/pip.zip/pip/_internal/cli/cmdoptions.py", line 14, in &lt;module&gt; ModuleNotFoundError: No module named 'distutils.util' </code></pre> <p>Again, installing python3-distutils results in python 3.6 appearing in the system</p> <p>So, is there a way to install ONLY a fully functional python 3.7 in ubuntu 18.04, WITHOUT having to install python 3.6?</p>
0debug
Anti Forgery Token race condition : <p>I have an MVC view that is supposed to be iFramed. And several instances of it might be iFramed in the same host page. In my view I have this:</p> <pre><code>@Html.AntiForgeryToken() </code></pre> <p>Which I use to try to make sure calls to a web api are only coming from this page. My host page might look something like this:</p> <pre><code>&lt;iframe src="http://myserver.com/myview?someparameters=0000"&gt;&lt;/iframe&gt; &lt;iframe src="http://myserver.com/myview?someparameters=0001"&gt;&lt;/iframe&gt; &lt;iframe src="http://myserver.com/myview?someparameters=0002"&gt;&lt;/iframe&gt; </code></pre> <p>In my view I grab the token and submit it in a header so that I can check it in my API:</p> <pre><code>var headers = actionContext.Request.Headers; var headerToken = headers.Contains("__RequestVerificationToken") ? headers.GetValues("__RequestVerificationToken").FirstOrDefault() : null; var cookie = headers.GetCookies("__RequestVerificationToken").FirstOrDefault()?["__RequestVerificationToken"]?.Value; AntiForgery.Validate(cookie,headerToken); </code></pre> <p>The problem I'm running into is that in my host page, all three views are getting loaded in parallel. As a result they all get their own random token in a hidden field and try to set the cookie. But while there can be three separate independent hidden input tokens, there can be only one cookie. So of the three requests, two will fail and one will succeed. A reload of the page will have all three working again, presumably because they are all getting the same anti-forgery token at this point (because it belongs to the session - if I understand this correctly).</p> <p>So how can I avoid this? How can I make sure they all get the same token?</p>
0debug
encode image to base64 from amazon-s3 : I have iframe which contain image. Image source is link to image in amazon-S3 bucket. I need encode this image in base64 and save ifram's body in db. How can i do this?
0debug
When I launch the Kentico site, I see offline page : After Upgrade kentico to 10, and fix errors in code. I launch the Kentico site, and see offline page(screenshot attached) [screenshot][1] Who can know why this happened? [1]: https://i.stack.imgur.com/g5P7v.png
0debug
void register_displaychangelistener(DisplayChangeListener *dcl) { QemuConsole *con; trace_displaychangelistener_register(dcl, dcl->ops->dpy_name); dcl->ds = get_alloc_displaystate(); QLIST_INSERT_HEAD(&dcl->ds->listeners, dcl, next); gui_setup_refresh(dcl->ds); if (dcl->con) { dcl->con->dcls++; con = dcl->con; } else { con = active_console; } if (dcl->ops->dpy_gfx_switch && con) { dcl->ops->dpy_gfx_switch(dcl, con->surface); } }
1threat
static void omap2_mpu_reset(void *opaque) { struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque; omap_inth_reset(mpu->ih[0]); omap_dma_reset(mpu->dma); omap_prcm_reset(mpu->prcm); omap_sysctl_reset(mpu->sysc); omap_gp_timer_reset(mpu->gptimer[0]); omap_gp_timer_reset(mpu->gptimer[1]); omap_gp_timer_reset(mpu->gptimer[2]); omap_gp_timer_reset(mpu->gptimer[3]); omap_gp_timer_reset(mpu->gptimer[4]); omap_gp_timer_reset(mpu->gptimer[5]); omap_gp_timer_reset(mpu->gptimer[6]); omap_gp_timer_reset(mpu->gptimer[7]); omap_gp_timer_reset(mpu->gptimer[8]); omap_gp_timer_reset(mpu->gptimer[9]); omap_gp_timer_reset(mpu->gptimer[10]); omap_gp_timer_reset(mpu->gptimer[11]); omap_synctimer_reset(mpu->synctimer); omap_sdrc_reset(mpu->sdrc); omap_gpmc_reset(mpu->gpmc); omap_dss_reset(mpu->dss); omap_uart_reset(mpu->uart[0]); omap_uart_reset(mpu->uart[1]); omap_uart_reset(mpu->uart[2]); omap_mmc_reset(mpu->mmc); omap_mcspi_reset(mpu->mcspi[0]); omap_mcspi_reset(mpu->mcspi[1]); omap_i2c_reset(mpu->i2c[0]); omap_i2c_reset(mpu->i2c[1]); cpu_reset(mpu->env); }
1threat
How to fix this? : <p>How do I fix this? I know that the error is in line 8 (g = f/5) but how do i fix the error? </p> <pre><code>a = input("Enter a number: ") b = input("Enter a second number: ") c = input("Enter a third number: ") d = input("Enter a fourth number: ") e = input("Enter a fifth number: ") f = a+b+c+d+e g = f/5 print ("The average of these numbers is "+str(g)) </code></pre>
0debug
How to replace ^ character in JS : <p>I have a json data in my hand and I want to clear this character "^"</p> <p>but I can't get out of it because it's a regex operator.</p> <p>The code I wrote:</p> <pre><code>data = JSON.stringify(data) data = data.replace(/^1/g, ''); data = JSON.parse(data) </code></pre>
0debug
static void test_hybrid_analysis(void) { LOCAL_ALIGNED_16(INTFLOAT, dst0, [BUF_SIZE], [2]); LOCAL_ALIGNED_16(INTFLOAT, dst1, [BUF_SIZE], [2]); LOCAL_ALIGNED_16(INTFLOAT, in, [12], [2]); LOCAL_ALIGNED_16(INTFLOAT, filter, [N], [8][2]); declare_func(void, INTFLOAT (*out)[2], INTFLOAT (*in)[2], const INTFLOAT (*filter)[8][2], ptrdiff_t stride, int n); randomize((INTFLOAT *)in, 12 * 2); randomize((INTFLOAT *)filter, N * 8 * 2); randomize((INTFLOAT *)dst0, BUF_SIZE * 2); memcpy(dst1, dst0, BUF_SIZE * 2 * sizeof(INTFLOAT)); call_ref(dst0, in, filter, STRIDE, N); call_new(dst1, in, filter, STRIDE, N); if (!float_near_abs_eps_array((float *)dst0, (float *)dst1, EPS, BUF_SIZE * 2)) fail(); bench_new(dst1, in, filter, STRIDE, N); }
1threat
Regular Expression specific to a particular message pattern : As I'm pretty new to Regular Expression, I'm looking for a regular expression which will validate whether entire string is separated by '|' and there will be values with '$' followed by an integer. Valid Values: ABC=$2|CDE=$1|Msg=$4|Ph.No=$3|TIME=$5 ABC=$2|CDE=$1|Msg123=$4|Ph.No=$3|TIME_23=$5 abc=$2|123=$1|cfg=$4|Ph.No=$3 Invalid Values: ABC=$2CDE=$1Msg=$4 ABC=2|CDE=1|Msg123=$4|Ph.No=$3|TIME_23=$5 abc$2|123$1|cfg$4|Ph.No=$3 Msg123=$ |Ph.No=$ |TIME_23=5 abcdefgh|1234|eghjik Msg123=$*|Ph.No=$()|TIME_23=$5 Msg123=$a|Ph.No=$b|TIME_23=$c
0debug
Export pyLDAvis graphs as standalone webpage : <p>i am analysing text with topic modelling and using Gensim and pyLDAvis for that. Would like to share the results with distant colleagues, without a need for them to install python and all required libraries. Is there a way to export interactive graphs as HTML/JS files that could be uploaded to any web server? I've found something mentioned in documentation, but have no idea how to implement it: <strong><a href="https://github.com/bmabey/pyLDAvis/blob/master/pyLDAvis/_display.py" rel="noreferrer">https://github.com/bmabey/pyLDAvis/blob/master/pyLDAvis/_display.py</a></strong></p>
0debug
how to invoke the _Verify_range in vector in c++? : my code ```c++ #include <iostream> #include <vector> #include <algorithm> using std::vector; using std::cout; using std::endl; using std::back_inserter; int main(void) { vector<int> coll1 {1, 2, 3, 4}; vector<int> coll2; copy(coll1.begin(), coll1.end(), back_inserter(coll2)); const auto start = coll2.cbegin(); const auto stop = coll2.cend(); // start: class std::_Vector_const_iterator<class std::_Vector_val<struct std::_Simple_types<int> > > cout << typeid(start).name() << endl; // _ITERATOR_DEBUG_LEVEL: 2 cout << _ITERATOR_DEBUG_LEVEL << endl; std::_Verify_range(start, stop); for (auto ele: coll2) cout << ele << ", " << ele << endl; return 0; } ``` compile error ``` error C2672: 'std::_Verify_range': no matching overloaded function found error C2784: 'void std::_Verify_range(const std::_Array_const_iterator<_Ty,_Size> &,const std::_Array_const_iterator<_Ty,_Size> &) noexcept': could not deduce template argument for 'const std::_Array_const_iterator<_Ty,_Size> &' from 'const std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>' error C2784: with error C2784: [ error C2784: _Ty=int error C2784: ] VC\14.22.27905\include\xutility(1467): message : see declaration of 'std::_Verify_range' error C2784: 'void std::_Verify_range(const std::reverse_iterator<_BidIt> &,const std::reverse_iterator<_BidIt2> &)': could not deduce template argument for 'const std::reverse_iterator<_BidIt> &' from 'const std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>' error C2784: with error C2784: [ error C2784: _Ty=int error C2784: ] VC\14.22.27905\include\xutility(983): message : see declaration of 'std::_Verify_range' error C2784: 'void std::_Verify_range(const _Ty *const ,const _Ty *const ) noexcept': could not deduce template argument for 'const _Ty *const ' from 'const std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>' error C2784: with error C2784: [ error C2784: _Ty=int error C2784: ] VC\14.22.27905\include\xutility(193): message : see declaration of 'std::_Verify_range' ``` this is the code in vector ``` // CLASS TEMPLATE _Vector_const_iterator template <class _Myvec> class _Vector_const_iterator : public _Iterator_base { public: ... #if _ITERATOR_DEBUG_LEVEL != 0 friend void _Verify_range(const _Vector_const_iterator& _First, const _Vector_const_iterator& _Last) { _STL_VERIFY(_First._Getcont() == _Last._Getcont(), "vector iterators in range are from different containers"); _STL_VERIFY(_First._Ptr <= _Last._Ptr, "vector iterator range transposed"); } #endif // _ITERATOR_DEBUG_LEVEL != 0 ... } ``` the compiler seems only try to match this three prototype function: ``` void std::_Verify_range(const std::_Array_const_iterator<_Ty,_Size> &,const std::_Array_const_iterator<_Ty,_Size> &); and void std::_Verify_range(const std::reverse_iterator<_BidIt> &,const std::reverse_iterator<_BidIt2> &) and void std::_Verify_range(const _Ty *const ,const _Ty *const ) noexcept; ``` can anyone help me to figure it out? can anyone help me to figure it out? can anyone help me to figure it out? can anyone help me to figure it out? can anyone help me to figure it out? can anyone help me to figure it out? can anyone help me to figure it out? can anyone help me to figure it out? can anyone help me to figure it out? can anyone help me to figure it out?
0debug
static av_always_inline int encode_line(FFV1Context *s, int w, int16_t *sample[3], int plane_index, int bits) { PlaneContext *const p = &s->plane[plane_index]; RangeCoder *const c = &s->c; int x; int run_index = s->run_index; int run_count = 0; int run_mode = 0; if (s->ac) { if (c->bytestream_end - c->bytestream < w * 20) { av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return AVERROR_INVALIDDATA; } } else { if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb) >> 3) < w * 4) { av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return AVERROR_INVALIDDATA; } } for (x = 0; x < w; x++) { int diff, context; context = get_context(p, sample[0] + x, sample[1] + x, sample[2] + x); diff = sample[0][x] - predict(sample[0] + x, sample[1] + x); if (context < 0) { context = -context; diff = -diff; } diff = fold(diff, bits); if (s->ac) { if (s->flags & CODEC_FLAG_PASS1) { put_symbol_inline(c, p->state[context], diff, 1, s->rc_stat, s->rc_stat2[p->quant_table_index][context]); } else { put_symbol_inline(c, p->state[context], diff, 1, NULL, NULL); } } else { if (context == 0) run_mode = 1; if (run_mode) { if (diff) { while (run_count >= 1 << ff_log2_run[run_index]) { run_count -= 1 << ff_log2_run[run_index]; run_index++; put_bits(&s->pb, 1, 1); } put_bits(&s->pb, 1 + ff_log2_run[run_index], run_count); if (run_index) run_index--; run_count = 0; run_mode = 0; if (diff > 0) diff--; } else { run_count++; } } av_dlog(s->avctx, "count:%d index:%d, mode:%d, x:%d pos:%d\n", run_count, run_index, run_mode, x, (int)put_bits_count(&s->pb)); if (run_mode == 0) put_vlc_symbol(&s->pb, &p->vlc_state[context], diff, bits); } } if (run_mode) { while (run_count >= 1 << ff_log2_run[run_index]) { run_count -= 1 << ff_log2_run[run_index]; run_index++; put_bits(&s->pb, 1, 1); } if (run_count) put_bits(&s->pb, 1, 1); } s->run_index = run_index; return 0; }
1threat
how to know the depth of a git's shallow clone? : <p>If I retrieve a shallow clone, e.g.</p> <pre><code>git clone --depth 10 http://foo.bar/baz.git </code></pre> <p>Does <code>git</code> have any command to retrieve the depth of this clone? (e.g. a command that simply prints <code>10</code>).</p>
0debug
static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { off_t start, data = 0, hole = 0; int64_t total_size; int ret; ret = fd_open(bs); if (ret < 0) { return ret; } start = sector_num * BDRV_SECTOR_SIZE; total_size = bdrv_getlength(bs); if (total_size < 0) { return total_size; } else if (start >= total_size) { *pnum = 0; return 0; } else if (start + nb_sectors * BDRV_SECTOR_SIZE > total_size) { nb_sectors = DIV_ROUND_UP(total_size - start, BDRV_SECTOR_SIZE); } ret = find_allocation(bs, start, &data, &hole); if (ret == -ENXIO) { *pnum = nb_sectors; ret = BDRV_BLOCK_ZERO; } else if (ret < 0) { *pnum = nb_sectors; ret = BDRV_BLOCK_DATA; } else if (data == start) { *pnum = MIN(nb_sectors, DIV_ROUND_UP(hole - start, BDRV_SECTOR_SIZE)); ret = BDRV_BLOCK_DATA; } else { assert(hole == start); *pnum = MIN(nb_sectors, (data - start) / BDRV_SECTOR_SIZE); ret = BDRV_BLOCK_ZERO; } return ret | BDRV_BLOCK_OFFSET_VALID | start; }
1threat
int ffurl_read(URLContext *h, unsigned char *buf, int size) { if (h->flags & AVIO_FLAG_WRITE) return AVERROR(EIO); return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read); }
1threat
Problems building a GUI which will compare algorithms : <p>I'm looking to build a GUI that will let the user randomly populate an array and then compare the time it takes to sort by bubble sort, insertion sort and selection sort. i have the code for the 3 algorithms but i'm struggling to put it all together and compare it using System.currentTimeMillis() </p>
0debug
Choice Stack Between Meteor, Ionic 2, Firebase : <p>I'm brand new to coding (still consoliding my JS) and i have a project for a webiste + mobile app to help people with their diet. It will have a database with lots of recipe and people will be able to put their needs, the application will propose them list of groceries and recipe to suit their needs. The point is not to discuss the application, i know there is a lot out here about that.</p> <p>What i would like to know is which solution will best suits my needs. I read about angular2 for the web application and ionic 2 for the mobile part, and i was planning to use firebase for the database. </p> <p>BUT i recently learned that something called Meteor is doing all of this in one place.</p> <p>I post this on stack to be sure that i understand correctly, so i'm wright or totally wrong ? </p> <p>Thank you in advance for your help and i whish you all a good day !</p>
0debug
Using multiple buckets with ActiveStorage : <p>Does anyone know if there is a way to configure custom buckets for specific attachments?</p> <pre><code>class MyModel &lt; ApplicationRecord ... has_one_attached :logo, bucket: 'custom_bucket' ... end </code></pre>
0debug
static int16_t *precalc_coefs(double dist25, int depth) { int i; double gamma, simil, C; int16_t *ct = av_malloc((512<<LUT_BITS)*sizeof(int16_t)); if (!ct) return NULL; gamma = log(0.25) / log(1.0 - FFMIN(dist25,252.0)/255.0 - 0.00001); for (i = -255<<LUT_BITS; i <= 255<<LUT_BITS; i++) { double f = ((i<<(9-LUT_BITS)) + (1<<(8-LUT_BITS)) - 1) / 512.0; simil = 1.0 - FFABS(f) / 255.0; C = pow(simil, gamma) * 256.0 * f; ct[(256<<LUT_BITS)+i] = lrint(C); } ct[0] = !!dist25; return ct; }
1threat
Need help building a counter in C inside a do while loop : I am trying to keep a count of how many times the operation inside the do-while loop is repeating, but the counter only shows 1 each time. Can anyone tell me where is my mistake? I have provided the code here. #include <stdio.h> #include <math.h> int main(void) { double i = 84; int counter = 0; do { counter++; i = fmod(i, 25.0); } while(i > 25); printf("Counter: %i\n %lf\n", counter, i); }
0debug
static void lsi_command_complete(SCSIBus *bus, int reason, uint32_t tag, uint32_t arg) { LSIState *s = DO_UPCAST(LSIState, dev.qdev, bus->qbus.parent); int out; out = (s->sstat1 & PHASE_MASK) == PHASE_DO; if (reason == SCSI_REASON_DONE) { DPRINTF("Command complete status=%d\n", (int)arg); s->status = arg; s->command_complete = 2; if (s->waiting && s->dbc != 0) { lsi_bad_phase(s, out, PHASE_ST); } else { lsi_set_phase(s, PHASE_ST); } qemu_free(s->current); s->current = NULL; lsi_resume_script(s); return; } if (s->waiting == 1 || !s->current || tag != s->current->tag || (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) { if (lsi_queue_tag(s, tag, arg)) return; } DPRINTF("Data ready tag=0x%x len=%d\n", tag, arg); s->current->dma_len = arg; s->command_complete = 1; if (!s->waiting) return; if (s->waiting == 1 || s->dbc == 0) { lsi_resume_script(s); } else { lsi_do_dma(s, out); } }
1threat
static bool scsi_block_is_passthrough(SCSIDiskState *s, uint8_t *buf) { switch (buf[0]) { case VERIFY_10: case VERIFY_12: case VERIFY_16: if ((buf[1] & 6) != 2) { return false; } break; case READ_6: case READ_10: case READ_12: case READ_16: case WRITE_6: case WRITE_10: case WRITE_12: case WRITE_16: case WRITE_VERIFY_10: case WRITE_VERIFY_12: case WRITE_VERIFY_16: if (s->qdev.type != TYPE_ROM) { return false; } break; default: break; } return true; }
1threat
I am new to Python. While coding an error of name not defined is generated. Can anyone help me with this? : I was coding for the question--Write a Python function that takes two lists and returns True if they have at least one common member code: first = [a,b,c,d,e,f] second = [a,s,d,f,g,h] for word1 in first: for word2 in second: if word1==word2: print("success") Error: first = list[a,b,c,d,e,f] NameError: name 'a' is not defined Can someone please help me with different errors faced while coding in python and what should be the best approach towards it? Thanks,
0debug