problem
stringlengths
26
131k
labels
class label
2 classes
static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, ff_asf_guid mediatype, ff_asf_guid subtype, ff_asf_guid formattype, int size) { WtvContext *wtv = s->priv_data; AVIOContext *pb = wtv->pb; if (!ff_guidcmp(subtype, mediasubtype_cpfilters_processed) && !ff_guidcmp(formattype, format_cpfilters_processed)) { ff_asf_guid actual_subtype; ff_asf_guid actual_formattype; if (size < 32) { av_log(s, AV_LOG_WARNING, "format buffer size underflow\n"); avio_skip(pb, size); return NULL; } avio_skip(pb, size - 32); ff_get_guid(pb, &actual_subtype); ff_get_guid(pb, &actual_formattype); avio_seek(pb, -size, SEEK_CUR); st = parse_media_type(s, st, sid, mediatype, actual_subtype, actual_formattype, size - 32); avio_skip(pb, 32); return st; } else if (!ff_guidcmp(mediatype, mediatype_audio)) { st = new_stream(s, st, sid, AVMEDIA_TYPE_AUDIO); if (!st) return NULL; if (!ff_guidcmp(formattype, format_waveformatex)) { ff_get_wav_header(pb, st->codec, size); } else { if (ff_guidcmp(formattype, format_none)) av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype)); avio_skip(pb, size); } if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) { st->codec->codec_id = ff_wav_codec_get_id(AV_RL32(subtype), st->codec->bits_per_coded_sample); } else if (!ff_guidcmp(subtype, mediasubtype_mpeg1payload)) { if (st->codec->extradata && st->codec->extradata_size >= 22) parse_mpeg1waveformatex(st); else av_log(s, AV_LOG_WARNING, "MPEG1WAVEFORMATEX underflow\n"); } else { st->codec->codec_id = ff_codec_guid_get_id(audio_guids, subtype); if (st->codec->codec_id == CODEC_ID_NONE) av_log(s, AV_LOG_WARNING, "unknown subtype:"PRI_GUID"\n", ARG_GUID(subtype)); } return st; } else if (!ff_guidcmp(mediatype, mediatype_video)) { st = new_stream(s, st, sid, AVMEDIA_TYPE_VIDEO); if (!st) return NULL; if (!ff_guidcmp(formattype, format_videoinfo2)) { int consumed = parse_videoinfoheader2(s, st); avio_skip(pb, FFMAX(size - consumed, 0)); } else if (!ff_guidcmp(formattype, format_mpeg2_video)) { int consumed = parse_videoinfoheader2(s, st); avio_skip(pb, FFMAX(size - consumed, 0)); } else { if (ff_guidcmp(formattype, format_none)) av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype)); avio_skip(pb, size); } if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) { st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(subtype)); } else { st->codec->codec_id = ff_codec_guid_get_id(video_guids, subtype); } if (st->codec->codec_id == CODEC_ID_NONE) av_log(s, AV_LOG_WARNING, "unknown subtype:"PRI_GUID"\n", ARG_GUID(subtype)); return st; } else if (!ff_guidcmp(mediatype, mediatype_mpeg2_pes) && !ff_guidcmp(subtype, mediasubtype_dvb_subtitle)) { st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE); if (!st) return NULL; if (ff_guidcmp(formattype, format_none)) av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype)); avio_skip(pb, size); st->codec->codec_id = CODEC_ID_DVB_SUBTITLE; return st; } else if (!ff_guidcmp(mediatype, mediatype_mstvcaption) && (!ff_guidcmp(subtype, mediasubtype_teletext) || !ff_guidcmp(subtype, mediasubtype_dtvccdata))) { st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE); if (!st) return NULL; if (ff_guidcmp(formattype, format_none)) av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype)); avio_skip(pb, size); st->codec->codec_id = CODEC_ID_DVB_TELETEXT; return st; } else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) && !ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) { if (ff_guidcmp(formattype, format_none)) av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype)); avio_skip(pb, size); return NULL; } av_log(s, AV_LOG_WARNING, "unknown media type, mediatype:"PRI_GUID ", subtype:"PRI_GUID", formattype:"PRI_GUID"\n", ARG_GUID(mediatype), ARG_GUID(subtype), ARG_GUID(formattype)); avio_skip(pb, size); return NULL; }
1threat
Regression Problem: How to solve the problem of highly decimal input features : <p>I have the following input data structure:</p> <pre><code> X1 | X2 | X3 | ... | Output (Label) 118.12341 | 118.12300 | 118.12001 | ... | [a value between 0 &amp; 1] e.g. 0.423645 </code></pre> <p>Where I'm using <code>tensorflow</code> in order to solve the regression problem here of predicting the future value of the <code>Output</code> variable. For that i built a feed forward neural network with three hidden layers having <code>relu</code> activation functions and a final output layer with one node of <code>linear activation</code>. This network is trained with back-propagation using <code>adam</code> optimizer.</p> <p>My problem is that after training the network for some thousands of epochs, I realized that this <strong>highly decimal</strong> values in both input features and the output, resulted in predictions near to the second decimal place only, for example:</p> <pre><code>Real value = 0.456751 | Predicted value = 0.452364 </code></pre> <p>However this is not accepted, where i need a precision to the forth decimal place (at least) to accept the value.</p> <p><strong>Q:</strong> Is there any trustworthy technique to solve this problem properly for getting better results (maybe a transformation algorithm)?</p> <p>Thanks in advance.</p>
0debug
How to get sum of array with "for" loop : <p>I'm a total newbie in <code>JavaScript</code>. I'm trying to learn it using programming experience in <code>Python</code>... </p> <p>Let's say there is an array of integers <code>[2,3,4,5]</code>. I want to get sum of all items in it with <code>for</code> loop. In <code>Python</code> this gonna looks like</p> <pre><code>list_sum = 0 for i in [2,3,4,5]: list_sum += i </code></pre> <p>Result is <code>14</code></p> <p>But if I try same in <code>JavaScript</code>:</p> <pre><code>var listSum = 0; for (i in [2,3,4,5]) { listSum += i; } </code></pre> <p>This will return <code>00123</code>. Seems that item indexes concatenated in a string with initial <code>listSum</code> value. How to make code works as intended and to get sum of all array items as integer?</p>
0debug
What are some machine learning algorithms : <p>I'm kinda confused about machine learning is classification in machine learning is algorithm amd is suprivied and unsupervised is algorithms or type of ML? What are some machine learning algorithms? </p>
0debug
Regex vs, versus, vs., v. matching in lines for c# code : >Hi I need to write a regex that matches the word >versus,verse, vs. , v. , v but v should not be jumbled in words @"\b((.*?)" + Regex.Unescape(xz) + @"[.,:/s]?)\b", RegexOptions.IgnoreCase)) >here i ll pass the array and test it
0debug
change the content of py file : <p>I have a python file which contain a dictionary and one more file which importing the file with the dictionary. I need to change the actual value of keys, I mean permanently - not by importing and editing for the code, How can I accomplish that ?</p>
0debug
static TileExcp decode_x1(DisasContext *dc, tilegx_bundle_bits bundle) { unsigned opc = get_Opcode_X1(bundle); unsigned dest = get_Dest_X1(bundle); unsigned srca = get_SrcA_X1(bundle); unsigned ext, srcb; int imm; switch (opc) { case RRR_0_OPCODE_X1: ext = get_RRROpcodeExtension_X1(bundle); srcb = get_SrcB_X1(bundle); switch (ext) { case UNARY_RRR_0_OPCODE_X1: ext = get_UnaryOpcodeExtension_X1(bundle); return gen_rr_opcode(dc, OE(opc, ext, X1), dest, srca); case ST1_RRR_0_OPCODE_X1: return gen_st_opcode(dc, dest, srca, srcb, MO_UB, "st1"); case ST2_RRR_0_OPCODE_X1: return gen_st_opcode(dc, dest, srca, srcb, MO_TEUW, "st2"); case ST4_RRR_0_OPCODE_X1: return gen_st_opcode(dc, dest, srca, srcb, MO_TEUL, "st4"); case STNT1_RRR_0_OPCODE_X1: return gen_st_opcode(dc, dest, srca, srcb, MO_UB, "stnt1"); case STNT2_RRR_0_OPCODE_X1: return gen_st_opcode(dc, dest, srca, srcb, MO_TEUW, "stnt2"); case STNT4_RRR_0_OPCODE_X1: return gen_st_opcode(dc, dest, srca, srcb, MO_TEUL, "stnt4"); case STNT_RRR_0_OPCODE_X1: return gen_st_opcode(dc, dest, srca, srcb, MO_TEQ, "stnt"); case ST_RRR_0_OPCODE_X1: return gen_st_opcode(dc, dest, srca, srcb, MO_TEQ, "st"); } return gen_rrr_opcode(dc, OE(opc, ext, X1), dest, srca, srcb); case SHIFT_OPCODE_X1: ext = get_ShiftOpcodeExtension_X1(bundle); imm = get_ShAmt_X1(bundle); return gen_rri_opcode(dc, OE(opc, ext, X1), dest, srca, imm); case IMM8_OPCODE_X1: ext = get_Imm8OpcodeExtension_X1(bundle); imm = (int8_t)get_Dest_Imm8_X1(bundle); srcb = get_SrcB_X1(bundle); switch (ext) { case ST1_ADD_IMM8_OPCODE_X1: return gen_st_add_opcode(dc, srca, srcb, imm, MO_UB, "st1_add"); case ST2_ADD_IMM8_OPCODE_X1: return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEUW, "st2_add"); case ST4_ADD_IMM8_OPCODE_X1: return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEUL, "st4_add"); case STNT1_ADD_IMM8_OPCODE_X1: return gen_st_add_opcode(dc, srca, srcb, imm, MO_UB, "stnt1_add"); case STNT2_ADD_IMM8_OPCODE_X1: return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEUW, "stnt2_add"); case STNT4_ADD_IMM8_OPCODE_X1: return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEUL, "stnt4_add"); case STNT_ADD_IMM8_OPCODE_X1: return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEQ, "stnt_add"); case ST_ADD_IMM8_OPCODE_X1: return gen_st_add_opcode(dc, srca, srcb, imm, MO_TEQ, "st_add"); case MFSPR_IMM8_OPCODE_X1: return gen_mfspr_x1(dc, dest, get_MF_Imm14_X1(bundle)); case MTSPR_IMM8_OPCODE_X1: return gen_mtspr_x1(dc, get_MT_Imm14_X1(bundle), srca); } imm = (int8_t)get_Imm8_X1(bundle); return gen_rri_opcode(dc, OE(opc, ext, X1), dest, srca, imm); case BRANCH_OPCODE_X1: ext = get_BrType_X1(bundle); imm = sextract32(get_BrOff_X1(bundle), 0, 17); return gen_branch_opcode_x1(dc, ext, srca, imm); case JUMP_OPCODE_X1: ext = get_JumpOpcodeExtension_X1(bundle); imm = sextract32(get_JumpOff_X1(bundle), 0, 27); return gen_jump_opcode_x1(dc, ext, imm); case ADDLI_OPCODE_X1: case SHL16INSLI_OPCODE_X1: case ADDXLI_OPCODE_X1: imm = (int16_t)get_Imm16_X1(bundle); return gen_rri_opcode(dc, OE(opc, 0, X1), dest, srca, imm); default: return TILEGX_EXCP_OPCODE_UNIMPLEMENTED; } }
1threat
static int audio_decode_frame(VideoState *is, uint8_t *audio_buf, double *pts_ptr) { AVPacket *pkt = &is->audio_pkt; int n, len1, data_size; double pts; for(;;) { while (is->audio_pkt_size > 0) { len1 = avcodec_decode_audio(&is->audio_st->codec, (int16_t *)audio_buf, &data_size, is->audio_pkt_data, is->audio_pkt_size); if (len1 < 0) { is->audio_pkt_size = 0; break; } is->audio_pkt_data += len1; is->audio_pkt_size -= len1; if (data_size <= 0) continue; pts = is->audio_clock; *pts_ptr = pts; n = 2 * is->audio_st->codec.channels; printf("%f %d %d %d\n", is->audio_clock, is->audio_st->codec.channels, data_size, is->audio_st->codec.sample_rate); is->audio_clock += (double)data_size / (double)(n * is->audio_st->codec.sample_rate); #if defined(DEBUG_SYNC) { static double last_clock; printf("audio: delay=%0.3f clock=%0.3f pts=%0.3f\n", is->audio_clock - last_clock, is->audio_clock, pts); last_clock = is->audio_clock; } #endif return data_size; } if (pkt->data) av_free_packet(pkt); if (is->paused || is->audioq.abort_request) { return -1; } if (packet_queue_get(&is->audioq, pkt, 1) < 0) return -1; is->audio_pkt_data = pkt->data; is->audio_pkt_size = pkt->size; if (pkt->pts != AV_NOPTS_VALUE) { is->audio_clock = (double)pkt->pts / AV_TIME_BASE; } } }
1threat
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) { void (*start_frame)(AVFilterLink *, AVFilterBufferRef *); AVFilterPad *dst = &link_dpad(link); FF_DPRINTF_START(NULL, start_frame); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " "); ff_dprintf_ref(NULL, picref, 1); if (!(start_frame = dst->start_frame)) start_frame = avfilter_default_start_frame; if ((dst->min_perms & picref->perms) != dst->min_perms || dst->rej_perms & picref->perms) { av_log(link->dst, AV_LOG_DEBUG, "frame copy needed (have perms %x, need %x, reject %x)\n", picref->perms, link_dpad(link).min_perms, link_dpad(link).rej_perms); link->cur_buf = avfilter_default_get_video_buffer(link, dst->min_perms, link->w, link->h); link->src_buf = picref; avfilter_copy_buffer_ref_props(link->cur_buf, link->src_buf); } else link->cur_buf = picref; start_frame(link, link->cur_buf); }
1threat
?selectableItemBackgroundBorderless not working : <p>I am trying to implement a view which uses the default itemBackground style of Android (but with the oval background, that is used on action bar items etc). Somehow the following view is not showing the background at all. If I change android:background to android:foreground it only shows the rectangle but not the oval. Has anyone an idea how to fix that?</p> <pre><code>&lt;LinearLayout app:visibleGone="@{showProfile}" android:layout_width="wrap_content" android:layout_height="26dp" android:layout_alignParentStart="true" android:gravity="center" android:paddingStart="16dp" android:paddingEnd="16dp"&gt; &lt;ImageView android:background="?selectableItemBackgroundBorderless" android:layout_width="24dp" android:layout_height="24dp" android:onClick="@{() -&gt; profileCallback.onClick()}" android:src="@drawable/profile_image" /&gt; &lt;/LinearLayout&gt; </code></pre>
0debug
static MemoryRegionSection *address_space_lookup_region(AddressSpaceDispatch *d, hwaddr addr, bool resolve_subpage) { MemoryRegionSection *section = atomic_read(&d->mru_section); subpage_t *subpage; bool update; if (section && section != &d->map.sections[PHYS_SECTION_UNASSIGNED] && section_covers_addr(section, addr)) { update = false; } else { section = phys_page_find(d, addr); update = true; } if (resolve_subpage && section->mr->subpage) { subpage = container_of(section->mr, subpage_t, iomem); section = &d->map.sections[subpage->sub_section[SUBPAGE_IDX(addr)]]; } if (update) { atomic_set(&d->mru_section, section); } return section; }
1threat
void ff_aac_search_for_tns(AACEncContext *s, SingleChannelElement *sce) { TemporalNoiseShaping *tns = &sce->tns; int w, g, order, sfb_start, sfb_len, coef_start, shift[MAX_LPC_ORDER], count = 0; const int is8 = sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE; const int tns_max_order = is8 ? 7 : s->profile == FF_PROFILE_AAC_LOW ? 12 : TNS_MAX_ORDER; const float freq_mult = mpeg4audio_sample_rates[s->samplerate_index]/(1024.0f/sce->ics.num_windows)/2.0f; float max_coef = 0.0f; sce->tns.present = 0; return; for (coef_start = 0; coef_start < 1024; coef_start++) max_coef = FFMAX(max_coef, sce->pcoeffs[coef_start]); for (w = 0; w < sce->ics.num_windows; w++) { int filters = 1, start = 0, coef_len = 0; int32_t conv_coeff[1024] = {0}; int32_t coefs_t[MAX_LPC_ORDER][MAX_LPC_ORDER] = {{0}}; for (g = 0; g < sce->ics.num_swb; g++) { if (start*freq_mult > TNS_LOW_LIMIT) { sfb_start = w*16+g; sfb_len = (w+1)*16 + g - sfb_start; coef_start = sce->ics.swb_offset[sfb_start]; coef_len = sce->ics.swb_offset[sfb_start + sfb_len] - coef_start; break; } start += sce->ics.swb_sizes[g]; } if (coef_len <= 0) continue; conv_to_int32(conv_coeff, &sce->pcoeffs[coef_start], coef_len, max_coef); order = ff_lpc_calc_coefs(&s->lpc, conv_coeff, coef_len, TNS_MIN_PRED_ORDER, tns_max_order, 32, coefs_t, shift, FF_LPC_TYPE_LEVINSON, 10, ORDER_METHOD_EST, MAX_LPC_SHIFT, 0) - 1; if (shift[order] > 3) { int direction = 0; float tns_coefs_raw[TNS_MAX_ORDER]; tns->n_filt[w] = filters++; conv_to_float(tns_coefs_raw, coefs_t[order], order); for (g = 0; g < tns->n_filt[w]; g++) { process_tns_coeffs(tns, tns_coefs_raw, order, w, g); apply_tns_filter(&sce->coeffs[coef_start], sce->pcoeffs, order, direction, tns->coef[w][g], sce->ics.ltp.present, w, g, coef_start, coef_len); tns->order[w][g] = order; tns->length[w][g] = sfb_len; tns->direction[w][g] = direction; } count++; } } sce->tns.present = !!count; }
1threat
def median_numbers(a,b,c): if a > b: if a < c: median = a elif b > c: median = b else: median = c else: if a > c: median = a elif b < c: median = b else: median = c return median
0debug
How to do to display "Times New Roman font" in pdf using iTextSharp? : I want to change the font of the content to TIMES NEW roman iTextSharp.text.html.simpleparser.HTMLWorker hw = new iTextSharp.text.html.simpleparser.HTMLWorker(textSharpDocument); #pragma warning restore 612, 618 String[] content = letterContent.Split(new string[] { AppUtil.GetAppSettings(AppConfigKey.ReceiptLetterPDFSeparator) }, StringSplitOptions.None); //Add Content to File if (content.Length > AppConstants.DEFAULT_PARAMETER_ZERO) { string imageFolderPath = AppUtil.GetAppSettings(AppConfigKey.UploadedImageFolderPath); for (int counter = 0; counter < content.Length - 1; counter++) { textSharpDocument.Add(new Paragraph()); if (!String.IsNullOrEmpty(imageUrlList[counter])) { string imageURL = imageFolderPath + imageUrlList[counter]; textSharpDocument.Add(new Paragraph()); string imagePath = AppUtil.GetAppSettings(AppConfigKey.ParticipantCommunicationFilePhysicalPath) + imageUrlList[counter]; imagePath = imagePath.Replace(@"\", "/"); if (File.Exists(imagePath)) { iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance(imageURL); imageLocationIDs[counter] = imageLocationIDs[counter] != null ? AppUtil.ConvertToInt(imageLocationIDs[counter], AppConstants.DEFAULT_PARAMETER_ONE) : AppUtil.ConvertEnumToInt(AppImageLocation.Left); if (imageLocationIDs[counter] == AppUtil.ConvertEnumToInt(AppImageLocation.Left)) png.Alignment = iTextSharp.text.Image.ALIGN_LEFT; if (imageLocationIDs[counter] == AppUtil.ConvertEnumToInt(AppImageLocation.Right)) png.Alignment = iTextSharp.text.Image.ALIGN_RIGHT; if (imageLocationIDs[counter] == AppUtil.ConvertEnumToInt(AppImageLocation.Center)) png.Alignment = iTextSharp.text.Image.ALIGN_CENTER; textSharpDocument.Add(png); } } hw.Parse(new StringReader(content[counter])); hw.EndElement("</html>"); hw.Parse(new StringReader(AppUtil.GetAppSettings(AppConfigKey.ReceiptLetterPDFSeparator))); } }
0debug
Write a program to read m and n from keyboard and list all possible combinations to get the score m-n : i am new on stack overflow This task is from my lab assignment and i am lost i cant find algorithm please help me out . Thanks Consider the final score of a football match is m-n where m and n are non-negative integers. Write a c++ program to read m and n from keyboard and list all possible combinations to get the score m-n. Example outputs: input m : 1 input n : 0 Possible combinations: 0-0, 1-0 input m : 4 input n : 0 Possible combinations: 0-0, 1-0, 2-0, 3-0, 4-0 input m : 1 input n : 1 Possible combinations: 0-0, 1-0, 1-1 0-0, 0-1, 1-1 input m : 2 input n : 1 Possible combinations: 0-0, 1-0, 2-0, 2-1 0-0, 1-0, 1-1, 2-1 0-0, 0-1, 1-1, 2-1 input m : 2 input n : 2 Possible combinations: 0-0, 1-0, 1-1, 2-1, 2-2 0-0, 1-0, 1-1, 1-2, 2-2 0-0, 1-0, 2-0, 2-1, 2-2 0-0, 0-1, 1-1, 1-2, 2-2 0-0, 0-1, 1-1, 2-1, 2-2 0-0, 0-1, 0-2, 1-2, 2-2 this is the code that i have tried when user enters m=2 and n=1 this code prints only two combinations like 0-0, 1-0, 2-0, 2-1 0-0, 0-1, 1-1, 2-1 { int m, n; cout<<"Enter the finals scores of both teams"; cout<<"\nenter the score for team m :"; cin>>m; cout<<"Enter the score for team n :"; cin>>n; if (m < 0 && n < 0){ cout<<"score can't be negative"; cout<<"\nenter the score for team m :"; cin>>m; cout<<"Enter the score for team n :"; cin>>n; } else{ int k=0; if (n==0){ for (int j = 0; j <= m; j++){ for (k; k <= n; k+=1){ cout<<j<<"-"<<k<<",\t"; } k--; } } else if(m==1 && n==1){ int i=0; int k=0; for (int j = 0; j <= m; j++){ for (k; k <= n; k+=1){ cout<<j<<"-"<<k<<",\t"; } k--; } cout<<endl<<endl; for (int j = 0; j <= n; j++){ for (i; i <= m; i+=1){ cout<<i<<"-"<<j<<",\t"; } i--; } } else { int i=0; int k=0; for (int j = 0; j <= m; j++){ for (k; k <= n; k+=1){ cout<<j<<"-"<<k<<",\t"; } k--; } cout<<endl<<endl; for (int j = 0; j <= n; j++){ for (i; i <= m; i++){ cout<<i<<"-"<<j<<",\t"; } i--; } } } }
0debug
Updating user by UserManager.Update() in ASP.NET Identity 2 : <p>I use <code>ASP.NET Identity 2</code> in an <code>MVC 5</code> project and I want to update <code>Student</code> data by using <code>UserManager.Update()</code> method. However, as I inherit from <code>ApplicationUser</code> class, I need to map <code>Student</code> to <code>ApplicationUser</code> before calling update method. On the other hand, when using the approach that I also used for creating new Student, there is an error due to concurrency as I create a new instance rather than update. As I am bored to solve the problem using <code>AutoMapper</code>, I need a stable fix to solve the problem without <code>AutoMapper</code>. Could you please clarify me how to solve this problem? I pass the <code>StudentViewModel</code> to the Update method in the Controller and then I need to map it to Student and then pass them to the <code>UserManager.Update()</code> method as <code>ApplicationUser</code>. On the other hand I am wondering if I should retrieve and send the password on Controller stage instead of passing to View for security concern? Could you also inform me about this issue (during User Update I do not update password and I have to keep the user's password in the database). Any help would be appreciated.</p> <p><strong>Entity Classes:</strong></p> <pre><code>public class ApplicationUser : IdentityUser&lt;int, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim&gt;, IUser&lt;int&gt; { public string Name { get; set; } public string Surname { get; set; } //code omitted for brevity } public class Student: ApplicationUser { public int? Number { get; set; } } </code></pre> <p><br/></p> <p><strong>Controller:</strong></p> <pre><code>[HttpPost] [ValidateAntiForgeryToken] public JsonResult Update([Bind(Exclude = null)] StudentViewModel model) { if (ModelState.IsValid) { ApplicationUser user = UserManager.FindById(model.Id); user = new Student { Name = model.Name, Surname = model.Surname, UserName = model.UserName, Email = model.Email, PhoneNumber = model.PhoneNumber, Number = model.Number, //custom property PasswordHash = checkUser.PasswordHash }; UserManager.Update(user); } } </code></pre>
0debug
Python: Check if string and its substring are existing in the same list : <p>I've extracted keywords based on 1-gram, 2-gram, 3-gram within a tokenized sentence</p> <pre><code>list_of_keywords = [] for i in range(0, len(stemmed_words)): temp = [] for j in range(0, len(stemmed_words[i])): temp.append([' '.join(x) for x in list(everygrams(stemmed_words[i][j], 1, 3)) if ' '.join(x) in set(New_vocabulary_list)]) list_of_keywords.append(temp) </code></pre> <p>I've obtained keywords list as </p> <pre><code>['blood', 'pressure', 'high blood', 'blood pressure', 'high blood pressure'] ['sleep', 'anxiety', 'lack of sleep'] </code></pre> <p>How can I simply the results by removing all substring within the list and remain:</p> <pre><code>['high blood pressure'] ['anxiety', 'lack of sleep'] </code></pre>
0debug
Query which return different results when executed on Oracle and PostgreSQL database : <p>Is there any (Sql, transactional or any other) query (or sequence of queries) which can execute on both Oracle and PostgreSQL database (containing same data), but will return different results?</p>
0debug
Relative links/partial routes with routerLink : <p>In my app some URLs take the form</p> <pre><code>/department/:dep/employee/:emp/contacts </code></pre> <p>In my sidebar I show a list of all employees, each of which has a <code>[routerLink]</code> which links to that employee's contacts</p> <pre><code>&lt;ul&gt; &lt;li&gt; &lt;a [routerLink]="['/department', 1, 'employee', 1, 'contacts']"&gt;&lt;/a&gt; &lt;li&gt; &lt;li&gt; &lt;a [routerLink]="['/department', 1, 'employee', 2, 'contacts']"&gt;&lt;/a&gt; &lt;li&gt; ... &lt;/ul&gt; </code></pre> <p>However, with this approach I always need to provide the full path, including all the params (like <code>dep</code> in the above example) which is quite cumbersome. Is there a way to provide just part of the route, such as</p> <pre><code>&lt;a [routerLink]="['employee', 2, 'contacts']"&gt;&lt;/a&gt; </code></pre> <p>(without the <code>department</code> part, because I don't really care about <code>department</code> in that view and my feeling is that this goes against separation of concerns anyway)?</p>
0debug
Easy way to find un-parented stories : <p>I had been adding a lot of stories these days to a VSTS project. Some of them have parent Features. Is there a way to list all stories with their parents and thus find out which all are unparented.</p> <p>Right now, I have to open each story and find it out myself on whether its parented or not.</p>
0debug
Python: understanding class and instance variables : <p>I think I have some misconception about class and instance variables. Here is an example code:</p> <pre><code>class Animal(object): energy = 10 skills = [] def work(self): print 'I do something' self.energy -= 1 def new_skill(self, skill): self.skills.append(skill) if __name__ == '__main__': a1 = Animal() a2 = Animal() a1.work() print a1.energy # result:9 print a2.energy # result:10 a1.new_skill('bark') a2.new_skill('sleep') print a1.skills # result:['bark', 'sleep'] print a2.skills # result:['bark', 'sleep'] </code></pre> <p>I thought that <code>energy</code> and <code>skill</code> were class variables, because I declared them out of any method. I modify its values inside the methods in the same way (with <code>self</code> in his declaration, maybe incorrect?). But the results show me that <code>energy</code> takes different values for each object (like a instance variable), while <code>skills</code> seems to be shared (like a class variable). I think I've missed something important...</p>
0debug
static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size) { put_flush_packet(bc); nut->last_packet_start= nut->packet_start; nut->packet_start+= nut->written_packet_size; nut->packet_size_pos = url_ftell(bc); nut->written_packet_size = max_size; put_v(bc, nut->written_packet_size); put_v(bc, nut->packet_start - nut->last_packet_start); return 0; }
1threat
I have difficulties writing code for this assignment for if/else statement. This is first programming class. : Write a program that calculates the areas of 2 triangles. Ask the user for the base and height of each triangle. Print the areas of both triangles. The program should tell the user which triangle has the larger area, or if the areas are the same. ERROR CHECKING: The user should not be allowed to enter a negative number for base or height, so validate the input. This is what I have done so far but, my program does not compile. #include <iostream> using namespace std; int main() { double baseOne, baseTwo, heightOne, heightTwo, areaOne, areaTwo, i1; cout << "Please enter the base and height of first triangle\n"; cin >> baseOne, heightOne; if (baseOne <= 0 && heightOne <= 0) { cout << "Your value is invalid!!\n"; } else { cout << "What is the length of first triangle?\n"; cin >> baseOne, heightOne; areaOne = (baseOne * heightOne) / 2; cout << "Area of the first triangle is" << areaOne << endl; } cout << "What is the base and height of second triangle\n"; cin >> baseTwo, heightTwo; if (baseTwo <= 0 && heightTwo <= 0) { cout << "Your value is invalid!!\n"; } else { cout << "What is the length of first triangle?\n"; cin >> baseTwo, heightTwo; areaTwo = (baseTwo * heightTwo) / 2; cout << "Area of the first triangle is" << areaTwo << endl; } if (areaOne > areaTwo) { cout << "Area One is larger with " << areaOne << "than area two\n"; } else if (areaOne < areaTwo) { cout << "Area Two is larger with" << areaTwo << "than area one\n"; } else areaOne == areaTwo; areaOne = i1; cout << "Magnitude of area one and area two is same with " << i1 <<< endl; system("pause"); return 0; }
0debug
int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) { int ret; sigset_t val; sigset_t *temp = NULL; CPUState *cpu = thread_cpu; TaskState *ts = (TaskState *)cpu->opaque; bool segv_was_blocked = ts->sigsegv_blocked; if (set) { bool has_sigsegv = sigismember(set, SIGSEGV); val = *set; temp = &val; sigdelset(temp, SIGSEGV); switch (how) { case SIG_BLOCK: if (has_sigsegv) { ts->sigsegv_blocked = true; } break; case SIG_UNBLOCK: if (has_sigsegv) { ts->sigsegv_blocked = false; } break; case SIG_SETMASK: ts->sigsegv_blocked = has_sigsegv; break; default: g_assert_not_reached(); } } ret = sigprocmask(how, temp, oldset); if (oldset && segv_was_blocked) { sigaddset(oldset, SIGSEGV); } return ret; }
1threat
Trying to use scanf() to take in multiple variables : <p>So I've decided to add some programming skills to my repertoire, typically i've been an application support analyst with beginner to average SQL coding skills, but in today's climate I know I need to get better at automating simple tasks. So I bought a course in c programming (this is not for college credit, so by asking I'm not cheating). So far it's going quite well, but I've come against a problem, actually I decided to improve upon the challenge given to me and I can't seem to figure it out. Originally I was asked to create a small application that printed out the width, height, perimeter and area of a rectangle, with the width and the height hard-coded. That was simple to figure out. I decided to add an extra challenge and have the end user input the width and height of rectangle, but it's not working like I planned. I'm including my code and as well my output after compiling. I don't really want an answer as I would like to discover the solution myself, but if someone could point me to some documentation that would be much appreciated.</p> <p>CODE:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int main() { double width; double height; double perimeter; double area; char newLine = '\n'; printf("Please enter the width of your rectangle:"); scanf("%f", &amp;width); printf("Please enter the height of your rectangle:"); scanf("%f", &amp;height); perimeter = 2.0 * (height + width); area = (width * height); printf("%c",newLine); printf("The widith of the Rectangle is: %.2f centimeters %c",width, newLine); printf("The height of the rectangle is: %.2f centimeters %c",height, newLine); printf("The permimeter of the rectangle is: %.2f centimeters %c",perimeter, newLine); printf("The area of the rectangle is: %.2f centimeters %c",area, newLine); printf("%c",newLine); return 0; } </code></pre> <p>OUTPUT:</p> <pre><code>[user@localhost.local]$ ./output/rectangle.a Please enter the width of your rectangle:15 Please enter the height of your rectangle:12 The widith of the Rectangle is: 0.00 centimeters The height of the rectangle is: 0.00 centimeters The permimeter of the rectangle is: 0.00 centimeters The area of the rectangle is: 0.00 centimeters </code></pre>
0debug
static void megasas_port_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { megasas_mmio_write(opaque, addr & 0xff, val, size); }
1threat
will encrypted value change in c#? : <p>in C#, if i use some encrypt such as Rfc2898DeriveBytes() to encrypt a string, will the encrypted value always be the same? I know it will produce some random value, but will the random value change?</p>
0debug
Convert escaped characters PHP : <p>I know this is a simple question, but having a hard time finding a simple solution.</p> <p>I have a form on my PHP site that takes in the user message, then sends an email to my client with the message. I want the message sent to my client to be easily readable, without escaped characters \r , \n , \" , etc.</p> <p>For example, the message is currently coming into the email as:</p> <pre><code>test\'s\r\nnew line \r\n\"quote\" </code></pre> <p>What I want it to come in as:</p> <pre><code>test's new line "quote" </code></pre> <p><strong>Current code is:</strong></p> <pre><code>if(isset($_POST['submit']) &amp;&amp; !empty($_POST['email'])){ //Process form $name = $_POST['name']; $name = mysql_prep($name); $email = $_POST['email']; $email = mysql_prep($email); $message = $_POST['message']; $message = mysql_prep($message); $emailto = "client_email1@gmail.com,client_email2@gmail.com"; $subject = "Message from '$name'"; // the message $message = "&lt;html&gt;&lt;body&gt; &lt;h3&gt;Title&lt;/h3&gt; From: $name&lt;br&gt; Email: $email&lt;br&gt;&lt;br&gt; Message:&lt;br&gt; $message&lt;br&gt;&lt;br&gt; &lt;/body&gt;&lt;/html&gt;"; //headers make the mail() work $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($emailto, $subject, $message, $headers); </code></pre>
0debug
int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) { char backing_filename[PATH_MAX]; int back_flags, ret; BlockDriver *back_drv = NULL; Error *local_err = NULL; if (bs->backing_hd != NULL) { QDECREF(options); return 0; } if (options == NULL) { options = qdict_new(); } bs->open_flags &= ~BDRV_O_NO_BACKING; if (qdict_haskey(options, "file.filename")) { backing_filename[0] = '\0'; } else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) { QDECREF(options); return 0; } else { bdrv_get_full_backing_filename(bs, backing_filename, sizeof(backing_filename)); } bs->backing_hd = bdrv_new(""); if (bs->backing_format[0] != '\0') { back_drv = bdrv_find_format(bs->backing_format); } back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT); ret = bdrv_open(bs->backing_hd, *backing_filename ? backing_filename : NULL, options, back_flags, back_drv, &local_err); pstrcpy(bs->backing_file, sizeof(bs->backing_file), bs->backing_hd->file->filename); if (ret < 0) { bdrv_unref(bs->backing_hd); bs->backing_hd = NULL; bs->open_flags |= BDRV_O_NO_BACKING; error_propagate(errp, local_err); return ret; } return 0; }
1threat
C# : Convert Single String to Nested List Array : String value = "**71.08099899999999,24.10229 // 71.08099899999999,24.102665 /// 71.080874,24.10279 // 71.080749,24.102915** "; To Nested Array List List<List<List<int>>> Arr = [ [ [ [71.08099899999999][24.10229] ][ [71.08099899999999][24.102665] ] ][ [ [71.080874][24.10279] ][ [71.080749][24.102915] ] ] ];
0debug
I have to iterate over the famous array and add to favorites people array whose names begin with 'a : i have to pass the values from one array to the orher. With the condition that the name start with "A". ```````````` var favorites = [] var famous = ['alex smith', 'amy whinehouse', 'cameron diaz', 'brad pitt', 'ashton kutcher', 'mark whalberg', 'morgan freeman', 'mila kunis'] for (var i=0; i<famous.length; i++ ) { if(famous[i][0]==="a") { favorites.push((famous[i][0]).unshift()) }} ```````````` The console return me an error.
0debug
when I try to run my program it won't run : I'm very very new to python and I'm I've got this exercise and like the first part of the program was running fine and I must've done something because now when I try to run it will just show => None and and nothing seems to be 'wrong'. and I don't know enough to even figure out what's wrong. def main(): """Gets the job done""" #this program returns the value according to the colour def re_start(): #do the work return read_colour def read_names(): """prompt user for their name and returns in a space-separaded line""" PROMPT_NAMES = input("Enter names: ") users_names = '{}'.format(PROMPT_NAMES) print (users_names) return users_names def read_colour(): """prompt user for a colour letter if invalid colour enter retry""" ALLOWED_COLOURS = ["whero", "kowhai", "kikorangi", "parauri", "kiwikiwi", "karaka", "waiporoporo", "pango"] PROMPT_COLOUR = input("Enter letter colour: ").casefold() if PROMPT_COLOUR in ALLOWED_COLOURS: return read_names() else: print("Invalid colour...") print(*ALLOWED_COLOURS,sep='\n') re_start() main()
0debug
static int parse_presentation_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int64_t pts) { PGSSubContext *ctx = avctx->priv_data; int i, state, ret; const uint8_t *buf_end = buf + buf_size; int w = bytestream_get_be16(&buf); int h = bytestream_get_be16(&buf); uint16_t object_index; ctx->presentation.pts = pts; av_dlog(avctx, "Video Dimensions %dx%d\n", w, h); ret = ff_set_dimensions(avctx, w, h); if (ret < 0) return ret; buf++; ctx->presentation.id_number = bytestream_get_be16(&buf); state = bytestream_get_byte(&buf) >> 6; if (state != 0) { flush_cache(avctx); buf += 1; ctx->presentation.palette_id = bytestream_get_byte(&buf); ctx->presentation.object_count = bytestream_get_byte(&buf); if (ctx->presentation.object_count > MAX_OBJECT_REFS) { av_log(avctx, AV_LOG_ERROR, "Invalid number of presentation objects %d\n", ctx->presentation.object_count); ctx->presentation.object_count = 2; if (avctx->err_recognition & AV_EF_EXPLODE) { for (i = 0; i < ctx->presentation.object_count; i++) { ctx->presentation.objects[i].id = bytestream_get_be16(&buf); ctx->presentation.objects[i].window_id = bytestream_get_byte(&buf); ctx->presentation.objects[i].composition_flag = bytestream_get_byte(&buf); ctx->presentation.objects[i].x = bytestream_get_be16(&buf); ctx->presentation.objects[i].y = bytestream_get_be16(&buf); if (ctx->presentation.objects[i].composition_flag & 0x80) { ctx->presentation.objects[i].crop_x = bytestream_get_be16(&buf); ctx->presentation.objects[i].crop_y = bytestream_get_be16(&buf); ctx->presentation.objects[i].crop_w = bytestream_get_be16(&buf); ctx->presentation.objects[i].crop_h = bytestream_get_be16(&buf); av_dlog(avctx, "Subtitle Placement x=%d, y=%d\n", ctx->presentation.objects[i].x, ctx->presentation.objects[i].y); if (ctx->presentation.objects[i].x > avctx->width || ctx->presentation.objects[i].y > avctx->height) { av_log(avctx, AV_LOG_ERROR, "Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n", ctx->presentation.objects[i].x, ctx->presentation.objects[i].y, avctx->width, avctx->height); ctx->presentation.objects[i].x = 0; ctx->presentation.objects[i].y = 0; if (avctx->err_recognition & AV_EF_EXPLODE) { return 0;
1threat
How to figure out which SIM received SMS in Dual SIM Android Device : <p>I'm working on a project to sync sms received in a Android phone to a online database. I can get sender's number by calling <code>getOriginatingAddress()</code> method. But I can't find any solution to figure out which SIM in my device received the sms.</p> <p>I searched the web about it, but couldn't find a way to figure this out. Is there any way to get SMS receiver's number?</p>
0debug
How to use Scroll on Elasticsearch aggregation? : <p>I am using Elasticsearch 5.3. I am aggregating on some data but the results are far too much to return in a single query. I tried using <code>size = Integer.MAX_VALUE;</code> but even that has proved to be less. In ES search API, there is a method to <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-search-scrolling.html" rel="noreferrer" title="scroll">scroll</a> through the search results. Is there a similar feature to use for the <code>org.elasticsearch.search.aggregations.AggregationBuilders.terms</code> aggregator and how do I use it? Can the search scroll API be used for the aggregators?</p>
0debug
static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value) { struct vmsvga_state_s *s = opaque; switch (s->index) { case SVGA_REG_ID: if (value == SVGA_ID_2 || value == SVGA_ID_1 || value == SVGA_ID_0) s->svgaid = value; break; case SVGA_REG_ENABLE: s->enable = value; s->config &= !!value; s->width = -1; s->height = -1; s->invalidated = 1; s->vga.invalidate(&s->vga); if (s->enable) { s->fb_size = ((s->depth + 7) >> 3) * s->new_width * s->new_height; vga_dirty_log_stop(&s->vga); } else { vga_dirty_log_start(&s->vga); } break; case SVGA_REG_WIDTH: s->new_width = value; s->invalidated = 1; break; case SVGA_REG_HEIGHT: s->new_height = value; s->invalidated = 1; break; case SVGA_REG_DEPTH: case SVGA_REG_BITS_PER_PIXEL: if (value != s->depth) { printf("%s: Bad colour depth: %i bits\n", __FUNCTION__, value); s->config = 0; } break; case SVGA_REG_CONFIG_DONE: if (value) { s->fifo = (uint32_t *) s->fifo_ptr; if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) break; if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) break; if (CMD(max) > SVGA_FIFO_SIZE) break; if (CMD(max) < CMD(min) + 10 * 1024) break; } s->config = !!value; break; case SVGA_REG_SYNC: s->syncing = 1; vmsvga_fifo_run(s); break; case SVGA_REG_GUEST_ID: s->guest = value; #ifdef VERBOSE if (value >= GUEST_OS_BASE && value < GUEST_OS_BASE + ARRAY_SIZE(vmsvga_guest_id)) printf("%s: guest runs %s.\n", __FUNCTION__, vmsvga_guest_id[value - GUEST_OS_BASE]); #endif break; case SVGA_REG_CURSOR_ID: s->cursor.id = value; break; case SVGA_REG_CURSOR_X: s->cursor.x = value; break; case SVGA_REG_CURSOR_Y: s->cursor.y = value; break; case SVGA_REG_CURSOR_ON: s->cursor.on |= (value == SVGA_CURSOR_ON_SHOW); s->cursor.on &= (value != SVGA_CURSOR_ON_HIDE); #ifdef HW_MOUSE_ACCEL if (value <= SVGA_CURSOR_ON_SHOW) { dpy_mouse_set(s->vga.ds, s->cursor.x, s->cursor.y, s->cursor.on); } #endif break; case SVGA_REG_MEM_REGS: case SVGA_REG_NUM_DISPLAYS: case SVGA_REG_PITCHLOCK: case SVGA_PALETTE_BASE ... SVGA_PALETTE_END: break; default: if (s->index >= SVGA_SCRATCH_BASE && s->index < SVGA_SCRATCH_BASE + s->scratch_size) { s->scratch[s->index - SVGA_SCRATCH_BASE] = value; break; } printf("%s: Bad register %02x\n", __FUNCTION__, s->index); } }
1threat
How to add our external js file in react : <p>Can anybody tell me that how we can external js file into our react component,or in our index.html or in body.</p> <p>Provide code if possible</p>
0debug
Why is PEP-801 reserved? : <p>I was scrolling through the PEP index page and noticed that a PEP number was reserved by <code>Warsaw</code> :</p> <pre><code>Reserved PEP Numbers num title owner --- ----- ----- 801 RESERVED Warsaw </code></pre> <p>I looked it up out of curiosity and the only thing I found referencing this was the <a href="https://www.python.org/dev/peps/" rel="noreferrer">PEP index page</a> and <a href="https://mail.python.org/pipermail/python-checkins/2013-October/124775.html" rel="noreferrer">this commit</a> from 2013 which didn't anwser my question</p> <p>In the commit, they explain that it could be for humour reason (like 666 for example) but I Don't see why <code>801</code>. What is that number linked to ?</p>
0debug
mysqli calling same data twice : <p>Can anyone explain a detailed answer as, am not able to found it on stackoverflow</p> <pre><code>&lt;?php error_reporting(E_ALL); ini_set('display_errors', 1); ini_set('log_errors',1); mysqli_report(MYSQLI_REPORT_ALL); $link = mysqli_connect('localhost', 'root', '', 'test') or die(mysqli_connect_error()); $query2 = "Select * from qualifications"; $result=mysqli_query($link,$query2)or die (mysqli_error($link)); ?&gt; &lt;form&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; &lt;select name="short_term_degree" id="short_term_degree" &gt; &lt;option value=""&gt;Select&lt;/option&gt; &lt;?php while ( $d=mysqli_fetch_assoc($result)) { echo "&lt;option value='".$d['qual_id']."'&gt;".$d['qualification']."&lt;/option&gt;"; } ?&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;select name="short_term_course" id="short_term_course" &gt; &lt;option value=""&gt;Select&lt;/option&gt; &lt;?php while ( $d=mysqli_fetch_assoc($result)) { echo "&lt;option value='".$d['qual_id']."'&gt;".$d['qualification']."&lt;/option&gt;"; } ?&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; </code></pre> <p>Result I Got</p> <pre><code>&lt;select name="short_term_degree" id="short_term_course"&gt; &lt;option value=""&gt;Select&lt;/option&gt; &lt;option value="268"&gt;Graduate&lt;/option&gt; &lt;option value="269"&gt;Mtech&lt;/option&gt; &lt;option value="353"&gt;Bachelor of Econimics&lt;/option&gt; &lt;/select&gt; &lt;select name="short_term_course" id="short_term_course"&gt; &lt;option value=""&gt;Select&lt;/option&gt; &lt;/select&gt; </code></pre> <p>The Second Select Box Doesn't show any data What's the reason.</p> <p>why do i require to use again mysqli_query() before while OR mysqli_data_seek($result,0); for getting result in select box</p>
0debug
static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, bool last_stage, ram_addr_t dirty_ram_abs) { int res = 0; if (migration_bitmap_clear_dirty(rs, dirty_ram_abs)) { unsigned long *unsentmap; if (migrate_use_compression() && (rs->ram_bulk_stage || !migrate_use_xbzrle())) { res = ram_save_compressed_page(rs, pss, last_stage); } else { res = ram_save_page(rs, pss, last_stage); } if (res < 0) { return res; } unsentmap = atomic_rcu_read(&rs->ram_bitmap)->unsentmap; if (unsentmap) { clear_bit(dirty_ram_abs >> TARGET_PAGE_BITS, unsentmap); } } return res; }
1threat
ruby on rails jsonb column default value : <p>I have a model ProjectKeyword where I use jsonb datatype in the column <code>:segemnted_data</code></p> <pre><code>class ProjectKeyword &lt; ApplicationRecord belongs_to :project belongs_to :keyword has_many :project_keyword_dimensions has_many :dimensions, through: :project_keyword_dimensions validates :project_id, :keyword_id, presence: true end </code></pre> <p>Migration </p> <pre><code>class AddSegemtnedDataToProjectKeywords &lt; ActiveRecord::Migration[5.0] def change add_column :project_keywords, :segmented_data, :jsonb, default: '{}' add_index :project_keywords, :segmented_data, using: :gin end end </code></pre> <p>My problem is when I create new <code>project_keyword</code> instance the default value of the <code>segmented_data</code> is a string not a hash and I cannot update this field or merge with another hash For example</p> <pre><code>[12] pry(#)&gt; new_pr_keyword = ProjectKeyword.new(project_id: 1671333, keyword_id: 39155) =&gt; #&lt;ProjectKeyword:0x007fd997641090 id: nil, project_id: 1671333, keyword_id: 39155, segmented_data: "{}"&gt; [13] pry(#)&gt; new_pr_keyword.save! =&gt; true [14] pry(#)&gt; new_pr_keyword.segmented_data.update({'new_data' =&gt; 'some_data'}) NoMethodError: undefined method `update' for "{}":String from (pry):14:in `block (3 levels) in &lt;top (required)&gt;' </code></pre> <p>But when I asign <code>hash</code> value to the field <code>segmented_data</code> before update then <code>update</code> method works fine.</p> <p>For example </p> <pre><code>[15] pry(#)&gt; new_pr_keyword.segmented_data = {'new_data' =&gt; 'some_data'} =&gt; {"new_data"=&gt;"some_data"} [16] pry(#)&gt; new_pr_keyword.save! =&gt; true [17] pry(#)&gt; new_pr_keyword.segmented_data.update({'new_data_2' =&gt; 'some_data_2'}) =&gt; {"new_data"=&gt;"some_data", "new_data_2"=&gt;"some_data_2"} [18] pry(#)&gt; new_pr_keyword.save! =&gt; true </code></pre> <p>The question is how to make default value of segmented_data to be a Hash class not a String so method update then will work straight away on this field, after object just was created.</p>
0debug
static int coroutine_fn bdrv_co_writev_em(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov) { return bdrv_co_io_em(bs, sector_num, nb_sectors, iov, true); }
1threat
static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src, uint32_t size) { Hnm4VideoContext *hnm = avctx->priv_data; GetByteContext gb; uint32_t writeoffset = 0, offset; uint8_t tag, count, previous, delta; bytestream2_init(&gb, src, size); while (bytestream2_tell(&gb) < size) { count = bytestream2_peek_byte(&gb) & 0x3F; if (count == 0) { tag = bytestream2_get_byte(&gb) & 0xC0; tag = tag >> 6; if (tag == 0) { writeoffset += bytestream2_get_byte(&gb); } else if (tag == 1) { if (writeoffset + hnm->width >= hnm->width * hnm->height) { av_log(avctx, AV_LOG_ERROR, "writeoffset out of bounds\n"); break; } hnm->current[writeoffset] = bytestream2_get_byte(&gb); hnm->current[writeoffset + hnm->width] = bytestream2_get_byte(&gb); writeoffset++; } else if (tag == 2) { writeoffset += hnm->width; } else if (tag == 3) { break; } if (writeoffset > hnm->width * hnm->height) { av_log(avctx, AV_LOG_ERROR, "writeoffset out of bounds\n"); break; } } else { delta = bytestream2_peek_byte(&gb) & 0x80; previous = bytestream2_peek_byte(&gb) & 0x40; bytestream2_skip(&gb, 1); offset = writeoffset; offset += bytestream2_get_le16(&gb); if (delta) offset -= 0x10000; if (offset + hnm->width + count >= hnm->width * hnm->height) { av_log(avctx, AV_LOG_ERROR, "Attempting to read out of bounds\n"); break; } else if (writeoffset + hnm->width + count >= hnm->width * hnm->height) { av_log(avctx, AV_LOG_ERROR, "Attempting to write out of bounds\n"); break; } if (previous) { while (count > 0) { hnm->current[writeoffset] = hnm->previous[offset]; hnm->current[writeoffset + hnm->width] = hnm->previous[offset + hnm->width]; writeoffset++; offset++; count--; } } else { while (count > 0) { hnm->current[writeoffset] = hnm->current[offset]; hnm->current[writeoffset + hnm->width] = hnm->current[offset + hnm->width]; writeoffset++; offset++; count--; } } } } }
1threat
Please help me, this error my code : @IBAction func signinButton(_ sender: AnyObject) { self.ActivityIndicator.startAnimating() let id = usernameTextField.text; let pwd = passwordTextField.text; if (id!.isEmpty || (pwd!.isEmpty)){ let alert = UIAlertController(title: "Information!", message: "Username and Password is not empety", preferredStyle: UIAlertControllerStyle.alert) alert.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.destructive, handler: nil)) present(alert, animated: true, completion: nil) self.present(alert, animated: true, completion: nil) } } this error : Warning: Attempt to present <UIAlertController:0x1847000> on <phmis.ViewController:0x17db23b0> whose view is not in the window hierarchy! please help me..
0debug
add event to all labels in form : <p>I want to add click,mouseleave and mouseenter event to all labels in the form using code below. But i call the addeventtoalllabels on form_load but it wont add event to labels.</p> <pre><code> public void setColor() { if (clickedLabel != default(Label)) clickedLabel.BackColor = Color.Yellow; //Resetting clicked label because another (or the same) was just clicked. } void addeventtoalllabels() { foreach (Label c in this.Controls.OfType&lt;Label&gt;()) { try { c.Click += (sender, e) =&gt; { setColor(); Label theLabel = (Label)sender; clickedLabel = theLabel; }; c.MouseEnter += (sender, e) =&gt; { Label theLabel = (Label)sender; if (theLabel != clickedLabel) theLabel.BackColor = Color.Red; }; c.MouseLeave += (sender, e) =&gt; { Label theLabel = (Label)sender; if (theLabel != clickedLabel) theLabel.BackColor = Color.Yellow; }; } catch { } } } </code></pre>
0debug
Why no exception when finally has return clause : <p>The code snap is like below: </p> <pre><code>public static void main(String[] args) { System.out.println(echo("jjj")); } public static String echo(String str) { try { int a = 1/0; } catch (Exception e) { throw e; } finally { return str; } } </code></pre> <p>Why can I get the output and no exception occurs?<br> And if I put the return clause out of finally, then exception occurs.<br> How could <code>return</code>(in <code>finally</code>) stop <code>exception</code>?</p>
0debug
How to structure a Django website : <p>After creating reusable Django apps do one make an app that glue them together to create a website? Also is it correct to make each menu item and section an app itself in Django? The source code of <a href="https://www.djangoproject.com/" rel="nofollow">https://www.djangoproject.com/</a> is probably the best example of how to correctly structure Django websites if it is available.</p>
0debug
Low latency (< 2s) live video streaming HTML5 solutions? : <p>With Chrome disabling Flash by default very soon I need to start looking into flash/rtmp html5 replacement solutions.</p> <p>Currently with Flash + RTMP I have a live video stream with &lt; 1-2 second delay.</p> <p>I've experimented with MPEG-DASH which seems to be the new industry standard for streaming but that came up short with 5 second delay being the best I could squeeze from it.</p> <p>For context, I am trying to allow user's to control physical objects they can see on the stream, so anything above a couple of seconds of delay leads to a frustrating experience.</p> <p>Are there any other techniques, or is there really no low latency html5 solutions for live streaming yet?</p>
0debug
Div odd and even : <p>I have a problem that i believe to have a simple fix I just don't know the fix myself.</p> <p>Say i have some divs i.e.</p> <pre><code>&lt;div class="box-1"&gt;&lt;/div&gt; &lt;div class="box-2"&gt;&lt;/div&gt; &lt;div class="box-3"&gt;&lt;/div&gt; &lt;div class="box-4"&gt;&lt;/div&gt; </code></pre> <p>etc.</p> <p>If these boxes need to be alternate colours. I need to create some css which basically does the following:</p> <pre><code>.box-(odd-number) { color:#000; } .box-(even-number) { color:#fff; } </code></pre> <p>Obviously I know the above is not the correct syntax. Could some one point me in the right direction.</p> <p>Thanks</p>
0debug
OpenGL + GLM + C++ damping camera : I have read about the damping. Basically it is smooth camera movement. However, I am not sure how to implement damping using C ++, OpenGL and glm. If any of you could help me with a small sample code, I would greatly appreciate it.
0debug
jQuery.post() and modifying the HTML code of a div asap : I have a very simple line of HTML code: <div id="bio">Something...</div> And then I have some jQuery code. It should be very fast. This is important. I do not want to kill the browser. So, the problem is that I do not which code is the best one, A) or B). I also would like to know are they both 100% cross-browser solutions or not if jQuery/JavaScript is enabled on the browser. Or should I forget both of them and do something else instead? A) $(document).ready(function() { get_bio_data = function() { var bio = 106; jQuery.post("get_bio.php", { bio: bio }).done(function(data) { $('#bio').html(data); setTimeout(get_bio_data, 5000); }); }; setTimeout(get_bio_data, 5000); }); B) $(document).ready(function() { function get_bio_data() { var bio = 106, old_bio = document.getElementById('bio'); jQuery.post("get_bio.php", { bio: bio }).done(function(data) { var new_bio = document.createElement('div'); new_bio.innerHTML = data; new_bio.id = 'bio'; old_bio.parentNode.replaceChild(new_bio, old_bio); old_bio = new_bio; setTimeout(get_bio_data, 5000); }); }; get_bio_data(); });
0debug
how to decode a base64 email with php? : i'm trying to docode my messege with base 64 decode method does anybody know hoe to do it or may be via php funcion??? <?php class Gmail { public function __construct($client) { $this->client = $client; } public function readLabels() { $service = new Google_Service_Gmail($this->client); // Print the labels in the user's account. $user = 'me'; $results = $service->users_labels->listUsersLabels($user); $the_html = ""; if (count($results->getLabels()) == 0) { // print "No labels found.\n"; $the_html .= "<p>No labels found</p>"; } else { // print "Labels:\n"; $the_html .= "<p>labels</p>"; foreach ($results->getLabels() as $label) { // printf("- %s\n", $label->getName()); $the_html .= "<p>" . $label->getName() . "</p>"; } return $the_html; } } /** * Get list of Messages in user's mailbox. * * @param Google_Service_Gmail $service Authorized Gmail API instance. * @param string $userId User's email address. The special value 'me' * can be used to indicate the authenticated user. * @return array Array of Messages. */ public function listMessages() { $service = new Google_Service_Gmail($this->client); // Print the labels in the user's account. $userId = 'me'; $pageToken = null; $messages = array(); $opt_param = array(); $messagesResponse = array(); $i = 0; do { if ($i == 5) break; $i++; try { if ($pageToken) { $opt_param['pageToken'] = $pageToken; } $messagesResponse = $service->users_messages->listUsersMessages($userId, $opt_param); if ($messagesResponse->getMessages()) { $messages = array_merge($messages, $messagesResponse->getMessages()); $pageToken = $messagesResponse->getNextPageToken(); } } catch (Exception $e) { print 'An error occurred: ' . $e->getMessage(); } } while ($pageToken); foreach ($messages as $message) { print 'Message with ID: ' . $message->getId() . '<br/>'; $msg = $service->users_messages->get($userId, $message->getId()); echo "<pre>" . var_export($msg->payload->parts[1]->body->data->base64_decode, true) . "</pre>"; } return $messages; } }
0debug
static void nvram_writeb (void *opaque, target_phys_addr_t addr, uint32_t value) { M48t59State *NVRAM = opaque; m48t59_write(NVRAM, addr, value & 0xff); }
1threat
Is it possible to use multiple catch blocks in user defined exception? : <p>I am just confused whether it is possible to use multiple catch blocks in user defined exceptions </p>
0debug
how do i make this program more detailed and tell me the winning percentages after i played it in? : So far this craps game works in python but i need to add the winning percentage after you played it. Plus, how do i make it where the players response has to be "yes" or "no" in order to run? It will run no matter what.And is there way to replace "break" in this program? <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-css --> import random first_roll = 0 def play(): yesOrno = str(input('Would you like to play? ')) yesOrno = yesOrno[0].lower() while yesOrno == 'y': throw_1 = random.randint(1,6) throw_2 = random.randint(1,6) total = throw_1 + throw_2 if total == (2,12): yesOrno = str(input('You lost! Would you like to play again?')) yesOrno = yesOrno[0].lower() elif total == (7,11): yesOrno == str(input('You won! Would you like to play again?')) yesOrno = yesOrno[0].lower() else: first_roll == total while yesOrno == 'y': throw_1 = random.randint(1,6) throw_2 = random.randint(1,6) finalRoll = throw_1 + throw_2 print('You rolled a',total) if total == 2 or 3 or 7 or 11 or 12: yesOrno = str(input('You lost! Would you like to play again?')) yesOrno = yesOrno[0].lower() break elif total == first_roll: yesOrno = str(input('You won! Would you like to play again?')) yesOrno = yesOrno[0].lower() break else: yesOrno == 'y' print('Thanks for playing!') play() <!-- end snippet -->
0debug
When is --thunder-lock beneficial? : <p>This long, detailed, and entertaining article describes the history and design of <code>--thunder-lock</code>: <a href="http://uwsgi-docs.readthedocs.org/en/latest/articles/SerializingAccept.html" rel="noreferrer">http://uwsgi-docs.readthedocs.org/en/latest/articles/SerializingAccept.html</a></p> <p>But it doesn't help me decide when I need it!</p> <p>When is and isn't <code>--thunder-lock</code> beneficial?</p>
0debug
Find distribution of consecutive zeros : <p>I have a vector, say <code>x</code> which contains only the integer numbers <code>0</code>,<code>1</code> and <code>2</code>. For example;</p> <pre><code>x &lt;- c(0,1,0,2,0,0,1,0,0,1,0,0,0,1,0) </code></pre> <p>From this I would like to extract how many times zero occurs in each "pattern". In this simple example it occurs three times on it own, twice as <code>00</code> and exactly once as <code>000</code>, so I would like to output something like:</p> <pre><code>0 3 00 2 000 1 </code></pre> <p>My actual dataset is quite large (1000-2000 elements in the vector) and at least in theory the maximum number of consecutive zeros is <code>length(x)</code></p>
0debug
static void filter_channel(MLPDecodeContext *m, unsigned int substr, unsigned int channel) { SubStream *s = &m->substream[substr]; int32_t firbuf[MAX_BLOCKSIZE + MAX_FIR_ORDER]; int32_t iirbuf[MAX_BLOCKSIZE + MAX_IIR_ORDER]; FilterParams *fir = &m->channel_params[channel].filter_params[FIR]; FilterParams *iir = &m->channel_params[channel].filter_params[IIR]; unsigned int filter_shift = fir->shift; int32_t mask = MSB_MASK(s->quant_step_size[channel]); int index = MAX_BLOCKSIZE; int i; memcpy(&firbuf[MAX_BLOCKSIZE], &fir->state[0], MAX_FIR_ORDER * sizeof(int32_t)); memcpy(&iirbuf[MAX_BLOCKSIZE], &iir->state[0], MAX_IIR_ORDER * sizeof(int32_t)); for (i = 0; i < s->blocksize; i++) { int32_t residual = m->sample_buffer[i + s->blockpos][channel]; unsigned int order; int64_t accum = 0; int32_t result; for (order = 0; order < fir->order; order++) accum += (int64_t)firbuf[index + order] * fir->coeff[order]; for (order = 0; order < iir->order; order++) accum += (int64_t)iirbuf[index + order] * iir->coeff[order]; accum = accum >> filter_shift; result = (accum + residual) & mask; --index; firbuf[index] = result; iirbuf[index] = result - accum; m->sample_buffer[i + s->blockpos][channel] = result; } memcpy(&fir->state[0], &firbuf[index], MAX_FIR_ORDER * sizeof(int32_t)); memcpy(&iir->state[0], &iirbuf[index], MAX_IIR_ORDER * sizeof(int32_t)); }
1threat
How to git cherrypick all changes introduced in specific branch : <p><strong>Background info:</strong> </p> <p>Due to restrictions in workflow with out existing systems, we need to set up a somewhat unorthodox git process. </p> <pre><code>(patch) A-B---F | | (hotfix) C-D-E | (dev) 1-2-3-G </code></pre> <p>On the patch branch, there are some commits. The files here are similar but not identical to the ones on dev (sync scripts switch around the order of settings in many of the files, making them appear changed while they are functionally the same). </p> <p>A fix is needed on this branch so a hotfix branch is created and worked on. This branch is then merged back into patch, so far, so good.</p> <p>This same fix needs to be deployed to the dev branch so it stays relatively in sync with patch, but trying to merge the hotfix branch leads to git trying to merge all the unrelated and 'unchanged' files from A and B as well, rather than only C,D and E.</p> <p><strong>Question:</strong></p> <p>It seems that cherry-pick does what we want in terms of only getting changes from selected commits, but I would really like a way to cherry-pick all commits in a given branch at once, without having to look up the commit ids every time. </p>
0debug
Rails - How to counting down expired date on rails : I am creating Expired of voucher system. (expired:integer) And the expired is counting down from the date it was made until the expired date. E.g : i put 5 days into expired column as a validity period of this voucher. October 1 = 5 days left October 2 = 4 days left October 3 = 3 days left October 4 = 2 days left October 5 = Last day October 6 = Your voucher has expired
0debug
LINQ OrderBy is not sorting correctly : <p>I hope someone can prove me wrong here :)</p> <p>If I do this:</p> <pre><code>List&lt;string&gt; a = new List&lt;string&gt; { "b", "c", "a", "aa" }; var b = a.OrderBy(o =&gt; o).ToList(); </code></pre> <p>I would expect the result of 'b' to be:</p> <pre><code>a aa b c </code></pre> <p>Instead, the result I get is:</p> <pre><code>a b c aa </code></pre> <p>How can I get OrderBy to do a "correct" alphabetical sort? Am I just plain wrong? :)</p>
0debug
static void virtio_notify_vector(VirtIODevice *vdev, uint16_t vector) { BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); if (k->notify) { k->notify(qbus->parent, vector);
1threat
Three joined tables query with many-to-many relationship in JPA : <p>There are three tables: <code>Hospital</code>, <code>Medical_Service</code> and <code>Language_Service</code>, Hospital can provide medical service and language service. So there are two many-to-many relationships.</p> <p><a href="http://i.stack.imgur.com/NCb4e.png" rel="nofollow">ERD Image</a></p> <p>Now I want to search hospitals by three conditions: Postcode, Medical and Language, how can I write this SQL.</p>
0debug
SQL Select query for the mentioned condition : <p>There are two tables <strong>A</strong> and <strong>B</strong>.</p> <p>A has two columns <strong>account_id</strong> and <strong>ad_id</strong>. There are multiple <strong>ad_id</strong> for each <strong>account_i</strong>d. </p> <p>Table B has multiple columns including and ad_id. </p> <p>I need to fetch all the <strong>ad_id</strong> for <strong>account_id=100</strong> then for all these <strong>ad_id</strong> I need to delete the data from <strong>table B</strong></p> <p>I need Help with the SQL query for the same.</p>
0debug
Hi, I'm trying to solve this erorr in orangescrum MissingControllerException : I'm trying add new project but i couldn't do that. error log output: 2017-11-29 08:43:50 Error: [MissingControllerException] Controller class FontsController could not be found. Exception Attributes: array ( 'class' => 'FontsController', 'plugin' => NULL, ) Request URL: /projectmanagement/fonts/RobotoDraft-Medium.woff Stack Trace: #0 /home/itwolfsolutions/public_html/projectmanagement/app/webroot/index.php(92): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse)) #1 {main}
0debug
static void ide_cd_change_cb(void *opaque, bool load) { IDEState *s = opaque; uint64_t nb_sectors; s->tray_open = !load; bdrv_get_geometry(s->bs, &nb_sectors); s->nb_sectors = nb_sectors; s->cdrom_changed = 1; s->events.new_media = true; s->events.eject_request = false; ide_set_irq(s->bus); }
1threat
void *qemu_anon_ram_alloc(size_t size) { void *ptr; ptr = VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); trace_qemu_anon_ram_alloc(size, ptr); return ptr; }
1threat
print() vs debugPrint() in swift : <p>This might be a simple question but because of clear understanding between print() and debug() print in swift I am unable to understand where to use each one. </p>
0debug
golang vnc connexion error - out of memory : i have vnc application wited in go, problem is after same time execution crash, with message out of memory. the complete log is here : https://ghostbin.com/paste/3wpcm the complete code of client.go where exist this error is this : https://ghostbin.com/paste/bgn7s does anyone know why this application is out of memory? my linux machine has 16gb ram memory.
0debug
void backup_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, int64_t speed, MirrorSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap, BlockdevOnError on_source_error, BlockdevOnError on_target_error, BlockCompletionFunc *cb, void *opaque, BlockJobTxn *txn, Error **errp) { int64_t len; BlockDriverInfo bdi; BackupBlockJob *job = NULL; int ret; assert(bs); assert(target); if (bs == target) { error_setg(errp, "Source and target cannot be the same"); return; } if (!bdrv_is_inserted(bs)) { error_setg(errp, "Device is not inserted: %s", bdrv_get_device_name(bs)); return; } if (!bdrv_is_inserted(target)) { error_setg(errp, "Device is not inserted: %s", bdrv_get_device_name(target)); return; } if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp)) { return; } if (bdrv_op_is_blocked(target, BLOCK_OP_TYPE_BACKUP_TARGET, errp)) { return; } if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) { if (!sync_bitmap) { error_setg(errp, "must provide a valid bitmap name for " "\"incremental\" sync mode"); return; } if (bdrv_dirty_bitmap_create_successor(bs, sync_bitmap, errp) < 0) { return; } } else if (sync_bitmap) { error_setg(errp, "a sync_bitmap was provided to backup_run, " "but received an incompatible sync_mode (%s)", MirrorSyncMode_lookup[sync_mode]); return; } len = bdrv_getlength(bs); if (len < 0) { error_setg_errno(errp, -len, "unable to get length for '%s'", bdrv_get_device_name(bs)); goto error; } job = block_job_create(job_id, &backup_job_driver, bs, speed, cb, opaque, errp); if (!job) { goto error; } job->target = blk_new(); blk_insert_bs(job->target, target); job->on_source_error = on_source_error; job->on_target_error = on_target_error; job->sync_mode = sync_mode; job->sync_bitmap = sync_mode == MIRROR_SYNC_MODE_INCREMENTAL ? sync_bitmap : NULL; ret = bdrv_get_info(target, &bdi); if (ret < 0 && !target->backing) { error_setg_errno(errp, -ret, "Couldn't determine the cluster size of the target image, " "which has no backing file"); error_append_hint(errp, "Aborting, since this may create an unusable destination image\n"); goto error; } else if (ret < 0 && target->backing) { job->cluster_size = BACKUP_CLUSTER_SIZE_DEFAULT; } else { job->cluster_size = MAX(BACKUP_CLUSTER_SIZE_DEFAULT, bdi.cluster_size); } bdrv_op_block_all(target, job->common.blocker); job->common.len = len; job->common.co = qemu_coroutine_create(backup_run); block_job_txn_add_job(txn, &job->common); qemu_coroutine_enter(job->common.co, job); return; error: if (sync_bitmap) { bdrv_reclaim_dirty_bitmap(bs, sync_bitmap, NULL); } if (job) { blk_unref(job->target); block_job_unref(&job->common); } }
1threat
How to plot monthly date frequency for single year out of dataframe with more than 10 years of data in R ? : I am a newbie and any help will be greatly appreciated. My dataframe has two columns date and value 2004-10-12 2 my problem is my data is too large ie more than 10 years. How can I plot for monthly frequency for just one year.
0debug
static inline void IRQ_resetbit(IRQ_queue_t *q, int n_IRQ) { q->pending--; reset_bit(q->queue, n_IRQ); }
1threat
C# Using child class methods on an array of objects : <p>I'm sure I'm missing something minor but I can't for the life of me figure it out. I'm trying to use the child class method CalculateInterest for child class SavingsAccount and the child class property TransactionFee for the child class CheckingAccount in the below script. Basically, the test program should loop through each object in the array and depending upon whether the object is a CheckingAccount or SavingsAccount state the interest earned or the transaction fee charged.</p> <p>The error I get is that CalculateInterest() and TransactionFee are not defined in class Account.</p> <pre><code>using System; class BankAccountTester { static void Main() { Account[] accounts = new Account[4]; accounts[0] = new SavingsAccount(25, 3); accounts[1] = new CheckingAccount(80, 1); accounts[2] = new SavingsAccount(200, 1.5); accounts[3] = new CheckingAccount(400, 0.5); for (int i = 0; i &lt; 4; i++) { double amount; string entryString; bool check = false; Console.WriteLine("Enter an amount to withdraw from Account " + i ); entryString = Console.ReadLine(); check = double.TryParse(entryString, out amount); while (check == false) { Console.WriteLine("Invalid entry. Please specify an amount to withdraw from Account " + i); entryString = Console.ReadLine(); check = double.TryParse(entryString, out amount); } accounts[i].Debit(amount); Console.WriteLine("Enter an amount to deposit into Account " + i); entryString = Console.ReadLine(); check = double.TryParse(entryString, out amount); while (check == false) { Console.WriteLine("Invalid entry. Please specify an amount to deposit into Account " + i); entryString = Console.ReadLine(); check = double.TryParse(entryString, out amount); } accounts[i].Credit(amount); if (accounts[i] is SavingsAccount) { Console.WriteLine("This is a savings account."); double interestEarned = accounts[i].CalculateInterest(); Console.WriteLine("Adding {0} interest to Account {2} (Savings Account)", interestEarned, i); } else { Console.WriteLine("This is a checking account."); Console.WriteLine("{0} transaction fee charged.", accounts[i].TransactionFee); } } } } class Account { private double balance; public double Balance { get { return balance; } set { if (value&lt;0) { balance = 0; } else balance = value; } } public Account(double initBalance) { Balance = initBalance; } public void Credit(double amount) { Balance = Balance + amount; } public void Debit(double amount) { if (amount&gt;Balance) { Console.WriteLine("Amount exceeds account balance."); } else Balance = Balance - amount; } } class SavingsAccount : Account { private double interestRate; private double interestEarned; public SavingsAccount(double initBalance, double interest) : base(initBalance) { interestRate = interest/100; } public double CalculateInterest() { interestEarned = Balance*interestRate; return interestEarned; } } class CheckingAccount : Account { private double transactionFee; public double TransactionFee { get { return transactionFee; } set { transactionFee = value; } } public CheckingAccount(double initBalance, double fee) : base(initBalance) { TransactionFee = fee; } public new void Credit(double amount) { Balance = Balance + amount; Balance = Balance - TransactionFee; } public new void Debit(double amount) { bool check; if (amount&gt;Balance) { Console.WriteLine("Amount exceeds account balance."); check = false; } else { Balance = Balance - amount; check = true; } if (check == true) { Balance = Balance - TransactionFee; } else Balance = Balance; } } </code></pre>
0debug
Any way to get JavaScript numbers without Euler's number : <p>I try to get</p> <p><code>Math.pow(2,1000);</code></p> <p>The result is " 1.2676506002282294e+30 "</p> <p>I need the number without Euler's number "e+30"</p>
0debug
How to disply two markdown code blocks side by side : <p>I would like to display two blocks of a source codes side by side -before refactoring and after. Is it possible to create two code blocks side by side? If not then what is the alternative solution?</p>
0debug
void qemu_del_vlan_client(VLANClientState *vc) { if (vc->vlan) { QTAILQ_REMOVE(&vc->vlan->clients, vc, next); } else { if (vc->send_queue) { qemu_del_net_queue(vc->send_queue); } QTAILQ_REMOVE(&non_vlan_clients, vc, next); if (vc->peer) { vc->peer->peer = NULL; } } if (vc->info->cleanup) { vc->info->cleanup(vc); } qemu_free(vc->name); qemu_free(vc->model); qemu_free(vc); }
1threat
static void dnxhd_decode_dct_block_10_444(const DNXHDContext *ctx, RowContext *row, int n) { dnxhd_decode_dct_block(ctx, row, n, 6, 32, 6); }
1threat
webcam LED, hardware or software? : <p>To my knowledge most webcams are equipped with a LED which will turn ON if the webcam is being used.</p> <p>I was wondering if a software can avoid the LED behing activated or if it's built-in electronic.</p> <p>In other terms : If my webcam LED is off does it means 100% nobody is using it ? Remote or local.</p>
0debug
static int set_format(void *obj, const char *name, int fmt, int search_flags, enum AVOptionType type, const char *desc, int nb_fmts) { void *target_obj; const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); int min, max; const AVClass *class = *(AVClass **)obj; if (!o || !target_obj) return AVERROR_OPTION_NOT_FOUND; if (o->type != type) { av_log(obj, AV_LOG_ERROR, "The value set by option '%s' is not a %s format", name, desc); return AVERROR(EINVAL); } #if LIBAVUTIL_VERSION_MAJOR < 54 if (class->version && class->version < AV_VERSION_INT(52, 11, 100)) { min = -1; max = nb_fmts-1; } else #endif { min = FFMIN(o->min, -1); max = FFMAX(o->max, nb_fmts-1); } if (fmt < min || fmt > max) { av_log(obj, AV_LOG_ERROR, "Value %d for parameter '%s' out of %s format range [%d - %d]\n", fmt, name, desc, min, max); return AVERROR(ERANGE); } *(int *)(((uint8_t *)target_obj) + o->offset) = fmt; return 0; }
1threat
CODEIGNITER email : Iam trying to send email using codeigniter is there anyway I can send message in any email for example gmail, yahoo, or outlook .com so, this is what i have: public function sendmail() { $config['protocol'] = 'sendmail'; $config['mailpath'] = '/usr/sbin/sendmail'; $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = TRUE; $this->load->library('email',$config); // load email library $this->email->set_newline ("\r\n"); $this->email->from('user@gmail.com', 'sender name'); $this->email->to('test@gmail.com'); $this->email->subject('Your Subject'); $this->email->message('ed wow sir'); if ($this->email->send()) echo "nasend na!"; else echo $this->email->print_debugger(); } and it shows error : Exit status code: 1 Unable to open a socket to Sendmail. Please check settings. Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.
0debug
void helper_st_asi(target_ulong addr, target_ulong val, int asi, int size) { #ifdef DEBUG_ASI dump_asi("write", addr, asi, size, val); #endif asi &= 0xff; if ((asi < 0x80 && (env->pstate & PS_PRIV) == 0) || ((env->def->features & CPU_FEATURE_HYPV) && asi >= 0x30 && asi < 0x80 && !(env->hpstate & HS_PRIV))) raise_exception(TT_PRIV_ACT); helper_check_align(addr, size - 1); switch (asi) { case 0x0c: case 0x18: case 0x19: case 0x1c: case 0x1d: case 0x88: case 0x89: switch(size) { case 2: val = bswap16(val); break; case 4: val = bswap32(val); break; case 8: val = bswap64(val); break; default: break; } default: break; } switch(asi) { case 0x10: case 0x11: case 0x18: case 0x19: case 0x80: case 0x81: case 0x88: case 0x89: case 0xe2: case 0xe3: if ((asi & 0x80) && (env->pstate & PS_PRIV)) { if ((env->def->features & CPU_FEATURE_HYPV) && env->hpstate & HS_PRIV) { switch(size) { case 1: stb_hypv(addr, val); break; case 2: stw_hypv(addr, val); break; case 4: stl_hypv(addr, val); break; case 8: default: stq_hypv(addr, val); break; } } else { if (asi & 1) { switch(size) { case 1: stb_kernel_secondary(addr, val); break; case 2: stw_kernel_secondary(addr, val); break; case 4: stl_kernel_secondary(addr, val); break; case 8: default: stq_kernel_secondary(addr, val); break; } } else { switch(size) { case 1: stb_kernel(addr, val); break; case 2: stw_kernel(addr, val); break; case 4: stl_kernel(addr, val); break; case 8: default: stq_kernel(addr, val); break; } } } } else { if (asi & 1) { switch(size) { case 1: stb_user_secondary(addr, val); break; case 2: stw_user_secondary(addr, val); break; case 4: stl_user_secondary(addr, val); break; case 8: default: stq_user_secondary(addr, val); break; } } else { switch(size) { case 1: stb_user(addr, val); break; case 2: stw_user(addr, val); break; case 4: stl_user(addr, val); break; case 8: default: stq_user(addr, val); break; } } } break; case 0x14: case 0x15: , non-cacheable case 0x1c: case 0x1d: { switch(size) { case 1: stb_phys(addr, val); break; case 2: stw_phys(addr, val); break; case 4: stl_phys(addr, val); break; case 8: default: stq_phys(addr, val); break; } } return; case 0x24: case 0x2c: LE raise_exception(TT_ILL_INSN); return; case 0x04: case 0x0c: { switch(size) { case 1: stb_nucleus(addr, val); break; case 2: stw_nucleus(addr, val); break; case 4: stl_nucleus(addr, val); break; default: case 8: stq_nucleus(addr, val); break; } break; } case 0x4a: return; case 0x45: { uint64_t oldreg; oldreg = env->lsu; env->lsu = val & (DMMU_E | IMMU_E); if (oldreg != env->lsu) { DPRINTF_MMU("LSU change: 0x%" PRIx64 " -> 0x%" PRIx64 "\n", oldreg, env->lsu); #ifdef DEBUG_MMU dump_mmu(env); #endif tlb_flush(env, 1); } return; } case 0x50: { int reg = (addr >> 3) & 0xf; uint64_t oldreg; oldreg = env->immuregs[reg]; switch(reg) { case 0: return; case 1: case 2: return; case 3: if ((val & 1) == 0) val = 0; env->immu.sfsr = val; break; case 4: return; case 5: DPRINTF_MMU("immu TSB write: 0x%016" PRIx64 " -> 0x%016" PRIx64 "\n", env->immu.tsb, val); env->immu.tsb = val; break; case 6: env->immu.tag_access = val; break; case 7: case 8: return; default: break; } if (oldreg != env->immuregs[reg]) { DPRINTF_MMU("immu change reg[%d]: 0x%016" PRIx64 " -> 0x%016" PRIx64 "\n", reg, oldreg, env->immuregs[reg]); } #ifdef DEBUG_MMU dump_mmu(env); #endif return; } case 0x54: replace_tlb_1bit_lru(env->itlb, env->immu.tag_access, val, "immu", env); return; case 0x55: { unsigned int i = (addr >> 3) & 0x3f; replace_tlb_entry(&env->itlb[i], env->immu.tag_access, val, env); #ifdef DEBUG_MMU DPRINTF_MMU("immu data access replaced entry [%i]\n", i); dump_mmu(env); #endif return; } case 0x57: demap_tlb(env->itlb, addr, "immu", env); return; case 0x58: { int reg = (addr >> 3) & 0xf; uint64_t oldreg; oldreg = env->dmmuregs[reg]; switch(reg) { case 0: case 4: return; case 3: if ((val & 1) == 0) { val = 0; , Fault address env->dmmu.sfar = 0; } env->dmmu.sfsr = val; break; case 1: context env->dmmu.mmu_primary_context = val; break; case 2: context env->dmmu.mmu_secondary_context = val; break; case 5: DPRINTF_MMU("dmmu TSB write: 0x%016" PRIx64 " -> 0x%016" PRIx64 "\n", env->dmmu.tsb, val); env->dmmu.tsb = val; break; case 6: env->dmmu.tag_access = val; break; case 7: case 8: default: env->dmmuregs[reg] = val; break; } if (oldreg != env->dmmuregs[reg]) { DPRINTF_MMU("dmmu change reg[%d]: 0x%016" PRIx64 " -> 0x%016" PRIx64 "\n", reg, oldreg, env->dmmuregs[reg]); } #ifdef DEBUG_MMU dump_mmu(env); #endif return; } case 0x5c: replace_tlb_1bit_lru(env->dtlb, env->dmmu.tag_access, val, "dmmu", env); return; case 0x5d: { unsigned int i = (addr >> 3) & 0x3f; replace_tlb_entry(&env->dtlb[i], env->dmmu.tag_access, val, env); #ifdef DEBUG_MMU DPRINTF_MMU("dmmu data access replaced entry [%i]\n", i); dump_mmu(env); #endif return; } case 0x5f: demap_tlb(env->dtlb, addr, "dmmu", env); return; case 0x49: return; case 0x46: case 0x47: case 0x4b: case 0x4c: case 0x4d: case 0x4e: case 0x66: case 0x67: case 0x6e: case 0x6f: case 0x76: case 0x7e: return; case 0x51: case 0x52: case 0x56: case 0x59: case 0x5a: case 0x5b: case 0x5e: case 0x48: case 0x7f: case 0x82: no-fault, RO case 0x83: no-fault, RO case 0x8a: no-fault LE, RO case 0x8b: no-fault LE, RO default: do_unassigned_access(addr, 1, 0, 1, size); return; } }
1threat
static int qemu_rdma_accept(RDMAContext *rdma) { RDMACapabilities cap; struct rdma_conn_param conn_param = { .responder_resources = 2, .private_data = &cap, .private_data_len = sizeof(cap), }; struct rdma_cm_event *cm_event; struct ibv_context *verbs; int ret = -EINVAL; int idx; ret = rdma_get_cm_event(rdma->channel, &cm_event); if (ret) { goto err_rdma_dest_wait; } if (cm_event->event != RDMA_CM_EVENT_CONNECT_REQUEST) { rdma_ack_cm_event(cm_event); goto err_rdma_dest_wait; } memcpy(&cap, cm_event->param.conn.private_data, sizeof(cap)); network_to_caps(&cap); if (cap.version < 1 || cap.version > RDMA_CONTROL_VERSION_CURRENT) { fprintf(stderr, "Unknown source RDMA version: %d, bailing...\n", cap.version); rdma_ack_cm_event(cm_event); goto err_rdma_dest_wait; } cap.flags &= known_capabilities; if (cap.flags & RDMA_CAPABILITY_PIN_ALL) { rdma->pin_all = true; } rdma->cm_id = cm_event->id; verbs = cm_event->id->verbs; rdma_ack_cm_event(cm_event); DPRINTF("Memory pin all: %s\n", rdma->pin_all ? "enabled" : "disabled"); caps_to_network(&cap); DPRINTF("verbs context after listen: %p\n", verbs); if (!rdma->verbs) { rdma->verbs = verbs; } else if (rdma->verbs != verbs) { fprintf(stderr, "ibv context not matching %p, %p!\n", rdma->verbs, verbs); goto err_rdma_dest_wait; } qemu_rdma_dump_id("dest_init", verbs); ret = qemu_rdma_alloc_pd_cq(rdma); if (ret) { fprintf(stderr, "rdma migration: error allocating pd and cq!\n"); goto err_rdma_dest_wait; } ret = qemu_rdma_alloc_qp(rdma); if (ret) { fprintf(stderr, "rdma migration: error allocating qp!\n"); goto err_rdma_dest_wait; } ret = qemu_rdma_init_ram_blocks(rdma); if (ret) { fprintf(stderr, "rdma migration: error initializing ram blocks!\n"); goto err_rdma_dest_wait; } for (idx = 0; idx < RDMA_WRID_MAX; idx++) { ret = qemu_rdma_reg_control(rdma, idx); if (ret) { fprintf(stderr, "rdma: error registering %d control!\n", idx); goto err_rdma_dest_wait; } } qemu_set_fd_handler2(rdma->channel->fd, NULL, NULL, NULL, NULL); ret = rdma_accept(rdma->cm_id, &conn_param); if (ret) { fprintf(stderr, "rdma_accept returns %d!\n", ret); goto err_rdma_dest_wait; } ret = rdma_get_cm_event(rdma->channel, &cm_event); if (ret) { fprintf(stderr, "rdma_accept get_cm_event failed %d!\n", ret); goto err_rdma_dest_wait; } if (cm_event->event != RDMA_CM_EVENT_ESTABLISHED) { fprintf(stderr, "rdma_accept not event established!\n"); rdma_ack_cm_event(cm_event); goto err_rdma_dest_wait; } rdma_ack_cm_event(cm_event); rdma->connected = true; ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); if (ret) { fprintf(stderr, "rdma migration: error posting second control recv!\n"); goto err_rdma_dest_wait; } qemu_rdma_dump_gid("dest_connect", rdma->cm_id); return 0; err_rdma_dest_wait: rdma->error_state = ret; qemu_rdma_cleanup(rdma); return ret; }
1threat
linux copying a file from a usb to the desktop script : <p>im trying from linux machine to make a script to copying a file from a usb(il attempt to move onto my phone but want the usb first) to the desktop script thanks for looking and any suggestions are helpful </p>
0debug
static void ioreq_finish(struct ioreq *ioreq) { struct XenBlkDev *blkdev = ioreq->blkdev; LIST_REMOVE(ioreq, list); LIST_INSERT_HEAD(&blkdev->finished, ioreq, list); blkdev->requests_inflight--; blkdev->requests_finished++; }
1threat
how to create single page website in laravel 5.6 : <p>I am making a single page website in Laravel 5.6. My site has 7 different sections. I am planning to make a CRUD operation for each section separately for Admin to make changes. However, I am stuck with how to load/Display information stored in different tables in one view(index.blade.php)? I have made multiple page sites in Laravel before but one page site is giving me some confusion. Any suggestions please.</p>
0debug
def triangle_area(r) : if r < 0 : return -1 return r * r
0debug
tsc throws `TS2307: Cannot find module` for a local file : <p>I've got a simple example project using TypeScript: <a href="https://github.com/unindented/ts-webpack-example" rel="noreferrer">https://github.com/unindented/ts-webpack-example</a></p> <p>Running <code>tsc -p .</code> (with <code>tsc</code> version 1.8.10) throws the following:</p> <pre><code>app/index.ts(1,21): error TS2307: Cannot find module 'components/counter'. components/button/index.ts(2,22): error TS2307: Cannot find module 'shared/backbone_base_view'. components/button/index.ts(3,25): error TS2307: Cannot find module 'shared/backbone_with_default_render'. components/counter/index.ts(2,22): error TS2307: Cannot find module 'shared/backbone_base_view'. components/counter/index.ts(3,25): error TS2307: Cannot find module 'shared/backbone_with_default_render'. components/counter/index.ts(4,27): error TS2307: Cannot find module 'shared/backbone_with_subviews'. components/counter/index.ts(5,20): error TS2307: Cannot find module 'components/button'. </code></pre> <p>It complains about all imports of local files, like the following:</p> <pre><code>import Counter from 'components/counter'; </code></pre> <p>If I change it to a relative path it works, but I don't want to, as it makes my life more difficult when moving files around:</p> <pre><code>import Counter from '../components/counter'; </code></pre> <p>The <code>vscode</code> codebase does not use relative paths, but everything works fine for them, so I must be missing something in my project: <a href="https://github.com/Microsoft/vscode/blob/0e81224179fbb8f6fda18ca7362d8500a263cfef/src/vs/languages/typescript/common/typescript.ts#L7-L14" rel="noreferrer">https://github.com/Microsoft/vscode/blob/0e81224179fbb8f6fda18ca7362d8500a263cfef/src/vs/languages/typescript/common/typescript.ts#L7-L14</a></p> <p>You can check out my GitHub repo, but in case it helps here's the <code>tsconfig.json</code> file I'm using:</p> <pre><code>{ "compilerOptions": { "target": "es5", "module": "commonjs", "noImplicitAny": false, "removeComments": false, "preserveConstEnums": true, "sourceMap": true, "outDir": "dist" }, "exclude": [ "dist", "node_modules" ] } </code></pre> <p>Funny thing is, building the project through <code>webpack</code> using <code>ts-loader</code> works fine, so I'm guessing it's just a configuration issue...</p>
0debug
How do i check <p> element is empty using class? #javascript : How do i check if the element is p is empty using class. for e.g. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> n=1 while (n<4) { if (checks if p element class(n) is empty){ //Replaces the p element with variable } else { n++} <!-- end snippet --> <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <p id="working" class="machine1"></p> <p id="working" class="machine2"></p> <p id="working" class="machine3"></p> <!-- end snippet -->
0debug
displaying name and age in same label via JSON : <p>I have been trying to fetch data from JSON to the label of collection view cell. I need to display name and age within a same label and city and distance within a same label just like this.</p> <p><a href="https://i.stack.imgur.com/umPtn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/umPtn.png" alt="enter image description here"></a>. </p> <p>I have already done fetching data but by taking different labels for all the four of them. How can i do the same thing in two different labels.</p>
0debug
HTML/CSS 3 even widthed(is that a word?) background images : <br> im trying to get 3 even background images on my page. They should fit the whole page and should be centered(Only the center should be shown,since the pictures are big.) <br> i did 3 bootstrap col's and tried to put in these pictures. ` <div class="container-fluid"> <div class="row"> <div class="col-xs-4 picture1"> </div> <div class="col-xs-4 picture2"> </div> <div class="col-xs-4 picture3"> </div> </div> </div>`<br> css ` .picture1 {background: url(images/home.jpg) no-repeat center center fixed;} thank you. I honestly have no idea how to do it.`
0debug
Flutter: Where to add listeners in StatelessWidget? : <p>If I were using a StatefulWidget, then I would be listening to a Stream for example inside the initState method. Where would I do the equivalent in a StatelessWidget (like to use Bloc with streams for state management)? I could do it in the build method but since these are repetitively I wondered if there is a more efficient way than checking for existent listeners like below. I know that this is a redundant and useless example but it's just to show the problem.</p> <pre class="lang-dart prettyprint-override"><code> import "package:rxdart/rxdart.dart"; import 'package:flutter/material.dart'; final counter = BehaviorSubject&lt;int&gt;(); final notifier = ValueNotifier&lt;int&gt;(0); void main() =&gt; runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { if (!counter.hasListener) counter.listen((value) =&gt; notifier.value += value); return MaterialApp( home: Scaffold( body: Center( child:FlatButton( onPressed: () =&gt; counter.add(1), child: ValueListenableBuilder( valueListenable: notifier, builder: (context, value, child) =&gt; Text( value.toString() ), ), ) ), ) ); } } </code></pre>
0debug
Outofmeoryerror due to infinite loop because of equals method implementation : I am just trying to understand equals method. I overrode this method in a custom class just to see the behavior but getting out of memory error due to an infinite loop.I know the contract to override equals method 1) Reflexivity 2) Symmetry 3) Transitive 4) Consistent 5) For any null reference, it must return false public class Reflexivity { public static void main(String[] args) { Reflexivity reflexivity = new Reflexivity(); Reflexivity reflexivity1 = new Reflexivity(); System.out.println(reflexivity.equals(reflexivity1)); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Reflexivity)) { return false; } // TODO Auto-generated method stub return this.equals(obj); } }
0debug
What is the watermark heuristic for PubsubIO running on GCD? : <p>Hi I'm trying to run a pipeline where I am calculating diffs between messages that are published to pubsub with 30sec heartbeats* (10K streams, each heartbeating every 30sec). I don't care about 100% data completeness, but I'd like to understand what the watermark heuristic is for PubsubIO (and if I can tweak it), to determine whether I can ignore late data with sufficiently low loss. </p> <p>*Note, the pubsub topic provides [potentially days worth of] persistence in case we have to take down the pipeline so it's important that the heuristic work well with a backlogged subscription. </p> <p>Can someone explain how the watermark is calculated (assuming timestamplabel() is used), and how it can be adjusted, if at all?</p>
0debug
static inline void gen_st32(TCGv val, TCGv addr, int index) { tcg_gen_qemu_st32(val, addr, index); dead_tmp(val); }
1threat
static IOMMUTLBEntry pbm_translate_iommu(MemoryRegion *iommu, hwaddr addr, bool is_write) { IOMMUState *is = container_of(iommu, IOMMUState, iommu); hwaddr baseaddr, offset; uint64_t tte; uint32_t tsbsize; IOMMUTLBEntry ret = { .target_as = &address_space_memory, .iova = 0, .translated_addr = 0, .addr_mask = ~(hwaddr)0, .perm = IOMMU_NONE, }; if (!(is->regs[IOMMU_CTRL >> 3] & IOMMU_CTRL_MMU_EN)) { ret.iova = addr & IOMMU_PAGE_MASK_8K; ret.translated_addr = addr; ret.addr_mask = IOMMU_PAGE_MASK_8K; ret.perm = IOMMU_RW; return ret; } baseaddr = is->regs[IOMMU_BASE >> 3]; tsbsize = (is->regs[IOMMU_CTRL >> 3] >> IOMMU_CTRL_TSB_SHIFT) & 0x7; if (is->regs[IOMMU_CTRL >> 3] & IOMMU_CTRL_TBW_SIZE) { switch (tsbsize) { case 0: offset = (addr & IOMMU_TSB_64K_OFFSET_MASK_64M) >> 13; break; case 1: offset = (addr & IOMMU_TSB_64K_OFFSET_MASK_128M) >> 13; break; case 2: offset = (addr & IOMMU_TSB_64K_OFFSET_MASK_256M) >> 13; break; case 3: offset = (addr & IOMMU_TSB_64K_OFFSET_MASK_512M) >> 13; break; case 4: offset = (addr & IOMMU_TSB_64K_OFFSET_MASK_1G) >> 13; break; case 5: offset = (addr & IOMMU_TSB_64K_OFFSET_MASK_2G) >> 13; break; default: return ret; } } else { switch (tsbsize) { case 0: offset = (addr & IOMMU_TSB_8K_OFFSET_MASK_8M) >> 10; break; case 1: offset = (addr & IOMMU_TSB_8K_OFFSET_MASK_16M) >> 10; break; case 2: offset = (addr & IOMMU_TSB_8K_OFFSET_MASK_32M) >> 10; break; case 3: offset = (addr & IOMMU_TSB_8K_OFFSET_MASK_64M) >> 10; break; case 4: offset = (addr & IOMMU_TSB_8K_OFFSET_MASK_128M) >> 10; break; case 5: offset = (addr & IOMMU_TSB_8K_OFFSET_MASK_256M) >> 10; break; case 6: offset = (addr & IOMMU_TSB_8K_OFFSET_MASK_512M) >> 10; break; case 7: offset = (addr & IOMMU_TSB_8K_OFFSET_MASK_1G) >> 10; break; } } tte = address_space_ldq_be(&address_space_memory, baseaddr + offset, MEMTXATTRS_UNSPECIFIED, NULL); if (!(tte & IOMMU_TTE_DATA_V)) { return ret; } if (tte & IOMMU_TTE_DATA_W) { ret.perm = IOMMU_RW; } else { ret.perm = IOMMU_RO; } if (tte & IOMMU_TTE_DATA_SIZE) { ret.iova = addr & IOMMU_PAGE_MASK_64K; ret.translated_addr = tte & IOMMU_TTE_PHYS_MASK_64K; ret.addr_mask = (IOMMU_PAGE_SIZE_64K - 1); } else { ret.iova = addr & IOMMU_PAGE_MASK_8K; ret.translated_addr = tte & IOMMU_TTE_PHYS_MASK_8K; ret.addr_mask = (IOMMU_PAGE_SIZE_8K - 1); } return ret; }
1threat
How to change page heading in activeadmin : <p>I want to change the titles of page as shown in diagram below. <a href="https://i.stack.imgur.com/pryOB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pryOB.png" alt="enter image description here"></a></p> <p>How can I change that?</p>
0debug
Using a C++ user-defined literal to initialise an array : <p>I have a bunch of test vectors, presented in the form of hexadecimal strings:</p> <pre><code>MSG: 6BC1BEE22E409F96E93D7E117393172A MAC: 070A16B46B4D4144F79BDD9DD04A287C MSG: 6BC1BEE22E409F96E93D7E117393172AAE2D8A57 MAC: 7D85449EA6EA19C823A7BF78837DFADE </code></pre> <p>etc. I need to get these into a C++ program somehow, without too much editing required. There are various options:</p> <ul> <li>Edit the test vectors by hand into the form <code>0x6B,0xC1,0xBE,...</code></li> <li>Edit the test vectors by hand into the form "6BC1BEE22E409F96E93D7E117393172A" and write a function to convert that into a byte array at run time.</li> <li>Write a program to parse the test vectors and output C++ code.</li> </ul> <p>But the one I ended up using was:</p> <ul> <li>User-defined literals,</li> </ul> <p>because fun. I defined a helper class <code>HexByteArray</code> and a user-defined literal operator <code>HexByteArray operator "" _$ (const char* s)</code> that parses a string of the form <code>"0xXX...XX"</code>, where <code>XX...XX</code> is an even number of hex digits. <code>HexByteArray</code> includes conversion operators to <code>const uint8_t*</code> and <code>std::vector&lt;uint8_t&gt;</code>. So now I can write e.g.</p> <pre><code>struct { std::vector&lt;uint8_t&gt; MSG ; uint8_t* MAC ; } Test1 = { 0x6BC1BEE22E409F96E93D7E117393172A_$, 0x070A16B46B4D4144F79BDD9DD04A287C_$ } ; </code></pre> <p>Which works nicely. But now here is my question: Can I do this for arrays as well? For instance:</p> <pre><code>uint8_t MAC[16] = 0x070A16B46B4D4144F79BDD9DD04A287C_$ ; </code></pre> <p>or even</p> <pre><code>uint8_t MAC[] = 0x070A16B46B4D4144F79BDD9DD04A287C_$ ; </code></pre> <p>I can't see how to make this work. To initialise an array, I would seem to need an <code>std::initializer_list</code>. But as far as I can tell, only the compiler can instantiate such a thing. Any ideas?</p> <hr> <p>Here is my code:</p> <p><code>HexByteArray.h</code></p> <pre><code>#include &lt;cstdint&gt; #include &lt;vector&gt; class HexByteArray { public: HexByteArray (const char* s) ; ~HexByteArray() { delete[] a ; } operator const uint8_t*() &amp;&amp; { const uint8_t* t = a ; a = 0 ; return t ; } operator std::vector&lt;uint8_t&gt;() &amp;&amp; { std::vector&lt;uint8_t&gt; v ( a, a + len ) ; a = 0 ; return v ; } class ErrorInvalidPrefix { } ; class ErrorHexDigit { } ; class ErrorOddLength { } ; private: const uint8_t* a = 0 ; size_t len ; } ; inline HexByteArray operator "" _$ (const char* s) { return HexByteArray (s) ; } </code></pre> <p><code>HexByteArray.cpp</code></p> <pre><code>#include "HexByteArray.h" #include &lt;cctype&gt; #include &lt;cstring&gt; HexByteArray::HexByteArray (const char* s) { if (s[0] != '0' || toupper (s[1]) != 'X') throw ErrorInvalidPrefix() ; s += 2 ; // Special case: 0x0_$ is an empty array (because 0x_$ is invalid C++ syntax) if (!strcmp (s, "0")) { a = nullptr ; len = 0 ; } else { for (len = 0 ; s[len] ; len++) if (!isxdigit (s[len])) throw ErrorHexDigit() ; if (len &amp; 1) throw ErrorOddLength() ; len /= 2 ; uint8_t* t = new uint8_t[len] ; for (size_t i = 0 ; i &lt; len ; i++, s += 2) sscanf (s, "%2hhx", &amp;t[i]) ; a = t ; } } </code></pre>
0debug
refactor SELECT WHERE AND OR EXISTS : SELECT * FROM a WHERE a.field=@fieldValue AND ( YEAR(a.myDate)=@y OR EXISTS ( SELECT * FROM b WHERE b.Id=a.Id ) OR EXISTS ( SELECT * FROM c WHERE c.Id=a.Id ) ... ) How can this be rewritten in a simpler way ?
0debug
i already input the id_barang, so could you give me an solution? : <p>SQLSTATE[HY000]: General error: 1400 OCIStmtExecute: ORA-01400: cannot insert NULL into ("PABW2"."BASKET"."ID_BARANG") (ext\pdo_oci\oci_statement.c:159)</p>
0debug
static void id3v2_read_internal(AVIOContext *pb, AVDictionary **metadata, AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta) { int len, ret; uint8_t buf[ID3v2_HEADER_SIZE]; int found_header; int64_t off; do { off = avio_tell(pb); ret = avio_read(pb, buf, ID3v2_HEADER_SIZE); if (ret != ID3v2_HEADER_SIZE) { avio_seek(pb, off, SEEK_SET); break; } found_header = ff_id3v2_match(buf, magic); if (found_header) { len = ((buf[6] & 0x7f) << 21) | ((buf[7] & 0x7f) << 14) | ((buf[8] & 0x7f) << 7) | (buf[9] & 0x7f); id3v2_parse(pb, metadata, s, len, buf[3], buf[5], extra_meta); } else { avio_seek(pb, off, SEEK_SET); } } while (found_header); ff_metadata_conv(metadata, NULL, ff_id3v2_34_metadata_conv); ff_metadata_conv(metadata, NULL, id3v2_2_metadata_conv); ff_metadata_conv(metadata, NULL, ff_id3v2_4_metadata_conv); merge_date(metadata); }
1threat