problem
stringlengths
26
131k
labels
class label
2 classes
External library in Android : <p>i was wondering if it's good to use external libraries took from git hub and use it in a professional app.This libraries may produce low performance or lag? Big company use external libraries for own apps?</p>
0debug
how to make sure a file's integrity in C# : <p>I am deploying a file along with a C# application. And I want to make sure that file is same as it was supplied otherwise the C# application will show error. Now, a file's creation and modification date can be changed after it is modified. Is there any checksum/hash etc. in C# to make sure file is not changed by user.</p>
0debug
WebSockets in Chrome and Firefox Disconnecting After One Minute of Inactivity : <p>I have found that WebSockets in Chrome and Firefox disconnect after exactly one minute of inactivity. Based on stuff I've seen online, I was all set to blame proxies or some server settings or something, but this does not happen in IE or Edge. It seems like if sockets are disconnected by the server after one minute of inactivity that would apply to IE and Edge just as much as Chrome and Firefox.</p> <p>Does anyone know why this is? Is it documented anywhere? I know a possible way to stop it by pinging, but I'm more interested in why it's happening. The reason code given on disconnect is 1006, indicating that the browser closed the connection. No errors are thrown and the onerror event for the socket is not triggered.</p> <p>This project was built at <a href="https://glitch.com/edit/#!/noiseless-helmet" rel="noreferrer">https://glitch.com/edit/#!/noiseless-helmet</a> where you can see and run everything. The client page is served here: <a href="https://noiseless-helmet.glitch.me/" rel="noreferrer">https://noiseless-helmet.glitch.me/</a></p> <p>Here is my client page:</p> <pre><code>&lt;div id="div"&gt; &lt;/div&gt; &lt;script&gt; let socket = new WebSocket("wss://noiseless-helmet.glitch.me/"); socket.onmessage = function(event) { div.innerHTML += "&lt;br&gt;message " + new Date().toLocaleString() + " " + event.data; }; socket.onopen = function (event) { div.innerHTML += "&lt;br&gt;opened " + new Date().toLocaleString(); socket.send("Hey socket! " + new Date().toLocaleString()); }; socket.onclose = function(event) { div.innerHTML += "&lt;br&gt;socket closed " + new Date().toLocaleString(); div.innerHTML += "&lt;br&gt;code: " + event.code; div.innerHTML += "&lt;br&gt;reason: " + event.reason; div.innerHTML += "&lt;br&gt;clean: " + event.wasClean; }; socket.onerror = function(event) { div.innerHTML += "&lt;br&gt;error: " + event.error; }; &lt;/script&gt; </code></pre> <p>And here is my Node.js server code:</p> <pre><code>var express = require('express'); var app = express(); app.use(express.static('public')); let server = require('http').createServer(), WebSocketServer = require('ws').Server, wss = new WebSocketServer({ server: server }); app.get("/", function (request, response) { response.sendFile(__dirname + '/views/index.html'); }); let webSockets = []; wss.on('connection', function connection(socket) { webSockets.push(socket); webSockets.forEach((w) =&gt; { w.send("A new socket connected"); }); socket.on('close', (code, reason) =&gt; { console.log('closing socket'); console.log(code); console.log(reason); let i = webSockets.indexOf(socket); webSockets.splice(i, 1); }); }); server.on('request', app); server.listen(process.env.PORT, function () { console.log('Your app is listening on port ' + server.address().port); }); </code></pre>
0debug
test_opts_range_unvisited(void) { intList *list = NULL; intList *tail; QemuOpts *opts; Visitor *v; opts = qemu_opts_parse(qemu_find_opts("userdef"), "ilist=0-2", false, &error_abort); v = opts_visitor_new(opts); visit_start_struct(v, NULL, NULL, 0, &error_abort); visit_start_list(v, "ilist", (GenericList **)&list, sizeof(*list), &error_abort); tail = list; visit_type_int(v, NULL, &tail->value, &error_abort); g_assert_cmpint(tail->value, ==, 0); tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list)); g_assert(tail); visit_type_int(v, NULL, &tail->value, &error_abort); g_assert_cmpint(tail->value, ==, 1); tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list)); g_assert(tail); visit_check_list(v, &error_abort); visit_end_list(v, (void **)&list); visit_check_struct(v, &error_abort); visit_end_struct(v, NULL); qapi_free_intList(list); visit_free(v); qemu_opts_del(opts); }
1threat
Async OnActionExecuting in ASP.NET Core's ActionFilterAttribute : <p>ASP.NET Core's <code>ActionFilterAttribute</code> has these:</p> <pre><code>public virtual void OnActionExecuting(ActionExecutingContext context); public virtual void OnActionExecuted(ActionExecutedContext context); public virtual Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next); </code></pre> <p>I need an async version of <code>OnActionExecuting</code>, which doesn't exist.</p> <p>However I have a feeling that I can use <code>OnActionExecutionAsync</code> instead, as it also has an argument of <code>ActionExecutingContext</code>.</p> <p>Am I correct that despite the name, they trigger at the same point in the process?</p> <p>Also, what do I need to do with the <code>next</code> argument? Once I'm done with my stuff, do I simply need to call <code>await next()</code>?</p> <p>Is that it? I'm unsure as I can't find docs for this.</p>
0debug
void pc_cmos_set_s3_resume(void *opaque, int irq, int level) { ISADevice *s = opaque; if (level) { rtc_set_memory(s, 0xF, 0xFE); } }
1threat
static void decode_mb_b(AVSContext *h, enum cavs_mb mb_type) { int block; enum cavs_sub_mb sub_type[4]; int flags; ff_cavs_init_mb(h); h->mv[MV_FWD_X0] = ff_cavs_dir_mv; set_mvs(&h->mv[MV_FWD_X0], BLK_16X16); h->mv[MV_BWD_X0] = ff_cavs_dir_mv; set_mvs(&h->mv[MV_BWD_X0], BLK_16X16); switch(mb_type) { case B_SKIP: case B_DIRECT: if(!h->col_type_base[h->mbidx]) { ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_BSKIP, BLK_16X16, 1); ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_BSKIP, BLK_16X16, 0); } else for(block=0;block<4;block++) mv_pred_direct(h,&h->mv[mv_scan[block]], &h->col_mv[h->mbidx*4 + block]); break; case B_FWD_16X16: ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1); break; case B_SYM_16X16: ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_MEDIAN, BLK_16X16, 1); mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_16X16); break; case B_BWD_16X16: ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_MEDIAN, BLK_16X16, 0); break; case B_8X8: for(block=0;block<4;block++) sub_type[block] = get_bits(&h->s.gb,2); for(block=0;block<4;block++) { switch(sub_type[block]) { case B_SUB_DIRECT: if(!h->col_type_base[h->mbidx]) { ff_cavs_mv(h, mv_scan[block], mv_scan[block]-3, MV_PRED_BSKIP, BLK_8X8, 1); ff_cavs_mv(h, mv_scan[block]+MV_BWD_OFFS, mv_scan[block]-3+MV_BWD_OFFS, MV_PRED_BSKIP, BLK_8X8, 0); } else mv_pred_direct(h,&h->mv[mv_scan[block]], &h->col_mv[h->mbidx*4 + block]); break; case B_SUB_FWD: ff_cavs_mv(h, mv_scan[block], mv_scan[block]-3, MV_PRED_MEDIAN, BLK_8X8, 1); break; case B_SUB_SYM: ff_cavs_mv(h, mv_scan[block], mv_scan[block]-3, MV_PRED_MEDIAN, BLK_8X8, 1); mv_pred_sym(h, &h->mv[mv_scan[block]], BLK_8X8); break; } } for(block=0;block<4;block++) { if(sub_type[block] == B_SUB_BWD) ff_cavs_mv(h, mv_scan[block]+MV_BWD_OFFS, mv_scan[block]+MV_BWD_OFFS-3, MV_PRED_MEDIAN, BLK_8X8, 0); } break; default: av_assert2((mb_type > B_SYM_16X16) && (mb_type < B_8X8)); flags = ff_cavs_partition_flags[mb_type]; if(mb_type & 1) { if(flags & FWD0) ff_cavs_mv(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP, BLK_16X8, 1); if(flags & SYM0) mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_16X8); if(flags & FWD1) ff_cavs_mv(h, MV_FWD_X2, MV_FWD_A1, MV_PRED_LEFT, BLK_16X8, 1); if(flags & SYM1) mv_pred_sym(h, &h->mv[MV_FWD_X2], BLK_16X8); if(flags & BWD0) ff_cavs_mv(h, MV_BWD_X0, MV_BWD_C2, MV_PRED_TOP, BLK_16X8, 0); if(flags & BWD1) ff_cavs_mv(h, MV_BWD_X2, MV_BWD_A1, MV_PRED_LEFT, BLK_16X8, 0); } else { if(flags & FWD0) ff_cavs_mv(h, MV_FWD_X0, MV_FWD_B3, MV_PRED_LEFT, BLK_8X16, 1); if(flags & SYM0) mv_pred_sym(h, &h->mv[MV_FWD_X0], BLK_8X16); if(flags & FWD1) ff_cavs_mv(h,MV_FWD_X1,MV_FWD_C2,MV_PRED_TOPRIGHT,BLK_8X16,1); if(flags & SYM1) mv_pred_sym(h, &h->mv[MV_FWD_X1], BLK_8X16); if(flags & BWD0) ff_cavs_mv(h, MV_BWD_X0, MV_BWD_B3, MV_PRED_LEFT, BLK_8X16, 0); if(flags & BWD1) ff_cavs_mv(h,MV_BWD_X1,MV_BWD_C2,MV_PRED_TOPRIGHT,BLK_8X16,0); } } ff_cavs_inter(h, mb_type); set_intra_mode_default(h); if(mb_type != B_SKIP) decode_residual_inter(h); ff_cavs_filter(h,mb_type); }
1threat
static void mux_print_help(CharDriverState *chr) { int i, j; char ebuf[15] = "Escape-Char"; char cbuf[50] = "\n\r"; if (term_escape_char > 0 && term_escape_char < 26) { snprintf(cbuf, sizeof(cbuf), "\n\r"); snprintf(ebuf, sizeof(ebuf), "C-%c", term_escape_char - 1 + 'a'); } else { snprintf(cbuf, sizeof(cbuf), "\n\rEscape-Char set to Ascii: 0x%02x\n\r\n\r", term_escape_char); } qemu_chr_fe_write(chr, (uint8_t *)cbuf, strlen(cbuf)); for (i = 0; mux_help[i] != NULL; i++) { for (j=0; mux_help[i][j] != '\0'; j++) { if (mux_help[i][j] == '%') qemu_chr_fe_write(chr, (uint8_t *)ebuf, strlen(ebuf)); else qemu_chr_fe_write(chr, (uint8_t *)&mux_help[i][j], 1); } } }
1threat
document.location = 'http://evil.com?username=' + user_input;
1threat
static void mipsnet_cleanup(NetClientState *nc) { MIPSnetState *s = qemu_get_nic_opaque(nc); s->nic = NULL; }
1threat
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
how stop auto reloading table view while scrolling table upward and downward directions in swift ? : <p>I'm using table view for filling data and displaying same data in table with single custom cell(both viewing and editing). While editing what ever the data entered and scrolled top to bottom the data was entered in cell it was gone because auto reloading.</p> <p>Please help me how to stop table auto reloading.</p> <p>Thanks</p>
0debug
Need to retrieve and convert to an integer using SELECT SCOPE_IDENTITY : <p>I'm trying to match the users ID (pk) on the 'users' table, with the users ID (fk) on the 'owners' table, but it seems to not be working.</p> <p>But it gives me and error on the dono (onwer) saying that I need to convert it.</p> <pre><code> protected void confirmarButton_Click(object sender, EventArgs e) { int n = 0; if (primeiroNome.Text != "" &amp; nomeDoMeio.Text != "" &amp;&amp; sobrenome.Text != "" &amp;&amp; dataDeNascimento.Text != "" &amp;&amp; enderecoPostal1.Text != "" &amp;&amp; cidade.Text != "" &amp;&amp; email.Text != "" &amp;&amp; username.Text != "" &amp;&amp; password.Text != "" &amp;&amp; confirmarPassword.Text != "") { if (password.Text == confirmarPassword.Text) { String CS = ConfigurationManager.ConnectionStrings["ClinicaAnimal"].ConnectionString; using (SqlConnection con = new SqlConnection(CS)) { n = userIdNumber(); SqlCommand cmd2 = new SqlCommand("Insert into Users ([Username], [Password],[Tipo de User])Values('" + username.Text + "','" + Encrypt(password.Text.Trim()) + "','" + "Dono" + "')", con); // cmd2.Parameters.AddWithValue("@Password", Encrypt(password.Text.Trim())); SqlCommand cmd = new SqlCommand("Insert into Dono ([Primeiro Nome], [Nome do Meio], [Sobrenome], [Data de Nascimento], [Endereço Postal1], [Endereço Postal2], [Cidade], [Email], [UserID])Values('" + primeiroNome.Text + "','" + nomeDoMeio.Text + "','" + sobrenome.Text + "','" + dataDeNascimento.Text + "','" + enderecoPostal1.Text + " ','" + enderecoPostal2.Text + " ','" + cidade.Text + " ','" + email.Text + "','"+ "SELECT SCOPE_IDENTITY()" +"')", con); con.Open(); cmd2.ExecuteNonQuery(); cmd.ExecuteNonQuery(); Response.Redirect("~/Home.aspx"); } } else </code></pre>
0debug
return is undefined JAVASCRIPT : <p>I have a question??.Why this function return value is undefined. i don't understand.</p> <p>Help to solve me please.</p> <p><a href="https://i.stack.imgur.com/wIb8N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wIb8N.png" alt="enter image description here"></a></p>
0debug
static void hdcd_reset(hdcd_state_t *state, unsigned rate) { int i; state->window = 0; state->readahead = 32; state->arg = 0; state->control = 0; state->running_gain = 0; state->sustain = 0; state->sustain_reset = rate * 10; state->code_counterA = 0; state->code_counterA_almost = 0; state->code_counterB = 0; state->code_counterB_checkfails = 0; state->code_counterC = 0; state->code_counterC_unmatched = 0; state->count_peak_extend = 0; state->count_transient_filter = 0; for(i = 0; i < 16; i++) state->gain_counts[i] = 0; state->max_gain = 0; state->count_sustain_expired = -1; }
1threat
static void scsi_unmap_complete_noio(UnmapCBData *data, int ret) { SCSIDiskReq *r = data->r; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); uint64_t sector_num; uint32_t nb_sectors; assert(r->req.aiocb == NULL); if (r->req.io_canceled) { scsi_req_cancel_complete(&r->req); goto done; } if (ret < 0) { if (scsi_handle_rw_error(r, -ret, false)) { goto done; } } if (data->count > 0) { sector_num = ldq_be_p(&data->inbuf[0]); nb_sectors = ldl_be_p(&data->inbuf[8]) & 0xffffffffULL; if (!check_lba_range(s, sector_num, nb_sectors)) { scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE)); goto done; } r->req.aiocb = blk_aio_discard(s->qdev.conf.blk, sector_num * (s->qdev.blocksize / 512), nb_sectors * (s->qdev.blocksize / 512), scsi_unmap_complete, data); data->count--; data->inbuf += 16; return; } scsi_req_complete(&r->req, GOOD); done: scsi_req_unref(&r->req); g_free(data); }
1threat
Random generation in Java : <p>Is there a method like the <code>rng.randint()</code> in the code below for Java? </p> <p>Are Math.random() o java.util.Random viable for this aim?</p> <pre><code> ... rng.seed(random_seed) child1, child2 = parents const1 = child1.const_set const2 = child2.const_set cp1 = rng.randint(1, len(const1) - 1) if len(const1) &gt; 1 else 0 cp2 = rng.randint(1, len(const2) - 1) if len(const2) &gt; 1 else 0 </code></pre>
0debug
python take the values ​in ascending order and delet non increasing values : python program. how do I take the elements in ascending order of a whole list and delete items that do not follow the growth? exemple [2,4,3,5,6,8] #output [2, 4, 5, 6, 8]
0debug
static void dequantization_int(int x, int y, Jpeg2000Cblk *cblk, Jpeg2000Component *comp, Jpeg2000T1Context *t1, Jpeg2000Band *band) { int i, j, idx; int32_t *datap = (int32_t *) &comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x]; for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) for (i = 0; i < (cblk->coord[0][1] - cblk->coord[0][0]); ++i) { idx = (comp->coord[0][1] - comp->coord[0][0]) * j + i; datap[idx] = ((int32_t)(t1->data[j][i]) * band->i_stepsize + (1 << 15)) >> 16; } }
1threat
componentDidUpdate vs componentWillReceiveProps use case in react : <p>This is how we use <code>componentWillReceiveProps</code></p> <pre><code>componentWillReceiveProps(nextProps) { if(nextProps.myProp !== this.props.myProps) { // nextProps.myProp has a different value than our current prop } } </code></pre> <p>It's very similar to <code>componentDidUpdate</code></p> <pre><code>componentDidUpdate(prevProps) { if(prevProps.myProps !== this.props.myProp) { // this.props.myProp has a different value // ... } } </code></pre> <p>I can see some differences, like if I do setState in componentDidUpdate, render will trigger twice, and the argument for componentWillReceiveProps is nextProps, while argument for <code>componentDidUpdate</code> is prevProp, but seriously I don't know when to use them. I often use <code>componentDidUpdate</code>, but with prevState, like change a dropdown state and call api</p> <p>eg.</p> <pre><code>componentDidUpdate(prevProps, prevState) { if(prevState.seleted !== this.state.seleted) { this.setState({ selected: something}, ()=&gt; callAPI()) } } </code></pre>
0debug
static int dvvideo_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { uint8_t *buf = avpkt->data; int buf_size = avpkt->size; DVVideoContext *s = avctx->priv_data; const uint8_t* vsc_pack; int apt, is16_9, ret; const DVprofile *sys; sys = avpriv_dv_frame_profile2(avctx, s->sys, buf, buf_size); if (!sys || buf_size < sys->frame_size) { av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n"); return -1; } if (sys != s->sys) { ret = ff_dv_init_dynamic_tables(s, sys); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error initializing the work tables.\n"); return ret; } s->sys = sys; } s->frame = data; s->frame->key_frame = 1; s->frame->pict_type = AV_PICTURE_TYPE_I; avctx->pix_fmt = s->sys->pix_fmt; avctx->time_base = s->sys->time_base; ret = ff_set_dimensions(avctx, s->sys->width, s->sys->height); if (ret < 0) return ret; vsc_pack = buf + 80*5 + 48 + 5; if ( *vsc_pack == dv_video_control ) { apt = buf[4] & 0x07; is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07))); ff_set_sar(avctx, s->sys->sar[is16_9]); } if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0) return ret; s->frame->interlaced_frame = 1; s->frame->top_field_first = 0; if ( *vsc_pack == dv_video_control ) { s->frame->top_field_first = !(vsc_pack[3] & 0x40); } s->buf = buf; avctx->execute(avctx, dv_decode_video_segment, s->work_chunks, NULL, dv_work_pool_size(s->sys), sizeof(DVwork_chunk)); emms_c(); *got_frame = 1; return s->sys->frame_size; }
1threat
def pos_nos(list1): for num in list1: if num >= 0: return num
0debug
void HELPER(crypto_aese)(CPUARMState *env, uint32_t rd, uint32_t rm, uint32_t decrypt) { static uint8_t const sbox[][256] = { { 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }, { 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d } }; static uint8_t const shift[][16] = { { 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11 }, { 0, 13, 10, 7, 4, 1, 14, 11, 8, 5, 2, 15, 12, 9, 6, 3 }, }; union AES_STATE rk = { .l = { float64_val(env->vfp.regs[rm]), float64_val(env->vfp.regs[rm + 1]) } }; union AES_STATE st = { .l = { float64_val(env->vfp.regs[rd]), float64_val(env->vfp.regs[rd + 1]) } }; int i; assert(decrypt < 2); rk.l[0] ^= st.l[0]; rk.l[1] ^= st.l[1]; for (i = 0; i < 16; i++) { st.bytes[i] = sbox[decrypt][rk.bytes[shift[decrypt][i]]]; } env->vfp.regs[rd] = make_float64(st.l[0]); env->vfp.regs[rd + 1] = make_float64(st.l[1]); }
1threat
static int asf_read_single_payload(AVFormatContext *s, AVPacket *pkt, ASFPacket *asf_pkt) { ASFContext *asf = s->priv_data; AVIOContext *pb = s->pb; int64_t offset; uint64_t size; unsigned char *p; int ret; if (!asf_pkt->data_size) { asf_pkt->data_size = asf_pkt->size_left = avio_rl32(pb); if (asf_pkt->data_size <= 0) return AVERROR_EOF; if ((ret = av_new_packet(&asf_pkt->avpkt, asf_pkt->data_size)) < 0) return ret; } else avio_skip(pb, 4); asf_pkt->dts = avio_rl32(pb); if (asf->rep_data_len >= 8) avio_skip(pb, asf->rep_data_len - 8); offset = avio_tell(pb); if (asf->packet_size_internal) size = asf->packet_size_internal - offset + asf->packet_offset - asf->pad_len; else size = asf->packet_size - offset + asf->packet_offset - asf->pad_len; if (size > asf->packet_size) { av_log(s, AV_LOG_ERROR, "Error: invalid data packet size, offset %"PRId64".\n", avio_tell(pb)); return AVERROR_INVALIDDATA; } p = asf_pkt->avpkt.data + asf_pkt->data_size - asf_pkt->size_left; if (size > asf_pkt->size_left || asf_pkt->size_left <= 0) return AVERROR_INVALIDDATA; if (asf_pkt->size_left > size) asf_pkt->size_left -= size; else asf_pkt->size_left = 0; if ((ret = avio_read(pb, p, size)) < 0) return ret; if (s->key && s->keylen == 20) ff_asfcrypt_dec(s->key, p, ret); if (asf->packet_size_internal) avio_skip(pb, asf->packet_size - asf->packet_size_internal); avio_skip(pb, asf->pad_len); return 0; }
1threat
static CharDriverState *text_console_init(ChardevVC *vc, Error **errp) { CharDriverState *chr; QemuConsole *s; unsigned width = 0; unsigned height = 0; chr = qemu_chr_alloc(); if (vc->has_width) { width = vc->width; } else if (vc->has_cols) { width = vc->cols * FONT_WIDTH; } if (vc->has_height) { height = vc->height; } else if (vc->has_rows) { height = vc->rows * FONT_HEIGHT; } trace_console_txt_new(width, height); if (width == 0 || height == 0) { s = new_console(NULL, TEXT_CONSOLE, 0); } else { s = new_console(NULL, TEXT_CONSOLE_FIXED_SIZE, 0); s->surface = qemu_create_displaysurface(width, height); } if (!s) { g_free(chr); error_setg(errp, "cannot create text console"); return NULL; } s->chr = chr; chr->opaque = s; chr->chr_set_echo = text_console_set_echo; chr->explicit_be_open = true; if (display_state) { text_console_do_init(chr, display_state); } return chr; }
1threat
I need assistance with understanding the / and % symbol from Java. Also, I need some advice on how to proceed with the code : <p>Alright, let us start off, by showing my question.</p> <h2>The Problem:</h2> <p>10001st prime</p> <p>By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.</p> <h2>What is the 10 001st prime number?</h2> <p>This is what I currently have down. I'm pretty bad at creating algorithms, but I truly have the desire to follow in my Father's path of being a IT. I enjoy doing this a lot, but I'm struggling right now.</p> <pre><code>public class PrimeNumber { public static void main(String[] args) { int primeNum = 2; for (int count = 0; count &lt; 10002; count++) { if (primeNum / 2 == &amp;&amp; primeNum / primeNum == 1) { primeNum++; } else { System.out.println("Error."); } } System.out.println(primeNum); } } </code></pre>
0debug
Bootstrap col-md-offset-* not working : <p>I'm trying to add Bootstrap offset class in my code to achieve diagonal alignment like this:</p> <p><a href="https://i.stack.imgur.com/FHTgp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FHTgp.png" alt="Image "></a></p> <p>But I don't know what offset should I use. I've tried couple of offsets to achieve this but no use.Text is covering whole jumbotron.Here is my code</p> <p>Html:</p> <pre><code>&lt;div class="jumbotron"&gt; &lt;div class="container"&gt; &lt;div class="row"&gt; &lt;div&gt; &lt;h2 class="col-md-4 col-md-offset-4"&gt;Browse.&lt;/h2&gt; &lt;h2 class="col-md-4 col-md-offset-4"&gt;create.&lt;/h2&gt; &lt;h2 class="col-md-4 col-md-offset-4"&gt;share.&lt;/h2&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>.jumbotron { height: 500px; width: 100%; background-image: url(img/bg.jpg); background-size: cover; background-position: center; } .jumbotron h2 { color: white; font-size: 60px; } .jumbotron h2:first-child { margin: 120px 0 0; } </code></pre> <p>Please guide me.Thank you in advance.</p>
0debug
void cpu_x86_load_seg(CPUX86State *s, int seg_reg, int selector) { CPUX86State *saved_env; saved_env = env; env = s; if (env->eflags & VM_MASK) { SegmentCache *sc; selector &= 0xffff; sc = &env->seg_cache[seg_reg]; sc->base = (void *)(selector << 4); sc->limit = 0xffff; sc->seg_32bit = 0; env->segs[seg_reg] = selector; } else { load_seg(seg_reg, selector, 0); } env = saved_env; }
1threat
in C++, can I get the array size of a float[]? : <p>I have a variable of type float[] in C++. The variable is defined in a third-party header file and accessible from my source code. Can I get the size of the variable at run-time?</p>
0debug
static void vmmouse_reset(DeviceState *d) { VMMouseState *s = container_of(d, VMMouseState, dev.qdev); s->status = 0xffff; s->queue_size = VMMOUSE_QUEUE_SIZE; }
1threat
notifyDataSetChanged() NullPointerException : <p>i try to add onClick this button then create contact in database</p> <p>Here is code i try to add it to main_fragment</p> <pre><code> final Button addBtn = (Button) view.findViewById(R.id.btnadd); addBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri imageUri = Uri.parse("android.resource://org.intracode.contactmanager/drawable/no_user_logo.png"); import_fragment.Contact contact = new import_fragment.Contact(dbHandler.getContactsCount(), String.valueOf(nametxt.getText()), String.valueOf(phoneTxt.getText()), String.valueOf(emailTxt.getText()), String.valueOf(addressTxt.getText()), imageUri); if (!contactExists(contact)) { dbHandler.createContact(contact); Contacts.add(contact); contactAdapter.notifyDataSetChanged(); // Error in this line Toast.makeText(getActivity().getApplicationContext(), String.valueOf(nametxt.getText()) + " has been added to your Contacts!", Toast.LENGTH_SHORT).show(); return; } Toast.makeText(getActivity().getApplicationContext(), String.valueOf(nametxt.getText()) + " already exists. Please use a different name.", Toast.LENGTH_SHORT).show(); } }); </code></pre> <p>When i press this button in my app, 'app has stopped working'</p> <p>Here is my logcat</p> <pre><code>01-22 08:31:04.014 29398-29398/com.al3almya.users.al3almya E/AndroidRuntime: FATAL EXCEPTION: main Process: com.al3almya.users.al3almya, PID: 29398 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ArrayAdapter.notifyDataSetChanged()' on a null object reference at com.al3almya.users.al3almya.main_fragment$1.onClick(main_fragment.java:77) at android.view.View.performClick(View.java:4848) at android.view.View$PerformClick.run(View.java:20262) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5637) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) </code></pre>
0debug
How to convert two Array : <p>What is the best way to convert:</p> <pre><code>["Isolated-1", "SVT_FedPortGroup", "SVT_StoragePortGroup", "VM Network", "test-pg-2002"] </code></pre> <p>and this : </p> <pre><code>["target_Isolated-1", "target_SVT_FedPortGroup", "target_SVT_StoragePortGroup","target_VM Network" ,"target_test-pg-2002"]; </code></pre> <p>to:</p> <pre><code>"NetworkMaps": [ { "ENVID": null, "SourcePG": "Isolated-1", "TargetPG": "target_Isolated-1" }, { "ENVID": null, "SourcePG": "VM Network", "TargetPG": "target_SVT_FedPortGroup" }... ] </code></pre> <p>I need to to merge two array with respective values. For example</p> <pre><code> arr1 : ["a", "b", "c"]; arr2 : ["apple", "ball", "cat"]; result : [{source: "a",target: "apple"}, {source: "b",target: "ball"},{source: "c",target: "cat"}] </code></pre>
0debug
static void tgen_compare_branch(TCGContext *s, S390Opcode opc, int cc, TCGReg r1, TCGReg r2, int labelno) { TCGLabel* l = &s->labels[labelno]; intptr_t off; if (l->has_value) { off = l->u.value_ptr - s->code_ptr; } else { off = s->code_ptr[1]; tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, labelno, -2); } tcg_out16(s, (opc & 0xff00) | (r1 << 4) | r2); tcg_out16(s, off); tcg_out16(s, cc << 12 | (opc & 0xff)); }
1threat
Is linking one project class to another project cause any performance or mermory issue in c# .Net? : I have linked some of the classes from one project to another project by using the below codes. This code added in my csproject file. <ItemGroup> <Compile Include="..\..\OrignialFile\ClassName.cs"> <Link>Destination\ClassName.cs</Link> </Compile> </ItemGroup> While running the application by adding these project files as reference i have faced some performance issue (i.e takes such long time for execution). Before linking i can able to do the same at minimal time. So i suspect linking classes could be reason for the performance issue. Is my suspection is correct, if it true please help me to resolve this issue?
0debug
Returning the length of largest word in a sentence : <p>I have written a function which receives a sentence and calculates the longest word in that sentence.</p> <pre><code>function findLongestWord(str) { var charArray = str.split(" "); var wordArray = []; for(var i = 0; i &lt; charArray.length; i++ ) { wordArray.push(charArray[i].length); wordArray.sort(); wordArray.reverse(); } return wordArray[0]; } </code></pre> <p>My function works with inputs such as:</p> <pre><code>findLongestWord("The quick brown fox jumped over the lazy dog"); </code></pre> <p>But when i pass it: </p> <pre><code>findLongestWord("What if we try a super-long word such as otorhinolaryngology") </code></pre> <p>The function returns:</p> <pre><code>4 </code></pre> <p>Rather than </p> <pre><code>19 </code></pre>
0debug
void event_notifier_set_handler(EventNotifier *e, EventNotifierHandler *handler) { iohandler_init(); aio_set_event_notifier(iohandler_ctx, e, false, handler, NULL); }
1threat
static void xhci_intr_raise(XHCIState *xhci, int v) { PCIDevice *pci_dev = PCI_DEVICE(xhci); xhci->intr[v].erdp_low |= ERDP_EHB; xhci->intr[v].iman |= IMAN_IP; xhci->usbsts |= USBSTS_EINT; if (!(xhci->intr[v].iman & IMAN_IE)) { if (!(xhci->usbcmd & USBCMD_INTE)) { if (msix_enabled(pci_dev)) { trace_usb_xhci_irq_msix(v); msix_notify(pci_dev, v); if (msi_enabled(pci_dev)) { trace_usb_xhci_irq_msi(v); msi_notify(pci_dev, v); if (v == 0) { trace_usb_xhci_irq_intx(1); pci_irq_assert(pci_dev);
1threat
Open URL in browser from Message Button using Slack API : <p>I am sending the users a slack message with a button through a Slack App. On every click of the button, I generate a new URL. </p> <p>At the moment, I am able to return the URL back as a message. The user clicks on the message to open the URL in the browser.</p> <p>Instead of the sending a message back, I want to open the URL directly in the browser using slack API. </p> <p>How can I accomplish it? I can't seem to find anything in the documentation that does that.</p> <p>Thanks</p> <p>PS: Google Drive integration does that already.</p>
0debug
Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true : <p>I am using <a href="https://github.com/babenkoivan/scout-elasticsearch-driver" rel="noreferrer">https://github.com/babenkoivan/scout-elasticsearch-driver</a> to implement Elasticsearch with Laravel Scout. Ivan mentions this at Github:</p> <blockquote> <p>Indices created in Elasticsearch 6.0.0 or later may only contain a single mapping type. Indices created in 5.x with multiple mapping types will continue to function as before in Elasticsearch 6.x. Mapping types will be completely removed in Elasticsearch 7.0.0.</p> </blockquote> <p>If I understood right here: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/removal-of-types.html" rel="noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/master/removal-of-types.html</a> I either need to use: </p> <p>1) PUT index?include_type_name=true</p> <p>or, better</p> <p>2) PUT index/_doc/1 { "foo": "baz" }</p> <p>I am stucked since I have no idea how to use either 1) or 2)</p> <p>How can I add the parameter include_type_name=true?</p> <p>How can I create the right mapping without using the include_type_name parameter?</p> <pre><code>class TestIndexConfigurator extends IndexConfigurator { use Migratable; /** * @var array */ protected $settings = [ ]; protected $name = 'test'; } </code></pre>
0debug
How can I make Angular HTTP Post wait for node js response : <p>i am new to Angular/Node JS, and I am doing a project for university where I am trying to implement authorization/authentication in my frontend and backend.</p> <p>So I made the method Login in the Node JS and testing with postman the response is what I want. But when I send call the method login in the Angular it doesnt return anything.</p> <p>Using debug I could observe that the angular doesnt await for the response of Node JS, how can I make it only continue when the response arrives?</p> <p>Node JS Method</p> <pre><code>exports.cliente_login = function (req, res){ let cliente = transform.ToLogin(req); service.ClienteLogin(cliente, function (cliente, erro) { if (cliente) { res.json(cliente); } else { return res.send(erro); } }) </code></pre> <p>Angular Service Method </p> <pre><code>loginCliente(cliente): Observable&lt;Cliente&gt; { return this.http.post&lt;Cliente&gt;(this.myAppUrl + this.myApiUrl + 'login', JSON.stringify(cliente), this.httpOptions) .pipe( retry(1), catchError(this.errorHandler) ); } </code></pre> <p>Angular Auth Method</p> <pre><code>login(email: string, password: string) { let user: any; let userLogin = new UserToLogin(); userLogin.email = email; userLogin.password = password; user = this.clienteService.loginCliente(userLogin); if (user &amp;&amp; user.token) { // store user details and jwt token in local storage to keep user logged in between page refreshes localStorage.setItem('currentUser', JSON.stringify(user)); this.currentUserSubject.next(user); } return user; } </code></pre> <p>Thank you for your help !</p>
0debug
Angular 2.0 translate Pipe could not be found : <p>I have a component that uses the translateService, but it's not possible to translate items with the pipe on the Component Template HTML, i get following error:</p> <blockquote> <p>The pipe 'translate' could not be found</p> </blockquote> <p>app.module.ts</p> <pre><code>import {BrowserModule} from "@angular/platform-browser"; import {NgModule} from "@angular/core"; import {HttpModule, Http} from "@angular/http"; import {TranslateModule, TranslateLoader, TranslateStaticLoader} from 'ng2-translate'; import {AppComponent} from "./app.component"; @NgModule({ declarations: [AppComponent], imports: [ BrowserModule, HttpModule, TranslateModule.forRoot({ provide: TranslateLoader, useFactory: (http: Http) =&gt; new TranslateStaticLoader(http, './assets/i18n', '.json'), deps: [Http] }) ], bootstrap: [AppComponent] }) export class AppModule { } </code></pre> <p>booking.component.ts</p> <pre><code>import {Component, OnInit} from '@angular/core'; import {BookingComponent} from './booking.component'; import {TranslateService} from 'ng2-translate'; @Component({ selector: 'app-booking', templateUrl: './booking.component.html', styleUrls: ['./booking.component.css'] }) export class BookingComponent implements OnInit { constructor(private translate: TranslateService ) { translate.setDefaultLang('de'); translate.use('de'); }; ngOnInit() { } } </code></pre> <p>booking.component.html</p> <pre><code>&lt;p&gt;{{'TESTKEY' | translate }}&lt;/p&gt; </code></pre> <p>The translation with the service on the component works fine, but i need to translate also the html with pipe</p>
0debug
How can i measure the usage of my android app? (e.g. in Play Console) : Is there a way to measure the usage (startups) of my android app? In Play Console i only see the installations/deinstallations but not the startups etc.? Well - i could implement a tracker on my own that access an interface on each startup - but i wonder if it's really necessary or if google provides that. Thanks.
0debug
Bootstrap 4 layout with one width fixed column : <p>this is my html code:</p> <pre><code>&lt;div class="container-fluid d-flex h-100"&gt; &lt;div class="white h-100" style="background-color: white;"&gt; fixed 100px &lt;/div&gt; &lt;div class="col-3 blue h-100" style="background-color: blue;"&gt; 3 &lt;/div&gt; &lt;div class="col-6 red h-100" style="background-color: red;"&gt; 6 &lt;/div&gt; &lt;div class="col-3 blue h-100" style="background-color: blue;"&gt; 3 &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Can you help me to fix my code please? I need on left side column with fixed width, which will be have 100px. This column have not resize. Rest of space I need to should be dynamically adjustable in ratio 1 : 2 : 1. Thanks for help.</p>
0debug
How to remove all occurrence with a specific pattern? : <p>Suppose I have a file like this:</p> <pre><code>EN;05;UK;55;EN;66;US;87;US;89;EN;66;UK;87; </code></pre> <p>I want remove all the <code>EN</code> occurrence, so the final string should be:</p> <pre><code>UK;55;US;87;US;89;UK;87; </code></pre> <p>I can remove the <code>EN</code> using <code>string.Replace("EN", "")</code> but how to remove also the number?</p>
0debug
How to disable npm's progress bar : <p>As pointed out <a href="https://github.com/npm/npm/issues/11283" rel="noreferrer">here</a> the progress bar of npm slows down the whole installation progress significantly. The solution given is to disable it</p> <pre><code>$&gt; npm set progress=false &amp;&amp; npm install </code></pre> <p>The question I have, is it possible inside a project to set something (in package.json for example) such that I can omit <code>progress=false</code> on the command line and simply can do <code>$&gt; npm install</code> and obtain the same result as above?</p>
0debug
Parse Numbers from Text : I want to parse number from Text Line in SQL. My Text line is as: [![enter image description here][1]][1] I want to retrieve values of First & second as column using SQL as below. [![enter image description here][2]][2] [1]: https://i.stack.imgur.com/ZG5ac.png [2]: https://i.stack.imgur.com/ICM5j.png
0debug
static void uart_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { MilkymistUartState *s = opaque; unsigned char ch = value; trace_milkymist_uart_memory_write(addr, value); addr >>= 2; switch (addr) { case R_RXTX: if (s->chr) { qemu_chr_fe_write(s->chr, &ch, 1); } s->regs[R_STAT] |= STAT_TX_EVT; break; case R_DIV: case R_CTRL: case R_DBG: s->regs[addr] = value; break; case R_STAT: s->regs[addr] &= ~(value & (STAT_RX_EVT | STAT_TX_EVT)); break; default: error_report("milkymist_uart: write access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } uart_update_irq(s); }
1threat
List of swagger UI alternatives : <p>Is there any Swagger UI alternatives ? I already know:</p> <ul> <li><a href="http://swaggerui.herokuapp.com/#!/pet/addPet" rel="noreferrer">http://swaggerui.herokuapp.com/#!/pet/addPet</a></li> <li><a href="http://public.redfroggy.fr/swagger2" rel="noreferrer">http://public.redfroggy.fr/swagger2</a></li> </ul>
0debug
How to remove all docker volumes? : <p>If I do a <code>docker volume ls</code>, my list of volumes is like this:</p> <pre><code>DRIVER VOLUME NAME local 305eda2bfd9618266093921031e6e341cf3811f2ad2b75dd7af5376d037a566a local 226197f60c92df08a7a5643f5e94b37947c56bdd4b532d4ee10d4cf21b27b319 ... ... local 209efa69f1679224ab6b2e7dc0d9ec204e3628a1635fa3410c44a4af3056c301 </code></pre> <p>and I want to remove all of my volumes at once. How can I do it?</p>
0debug
How to stop the closing of date-picker of pickadate.js on blur? : I want to remain open my date-picker calendar on click outside the calendar. Please tell me the exact solution. Thanks in Advance.
0debug
Microsoft Excel Macro: Bulk Reading and Writing First Line and Rest of File : <p>I am trying to make a macro that will bulk perform on all .txt files in a given directory. I would like the first line to be copied into the first cell (A1). And then I would like the rest of the contents to be pasted into B1. </p> <p>The macro would perform that for all the .txt files in a directory, except it would go to A2, B2...A3,B3 etc</p> <p>Can anyone help?</p>
0debug
Why hash maps in Java 8 use binary tree instead of linked list? : <p>I recently came to know that in Java 8 hash maps uses binary tree instead of linked list and hash code is used as the branching factor.I understand that in case of high collision the lookup is reduced to O(log n) from O(n) by using binary trees.My question is what good does it really do as the amortized time complexity is still O(1) and maybe if you force to store all the entries in the same bucket by providing the same hash code for all keys we can see a significant time difference but no one in their right minds would do that.</p> <p>Binary tree also uses more space than singly linked list as it stores both left and right nodes.Why increase the space complexity when there is absolutely no improvement in time complexity except for some spurious test cases.</p>
0debug
int msix_uninit(PCIDevice *dev, MemoryRegion *bar) { if (!(dev->cap_present & QEMU_PCI_CAP_MSIX)) return 0; pci_del_capability(dev, PCI_CAP_ID_MSIX, MSIX_CAP_LENGTH); dev->msix_cap = 0; msix_free_irq_entries(dev); dev->msix_entries_nr = 0; memory_region_del_subregion(bar, &dev->msix_mmio); memory_region_destroy(&dev->msix_mmio); g_free(dev->msix_table_page); dev->msix_table_page = NULL; g_free(dev->msix_entry_used); dev->msix_entry_used = NULL; dev->cap_present &= ~QEMU_PCI_CAP_MSIX; return 0; }
1threat
Convert from HttpResponseMessage to IActionResult in .NET Core : <p>I'm porting over some code that was previously written in .NET Framework to .NET Core.</p> <p>I had something like this:</p> <pre><code>HttpResponseMessage result = await client.SendAync(request); if (result.StatusCode != HttpStatusCode.OK) { IHttpActionResult response = ResponseMessage(result); return response; } </code></pre> <p>The return value of this function is now <code>IActionResult</code>.</p> <p>How do I take the <code>HttpResponseMessage result</code> object and return an <code>IActionResult</code> from it?</p>
0debug
hi i'm trying to echo condition by given input but results are three times i want single result condition by given input : **hi here is the code please answer my question hi i'm trying to echo condition by given input but results are three times i want single result condition by given input ** <?php $arrayName = array('bravo','alpha','jhony' ); foreach ($arrayName as $key ){ if(isset($_REQUEST['num1']) && $_REQUEST['num1']== $key ){ echo "yes". $_REQUEST['num1']. "Available"; } else{ echo "Sorry!".$_REQUEST['num1']." is not available"; } } ?> <form action="" method="get" accept-charset="utf-8"> <input type="text" name="num1"> <button type="submit">submit</button></form>
0debug
spring-configuration-metadata.json file is not generated in IntelliJ Idea for Kotlin @ConfigurationProperties class : <p>I'm trying to generate spring-configuration-metadata.json file for my Spring Boot based project. If I use Java <strong>@ConfigurationProperties</strong> class it is generated correctly and automatically:</p> <pre><code>@ConfigurationProperties("myprops") public class MyProps { private String hello; public String getHello() { return hello; } public void setHello(String hello) { this.hello = hello; } } </code></pre> <p>But if I use Kotlin class the <strong>spring-configuration-metadata.json</strong> file is not generated (I've tried both <strong>gradle build</strong> and Idea <strong>Rebuild Project</strong>).</p> <pre><code>@ConfigurationProperties("myprops") class MyProps { var hello: String? = null } </code></pre> <p>AFAIK Kotlin generates the same class with constructor, getters and setters and should act as regular Java bean.</p> <p>Any ideas why <strong>spring-boot-configuration-processor</strong> doesn't work with Kotlin classes?</p>
0debug
static bool run_poll_handlers_once(AioContext *ctx) { bool progress = false; AioHandler *node; QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) { if (!node->deleted && node->io_poll && aio_node_check(ctx, node->is_external) && node->io_poll(node->opaque)) { progress = true; } } return progress; }
1threat
How to pass a JS value into a PHP parameter : <p>In the code added here, I pass on value from PHP parameter to JS parameter: Both parameters are called 'stv'.</p> <p>I wonder how do I do the exact opposite?</p> <p>Thanks!</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script&gt; var stv="&lt;?php echo $stv; ?&gt;"; &lt;/script&gt;</code></pre> </div> </div> </p>
0debug
Hiiiii, i can show data in emulator from mysql database but not retrive in smartphones : [i retrived data from MySQL database, but it show in emulator, and not retrive in devices. ][1] [so plz tell why this problem i get and how i reslove this.][2] [1]: https://i.stack.imgur.com/dE1Yr.jpg [2]: https://i.stack.imgur.com/pObaI.png
0debug
Whats best way to have indexing in mysql : Need a support! Seems like small question, but i am puzzled. I have a table with around 25 columns. The table will contains many lakhs of rows at any point of time. I want to run below query continously in loop. SELECT recordfile FROM MYTABLE WHERE duration = '0' AND attempt < max_attempt AND thread =1 ORDER BY id ASC It looks like query is taking more time(0.0150 secs on avg) Please help to put proper indexing or any other method, to make the query optimally quick. Thanks!
0debug
How to include the end date in a DatePeriod? : <p>I am trying to get a Date range for all workdays this week. I have written the following code to do so.</p> <h3>Code</h3> <pre><code>$begin = new DateTime('monday this week'); 2016-07-04 $end = clone $begin; $end-&gt;modify('next friday'); // 2016-07-08 $interval = new DateInterval('P1D'); $daterange = new DatePeriod($begin, $interval, $end); foreach($daterange as $date) { echo $date-&gt;format('Y-m-d')."&lt;br /&gt;"; } </code></pre> <h3>Output</h3> <ul> <li>2016-07-04</li> <li>2016-07-05</li> <li>2016-07-06</li> <li>2016-07-07</li> </ul> <p>In the output friday is missing. I can fix this by doing <code>$end-&gt;modify('next saturday')</code> but I was wondering why the last day of a <code>DatePeriod</code> is not included in the range.</p>
0debug
C++ malloc(): memory corruption : <p>I am currently going through a fibonacci practice problem on hackerrank and am having a malloc memory corruption error. This is the link to the problem I am doing:</p> <p><a href="https://www.hackerrank.com/contests/programming-interview-questions/challenges/fibonacci-returns/" rel="nofollow noreferrer">https://www.hackerrank.com/contests/programming-interview-questions/challenges/fibonacci-returns/</a></p> <p>Input is 0-10, each number separated by a new line. For each input, the value at that point in the sequence is printed. It works for small inputs, but after 6 it gets the malloc error. It doesn't seem that the size of the sequence is an issue either, just how many are done in succession.</p> <pre><code>#include &lt;cmath&gt; #include &lt;cstdio&gt; #include &lt;vector&gt; #include &lt;iostream&gt; #include &lt;algorithm&gt; using namespace std; vector&lt;int&gt; bigFib(1); int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int x; while(cin &gt;&gt; x){ if(bigFib.size()-1 &gt;= x){ cout &lt;&lt; bigFib[x] &lt;&lt; endl; } else{ vector&lt;int&gt; fib(x); fib[0] = 0; fib[1] = 1; for(int j = 2; j &lt;= x; j++){ fib[j] = fib[j-1] + fib[j-2]; } bigFib = fib; cout &lt;&lt; fib[x] &lt;&lt; endl; } } return 0; } </code></pre> <p>I am pretty new to C++ and can't find the problem. Thanks for your time.</p>
0debug
static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { S302MEncContext *s = avctx->priv_data; const int buf_size = AES3_HEADER_LEN + (frame->nb_samples * avctx->channels * (avctx->bits_per_raw_sample + 4)) / 8; int ret, c, channels; uint8_t *o; PutBitContext pb; if ((ret = ff_alloc_packet2(avctx, avpkt, buf_size)) < 0) return ret; o = avpkt->data; init_put_bits(&pb, o, buf_size * 8); put_bits(&pb, 16, buf_size - AES3_HEADER_LEN); put_bits(&pb, 2, (avctx->channels - 2) >> 1); put_bits(&pb, 8, 0); put_bits(&pb, 2, (avctx->bits_per_raw_sample - 16) / 4); put_bits(&pb, 4, 0); flush_put_bits(&pb); o += AES3_HEADER_LEN; if (avctx->bits_per_raw_sample == 24) { const uint32_t *samples = (uint32_t *)frame->data[0]; for (c = 0; c < frame->nb_samples; c++) { uint8_t vucf = s->framing_index == 0 ? 0x10: 0; for (channels = 0; channels < avctx->channels; channels += 2) { o[0] = ff_reverse[(samples[0] & 0x0000FF00) >> 8]; o[1] = ff_reverse[(samples[0] & 0x00FF0000) >> 16]; o[2] = ff_reverse[(samples[0] & 0xFF000000) >> 24]; o[3] = ff_reverse[(samples[1] & 0x00000F00) >> 4] | vucf; o[4] = ff_reverse[(samples[1] & 0x000FF000) >> 12]; o[5] = ff_reverse[(samples[1] & 0x0FF00000) >> 20]; o[6] = ff_reverse[(samples[1] & 0xF0000000) >> 28]; o += 7; samples += 2; } s->framing_index++; if (s->framing_index >= 192) s->framing_index = 0; } } else if (avctx->bits_per_raw_sample == 20) { const uint32_t *samples = (uint32_t *)frame->data[0]; for (c = 0; c < frame->nb_samples; c++) { uint8_t vucf = s->framing_index == 0 ? 0x80: 0; for (channels = 0; channels < avctx->channels; channels += 2) { o[0] = ff_reverse[ (samples[0] & 0x000FF000) >> 12]; o[1] = ff_reverse[ (samples[0] & 0x0FF00000) >> 20]; o[2] = ff_reverse[((samples[0] & 0xF0000000) >> 28) | vucf]; o[3] = ff_reverse[ (samples[1] & 0x000FF000) >> 12]; o[4] = ff_reverse[ (samples[1] & 0x0FF00000) >> 20]; o[5] = ff_reverse[ (samples[1] & 0xF0000000) >> 28]; o += 6; samples += 2; } s->framing_index++; if (s->framing_index >= 192) s->framing_index = 0; } } else if (avctx->bits_per_raw_sample == 16) { const uint16_t *samples = (uint16_t *)frame->data[0]; for (c = 0; c < frame->nb_samples; c++) { uint8_t vucf = s->framing_index == 0 ? 0x10 : 0; for (channels = 0; channels < avctx->channels; channels += 2) { o[0] = ff_reverse[ samples[0] & 0xFF]; o[1] = ff_reverse[(samples[0] & 0xFF00) >> 8]; o[2] = ff_reverse[(samples[1] & 0x0F) << 4] | vucf; o[3] = ff_reverse[(samples[1] & 0x0FF0) >> 4]; o[4] = ff_reverse[(samples[1] & 0xF000) >> 12]; o += 5; samples += 2; } s->framing_index++; if (s->framing_index >= 192) s->framing_index = 0; } } *got_packet_ptr = 1; return 0; }
1threat
int virtio_load(VirtIODevice *vdev, QEMUFile *f) { int i, ret; int32_t config_len; uint32_t num; uint32_t features; uint32_t supported_features; BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); if (k->load_config) { ret = k->load_config(qbus->parent, f); if (ret) return ret; } qemu_get_8s(f, &vdev->status); qemu_get_8s(f, &vdev->isr); qemu_get_be16s(f, &vdev->queue_sel); if (vdev->queue_sel >= VIRTIO_PCI_QUEUE_MAX) { return -1; } qemu_get_be32s(f, &features); if (virtio_set_features(vdev, features) < 0) { supported_features = k->get_features(qbus->parent); error_report("Features 0x%x unsupported. Allowed features: 0x%x", features, supported_features); return -1; } config_len = qemu_get_be32(f); if (config_len != vdev->config_len) { error_report("Unexpected config length 0x%x. Expected 0x%zx", config_len, vdev->config_len); return -1; } qemu_get_buffer(f, vdev->config, vdev->config_len); num = qemu_get_be32(f); if (num > VIRTIO_PCI_QUEUE_MAX) { error_report("Invalid number of PCI queues: 0x%x", num); return -1; } for (i = 0; i < num; i++) { vdev->vq[i].vring.num = qemu_get_be32(f); if (k->has_variable_vring_alignment) { vdev->vq[i].vring.align = qemu_get_be32(f); } vdev->vq[i].pa = qemu_get_be64(f); qemu_get_be16s(f, &vdev->vq[i].last_avail_idx); vdev->vq[i].signalled_used_valid = false; vdev->vq[i].notification = true; if (vdev->vq[i].pa) { uint16_t nheads; virtqueue_init(&vdev->vq[i]); nheads = vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].last_avail_idx; if (nheads > vdev->vq[i].vring.num) { error_report("VQ %d size 0x%x Guest index 0x%x " "inconsistent with Host index 0x%x: delta 0x%x", i, vdev->vq[i].vring.num, vring_avail_idx(&vdev->vq[i]), vdev->vq[i].last_avail_idx, nheads); return -1; } } else if (vdev->vq[i].last_avail_idx) { error_report("VQ %d address 0x0 " "inconsistent with Host index 0x%x", i, vdev->vq[i].last_avail_idx); return -1; } if (k->load_queue) { ret = k->load_queue(qbus->parent, i, f); if (ret) return ret; } } virtio_notify_vector(vdev, VIRTIO_NO_VECTOR); return 0; }
1threat
Return input value inside a function : <p>I need help if someone types a wrong input it should return the question again in python3.</p> <p>I tried to return the variable.</p> <pre><code>def main(): this = input ('Is this your ..? (Yes/No)') if this != 'Yes' and this != 'No': print ('please provide a valid answer') </code></pre> <p>I want to ask the question again and again until the answer will be Yes or No.</p>
0debug
LocalDateTime variable stopped being live : <p>When I first ran my code (below) it printed out the live time (ignore the "LOL", that was for debugging purposes..), but I've been running it over and over for a while now while doing other stuff and I realized it wasn't printing the live time anymore, just the time it registered the first time I ran it. Code:</p> <pre class="lang-java prettyprint-override"><code> public static String classCheck(){ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HH:MM"); LocalDateTime now = LocalDateTime.now(); System.out.println(dtf.format(now)+"LOL"); int currentTime = toMins(dtf.format(now)); //Beging collecting preset class timings.. String classOneBegin = "11:00", classTwoBegin = "12:30", classThreeBegin = "14:00", classFourBegin = "16:30", classFourEnd = "18:00"; int classOneBeginX, classTwoBeginX, classThreeBeginX, classFourBeginX, classFourEndX; classOneBeginX = timeCheck.toMins(classOneBegin); classTwoBeginX = timeCheck.toMins(classTwoBegin); classThreeBeginX = timeCheck.toMins(classThreeBegin); classFourBeginX = timeCheck.toMins(classFourBegin); classFourEndX = timeCheck.toMins(classFourEnd); //...End. I feel confident that I could've found a faster, more inclusive solution to this, but time is of the essence.. //Now to compare the time with each "cycle" and return an int that represent the current class. if (currentTime &gt;= classOneBeginX &amp;&amp; currentTime &lt;= classTwoBeginX) { return "4"; }else if(currentTime &gt;= classTwoBeginX &amp;&amp; currentTime &lt;= classThreeBeginX){ return "1"; }else if(currentTime &gt;= classThreeBeginX &amp;&amp; currentTime &lt;= classFourBeginX){ return "2"; }else if(currentTime &gt;= classFourBeginX &amp;&amp; currentTime &lt;= classFourEndX){ return "3"; }else return "0"; //Outside of class time .. } </code></pre> <p>I'm not sure where the issue is to be honest, the lines of code of focus here is lines 2~4</p> <pre class="lang-java prettyprint-override"><code>DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HH:MM"); LocalDateTime now = LocalDateTime.now(); System.out.println(dtf.format(now)+"LOL"); </code></pre> <p>It's stuck at 2:04, but it's currently 3:08 right now, I was expecting that each time I ran my code it'd print the live time (+"LOL"..)</p>
0debug
Convert Date from Json in React Native : I'm taking the date from an API that looks like this on render '20180914' and I'd like it to transform it into something more common, like 09/14/2018. I've looked around and found that the momentJS is how to achieve this, but I'm still having trouble with it, as I'm a RN noob :S I'm using Fetch to get my API and I get the date from `{item.segments[0].date2}`. Can you tell me how to use this with moment? thank you so much for your time.
0debug
how to concat a variable to a regex in C# : <p>I am trying to concat a variable to a regen in c# but it is not working</p> <pre><code>string color_id = "sdsdssd"; Match variations = Regex.Match (data, @""+color_id+"_[^\""]*\""\W\,\""sizes\""\:\s*\W.*?businessCatalogItemId"":\"")", RegexOptions.IgnoreCase);@""+color_id+"_[^\""]*\""\W\,\""sizes\""\:\s*\W.*?businessCatalogItemId"":\"")"; </code></pre> <p>But the above is not working</p> <p>How to concat a variable at starting element to regex in c#</p>
0debug
Xamarin Studio not Recognizing Provisioning Profiles : <p>I'm at my wit's end with these apple certificates. I have a Xamarin.Forms app that I need to sign with a provisioning profile so I can enable push notifications. However, Xamarin Studio isn't recognizing any of the provisioning profiles that I'm making. Can someone please help?</p> <p>Xamarin Studio trying to link provisioning profiles, profile 23devpp not found: <a href="https://i.stack.imgur.com/pez1Z.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pez1Z.png" alt="enter image description here"></a></p> <p>Xcode finds prov. profile 23devpp: <a href="https://i.stack.imgur.com/CI05C.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CI05C.png" alt="enter image description here"></a></p> <p>Developer window has provisioning profile marked as active: <a href="https://i.stack.imgur.com/5iygS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5iygS.png" alt="enter image description here"></a></p>
0debug
void error_setg_errno(Error **errp, int os_errno, const char *fmt, ...) { va_list ap; char *msg; int saved_errno = errno; if (errp == NULL) { return; } va_start(ap, fmt); error_setv(errp, ERROR_CLASS_GENERIC_ERROR, fmt, ap); va_end(ap); if (os_errno != 0) { msg = (*errp)->msg; (*errp)->msg = g_strdup_printf("%s: %s", msg, strerror(os_errno)); g_free(msg); } errno = saved_errno; }
1threat
static int vfio_connect_container(VFIOGroup *group, AddressSpace *as) { VFIOContainer *container; int ret, fd; VFIOAddressSpace *space; space = vfio_get_address_space(as); QLIST_FOREACH(container, &space->containers, next) { if (!ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &container->fd)) { group->container = container; QLIST_INSERT_HEAD(&container->group_list, group, container_next); return 0; } } fd = qemu_open("/dev/vfio/vfio", O_RDWR); if (fd < 0) { error_report("vfio: failed to open /dev/vfio/vfio: %m"); ret = -errno; goto put_space_exit; } ret = ioctl(fd, VFIO_GET_API_VERSION); if (ret != VFIO_API_VERSION) { error_report("vfio: supported vfio version: %d, " "reported version: %d", VFIO_API_VERSION, ret); ret = -EINVAL; goto close_fd_exit; } container = g_malloc0(sizeof(*container)); container->space = space; container->fd = fd; if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU) || ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU)) { bool v2 = !!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU); struct vfio_iommu_type1_info info; ret = ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &fd); if (ret) { error_report("vfio: failed to set group container: %m"); ret = -errno; goto free_container_exit; } container->iommu_type = v2 ? VFIO_TYPE1v2_IOMMU : VFIO_TYPE1_IOMMU; ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type); if (ret) { error_report("vfio: failed to set iommu for container: %m"); ret = -errno; goto free_container_exit; } info.argsz = sizeof(info); ret = ioctl(fd, VFIO_IOMMU_GET_INFO, &info); if (ret || !(info.flags & VFIO_IOMMU_INFO_PGSIZES)) { info.iova_pgsizes = 4096; } vfio_host_win_add(container, 0, (hwaddr)-1, info.iova_pgsizes); } else if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_IOMMU) || ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_v2_IOMMU)) { struct vfio_iommu_spapr_tce_info info; bool v2 = !!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_v2_IOMMU); ret = ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &fd); if (ret) { error_report("vfio: failed to set group container: %m"); ret = -errno; goto free_container_exit; } container->iommu_type = v2 ? VFIO_SPAPR_TCE_v2_IOMMU : VFIO_SPAPR_TCE_IOMMU; ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type); if (ret) { error_report("vfio: failed to set iommu for container: %m"); ret = -errno; goto free_container_exit; } if (!v2) { ret = ioctl(fd, VFIO_IOMMU_ENABLE); if (ret) { error_report("vfio: failed to enable container: %m"); ret = -errno; goto free_container_exit; } } else { container->prereg_listener = vfio_prereg_listener; memory_listener_register(&container->prereg_listener, &address_space_memory); if (container->error) { memory_listener_unregister(&container->prereg_listener); error_report("vfio: RAM memory listener initialization failed for container"); goto free_container_exit; } } info.argsz = sizeof(info); ret = ioctl(fd, VFIO_IOMMU_SPAPR_TCE_GET_INFO, &info); if (ret) { error_report("vfio: VFIO_IOMMU_SPAPR_TCE_GET_INFO failed: %m"); ret = -errno; if (v2) { memory_listener_unregister(&container->prereg_listener); } goto free_container_exit; } vfio_host_win_add(container, info.dma32_window_start, info.dma32_window_start + info.dma32_window_size - 1, 0x1000); } else { error_report("vfio: No available IOMMU models"); ret = -EINVAL; goto free_container_exit; } container->listener = vfio_memory_listener; memory_listener_register(&container->listener, container->space->as); if (container->error) { ret = container->error; error_report("vfio: memory listener initialization failed for container"); goto listener_release_exit; } container->initialized = true; QLIST_INIT(&container->group_list); QLIST_INSERT_HEAD(&space->containers, container, next); group->container = container; QLIST_INSERT_HEAD(&container->group_list, group, container_next); return 0; listener_release_exit: vfio_listener_release(container); free_container_exit: g_free(container); close_fd_exit: close(fd); put_space_exit: vfio_put_address_space(space); return ret; }
1threat
How to implement a debounce time in keyup event in Angular 6 : <p>I create an Angular app that search students from API. It works fine but it calls API every time an input value is changed. I've done a research that I need something called debounce ,but I don't know how to implement this in my app.</p> <p><strong>App.component.html</strong></p> <pre><code> &lt;div class="container"&gt; &lt;h1 class="mt-5 mb-5 text-center"&gt;Student&lt;/h1&gt; &lt;div class="form-group"&gt; &lt;input class="form-control form-control-lg" type="text" [(ngModel)]=q (keyup)=search() placeholder="Search student by id or firstname or lastname"&gt; &lt;/div&gt; &lt;hr&gt; &lt;table class="table table-striped mt-5"&gt; &lt;thead class="thead-dark"&gt; &lt;tr&gt; &lt;th scope="col" class="text-center" style="width: 10%;"&gt;ID&lt;/th&gt; &lt;th scope="col" class="text-center" style="width: 30%;"&gt;Name&lt;/th&gt; &lt;th scope="col" style="width: 30%;"&gt;E-mail&lt;/th&gt; &lt;th scope="col" style="width: 30%;"&gt;Phone&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr *ngFor="let result of results"&gt; &lt;th scope="row"&gt;{{result.stu_id}}&lt;/th&gt; &lt;td&gt;{{result.stu_fname}} {{result.stu_lname}}&lt;/td&gt; &lt;td&gt;{{result.stu_email}}&lt;/td&gt; &lt;td&gt;{{result.stu_phonenumber}}&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> <p><strong>App.component.ts</strong></p> <pre><code>import { Component} from '@angular/core'; import { Http,Response } from '@angular/http'; import { Subject, Observable } from 'rxjs'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { results; q = ''; constructor(private http:Http) { } search() { this.http.get("https://www.example.com/search/?q="+this.q) .subscribe( (res:Response) =&gt; { const studentResult = res.json(); console.log(studentResult); if(studentResult.success) { this.results = studentResult.data; } else { this.results = []; } } ) } } </code></pre> <p><strong>Screenshot</strong> <a href="https://i.stack.imgur.com/mt9mt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mt9mt.png" alt="Screenshot"></a></p> <p>I've tried something like this but it's error <strong>Property debounceTime does not exist on type Subject&lt;{}></strong></p> <pre><code> mySubject = new Subject(); constructor(private http:Http) { this.mySubject .debounceTime(5000) .subscribe(val =&gt; { //do what you want }); } </code></pre> <p>and this's also not work. <strong>Property 'fromEvent' does not exist on type 'typeof Observable'</strong> </p> <pre><code> Observable.fromEvent&lt;KeyboardEvent&gt;(this.getNativeElement(this.term), 'keyup') </code></pre> <p>So, what's the correct way to implement this ? </p> <p>Thank you.</p>
0debug
Count number of matching words from an array of words with another array of sentence in Javascript : <pre><code>var word_array = ['apple', 'mango', 'school']; var sentences = [ {name: 'Jon', info: 'Jon takes apple in school'}, {name: 'Anna', info: 'Anna loves to eat mango'}, {name: 'Dani', info: 'Dani wants to go to park today'} ]; </code></pre> <p>I want to count the matched words for each names of the sentences.</p> <pre><code>Output: Result = [ {name: 'Jon', count: 2}, {name: 'Anna', count: 1}, {name: 'Dani', count: 0} ]; </code></pre>
0debug
Install Oracle 12c on window 7 32bit : <p>Is there any manual or site on how to install oracle 12c on window 7 32 bit machine? I already downloaded the software but majority for the sites is for only 64bit machine </p>
0debug
how do i install J Query select2? : i have been trying to install and use select2 for my drop-down but i just cant get it to work, i tried following what is documented here: http://stackoverflow.com/questions/36132875/how-to-use-select2-bootstrap but still got no luck here is my code: <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.css"> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/select2-bootstrap-css/1.4.6/select2-bootstrap.css"> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.css"> <body> <script> $("#disease").select2({ allowClear:true, placeholder: 'Search for a disease' }); </script> <select id="disease" style="width: 40%; position: relative;top: 220px; left: 182px; " name="tdisease" > <option value="">Select Disease</option> <?php while ($row=$result->fetch_array(MYSQLI_ASSOC)) { ?> <option value="<?php echo $row['ICD10']?>"><?php echo $row['diagnosis'];?> </option> <?php } ?> </select> </body>
0debug
static void avc_luma_midh_qrt_and_aver_dst_16w_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, int32_t height, uint8_t horiz_offset) { uint32_t multiple8_cnt; for (multiple8_cnt = 4; multiple8_cnt--;) { avc_luma_midh_qrt_and_aver_dst_4w_msa(src, src_stride, dst, dst_stride, height, horiz_offset); src += 4; dst += 4; } }
1threat
static void sdl_callback (void *opaque, Uint8 *buf, int len) { SDLVoiceOut *sdl = opaque; SDLAudioState *s = &glob_sdl; HWVoiceOut *hw = &sdl->hw; int samples = len >> hw->info.shift; if (s->exit) { return; } while (samples) { int to_mix, decr; sdl_wait (s, "sdl_callback"); if (s->exit) { return; } if (sdl_lock (s, "sdl_callback")) { return; } if (audio_bug (AUDIO_FUNC, sdl->live < 0 || sdl->live > hw->samples)) { dolog ("sdl->live=%d hw->samples=%d\n", sdl->live, hw->samples); return; } if (!sdl->live) { goto again; } to_mix = audio_MIN (samples, sdl->live); decr = to_mix; while (to_mix) { int chunk = audio_MIN (to_mix, hw->samples - hw->rpos); st_sample_t *src = hw->mix_buf + hw->rpos; hw->clip (buf, src, chunk); sdl->rpos = (sdl->rpos + chunk) % hw->samples; to_mix -= chunk; buf += chunk << hw->info.shift; } samples -= decr; sdl->live -= decr; sdl->decr += decr; again: if (sdl_unlock (s, "sdl_callback")) { return; } } }
1threat
Is there a way to disable chrome autofill option for angular form fields : <p>I have tried using autocomplete false and also auto complete off. The cache is removed from the field, but iam still seeing chrome autofill data. Is there a way to disable chrome autofill option in angular forms? Any suggestions would be appreciated. Thanks </p>
0debug
parse json array with javascript : I have a mySQL database with a table of Latitudes and longitudes with associated data. I'm trying to create a Google Map and want to parse the JSON string using Javascript. I have looked here and on youtube and I don't know how to solve what I'm doing wrong. Here is my json string that I get with my echo statement: {"cm_mapTABLE":[["1","Angels Rest Photos OR","Angels_Rest_Photos_OR","663","aaj.jpg","2","Angel's Rest","Hike one of the trails in the Gorge with a scenic overlook, stream, and waterfall.","0","blue","4.5","45.5603","-122.171","http:\/\/www.eyehike.com\/pgallery\/index.php?\/category\/6","Angels_Rest_Photos_OR\/aae.thumb.jpg\" ALIGN=left HEIGHT=115 WIDTH=150>","http:\/\/www.eyehike.com\/pgallery\/i.php?\/galleries\/Angels_Rest_Photos_OR\/aaj-th.jpg","","","",""],["2","Ape Canyon Photos WA","Ape_Canyon_Photos_WA","681","PICT0114.jpg","3","Ape Canyon Trail","This trail is popular with hikers and mountain bikers with great views of several mountains.","0","blue","11","46.1653","-122.092","http:\/\/www.eyehike.com\/pgallery\/index.php?\/category\/8","Ape_Canyon_Photos_WA\/PICT0114.thumb.jpg\" ALIGN=left HEIGHT=115 WIDTH=150>","http:\/\/www.eyehike.com\/pgallery\/i.php?\/galleries\/Ape_Canyon_Photos_WA\/PICT0114-th.jpg","","","",""]]} Here is my code: <!DOCTYPE html> <head> <?php require("phpsqlsearch_dbinfo.php"); // This is the file with your logon info //$host="localhost"; //replace with your hostname //$username="root"; //replace with your username //$password=""; //replace with your password //$db_name="$database"; //replace with your database $con=mysqli_connect("$hostname", "$username", "$password", "$database")or die("cannot connect"); //mysqli_select_db("$db_name")or die("cannot select DB"); $sql = "select * from location_markers WHERE mrk_id < 3"; //replace emp_info with your table name $result = mysqli_query($con, $sql); $json_string_data = array(); if(mysqli_num_rows($result)){ while($row=mysqli_fetch_row($result)){ $json_string_data['cm_mapTABLE'][]=$row; } } mysqli_close($con); // You have to give the json a name to make it accessible by JS, e.g.: // echo 'file='.json_encode($json_string_data),';'; // This statement will echo the json output in the displayed web page echo json_encode($json_string_data); // please refer to our PHP JSON encode function tutorial for learning json_encode function in detail ?> </head> <body> <script> for (i = 0;i < $json_string_data.length;i++){ var javascript_string_data=<?php echo json_encode($json_string_data); ?>; document.write(cm_mapTABLE.rank[i]); } </script> </body> </html> I'm using Firebug and here is the error: ReferenceError: $json_string_data is not defined for (i = 0;i < $json_string_data.length;i++){ Could someone please tell me the proper way to refer to elements in my JSON string? Do I need to somehow get the field names in my JSON string?
0debug
php method argument type hinting with question mark (?type) : <p>I just felt on pieces of php (symfony/laravel) code using question mark in method type hints :</p> <pre><code>public function functionName(?int $arg = 0) </code></pre> <p>In other occasions the <strong>?type</strong> was not the last one, but I did not find any of these with no default yet.</p> <p>Problem is, I cannot find any information about this, and I checked :</p> <ul> <li>here : <a href="http://php.net/manual/en/migration70.new-features.php" rel="noreferrer">http://php.net/manual/en/migration70.new-features.php</a></li> <li>and here : <a href="http://php.net/manual/en/migration71.new-features.php" rel="noreferrer">http://php.net/manual/en/migration71.new-features.php</a></li> <li>and here : <a href="http://php.net/manual/en/functions.arguments.php" rel="noreferrer">http://php.net/manual/en/functions.arguments.php</a></li> </ul> <p>And same with 7.2, but since the code only requires 7.1, it seems rather normal.</p> <p>I also googled, and searched here, but either this is not documented or the question marks topic is defeating search engines.</p> <p>So I feel a little dumb now, and I would really appreciate if someone could enlighten me on the signification of this question mark in method signatures arguments.</p> <p>Thanks</p>
0debug
Swift 3 - Send make synchronous http request : <p>I have the following code:</p> <pre><code>func completeLoadAction(urlString:String) -&gt; Int { let url = URL(string:urlString.trimmingCharacters(in: .whitespaces)) let request = URLRequest(url: url!) let task = URLSession.shared.dataTask(with: request) { data, response, error in guard let data = data, error == nil else { // check for fundamental networking error print("error=\(error)") let ac = UIAlertController(title: "Unable to complete", message: "The load has been added to the completion queue. This will be processed once there is a connection.", preferredStyle: .alert) ac.addAction(UIAlertAction(title: "OK", style: .default)) self.present(ac, animated: true) return } let httpStatus = response as? HTTPURLResponse var httpStatusCode:Int = (httpStatus?.statusCode)! let responseString = String(data: data, encoding: .utf8) print("responseString = \(responseString)") let ac = UIAlertController(title: "Completed Successfully", message: "The "+coldel+" has been completed successfully", preferredStyle: .alert) ac.addAction(UIAlertAction(title:"Continue", style: .default, handler: { action in self.performSegue(withIdentifier: "segueConfirmedLoad", sender: self) })) self.present(ac, animated: true) } task.resume() return httpStatusCode } </code></pre> <p>I need to be able to call this and at the same time check the return value as it is the http status code, it will let me know if the call was successful or not.</p> <p>Problem is because it's in a dataTask I can't access the responses status code here</p> <pre><code>var httpStatusCode:Int = (httpStatus?.statusCode)! </code></pre> <p>Because the task doesn't start until Task.Resume() is called and the task is asynchronous so it will never work.</p> <p>Are there any ways around this?</p>
0debug
Creation of GSI taking long time : <p>I have a table with close to 2 billion rows already created in DynamoDB.</p> <p>Due to a query requirement, I had to create a Global Secondary Index(GSI) in it. The process of GSI creation started 36 hours ago but still isn't completed. Portal shows Item Count to be around 100 million. So long way to go.</p> <p>Questions:</p> <ol> <li>Why does it take such a long time when sufficient WCU and RCU are alotted( 30k in fact ).</li> <li>GSI partition key I've used is something whose values are repetitive, could that be the reason why GSI creation is taking more time (ideal scenario is that we select a partition key which doesn't repeat for items to span across multiple partitions).</li> <li>Is there a way to abort the creation of GSI while the process is on? it doesn't allow through AWS console.</li> </ol> <p>Thanks.</p>
0debug
Javascript: Find the second longest substring from the given string Ex: I/p: Aabbbccgggg o/p: bbb : <p>Javascript:Find the second longest substring from given string(input and output example added in heading)</p>
0debug
Dagger2 Error: Module Must Be Set : <p>I was trying to do SubScoping in Dagger2. However, I am not able to figure out this compilation error:-> <code>...MyApplicationModule must be set</code> which happens in my <code>LogInFragment</code>. If someone will try to throw some light on this error. I would really be glad.</p> <p>This is <strong>MyApplication Class</strong>:</p> <pre><code>public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); MyInjector.initialize(this); } } </code></pre> <p>This is <strong>MyInjector Class:</strong></p> <pre><code>public enum MyInjector { INSTANCE; MyApplicationComponent myApplicationComponent; private MyInjector() { } public static void initialize(MyApplication myApplication) { MyApplicationComponent myApplicationComponent = DaggerMyApplicationComponent.builder() .myApplicationModule(new MyApplicationModule(myApplication)) .build(); INSTANCE.myApplicationComponent = myApplicationComponent; } public static MyApplicationComponent get() { return INSTANCE.myApplicationComponent; } } </code></pre> <p>This is <strong>MyApplicationComponent Class:</strong></p> <pre><code>@Component (modules = {MyApplicationModule.class}) public interface MyApplicationComponent { } </code></pre> <p>This is <strong>MyApplicationModule Class</strong></p> <pre><code>@Module public class MyApplicationModule { private final MyApplication myApplication; public MyApplicationModule(MyApplication myApplication) { this.myApplication = myApplication; } @Singleton @Provides SharedPreferences providesSharedPreferences(Context context) { return context.getSharedPreferences("My_Pref", Context.MODE_PRIVATE); } @Singleton @Provides public Context providesMyApplicationContext() { return this.myApplication.getApplicationContext(); } @Singleton @Provides public LocationManager providesLocationService(Context context) { return (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); } @Singleton @Provides public MyDatabaseManager providesMyDatabaseManager(Context context) { return MyDatabaseManager.getInstance(context); } @Singleton @Provides public AccountSystemModel providesAccountSystemModel(Context context) { return MyDatabaseManager.getInstance(context); } @Singleton @Provides public MyApplication providesMyApplication(){ return this.myApplication; } } </code></pre> <p>This is where I am trying to <strong>Subscope</strong> </p> <p>This is <strong>MyLogIn Component Class</strong> </p> <pre><code>@Singleton @Component(modules = {MyApplicationModule.class}, dependencies = {MyApplicationComponent.class}) public interface LogInComponent { LogInPresenter signInPresenter(); } </code></pre> <p>This is where the <code>Compilation Error</code> happens</p> <p>This is <strong>MyLogInActivityFragment</strong></p> <pre><code>@Override protected void injectDependencies() { logInComponent = DaggerLogInComponent.builder() .myApplicationComponent(MyInjector.get()) .build(); } </code></pre>
0debug
Add/remove class to element with delay if mouse is still over : I am opening my submenu with adding a class("reveal") to it's parent. What i want to achieve is when i hover over a parent, if no "active" hover is going on, to open the submenu immediately, but if a submenu is already shown, then wait 1second before it opens a new one. I want this because of "bad" mouse movement for it to wait in case the mouse leaves the submenu/parent to see if it re-enters in 1second. I know there are a bunch of similar threads, but i already did my attempt and can't se eright now what im doing wrong: $('.menu > li').hover(function(){ var ele = $(this); if($('.menu li.reveal').length > 0){ var t = setTimeout(function(){ if( ele.hover() ){ $('.menu li.reveal').removeClass('reveal'); ele.addClass('reveal'); } },1000); } else{ ele.addClass('reveal'); } });
0debug
Python changing elements in array while it only appears once in shell : Didn't know how to correctly write the title, so i will try to explain it here. I am making a game, similar to tic tac toe. The play field is 4x4 and i am saving it as an array. I want to make changes in the array during the game, but it will not print out the array each time, rather it makes changes statically. Lets say at the beginning i print out the whole field and under it the user is asked to type a position. He gives it and the changes are being done in the first printed playfield, without calling it again in the shell. Kinda sloppy explanation, sorry about that. play_field = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] def print_playfield(): for rows in play_field: print(*['{:<4}'.format(each) for each in rows]) This is the function, which will display the playfield.I've done it with tkinter already, wanna try it without.
0debug
av_cold void ff_lpc_end(LPCContext *s) { av_freep(&s->windowed_samples); }
1threat
PHP Mysqli - SELECT * vs SELECT COUNT(*) when reult is 0? : Is there any difference in performance between `SELECT *` and `SELECT COUNT(*)` when no rows will be found? My chat script check every second for new messages so it would be good to know if I need count(*)
0debug
Count all amount from object in a List : <p>I have this Java object stored in a List:</p> <pre><code>public class ExpressCheckout { String currency; float amount; int quantity; String name; String description; ....... } </code></pre> <p>How I can count all amount value into List from every Object?</p>
0debug
Why i cant call my function when i put a paramether : Can somebody tell me why when i put "3" for paramether in function a() doesnt work? is that a wrong way or? help please...[Function][1] [function call][2] [1]: http://i.stack.imgur.com/7rq3t.png [2]: http://i.stack.imgur.com/7GNgx.png
0debug
Is this a possible bug in .Net Native compilation and optimization? : <p>I discovered an issue with (what might be) over-optimization in <code>.Net Native</code> and <code>structs</code>. I'm not sure if the compiler is too aggressive, or I'm too blind to see what I've done wrong. </p> <p>To reproduce this, follow these steps:</p> <p><strong>Step 1</strong>: Create a new Blank Universal (win10) app in <em>Visual Studio 2015 Update 2</em> targeting build 10586 with a min build of 10240. Call the project <em>NativeBug</em> so we have the same namespace.</p> <p><strong>Step 2</strong>: Open <code>MainPage.xaml</code> and insert this label</p> <pre><code>&lt;Page x:Class="NativeBug.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"&gt; &lt;Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt; &lt;!-- INSERT THIS LABEL --&gt; &lt;TextBlock x:Name="_Label" HorizontalAlignment="Center" VerticalAlignment="Center" /&gt; &lt;/Grid&gt; &lt;/Page&gt; </code></pre> <p><strong>Step 3</strong>: Copy/paste the following into <code>MainPage.xaml.cs</code></p> <pre><code>using System; using System.Collections.Generic; namespace NativeBug { public sealed partial class MainPage { public MainPage() { InitializeComponent(); var startPoint = new Point2D(50, 50); var points = new[] { new Point2D(100, 100), new Point2D(100, 50), new Point2D(50, 100), }; var bounds = ComputeBounds(startPoint, points, 15); _Label.Text = $"{bounds.MinX} , {bounds.MinY} =&gt; {bounds.MaxX} , {bounds.MaxY}"; } private static Rectangle2D ComputeBounds(Point2D startPoint, IEnumerable&lt;Point2D&gt; points, double strokeThickness = 0) { var lastPoint = startPoint; var cumulativeBounds = new Rectangle2D(); foreach (var point in points) { var bounds = ComputeBounds(lastPoint, point, strokeThickness); cumulativeBounds = cumulativeBounds.Union(bounds); lastPoint = point; } return cumulativeBounds; } private static Rectangle2D ComputeBounds(Point2D fromPoint, Point2D toPoint, double strokeThickness) { var bounds = new Rectangle2D(fromPoint.X, fromPoint.Y, toPoint.X, toPoint.Y); // ** Uncomment the line below to see the difference ** //return strokeThickness &lt;= 0 ? bounds : bounds.Inflate2(strokeThickness); return strokeThickness &lt;= 0 ? bounds : bounds.Inflate1(strokeThickness); } } public struct Point2D { public readonly double X; public readonly double Y; public Point2D(double x, double y) { X = x; Y = y; } } public struct Rectangle2D { public readonly double MinX; public readonly double MinY; public readonly double MaxX; public readonly double MaxY; private bool IsEmpty =&gt; MinX == 0 &amp;&amp; MinY == 0 &amp;&amp; MaxX == 0 &amp;&amp; MaxY == 0; public Rectangle2D(double x1, double y1, double x2, double y2) { MinX = Math.Min(x1, x2); MinY = Math.Min(y1, y2); MaxX = Math.Max(x1, x2); MaxY = Math.Max(y1, y2); } public Rectangle2D Union(Rectangle2D rectangle) { if (IsEmpty) { return rectangle; } var newMinX = Math.Min(MinX, rectangle.MinX); var newMinY = Math.Min(MinY, rectangle.MinY); var newMaxX = Math.Max(MaxX, rectangle.MaxX); var newMaxY = Math.Max(MaxY, rectangle.MaxY); return new Rectangle2D(newMinX, newMinY, newMaxX, newMaxY); } public Rectangle2D Inflate1(double value) { var halfValue = value * .5; return new Rectangle2D(MinX - halfValue, MinY - halfValue, MaxX + halfValue, MaxY + halfValue); } public Rectangle2D Inflate2(double value) { var halfValue = value * .5; var x1 = MinX - halfValue; var y1 = MinY - halfValue; var x2 = MaxX + halfValue; var y2 = MaxY + halfValue; return new Rectangle2D(x1, y1, x2, y2); } } } </code></pre> <p><strong>Step 4</strong>: Run the application in <code>Debug</code> <code>x64</code>. You should see this label:</p> <blockquote> <p>42.5 , 42.5 => 107.5 , 107.5</p> </blockquote> <p><strong>Step 5</strong>: Run the application in <code>Release</code> <code>x64</code>. You should see this label:</p> <blockquote> <p>-7.5 , -7.5 => 7.5, 7.5</p> </blockquote> <p><strong>Step 6</strong>: Uncomment <code>line 45</code> in <code>MainPage.xaml.cs</code> and repeat step 5. Now you see the original label</p> <blockquote> <p>42.5 , 42.5 => 107.5 , 107.5</p> </blockquote> <hr> <p>By commenting out <code>line 45</code>, the code will use <code>Rectangle2D.Inflate2(...)</code> which is exactly the same as <code>Rectangle2D.Inflate1(...)</code> except it creates a local copy of the computations before sending them to the constructor of <code>Rectangle2D</code>. In debug mode, these two function exactly the same. In release however, something is getting optimized out.</p> <p>This was a nasty bug in our app. The code you see here was stripped from a much larger library and I'm afraid there might be more. Before I report this to Microsoft, I would appreciate it if you could take a look and let me know why <code>Inflate1</code> doesn't work in release mode. Why do we have to create local copies?</p>
0debug
void kvm_flush_coalesced_mmio_buffer(void) { #ifdef KVM_CAP_COALESCED_MMIO KVMState *s = kvm_state; if (s->coalesced_mmio_ring) { struct kvm_coalesced_mmio_ring *ring = s->coalesced_mmio_ring; while (ring->first != ring->last) { struct kvm_coalesced_mmio *ent; ent = &ring->coalesced_mmio[ring->first]; cpu_physical_memory_write(ent->phys_addr, ent->data, ent->len); smp_wmb(); ring->first = (ring->first + 1) % KVM_COALESCED_MMIO_MAX; } } #endif }
1threat
How to call conditionally B::f only if derived from B in C++11? : <p>In case when static polymorphism is used, especially in templates (e.g. with policy/strategy pattern), it may be required to call base function member, but you don't know was instantiated class actually derived from this base or not.</p> <p>This easily can be solved with old good C++ ellipsis overload trick:</p> <pre><code>#include &lt;iostream&gt; template &lt;class I&gt; struct if_derived_from { template &lt;void (I::*f)()&gt; static void call(I&amp; x) { (x.*f)(); } static void call(...) { } }; struct A { void reset() { std::cout &lt;&lt; "reset A" &lt;&lt; std::endl; } }; struct B { void reset() { std::cout &lt;&lt; "reset B" &lt;&lt; std::endl; } }; struct C { void reset() { std::cout &lt;&lt; "reset C" &lt;&lt; std::endl; } }; struct E: C { void reset() { std::cout &lt;&lt; "reset E" &lt;&lt; std::endl; } }; struct D: E {}; struct X: A, D {}; int main() { X x; if_derived_from&lt;A&gt;::call&lt;&amp;A::reset&gt;(x); if_derived_from&lt;B&gt;::call&lt;&amp;B::reset&gt;(x); if_derived_from&lt;C&gt;::call&lt;&amp;C::reset&gt;(x); if_derived_from&lt;E&gt;::call&lt;&amp;E::reset&gt;(x); return 0; } </code></pre> <p>The question is:</p> <ul> <li>Is there any better <em>simple</em> way (e.g. SFINAE doesn't look so) to achieve same result in C++11/C++14?</li> <li>Would empty call of ellipsis parameter function be elided by optimizing compiler? Hope such case is not special against any "normal" function.</li> </ul>
0debug
std::bit_cast with std::array : <p>In his recent talk <a href="https://www.youtube.com/watch?v=_qzMpk-22cc" rel="noreferrer">“Type punning in modern C++”</a> Timur Doumler <a href="https://youtu.be/_qzMpk-22cc?t=2755" rel="noreferrer">said</a> that <code>std::bit_cast</code> cannot be used to bit cast a <code>float</code> into an <code>unsigned char[4]</code> because C-style arrays cannot be returned from a function. We should either use <code>std::memcpy</code> or wait until C++23 (or later) when something like <code>reinterpret_cast&lt;unsigned char*&gt;(&amp;f)[i]</code> will become well defined.</p> <p>In C++20, can we use an <code>std::array</code> with <code>std::bit_cast</code>,</p> <pre><code>float f = /* some value */; auto bits = std::bit_cast&lt;std::array&lt;unsigned char, sizeof(float)&gt;&gt;(f); </code></pre> <p>instead of a C-style array to get bytes of a <code>float</code>?</p>
0debug
Formatting a date - Rails : <p>I have a variable containing a date in this form: (2018-03-21 18:49:49 UTC) and I would like to display in this form: (day / month / year) but I can not find a solution. Do you have an idea ? Thank you !</p>
0debug
I need to create a Perl 5 regex statement that will parse 2 separate dates from a string : <p>The string is of the following format:<br> "Unwanted words and spaces" Date1 "and" Date2. Date 2 is at the very end of the whole string. How can I go about writing this? The date formats are of the form m/dd/yyyy.</p> <p>Thanks, Ryan</p>
0debug
Text Overlay Image with Darkened Opacity React Native : <p>I am attempting to overlay a title over an image - with the image darkened with a lower opacity. However, the opacity effect is changing the overlaying text as well - making it dim. Any fix to this? Here is what is looks like:</p> <p><a href="https://i.stack.imgur.com/1HzD7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1HzD7.png" alt="enter image description here"></a></p> <p>And here is my code for the custom component (article preview - which the above image is a row of article preview components): </p> <pre><code>//component for article preview touchable image /* will require the following - rss feed and api - user's keyword interests from parse In home.js - parse db needs to be augmented to include what they heart - parse db needs to be augmented to include what they press on (like google news) */ var React = require('react-native'); var { View, StyleSheet, Text, Image, TouchableHighlight, } = React; //dimensions var Dimensions = require('Dimensions'); var window = Dimensions.get('window'); var ImageButton = require('../../common/imageButton'); var KeywordBox = require('../../authentication/onboarding/keyword-box'); //additional libraries module.exports = React.createClass({ //onPress function that triggers when button pressed //this.props.text is property that can be dynamically filled within button /* following props: - source={this.props.source} - onPress={this.props.onPress} - {this.props.text} - {this.props.heartText} - key={this.props.key} - text={this.props.category} - this.props.selected */ render: function() { return ( &lt;TouchableHighlight underlayColor={'transparent'} onPress={this.props.onPress} &gt; &lt;Image source={this.props.source} style={[styles.articlePreview, this.border('red')]}&gt; &lt;View style={[styles.container, this.border('organge')]}&gt; &lt;View style={[styles.header, this.border('blue')]}&gt; &lt;Text style={[styles.previewText]}&gt;{this.props.text}&lt;/Text&gt; &lt;/View&gt; &lt;View style={[styles.footer, this.border('white')]}&gt; &lt;View style={[styles.heartRow, this.border('black')]}&gt; &lt;ImageButton style={[styles.heartBtn, , this.border('red')]} resizeMode={'contain'} onPress={this.onHeartPress} source={require('../../img/heart_btn.png')} /&gt; &lt;Text style={[styles.heartText]}&gt;{this.props.heartText + ' favorites'}&lt;/Text&gt; &lt;/View&gt; &lt;KeywordBox style={[styles.category, this.border('blue')]} key={this.props.key} text={this.props.category} onPress={this.props.categoryPress} selected={this.props.selected} /&gt; &lt;/View&gt; &lt;/View&gt; &lt;/Image&gt; &lt;/TouchableHighlight&gt; ); }, onHeartPress: function() { //will move this function to a general module }, border: function(color) { return { //borderColor: color, //borderWidth: 4, } }, }); var styles = StyleSheet.create({ heartText: { color: 'white', fontSize: 12, fontWeight: 'bold', alignSelf: 'center', marginLeft: 5, fontFamily: 'SFCompactText-Medium' }, heartRow: { flexDirection: 'row', justifyContent: 'space-around', alignSelf: 'center', justifyContent: 'center', }, heartBtn: { height: (92/97)*(window.width/13), width: window.width/13, alignSelf:'center', }, category: { fontFamily: 'Bebas Neue', fontSize: 10, fontWeight: 'bold' }, header: { flex: 3, alignItems: 'center', justifyContent: 'space-around', marginTop: window.height/30, }, footer: { flex: 1, flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', margin: window.height/50, }, container: { flex: 1, backgroundColor: 'black', opacity: 0.6, }, articlePreview: { flex: 1, height: window.height/3.2, width: window.width, flexDirection: 'column' }, previewText: { fontFamily: 'Bebas Neue', fontSize: 23, color: 'white', alignSelf: 'center', textAlign: 'center', margin: 5, position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 }, }); </code></pre>
0debug
React/RCTEventEmitter.h file not found : <p>I am trying to implement PushNotificationIOS with a detached Expo app. I am running SDK 21.0.0 (React Native 0.48).</p> <p>I am getting <code>React/RCTEventEmitter file not found</code> </p> <p>I have completed the following steps:</p> <ul> <li>Open my <code>.xcworkspace</code> project</li> <li>Drag the <code>RCTPushNotification.xcodeproj</code> into my Libraries folder</li> <li>Added <code>libRCTPushNotification.a</code> into <code>App &gt; Build Phases &gt; Link Binary With Libraries</code></li> <li>Added <code>$(SRCROOT)/../node_modules/react-native/Libraries</code> under Header Search Paths - I also tried without the <code>/../</code>. I have a bunch of Pods in the Header Search Paths list too.</li> </ul> <p>I then added the following into <code>AppDelegate.m</code> but when I click through to the file (⌘ + click), I get a question mark.</p> <pre><code>#import &lt;React/RCTPushNotificationManager.h&gt; </code></pre> <p>If I change it to the below, it works, I can click through</p> <pre><code>#import "RCTPushNotificationManager.h" </code></pre> <p><strong>However, this is my problem</strong></p> <p>When I clean and build my project, I get the below error in <code>RCTPushNotificationManager.h</code> to say:</p> <pre><code>'React/RCTEventEmitter.h' file not found </code></pre>
0debug
void hmp_host_net_remove(Monitor *mon, const QDict *qdict) { NetClientState *nc; int vlan_id = qdict_get_int(qdict, "vlan_id"); const char *device = qdict_get_str(qdict, "device"); nc = net_hub_find_client_by_name(vlan_id, device); if (!nc) { error_report("Host network device '%s' on hub '%d' not found", device, vlan_id); return; } if (!net_host_check_device(nc->model)) { error_report("invalid host network device '%s'", device); return; } qemu_del_net_client(nc->peer); qemu_del_net_client(nc); }
1threat
Azure Cosmos DB Update Pattern : <p>I have recently started using Cosmos DB for a project and I am running into a few design issues. Coming from a SQL background, I understand that related data should be nested within documents on a NoSQL DB. This does mean that documents can become quite large though. </p> <p>Since partial updates are not supported, what is the best design pattern to implement when you want to update a single property on a document? </p> <p>Should I be reading the entire document server side, updating the value and writing the document back immeadiately in order to perform an update? This seems problematic if the documents are large which they inevitably would be if all your data is nested.</p> <p>If I take the approach of making many smaller documents and infer relationships based on IDs I think this would solve the read/write immeadiately for updates concern but it feels like I am going against the concept of a NoSQL and in essence I am building a relational DB.</p> <p>Thanks</p>
0debug