problem
stringlengths
26
131k
labels
class label
2 classes
void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width, int height, INT64 pts) { ContextInfo *ci = (ContextInfo *) ctx; AVPicture picture1; Imlib_Image image; DATA32 *data; image = get_cached_image(ci, width, height); if (!image) { image = imlib_create_image(width, height); put_cached_image(ci, image, width, height); } imlib_context_set_image(image); data = imlib_image_get_data(); if (pix_fmt != PIX_FMT_RGBA32) { avpicture_fill(&picture1, (UINT8 *) data, PIX_FMT_RGBA32, width, height); if (img_convert(&picture1, PIX_FMT_RGBA32, picture, pix_fmt, width, height) < 0) { goto done; } } else { av_abort(); } imlib_image_set_has_alpha(0); { int wid, hig, h_a, v_a; char buff[1000]; char tbuff[1000]; char *tbp = ci->text; time_t now = time(0); char *p, *q; int x, y; if (ci->file) { int fd = open(ci->file, O_RDONLY); if (fd < 0) { tbp = "[File not found]"; } else { int l = read(fd, tbuff, sizeof(tbuff) - 1); if (l >= 0) { tbuff[l] = 0; tbp = tbuff; } else { tbp = "[I/O Error]"; } close(fd); } } strftime(buff, sizeof(buff), tbp, localtime(&now)); x = ci->x; y = ci->y; for (p = buff; p; p = q) { q = strchr(p, '\n'); if (q) *q++ = 0; imlib_text_draw_with_return_metrics(x, y, p, &wid, &hig, &h_a, &v_a); y += v_a; } } if (pix_fmt != PIX_FMT_RGBA32) { if (img_convert(picture, pix_fmt, &picture1, PIX_FMT_RGBA32, width, height) < 0) { } } done: ; }
1threat
def permute_string(str): if len(str) == 0: return [''] prev_list = permute_string(str[1:len(str)]) next_list = [] for i in range(0,len(prev_list)): for j in range(0,len(str)): new_str = prev_list[i][0:j]+str[0]+prev_list[i][j:len(str)-1] if new_str not in next_list: next_list.append(new_str) return next_list
0debug
ng serve not detecting file changes automatically : <p>I need to run <code>ng serve</code> every time when any changes made to the source files.I have no error in the console.</p> <pre><code>Angular CLI: 1.6.2 Node: 8.9.1 OS: linux ia32 Angular: 5.1.2 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router @angular/cdk: 5.0.2-c3d7cd9 @angular/cli: 1.6.2 @angular/material: 5.0.3-e20d8f0 @angular-devkit/build-optimizer: 0.0.36 @angular-devkit/core: 0.0.22 @angular-devkit/schematics: 0.0.42 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.9.2 @schematics/angular: 0.1.11 @schematics/schematics: 0.0.11 typescript: 2.4.2 webpack: 3.10.0 </code></pre>
0debug
Create-React-App with Moment JS: Cannot find module "./locale" : <p>Just ran an <code>npm update</code> on my web application and now <em>Moment JS</em> appears to be failing with the following message:</p> <pre><code>Error: Cannot find module "./locale" \node_modules\moment\src\lib\moment\prototype.js:1 &gt; 1 | import { Moment } from './constructor'; </code></pre> <p>Not sure what version of <em>Moment JS</em> I had prior to my update, but my application has been working for months. </p> <p>I created another react app and ran an <code>npm install moment --save</code> and modified the source to display the time and ended up with the same error described above.</p> <p>Not sure if there is a fail-proof way to integrate <em>Moment JS</em> using <em>Create-React-App</em> currently short of ejecting to manage the webpack settings myself, but I really don't want to do this. Anyone else seeing these issues or having success? If so, a short write up would go along way to helping out.</p>
0debug
How to generate class diagram from models in EF Core? : <p>We are building an application using ASP.NET MVC Core and Entity Framework Core and we have the whole bunch of classes in our application. In previous versions of Entity Framework, we would use this method for generating an edmx file for class diagram:</p> <pre><code>void ExportMappings(DbContext context, string edmxFile) { var settings = new XmlWriterSettings { Indent = true }; using (XmlWriter writer = XmlWriter.Create(edmxFile, settings)) { System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(context, writer); } } </code></pre> <p>but it seems that there's no such feature in EF Core. I wonder if there's an equivalent version for doing this in Entity Framework Core.</p>
0debug
Why does this program which finds the smallest triangle number with >500 factors crash? : <p>I have written the program below to solve Project Euler 12, which involves finding the smallest triangle number with over 500 factors.</p> <p>I don't think there are major errors. I suspect memory optimization may be an issue. That being said, however, I need the unsigned long long int for the large triangle number that will eventually be the answer. I start my natural number sequence at triangleNumbers[0]=10,000,000,000. I know 9,000,000,000 has roughly 300 factors, so 10,000,000,000 was a "best guess." That being said, however, I assume that 10,000,000,000 is the "first natural number" and continue adding subsequent natural numbers to get the "second" natural number and beyond (so triangleNumbers[1]=10,000,000,000 + 2, triangleNumbers[2]=10,000,000,000 +3, and so forth).</p> <p>Any suggestions and tips would be appreciated. Thank you for helping a beginner improve.</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;math.h&gt; using namespace std; bool keepRunning=true; unsigned long long int naturalNumberCount=0; unsigned long long int j=4; unsigned long long int sum=0; vector &lt;unsigned long long int&gt; triangleNumbers(0); unsigned long long int totalFactors=0; unsigned long long int trialDivisors=1; unsigned long long int storer=0; int main() { triangleNumbers[0]=10000000000; triangleNumbers[1]=10000000002; triangleNumbers[2]=10000000005; triangleNumbers[3]=10000000009; triangleNumbers[4]=10000000014; //listed first few prime numbers above. j is set at 4 for this reason naturalNumberCount=5; //10000000014 is the 5th triangle number, and 5 is the 5th natural num //need this for recursive relation //5th triangle number = 4th triangle num + 5 (num + naturalNumberCount while(keepRunning) { for(trialDivisors;trialDivisors&lt;=(unsigned long long int)(sqrt(triangleNumbers[j]));trialDivisors++) { if(triangleNumbers[j]%trialDivisors==0) { totalFactors++; if(totalFactors&gt;499)//499 because the number itself will be a divisor of itself, so no need to check { keepRunning=false; break; } else { keepRunning=true; } } else { keepRunning=true; } } //need the below to generate and store the next triangle number (as next element of array) naturalNumberCount++;//for recursive relation storer=triangleNumbers[j];//store the (j+1)'th triangle number, since we are changing j itself j++;//raise j, we gonna add the next value triangleNumbers[j]=(storer+naturalNumberCount);//the new value (last triangle number + current natural) totalFactors=0;//reset total factors to preclude any carry-over } cout&lt;&lt;triangleNumbers[j]&lt;&lt;flush; return 0; } </code></pre>
0debug
static void pxa2xx_rtc_piupdate(PXA2xxRTCState *s) { int64_t rt = qemu_get_clock(rt_clock); if (s->rtsr & (1 << 15)) s->last_swcr += rt - s->last_pi; s->last_pi = rt; }
1threat
document.getElementById('input').innerHTML = user_input;
1threat
static int net_socket_connect_init(NetClientState *peer, const char *model, const char *name, const char *host_str) { socket_connect_data *c = g_new0(socket_connect_data, 1); int fd = -1; Error *local_error = NULL; c->peer = peer; c->model = g_strdup(model); c->name = g_strdup(name); c->saddr = socket_parse(host_str, &local_error); if (c->saddr == NULL) { goto err; } fd = socket_connect(c->saddr, net_socket_connected, c, &local_error); if (fd < 0) { goto err; } return 0; err: error_report_err(local_error); socket_connect_data_free(c); return -1; }
1threat
HTML doctype, how browser performs on reading doctype : <p>actually i was thinking how browser performs or knows when it reads an specific doctype and after reading doctype, is there a pattern present or build in the browser or it searches on internet to know how to display ?</p>
0debug
How to deploy ASP.NET Core UserSecrets to production : <p>I followed the <a href="https://docs.asp.net/en/latest/security/app-secrets.html" rel="noreferrer">Safe storage of app secrets during development</a> guide over on the asp.net docs during development but it does not describe how to use it when publishing to another machine for QA, Production, etc. What I figured it would do was insert them into the appsettings.json during publish but it does not. I ended up having to place my SendGrid keys and other sensitive information directly into the appsettings.json which really defeats the purpose of the app secrets.</p> <p>Is using app secrets the best way or is there another way to store API keys and SQL user/passwords in my configs?</p>
0debug
How could you simplify or improve this method that checks has_many association for change before looping through and setting a value on each? : Below the code happens before the model is saved, it checks through each answer option to see if the correct_answer is changed on any of the answers if so, it then looks for which was changed and was true. if self.answer_options.select{|a| a.correct_answer_changed?}.any? self.answer_options.each do |answer_option| if answer_option.correct_answer_changed? && !answer_option.correct_answer_was answer_option.correct_answer = true else answer_option.correct_answer = false end end end
0debug
void ff_xvmc_decode_mb(MpegEncContext *s) { XvMCMacroBlock *mv_block; struct xvmc_pix_fmt *render; int i, cbp, blocks_per_mb; const int mb_xy = s->mb_y * s->mb_stride + s->mb_x; if (s->encoding) { av_log(s->avctx, AV_LOG_ERROR, "XVMC doesn't support encoding!!!\n"); return; } if (!s->mb_intra) { s->last_dc[0] = s->last_dc[1] = s->last_dc[2] = 128 << s->intra_dc_precision; } s->mb_skipped = 0; s->current_picture.qscale_table[mb_xy] = s->qscale; render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2]; assert(render); assert(render->xvmc_id == AV_XVMC_ID); assert(render->mv_blocks); mv_block = &render->mv_blocks[render->start_mv_blocks_num + render->filled_mv_blocks_num]; mv_block->x = s->mb_x; mv_block->y = s->mb_y; mv_block->dct_type = s->interlaced_dct; if (s->mb_intra) { mv_block->macroblock_type = XVMC_MB_TYPE_INTRA; } else { mv_block->macroblock_type = XVMC_MB_TYPE_PATTERN; if (s->mv_dir & MV_DIR_FORWARD) { mv_block->macroblock_type |= XVMC_MB_TYPE_MOTION_FORWARD; mv_block->PMV[0][0][0] = s->mv[0][0][0]; mv_block->PMV[0][0][1] = s->mv[0][0][1]; mv_block->PMV[1][0][0] = s->mv[0][1][0]; mv_block->PMV[1][0][1] = s->mv[0][1][1]; } if (s->mv_dir & MV_DIR_BACKWARD) { mv_block->macroblock_type |= XVMC_MB_TYPE_MOTION_BACKWARD; mv_block->PMV[0][1][0] = s->mv[1][0][0]; mv_block->PMV[0][1][1] = s->mv[1][0][1]; mv_block->PMV[1][1][0] = s->mv[1][1][0]; mv_block->PMV[1][1][1] = s->mv[1][1][1]; } switch(s->mv_type) { case MV_TYPE_16X16: mv_block->motion_type = XVMC_PREDICTION_FRAME; break; case MV_TYPE_16X8: mv_block->motion_type = XVMC_PREDICTION_16x8; break; case MV_TYPE_FIELD: mv_block->motion_type = XVMC_PREDICTION_FIELD; if (s->picture_structure == PICT_FRAME) { mv_block->PMV[0][0][1] <<= 1; mv_block->PMV[1][0][1] <<= 1; mv_block->PMV[0][1][1] <<= 1; mv_block->PMV[1][1][1] <<= 1; } break; case MV_TYPE_DMV: mv_block->motion_type = XVMC_PREDICTION_DUAL_PRIME; if (s->picture_structure == PICT_FRAME) { mv_block->PMV[0][0][0] = s->mv[0][0][0]; mv_block->PMV[0][0][1] = s->mv[0][0][1] << 1; mv_block->PMV[0][1][0] = s->mv[0][0][0]; mv_block->PMV[0][1][1] = s->mv[0][0][1] << 1; mv_block->PMV[1][0][0] = s->mv[0][2][0]; mv_block->PMV[1][0][1] = s->mv[0][2][1] << 1; mv_block->PMV[1][1][0] = s->mv[0][3][0]; mv_block->PMV[1][1][1] = s->mv[0][3][1] << 1; } else { mv_block->PMV[0][1][0] = s->mv[0][2][0]; mv_block->PMV[0][1][1] = s->mv[0][2][1]; } break; default: assert(0); } mv_block->motion_vertical_field_select = 0; if (s->mv_type == MV_TYPE_FIELD || s->mv_type == MV_TYPE_16X8) { mv_block->motion_vertical_field_select |= s->field_select[0][0]; mv_block->motion_vertical_field_select |= s->field_select[1][0] << 1; mv_block->motion_vertical_field_select |= s->field_select[0][1] << 2; mv_block->motion_vertical_field_select |= s->field_select[1][1] << 3; } } mv_block->index = render->next_free_data_block_num; blocks_per_mb = 6; if (s->chroma_format >= 2) { blocks_per_mb = 4 + (1 << s->chroma_format); } cbp = 0; for (i = 0; i < blocks_per_mb; i++) { cbp += cbp; if (s->block_last_index[i] >= 0) cbp++; } if (s->flags & CODEC_FLAG_GRAY) { if (s->mb_intra) { for (i = 4; i < blocks_per_mb; i++) { memset(s->pblocks[i], 0, sizeof(*s->pblocks[i])); if (!render->unsigned_intra) *s->pblocks[i][0] = 1 << 10; } } else { cbp &= 0xf << (blocks_per_mb - 4); blocks_per_mb = 4; } } mv_block->coded_block_pattern = cbp; if (cbp == 0) mv_block->macroblock_type &= ~XVMC_MB_TYPE_PATTERN; for (i = 0; i < blocks_per_mb; i++) { if (s->block_last_index[i] >= 0) { if (s->mb_intra && (render->idct || !render->unsigned_intra)) *s->pblocks[i][0] -= 1 << 10; if (!render->idct) { s->dsp.idct(*s->pblocks[i]); } if (s->avctx->xvmc_acceleration == 1) { memcpy(&render->data_blocks[render->next_free_data_block_num*64], s->pblocks[i], sizeof(*s->pblocks[i])); } render->next_free_data_block_num++; } } render->filled_mv_blocks_num++; assert(render->filled_mv_blocks_num <= render->allocated_mv_blocks); assert(render->next_free_data_block_num <= render->allocated_data_blocks); if (render->filled_mv_blocks_num == render->allocated_mv_blocks) ff_mpeg_draw_horiz_band(s, 0, 0); }
1threat
static inline void RENAME(rgb32to15)(const uint8_t *src, uint8_t *dst, unsigned src_size) { const uint8_t *s = src; const uint8_t *end; #ifdef HAVE_MMX const uint8_t *mm_end; #endif uint16_t *d = (uint16_t *)dst; end = s + src_size; #ifdef HAVE_MMX mm_end = end - 15; #if 1 asm volatile( "movq %3, %%mm5 \n\t" "movq %4, %%mm6 \n\t" "movq %5, %%mm7 \n\t" ".balign 16 \n\t" "1: \n\t" PREFETCH" 32(%1) \n\t" "movd (%1), %%mm0 \n\t" "movd 4(%1), %%mm3 \n\t" "punpckldq 8(%1), %%mm0 \n\t" "punpckldq 12(%1), %%mm3 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm3, %%mm4 \n\t" "pand %%mm6, %%mm0 \n\t" "pand %%mm6, %%mm3 \n\t" "pmaddwd %%mm7, %%mm0 \n\t" "pmaddwd %%mm7, %%mm3 \n\t" "pand %%mm5, %%mm1 \n\t" "pand %%mm5, %%mm4 \n\t" "por %%mm1, %%mm0 \n\t" "por %%mm4, %%mm3 \n\t" "psrld $6, %%mm0 \n\t" "pslld $10, %%mm3 \n\t" "por %%mm3, %%mm0 \n\t" MOVNTQ" %%mm0, (%0) \n\t" "addl $16, %1 \n\t" "addl $8, %0 \n\t" "cmpl %2, %1 \n\t" " jb 1b \n\t" : "+r" (d), "+r"(s) : "r" (mm_end), "m" (mask3215g), "m" (mask3216br), "m" (mul3215) ); #else __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); __asm __volatile( "movq %0, %%mm7\n\t" "movq %1, %%mm6\n\t" ::"m"(red_15mask),"m"(green_15mask)); while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movd %1, %%mm0\n\t" "movd 4%1, %%mm3\n\t" "punpckldq 8%1, %%mm0\n\t" "punpckldq 12%1, %%mm3\n\t" "movq %%mm0, %%mm1\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm3, %%mm4\n\t" "movq %%mm3, %%mm5\n\t" "psrlq $3, %%mm0\n\t" "psrlq $3, %%mm3\n\t" "pand %2, %%mm0\n\t" "pand %2, %%mm3\n\t" "psrlq $6, %%mm1\n\t" "psrlq $6, %%mm4\n\t" "pand %%mm6, %%mm1\n\t" "pand %%mm6, %%mm4\n\t" "psrlq $9, %%mm2\n\t" "psrlq $9, %%mm5\n\t" "pand %%mm7, %%mm2\n\t" "pand %%mm7, %%mm5\n\t" "por %%mm1, %%mm0\n\t" "por %%mm4, %%mm3\n\t" "por %%mm2, %%mm0\n\t" "por %%mm5, %%mm3\n\t" "psllq $16, %%mm3\n\t" "por %%mm3, %%mm0\n\t" MOVNTQ" %%mm0, %0\n\t" :"=m"(*d):"m"(*s),"m"(blue_15mask):"memory"); d += 4; s += 16; } #endif __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { const int src= *((uint32_t*)s)++; *d++ = ((src&0xFF)>>3) + ((src&0xF800)>>6) + ((src&0xF80000)>>9); } }
1threat
Area links don't generate in asp.net-core-mvc : <p>Following this guide I've been creating an Admin area: <a href="https://docs.asp.net/en/latest/mvc/controllers/areas.html" rel="noreferrer">https://docs.asp.net/en/latest/mvc/controllers/areas.html</a></p> <p>I can navigate to the admin pages by directly typing in the url, however I can't get links to generate</p> <p>I've tried placing the following on the Admin index.cshtml:</p> <pre><code>&lt;p&gt;&lt;a asp-action="Index"&gt;Admin Index&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a asp-controller="Home" asp-action="Index"&gt;Admin Index&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a asp-area="Admin" asp-controller="Home" asp-action="Index"&gt;Admin Index&lt;/a&gt;&lt;/p&gt; </code></pre> <p>Yet the all end up being non clickable anchors (no href)</p> <p>In fact, when I view source, I actually still see the "asp-action" etc tags</p> <pre><code>&lt;a asp-action="Index"&gt;Admin Index&lt;/a&gt; </code></pre> <p>MVC doesn't seem to be processing the link helper tags?</p> <p>Any idea what I've missed? Perhaps a configuration step somewhere?</p> <p>Thanks</p>
0debug
Using material-ui with redux? : <p>I'm currently rendering main component this way: </p> <pre><code> ReactDOM.render( &lt;Provider store = {store}&gt; {getRoutes(checkAuth)} &lt;/Provider&gt;, document.getElementById('app') ) </code></pre> <p>the docs state to use MuiThemeProvider to wrap my app component. I am alrady using Provider to wrap, any suggestions as to how to use material-ui ina redux app. I am trying to add material-ui in a redux-form Field as below:</p> <pre><code>import React, { PropTypes } from 'react' import {default as ReactModal} from 'react-modal' import {Field, reduxForm} from 'redux-form' import {TextField} from 'material-ui' const customStyles = { overlay: { position: 'fixed', top: 0, left: 0, right: 0, bottom: 0, backgroundColor: 'rgba(0, 0, 0, 0.55)' }, content: { top: '50%', left: '50%', right: 'auto', bottom: 'auto', marginRight: '-50%', transform: 'translate(-50%, -50%)' } } const modalForm = (props) =&gt; { // console.log(props) const { handleSubmit, pristine, reset, submitting } = props return ( &lt;div&gt; &lt;button onClick= {props.openModal}&gt;Duck&lt;/button&gt; &lt;ReactModal isOpen={props.isOpen} style={customStyles} onRequestClose={props.closeModal}&gt; &lt;h1&gt;Compose New Duck&lt;/h1&gt; &lt;form onSubmit= {handleSubmit}&gt; &lt;label&gt;duck&lt;/label&gt; &lt;Field name ='duck' component = {(duck) =&gt; &lt;TextField hintText = 'Enter Duck' floatingLabelText = 'Enter Duck here' {...duck} /&gt;} /&gt; &lt;/form&gt; &lt;button onClick= {props.closeModal}&gt;Close Modal...&lt;/button&gt; &lt;/ReactModal&gt; &lt;/div&gt; ) } export default reduxForm({ form: 'duckModal' // a unique identifier for this form })(modalForm) </code></pre>
0debug
static void test_io_channel_unix_fd_pass(void) { SocketAddress *listen_addr = g_new0(SocketAddress, 1); SocketAddress *connect_addr = g_new0(SocketAddress, 1); QIOChannel *src, *dst; int testfd; int fdsend[3]; int *fdrecv = NULL; size_t nfdrecv = 0; size_t i; char bufsend[12], bufrecv[12]; struct iovec iosend[1], iorecv[1]; #define TEST_SOCKET "test-io-channel-socket.sock" #define TEST_FILE "test-io-channel-socket.txt" testfd = open(TEST_FILE, O_RDWR|O_TRUNC|O_CREAT, 0700); g_assert(testfd != -1); fdsend[0] = testfd; fdsend[1] = testfd; fdsend[2] = testfd; listen_addr->type = SOCKET_ADDRESS_KIND_UNIX; listen_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); listen_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET); connect_addr->type = SOCKET_ADDRESS_KIND_UNIX; connect_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); connect_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET); test_io_channel_setup_sync(listen_addr, connect_addr, &src, &dst); memcpy(bufsend, "Hello World", G_N_ELEMENTS(bufsend)); iosend[0].iov_base = bufsend; iosend[0].iov_len = G_N_ELEMENTS(bufsend); iorecv[0].iov_base = bufrecv; iorecv[0].iov_len = G_N_ELEMENTS(bufrecv); g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); qio_channel_writev_full(src, iosend, G_N_ELEMENTS(iosend), fdsend, G_N_ELEMENTS(fdsend), &error_abort); qio_channel_readv_full(dst, iorecv, G_N_ELEMENTS(iorecv), &fdrecv, &nfdrecv, &error_abort); g_assert(nfdrecv == G_N_ELEMENTS(fdsend)); for (i = 0; i < nfdrecv; i++) { g_assert_cmpint(fdrecv[i], !=, testfd); } g_assert_cmpint(fdrecv[0], !=, fdrecv[1]); g_assert_cmpint(fdrecv[0], !=, fdrecv[2]); g_assert_cmpint(fdrecv[1], !=, fdrecv[2]); g_assert(memcmp(bufsend, bufrecv, G_N_ELEMENTS(bufsend)) == 0); g_assert(write(fdrecv[0], bufsend, G_N_ELEMENTS(bufsend)) == G_N_ELEMENTS(bufsend)); memset(bufrecv, 0, G_N_ELEMENTS(bufrecv)); g_assert(lseek(testfd, 0, SEEK_SET) == 0); g_assert(read(testfd, bufrecv, G_N_ELEMENTS(bufrecv)) == G_N_ELEMENTS(bufrecv)); g_assert(memcmp(bufsend, bufrecv, G_N_ELEMENTS(bufsend)) == 0); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); qapi_free_SocketAddress(listen_addr); qapi_free_SocketAddress(connect_addr); unlink(TEST_SOCKET); unlink(TEST_FILE); close(testfd); for (i = 0; i < nfdrecv; i++) { close(fdrecv[i]); } g_free(fdrecv); }
1threat
window.location.href = 'http://attack.com?user=' + user_input;
1threat
C++ double act as float? : <p>C++ </p> <pre><code>float f = 0.123456789; double d = 0.123456789; cout &lt;&lt; "float = " &lt;&lt; f &lt;&lt; endl; cout &lt;&lt; "double = " &lt;&lt; d &lt;&lt; endl; </code></pre> <p>Output </p> <pre><code>float = 0.123457 double = 0.123457 </code></pre> <p>Why?<br> How to use <em>double</em> and <em>long double</em>?<br> Is there a variable larger than <em>long double</em>?</p>
0debug
How do I wait for certain user response in Discord.net? : After asking a question in a channel await channel.SendMessageAsync("question?"); how do I wait for a certain response? (eg. yes, no) I've tried string input; bool done = false; while(!done) { input = channel.GetMessageAsync(channel.Id).ToString(); if (String.Compare(input, "yes") == 0) { //code here done = true; } else if (String.Compare(input, "no") == 0) { //code here done = true; } } but it doesn't seem to work.
0debug
static inline void idct4row(DCTELEM *row) { int c0, c1, c2, c3, a0, a1, a2, a3; a0 = row[0]; a1 = row[1]; a2 = row[2]; a3 = row[3]; c0 = (a0 + a2)*R3 + (1 << (R_SHIFT - 1)); c2 = (a0 - a2)*R3 + (1 << (R_SHIFT - 1)); c1 = a1 * R1 + a3 * R2; c3 = a1 * R2 - a3 * R1; row[0]= (c0 + c1) >> R_SHIFT; row[1]= (c2 + c3) >> R_SHIFT; row[2]= (c2 - c3) >> R_SHIFT; row[3]= (c0 - c1) >> R_SHIFT; }
1threat
crash when i click a button : I have a button to get to a new Activity, but the app crash when i click on it. what can i do to fix this. This is the code i juse for opening the Activity <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> package no.vfk.vfkhakkespettboka; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class Programvare extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_programvare); Button home = (Button)findViewById(R.id.home); home.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent startIntent = new Intent (getApplicationContext(), MainActivity.class); // Show how to pass Information to another Activity startActivity(startIntent); } }); } } <!-- end snippet -->
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Suggest data-structure for this use case : <p>Language: Java</p> <p>I have a fixed pool of threads running, all of who have to ask a question and take user input in the form of (Yes/No) at some point, which would basically decide its further execution. Since I don't want to intermingle the output questions from multiple threads, there will be another task/thread running (single) at fixed rate (Further referred as main thread), which can be used to get the questions and display it to the user. The number of questions asked by the thread may vary and once the question gets a response, it is no longer needed again.</p> <p>At this point my current implementation uses <code>LinkedTransferQueue</code>, which basically allows me to share data between main thread and question thread without having to wait for polling.</p> <p>I have created a synchronized <code>ArrayList</code> of a <code>Task</code> class, each of which contains a <code>LinkedTransferQueue&lt;String&gt;</code>. The thread creates a new <code>Task</code> and adds its question into its queue with <code>transfer()</code> method. The main thread picks them up and gets response from user, which is put back to the same queue. The advantage here is that <code>LinkedTransferQueue</code> offers a <code>take()</code> method that allows me to wait without polling.</p> <p>Other approaches include using a <code>volatile shared</code> variable, whose value is updated by main thread and is constantly being polled by the other thread. </p> <p>Please suggest if any other data structure is available for such a use case. This is not exactly a producer-consumer problem from what I can understand. Post questions if you have any other concerns.</p> <p>Thanks!!</p>
0debug
float64 float64_muladd(float64 a, float64 b, float64 c, int flags STATUS_PARAM) { flag aSign, bSign, cSign, zSign; int_fast16_t aExp, bExp, cExp, pExp, zExp, expDiff; uint64_t aSig, bSig, cSig; flag pInf, pZero, pSign; uint64_t pSig0, pSig1, cSig0, cSig1, zSig0, zSig1; int shiftcount; flag signflip, infzero; a = float64_squash_input_denormal(a STATUS_VAR); b = float64_squash_input_denormal(b STATUS_VAR); c = float64_squash_input_denormal(c STATUS_VAR); aSig = extractFloat64Frac(a); aExp = extractFloat64Exp(a); aSign = extractFloat64Sign(a); bSig = extractFloat64Frac(b); bExp = extractFloat64Exp(b); bSign = extractFloat64Sign(b); cSig = extractFloat64Frac(c); cExp = extractFloat64Exp(c); cSign = extractFloat64Sign(c); infzero = ((aExp == 0 && aSig == 0 && bExp == 0x7ff && bSig == 0) || (aExp == 0x7ff && aSig == 0 && bExp == 0 && bSig == 0)); if (((aExp == 0x7ff) && aSig) || ((bExp == 0x7ff) && bSig) || ((cExp == 0x7ff) && cSig)) { return propagateFloat64MulAddNaN(a, b, c, infzero STATUS_VAR); } if (infzero) { float_raise(float_flag_invalid STATUS_VAR); return float64_default_nan; } if (flags & float_muladd_negate_c) { cSign ^= 1; } signflip = (flags & float_muladd_negate_result) ? 1 : 0; pSign = aSign ^ bSign; if (flags & float_muladd_negate_product) { pSign ^= 1; } pInf = (aExp == 0x7ff) || (bExp == 0x7ff); pZero = ((aExp | aSig) == 0) || ((bExp | bSig) == 0); if (cExp == 0x7ff) { if (pInf && (pSign ^ cSign)) { float_raise(float_flag_invalid STATUS_VAR); return float64_default_nan; } return packFloat64(cSign ^ signflip, 0x7ff, 0); } if (pInf) { return packFloat64(pSign ^ signflip, 0x7ff, 0); } if (pZero) { if (cExp == 0) { if (cSig == 0) { if (pSign == cSign) { zSign = pSign; } else if (STATUS(float_rounding_mode) == float_round_down) { zSign = 1; } else { zSign = 0; } return packFloat64(zSign ^ signflip, 0, 0); } if (STATUS(flush_to_zero)) { float_raise(float_flag_output_denormal STATUS_VAR); return packFloat64(cSign ^ signflip, 0, 0); } } return packFloat64(cSign ^ signflip, cExp, cSig); } if (aExp == 0) { normalizeFloat64Subnormal(aSig, &aExp, &aSig); } if (bExp == 0) { normalizeFloat64Subnormal(bSig, &bExp, &bSig); } pExp = aExp + bExp - 0x3fe; aSig = (aSig | LIT64(0x0010000000000000))<<10; bSig = (bSig | LIT64(0x0010000000000000))<<11; mul64To128(aSig, bSig, &pSig0, &pSig1); if ((int64_t)(pSig0 << 1) >= 0) { shortShift128Left(pSig0, pSig1, 1, &pSig0, &pSig1); pExp--; } zSign = pSign ^ signflip; if (cExp == 0) { if (!cSig) { shift128RightJamming(pSig0, pSig1, 64, &pSig0, &pSig1); return roundAndPackFloat64(zSign, pExp - 1, pSig1 STATUS_VAR); } normalizeFloat64Subnormal(cSig, &cExp, &cSig); } cSig0 = cSig << (126 - 64 - 52); cSig1 = 0; cSig0 |= LIT64(0x4000000000000000); expDiff = pExp - cExp; if (pSign == cSign) { if (expDiff > 0) { shift128RightJamming(cSig0, cSig1, expDiff, &cSig0, &cSig1); zExp = pExp; } else if (expDiff < 0) { shift128RightJamming(pSig0, pSig1, -expDiff, &pSig0, &pSig1); zExp = cExp; } else { zExp = cExp; } add128(pSig0, pSig1, cSig0, cSig1, &zSig0, &zSig1); if ((int64_t)zSig0 < 0) { shift128RightJamming(zSig0, zSig1, 1, &zSig0, &zSig1); } else { zExp--; } shift128RightJamming(zSig0, zSig1, 64, &zSig0, &zSig1); return roundAndPackFloat64(zSign, zExp, zSig1 STATUS_VAR); } else { if (expDiff > 0) { shift128RightJamming(cSig0, cSig1, expDiff, &cSig0, &cSig1); sub128(pSig0, pSig1, cSig0, cSig1, &zSig0, &zSig1); zExp = pExp; } else if (expDiff < 0) { shift128RightJamming(pSig0, pSig1, -expDiff, &pSig0, &pSig1); sub128(cSig0, cSig1, pSig0, pSig1, &zSig0, &zSig1); zExp = cExp; zSign ^= 1; } else { zExp = pExp; if (lt128(cSig0, cSig1, pSig0, pSig1)) { sub128(pSig0, pSig1, cSig0, cSig1, &zSig0, &zSig1); } else if (lt128(pSig0, pSig1, cSig0, cSig1)) { sub128(cSig0, cSig1, pSig0, pSig1, &zSig0, &zSig1); zSign ^= 1; } else { zSign = signflip; if (STATUS(float_rounding_mode) == float_round_down) { zSign ^= 1; } return packFloat64(zSign, 0, 0); } } --zExp; if (zSig0) { shiftcount = countLeadingZeros64(zSig0) - 1; shortShift128Left(zSig0, zSig1, shiftcount, &zSig0, &zSig1); if (zSig1) { zSig0 |= 1; } zExp -= shiftcount; } else { shiftcount = countLeadingZeros64(zSig1) - 1; zSig0 = zSig1 << shiftcount; zExp -= (shiftcount + 64); } return roundAndPackFloat64(zSign, zExp, zSig0 STATUS_VAR); } }
1threat
void qmp_block_job_set_speed(const char *device, int64_t value, Error **errp) { BlockJob *job = find_block_job(device); if (!job) { error_set(errp, QERR_DEVICE_NOT_ACTIVE, device); return; } if (block_job_set_speed(job, value) < 0) { error_set(errp, QERR_NOT_SUPPORTED); } }
1threat
static void convert_matrix(int *qmat, UINT16 *qmat16, const UINT16 *quant_matrix, int qscale) { int i; if (av_fdct == jpeg_fdct_ifast) { for(i=0;i<64;i++) { qmat[block_permute_op(i)] = (int)((UINT64_C(1) << (QMAT_SHIFT + 11)) / (aanscales[i] * qscale * quant_matrix[block_permute_op(i)])); } } else { for(i=0;i<64;i++) { qmat[i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[i]); qmat16[i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[block_permute_op(i)]); } } }
1threat
How to properly extract content from object converted to string c#? : <p>I am writing Unit-Tests and am trying to extract a value from a HttpResponseMessage. I am trying to get the value <code>resultCount</code>. Currenly my string looks like this:<code>"{"resultCount":5,"works":null,"success::false,"errors"null}"</code></p> <p>Any ideas how I can get to the 'resultCount:5'</p>
0debug
VB getting the last 3 digit number in textbox : <p>i have 16textbox and one command button for my userform and the textbox 1 are the one that i use to search for the data and display it from other textbox.</p> <p>my question is.</p> <p>it is possible for textbox1 to search only the last 3 digit number instead of 8 digit? wish can some answer my question.</p> <p>thank you</p>
0debug
Understanding code for custom in-place modification function? : <p>I came across this post: <a href="http://r.789695.n4.nabble.com/speeding-up-perception-tp3640920p3646694.html" rel="noreferrer">http://r.789695.n4.nabble.com/speeding-up-perception-tp3640920p3646694.html</a> from Matt Dowle, discussing some early? implementation ideas of the <code>data.table</code> package.</p> <p>He uses the following code:</p> <pre><code>x = list(a = 1:10000, b = 1:10000) class(x) = "newclass" "[&lt;-.newclass" = function(x,i,j,value) x # i.e. do nothing tracemem(x) x[1, 2] = 42L </code></pre> <p><strong>Specifically I am looking at:</strong></p> <pre><code>"[&lt;-.newclass" = function(x,i,j,value) x </code></pre> <p>I am trying to understand what is done there and how i could use this notation.</p> <p>It looks to me like:</p> <ul> <li>i is the row index</li> <li>j is column index</li> <li>value is the value to be assigned</li> <li>x is the object under consideration</li> </ul> <p>My best guess would therefore be that i define a custom function for in place modification (for a given class).</p> <p><code>[&lt;-.newclass</code> is in class modification for class newclass.</p> <p>Understanding what happens: Usually the following code should return an error:</p> <pre><code>x = list(a = 1:10000, b = 1:10000) x[1, 2] = 42L </code></pre> <p>so i guess the sample code does not have any practical use.</p> <p><strong>Attempt to use the logic:</strong></p> <p>A simple non-sense try would be to square the value to be inserted:</p> <pre><code>x[i, j] &lt;- value^2 </code></pre> <p>Full try:</p> <pre><code>&gt; x = matrix(1:9, 3, 3) &gt; class(x) = "newclass" &gt; "[&lt;-.newclass" = function(x, i, j, value) x[i, j] &lt;- value^2 # i.e. do something &gt; x[1, 2] = 9 Error: C stack usage 19923536 is too close to the limit </code></pre> <p>This doesnt seem to work.</p> <p><strong>My question(s):</strong></p> <pre><code>"[&lt;-.newclass" = function(x,i,j,value) x </code></pre> <p>How exactly does this notation work and how would I use it?</p> <p>(I add data.table tag since the linked discussion is about the "by-reference" in place modification in data.table, i think).</p>
0debug
static int ehci_process_itd(EHCIState *ehci, EHCIitd *itd, uint32_t addr) { USBDevice *dev; USBEndpoint *ep; uint32_t i, len, pid, dir, devaddr, endp; uint32_t pg, off, ptr1, ptr2, max, mult; ehci->periodic_sched_active = PERIODIC_ACTIVE; dir =(itd->bufptr[1] & ITD_BUFPTR_DIRECTION); devaddr = get_field(itd->bufptr[0], ITD_BUFPTR_DEVADDR); endp = get_field(itd->bufptr[0], ITD_BUFPTR_EP); max = get_field(itd->bufptr[1], ITD_BUFPTR_MAXPKT); mult = get_field(itd->bufptr[2], ITD_BUFPTR_MULT); for(i = 0; i < 8; i++) { if (itd->transact[i] & ITD_XACT_ACTIVE) { pg = get_field(itd->transact[i], ITD_XACT_PGSEL); off = itd->transact[i] & ITD_XACT_OFFSET_MASK; len = get_field(itd->transact[i], ITD_XACT_LENGTH); if (len > max * mult) { len = max * mult; } if (len > BUFF_SIZE || pg > 6) { return -1; } ptr1 = (itd->bufptr[pg] & ITD_BUFPTR_MASK); qemu_sglist_init(&ehci->isgl, ehci->device, 2, ehci->as); if (off + len > 4096) { if (pg == 6) { return -1; } ptr2 = (itd->bufptr[pg + 1] & ITD_BUFPTR_MASK); uint32_t len2 = off + len - 4096; uint32_t len1 = len - len2; qemu_sglist_add(&ehci->isgl, ptr1 + off, len1); qemu_sglist_add(&ehci->isgl, ptr2, len2); } else { qemu_sglist_add(&ehci->isgl, ptr1 + off, len); } pid = dir ? USB_TOKEN_IN : USB_TOKEN_OUT; dev = ehci_find_device(ehci, devaddr); ep = usb_ep_get(dev, pid, endp); if (ep && ep->type == USB_ENDPOINT_XFER_ISOC) { usb_packet_setup(&ehci->ipacket, pid, ep, 0, addr, false, (itd->transact[i] & ITD_XACT_IOC) != 0); usb_packet_map(&ehci->ipacket, &ehci->isgl); usb_handle_packet(dev, &ehci->ipacket); usb_packet_unmap(&ehci->ipacket, &ehci->isgl); } else { DPRINTF("ISOCH: attempt to addess non-iso endpoint\n"); ehci->ipacket.status = USB_RET_NAK; ehci->ipacket.actual_length = 0; } switch (ehci->ipacket.status) { case USB_RET_SUCCESS: break; default: fprintf(stderr, "Unexpected iso usb result: %d\n", ehci->ipacket.status); case USB_RET_IOERROR: case USB_RET_NODEV: if (dir) { itd->transact[i] |= ITD_XACT_XACTERR; ehci_raise_irq(ehci, USBSTS_ERRINT); } break; case USB_RET_BABBLE: itd->transact[i] |= ITD_XACT_BABBLE; ehci_raise_irq(ehci, USBSTS_ERRINT); break; case USB_RET_NAK: ehci->ipacket.actual_length = 0; break; } if (!dir) { set_field(&itd->transact[i], len - ehci->ipacket.actual_length, ITD_XACT_LENGTH); } else { set_field(&itd->transact[i], ehci->ipacket.actual_length, ITD_XACT_LENGTH); } if (itd->transact[i] & ITD_XACT_IOC) { ehci_raise_irq(ehci, USBSTS_INT); } itd->transact[i] &= ~ITD_XACT_ACTIVE; } } return 0; }
1threat
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 : <p>I've build a react-native application and suddenly I get this error message on my terminal during run of the command react-native run-ios. The same code work fine 10 minutes ago and suddenly I get this error message. Please help...</p>
0debug
int ff_dca_lbr_parse(DCALbrDecoder *s, uint8_t *data, DCAExssAsset *asset) { struct { LBRChunk lfe; LBRChunk tonal; LBRChunk tonal_grp[5]; LBRChunk grid1[DCA_LBR_CHANNELS / 2]; LBRChunk hr_grid[DCA_LBR_CHANNELS / 2]; LBRChunk ts1[DCA_LBR_CHANNELS / 2]; LBRChunk ts2[DCA_LBR_CHANNELS / 2]; } chunk = { }; GetByteContext gb; int i, ch, sb, sf, ret, group, chunk_id, chunk_len; bytestream2_init(&gb, data + asset->lbr_offset, asset->lbr_size); if (bytestream2_get_be32(&gb) != DCA_SYNCWORD_LBR) { av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR sync word\n"); return AVERROR_INVALIDDATA; } switch (bytestream2_get_byte(&gb)) { case LBR_HEADER_SYNC_ONLY: if (!s->sample_rate) { av_log(s->avctx, AV_LOG_ERROR, "LBR decoder not initialized\n"); return AVERROR_INVALIDDATA; } break; case LBR_HEADER_DECODER_INIT: if ((ret = parse_decoder_init(s, &gb)) < 0) { s->sample_rate = 0; return ret; } break; default: av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR header type\n"); return AVERROR_INVALIDDATA; } chunk_id = bytestream2_get_byte(&gb); chunk_len = (chunk_id & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb); if (chunk_len > bytestream2_get_bytes_left(&gb)) { chunk_len = bytestream2_get_bytes_left(&gb); av_log(s->avctx, AV_LOG_WARNING, "LBR frame chunk was truncated\n"); if (s->avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } bytestream2_init(&gb, gb.buffer, chunk_len); switch (chunk_id & 0x7f) { case LBR_CHUNK_FRAME: if (s->avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)) { int checksum = bytestream2_get_be16(&gb); uint16_t res = chunk_id; res += (chunk_len >> 8) & 0xff; res += chunk_len & 0xff; for (i = 0; i < chunk_len - 2; i++) res += gb.buffer[i]; if (checksum != res) { av_log(s->avctx, AV_LOG_WARNING, "Invalid LBR checksum\n"); if (s->avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } } else { bytestream2_skip(&gb, 2); } break; case LBR_CHUNK_FRAME_NO_CSUM: break; default: av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR frame chunk ID\n"); return AVERROR_INVALIDDATA; } memset(s->quant_levels, 0, sizeof(s->quant_levels)); memset(s->sb_indices, 0xff, sizeof(s->sb_indices)); memset(s->sec_ch_sbms, 0, sizeof(s->sec_ch_sbms)); memset(s->sec_ch_lrms, 0, sizeof(s->sec_ch_lrms)); memset(s->ch_pres, 0, sizeof(s->ch_pres)); memset(s->grid_1_scf, 0, sizeof(s->grid_1_scf)); memset(s->grid_2_scf, 0, sizeof(s->grid_2_scf)); memset(s->grid_3_avg, 0, sizeof(s->grid_3_avg)); memset(s->grid_3_scf, 0, sizeof(s->grid_3_scf)); memset(s->grid_3_pres, 0, sizeof(s->grid_3_pres)); memset(s->tonal_scf, 0, sizeof(s->tonal_scf)); memset(s->lfe_data, 0, sizeof(s->lfe_data)); s->part_stereo_pres = 0; s->framenum = (s->framenum + 1) & 31; for (ch = 0; ch < s->nchannels; ch++) { for (sb = 0; sb < s->nsubbands / 4; sb++) { s->part_stereo[ch][sb][0] = s->part_stereo[ch][sb][4]; s->part_stereo[ch][sb][4] = 16; } } memset(s->lpc_coeff[s->framenum & 1], 0, sizeof(s->lpc_coeff[0])); for (group = 0; group < 5; group++) { for (sf = 0; sf < 1 << group; sf++) { int sf_idx = ((s->framenum << group) + sf) & 31; s->tonal_bounds[group][sf_idx][0] = s->tonal_bounds[group][sf_idx][1] = s->ntones; } } while (bytestream2_get_bytes_left(&gb) > 0) { chunk_id = bytestream2_get_byte(&gb); chunk_len = (chunk_id & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb); chunk_id &= 0x7f; if (chunk_len > bytestream2_get_bytes_left(&gb)) { chunk_len = bytestream2_get_bytes_left(&gb); av_log(s->avctx, AV_LOG_WARNING, "LBR chunk %#x was truncated\n", chunk_id); if (s->avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } switch (chunk_id) { case LBR_CHUNK_LFE: chunk.lfe.len = chunk_len; chunk.lfe.data = gb.buffer; break; case LBR_CHUNK_SCF: case LBR_CHUNK_TONAL: case LBR_CHUNK_TONAL_SCF: chunk.tonal.id = chunk_id; chunk.tonal.len = chunk_len; chunk.tonal.data = gb.buffer; break; case LBR_CHUNK_TONAL_GRP_1: case LBR_CHUNK_TONAL_GRP_2: case LBR_CHUNK_TONAL_GRP_3: case LBR_CHUNK_TONAL_GRP_4: case LBR_CHUNK_TONAL_GRP_5: i = LBR_CHUNK_TONAL_GRP_5 - chunk_id; chunk.tonal_grp[i].id = i; chunk.tonal_grp[i].len = chunk_len; chunk.tonal_grp[i].data = gb.buffer; break; case LBR_CHUNK_TONAL_SCF_GRP_1: case LBR_CHUNK_TONAL_SCF_GRP_2: case LBR_CHUNK_TONAL_SCF_GRP_3: case LBR_CHUNK_TONAL_SCF_GRP_4: case LBR_CHUNK_TONAL_SCF_GRP_5: i = LBR_CHUNK_TONAL_SCF_GRP_5 - chunk_id; chunk.tonal_grp[i].id = i; chunk.tonal_grp[i].len = chunk_len; chunk.tonal_grp[i].data = gb.buffer; break; case LBR_CHUNK_RES_GRID_LR: case LBR_CHUNK_RES_GRID_LR + 1: case LBR_CHUNK_RES_GRID_LR + 2: i = chunk_id - LBR_CHUNK_RES_GRID_LR; chunk.grid1[i].len = chunk_len; chunk.grid1[i].data = gb.buffer; break; case LBR_CHUNK_RES_GRID_HR: case LBR_CHUNK_RES_GRID_HR + 1: case LBR_CHUNK_RES_GRID_HR + 2: i = chunk_id - LBR_CHUNK_RES_GRID_HR; chunk.hr_grid[i].len = chunk_len; chunk.hr_grid[i].data = gb.buffer; break; case LBR_CHUNK_RES_TS_1: case LBR_CHUNK_RES_TS_1 + 1: case LBR_CHUNK_RES_TS_1 + 2: i = chunk_id - LBR_CHUNK_RES_TS_1; chunk.ts1[i].len = chunk_len; chunk.ts1[i].data = gb.buffer; break; case LBR_CHUNK_RES_TS_2: case LBR_CHUNK_RES_TS_2 + 1: case LBR_CHUNK_RES_TS_2 + 2: i = chunk_id - LBR_CHUNK_RES_TS_2; chunk.ts2[i].len = chunk_len; chunk.ts2[i].data = gb.buffer; break; } bytestream2_skip(&gb, chunk_len); } ret = parse_lfe_chunk(s, &chunk.lfe); ret |= parse_tonal_chunk(s, &chunk.tonal); for (i = 0; i < 5; i++) ret |= parse_tonal_group(s, &chunk.tonal_grp[i]); for (i = 0; i < (s->nchannels + 1) / 2; i++) { int ch1 = i * 2; int ch2 = FFMIN(ch1 + 1, s->nchannels - 1); if (parse_grid_1_chunk (s, &chunk.grid1 [i], ch1, ch2) < 0 || parse_high_res_grid(s, &chunk.hr_grid[i], ch1, ch2) < 0) { ret = -1; continue; } if (!chunk.grid1[i].len || !chunk.hr_grid[i].len || !chunk.ts1[i].len) continue; if (parse_ts1_chunk(s, &chunk.ts1[i], ch1, ch2) < 0 || parse_ts2_chunk(s, &chunk.ts2[i], ch1, ch2) < 0) { ret = -1; continue; } } if (ret < 0 && (s->avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; return 0; }
1threat
iOS 11 black bar appears on navigation bar when pushing view controller : <p>I have this weird bug only in iOS 11, in lower iOS, everything works fine. The problem is that whenever pushing to a view controller, there is a black space appears on top of the navigation bar. Has anyone else experienced this problem and how to fix it?</p> <p><a href="https://i.stack.imgur.com/1MFU1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1MFU1.png" alt="Pushing "></a></p>
0debug
How can I build a PROPER constructor and destructor? : Question #1: How can I build a constructor set the value for (R,PoF,PoR)? I am trying to understand how constructor works......but I guess I don't quite get it...... Question #2: Can I build destructor in this way, instead of the way I used in my program. Circle::~Circle() { std::cout << "The fence would cost " << SwimmingPool.PerimeterP(r) << std::endl; std::cout << "The road would cost " << SwimmingPool.AreaP(r) << std::endl; std::cout << "Present by FF" << std::endl; } I just want the cost to come out by itself, but I don't know how should I create destructor to do so. Here is my full code: #include "stdafx.h" #include "iostream" const double PI = 3.1415926; class Circle { public: Circle(); double AreaP(int r); double PerimeterP(int r); ~Circle(); private: int R; int PoF; int PoR; }; double Circle::AreaP(int r) { return ((r + R)*(r + R) - r*r)*PI*PoR; } double Circle::PerimeterP(int r) { return (r + R) * 2 * PI*PoF; } Circle::Circle() { int R = 3; int PoF = 35; int PoR = 20; } Circle::~Circle() { std::cout << "Present by FF" << std::endl; } int main() { int r; Circle SwimmingPool; std::cout << "Please input the radius of the Swimming Pool." << std::endl; std::cin >> r; std::cout << "The fence would cost " << SwimmingPool.PerimeterP(r) << std::endl; std::cout << "The road would cost " << SwimmingPool.AreaP(r) << std::endl; return 0; } Thanks for viewing and answering questions.
0debug
Are local variables necessary? : <p>My understanding is the C calling convention places arguments on the stack prior to calling a function. These arguments could be accessed within the function through explicit stack parameters using <code>EBP</code> as a reference such as <code>[EBP + 8]</code> or <code>[EBP + 12]</code>. </p> <p>My question is if it could be accessed this way, why are local variables necessary? - couldn't a function just work with the arguments directly? Is it just for cases where the function has no parameters, but still initializes local variables for internal use?</p>
0debug
Logstash multiple inputs multiple outputs : <p>I'm trying to sync data between MySQL and Elasticsearch with Logstash. </p> <p>I set multiple jdbc inputs and multiple outputs to different elasticsearch indexes ... and something I am doing wrong because everything is going to the else block.</p> <p>Here is my config:</p> <pre><code> input { jdbc { jdbc_connection_string =&gt; "jdbc:mysql:127.0.0.1:3306/whatever" jdbc_user =&gt; "xxx" jdbc_password =&gt; "yyy" jdbc_driver_library =&gt; "mysql-connector-java-5.1.41.jar" jdbc_driver_class =&gt; "com.mysql.jdbc.Driver" schedule =&gt; "* * * * *" statement =&gt; "SELECT * from table1 WHERE updated_at &gt; :sql_last_value order by updated_at" use_column_value =&gt; true tracking_column =&gt; updated_at type =&gt; "table1" last_run_metadata_path =&gt; "/opt/logstash-5.4.0/sql-last-values/table1" } jdbc { jdbc_connection_string =&gt; "jdbc:mysql:127.0.0.1:3306/whatever" jdbc_user =&gt; "xxx" jdbc_password =&gt; "yyy" jdbc_driver_library =&gt; "mysql-connector-java-5.1.41.jar" jdbc_driver_class =&gt; "com.mysql.jdbc.Driver" schedule =&gt; "* * * * *" statement =&gt; "SELECT * from table2 WHERE updated_at &gt; :sql_last_value order by updated_at" use_column_value =&gt; true tracking_column =&gt; updated_at type =&gt; "table2" last_run_metadata_path =&gt; "/opt/logstash-5.4.0/sql-last-values/table2" } } output { if [type] == "table1" { elasticsearch { hosts =&gt; ["localhost:9200"] index =&gt; "table1" document_type =&gt; "table1" document_id =&gt; "%{id}" } file { codec =&gt; json_lines path =&gt; "/opt/logstash-5.4.0/logs/table1.log" } } else if [type] == "table2" { elasticsearch { hosts =&gt; ["localhost:9200"] index =&gt; "table2" document_type =&gt; "table2" document_id =&gt; "%{id}" } } else { file { codec =&gt; json_lines path =&gt; "/opt/logstash-5.4.0/logs/unknown.log" } } } </code></pre> <p>What am I doing wrong ? everything is going to the else block, to the /opt/logstash-5.4.0/logs/unknown.log</p> <p>Is wrong my approach ? Should I have multiple files ?</p> <p>thank you in advance</p>
0debug
Server-side rendering + responsive design + inline styles -> which breakpoint to use? : <p>I have a responsive web application built with ReactJS for which I want one day to support server-side rendering. </p> <p>According to the viewport size, the application layout/behavior changes. But all these changes can not only be done with plain CSS mediaquery: the JS behavior, and the underlying HTML structure also has to be changed according to the width. </p> <p>For example I could have:</p> <p><strong>Under 800px width</strong>:</p> <pre><code>&lt;div class="app"&gt; &lt;div class="menu-mobile"&gt;...&lt;/div&gt; &lt;div class="content"&gt;...&lt;/div&gt; &lt;div class="mobile-left-menu"&gt;...&lt;/div&gt; &lt;div class="footer-mobile"&gt;...&lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>Above 800px width</strong>:</p> <pre><code>&lt;div class="app"&gt; &lt;div class="menu"&gt;...&lt;/div&gt; &lt;div class="main"&gt; &lt;div class="left-menu"&gt;...&lt;/div&gt; &lt;div class="content"&gt;...&lt;/div&gt; &lt;div class="right-menu"&gt;...&lt;/div&gt; &lt;/div&gt; &lt;div class="footer"&gt;...&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Now, I want to use server-side rendering for that application. But on the server I don't have the width, so I don't know which HTML structure to return to the client.</p> <p>Note that I'm not looking for a solution that use a static default server-side breakpoint, and that on the client correct the app. I am looking for a solution that would return to the client the proper html structure according to its device. So it should work fine if he disables javascript on his browser.</p> <hr> <p>One could argue that I could render the html needed for both, and hide/show the required parts with plain CSS mediaqueries and <code>display: none</code>, but it would complicates the app and make it render a lot of unused html elements because generally it's unlikely that the user move above/under the breakpoint (I mean if he has a mobile device, the html elements for desktop will never be used)</p> <p>Also, if I want to use inline-style, it becomes complicated because I have to render these inline styles for the correct width on the server.</p> <p>I've <a href="https://github.com/reactjs/react-future/issues/8#issuecomment-53353098" rel="noreferrer">seen</a> some people are thinking about sniffing the browser UA to make an estimated guess of their viewport size. But even with some unsecure screen dimension detection, I'm not sure we can know the device screen orientation on the server-side.</p> <p>Can I do anything to solve this problem?</p>
0debug
void checkasm_check_blockdsp(void) { LOCAL_ALIGNED_16(uint16_t, buf0, [6 * 8 * 8]); LOCAL_ALIGNED_16(uint16_t, buf1, [6 * 8 * 8]); AVCodecContext avctx = { 0 }; BlockDSPContext h; ff_blockdsp_init(&h, &avctx); check_clear(clear_block, 8 * 8); check_clear(clear_blocks, 8 * 8 * 6); report("blockdsp"); }
1threat
static struct bt_device_s *bt_device_add(const char *opt) { struct bt_scatternet_s *vlan; int vlan_id = 0; char *endp = strstr(opt, ",vlan="); int len = (endp ? endp - opt : strlen(opt)) + 1; char devname[10]; pstrcpy(devname, MIN(sizeof(devname), len), opt); if (endp) { vlan_id = strtol(endp + 6, &endp, 0); if (*endp) { fprintf(stderr, "qemu: unrecognised bluetooth vlan Id\n"); return 0; } } vlan = qemu_find_bt_vlan(vlan_id); if (!vlan->slave) fprintf(stderr, "qemu: warning: adding a slave device to " "an empty scatternet %i\n", vlan_id); if (!strcmp(devname, "keyboard")) return bt_keyboard_init(vlan); fprintf(stderr, "qemu: unsupported bluetooth device `%s'\n", devname); return 0; }
1threat
static void iommu_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val) { IOMMUState *s = opaque; target_phys_addr_t saddr; saddr = (addr - s->addr) >> 2; DPRINTF("write reg[%d] = %x\n", (int)saddr, val); switch (saddr) { case IOMMU_CTRL: switch (val & IOMMU_CTRL_RNGE) { case IOMMU_RNGE_16MB: s->iostart = 0xffffffffff000000ULL; break; case IOMMU_RNGE_32MB: s->iostart = 0xfffffffffe000000ULL; break; case IOMMU_RNGE_64MB: s->iostart = 0xfffffffffc000000ULL; break; case IOMMU_RNGE_128MB: s->iostart = 0xfffffffff8000000ULL; break; case IOMMU_RNGE_256MB: s->iostart = 0xfffffffff0000000ULL; break; case IOMMU_RNGE_512MB: s->iostart = 0xffffffffe0000000ULL; break; case IOMMU_RNGE_1GB: s->iostart = 0xffffffffc0000000ULL; break; default: case IOMMU_RNGE_2GB: s->iostart = 0xffffffff80000000ULL; break; } DPRINTF("iostart = " TARGET_FMT_plx "\n", s->iostart); s->regs[saddr] = ((val & IOMMU_CTRL_MASK) | s->version); break; case IOMMU_BASE: s->regs[saddr] = val & IOMMU_BASE_MASK; break; case IOMMU_TLBFLUSH: DPRINTF("tlb flush %x\n", val); s->regs[saddr] = val & IOMMU_TLBFLUSH_MASK; break; case IOMMU_PGFLUSH: DPRINTF("page flush %x\n", val); s->regs[saddr] = val & IOMMU_PGFLUSH_MASK; break; case IOMMU_AFAR: s->regs[saddr] = val; qemu_irq_lower(s->irq); break; case IOMMU_AFSR: s->regs[saddr] = (val & IOMMU_AFSR_MASK) | IOMMU_AFSR_RESV; qemu_irq_lower(s->irq); break; case IOMMU_SBCFG0: case IOMMU_SBCFG1: case IOMMU_SBCFG2: case IOMMU_SBCFG3: s->regs[saddr] = val & IOMMU_SBCFG_MASK; break; case IOMMU_ARBEN: s->regs[saddr] = (val & IOMMU_ARBEN_MASK) | IOMMU_MID; break; default: s->regs[saddr] = val; break; } }
1threat
Is use of generics valid in XCTestCase subclasses? : <p>I have a <code>XCTestCase</code> subclass that looks something like this. I have removed <code>setup()</code> and <code>tearDown</code> methods for brevity: </p> <pre><code>class ViewControllerTests &lt;T : UIViewController&gt;: XCTestCase { var viewController : T! final func loadControllerWithNibName(string:String) { viewController = T(nibName: string, bundle: NSBundle(forClass: ViewControllerTests.self)) if #available(iOS 9.0, *) { viewController.loadViewIfNeeded() } else { viewController.view.alpha = 1 } } } </code></pre> <p>And its subclass that looks something like this : </p> <pre><code>class WelcomeViewControllerTests : ViewControllerTests&lt;WelcomeViewController&gt; { override func setUp() { super.setUp() self.loadControllerWithNibName("welcomeViewController") // Put setup code here. This method is called before the invocation of each test method in the class. } func testName() { let value = self.viewController.firstNameTextField.text if value == "" { XCTFail() } } } </code></pre> <p>In theory, this should work as expected -- the compiler doesn't complain about anything. But it's just that when I run the test cases, the <code>setup()</code> method doesn't even get called. But, it says the tests have passed when clearly <code>testName()</code> method should fail. </p> <p>Is the use of generics a problem? I can easily think of many non-generic approaches, but I would very much want to write my test cases like this. Is the XCTest's interoperability between Objective-C and Swift the issue here? </p>
0debug
static inline void gen_goto_tb(DisasContext *s, int n, target_ulong dest) { if (use_goto_tb(s, dest)) { tcg_gen_goto_tb(n); gen_set_pc_im(s, dest); tcg_gen_exit_tb((uintptr_t)s->tb + n); } else { TCGv addr = tcg_temp_new(); gen_set_pc_im(s, dest); tcg_gen_extu_i32_tl(addr, cpu_R[15]); tcg_gen_lookup_and_goto_ptr(addr); tcg_temp_free(addr); } }
1threat
static int virtio_pci_load_config(void * opaque, QEMUFile *f) { VirtIOPCIProxy *proxy = opaque; int ret; ret = pci_device_load(&proxy->pci_dev, f); if (ret) { return ret; } msix_load(&proxy->pci_dev, f); if (msix_present(&proxy->pci_dev)) { qemu_get_be16s(f, &proxy->vdev->config_vector); } else { proxy->vdev->config_vector = VIRTIO_NO_VECTOR; } if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) { return msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector); } if (!(proxy->vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) && !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { proxy->bugs |= VIRTIO_PCI_BUG_BUS_MASTER; } return 0; }
1threat
static void dvbsub_parse_clut_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { DVBSubContext *ctx = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; int i, clut_id; int version; DVBSubCLUT *clut; int entry_id, depth , full_range; int y, cr, cb, alpha; int r, g, b, r_add, g_add, b_add; av_dlog(avctx, "DVB clut packet:\n"); for (i=0; i < buf_size; i++) { av_dlog(avctx, "%02x ", buf[i]); if (i % 16 == 15) av_dlog(avctx, "\n"); } if (i % 16) av_dlog(avctx, "\n"); clut_id = *buf++; version = ((*buf)>>4)&15; buf += 1; clut = get_clut(ctx, clut_id); if (!clut) { clut = av_malloc(sizeof(DVBSubCLUT)); memcpy(clut, &default_clut, sizeof(DVBSubCLUT)); clut->id = clut_id; clut->version = -1; clut->next = ctx->clut_list; ctx->clut_list = clut; } if (clut->version != version) { clut->version = version; while (buf + 4 < buf_end) { entry_id = *buf++; depth = (*buf) & 0xe0; if (depth == 0) { av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf); return; } full_range = (*buf++) & 1; if (full_range) { y = *buf++; cr = *buf++; cb = *buf++; alpha = *buf++; } else { y = buf[0] & 0xfc; cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4; cb = (buf[1] << 2) & 0xf0; alpha = (buf[1] << 6) & 0xc0; buf += 2; } if (y == 0) alpha = 0xff; YUV_TO_RGB1_CCIR(cb, cr); YUV_TO_RGB2_CCIR(r, g, b, y); av_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha); if (depth & 0x80) clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha); else if (depth & 0x40) clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha); else if (depth & 0x20) clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha); } } }
1threat
static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { BDRVQcowState *s = bs->opaque; z_stream strm; int ret, out_len; uint8_t *out_buf; uint64_t cluster_offset; if (nb_sectors == 0) { cluster_offset = bdrv_getlength(bs->file); cluster_offset = (cluster_offset + 511) & ~511; bdrv_truncate(bs->file, cluster_offset); return 0; } if (nb_sectors != s->cluster_sectors) { ret = -EINVAL; if (sector_num + nb_sectors == bs->total_sectors && nb_sectors < s->cluster_sectors) { uint8_t *pad_buf = qemu_blockalign(bs, s->cluster_size); memset(pad_buf, 0, s->cluster_size); memcpy(pad_buf, buf, nb_sectors * BDRV_SECTOR_SIZE); ret = qcow2_write_compressed(bs, sector_num, pad_buf, s->cluster_sectors); qemu_vfree(pad_buf); } return ret; } out_buf = g_malloc(s->cluster_size + (s->cluster_size / 1000) + 128); memset(&strm, 0, sizeof(strm)); ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -12, 9, Z_DEFAULT_STRATEGY); if (ret != 0) { ret = -EINVAL; goto fail; } strm.avail_in = s->cluster_size; strm.next_in = (uint8_t *)buf; strm.avail_out = s->cluster_size; strm.next_out = out_buf; ret = deflate(&strm, Z_FINISH); if (ret != Z_STREAM_END && ret != Z_OK) { deflateEnd(&strm); ret = -EINVAL; goto fail; } out_len = strm.next_out - out_buf; deflateEnd(&strm); if (ret != Z_STREAM_END || out_len >= s->cluster_size) { ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT, sector_num * BDRV_SECTOR_SIZE, s->cluster_sectors * BDRV_SECTOR_SIZE); if (ret < 0) { goto fail; } ret = bdrv_write(bs, sector_num, buf, s->cluster_sectors); if (ret < 0) { goto fail; } } else { cluster_offset = qcow2_alloc_compressed_cluster_offset(bs, sector_num << 9, out_len); if (!cluster_offset) { ret = -EIO; goto fail; } cluster_offset &= s->cluster_offset_mask; ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT, cluster_offset, out_len); if (ret < 0) { goto fail; } BLKDBG_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED); ret = bdrv_pwrite(bs->file, cluster_offset, out_buf, out_len); if (ret < 0) { goto fail; } } ret = 0; fail: g_free(out_buf); return ret; }
1threat
document.write('<script src="evil.js"></script>');
1threat
Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 3 : <p><strong>Introduction</strong></p> <p>I am working with the bootstrap framework.I am currently working on "Bootstrap Tabs"(hide/show).I am using bootstrap version 3 and jquery version 3.0.2 something.</p> <p><strong>Problem</strong></p> <p>My tabs are not working, unless i load jquery of version less than 1.6.But then ajax making problem with jquery less than 1.6. Chrome console give me this error.</p> <blockquote> <p>bootstrap.min.js:6 Uncaught Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 3</p> </blockquote> <p>I tried different fallback techniques but couldn't implement correctly.</p> <p>I am stuck here for 2 days, if someone have any idea or any reference, please do help.Thanks for your time.</p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
use of int32_t in c? : I have two Questions in my mind now 1.Firstly, why do we need int32_t as we already have different variation for it like short int unsigned int and etc. 2.Secondly does the use of this type of size fixed types makes programs portable?
0debug
static int cache_read(URLContext *h, unsigned char *buf, int size) { Context *c= h->priv_data; CacheEntry *entry, *next[2] = {NULL, NULL}; int r; entry = av_tree_find(c->root, &c->logical_pos, cmp, (void**)next); if (!entry) entry = next[0]; if (entry) { int64_t in_block_pos = c->logical_pos - entry->logical_pos; av_assert0(entry->logical_pos <= c->logical_pos); if (in_block_pos < entry->size) { int64_t physical_target = entry->physical_pos + in_block_pos; if (c->cache_pos != physical_target) { r = lseek(c->fd, physical_target, SEEK_SET); } else r = c->cache_pos; if (r >= 0) { c->cache_pos = r; r = read(c->fd, buf, FFMIN(size, entry->size - in_block_pos)); } if (r > 0) { c->cache_pos += r; c->logical_pos += r; c->cache_hit ++; return r; } } } if (c->logical_pos != c->inner_pos) { r = ffurl_seek(c->inner, c->logical_pos, SEEK_SET); if (r<0) { av_log(h, AV_LOG_ERROR, "Failed to perform internal seek\n"); return r; } c->inner_pos = r; } r = ffurl_read(c->inner, buf, size); if (r == 0 && size>0) { c->is_true_eof = 1; av_assert0(c->end >= c->logical_pos); } if (r<=0) return r; c->inner_pos += r; c->cache_miss ++; add_entry(h, buf, r); c->logical_pos += r; c->end = FFMAX(c->end, c->logical_pos); return r; }
1threat
static void gradfun_filter_line_mmxext(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers) { intptr_t x; if (width & 3) { x = width & ~3; ff_gradfun_filter_line_c(dst + x, src + x, dc + x / 2, width - x, thresh, dithers); width = x; } x = -width; __asm__ volatile( "movd %4, %%mm5 \n" "pxor %%mm7, %%mm7 \n" "pshufw $0, %%mm5, %%mm5 \n" "movq %6, %%mm6 \n" "movq %5, %%mm4 \n" "1: \n" "movd (%2,%0), %%mm0 \n" "movd (%3,%0), %%mm1 \n" "punpcklbw %%mm7, %%mm0 \n" "punpcklwd %%mm1, %%mm1 \n" "psllw $7, %%mm0 \n" "pxor %%mm2, %%mm2 \n" "psubw %%mm0, %%mm1 \n" "psubw %%mm1, %%mm2 \n" "pmaxsw %%mm1, %%mm2 \n" "pmulhuw %%mm5, %%mm2 \n" "psubw %%mm6, %%mm2 \n" "pminsw %%mm7, %%mm2 \n" "pmullw %%mm2, %%mm2 \n" "paddw %%mm4, %%mm0 \n" "pmulhw %%mm2, %%mm1 \n" "psllw $2, %%mm1 \n" "paddw %%mm1, %%mm0 \n" "psraw $7, %%mm0 \n" "packuswb %%mm0, %%mm0 \n" "movd %%mm0, (%1,%0) \n" "add $4, %0 \n" "jl 1b \n" "emms \n" :"+r"(x) :"r"(dst+width), "r"(src+width), "r"(dc+width/2), "rm"(thresh), "m"(*dithers), "m"(*pw_7f) :"memory" ); }
1threat
How can i read a csv based on data in other columns? : <p>Heres my example csv:</p> <pre><code>col1: col2: col3: 1 true false 2 true true 3 false false 4 false true 5 true true </code></pre> <p>i want to be able to say 'give me col1 if col2 is true and col3 is false' Any help is appreciated</p>
0debug
how to conver Linq to sql : How can I can I write this sql queryt to linq select c.Name as 'Name', s.Status from (select * , ROW_NUMBER() over (partition by CustomerID order by Date desc) rn from CustomerStatus) detail inner join Status s on detail.Status = s.Id inner join Customers c on detail.CustomerId = c.Id where detail.rn = 1 Here I am unable to convert this sql to linq how can do this??
0debug
How to create Toast in Flutter? : <p>Can I create something similar to <a href="https://developer.android.com/guide/topics/ui/notifiers/toasts.html" rel="noreferrer">Toasts</a> in Flutter ? Just a tiny notification window that is not directly in the face of the user and does not lock or fade the view behind it?</p>
0debug
Generate PDF in .Net core 2.0 using rdlc : <p>With .Net Core 2.0 not supporting Report Viewer, is there any other alternative way of doing this? </p> <p>I found alanjuden's solution (<a href="https://alanjuden.com/2016/11/10/mvc-net-core-report-viewer/" rel="noreferrer">https://alanjuden.com/2016/11/10/mvc-net-core-report-viewer/</a>), but actually looking for official references.</p> <p>We have migrated our project from .Net Framework 4.5.2 to .Net Core 2.0. However, stuck up with these reporting files as core 2.0 doesn't support.</p> <p>Any suggestions?</p> <p>Thanks in advance.</p>
0debug
Can I run a Go web server with HTML/JavaScript UI as a cross platform application (Linux, Android, iOS, macOS, Windows) : <p>I'm experimenting with Go and as I web developer I want to explore the possibilities of building the same Go web service with the same HTML/JavaScript/CSS UI cross platform for Linux, Android, iOS, macOS, Windows and so on.</p> <p>I am aware of frameworks such as Electron, Cordova, gomobile but none of them seem to work both with Go and a web UI to generate several of Linux binary, Android APK, Windows exe, macOS dmg, iOS binary (don't know that format yet) without having to code different UIs for different platforms.</p> <p>Any suggestions on how to solve this?</p>
0debug
Entity Framework like ORM for Cosmos DB : <p>I am looking for any ORM for Cosmos DB. Most of the client which have been mentioned in samples create a new connection to table when they need i.e. there is no connection pooling policy. It seems creating new connection always as is given in samples is non scalable. Please correct me if I am wrong. And does anyone have any good ORM solution which comes with connection pooling</p>
0debug
Why we use '?' character in c# : <p>I am looking at somebody code. I found:</p> <pre><code>XOffset = !MirroredMovement ? trans.x * MoveRate : -trans.x * MoveRate; </code></pre> <p>He use '?' character, why ? What does it mean ? I did not understand.</p>
0debug
Bash (zsh) script syntax issue : I've honestly worn out my keyboard on this one... what does the (N) term in the following script segment mean? (from oh-my-zsh.sh): for config_file ($ZSH_CUSTOM/*.zsh**(N)**); do source $config_file done I ask because .zsh files in $ZSH_CUSTOM directory aren't getting sourced. Thanks for any insights!
0debug
CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler) { CPUDebugExcpHandler *old_handler = debug_excp_handler; debug_excp_handler = handler; return old_handler; }
1threat
I want to scrape content or data from dynamic web page using php? : <p>Is it possible to scrape content or data from dynamic web page? If it is possible please attach PHP code. Thanks in Advance. </p>
0debug
static inline int GET_TOK(TM2Context *ctx,int type) { if(ctx->tok_ptrs[type] >= ctx->tok_lens[type]) { av_log(ctx->avctx, AV_LOG_ERROR, "Read token from stream %i out of bounds (%i>=%i)\n", type, ctx->tok_ptrs[type], ctx->tok_lens[type]); return 0; } if(type <= TM2_MOT) return ctx->deltas[type][ctx->tokens[type][ctx->tok_ptrs[type]++]]; return ctx->tokens[type][ctx->tok_ptrs[type]++]; }
1threat
How to compare two aspect ratios? : I want to compare two ratios using javascript. I have two ratios 12:3 and 12:2 and I need to compare both. if(12:3 > 12:2) { console.log(true); } Something similar to above.Thank you.
0debug
get all items in a list of strings in Python : I got the following code: import re dump_final = re.findall(r"\btext=[\w]*", dump5) Which returns me a list. E.g: Apple, Banana, Lemon Turns out I need to get all elements of this list and call another function using those elements. To scan all list, I used: for index in range(len(dump_final)): dump_final[index] = dump_final[index].replace("_"," ") But it returns me characters one by one. I need Apple. Not A, P, P, L, E how can I get them using loop? Thank you.
0debug
static int msrle_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MsrleContext *s = avctx->priv_data; int istride = FFALIGN(avctx->width*avctx->bits_per_coded_sample, 32) / 8; int ret; s->buf = buf; s->size = buf_size; if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) return ret; if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) { const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); if (pal) { s->frame->palette_has_changed = 1; memcpy(s->pal, pal, AVPALETTE_SIZE); } memcpy(s->frame->data[1], s->pal, AVPALETTE_SIZE); } if (avctx->height * istride == avpkt->size) { int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0); uint8_t *ptr = s->frame->data[0]; uint8_t *buf = avpkt->data + (avctx->height-1)*istride; int i, j; for (i = 0; i < avctx->height; i++) { if (avctx->bits_per_coded_sample == 4) { for (j = 0; j < avctx->width - 1; j += 2) { ptr[j+0] = buf[j>>1] >> 4; ptr[j+1] = buf[j>>1] & 0xF; } if (avctx->width & 1) ptr[j+0] = buf[j>>1] >> 4; } else { memcpy(ptr, buf, linesize); } buf -= istride; ptr += s->frame->linesize[0]; } } else { bytestream2_init(&s->gb, buf, buf_size); ff_msrle_decode(avctx, (AVPicture*)s->frame, avctx->bits_per_coded_sample, &s->gb); } if ((ret = av_frame_ref(data, s->frame)) < 0) return ret; *got_frame = 1; return buf_size; }
1threat
Visual Studio 2015 Diagnostic Tools Window doesn't show up : <p>I'm able to show the diagnostic tools windows via Debug -> Windows -> Show Diagnostic Tool.</p> <p>But that windows always disappears when starting / debugging the application.</p> <p>What is going on?</p>
0debug
How can I improve this JavaScript code? : <pre><code>for(var i = 1; i &lt;= 20; i++){ switch (i) { case 3: case 6: case 9: case 12: case 18: console.log("Fizz"); break; case 5: case 10: case 20: console.log("Buzz"); break; case 15: console.log("FizzBuzz"); break; default: console.log(i); } } </code></pre> <p>I am supposed to print numbers from 1-20.</p> <p>These are the conditions.</p> <p>if a number is divisible by 3, then i need to print "Fizz"</p> <p>If a number is divisible by 5, then I need to print "Buzz"</p> <p>if a number is divisible by both 3 and 5, then I need to print "FizzBuzz".</p> <p>I came up with the aforementioned code, but I think it can be improved.</p>
0debug
How to get index of a triggered array input []? : So we can do: <input name=test[]> <input name=test[]> ... to created an array of input for test[]. But before submission, if I were to manipulate each input in javascript upon change, how do I do that? I figure there needs to be a way to pass the index of a particular input from test[]? I'm stuck at $(this).index() or $(this).parents().index(), but these are index values of the DOM, they don't give the index values of the text[] array. Help? Thank you.
0debug
js onclick working strange : <p>I have the next code </p> <pre><code>$.ajax({ url: '/data', type: "POST", data: JSON.stringify(formData), contentType: "application/json", dataType: "json", success: function(response){ for (var i=0; i&lt;response.length; i++) { var htmlEdit = "creating button here"; var btnEdit = jQuery(htmlEdit); btnEdit.appendTo(divCollapse); btnEdit.click(function() { editBooking(btnEdit); }); } } }); function editBooking(btn) { btn.button('loading'); } </code></pre> <p>So I have rows with identical items. Buttons are shown as expected. Click to any button invokes loading state for the <strong>last</strong> button. What I'm doing wrong? Thank you.</p>
0debug
What is the meaning of the mentioned query? : <p>If I had the table "CustomerDetails" than what is the below query explains??</p> <pre><code>var details = (from data in entity.CustomerDetails where (data.CustomerId == CustId &amp;&amp; data.CustomerProjectID == CustProjId) select data).FirstOrDefault(); </code></pre> <p>Share the exact meaning. Thanks in advance.</p>
0debug
if I have a collection of hashes with the same key and values, how do I add another value together : Say I've assigned the rows below to hashes. How do I add together the :amount values for a specific id number? (so for id: 1, I need the total= 9290+2262) other_id: 1,amount: 9290,id: 1 other_id: 2,amount: 2262,id: 1 other_id: 3,amount: 9588,id: 2 other_id: 4,amount: 1634,id: 2 or even better, if I had a large collection of these. how would I write code so that it would find the id number with the maximum value of total (if total is the sum of all amount instances for a specific id number)
0debug
static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) { AVFilterContext *ctx = inlink->dst; TInterlaceContext *tinterlace = ctx->priv; avfilter_unref_buffer(tinterlace->cur); tinterlace->cur = tinterlace->next; tinterlace->next = picref; return 0; }
1threat
static void qtrle_encode_line(QtrleEncContext *s, AVFrame *p, int line, uint8_t **buf) { int width=s->logical_width; int i; signed char rlecode; unsigned int bulkcount; unsigned int skipcount; unsigned int repeatcount; int total_bulk_cost; int total_skip_cost; int total_repeat_cost; int temp_cost; int j; uint8_t *this_line = p-> data[0] + line*p-> linesize[0] + (width - 1)*s->pixel_size; uint8_t *prev_line = s->previous_frame.data[0] + line*s->previous_frame.linesize[0] + (width - 1)*s->pixel_size; s->length_table[width] = 0; skipcount = 0; for (i = width - 1; i >= 0; i--) { if (!s->frame.key_frame && !memcmp(this_line, prev_line, s->pixel_size)) skipcount = FFMIN(skipcount + 1, MAX_RLE_SKIP); else skipcount = 0; total_skip_cost = s->length_table[i + skipcount] + 2; s->skip_table[i] = skipcount; if (i < width - 1 && !memcmp(this_line, this_line + s->pixel_size, s->pixel_size)) repeatcount = FFMIN(repeatcount + 1, MAX_RLE_REPEAT); else repeatcount = 1; total_repeat_cost = s->length_table[i + repeatcount] + 1 + s->pixel_size; if (i == 0) { total_skip_cost--; total_repeat_cost++; } if (repeatcount > 1 && (skipcount == 0 || total_repeat_cost < total_skip_cost)) { s->length_table[i] = total_repeat_cost; s->rlecode_table[i] = -repeatcount; } else if (skipcount > 0) { s->length_table[i] = total_skip_cost; s->rlecode_table[i] = 0; } else { int limit = FFMIN(width - i, MAX_RLE_BULK); temp_cost = 1 + s->pixel_size + !i; total_bulk_cost = INT_MAX; for (j = 1; j <= limit; j++) { if (s->length_table[i + j] + temp_cost < total_bulk_cost) { total_bulk_cost = s->length_table[i + j] + temp_cost; bulkcount = j; } temp_cost += s->pixel_size; } s->length_table[i] = total_bulk_cost; s->rlecode_table[i] = bulkcount; } this_line -= s->pixel_size; prev_line -= s->pixel_size; } i=0; this_line = p-> data[0] + line*p->linesize[0]; if (s->rlecode_table[0] == 0) { bytestream_put_byte(buf, s->skip_table[0] + 1); i += s->skip_table[0]; } else bytestream_put_byte(buf, 1); while (i < width) { rlecode = s->rlecode_table[i]; bytestream_put_byte(buf, rlecode); if (rlecode == 0) { bytestream_put_byte(buf, s->skip_table[i] + 1); i += s->skip_table[i]; } else if (rlecode > 0) { if (s->avctx->pix_fmt == PIX_FMT_GRAY8) { int j; for (j = 0; j < rlecode*s->pixel_size; ++j) bytestream_put_byte(buf, *(this_line + i*s->pixel_size + j) ^ 0xff); } else { bytestream_put_buffer(buf, this_line + i*s->pixel_size, rlecode*s->pixel_size); } i += rlecode; } else { if (s->avctx->pix_fmt == PIX_FMT_GRAY8) { int j; for (j = 0; j < s->pixel_size; ++j) bytestream_put_byte(buf, *(this_line + i*s->pixel_size + j) ^ 0xff); } else { bytestream_put_buffer(buf, this_line + i*s->pixel_size, s->pixel_size); } i -= rlecode; } } bytestream_put_byte(buf, -1); }
1threat
static void q35_host_get_pci_hole_start(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Q35PCIHost *s = Q35_HOST_DEVICE(obj); uint32_t value = s->mch.pci_hole.begin; visit_type_uint32(v, name, &value, errp); }
1threat
what is double(::) in angular js? : <p>While going through some of the angular best practices guide I found this concept of using <code>::</code> before models for uni-direction binding. But it seems does not work with <code>input</code> field. Here is an example:</p> <p><a href="https://plnkr.co/edit/gZ73PNGGg4m45zFuBYZw?p=preview" rel="nofollow">https://plnkr.co/edit/gZ73PNGGg4m45zFuBYZw?p=preview</a></p> <p>Inside expression it works as expected but inside ng-model, it's still 2-way binding. Then what's the difference?</p>
0debug
Comparing a date between two date ranges i.e,.fromDate and toDate in java : <p>How to check whether a given date is between two dates but it should not check with the time in given date.</p> <p>I have tried with after but it checks for time range too.</p> <p>Could anyone help me to know about this ?</p> <p>TIA.,</p>
0debug
Angular 2 Router Wildcard handling with child-routes : <p>When using child routes with angular2's router "3.0", there is no need to declare them in the parent router config (before, you had to do something like <code>/child...</code> in the parent component).</p> <p>I want to configure a global "page not found" handler, which I can do like this:</p> <pre><code>{ path: '**', component: PageNotFoundComponent } </code></pre> <p>in my app routing module.</p> <p>The caveat: If I do this, the router navigates to routes declared in the app routing module before the <code>PageNotFoundComponent</code> just fine. But it always navigates to the wildcard route when I try to access a child route (declared using <code>RouterModule.forChild</code> in some child routing module.</p> <p>Intuitively, the wildcard route should be placed behind all other route configs, because the router resolves in declaration order. But there does not seem to be a way to declare it after the child routes. It also does not seem very elegant to declare a wildcard route in all child router modules.</p> <p>Am I missing something or is there just no way to define a global 404-page in Angular-2-Router-3 when using child routes?</p>
0debug
static av_cold int jpg_init(AVCodecContext *avctx, JPGContext *c) { int ret; ret = build_vlc(&c->dc_vlc[0], avpriv_mjpeg_bits_dc_luminance, avpriv_mjpeg_val_dc, 12, 0); if (ret) return ret; ret = build_vlc(&c->dc_vlc[1], avpriv_mjpeg_bits_dc_chrominance, avpriv_mjpeg_val_dc, 12, 0); if (ret) return ret; ret = build_vlc(&c->ac_vlc[0], avpriv_mjpeg_bits_ac_luminance, avpriv_mjpeg_val_ac_luminance, 251, 1); if (ret) return ret; ret = build_vlc(&c->ac_vlc[1], avpriv_mjpeg_bits_ac_chrominance, avpriv_mjpeg_val_ac_chrominance, 251, 1); if (ret) return ret; ff_blockdsp_init(&c->bdsp, avctx); ff_idctdsp_init(&c->idsp, avctx); ff_init_scantable(c->idsp.idct_permutation, &c->scantable, ff_zigzag_direct); return 0; }
1threat
Why RuntimeException Legal here? : import java.io.*; import java.sql.*; import java.io.*; import java.sql.*; class Vehicle{ public void park()throws IOException{//compiletime checked } } class Car extends Vehicle{ public void park()throws RuntimeException{//compile time unchecked // } } why compile time unchecked exceptions legal here.sdfsdfsdfdsfddsfdsfds
0debug
Search for a specific value inside a Generic list : <p>The purpose of the below code is to find a specific value within a generic list using List.Find() method . I am pasting a code below : </p> <pre><code>class Program { public static List&lt;Currency&gt; FindItClass = new List&lt;Currency&gt;(); public class Currency { public string Country { get; set; } public string Code { get; set; } } public static void PopulateListWithClass(string country, string code) { Currency currency = new Currency(); currency.Country = country; currency.Code = code; FindItClass.Add(currency); } static void Main(string[] args) { PopulateListWithClass("America (United States of America), Dollars", "USD"); PopulateListWithClass("Germany, Euro", "EUR"); PopulateListWithClass("Switzerland, Francs", "CHF"); PopulateListWithClass("India, Rupees", "INR"); PopulateListWithClass("United Kingdom, Pounds", "GBP"); PopulateListWithClass("Canada, Dollars", "CAD"); PopulateListWithClass("Pakistan, Rupees", "PKR"); PopulateListWithClass("Turkey, New Lira", "TRY"); PopulateListWithClass("Russia, Rubles", "RUB"); PopulateListWithClass("United Arab Emirates, Dirhams", "AED"); Console.Write("Enter an UPPDERCASE 3 character currency code and then enter: "); string searchFor = Console.ReadLine(); Currency result = FindItClass.Find(delegate(Currency cur) { return cur.Code == searchFor; }); Console.WriteLine(); if (result != null) { Console.WriteLine(searchFor + " represents " + result.Country); } else { Console.WriteLine("The currency code you entered was not found."); } Console.ReadLine(); } } </code></pre> <p>My query is why List is static , what is the purpose of using static over there.</p> <pre><code> public static List&lt;Currency&gt; FindItClass = new List&lt;Currency&gt;(); </code></pre> <p>Another query is why a delegate is used over there inside the find method. </p> <pre><code>Currency result = FindItClass.Find(delegate(Currency cur) { return cur.Code == searchFor; }); </code></pre>
0debug
Concise, universal A* search in C# : <p>I was looking for an A* search implementation in C#. Eventually wrote my own. Because it's universal, I hope it will be useful for others.</p>
0debug
pvscsi_command_complete(SCSIRequest *req, uint32_t status, size_t resid) { PVSCSIRequest *pvscsi_req = req->hba_private; PVSCSIState *s = pvscsi_req->dev; if (!pvscsi_req) { trace_pvscsi_command_complete_not_found(req->tag); return; } if (resid) { trace_pvscsi_command_complete_data_run(); pvscsi_req->cmp.hostStatus = BTSTAT_DATARUN; } pvscsi_req->cmp.scsiStatus = status; if (pvscsi_req->cmp.scsiStatus == CHECK_CONDITION) { uint8_t sense[SCSI_SENSE_BUF_SIZE]; int sense_len = scsi_req_get_sense(pvscsi_req->sreq, sense, sizeof(sense)); trace_pvscsi_command_complete_sense_len(sense_len); pvscsi_write_sense(pvscsi_req, sense, sense_len); } qemu_sglist_destroy(&pvscsi_req->sgl); pvscsi_complete_request(s, pvscsi_req); }
1threat
Helpt to understand 'string' must be a non-nullable and generic method : I have few questions in the following method. Can an expert help me to understand the structure and why I am getting the error? I have this method that will get a xml element, search the attribute specified in name parameter and case is can't find in the xml, it returns the default value: protected static T GetValue<T>(XElement group, string name, T default) where T : struct { //Removed some code for better view XAttribute setting = group.Attribute(name); return setting == null ? default: (T)Enum.Parse(typeof(T), setting.Value); } My questions is about the generic types used in this method. When I try to use this method in a string variable, I get the following error: string test = GetValue(element, "search", "default value"); The type 'string' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'GetValue<T>(XElement, string, T)' What T is this method it the issue that I am getting that error? What does where T : struct mean? I tried to use this as GetValue<String> and it did not work as well... Any help are really welcome! Thanks!
0debug
SELECTED DROP BOX SHOWS 2 VALUES FROM MYSQL DATABASE : Hey I am having some trouble with my dropdown menu values that I retrieve from my database. I see two values instead of one. $con = mysqli_connect("localhost","root","") ; $myDB = mysqli_select_db($con, "test"); $dbEnc = mysqli_set_charset($con, 'utf8'); $sqlSELECT = mysqli_query($con, 'SELECT class FROM disastergroups'); <!DOCTYPE html> <html> <head> <title>test</title> <meta http-equiv="content-type" content = "text/html; charset=utf-8"/> </head> <body> <select name="test"> <option value="">Select...</option> <?php while ($row1 = mysqli_fetch_array($sqlSELECT)): ;?> <option><?php echo implode("\t", $row1); ?></option> <?php endwhile;?> </select> <input type="submit" value="Submit Data"> </body> </html> The image below shows the duplicates in the dropdown menu... how do I fix this? [CLICK HERE FOR IMAGE][1] [1]: https://i.stack.imgur.com/JIcz6.png
0debug
Selenium on Google Colab, PermissionError: [Errno 13] Permission denied: '/content/chromedriver.exe' : I have been using Google Colab for my python projects. I want to learn & implement Selenium using Google Colab. I am trying to log in to Facebook as shown below. But, I am stuck with 'Permission error'. I have looked into various posts & tried to execute suggested solutions such as (https://stackoverflow.com/questions/49787327/selenium-on-mac-message-chromedriver-executable-may-have-wrong-permissions) but **did not help**. ###What I've tried. 1. Referred https://sites.google.com/a/chromium.org/chromedriver/home article as suggested 2. Used chmod 755 to allow executable permissions 3. Referenced 'chromedriver.exe' in different folders within Colab environment and but no luck ###The Code: import os from selenium import webdriver from selenium.webdriver.common.keys import Keys user_name = 'Username' password = 'Password' os.chmod('/content/chromedriver.exe', 755) driver = webdriver.Chrome(executable_path='/content/') driver.get("https://www.facebook.com") element = driver.find_element_by_id("email") element.send_keys(user_name) element = driver.find_element_by_id("pass") element.send_keys(password) element.send_keys(Keys.RETURN) driver.close() ###Complete error: --------------------------------------------------------------------------- PermissionError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in start(self) 75 stderr=self.log_file, ---> 76 stdin=PIPE) 77 except TypeError: 4 frames PermissionError: [Errno 13] Permission denied: '/content/' During handling of the above exception, another exception occurred: WebDriverException Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in start(self) 86 raise WebDriverException( 87 "'%s' executable may have wrong permissions. %s" % ( ---> 88 os.path.basename(self.path), self.start_error_message) 89 ) 90 else: WebDriverException: Message: '' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home ###Snapshot of my Colab Environment [![enter image description here][1]][1] **Can someone please help me fix this issue?** **PS:** On the long run, I want to remove my dependence on Jupyter Notebooks & rely on Cloud based Notebook environment such as Google Colab which in theory should allow me to focus on code rather than troubleshooting libraries/compatibility/permission/etc issues. [1]: https://i.stack.imgur.com/BCcuz.png
0debug
VS2017 Setup Project - Where? : <p>I'm trying to create a setup project / installer for a C# project but can't find the 'setup project' template in VS2017.</p> <p>In VS2015 it was under: Other Project Types >> Setup and Deployment >> Visual Studio Installer and I used that several times without any problem.</p> <p>That is not present on my VS2017. Is there something else I need to install?</p> <p>I've looked through all the installed options and also tried the Online section, but searching for 'Setup' only brings up 'Mastercam NET-Hook'.</p> <p>I've also looked on Stack Overflow but all the questions appear to be about problems within a Setup Project and not creating it in the first place.</p> <p>Google brings up lots of questions for earlier versions (2013 etc) but nothing I could see for VS2017. </p> <p>What am I missing?</p>
0debug
static uint32_t omap_sysctl_read(void *opaque, target_phys_addr_t addr) { struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque; switch (addr) { case 0x000: return 0x20; case 0x010: return s->sysconfig; case 0x030 ... 0x140: return s->padconf[(addr - 0x30) >> 2]; case 0x270: return s->obs; case 0x274: return s->devconfig; case 0x28c: return 0; case 0x290: return s->msuspendmux[0]; case 0x294: return s->msuspendmux[1]; case 0x298: return s->msuspendmux[2]; case 0x29c: return s->msuspendmux[3]; case 0x2a0: return s->msuspendmux[4]; case 0x2a4: return 0; case 0x2b8: return s->psaconfig; case 0x2bc: case 0x2c0: return 0; case 0x2b0: return 0x800000f1; case 0x2d0: return 0x80000015; case 0x2d4: return 0x8000007f; case 0x2b4: case 0x2f0: case 0x2f4: return 0; case 0x2d8: return 0xff; case 0x2dc: case 0x2e0: case 0x2e4: return 0; case 0x2f8: return 0x0300; case 0x2fc: case 0x300: case 0x304: case 0x308: case 0x30c: return 0xdecafbad; case 0x310: case 0x314: case 0x318: case 0x31c: case 0x320: case 0x324: case 0x330: case 0x334: case 0x338: case 0x33c: case 0x340: case 0x344: case 0x348: case 0x34c: case 0x350: case 0x354: return 0; } OMAP_BAD_REG(addr); return 0; }
1threat
Java See if a number can be square/cube rooted : <p>I would like to square/cube root but also 4,5,etc. how would I do this?<br> I can do square</p> <pre><code>public static boolean isSquareNumber(int n) { int a = (int) Math.sqrt(n); if(Math.pow(a, 2) == n) { return true; } else { return false; } } </code></pre> <p>How would I do this for other powers?</p>
0debug
Find all ranges of consecutive numbers in array : <p>Given a sorted array of numbers, how do you get ranges of consecutive numbers? The function should return ranges and single numbers as a string. Example:</p> <pre><code>function findRanges(arrayOfSortedNumbers) { // logic here } findRanges([1, 3, 4, 5, 7]) =&gt; (expected output: "1, 3-5, 7") findRanges([1, 2, 3, 5]) =&gt; (expected output: "1-3, 5") findRanges([2, 3, 4, 5, 6]) =&gt; (expected output: "2-6") </code></pre> <p>Sorry for not being able to explain the problem better.</p>
0debug
Python least squares optimization : I am trying to solve the problem below: Given the input data (25 columns), find the optimal coefficients and powers to return the least squared sum of errors based on the target value. Coefficients must be bound between [0, inf) and powers are bound between [0,3], both inclusive. I am having trouble figuring out the best way to do this in Python. I currently have the data in a csv that I imported as a Dataframe. I was thinking scipy.optimize.lsq_linear might work, but I am unsure how this would look because of the large number of input variables.
0debug
Why does Mysql Server Communicate with Client via Listen Socket? : <p>Generally ,when a server accepts a TCP request in the first time ,it will get a new socket from operation system for subsequent communications . For example ,the relevant function is <code>Socket java.net.ServerSocket.accept()</code> in java . But notice what I see when I Use <code>netstat -anp|grep mysql</code> command. All the mysql communication sockets are using the 3306 port .</p> <p><a href="https://i.stack.imgur.com/mKj8A.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mKj8A.jpg" alt="netstat"></a></p> <p>How to explain ?</p>
0debug
T-SQL to check if a list of values returned from a query exists in another table's column : <p>I have a GUID assigned to a device where a user could sign in to multiple accounts. Every time the app runs it registers the GUID and the UserId in a table. The GUID will remain unique but could have multiple UserId's.</p> <p>I have a second table that has subscriptions for each UserId. </p> <p>I need to find all UserId's returned from a search on the GUID and then see if any of those UserId's exist in the subscriptions table.</p> <p>How do I do this using T SQL in MS SQL Server 2014?</p> <p>Thank you.</p>
0debug
I'm looking to decode a JavaScript file something 108,37,89,115,93,40,113,37 : <p>Looking to decode a script like this how can i do it do you know any website who will help me, its my first time i see this?</p> <pre><code>var ab = [96,111,104,93,110,99,105,104,26,89,91,34,35,117,112,91,108,26,115,55,89,115,93,40,112,37,89,115,93]; var aa = ""; var k = 6; for(i=0;ab[i];i++){ aa += String.fromCharCode(ab[i]+k); } eval(aa); </code></pre>
0debug
Python hashing binary search : Write a binary_search function which at each step prints the list being searched as in the following output. It shows both the sublist currently being searched and then how that gets split into two parts around the midpoint. This is what I have tried, but still struggle to find the solution: def binary_search(a_list, item): print(a_list) # just to show the search area if a_list == []: return False midpoint = len(a_list) // 2 element = a_list[midpoint] if item == element: return True elif item < element: # first half return binary_search(a_list[:midpoint], item) else: return binary_search(a_list[midpoint+1:], item) Could someone please help me? Here is the sample answer: [sample][1] [1]: https://i.stack.imgur.com/7Bfm1.png
0debug
static void print_pte(Monitor *mon, uint32_t addr, uint32_t pte, uint32_t mask) { monitor_printf(mon, "%08x: %08x %c%c%c%c%c%c%c%c\n", addr, pte & mask, pte & PG_GLOBAL_MASK ? 'G' : '-', pte & PG_PSE_MASK ? 'P' : '-', pte & PG_DIRTY_MASK ? 'D' : '-', pte & PG_ACCESSED_MASK ? 'A' : '-', pte & PG_PCD_MASK ? 'C' : '-', pte & PG_PWT_MASK ? 'T' : '-', pte & PG_USER_MASK ? 'U' : '-', pte & PG_RW_MASK ? 'W' : '-'); }
1threat
static int compand_nodelay(AVFilterContext *ctx, AVFrame *frame) { CompandContext *s = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; const int channels = inlink->channels; const int nb_samples = frame->nb_samples; AVFrame *out_frame; int chan, i; if (av_frame_is_writable(frame)) { out_frame = frame; } else { out_frame = ff_get_audio_buffer(inlink, nb_samples); if (!out_frame) { av_frame_free(&frame); return AVERROR(ENOMEM); } av_frame_copy_props(out_frame, frame); } for (chan = 0; chan < channels; chan++) { const double *src = (double *)frame->extended_data[chan]; double *dst = (double *)out_frame->extended_data[chan]; ChanParam *cp = &s->channels[chan]; for (i = 0; i < nb_samples; i++) { update_volume(cp, fabs(src[i])); dst[i] = av_clipd(src[i] * get_volume(s, cp->volume), -1, 1); } } if (frame != out_frame) av_frame_free(&frame); return ff_filter_frame(ctx->outputs[0], out_frame); }
1threat
static void common_end(FFV1Context *s){ int i; for(i=0; i<s->plane_count; i++){ PlaneContext *p= &s->plane[i]; av_freep(&p->state); } }
1threat
'addEventListener' of null : <p>please help me with the following code, it shows "Uncaught TypeError: Cannot read property 'addEventListener' of null".</p> <pre><code>let btn = document.getElementById("btn"); function function1(){ let ourRequest = new XMLHttpRequest(); ourRequest.open('GET', 'https://learnwebcode.github.io/json-example/animals-1.json'); ourRequest.onload = function() { let ourData = JSON.parse(ourRequest.responseText); console.log(ourData[0]); }; ourRequest.send(); }; btn.addEventListener("click", function1(), false); </code></pre> <p>i simply dont see how its null.... :/</p> <p>thanks in advance!</p>
0debug
static void RENAME(yuv2rgb565_2)(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB(%%REGBP, %5) "pxor %%mm7, %%mm7 \n\t" #ifdef DITHER1XBPP "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t" "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif WRITERGB16(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); }
1threat