problem
stringlengths
26
131k
labels
class label
2 classes
static void do_dcbz(target_ulong addr, int dcache_line_size) { addr &= ~(dcache_line_size - 1); int i; for (i = 0 ; i < dcache_line_size ; i += 4) { stl(addr + i , 0); } if (env->reserve == addr) env->reserve = (target_ulong)-1ULL; }
1threat
How should I approach building a picture only portfolio? : <p>I love these following portfolios:</p> <p><a href="http://www.ericryananderson.com/" rel="nofollow">http://www.ericryananderson.com/</a></p> <p><a href="http://jeremycowart.com/portfolio/featured/" rel="nofollow">http://jeremycowart.com/portfolio/featured/</a></p> <p>I wanted to create a website with the same concept of a collage of photos connecting together. But I am not sure the best way to approach this, would I just use box-sizing and floats? Or would bootstrap make this project easier? Thank you for your help!</p> <p>Edit: I was told in order to do this, photoshop would be the best method, but I would like to complete this with just programming if possible.</p>
0debug
uint64_t helper_stq_c_raw(uint64_t t0, uint64_t t1) { uint64_t ret; if (t1 == env->lock) { stq_raw(t1, t0); ret = 0; } else ret = 1; env->lock = 1; return ret; }
1threat
How can I create a lightbox with text and image? : <p>I am not good at programming. I am trying to create an image gallery with lightbox and content in it. <a href="https://i.stack.imgur.com/7exQg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7exQg.png" alt="it looks something like that"></a></p> <p>I am looking for a plugin for this kind of function.</p> <p>Any suggestion?</p>
0debug
static inline void gen_add_datah_offset(DisasContext *s, unsigned int insn, int extra, TCGv var) { int val, rm; TCGv offset; if (insn & (1 << 22)) { val = (insn & 0xf) | ((insn >> 4) & 0xf0); if (!(insn & (1 << 23))) val = -val; val += extra; if (val != 0) tcg_gen_addi_i32(var, var, val); } else { if (extra) tcg_gen_addi_i32(var, var, extra); rm = (insn) & 0xf; offset = load_reg(s, rm); if (!(insn & (1 << 23))) tcg_gen_sub_i32(var, var, offset); else tcg_gen_add_i32(var, var, offset); dead_tmp(offset); } }
1threat
How to manage multiple maven projects in gitlab : <p>We have multiple (about 75) maven projects, which we have pushed to Gitlab <strong>individually</strong> in following manner:<br> GROUP1 - 4 projects<br> GROUP2 - 2 projects<br> GROUP3 - 10 Projects<br> .<br> .<br> GROUP10 - 6 Projects</p> <hr> <p>We now want to implement CI tool like <code>Jenkins</code>. But creating and managing all 75 projects in jenkins individuality is very time consuming. So that we have 2 methods in mind. </p> <ol> <li><strong><code>git submodules</code>:</strong> In this case we might get many complications, as individual developer is forking the multiple project and works in his forked repo.</li> <li><strong>Single <code>git</code> Project:</strong> In this case if every developer will fork the main repo, then disk space required is much and the performance will also get degrade. But it will be better than <code>git submodules</code> to manage, as build can be simplified with maven <code>multiple module way</code>. </li> </ol> <p>So according to you, is there any other approach we can think about, or can we go with <strong>Single git project</strong>?</p>
0debug
Grid layout like pinterest using css only and without javascript : <p>I need a grid layout like Pinterest. How am I going to achieve such layout? </p> <p>I tried using <code>flex</code> but each element has space and I want the grid layout like in Pinterest.</p> <pre><code>&lt;style&gt; .flex{ width: 100%; display: flex; flex-direction: row; flex-wrap: wrap; } .flex-item{ width: 20%; background: #dddddd; } &lt;/style&gt; &lt;div class="flex"&gt; &lt;div class="flex-item"&gt;content.....&lt;/div&gt; &lt;div class="flex-item"&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit..&lt;/div&gt; &lt;div class="flex-item"&gt;Lorem ipsum dolor sit..&lt;/div&gt; &lt;div class="flex-item"&gt;Lorem ipsum dolor sit amet consectetur..&lt;/div&gt; &lt;div class="flex-item"&gt;Lorem ipsum..&lt;/div&gt; &lt;/div&gt; </code></pre> <p>I really want the layout to be like pinterest I'm not sure if the flex is the practical way to achieve this. Any solution or advice will be much appreciated. Thanks in advance!</p>
0debug
How to extract a specific data range form multiple sheets in excel : I have an excel sheet with four additional sheets sheet1 sheet2 sheet3 summary (sheet4) The first three sheets have a column of age. At the summary sheet i want to age data as age group ( 18 to 25, 26 to 33 etc..). I know how to get age group range from single sheet, but don't know how to get (exmp:18 to 25 from sheet1+sheet2+sheet3)a range from multiple sheet. Please try to understand my question and please answer without VB code. Thanks
0debug
int ff_audio_interleave_init(AVFormatContext *s, const int *samples_per_frame, AVRational time_base) { int i; if (!samples_per_frame) return -1; if (!time_base.num) { av_log(s, AV_LOG_ERROR, "timebase not set for audio interleave\n"); return -1; } for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; AudioInterleaveContext *aic = st->priv_data; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { aic->sample_size = (st->codec->channels * av_get_bits_per_sample(st->codec->codec_id)) / 8; if (!aic->sample_size) { av_log(s, AV_LOG_ERROR, "could not compute sample size\n"); return -1; } aic->samples_per_frame = samples_per_frame; aic->samples = aic->samples_per_frame; aic->time_base = time_base; aic->fifo_size = 100* *aic->samples; aic->fifo= av_fifo_alloc_array(100, *aic->samples); } } return 0; }
1threat
Pass method = post in button and not in firm : I want to pass a variable but for that i need to create a form. But I am using java script to open the next page(that is a block page) but I want to pass the method=post directly in the button and not in the form because it does not recognize the code, here is an example: What I have: <form action="" method="post"> <button onclick="document.getElementById('id144').style.display='block'" class="btn btn-warning">Editar nome grupo</button> </form> What I want <button //pass method = post here onclick="document.getElementById('id144').style.display='block'" class="btn btn-warning">Editar nome grupo</button>
0debug
av_cold int ff_h264_decode_init(AVCodecContext *avctx) { H264Context *h = avctx->priv_data; int i; int ret; h->avctx = avctx; h->bit_depth_luma = 8; h->chroma_format_idc = 1; h->cur_chroma_format_idc = 1; ff_h264dsp_init(&h->h264dsp, 8, 1); av_assert0(h->sps.bit_depth_chroma == 0); ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma); ff_h264qpel_init(&h->h264qpel, 8); ff_h264_pred_init(&h->hpc, h->avctx->codec_id, 8, 1); h->dequant_coeff_pps = -1; h->current_sps_id = -1; ff_videodsp_init(&h->vdsp, 8); memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t)); memset(h->pps.scaling_matrix8, 16, 2 * 64 * sizeof(uint8_t)); h->picture_structure = PICT_FRAME; h->slice_context_count = 1; h->workaround_bugs = avctx->workaround_bugs; h->flags = avctx->flags; if (!avctx->has_b_frames) h->low_delay = 1; avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; ff_h264_decode_init_vlc(); ff_init_cabac_states(); h->pixel_shift = 0; h->cur_bit_depth_luma = h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8; h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? H264_MAX_THREADS : 1; h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx)); if (!h->slice_ctx) { h->nb_slice_ctx = 0; return AVERROR(ENOMEM); } for (i = 0; i < h->nb_slice_ctx; i++) h->slice_ctx[i].h264 = h; h->outputed_poc = h->next_outputed_poc = INT_MIN; for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) h->last_pocs[i] = INT_MIN; h->prev_poc_msb = 1 << 16; h->prev_frame_num = -1; h->x264_build = -1; h->sei_fpa.frame_packing_arrangement_cancel_flag = -1; ff_h264_reset_sei(h); if (avctx->codec_id == AV_CODEC_ID_H264) { if (avctx->ticks_per_frame == 1) { if(h->avctx->time_base.den < INT_MAX/2) { h->avctx->time_base.den *= 2; } else h->avctx->time_base.num /= 2; } avctx->ticks_per_frame = 2; } if (avctx->extradata_size > 0 && avctx->extradata) { ret = ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size); if (ret < 0) { ff_h264_free_context(h); return ret; } } if (h->sps.bitstream_restriction_flag && h->avctx->has_b_frames < h->sps.num_reorder_frames) { h->avctx->has_b_frames = h->sps.num_reorder_frames; h->low_delay = 0; } avctx->internal->allocate_progress = 1; ff_h264_flush_change(h); if (h->enable_er) { av_log(avctx, AV_LOG_WARNING, "Error resilience is enabled. It is unsafe and unsupported and may crash. " "Use it at your own risk\n"); } return 0; }
1threat
What is the execution logic of the expression in C? : <p>Suppose I a couple of expression in C. Different outputs are provided.</p> <pre><code>int i =2,j; j= i + (2,3,4,5); printf("%d %d", i,j); //Output= 2 7 j= i + 2,3,4,5; printf("%d %d", i,j); //Output 2 4 </code></pre> <p>How does the execution take place in both expression with and without bracket giving different outputs.</p>
0debug
Why choose UnityEvent over native C# events? : <p>I mean, UnityEvents are slower than the native C# events and they still store a strong reference to the receivers. So, the only valid reason I can find to use UnityEvents over native C# events is their integration with the editor. <em>Am I overlooking something</em>?</p>
0debug
How to create web-services in Zend Framework 2? : <p>How to create web services over HTTP REST protocol using Zend Framework 2 (third party)</p> <p>We use this code in Zend Framework 1 :</p> <pre><code> &lt;?php function methodName($name) { echo "Hello world - $name"; } $server = new Zend_Rest_Server(); $server-&gt;addFunction('methodName'); $server-&gt;handle(); ?&gt; </code></pre> <p>An example code will be useful.</p>
0debug
static inline int set_options(AVFilterContext *ctx, const char *args) { HueContext *hue = ctx->priv; int n, ret; char c1 = 0, c2 = 0; char *old_hue_expr, *old_hue_deg_expr, *old_saturation_expr; AVExpr *old_hue_pexpr, *old_hue_deg_pexpr, *old_saturation_pexpr; if (args) { if (strchr(args, '=')) { old_hue_expr = hue->hue_expr; old_hue_deg_expr = hue->hue_deg_expr; old_saturation_expr = hue->saturation_expr; old_hue_pexpr = hue->hue_pexpr; old_hue_deg_pexpr = hue->hue_deg_pexpr; old_saturation_pexpr = hue->saturation_pexpr; hue->hue_expr = NULL; hue->hue_deg_expr = NULL; hue->saturation_expr = NULL; if ((ret = av_set_options_string(hue, args, "=", ":")) < 0) return ret; if (hue->hue_expr && hue->hue_deg_expr) { av_log(ctx, AV_LOG_ERROR, "H and h options are incompatible and cannot be specified " "at the same time\n"); hue->hue_expr = old_hue_expr; hue->hue_deg_expr = old_hue_deg_expr; return AVERROR(EINVAL); } if (!hue->hue_expr && !hue->hue_deg_expr) { hue->hue_expr = old_hue_expr; hue->hue_deg_expr = old_hue_deg_expr; } if (hue->hue_deg_expr) PARSE_EXPRESSION(hue_deg, h); if (hue->hue_expr) PARSE_EXPRESSION(hue, H); if (hue->saturation_expr) PARSE_EXPRESSION(saturation, s); hue->flat_syntax = 0; av_log(ctx, AV_LOG_VERBOSE, "H_expr:%s h_deg_expr:%s s_expr:%s\n", hue->hue_expr, hue->hue_deg_expr, hue->saturation_expr); } else { n = sscanf(args, "%f%c%f%c", &hue->hue_deg, &c1, &hue->saturation, &c2); if (n != 1 && (n != 3 || c1 != ':')) { av_log(ctx, AV_LOG_ERROR, "Invalid syntax for argument '%s': " "must be in the form 'hue[:saturation]'\n", args); return AVERROR(EINVAL); } if (hue->saturation < SAT_MIN_VAL || hue->saturation > SAT_MAX_VAL) { av_log(ctx, AV_LOG_ERROR, "Invalid value for saturation %0.1f: " "must be included between range %d and +%d\n", hue->saturation, SAT_MIN_VAL, SAT_MAX_VAL); return AVERROR(EINVAL); } hue->hue = hue->hue_deg * M_PI / 180; hue->flat_syntax = 1; av_log(ctx, AV_LOG_VERBOSE, "H:%0.1f h:%0.1f s:%0.1f\n", hue->hue, hue->hue_deg, hue->saturation); } } compute_sin_and_cos(hue); return 0; }
1threat
VBScript - replace all commas occuring between ," and ", : <p>Using VBScript I need to replace all commas that occur between <strong>,"</strong> and <strong>",</strong> (i.e. chr(34)&amp;chr(44) and chr(44)&amp;chr(34)) with dots so it transforms below input into output string. Commas that occur not between these characters should stay.</p> <pre><code>Input 2019/011,05-11-2019,05-11-2019,"748,845,914,968,1019,1081",Edward Norton,86105015751000009077333566,,"5846,03",,"548,95",20,T Output 2019/011,05-11-2019,05-11-2019,"748.845.914.968.1019.1081",Edward Norton,86105015751000009077333566,,"5846.03",,"548.95",20,T </code></pre> <p>Many thanks.</p>
0debug
Swift 3 NSCache Generic parameter 'KeyType' could not be inferred : <p>This code worked in Swift 2.x:</p> <pre><code>/// An internal in-memory cache private var dataCache = NSCache.init() </code></pre> <p>In <strong>Swift 3</strong> it causes compilation error:</p> <pre><code>Generic parameter 'KeyType' could not be inferred </code></pre> <p>Why is that so and how should I refactor this (Migration tool did not pick this up)?</p>
0debug
void bdrv_drain_all(void) { bool busy = true; BlockDriverState *bs = NULL; GSList *aio_ctxs = NULL, *ctx; while ((bs = bdrv_next(bs))) { AioContext *aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); if (bs->job) { block_job_pause(bs->job); } bdrv_no_throttling_begin(bs); bdrv_drain_recurse(bs); aio_context_release(aio_context); if (!g_slist_find(aio_ctxs, aio_context)) { aio_ctxs = g_slist_prepend(aio_ctxs, aio_context); } } while (busy) { busy = false; for (ctx = aio_ctxs; ctx != NULL; ctx = ctx->next) { AioContext *aio_context = ctx->data; bs = NULL; aio_context_acquire(aio_context); while ((bs = bdrv_next(bs))) { if (aio_context == bdrv_get_aio_context(bs)) { bdrv_flush_io_queue(bs); if (bdrv_requests_pending(bs)) { busy = true; aio_poll(aio_context, busy); } } } busy |= aio_poll(aio_context, false); aio_context_release(aio_context); } } bs = NULL; while ((bs = bdrv_next(bs))) { AioContext *aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); bdrv_no_throttling_end(bs); if (bs->job) { block_job_resume(bs->job); } aio_context_release(aio_context); } g_slist_free(aio_ctxs); }
1threat
int qemu_get_fd(QEMUFile *f) { if (f->ops->get_fd) { return f->ops->get_fd(f->opaque); } return -1; }
1threat
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; H264Context *h = avctx->priv_data; MpegEncContext *s = &h->s; AVFrame *pict = data; int buf_index; s->flags= avctx->flags; s->flags2= avctx->flags2; out: if (buf_size == 0) { Picture *out; int i, out_idx; s->current_picture_ptr = NULL; out = h->delayed_pic[0]; out_idx = 0; for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame && !h->delayed_pic[i]->mmco_reset; i++) if(h->delayed_pic[i]->poc < out->poc){ out = h->delayed_pic[i]; out_idx = i; } for(i=out_idx; h->delayed_pic[i]; i++) h->delayed_pic[i] = h->delayed_pic[i+1]; if(out){ *data_size = sizeof(AVFrame); *pict= *(AVFrame*)out; } return 0; } buf_index=decode_nal_units(h, buf, buf_size); if(buf_index < 0) return -1; if (!s->current_picture_ptr && h->nal_unit_type == NAL_END_SEQUENCE) { buf_size = 0; goto out; } if(!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr){ if (avctx->skip_frame >= AVDISCARD_NONREF) return 0; av_log(avctx, AV_LOG_ERROR, "no frame!\n"); return -1; } if(!(s->flags2 & CODEC_FLAG2_CHUNKS) || (s->mb_y >= s->mb_height && s->mb_height)){ if(s->flags2 & CODEC_FLAG2_CHUNKS) decode_postinit(h); field_end(h, 0); if (!h->next_output_pic) { *data_size = 0; } else { *data_size = sizeof(AVFrame); *pict = *(AVFrame*)h->next_output_pic; } } assert(pict->data[0] || !*data_size); ff_print_debug_info(s, pict); return get_consumed_bytes(s, buf_index, buf_size); }
1threat
Firebase Email Verification Not Working Properly : <p><strong>WHAT I HAVE</strong></p> <p>I am using <strong>Firebase Authentication</strong> in my app where the users can register using <strong>Email &amp; Password</strong>. If the users have not verified their email, I disable some features until they verify their email.</p> <p>I also have a button to explicitly trigger verification mail, which just calls, <code>sendEmailVerification()</code>. It works perfectly and verification mail is always sent.</p> <p><strong>THE PROBLEM</strong> </p> <p>The user gets the verification mails, but when he/she verifies it and comes back to the app, the <code>isEmailVerified()</code> is always false. So my app still doesn't allow the user to use all functions in spite of the fact that he/she has verified their email.</p> <p>But if they log out and login again, the <code>isEmailVerified()</code> returns true immediately. But is it not good to log out the user and login back again.</p> <p>Is it a bug in Firebase? Or am I doing something wrong? </p>
0debug
Hello. I want an efficient way to truncate unwanted part from string in a DataFrame column : Data looks like these. Particulars<br/> IMPS/P2A/924413019791/CRYSTALV/THEGREAT/<br/> MOB/QYW6RJS14956/Ratnakar Bank CreditCard<br/> IMPS/P2A/924517325604/rajdha/HDFCBAN/X539003/<br/> BY CASH DEPOSIT-BNA/SWRO12802/9635/040919/JABALPU<br/> IMPS/P2A/924809539696/pradee/THEGREA/X783336/<br/> IMPS/P2A/924911569760/HARISHMA/ICICIBAN/NA<br/> IMPS/P2A/924916252301/pradee/THEGREA/X783336/<br/> BY CASH DEPOSIT-BNA/SWRO12802/462/070919/JABALPU<br/> AXMOB/MBR/38VRWY425344/915010029584916/080919<br/> NEFT/MB/AXMB192527472717/Pradeep sbi<br/> I need it in this manner. To be truncated after second forward slash(/) IMPS/P2A<br/> MOB/QYW6RJS14956<br/> IMPS/P2A<br/> BY CASH DEPOSIT-BNA/SWRO12802<br/> IMPS/P2A IMPS/P2A IMPS/P2A BY CASH DEPOSIT-BNA/SWRO12802<br/> AXMOB/MBR NEFT/MB Obviously I have used lstrip and rstrip here but it doesnt work. Please let me know if there is any other way I can solve this problem. Any recommendations are welcome. Thanks in advance and please ignore any mistakes in posting my question as it is my first time.
0debug
Tic tac toe JavaScript game - test user's number for matching patterns? : <p>Im making a game of "tic tac toe" also called "naughts and crosses".</p> <p>Each of the 9 squares has a number:</p> <pre><code>1 2 3 4 5 6 7 8 9 </code></pre> <p>As each player has a go the number they've chosen is added to the state. So if user1 has chosen squares 1 and 2, and user2 has chosen squares 4 and 5 then the state object looks like this: </p> <pre><code>const state = selected: { user1: [1,2], user2: [4,5] } </code></pre> <p>After each go I need to check the state to see if either user has 3 in a row. Here are all the possible winning numbers:</p> <pre><code>const winingNumbers = [ [1,2,3], // top row [4,5,6], // middle row [7,8,9], // bottom row [1,4,7], // first column [2,5,8], // second column [3,6,9], // last column [1,5,9], // last column [3,6,9], // diagonal 1 [3,5,7] // diagonal 2 ]; </code></pre> <p>How can I check the state to see if any of the users have a row? In this example user1 has a match: </p> <pre><code>const state = selected: { user1: [6,3,2,1], user2: [9,4,5] } </code></pre> <p>In this example user2 has a match: </p> <pre><code>const state = selected: { user1: [1,9,2,8], user2: [5,4,3,6] } </code></pre> <p>Note that the numbers can be an any order and other numbers not part of the match might be in the state also. Im using Bable so I can use ES6 syntax. </p>
0debug
int virtqueue_avail_bytes(VirtQueue *vq, unsigned int in_bytes, unsigned int out_bytes) { unsigned int in_total, out_total; virtqueue_get_avail_bytes(vq, &in_total, &out_total); if ((in_bytes && in_bytes < in_total) || (out_bytes && out_bytes < out_total)) { return 1; } return 0; }
1threat
Typescript hasOwnProperty equivalent : <p>In javascript if I want to loop through a dictionary and set properties of another dictionary, I'd use something like this:</p> <pre><code>for (let key in dict) { if (obj.hasOwnProperty(key)) { obj[key] = dict[key]; } } </code></pre> <p>If <code>obj</code> is a Typescript object (instance of a class), is there a way to perform the same operation?</p>
0debug
Dispaly a grid in html : I am a social sciences researchers and I am trying to create a task for an online study. The task is the following: a grid with shaded and white squares will be displayed and the task consist in counting the nb of shaded squares (as in the example). Different grids, with varying number of shaded squares will be shown to the participants in the study. I have the program that randomly generates an array of 0s and 1s in javascript and stores the number of 1s (answer for the problem=nb of coloured squares). What I need is to be able to display the array of numbers in a grid in html. Any ideas would be very welcome and extremely helpful. [enter image description here][1] [1]: http://i.stack.imgur.com/3F9IJ.jpg In any case, thanks a lot! Juliana
0debug
Mutilple Array puzzel : i have an array : $myArrays = array( array(1, 2, 3, 4), array(5, 6, 7, 8), array(9, 10, 11, 12), array(13, 14, 15, 16) ); i need to print output : <br>1<br>5<br>9<br>13<br>14<br>10<br>6<br>2<br>3<br>7<br>11<br>15<br>16<br>12<br>8<br>4
0debug
int ff_mpv_frame_size_alloc(MpegEncContext *s, int linesize) { int alloc_size = FFALIGN(FFABS(linesize) + 64, 32); FF_ALLOCZ_OR_GOTO(s->avctx, s->edge_emu_buffer, alloc_size * 4 * 24, fail); FF_ALLOCZ_OR_GOTO(s->avctx, s->me.scratchpad, alloc_size * 2 * 16 * 2, fail) s->me.temp = s->me.scratchpad; s->rd_scratchpad = s->me.scratchpad; s->b_scratchpad = s->me.scratchpad; s->obmc_scratchpad = s->me.scratchpad + 16; return 0; fail: av_freep(&s->edge_emu_buffer); return AVERROR(ENOMEM); }
1threat
int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg) { struct kvm_irq_routing_entry kroute; int virq; if (!kvm_gsi_routing_enabled()) { return -ENOSYS; } virq = kvm_irqchip_get_virq(s); if (virq < 0) { return virq; } kroute.gsi = virq; kroute.type = KVM_IRQ_ROUTING_MSI; kroute.flags = 0; kroute.u.msi.address_lo = (uint32_t)msg.address; kroute.u.msi.address_hi = msg.address >> 32; kroute.u.msi.data = msg.data; kvm_add_routing_entry(s, &kroute); return virq; }
1threat
While loops crashing, String not adding words to the Array : I've been searching for quite a while and i can't find the reason why nothing about this program works. It's supposed to ask the user to add a word that then will be added to the string array and after that, all words will be printed out. #include <iostream> int main() { int counter = 0; bool isRunning = true; std::string listofthings[] { }; while(isRunning) { char play; std::string word; std::cout << "Enter a word" << std::endl; std::cin >> word; listofthings[counter] = word; counter++; std::cout << "Word added! q to Quit, any other key to continue" << std::endl; std::cin >> play; if(play == 'q') isRunning = false; } int listnr = sizeof(listofthings)/sizeof(listofthings[0]); for(int i = 0; i < listnr; i++) { std::cout << listofthings[i] << std::endl; } } Thanks in advance
0debug
Deconstruction in foreach over Dictionary : <p>Is it possible in C#7 to use deconstruction in a foreach-loop over a Dictionary? Something like this:</p> <pre><code>var dic = new Dictionary&lt;string, int&gt;{ ["Bob"] = 32, ["Alice"] = 17 }; foreach (var (name, age) in dic) { Console.WriteLine($"{name} is {age} years old."); } </code></pre> <p>It doesn't seem to work with Visual Studio 2017 RC4 and .NET Framework 4.6.2:</p> <blockquote> <p>error CS1061: 'KeyValuePair' does not contain a definition for 'Deconstruct' and no extension method 'Deconstruct' accepting a first argument of type 'KeyValuePair' could be found (are you missing a using directive or an assembly reference?)</p> </blockquote>
0debug
Postgres enum in typeorm : <p>In typeorm, how can I create a postgres enum type <em>Gender</em> as in this raw query</p> <pre><code>CREATE TYPE public.Gender AS ENUM ( 'male', 'female' ); ALTER TABLE public.person ALTER COLUMN gender TYPE public.gender USING gender::gender; </code></pre> <p>and use it in the Entity class?</p> <p>I have tried </p> <pre><code>@Entity() export class Person { @Column('enum') gender: 'male' | 'female' } </code></pre> <p>but obviously this isn't the right way, since I got the error message "type <em>enum</em> does not exist". </p> <p>I don't want to use typescript enum either, since it will give me a bunch of 0s and 1s in the database.</p>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
convert CSV to JSON with exhaustive fileds : I want to convert my JSON {\"field1\": 11,\"field3\": 13},{\"field1\": 21,\"field2\": 22,\"field3\": 23},{\"field1\": 31,\"field2\": 32,\"field3\": 33,\"field4\": 34} to CSV Its returning field3 field1 13 11 23 21 33 31 It should rather return field1 field2 field3 field4 11 13 21 22 23 31 32 33 34 I am using below code String jsonString1 = "{\"infile\": [{\"field1\": 11,\"field3\": 13},{\"field1\": 21,\"field2\": 22,\"field3\": 23},{\"field1\": 31,\"field2\": 32,\"field3\": 33,\"field4\": 34}]}"; try { output = new JSONObject(jsonString1); String destination = "tmp/json2csv.csv"; JSONArray docs = output.getJSONArray("infile"); File file=new File(destination); String csv = CDL.toString(docs); FileUtils.writeStringToFile(file, csv); } catch (JSONException e) { }
0debug
int unix_listen_opts(QemuOpts *opts, Error **errp) { struct sockaddr_un un; const char *path = qemu_opt_get(opts, "path"); int sock, fd; sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) { error_setg_errno(errp, errno, "Failed to create Unix socket"); return -1; } memset(&un, 0, sizeof(un)); un.sun_family = AF_UNIX; if (path && strlen(path)) { snprintf(un.sun_path, sizeof(un.sun_path), "%s", path); } else { const char *tmpdir = getenv("TMPDIR"); tmpdir = tmpdir ? tmpdir : "/tmp"; if (snprintf(un.sun_path, sizeof(un.sun_path), "%s/qemu-socket-XXXXXX", tmpdir) >= sizeof(un.sun_path)) { error_setg_errno(errp, errno, "TMPDIR environment variable (%s) too large", tmpdir); goto err; } fd = mkstemp(un.sun_path); if (fd < 0) { error_setg_errno(errp, errno, "Failed to make a temporary socket name in %s", tmpdir); goto err; } close(fd); qemu_opt_set(opts, "path", un.sun_path, &error_abort); } if ((access(un.sun_path, F_OK) == 0) && unlink(un.sun_path) < 0) { error_setg_errno(errp, errno, "Failed to unlink socket %s", un.sun_path); goto err; } if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) { error_setg_errno(errp, errno, "Failed to bind socket to %s", un.sun_path); goto err; } if (listen(sock, 1) < 0) { error_setg_errno(errp, errno, "Failed to listen on socket"); goto err; } return sock; err: closesocket(sock); return -1; }
1threat
static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); cs->halted = 1; qemu_cpu_kick(cs); env->msr = 0; }
1threat
static void gen_maskg(DisasContext *ctx) { int l1 = gen_new_label(); TCGv t0 = tcg_temp_new(); TCGv t1 = tcg_temp_new(); TCGv t2 = tcg_temp_new(); TCGv t3 = tcg_temp_new(); tcg_gen_movi_tl(t3, 0xFFFFFFFF); tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F); tcg_gen_andi_tl(t1, cpu_gpr[rS(ctx->opcode)], 0x1F); tcg_gen_addi_tl(t2, t0, 1); tcg_gen_shr_tl(t2, t3, t2); tcg_gen_shr_tl(t3, t3, t1); tcg_gen_xor_tl(cpu_gpr[rA(ctx->opcode)], t2, t3); tcg_gen_brcond_tl(TCG_COND_GE, t0, t1, l1); tcg_gen_neg_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); gen_set_label(l1); tcg_temp_free(t0); tcg_temp_free(t1); tcg_temp_free(t2); tcg_temp_free(t3); if (unlikely(Rc(ctx->opcode) != 0)) gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); }
1threat
Need little help on understanding how starting index and substring works : <p>Here is my code</p> <pre><code>public static void main(String[] args) { Scanner reader = new Scanner(System.in); System.out.print("Type a word: "); String userWord = reader.nextLine(); System.out.print("Length of the first part: "); int userLength = Integer.parseInt(reader.nextLine()); System.out.println("Result: " + userWord.substring(0, userLength)); } </code></pre> <p>Result: </p> <pre><code>Type a word: hellothere Length of the first part: 3 Result: hel </code></pre> <p>Starting index starts counting from 0 right? So shouldn't the result print "hell"? </p> <p>0 = h</p> <p>1 = e</p> <p>2 = l</p> <p>3 = l</p>
0debug
Vue js Ready function is not triggered : <p>I have this vue function where there are basically two methods. The first one <code>postStatus</code> is used to save a post just after the user clicks on the save button, and the other one <code>getPosts</code> is used to retrieve all previous posts of that user from the database.</p> <p>Here is the vue.js, where there is an ajax call to a controller (in Laravel 5.3)</p> <pre><code>$(document).ready(function () { var csrf_token = $('meta[name="csrf-token"]').attr('content'); /*Event handling within vue*/ //when we actually submit the form, we want to catch the action new Vue({ el : '#timeline', data : { post : '', posts : [], token : csrf_token, limit : 20, }, methods : { postStatus : function (e) { e.preventDefault(); //console.log('Posted: '+this.post+ '. Token: '+this.token); var request = $.ajax({ url : '/posts', method : "POST", dataType : 'json', data : { 'body' : this.post, '_token': this.token, } }).done(function (data) { //console.log('Data saved successfully. Response: '+data); this.post = ''; this.posts.unshift(data); //Push it to the top of the array and pass the data that we get back }.bind(this));/*http://stackoverflow.com/a/26479602/1883256 and http://stackoverflow.com/a/39945594/1883256 */ /*request.done(function( msg ) { console.log('The tweet has been saved: '+msg+'. Outside ...'); //$( "#log" ).html( msg ); });*/ request.fail(function( jqXHR, textStatus ) { console.log( "Request failed: " + textStatus ); }); }, getPosts : function () { //Ajax request to retrieve all posts $.ajax({ url : '/posts', method : "GET", dataType : 'json', data : { limit : this.limit, } }).done(function (data) { this.posts = data.posts; }.bind(this)); } }, //the following will be run when everything is booted up ready : function () { console.log('Attempting to get the previous posts ...'); this.getPosts(); } }); }); </code></pre> <p>So far the, first method <code>postStatus</code> is working fine.</p> <p>The second one is supposed to be called or fired right at the ready function, however, nothing happens. I don't even get the console.log message <code>Attempting to get the previous posts ...</code>. It seems it's never fired.</p> <p>What is the issue? How do I fix it?</p> <p>Notes: I am using jQuery 3.1.1, Vue.js 2.0.1</p>
0debug
void ff_h261_loop_filter(H261Context * h){ MpegEncContext * const s = &h->s; int i; const int linesize = s->linesize; const int uvlinesize= s->uvlinesize; uint8_t *dest_y = s->dest[0]; uint8_t *dest_cb= s->dest[1]; uint8_t *dest_cr= s->dest[2]; uint8_t *src; CHECKED_ALLOCZ((src),sizeof(uint8_t) * 64 ); for(i=0; i<8;i++) memcpy(src+i*8,dest_y+i*linesize,sizeof(uint8_t) * 8 ); s->dsp.h261_v_loop_filter(dest_y, src, linesize); s->dsp.h261_h_loop_filter(dest_y, src, linesize); for(i=0; i<8;i++) memcpy(src+i*8,dest_y+i*linesize + 8,sizeof(uint8_t) * 8 ); s->dsp.h261_v_loop_filter(dest_y + 8, src, linesize); s->dsp.h261_h_loop_filter(dest_y + 8, src, linesize); for(i=0; i<8;i++) memcpy(src+i*8,dest_y+(i+8)*linesize,sizeof(uint8_t) * 8 ); s->dsp.h261_v_loop_filter(dest_y + 8 * linesize, src, linesize); s->dsp.h261_h_loop_filter(dest_y + 8 * linesize, src, linesize); for(i=0; i<8;i++) memcpy(src+i*8,dest_y+(i+8)*linesize + 8,sizeof(uint8_t) * 8 ); s->dsp.h261_v_loop_filter(dest_y + 8 * linesize + 8, src, linesize); s->dsp.h261_h_loop_filter(dest_y + 8 * linesize + 8, src, linesize); for(i=0; i<8;i++) memcpy(src+i*8,dest_cb+i*uvlinesize,sizeof(uint8_t) * 8 ); s->dsp.h261_v_loop_filter(dest_cb, src, uvlinesize); s->dsp.h261_h_loop_filter(dest_cb, src, uvlinesize); for(i=0; i<8;i++) memcpy(src+i*8,dest_cr+i*uvlinesize,sizeof(uint8_t) * 8 ); s->dsp.h261_v_loop_filter(dest_cr, src, uvlinesize); s->dsp.h261_h_loop_filter(dest_cr, src, uvlinesize); fail: av_free(src); return; }
1threat
Shared preference and SQLite : <p>I want to confirm my understanding about sharedPreference and SQLite. Please help me.</p> <p>shared preference </p> <ol> <li>store private primitive data in key-value pair. </li> <li>Useful for store small amount of data </li> <li>Data stored in xml file, and without encryption. Thus it is not secure.</li> <li>Able to access by other apps. Not secure. </li> </ol> <p>SQLite</p> <ol> <li>Does not require any server, it store locally in the mobile device.</li> <li>Useful for store small or large amount of data.</li> <li>Data stored is encrypted. Thus more secure.</li> <li>Not accessible outside the app. Thus more secure.</li> </ol> <p>Please correct me if anything wrong. Thank you. </p>
0debug
Taskkill /PID not working in GitBash : <p>I'm trying to kill a process on GitBash on Windows10 using the taskkill command. However, I get the following error:</p> <pre><code>$ taskkill /pid 13588 ERROR: Invalid argument/option - 'C:/Program Files/Git/pid'. Type "TASKKILL /?" for usage. </code></pre> <p>it works fine on cmd. Can anyone help?</p>
0debug
What to store in a JWT? : <p>How do you guys deal with the same user on multiple devices? Won't data such as <code>{admin: true}</code> become stale except for the device that changed it?</p> <p>Should this even be in a JWT? If not, and we resort to only putting the user ID, won't that be just like a cookie-based session since we store the state on the server?</p>
0debug
static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size; size= MP3_PACKET_SIZE; ret= av_get_packet(s->pb, pkt, size); pkt->stream_index = 0; if (ret <= 0) { if(ret<0) return ret; return AVERROR_EOF; } if (ret > ID3v1_TAG_SIZE && memcmp(&pkt->data[ret - ID3v1_TAG_SIZE], "TAG", 3) == 0) ret -= ID3v1_TAG_SIZE; pkt->size = ret; return ret; }
1threat
static int inject_error(BlockDriverState *bs, BlkdebugRule *rule) { BDRVBlkdebugState *s = bs->opaque; int error = rule->options.inject.error; bool immediately = rule->options.inject.immediately; if (rule->options.inject.once) { QSIMPLEQ_REMOVE(&s->active_rules, rule, BlkdebugRule, active_next); remove_rule(rule); } if (!immediately) { aio_bh_schedule_oneshot(bdrv_get_aio_context(bs), error_callback_bh, qemu_coroutine_self()); qemu_coroutine_yield(); } return -error; }
1threat
What's the reason behind having std::integral_constant? : <p>What's the real use case of this?</p> <pre><code>std::integral_constant </code></pre> <p>I can understand this is a wrapper with value 2:</p> <pre><code>typedef std::integral_constant&lt;int, 2&gt; two_t </code></pre> <p>But why not just use 2 or define a const int value with 2?</p>
0debug
How to compare clob columns of single table in oracle? : <p>How to compare clob columns of single table in oracle?</p>
0debug
static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) { ARMCPU *cpu = s->cpu; uint32_t val; switch (offset) { case 4: return ((s->num_irq - NVIC_FIRST_IRQ) / 32) - 1; case 0x380 ... 0x3bf: { int startvec = 32 * (offset - 0x380) + NVIC_FIRST_IRQ; int i; if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return 0; } val = 0; for (i = 0; i < 32 && startvec + i < s->num_irq; i++) { if (s->itns[startvec + i]) { val |= (1 << i); } } return val; } case 0xd00: return cpu->midr; case 0xd04: val = cpu->env.v7m.exception; val |= (s->vectpending & 0xff) << 12; if (nvic_isrpending(s)) { val |= (1 << 22); } if (nvic_rettobase(s)) { val |= (1 << 11); } if (attrs.secure) { if (s->sec_vectors[ARMV7M_EXCP_SYSTICK].pending) { val |= (1 << 26); } if (s->sec_vectors[ARMV7M_EXCP_PENDSV].pending) { val |= (1 << 28); } } else { if (s->vectors[ARMV7M_EXCP_SYSTICK].pending) { val |= (1 << 26); } if (s->vectors[ARMV7M_EXCP_PENDSV].pending) { val |= (1 << 28); } } if ((cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) && s->vectors[ARMV7M_EXCP_NMI].pending) { val |= (1 << 31); } return val; case 0xd08: return cpu->env.v7m.vecbase[attrs.secure]; case 0xd0c: val = 0xfa050000 | (s->prigroup[attrs.secure] << 8); if (attrs.secure) { val |= cpu->env.v7m.aircr; } else { if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { val |= cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK; } } return val; case 0xd10: return 0; case 0xd14: val = cpu->env.v7m.ccr[attrs.secure]; val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK; return val; case 0xd24: val = 0; if (attrs.secure) { if (s->sec_vectors[ARMV7M_EXCP_MEM].active) { val |= (1 << 0); } if (s->sec_vectors[ARMV7M_EXCP_HARD].active) { val |= (1 << 2); } if (s->sec_vectors[ARMV7M_EXCP_USAGE].active) { val |= (1 << 3); } if (s->sec_vectors[ARMV7M_EXCP_SVC].active) { val |= (1 << 7); } if (s->sec_vectors[ARMV7M_EXCP_PENDSV].active) { val |= (1 << 10); } if (s->sec_vectors[ARMV7M_EXCP_SYSTICK].active) { val |= (1 << 11); } if (s->sec_vectors[ARMV7M_EXCP_USAGE].pending) { val |= (1 << 12); } if (s->sec_vectors[ARMV7M_EXCP_MEM].pending) { val |= (1 << 13); } if (s->sec_vectors[ARMV7M_EXCP_SVC].pending) { val |= (1 << 15); } if (s->sec_vectors[ARMV7M_EXCP_MEM].enabled) { val |= (1 << 16); } if (s->sec_vectors[ARMV7M_EXCP_USAGE].enabled) { val |= (1 << 18); } if (s->sec_vectors[ARMV7M_EXCP_HARD].pending) { val |= (1 << 21); } if (s->vectors[ARMV7M_EXCP_SECURE].active) { val |= (1 << 4); } if (s->vectors[ARMV7M_EXCP_SECURE].enabled) { val |= (1 << 19); } if (s->vectors[ARMV7M_EXCP_SECURE].pending) { val |= (1 << 20); } } else { if (s->vectors[ARMV7M_EXCP_MEM].active) { val |= (1 << 0); } if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { if (s->vectors[ARMV7M_EXCP_HARD].active) { val |= (1 << 2); } if (s->vectors[ARMV7M_EXCP_HARD].pending) { val |= (1 << 21); } } if (s->vectors[ARMV7M_EXCP_USAGE].active) { val |= (1 << 3); } if (s->vectors[ARMV7M_EXCP_SVC].active) { val |= (1 << 7); } if (s->vectors[ARMV7M_EXCP_PENDSV].active) { val |= (1 << 10); } if (s->vectors[ARMV7M_EXCP_SYSTICK].active) { val |= (1 << 11); } if (s->vectors[ARMV7M_EXCP_USAGE].pending) { val |= (1 << 12); } if (s->vectors[ARMV7M_EXCP_MEM].pending) { val |= (1 << 13); } if (s->vectors[ARMV7M_EXCP_SVC].pending) { val |= (1 << 15); } if (s->vectors[ARMV7M_EXCP_MEM].enabled) { val |= (1 << 16); } if (s->vectors[ARMV7M_EXCP_USAGE].enabled) { val |= (1 << 18); } } if (attrs.secure || (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { if (s->vectors[ARMV7M_EXCP_BUS].active) { val |= (1 << 1); } if (s->vectors[ARMV7M_EXCP_BUS].pending) { val |= (1 << 14); } if (s->vectors[ARMV7M_EXCP_BUS].enabled) { val |= (1 << 17); } if (arm_feature(&cpu->env, ARM_FEATURE_V8) && s->vectors[ARMV7M_EXCP_NMI].active) { val |= (1 << 5); } } if (s->vectors[ARMV7M_EXCP_DEBUG].active) { val |= (1 << 8); } return val; case 0xd28: val = cpu->env.v7m.cfsr[attrs.secure]; val |= cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK; return val; case 0xd2c: return cpu->env.v7m.hfsr; case 0xd30: return cpu->env.v7m.dfsr; case 0xd34: return cpu->env.v7m.mmfar[attrs.secure]; case 0xd38: return cpu->env.v7m.bfar; case 0xd3c: qemu_log_mask(LOG_UNIMP, "Aux Fault status registers unimplemented\n"); return 0; case 0xd40: return 0x00000030; case 0xd44: return 0x00000200; case 0xd48: return 0x00100000; case 0xd4c: return 0x00000000; case 0xd50: return 0x00000030; case 0xd54: return 0x00000000; case 0xd58: return 0x00000000; case 0xd5c: return 0x00000000; case 0xd60: return 0x01141110; case 0xd64: return 0x02111000; case 0xd68: return 0x21112231; case 0xd6c: return 0x01111110; case 0xd70: return 0x01310102; case 0xd90: return cpu->pmsav7_dregion << 8; break; case 0xd94: return cpu->env.v7m.mpu_ctrl[attrs.secure]; case 0xd98: return cpu->env.pmsav7.rnr[attrs.secure]; case 0xd9c: case 0xda4: case 0xdac: case 0xdb4: { int region = cpu->env.pmsav7.rnr[attrs.secure]; if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { int aliasno = (offset - 0xd9c) / 8; if (aliasno) { region = deposit32(region, 0, 2, aliasno); } if (region >= cpu->pmsav7_dregion) { return 0; } return cpu->env.pmsav8.rbar[attrs.secure][region]; } if (region >= cpu->pmsav7_dregion) { return 0; } return (cpu->env.pmsav7.drbar[region] & 0x1f) | (region & 0xf); } case 0xda0: case 0xda8: case 0xdb0: case 0xdb8: { int region = cpu->env.pmsav7.rnr[attrs.secure]; if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { int aliasno = (offset - 0xda0) / 8; if (aliasno) { region = deposit32(region, 0, 2, aliasno); } if (region >= cpu->pmsav7_dregion) { return 0; } return cpu->env.pmsav8.rlar[attrs.secure][region]; } if (region >= cpu->pmsav7_dregion) { return 0; } return ((cpu->env.pmsav7.dracr[region] & 0xffff) << 16) | (cpu->env.pmsav7.drsr[region] & 0xffff); } case 0xdc0: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } return cpu->env.pmsav8.mair0[attrs.secure]; case 0xdc4: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } return cpu->env.pmsav8.mair1[attrs.secure]; case 0xdd0: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return 0; } return cpu->env.sau.ctrl; case 0xdd4: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return 0; } return cpu->sau_sregion; case 0xdd8: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return 0; } return cpu->env.sau.rnr; case 0xddc: { int region = cpu->env.sau.rnr; if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return 0; } if (region >= cpu->sau_sregion) { return 0; } return cpu->env.sau.rbar[region]; } case 0xde0: { int region = cpu->env.sau.rnr; if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return 0; } if (region >= cpu->sau_sregion) { return 0; } return cpu->env.sau.rlar[region]; } case 0xde4: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return 0; } return cpu->env.v7m.sfsr; case 0xde8: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return 0; } return cpu->env.v7m.sfar; default: bad_offset: qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset); return 0; } }
1threat
void ff_acelp_interpolate( int16_t* out, const int16_t* in, const int16_t* filter_coeffs, int precision, int frac_pos, int filter_length, int length) { int n, i; assert(pitch_delay_frac >= 0 && pitch_delay_frac < precision); for(n=0; n<length; n++) { int idx = 0; int v = 0x4000; for(i=0; i<filter_length;) { v += in[n + i] * filter_coeffs[idx + frac_pos]; idx += precision; i++; v += in[n - i] * filter_coeffs[idx - frac_pos]; } out[n] = av_clip_int16(v >> 15); } }
1threat
Group arrays according to their keys and remove duplicates (2 dimensional arrays PHP) : I have three arrays as follow: $a=Array ( [0] => 'member0' [1] => 'member1' [2] => 'member2' [3] => 'member1'); $b=Array ( [0] => 'id0' [1] => 'id1' [2] => 'id2' [3] => 'id1'); $c=Array ( [0] => 'tf0' [1] => 'tf1' [2] => 'tf2' [3] => 'tf1'); I would like to group their values according to their keys in a 2 dimensional array to output the following: $2dim_array=array(array('member0','id0','tf0'),array('member1','id1','tf1'),array('member2','id2','tf2'),array('member1','id1','tf1')); After, I would like to remove any duplicate array inside of the previous 2 dimensional array and output something like this: $remove_duplicates=array(array('member0','id0','tf0'),array('member1','id1','tf1'),array('member2','id2','tf2')); How can I do this?. Thanks. Note: The arrays of this example only contain 3 elements each, but the length of my arrays can be variable (undefined number of keys).
0debug
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set. : <p>I am getting exception even after setting hibernate.dialect property. I am using hibernate 5.0.11 with spring boot 1.4.2 and mysql version as 5.7</p> <pre><code>application.properties is like this # Hibernate hibernate.dialect=org.hibernate.dialect.MySQL5Dialect hibernate.show_sql=true hibernate.hbm2ddl.auto=validate </code></pre> <p>pom.xml </p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-aop&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt; &lt;/dependency&gt; &lt;!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --&gt; &lt;dependency&gt; &lt;groupId&gt;org.projectlombok&lt;/groupId&gt; &lt;artifactId&gt;lombok&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt; &lt;/dependency&gt; </code></pre> <p>What is issue here ? </p>
0debug
Index position in Python : <p>Can someone please explain why in the second variable we select index [1]? Wouldn't the index position be the same as the first variable since I am trying to compare the first letter of the word. Please help and thank you in advance. </p> <pre><code>def animal_crakers(text): string = text.split() return string[0][0] == string[1][0] </code></pre>
0debug
Javascript eval questions : <p>I see following code and would like to know what it is doing. It is converting eval result to object?</p> <pre><code>eval("Function here")("Object here"); </code></pre> <p>I have another question. Does eval work as reflection? It loads to memory every time this code is called and ends up with memory leak?</p>
0debug
c# parallel foreach loop finding index : <p>I am trying to read all lines in a text file and planning to display each line info. How can I find the index for each item inside loop?</p> <pre><code>string[] lines = File.ReadAllLines("MyFile.txt"); List&lt;string&gt; list_lines = new List&lt;string&gt;(lines); Parallel.ForEach(list_lines, (line, index) =&gt; { Console.WriteLine(index); // Console.WriteLine(list_lines[index]); Console.WriteLine(list_lines[0]); }); Console.ReadLine(); </code></pre>
0debug
static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit) { MpegTSContext *ts = s->priv_data; int64_t pos, timestamp; uint8_t buf[TS_PACKET_SIZE]; int pcr_l, pcr_pid = ((PESContext*)s->streams[stream_index]->priv_data)->pcr_pid; pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47; while(pos < pos_limit) { avio_seek(s->pb, pos, SEEK_SET); if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) return AV_NOPTS_VALUE; if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) && parse_pcr(&timestamp, &pcr_l, buf) == 0) { *ppos = pos; return timestamp; } pos += ts->raw_packet_size; } return AV_NOPTS_VALUE; }
1threat
"Protocols cannot be used with isinstance()" - why not? : <p>The new <code>typing</code> module contains several objects with names like "SupportsInt" (-Float, -Bytes, etc.). The name, and the descriptions on <a href="https://docs.python.org/3/library/typing.html">the documentation page for the module</a>, might be read to suggest that you can test whether an object is of a type that "supports <code>__int__()</code>". But if you try to use <code>isinstance()</code>, it gives a response that makes it clear that that isn't something you are meant to do:</p> <pre><code>&gt;&gt;&gt; isinstance(5, typing.SupportsInt) (Traceback omitted) TypeError: Protocols cannot be used with isinstance(). </code></pre> <p>On the other hand, you can use <code>issubclass()</code>:</p> <pre><code>&gt;&gt;&gt; issubclass((5).__class__, typing.SupportsInt) True &gt;&gt;&gt; issubclass(type(5), typing.SupportsInt) True </code></pre> <p>What is a "protocol" in this context? Why does it disallow the use of <code>isinstance()</code> in this way?</p>
0debug
static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) { GICv3State *s = KVM_ARM_GICV3(dev); KVMARMGICv3Class *kgc = KVM_ARM_GICV3_GET_CLASS(s); Error *local_err = NULL; DPRINTF("kvm_arm_gicv3_realize\n"); kgc->parent_realize(dev, &local_err); if (local_err) { error_propagate(errp, local_err); return; } if (s->security_extn) { error_setg(errp, "the in-kernel VGICv3 does not implement the " "security extensions"); return; } gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL); s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V3, false); if (s->dev_fd < 0) { error_setg_errno(errp, -s->dev_fd, "error creating in-kernel VGIC"); return; } kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0, &s->num_irq, true); kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true); kvm_arm_register_device(&s->iomem_dist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR, KVM_VGIC_V3_ADDR_TYPE_DIST, s->dev_fd); kvm_arm_register_device(&s->iomem_redist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR, KVM_VGIC_V3_ADDR_TYPE_REDIST, s->dev_fd); error_setg(&s->migration_blocker, "vGICv3 migration is not implemented"); migrate_add_blocker(s->migration_blocker); if (kvm_has_gsi_routing()) { kvm_init_irq_routing(kvm_state); for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) { kvm_irqchip_add_irq_route(kvm_state, i, 0, i); } kvm_gsi_routing_allowed = true; kvm_irqchip_commit_routes(kvm_state); } }
1threat
void op_dmtc0_ebase (void) { env->CP0_EBase = (int32_t)0x80000000 | (T0 & 0x3FFFF000); RETURN(); }
1threat
int bdrv_open(BlockDriverState *bs, const char *filename, int flags, BlockDriver *drv) { int ret, open_flags; char tmp_filename[PATH_MAX]; char backing_filename[PATH_MAX]; bs->is_temporary = 0; bs->encrypted = 0; bs->valid_key = 0; bs->open_flags = flags; bs->buffer_alignment = 512; if (flags & BDRV_O_SNAPSHOT) { BlockDriverState *bs1; int64_t total_size; int is_protocol = 0; BlockDriver *bdrv_qcow2; QEMUOptionParameter *options; bs1 = bdrv_new(""); ret = bdrv_open(bs1, filename, 0, drv); if (ret < 0) { bdrv_delete(bs1); return ret; } total_size = bdrv_getlength(bs1) >> BDRV_SECTOR_BITS; if (bs1->drv && bs1->drv->protocol_name) is_protocol = 1; bdrv_delete(bs1); get_tmp_filename(tmp_filename, sizeof(tmp_filename)); if (is_protocol) snprintf(backing_filename, sizeof(backing_filename), "%s", filename); else if (!realpath(filename, backing_filename)) return -errno; bdrv_qcow2 = bdrv_find_format("qcow2"); options = parse_option_parameters("", bdrv_qcow2->create_options, NULL); set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size * 512); set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename); if (drv) { set_option_parameter(options, BLOCK_OPT_BACKING_FMT, drv->format_name); } ret = bdrv_create(bdrv_qcow2, tmp_filename, options); if (ret < 0) { return ret; } filename = tmp_filename; drv = bdrv_qcow2; bs->is_temporary = 1; } pstrcpy(bs->filename, sizeof(bs->filename), filename); if (!drv) { drv = find_hdev_driver(filename); if (!drv) { drv = find_image_format(filename); } } if (!drv) { ret = -ENOENT; goto unlink_and_fail; } if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) { ret = -ENOTSUP; goto unlink_and_fail; } bs->drv = drv; bs->opaque = qemu_mallocz(drv->instance_size); if (flags & (BDRV_O_CACHE_WB|BDRV_O_NOCACHE)) bs->enable_write_cache = 1; open_flags = flags & ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); if (bs->is_temporary) { open_flags |= BDRV_O_RDWR; } ret = drv->bdrv_open(bs, filename, open_flags); if (ret < 0) { goto free_and_fail; } bs->keep_read_only = bs->read_only = !(open_flags & BDRV_O_RDWR); if (drv->bdrv_getlength) { bs->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; } #ifndef _WIN32 if (bs->is_temporary) { unlink(filename); } #endif if ((flags & BDRV_O_NO_BACKING) == 0 && bs->backing_file[0] != '\0') { BlockDriver *back_drv = NULL; bs->backing_hd = bdrv_new(""); path_combine(backing_filename, sizeof(backing_filename), filename, bs->backing_file); if (bs->backing_format[0] != '\0') back_drv = bdrv_find_format(bs->backing_format); open_flags &= ~BDRV_O_RDWR; ret = bdrv_open(bs->backing_hd, backing_filename, open_flags, back_drv); if (ret < 0) { bdrv_close(bs); return ret; } if (bs->is_temporary) { bs->backing_hd->keep_read_only = !(flags & BDRV_O_RDWR); } else { bs->backing_hd->keep_read_only = bs->keep_read_only; } } if (!bdrv_key_required(bs)) { bs->media_changed = 1; if (bs->change_cb) bs->change_cb(bs->change_opaque); } return 0; free_and_fail: qemu_free(bs->opaque); bs->opaque = NULL; bs->drv = NULL; unlink_and_fail: if (bs->is_temporary) unlink(filename); return ret; }
1threat
How to serialize LocalDateTime with Jackson? : <p>I got the following piece of code:</p> <pre><code> ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); String now = new ObjectMapper().writeValueAsString(new SomeClass(LocalDateTime.now())); System.out.println(now); </code></pre> <p>And I get this:</p> <blockquote> <p>{"time":{"hour":20,"minute":49,"second":42,"nano":99000000,"dayOfYear":19,"dayOfWeek":"THURSDAY","month":"JANUARY","dayOfMonth":19,"year":2017,"monthValue":1,"chronology":{"id":"ISO","calendarType":"iso8601"}}}</p> </blockquote> <p>What I want to achieve is a string in ISO8601</p> <blockquote> <p>2017-01-19T18:36:51Z</p> </blockquote>
0debug
Can't bind to 'ngValue' since it isn't a known property of 'option' : <p>I am trying to implement <code>select</code> in Angular 5 but I am constantly getting this</p> <p><a href="https://i.stack.imgur.com/nmJg1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nmJg1.png" alt="enter image description here"></a></p> <p>I've tried many StackOverflow questions already, The only difference is - My components are inside another module within the application which is at the end injected into the main module eventually. I've also tried injecting the <code>FormsModule</code> inside the inner module. I have tried importing <code>ReactiveFormsModule</code> but didn't work.</p> <p>I've added <code>FormsModule</code> to imports like this</p> <pre><code>import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AppRoutingModule } from './app-routing.module'; @NgModule({ declarations: [ ...CombineComponents ], imports: [ BrowserModule, FormsModule, AppRoutingModule, HttpClientModule ] }); </code></pre> <p>and here is my component markup</p> <pre><code>&lt;label for="ctn" class="d-inline-block pl-1 semi-bold"&gt;Current active number&lt;/label&gt; &lt;select #selectElem class="custom-select" id="ctn" (change)="onCTNChange(selectElem.value)" formControlName="state" &gt; &lt;option value="" disabled&gt;Choose a state&lt;/option&gt; &lt;option *ngFor="let ctn of availableCTN" [ngValue]="ctn.value"&gt; {{ctn.text}} &lt;/option&gt; &lt;/select&gt; </code></pre>
0debug
Power BI architecture : <p>I need your help please .I'm working with Power BI but I haven't undestand how it work exactly and what it is,is power BI just a tool of visualisation or it is a whole plateform BI which contain his ETL,Datawarhouse,Olap engine ?can someone explain to me this point and give me an the equivalence of ETL,Datwaehouse ,olap in Power BI and tell me wehere the Data is stored inside it.Thanks</p>
0debug
3d animated plots for 12 different columns : <p>I have data frame with 500,000 rows and 16 columns, I have temprature data for all 12 months (500,000) observations for each month(columns), against Latitude and Longitude values( 2 columns). I need to plot animated plot for temperature observations against each month taking long and latitude column. In short want 3d plot (Latitude vs Longitude and Plot temperatures for all 12 months).Please help if you can.</p>
0debug
Access-Control-Max-Age vs Cache-Control : <p>What is the difference between Access-Control-Max-Age and Cache-Control within a http response header?</p> <pre><code>Access-Control-Max-Age:1728000 Cache-Control:max-age=21600, public </code></pre> <p>I have the feeling that they do not refer to the same thing, as often they appear together and sometimes with different values.</p> <p>If they <em>do</em> both appear within a http header, but contain different values, would this be valid?</p>
0debug
'NoneType' object has no attribute 'count' <-- Anagrams : #**I have this error but I don't know why** import itertools word = 'stop' #input('Word [ 2-5 letters recommended ] :').lower() word = list(str(word)) anagrams = ["".join(perm) for perm in itertools.permutations(word)] file = open('wordlist.txt', 'r') lines = file.read().split('\n') for n, i in enumerate(anagrams): if i not in lines: anagrams[n] = '/' for i in enumerate(anagrams): if '/' in anagrams: while anagrams.count('/') > 0: anagrams = anagrams.remove('/') anagrams = '\n'.join(map(str,anagrams)) print(anagrams.strip('')) ##Error: Traceback (most recent call last): File "main.py", line 13, in <module> while anagrams.count('/') > 0: AttributeError: 'NoneType' object has no attribute 'count' Is there anything I am doing wrong? Help!!!!!!! ##[Link for my main code][1] [1]: https://repl.it/@panniu/Anagrams
0debug
excel, check if string contains a character a-z or A-Z : <p>I have a column with unstructured data. I need to detect if the string has an alphabetical character meaning a-z or A-Z. I am not sure how to do this in excel with a formula or other. I am thinking this could be a long countif and sumproduct. Or maybe regex in excel. I will post an attempt try once I try this out more. But I am looking for some advice. While searching online, I could not find a formula to do this. Thanks for your help. Please see below screenshot for sample data.</p> <p><a href="https://i.stack.imgur.com/ucKOl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ucKOl.png" alt="enter image description here"></a></p>
0debug
datetime data type seperate am and pm as checkin and checkout MSSQL : [I need to separate the checkintime column as AM as checkin and PM as checkout ][1] [1]: http://i.stack.imgur.com/1dvUT.jpg
0debug
Redux - how to keep the reducer state during hot reload : <p>I use <em>React</em> + <em>Redux</em> + <em>Webpack</em> + <em>WebpackDevserver</em>. Once the hot loader is launched all my reducers are reseted to the initial state. </p> <p>Can I keep somehow my reducers in the actual state?</p> <p>My Webpack config contains:</p> <pre><code>entry: [ "./index.jsx" ], output: { filename: "./bundle.js" }, module: { loaders: [ { test: /\.js|\.jsx$/, exclude: /node_modules/, loaders: ["react-hot","babel-loader"], } ] }, plugins: [ new webpack.HotModuleReplacementPlugin() ] </code></pre> <p>My reducers stats with:</p> <pre><code>const initialState = { ... } export default function config(state = initialState, action) { ... </code></pre> <p>I start my Webpack Dev-Server just by:</p> <pre><code>"start": "webpack-dev-server", </code></pre>
0debug
libc++ vs libstdc++ std::is_move_assignable: Which is the most correct? : <p>I'm trying to get a deeper understanding of C++ by reading the C++14 standard along with the source of libc++ and libstdc++. The implementation of various <code>type_traits</code> items varies between the two, particularly <code>is_move_assignable</code>, and I'm trying to figure out which of them is "more correct."</p> <p>libc++:</p> <pre><code>template &lt;class _Tp&gt; struct is_move_assignable : public is_assignable&lt;typename add_lvalue_reference&lt;_Tp&gt;::type, const typename add_rvalue_reference&lt;_Tp&gt;::type&gt; {}; </code></pre> <p>libstdc++:</p> <pre><code>template&lt;typename _Tp, bool = __is_referenceable&lt;_Tp&gt;::value&gt; struct __is_move_assignable_impl; template&lt;typename _Tp&gt; struct __is_move_assignable_impl&lt;_Tp, false&gt; : public false_type { }; template&lt;typename _Tp&gt; struct __is_move_assignable_impl&lt;_Tp, true&gt; : public is_assignable&lt;_Tp&amp;, _Tp&amp;&amp;&gt; { }; template&lt;typename _Tp&gt; struct is_move_assignable : public __is_move_assignable_impl&lt;_Tp&gt; { }; </code></pre> <p>The standard states:</p> <blockquote> <p>For a referenceable type <code>T</code>, the same result as <code>is_assignable&lt;T&amp;, T&amp;&amp;&gt;::value</code>, otherwise <code>false</code>.</p> </blockquote> <p>The first thing I noted is that libc++ applies <code>const</code> to the second template parameter, which doesn't seem right since the move assignment operator takes a non-const rvalue. libstdc++ also uses <code>__is_referenceable</code>, which follows the wording of the standard, but libc++ doesn't. Is that requirement covered by libc++'s use of <code>add_lvalue_reference</code> and <code>add_rvalue_reference</code>, which both enforce <code>__is_referenceable</code> on their own?</p> <p>I would really appreciate any insight into why each project chose their solutions!</p>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
a half gauge/speedometer animation using javascript : Hiiiii, i am having problem with a gauge "[click here][1]", i need this gauge animated on change of amount given below the "GAUGE" not on "Turnover amount" [1]: http://clients.pix10.com/demo/5paisa/index.html
0debug
save data to database asp.net mvc : this is the error message : (46,12) : error 2019: Member Mapping specified is not valid. The type 'Edm.String[Nullable=True,DefaultValue=,MaxLength=Max,Unicode=True,FixedLength=False]' of member 'SEJ_STARDATE' in type 'HotelSearch.APP_SEJOUR' is not compatible with 'SqlServer.date[Nullable=True,DefaultValue=,Precision=0]' of member 'SEJ_STARDATE' in type 'CodeFirstDatabaseSchema.APP_SEJOUR'. (47,12) : error 2019: Member Mapping specified is not valid. The type 'Edm.String[Nullable=True,DefaultValue=,MaxLength=Max,Unicode=True,FixedLength=False]' of member 'SEJ_ENDDATE' in type 'HotelSearch.APP_SEJOUR' is not compatible with 'SqlServer.date[Nullable=True,DefaultValue=,Precision=0]' of member 'SEJ_ENDDATE' in type 'CodeFirstDatabaseSchema.APP_SEJOUR'. (112,12) : error 2019: Member Mapping specified is not valid. The type 'Edm.String[Nullable=True,DefaultValue=,MaxLength=Max,Unicode=True,FixedLength=False]' of member 'PRIX_PRICE' in type 'HotelSearch.RFS_PRIX_R' is not compatible with 'SqlServer.date[Nullable=True,DefaultValue=,Precision=0]' of member 'PRIX_PRICE' in type 'CodeFirstDatabaseSchema.RFS_PRIX_R'. how can i fix it ?
0debug
static int netmap_can_send(void *opaque) { NetmapState *s = opaque; return qemu_can_send_packet(&s->nc); }
1threat
Java and haarcascade face and mouth detection - mouth as the nose : <p>Today I begin to test the project which detects a smile in Java and OpenCv. To recognition face and mouth project used haarcascade_frontalface_alt and haarcascade_mcs_mouth But i don't understand why in some reasons project detect nose as a mouth. I have two methods:</p> <pre><code>private ArrayList&lt;Mat&gt; detectMouth(String filename) { int i = 0; ArrayList&lt;Mat&gt; mouths = new ArrayList&lt;Mat&gt;(); // reading image in grayscale from the given path image = Highgui.imread(filename, Highgui.CV_LOAD_IMAGE_GRAYSCALE); MatOfRect faceDetections = new MatOfRect(); // detecting face(s) on given image and saving them to MatofRect object faceDetector.detectMultiScale(image, faceDetections); System.out.println(String.format("Detected %s faces", faceDetections.toArray().length)); MatOfRect mouthDetections = new MatOfRect(); // detecting mouth(s) on given image and saving them to MatOfRect object mouthDetector.detectMultiScale(image, mouthDetections); System.out.println(String.format("Detected %s mouths", mouthDetections.toArray().length)); for (Rect face : faceDetections.toArray()) { Mat outFace = image.submat(face); // saving cropped face to picture Highgui.imwrite("face" + i + ".png", outFace); for (Rect mouth : mouthDetections.toArray()) { // trying to find right mouth // if the mouth is in the lower 2/5 of the face // and the lower edge of mouth is above of the face // and the horizontal center of the mouth is the enter of the face if (mouth.y &gt; face.y + face.height * 3 / 5 &amp;&amp; mouth.y + mouth.height &lt; face.y + face.height &amp;&amp; Math.abs((mouth.x + mouth.width / 2)) - (face.x + face.width / 2) &lt; face.width / 10) { Mat outMouth = image.submat(mouth); // resizing mouth to the unified size of trainSize Imgproc.resize(outMouth, outMouth, trainSize); mouths.add(outMouth); // saving mouth to picture Highgui.imwrite("mouth" + i + ".png", outMouth); i++; } } } return mouths; } </code></pre> <p>and detect smile</p> <pre><code>private void detectSmile(ArrayList&lt;Mat&gt; mouths) { trainSVM(); CvSVMParams params = new CvSVMParams(); // set linear kernel (no mapping, regression is done in the original feature space) params.set_kernel_type(CvSVM.LINEAR); // train SVM with images in trainingImages, labels in trainingLabels, given params with empty samples clasificador = new CvSVM(trainingImages, trainingLabels, new Mat(), new Mat(), params); // save generated SVM to file, so we can see what it generated clasificador.save("svm.xml"); // loading previously saved file clasificador.load("svm.xml"); // returnin, if there aren't any samples if (mouths.isEmpty()) { System.out.println("No mouth detected"); return; } for (Mat mouth : mouths) { Mat out = new Mat(); // converting to 32 bit floating point in gray scale mouth.convertTo(out, CvType.CV_32FC1); if (clasificador.predict(out.reshape(1, 1)) == 1.0) { System.out.println("Detected happy face"); } else { System.out.println("Detected not a happy face"); } } } </code></pre> <p>Examples:</p> <p>For that picture </p> <p><a href="https://i.stack.imgur.com/9b83D.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/9b83D.jpg" alt="enter image description here"></a></p> <p>correctly detects this mounth:</p> <p><a href="https://i.stack.imgur.com/ikQpM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ikQpM.png" alt="enter image description here"></a></p> <p>but in other picture </p> <p><a href="https://i.stack.imgur.com/t7Hg8.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/t7Hg8.jpg" alt="enter image description here"></a></p> <p>nose is detected <a href="https://i.stack.imgur.com/uFWLa.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uFWLa.png" alt="enter image description here"></a></p> <p>What's the problem in your opinion ?</p>
0debug
static int blk_init(struct XenDevice *xendev) { struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); int index, qflags, have_barriers, info = 0; char *h; if (blkdev->params == NULL) { blkdev->params = xenstore_read_be_str(&blkdev->xendev, "params"); h = strchr(blkdev->params, ':'); if (h != NULL) { blkdev->fileproto = blkdev->params; blkdev->filename = h+1; *h = 0; } else { blkdev->fileproto = "<unset>"; blkdev->filename = blkdev->params; } } if (blkdev->mode == NULL) blkdev->mode = xenstore_read_be_str(&blkdev->xendev, "mode"); if (blkdev->type == NULL) blkdev->type = xenstore_read_be_str(&blkdev->xendev, "type"); if (blkdev->dev == NULL) blkdev->dev = xenstore_read_be_str(&blkdev->xendev, "dev"); if (blkdev->devtype == NULL) blkdev->devtype = xenstore_read_be_str(&blkdev->xendev, "device-type"); if (blkdev->params == NULL || blkdev->mode == NULL || blkdev->type == NULL || blkdev->dev == NULL) return -1; if (strcmp(blkdev->mode, "w") == 0) { qflags = BDRV_O_RDWR; } else { qflags = 0; info |= VDISK_READONLY; } if (blkdev->devtype && !strcmp(blkdev->devtype, "cdrom")) info |= VDISK_CDROM; index = (blkdev->xendev.dev - 202 * 256) / 16; blkdev->dinfo = drive_get(IF_XEN, 0, index); if (!blkdev->dinfo) { xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n"); blkdev->bs = bdrv_new(blkdev->dev); if (blkdev->bs) { if (bdrv_open(blkdev->bs, blkdev->filename, qflags, bdrv_find_whitelisted_format(blkdev->fileproto)) != 0) { bdrv_delete(blkdev->bs); blkdev->bs = NULL; } } if (!blkdev->bs) return -1; } else { xen_be_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n"); blkdev->bs = blkdev->dinfo->bdrv; } blkdev->file_blk = BLOCK_SIZE; blkdev->file_size = bdrv_getlength(blkdev->bs); if (blkdev->file_size < 0) { xen_be_printf(&blkdev->xendev, 1, "bdrv_getlength: %d (%s) | drv %s\n", (int)blkdev->file_size, strerror(-blkdev->file_size), blkdev->bs->drv ? blkdev->bs->drv->format_name : "-"); blkdev->file_size = 0; } have_barriers = blkdev->bs->drv && blkdev->bs->drv->bdrv_flush ? 1 : 0; xen_be_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\"," " size %" PRId64 " (%" PRId64 " MB)\n", blkdev->type, blkdev->fileproto, blkdev->filename, blkdev->file_size, blkdev->file_size >> 20); xenstore_write_be_int(&blkdev->xendev, "feature-barrier", have_barriers); xenstore_write_be_int(&blkdev->xendev, "info", info); xenstore_write_be_int(&blkdev->xendev, "sector-size", blkdev->file_blk); xenstore_write_be_int(&blkdev->xendev, "sectors", blkdev->file_size / blkdev->file_blk); return 0; }
1threat
def gcd(x, y): gcd = 1 if x % y == 0: return y for k in range(int(y / 2), 0, -1): if x % k == 0 and y % k == 0: gcd = k break return gcd
0debug
How to change the values of cv2.boundingRect : <p>is there a way to change the values of cv2.boundingRect </p> <p><a href="https://i.stack.imgur.com/RDv2J.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RDv2J.jpg" alt="enter image description here"></a></p> <p>I want to adjust so I can get the accurate cv2.drawContours <a href="https://i.stack.imgur.com/jzlTx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jzlTx.png" alt="enter image description here"></a></p> <pre><code>import cv2 # Load image, grayscale, Gaussian blur, Otsu's threshold image = cv2.imread("5.jpg") gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) blur = cv2.GaussianBlur(gray, (5,5), 0) thresh = cv2.threshold(blur, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1] # Find bounding box x,y,w,h = cv2.boundingRect(thresh) cv2.rectangle(image, (x, y), (x + w, y + h), (36,255,12), 2) cv2.putText(image, "w={},h={}".format(w,h), (x,y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (36,255,12), 2) cv2.imshow("thresh", thresh) cv2.imshow("image", image) cv2.waitKey() </code></pre>
0debug
static uint32_t do_mac_read(lan9118_state *s, int reg) { switch (reg) { case MAC_CR: return s->mac_cr; case MAC_ADDRH: return s->conf.macaddr.a[4] | (s->conf.macaddr.a[5] << 8); case MAC_ADDRL: return s->conf.macaddr.a[0] | (s->conf.macaddr.a[1] << 8) | (s->conf.macaddr.a[2] << 16) | (s->conf.macaddr.a[3] << 24); case MAC_HASHH: return s->mac_hashh; break; case MAC_HASHL: return s->mac_hashl; break; case MAC_MII_ACC: return s->mac_mii_acc; case MAC_MII_DATA: return s->mac_mii_data; case MAC_FLOW: return s->mac_flow; default: hw_error("lan9118: Unimplemented MAC register read: %d\n", s->mac_cmd & 0xf); } }
1threat
static enum AVHWDeviceType hw_device_match_type_by_hwaccel(enum HWAccelID hwaccel_id) { int i; if (hwaccel_id == HWACCEL_NONE) return AV_HWDEVICE_TYPE_NONE; for (i = 0; hwaccels[i].name; i++) { if (hwaccels[i].id == hwaccel_id) return hwaccels[i].device_type; } return AV_HWDEVICE_TYPE_NONE; }
1threat
Spring @Value TypeMismatchException:Failed to convert value of type 'java.lang.String' to required type 'java.lang.Double' : <p>I want to use the @Value annotation to inject a Double property such as:</p> <pre><code>@Service public class MyService { @Value("${item.priceFactor}") private Double priceFactor = 0.1; // ... </code></pre> <p>and using Spring property placeholder (Properties files):</p> <pre><code>item.priceFactor=0.1 </code></pre> <p>I get Exception: </p> <blockquote> <p>org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Double'; nested exception is java.lang.NumberFormatException: For input string: "${item.priceFactor}"</p> </blockquote> <p>Is there a way to use a Double value coming from a properties file?</p>
0debug
static int mov_write_header(AVFormatContext *s) { AVIOContext *pb = s->pb; MOVMuxContext *mov = s->priv_data; AVDictionaryEntry *t, *global_tcr = av_dict_get(s->metadata, "timecode", NULL, 0); int i, ret, hint_track = 0, tmcd_track = 0; mov->fc = s; mov->mode = MODE_MP4; if (s->oformat) { if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP; else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2; else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV; else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP; else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD; else if (!strcmp("ismv",s->oformat->name)) mov->mode = MODE_ISM; else if (!strcmp("f4v", s->oformat->name)) mov->mode = MODE_F4V; } if (s->flags & AVFMT_FLAG_BITEXACT) mov->exact = 1; if (mov->flags & FF_MOV_FLAG_DELAY_MOOV) mov->flags |= FF_MOV_FLAG_EMPTY_MOOV; if (mov->max_fragment_duration || mov->max_fragment_size || mov->flags & (FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_FRAG_KEYFRAME | FF_MOV_FLAG_FRAG_CUSTOM)) mov->flags |= FF_MOV_FLAG_FRAGMENT; if (mov->mode == MODE_ISM) mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF | FF_MOV_FLAG_FRAGMENT; if (mov->flags & FF_MOV_FLAG_DASH) mov->flags |= FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_DEFAULT_BASE_MOOF; if (mov->flags & FF_MOV_FLAG_FASTSTART) { mov->reserved_moov_size = -1; } if (mov->use_editlist < 0) { mov->use_editlist = 1; if (mov->flags & FF_MOV_FLAG_FRAGMENT && !(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) { if (s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO || s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) mov->use_editlist = 0; } } if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV && !(mov->flags & FF_MOV_FLAG_DELAY_MOOV) && mov->use_editlist) av_log(s, AV_LOG_WARNING, "No meaningful edit list will be written when using empty_moov without delay_moov\n"); if (!mov->use_editlist && s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO) s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_ZERO; if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET && mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF) mov->flags &= ~FF_MOV_FLAG_OMIT_TFHD_OFFSET; if (mov->frag_interleave && mov->flags & (FF_MOV_FLAG_OMIT_TFHD_OFFSET | FF_MOV_FLAG_SEPARATE_MOOF)) { av_log(s, AV_LOG_ERROR, "Sample interleaving in fragments is mutually exclusive with " "omit_tfhd_offset and separate_moof\n"); return AVERROR(EINVAL); } if (!s->pb->seekable && (!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) { av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); return AVERROR(EINVAL); } if (!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) { if ((ret = mov_write_identification(pb, s)) < 0) return ret; } mov->nb_streams = s->nb_streams; if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters) mov->chapter_track = mov->nb_streams++; if (mov->flags & FF_MOV_FLAG_RTP_HINT) { hint_track = mov->nb_streams; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { mov->nb_streams++; } } } if (mov->mode == MODE_MOV) { tmcd_track = mov->nb_streams; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (global_tcr || av_dict_get(st->metadata, "timecode", NULL, 0))) mov->nb_meta_tmcd++; } if (mov->nb_meta_tmcd) { for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codec->codec_tag == MKTAG('t','m','c','d')) { av_log(s, AV_LOG_WARNING, "You requested a copy of the original timecode track " "so timecode metadata are now ignored\n"); mov->nb_meta_tmcd = 0; } } } mov->nb_streams += mov->nb_meta_tmcd; } mov->tracks = av_mallocz_array((mov->nb_streams + 1), sizeof(*mov->tracks)); if (!mov->tracks) return AVERROR(ENOMEM); for (i = 0; i < s->nb_streams; i++) { AVStream *st= s->streams[i]; MOVTrack *track= &mov->tracks[i]; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0); track->st = st; track->enc = st->codec; track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV); if (track->language < 0) track->language = 0; track->mode = mov->mode; track->tag = mov_find_codec_tag(s, track); if (!track->tag) { av_log(s, AV_LOG_ERROR, "Could not find tag for codec %s in stream #%d, " "codec not currently supported in container\n", avcodec_get_name(st->codec->codec_id), i); ret = AVERROR(EINVAL); goto error; } track->hint_track = -1; track->start_dts = AV_NOPTS_VALUE; track->start_cts = AV_NOPTS_VALUE; track->end_pts = AV_NOPTS_VALUE; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') || track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') || track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) { if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) { av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n"); ret = AVERROR(EINVAL); goto error; } track->height = track->tag >> 24 == 'n' ? 486 : 576; } if (mov->video_track_timescale) { track->timescale = mov->video_track_timescale; } else { track->timescale = st->time_base.den; while(track->timescale < 10000) track->timescale *= 2; } if (st->codec->width > 65535 || st->codec->height > 65535) { av_log(s, AV_LOG_ERROR, "Resolution %dx%d too large for mov/mp4\n", st->codec->width, st->codec->height); ret = AVERROR(EINVAL); goto error; } if (track->mode == MODE_MOV && track->timescale > 100000) av_log(s, AV_LOG_WARNING, "WARNING codec timebase is very high. If duration is too long,\n" "file may not be playable by quicktime. Specify a shorter timebase\n" "or choose different container.\n"); } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { track->timescale = st->codec->sample_rate; if (!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) { av_log(s, AV_LOG_WARNING, "track %d: codec frame size is not set\n", i); track->audio_vbr = 1; }else if (st->codec->codec_id == AV_CODEC_ID_ADPCM_MS || st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV || st->codec->codec_id == AV_CODEC_ID_ILBC){ if (!st->codec->block_align) { av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i); ret = AVERROR(EINVAL); goto error; } track->sample_size = st->codec->block_align; }else if (st->codec->frame_size > 1){ track->audio_vbr = 1; }else{ track->sample_size = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels; } if (st->codec->codec_id == AV_CODEC_ID_ILBC || st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_QT) { track->audio_vbr = 1; } if (track->mode != MODE_MOV && track->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) { if (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL) { av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not standard, to mux anyway set strict to -1\n", i, track->enc->sample_rate); ret = AVERROR(EINVAL); goto error; } else { av_log(s, AV_LOG_WARNING, "track %d: muxing mp3 at %dhz is not standard in MP4\n", i, track->enc->sample_rate); } } } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { track->timescale = st->time_base.den; } else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) { track->timescale = st->time_base.den; } else { track->timescale = MOV_TIMESCALE; } if (!track->height) track->height = st->codec->height; if (mov->mode == MODE_ISM) track->timescale = 10000000; avpriv_set_pts_info(st, 64, 1, track->timescale); if (st->codec->extradata_size) { if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE) mov_create_dvd_sub_decoder_specific_info(track, st); else if (!TAG_IS_AVCI(track->tag) && st->codec->codec_id != AV_CODEC_ID_DNXHD) { track->vos_len = st->codec->extradata_size; track->vos_data = av_malloc(track->vos_len); if (!track->vos_data) { ret = AVERROR(ENOMEM); goto error; } memcpy(track->vos_data, st->codec->extradata, track->vos_len); } } } for (i = 0; i < s->nb_streams; i++) { int j; AVStream *st= s->streams[i]; MOVTrack *track= &mov->tracks[i]; if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || track->enc->channel_layout != AV_CH_LAYOUT_MONO) continue; for (j = 0; j < s->nb_streams; j++) { AVStream *stj= s->streams[j]; MOVTrack *trackj= &mov->tracks[j]; if (j == i) continue; if (stj->codec->codec_type != AVMEDIA_TYPE_AUDIO || trackj->enc->channel_layout != AV_CH_LAYOUT_MONO || trackj->language != track->language || trackj->tag != track->tag ) continue; track->multichannel_as_mono++; } } enable_tracks(s); if (mov->reserved_moov_size){ mov->reserved_moov_pos= avio_tell(pb); if (mov->reserved_moov_size > 0) avio_skip(pb, mov->reserved_moov_size); } if (mov->flags & FF_MOV_FLAG_FRAGMENT) { if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME | FF_MOV_FLAG_FRAG_CUSTOM)) && !mov->max_fragment_duration && !mov->max_fragment_size) mov->flags |= FF_MOV_FLAG_FRAG_KEYFRAME; } else { if (mov->flags & FF_MOV_FLAG_FASTSTART) mov->reserved_moov_pos = avio_tell(pb); mov_write_mdat_tag(pb, mov); } if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) mov->time = ff_iso8601_to_unix_time(t->value); if (mov->time) mov->time += 0x7C25B080; if (mov->chapter_track) if ((ret = mov_create_chapter_track(s, mov->chapter_track)) < 0) goto error; if (mov->flags & FF_MOV_FLAG_RTP_HINT) { for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if ((ret = ff_mov_init_hinting(s, hint_track, i)) < 0) goto error; hint_track++; } } } if (mov->nb_meta_tmcd) { for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; t = global_tcr; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (!t) t = av_dict_get(st->metadata, "timecode", NULL, 0); if (!t) continue; if ((ret = mov_create_timecode_track(s, tmcd_track, i, t->value)) < 0) goto error; tmcd_track++; } } } avio_flush(pb); if (mov->flags & FF_MOV_FLAG_ISML) mov_write_isml_manifest(pb, mov); if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV && !(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) { if ((ret = mov_write_moov_tag(pb, mov, s)) < 0) return ret; mov->moov_written = 1; if (mov->flags & FF_MOV_FLAG_FASTSTART) mov->reserved_moov_pos = avio_tell(pb); } return 0; error: mov_free(s); return ret; }
1threat
How to move files into corresponding folders in bash : I have a folder with files such as: 20170129-aaa.jpg 20170130-bbb.jpg 20170131-ccc.jpg 20170201-ddd.jpg 20170202-eee.jpg I'd like to create folders based on the YYYYMM part of the files, and move the files to its corresponding folder. (eg. `20170129-aaa.jpg` -> `201701/20170129-aaa.jpg`) I'm new to bash, my attempts on awk, uniq, substring are all failed. How can I make this work? Thanks
0debug
Routes won't work when I install composer and use autoloading option? : <p>When I install composer and set autoloading option and then click on my links other than home page I get this error 'Fatal error: Uncaught Error: Class 'homeController' not found in C:\xampp\htdocs\gacho\app\core\Application.php:13 Stack trace: #0 C:\xampp\htdocs\gacho\public\index.php(16): Application->__construct() #1 {main} thrown in C:\xampp\htdocs\gacho\app\core\Application.php on line 13 ', but link to home page works just fine. Here is my code structure and code: </p> <p>code structure</p> <pre><code> gacho |-app |- controller |- core |- model |- view |-public |-vendor |-composer |- autoload_classmap.php |- autoload.php |- .htaccess |- composer.json |- index.php </code></pre> <p>.htaccess</p> <pre><code>RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^ index.php [QSA,L] </code></pre> <p>composer.json</p> <pre><code>{ "autoload": { "classmap":[ "../app" ] } } </code></pre> <p>autoload_classmap</p> <pre><code>$vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( 'App\\Controller\\HomeController' =&gt; $baseDir . '/../app/controller/HomeController.php', 'App\\Core\\Application' =&gt; $baseDir . '/../app/core/Application.php', 'App\\Core\\Controller' =&gt; $baseDir . '/../app/core/Controller.php', 'App\\Core\\Database' =&gt; $baseDir . '/../app/core/Database.php', 'App\\Core\\View' =&gt; $baseDir . '/../app/core/View.php', 'App\\Model\\User' =&gt; $baseDir . '/../app/model/User.php', ); </code></pre> <p>index.php</p> <pre><code>define('ROOT', dirname(__DIR__) . DIRECTORY_SEPARATOR); define('APP', ROOT . 'app' . DIRECTORY_SEPARATOR); define('CONTROLLER', ROOT . 'app' . DIRECTORY_SEPARATOR . 'controller' . DIRECTORY_SEPARATOR); define('VIEW', ROOT . 'app' . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR); define('MODEL', ROOT . 'app' . DIRECTORY_SEPARATOR . 'model' . DIRECTORY_SEPARATOR); define('CORE', ROOT . 'app' . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR); $modules = [ROOT, APP, CORE, CONTROLLER]; require_once __DIR__ . '\vendor\autoload.php'; new Application; </code></pre> <p>Application.php</p> <pre><code>class Application { protected $controller = 'HomeController'; protected $action = 'index'; protected $params = []; public function __construct() { $this-&gt;prepareURL(); if (file_exists(CONTROLLER. $this-&gt;controller . '.php')) { $this-&gt;controller = new $this-&gt;controller; if (method_exists($this-&gt;controller, $this-&gt;action)) { call_user_func_array([$this-&gt;controller, $this-&gt;action], $this-&gt;params); } } } </code></pre>
0debug
Exception when calling : <p>I would like to ask a question for computing a hashvalue for a empty file. I need to compute a hash_value when the file f is first created and is empty. Then, at the end I will update the hash_value again. My code is not working for windows os. Can you tell me how to handle this? Thanks. </p> <pre><code> objectFile = File(fullFilePath); fileInputStream = FileInputStream(objectFile); data = IOUtils.toString(fileInputStream, 'UTF-8'); persistent digest; if isempty(digest) digest = MessageDigest.getInstance('SHA-256'); end hash = digest.digest(java.lang.String(data).getBytes('UTF-8')); </code></pre> <p>Error Message</p> <pre><code> digest.digest(java.lang.String(data).getBytes('UTF-8')) Java exception occurred: java.lang.NullPointerException at java.security.MessageDigest.update(Unknown Source) at java.security.MessageDigest.digest(Unknown Source) </code></pre>
0debug
import URL from row in csv for beautifulsoup : <p>I am looking to import the URL from rows in file.csv so beautiful soup can parse the XML, but I have no idea how to make the following occur. </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>url = row in 'file.csv' soup = BeautifulSoup(urllib2.urlopen('url').read() letters = soup.select('h1') print letters</code></pre> </div> </div> </p>
0debug
Get URL from intranet link name using vba : I am new...I has been searching answers but still cant find it. Looking forward this forum can help me...every month we downloaded over-time form from intranet by clicking a link...So i want to make a vba to get the URL from one of the link name in site. The attach image is the example...i want to get the URL encircled in red and paste into excel (filename otform.xlsm cell A1)..really need help...thanks [enter image description here][1] [1]: http://i.stack.imgur.com/DL3o0.jpg
0debug
static void control_out(VirtIODevice *vdev, VirtQueue *vq) { VirtQueueElement elem; VirtIOSerial *vser; uint8_t *buf; size_t len; vser = VIRTIO_SERIAL(vdev); len = 0; buf = NULL; while (virtqueue_pop(vq, &elem)) { size_t cur_len; cur_len = iov_size(elem.out_sg, elem.out_num); if (cur_len > len) { g_free(buf); buf = g_malloc(cur_len); len = cur_len; } iov_to_buf(elem.out_sg, elem.out_num, 0, buf, cur_len); handle_control_message(vser, buf, cur_len); virtqueue_push(vq, &elem, 0); } g_free(buf); virtio_notify(vdev, vq); }
1threat
Bind variable in sql developper with oracle 11g : I have problem when trying to excute a sequence with a before insert trigger CREATE TABLE personne (ID number, nom varchar2(250 char)); CREATE SEQUENCE s_inc_pers START WITH 1 INCREMENT BY 1; CREATE TRIGGER tr_inc_pers ON t1 BEFORE INSERT FOR EACH ROW DECLARE BEGIN select s_inc_pers into :new.t1.ID from DUAL; END.
0debug
What does control input do? : <p>I’m trying to learn vanilla JavaScript using JavaScript30 and on a video I was watching, there was a statement saying document.queryselectorAll(’.controls input’); I’ve tried looking this up, but I cannot find it anywhere. Can anyone tell me what this means?</p>
0debug
How can I run time in C++? : I'm learning C++ and I got this time program question.So what this program has got to do is to get time from user and should display time also it must work like a clock. For example when the user gives 20:13:10 it must work on it like after 60 seconds if the user asks for time it must give 20:14:10, how do I make it count in the background while it asks for user for time, I've made a basic program and can you help how do I make it the way it is asked for? program is down there: //om! god is great, greatest #include <iostream> #include<conio.h> using namespace std; class Time{ int hour, minute, second; public: void SetTime(int hour1=0, int minute1=0, int second1=0){ hour = hour1; minute=minute1; second=second1; cout<<"set time working"; } void display(){ cout<<"hour | minute | second"<<endl; cout<<hour<<" "<<minute<<" "<<second; } }; int main(){ Time time; //char om; int hour1, minute1,second1; cout<<"enter the hour,minute,second: "; cin>>hour1; cin>>minute1; cin>>second1; time.SetTime(hour1,minute1,second1); cout<<"\n The current time?"; time.display(); return 0; }
0debug
static int amr_wb_encode_frame(AVCodecContext *avctx, unsigned char *frame, int buf_size, void *data) { AMRWBContext *s; int size; s = (AMRWBContext*) avctx->priv_data; s->mode=getWBBitrateMode(avctx->bit_rate); size = E_IF_encode(s->state, s->mode, data, frame, s->allow_dtx); return size; }
1threat
How to get multiple static contexts in new CONTEXT API in React v16.6 : <p>Hi I'm trying to access multiple contexts in a component but I got success with only one context value from provider. there are two providers <code>ListContext</code> and `MappingContext. How can I access contexts like this: </p> <pre><code>class TableData extends React.Component { static contextType = ListContext; static contextType = MappingContext; componentDidMount() { const data = this.context // it will have only one context from ListContext } </code></pre> <p>I know I can use multiple providers in render() but I want to access the contexts like above. Any help will be appreciated. </p> <p>Thanks</p>
0debug
Autocapitalization of first letter of edit text not working : i am trying to add edittext with inputtype = textCapWords but it is not working for me . ihave also tried textcapsentences but it is also not working. <EditText android:id="@+id/editText2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/d1" android:textCursorDrawable="@drawable/custom_cursor" android:background="@drawable/text_field_account" android:gravity="left|center_vertical" android:hint="@string/Last_Name" android:inputType="se" android:maxWidth="30dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:singleLine="true" android:text="" android:maxLength="30" android:textColor="@color/black000" android:textColorHint="@color/text_color_hint" android:textSize="@dimen/font_n" />
0debug
void qio_channel_socket_connect_async(QIOChannelSocket *ioc, SocketAddress *addr, QIOTaskFunc callback, gpointer opaque, GDestroyNotify destroy) { QIOTask *task = qio_task_new( OBJECT(ioc), callback, opaque, destroy); SocketAddress *addrCopy; addrCopy = QAPI_CLONE(SocketAddress, addr); trace_qio_channel_socket_connect_async(ioc, addr); qio_task_run_in_thread(task, qio_channel_socket_connect_worker, addrCopy, (GDestroyNotify)qapi_free_SocketAddress); }
1threat
NullPointerException with non-null <key,value> pair in hashtable : <p>I get a null pointer exception with a hashtable 'get' method call. The key is definitely not null. I checked at 'check1'(commented in the code) by prining the value of the variable item. I have valid list of strings. I still get a null pointer exception. What am I doing wrong ? </p> <pre><code> List&lt;String&gt; l= new ArrayList&lt;String&gt;(); //Values added to l; Hashtable&lt;String,int&gt; h=new Hashtable&lt;String,int&gt;(); for(int i=0;i&lt;l.size();i++){ String item= l.get(i); //check1 int value= h.get(item); //exception arises at this point h.put(item,++value); } </code></pre>
0debug
Angular2 dynamic img src : <p>I have the following code:</p> <pre><code>&lt;a routerLink="/dashboard" routerLinkActive="active" #rla="routerLinkActive"&gt; &lt;img src="/assets/navigation/dashboard-icon-active.svg" /&gt; &lt;template [ngIf]="!isSmallSidebar"&gt; Dashboard &lt;/template&gt; &lt;/a&gt; </code></pre> <p>Running my app I see the image displayed correctly. However I want the image to change if the current route is active. So I did:</p> <pre><code>&lt;a routerLink="/dashboard" routerLinkActive="active" #rla="routerLinkActive"&gt; &lt;!-- &lt;img id="re-nav-dashboard-img" src={{ rla.isActive ? './assets/navigation/dashboard-icon-active.svg' : './assets/navigation/dashboard-icon.svg' }} /&gt; --&gt; &lt;template [ngIf]="!isSmallSidebar"&gt; Dashboard &lt;/template&gt; &lt;/a&gt; </code></pre> <p>This on the other hand results in: <a href="https://i.stack.imgur.com/5lQpZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5lQpZ.png" alt="enter image description here"></a></p> <p>What am I doing wrong or is this a bug ?</p>
0debug
void sh_intc_register_sources(struct intc_desc *desc, struct intc_vect *vectors, int nr_vectors, struct intc_group *groups, int nr_groups) { unsigned int i, k; struct intc_source *s; for (i = 0; i < nr_vectors; i++) { struct intc_vect *vect = vectors + i; sh_intc_register_source(desc, vect->enum_id, groups, nr_groups); s = sh_intc_source(desc, vect->enum_id); if (s) s->vect = vect->vect; #ifdef DEBUG_INTC_SOURCES printf("sh_intc: registered source %d -> 0x%04x (%d/%d)\n", vect->enum_id, s->vect, s->enable_count, s->enable_max); #endif } if (groups) { for (i = 0; i < nr_groups; i++) { struct intc_group *gr = groups + i; s = sh_intc_source(desc, gr->enum_id); s->next_enum_id = gr->enum_ids[0]; for (k = 1; k < ARRAY_SIZE(gr->enum_ids); k++) { if (!gr->enum_ids[k]) continue; s = sh_intc_source(desc, gr->enum_ids[k - 1]); s->next_enum_id = gr->enum_ids[k]; } #ifdef DEBUG_INTC_SOURCES printf("sh_intc: registered group %d (%d/%d)\n", gr->enum_id, s->enable_count, s->enable_max); #endif } } }
1threat
Angular2 cast string to JSON : <p>What is the right syntax to cast a string to JSON in Angular2? I tried:</p> <pre><code>var someString; someString.toJSON(); //or someString.toJson(); </code></pre> <p>it says: <code>someString.toJSON is not a function</code></p> <p>I'm lost because it was working with Angular1.</p> <hr> <p>If I try to add an attribute directly on my string (which is formatted like a true JSON):</p> <pre><code>var someString; someString.att = 'test'; </code></pre> <p>it says: <code>TypeError: Cannot create property 'att' on string '...'</code></p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
bool tcg_target_deposit_valid(int ofs, int len) { return (facilities & FACILITY_GEN_INST_EXT) != 0; }
1threat