problem
stringlengths
26
131k
labels
class label
2 classes
How to accept Integers or Strings JAVA : <pre><code> private void CreateAccount() { // TODO Auto-generated method stub String firstName, accountType=""; double initialDesposit = 0; boolean valid = false; int Current = 1; int Saving = 2; while (!valid){ //Only can select current or saving account System.out.println("Enter account Type"); System.out.println("1:Current"); System.out.println("2:Saving"); accountType = keyboard.nextLine(); //User Input of the Account Type if (accountType.equalsIgnoreCase("Current") || accountType.equalsIgnoreCase("Saving")|| accountType.equals(1) || accountType.equals(2) ){ valid = true; //If selection is true }else{ System.out.println("Invalid"); } } </code></pre> <p>I am trying to make it that when user is displayed option they can either choose the option by number or letters i.e. instead of typing "Saving" user can simply just press "2" and it is recorded as Saving. </p>
0debug
static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *buf_end){ unsigned char *frame0_end = s->last_frame.data[0] + s->avctx->width*s->last_frame.linesize[0]; int num_mvs; int num_blocks_raw; int num_blocks_packed; int vector_bits; int i,j,x,y; GetBitContext gb; int mvbits; const unsigned char *blocks_raw; if(buf+12>buf_end) return -1; num_mvs = AV_RL16(&buf[0]); num_blocks_raw = AV_RL16(&buf[2]); num_blocks_packed = AV_RL16(&buf[4]); vector_bits = AV_RL16(&buf[6]); buf += 12; if (num_mvs > s->num_mvs) { s->mv_codebook = av_realloc(s->mv_codebook, num_mvs*2*sizeof(int)); s->num_mvs = num_mvs; } if (num_blocks_packed > s->num_blocks_packed) { s->block_codebook = av_realloc(s->block_codebook, num_blocks_packed*16*sizeof(unsigned char)); s->num_blocks_packed = num_blocks_packed; } mvbits = (num_mvs*2*10+31) & ~31; if (buf+(mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed>buf_end) return -1; init_get_bits(&gb, buf, mvbits); for (i=0; i<num_mvs; i++) { s->mv_codebook[i][0] = get_sbits(&gb, 10); s->mv_codebook[i][1] = get_sbits(&gb, 10); } buf += mvbits>>3; blocks_raw = buf; buf += num_blocks_raw*16; init_get_bits(&gb, buf, (buf_end-buf)<<3); for (i=0; i<num_blocks_packed; i++) { int tmp[4]; for(j=0; j<4; j++) tmp[j] = get_bits(&gb, 8); for(j=0; j<16; j++) s->block_codebook[i][15-j] = tmp[get_bits(&gb, 2)]; } if (get_bits_left(&gb) < vector_bits * (s->avctx->height/4) * (s->avctx->width/4)) return -1; for(y=0; y<s->avctx->height/4; y++) for(x=0; x<s->avctx->width/4; x++) { unsigned int vector = get_bits(&gb, vector_bits); const unsigned char *src; int src_stride; if (vector < num_mvs) { src = s->last_frame.data[0] + (y*4 + s->mv_codebook[vector][1])*s->last_frame.linesize[0] + x*4 + s->mv_codebook[vector][0]; src_stride = s->last_frame.linesize[0]; if (src+3*src_stride+3>=frame0_end) continue; }else{ int offset = vector - num_mvs; if (offset<num_blocks_raw) src = blocks_raw + 16*offset; else if (offset-num_blocks_raw<num_blocks_packed) src = s->block_codebook[offset-num_blocks_raw]; else continue; src_stride = 4; } for(j=0; j<4; j++) for(i=0; i<4; i++) s->frame.data[0][ (y*4+j)*s->frame.linesize[0] + (x*4+i) ] = src[j*src_stride + i]; } return 0; }
1threat
Want to retrieve data from firebase and want to store it in textview object of swift : Heres is my code :- import UIKit import Firebase import FirebaseDatabase class PoliticsNewsViewController: UIViewController{ @IBOutlet weak var Image: UIImageView! @IBOutlet weak var textView: UITextView! var ref:FIRDatabaseReference! override func viewDidLoad() { super.viewDidLoad() //Retrieval and insertion must done here currently create() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func create() { //let date="9 feb 2017" let text="Sidhu joins congress" let aapNews="Arvind kejriwal now in race of wining wining punjab elections as he is gaining 70% seats in punjab" let BJPNews="BJP sufeers major blow in punjab due to demonatization gaining only 40 seats" ref=FIRDatabase.database().reference() ref.child("Politics News Table").childByAutoId().setValue(["Text" : text,"AAP news" : aapNews,"BJP News" : BJPNews]) }
0debug
static int h264_parse(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { H264Context *h = s->priv_data; ParseContext *pc = &h->s.parse_context; int next; if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){ next= buf_size; }else{ next= find_frame_end(h, buf, buf_size); if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) { *poutbuf = NULL; *poutbuf_size = 0; return buf_size; } if(next<0){ find_frame_end(h, &pc->buffer[pc->last_index + next], -next); } } *poutbuf = (uint8_t *)buf; *poutbuf_size = buf_size; return next; }
1threat
Turn off Intellij auto adding to VCS/Git : <p>I've accidentally turned on automatic addition of new files into Git and clicked 'Remember my decision, don't ask again' (or whatever the option actually is) and now I'm unable to change the selection in Preferences |> Version Control |> Confirmation, those options are greyed out. Is there a way to disable this again?</p>
0debug
static inline void gen_intermediate_code_internal(CPUX86State *env, TranslationBlock *tb, int search_pc) { DisasContext dc1, *dc = &dc1; target_ulong pc_ptr; uint16_t *gen_opc_end; CPUBreakpoint *bp; int j, lj; uint64_t flags; target_ulong pc_start; target_ulong cs_base; int num_insns; int max_insns; pc_start = tb->pc; cs_base = tb->cs_base; flags = tb->flags; dc->pe = (flags >> HF_PE_SHIFT) & 1; dc->code32 = (flags >> HF_CS32_SHIFT) & 1; dc->ss32 = (flags >> HF_SS32_SHIFT) & 1; dc->addseg = (flags >> HF_ADDSEG_SHIFT) & 1; dc->f_st = 0; dc->vm86 = (flags >> VM_SHIFT) & 1; dc->cpl = (flags >> HF_CPL_SHIFT) & 3; dc->iopl = (flags >> IOPL_SHIFT) & 3; dc->tf = (flags >> TF_SHIFT) & 1; dc->singlestep_enabled = env->singlestep_enabled; dc->cc_op = CC_OP_DYNAMIC; dc->cs_base = cs_base; dc->tb = tb; dc->popl_esp_hack = 0; dc->mem_index = 0; if (flags & HF_SOFTMMU_MASK) { if (dc->cpl == 3) dc->mem_index = 2 * 4; else dc->mem_index = 1 * 4; } dc->cpuid_features = env->cpuid_features; dc->cpuid_ext_features = env->cpuid_ext_features; dc->cpuid_ext2_features = env->cpuid_ext2_features; dc->cpuid_ext3_features = env->cpuid_ext3_features; #ifdef TARGET_X86_64 dc->lma = (flags >> HF_LMA_SHIFT) & 1; dc->code64 = (flags >> HF_CS64_SHIFT) & 1; #endif dc->flags = flags; dc->jmp_opt = !(dc->tf || env->singlestep_enabled || (flags & HF_INHIBIT_IRQ_MASK) #ifndef CONFIG_SOFTMMU || (flags & HF_SOFTMMU_MASK) #endif ); #if 0 if (!dc->addseg && (dc->vm86 || !dc->pe || !dc->code32)) printf("ERROR addseg\n"); #endif cpu_T[0] = tcg_temp_new(); cpu_T[1] = tcg_temp_new(); cpu_A0 = tcg_temp_new(); cpu_T3 = tcg_temp_new(); cpu_tmp0 = tcg_temp_new(); cpu_tmp1_i64 = tcg_temp_new_i64(); cpu_tmp2_i32 = tcg_temp_new_i32(); cpu_tmp3_i32 = tcg_temp_new_i32(); cpu_tmp4 = tcg_temp_new(); cpu_tmp5 = tcg_temp_new(); cpu_ptr0 = tcg_temp_new_ptr(); cpu_ptr1 = tcg_temp_new_ptr(); gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; pc_ptr = pc_start; lj = -1; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) max_insns = CF_COUNT_MASK; gen_icount_start(); for(;;) { if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == pc_ptr && !((bp->flags & BP_CPU) && (tb->flags & HF_RF_MASK))) { gen_debug(dc, pc_ptr - dc->cs_base); break; } } } if (search_pc) { j = gen_opc_ptr - gen_opc_buf; if (lj < j) { lj++; while (lj < j) gen_opc_instr_start[lj++] = 0; } gen_opc_pc[lj] = pc_ptr; gen_opc_cc_op[lj] = dc->cc_op; gen_opc_instr_start[lj] = 1; gen_opc_icount[lj] = num_insns; } if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) gen_io_start(); pc_ptr = disas_insn(dc, pc_ptr); num_insns++; if (dc->is_jmp) break; if (dc->tf || dc->singlestep_enabled || (flags & HF_INHIBIT_IRQ_MASK)) { gen_jmp_im(pc_ptr - dc->cs_base); gen_eob(dc); break; } if (gen_opc_ptr >= gen_opc_end || (pc_ptr - pc_start) >= (TARGET_PAGE_SIZE - 32) || num_insns >= max_insns) { gen_jmp_im(pc_ptr - dc->cs_base); gen_eob(dc); break; } if (singlestep) { gen_jmp_im(pc_ptr - dc->cs_base); gen_eob(dc); break; } } if (tb->cflags & CF_LAST_IO) gen_io_end(); gen_icount_end(tb, num_insns); *gen_opc_ptr = INDEX_op_end; if (search_pc) { j = gen_opc_ptr - gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; } #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { int disas_flags; qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); #ifdef TARGET_X86_64 if (dc->code64) disas_flags = 2; else #endif disas_flags = !dc->code32; log_target_disas(pc_start, pc_ptr - pc_start, disas_flags); qemu_log("\n"); } #endif if (!search_pc) { tb->size = pc_ptr - pc_start; tb->icount = num_insns; } }
1threat
Combining one webpage section into other webpage : <p>I have downloaded a several nulled website templates for testing purposes. I was wondering if I could combine them into one webpage?</p> <p>For example, take category page layout from one webpage and implement it to other webpage. Is it possible to create webpage using php and html files combined, lets say index.html and contact.php?</p> <p>Thank You in advance.</p>
0debug
How to disable CSRF Token in Laravel and why we have to disable it? : <p>I want to see how I can disable CSRF token in Laravel and where I have to disable it. Is this good to disable it or not?</p>
0debug
av_cold static int lavfi_read_header(AVFormatContext *avctx) { LavfiContext *lavfi = avctx->priv_data; AVFilterInOut *input_links = NULL, *output_links = NULL, *inout; AVFilter *buffersink, *abuffersink; int *pix_fmts = create_all_formats(AV_PIX_FMT_NB); enum AVMediaType type; int ret = 0, i, n; #define FAIL(ERR) { ret = ERR; goto end; } if (!pix_fmts) FAIL(AVERROR(ENOMEM)); avfilter_register_all(); buffersink = avfilter_get_by_name("ffbuffersink"); abuffersink = avfilter_get_by_name("ffabuffersink"); if (lavfi->graph_filename && lavfi->graph_str) { av_log(avctx, AV_LOG_ERROR, "Only one of the graph or graph_file options must be specified\n"); return AVERROR(EINVAL); } if (lavfi->graph_filename) { uint8_t *file_buf, *graph_buf; size_t file_bufsize; ret = av_file_map(lavfi->graph_filename, &file_buf, &file_bufsize, 0, avctx); if (ret < 0) return ret; graph_buf = av_malloc(file_bufsize + 1); if (!graph_buf) { av_file_unmap(file_buf, file_bufsize); return AVERROR(ENOMEM); } memcpy(graph_buf, file_buf, file_bufsize); graph_buf[file_bufsize] = 0; av_file_unmap(file_buf, file_bufsize); lavfi->graph_str = graph_buf; } if (!lavfi->graph_str) lavfi->graph_str = av_strdup(avctx->filename); if (!(lavfi->graph = avfilter_graph_alloc())) FAIL(AVERROR(ENOMEM)); if ((ret = avfilter_graph_parse(lavfi->graph, lavfi->graph_str, &input_links, &output_links, avctx)) < 0) FAIL(ret); if (input_links) { av_log(avctx, AV_LOG_ERROR, "Open inputs in the filtergraph are not acceptable\n"); FAIL(AVERROR(EINVAL)); } for (n = 0, inout = output_links; inout; n++, inout = inout->next); if (!(lavfi->sink_stream_map = av_malloc(sizeof(int) * n))) FAIL(AVERROR(ENOMEM)); if (!(lavfi->sink_eof = av_mallocz(sizeof(int) * n))) FAIL(AVERROR(ENOMEM)); if (!(lavfi->stream_sink_map = av_malloc(sizeof(int) * n))) FAIL(AVERROR(ENOMEM)); for (i = 0; i < n; i++) lavfi->stream_sink_map[i] = -1; for (i = 0, inout = output_links; inout; i++, inout = inout->next) { int stream_idx; if (!strcmp(inout->name, "out")) stream_idx = 0; else if (sscanf(inout->name, "out%d\n", &stream_idx) != 1) { av_log(avctx, AV_LOG_ERROR, "Invalid outpad name '%s'\n", inout->name); FAIL(AVERROR(EINVAL)); } if ((unsigned)stream_idx >= n) { av_log(avctx, AV_LOG_ERROR, "Invalid index was specified in output '%s', " "must be a non-negative value < %d\n", inout->name, n); FAIL(AVERROR(EINVAL)); } type = inout->filter_ctx->output_pads[inout->pad_idx].type; if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) { av_log(avctx, AV_LOG_ERROR, "Output '%s' is not a video or audio output, not yet supported\n", inout->name); FAIL(AVERROR(EINVAL)); } if (lavfi->stream_sink_map[stream_idx] != -1) { av_log(avctx, AV_LOG_ERROR, "An output with stream index %d was already specified\n", stream_idx); FAIL(AVERROR(EINVAL)); } lavfi->sink_stream_map[i] = stream_idx; lavfi->stream_sink_map[stream_idx] = i; } for (i = 0, inout = output_links; inout; i++, inout = inout->next) { AVStream *st; if (!(st = avformat_new_stream(avctx, NULL))) FAIL(AVERROR(ENOMEM)); st->id = i; } lavfi->sinks = av_malloc(sizeof(AVFilterContext *) * avctx->nb_streams); if (!lavfi->sinks) FAIL(AVERROR(ENOMEM)); for (i = 0, inout = output_links; inout; i++, inout = inout->next) { AVFilterContext *sink; type = inout->filter_ctx->output_pads[inout->pad_idx].type; if (type == AVMEDIA_TYPE_VIDEO && ! buffersink || type == AVMEDIA_TYPE_AUDIO && ! abuffersink) { av_log(avctx, AV_LOG_ERROR, "Missing required buffersink filter, aborting.\n"); FAIL(AVERROR_FILTER_NOT_FOUND); } if (type == AVMEDIA_TYPE_VIDEO) { AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc(); buffersink_params->pixel_fmts = pix_fmts; ret = avfilter_graph_create_filter(&sink, buffersink, inout->name, NULL, buffersink_params, lavfi->graph); av_freep(&buffersink_params); if (ret < 0) goto end; } else if (type == AVMEDIA_TYPE_AUDIO) { enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL, -1 }; AVABufferSinkParams *abuffersink_params = av_abuffersink_params_alloc(); abuffersink_params->sample_fmts = sample_fmts; ret = avfilter_graph_create_filter(&sink, abuffersink, inout->name, NULL, abuffersink_params, lavfi->graph); av_free(abuffersink_params); if (ret < 0) goto end; } lavfi->sinks[i] = sink; if ((ret = avfilter_link(inout->filter_ctx, inout->pad_idx, sink, 0)) < 0) FAIL(ret); } if ((ret = avfilter_graph_config(lavfi->graph, avctx)) < 0) FAIL(ret); if (lavfi->dump_graph) { char *dump = avfilter_graph_dump(lavfi->graph, lavfi->dump_graph); fputs(dump, stderr); fflush(stderr); av_free(dump); } for (i = 0; i < avctx->nb_streams; i++) { AVFilterLink *link = lavfi->sinks[lavfi->stream_sink_map[i]]->inputs[0]; AVStream *st = avctx->streams[i]; st->codec->codec_type = link->type; avpriv_set_pts_info(st, 64, link->time_base.num, link->time_base.den); if (link->type == AVMEDIA_TYPE_VIDEO) { st->codec->codec_id = AV_CODEC_ID_RAWVIDEO; st->codec->pix_fmt = link->format; st->codec->time_base = link->time_base; st->codec->width = link->w; st->codec->height = link->h; st ->sample_aspect_ratio = st->codec->sample_aspect_ratio = link->sample_aspect_ratio; } else if (link->type == AVMEDIA_TYPE_AUDIO) { st->codec->codec_id = av_get_pcm_codec(link->format, -1); st->codec->channels = av_get_channel_layout_nb_channels(link->channel_layout); st->codec->sample_fmt = link->format; st->codec->sample_rate = link->sample_rate; st->codec->time_base = link->time_base; st->codec->channel_layout = link->channel_layout; if (st->codec->codec_id == AV_CODEC_ID_NONE) av_log(avctx, AV_LOG_ERROR, "Could not find PCM codec for sample format %s.\n", av_get_sample_fmt_name(link->format)); } } end: av_free(pix_fmts); avfilter_inout_free(&input_links); avfilter_inout_free(&output_links); if (ret < 0) lavfi_read_close(avctx); return ret; }
1threat
java.lang.NullPointerException: Can't pass null for argument 'pathString' in child(); first time to firebase really confused : I dont really know whats wrong here, i am able to add data on the other activity. getting error "java.lang.NullPointerException: Can't pass null for argument 'pathString' in child()" and dont know how to fix. there are 3 other classes created only one other is adding data to firebase realtime database storage package com.example.akshay.katiroll.FirstScreen; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import com.example.akshay.katiroll.R; import com.example.akshay.katiroll.SecondScreen.welcome; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; public class Profile extends AppCompatActivity { EditText fName, lName, PhNo, BDay, Zip; Button svBtn; DatabaseReference mDataReference; String keyUser; String fNameStr, lNameStr, PhNoStr, BDayStr, ZipStr; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); keyUser = getIntent().getStringExtra("USER_KEY"); mDataReference = FirebaseDatabase.getInstance().getReference().child("Users").child(keyUser);//pretty sure something is wrong with this line fName = (EditText) findViewById(R.id.fName); //error in this line lName = (EditText) findViewById(R.id.lName); PhNo = (EditText) findViewById(R.id.phno); BDay = (EditText) findViewById(R.id.bday); Zip = (EditText) findViewById(R.id.zip); svBtn = (Button) findViewById(R.id.svBtn); svBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fNameStr = fName.getText().toString(); lNameStr = lName.getText().toString(); PhNoStr = PhNo.getText().toString(); BDayStr = BDay.getText().toString(); ZipStr = Zip.getText().toString(); if(!TextUtils.isEmpty(fNameStr) && !TextUtils.isEmpty(lNameStr) && !TextUtils.isEmpty(PhNoStr)) { DatabaseReference mDataRef = mDataReference.child("Users").push(); mDataRef.child("firstName").setValue(""+fNameStr); mDataRef.child("lastName").setValue(""+lNameStr); mDataRef.child("phoneNumber").setValue(""+PhNoStr); mDataRef.child("isVerified").setValue("verified"); if(!TextUtils.isEmpty(BDayStr)){ mDataRef.child("birthday").setValue(""+BDayStr); }else{ mDataRef.child("birthday").setValue("null"); } if(!TextUtils.isEmpty(ZipStr)){ mDataRef.child("zipcode").setValue("ZipStr"); }else{ mDataRef.child("zipcode").setValue("null"); } Toast.makeText(Profile.this, "User profile added", Toast.LENGTH_LONG).show(); startActivity(new Intent(Profile.this, welcome.class)); }else{ Toast.makeText(Profile.this, "Failed to create User Account", Toast.LENGTH_LONG).show(); } } }); } } getting error "java.lang.NullPointerException: Can't pass null for argument 'pathString' in child()" and dont know how to fix. there are 3 other classes created only one other is adding data to firebase realtime database storage
0debug
static void spapr_numa_cpu(const void *data) { char *cli; QDict *resp; QList *cpus; const QObject *e; cli = make_cli(data, "-smp 4,cores=4 " "-numa node,nodeid=0 -numa node,nodeid=1 " "-numa cpu,node-id=0,core-id=0 " "-numa cpu,node-id=0,core-id=1 " "-numa cpu,node-id=0,core-id=2 " "-numa cpu,node-id=1,core-id=3"); qtest_start(cli); cpus = get_cpus(&resp); g_assert(cpus); while ((e = qlist_pop(cpus))) { QDict *cpu, *props; int64_t core, node; cpu = qobject_to_qdict(e); g_assert(qdict_haskey(cpu, "props")); props = qdict_get_qdict(cpu, "props"); g_assert(qdict_haskey(props, "node-id")); node = qdict_get_int(props, "node-id"); g_assert(qdict_haskey(props, "core-id")); core = qdict_get_int(props, "core-id"); if (core >= 0 && core < 3) { g_assert_cmpint(node, ==, 0); } else if (core == 3) { g_assert_cmpint(node, ==, 1); } else { g_assert(false); } } QDECREF(resp); qtest_end(); g_free(cli); }
1threat
How to copy from the next row when i run my macro again : I am new to VBA so I am only doing record macro and editing from it. I have some data in a table that is captured from formulas and I need to 'archive' them so that when the source is changed, the data is still there. I recorded a macro to copy the formula in the row to paste it on the next row and copy and paste numbers on the same row so that the data will not changed when the source is changed. But I want the macro to do the same for the following row when I click it the next time, how can i edit my code to do so? Range("B20:K20").Select Selection.Copy Range("B21:K21").Select ActiveSheet.Paste Range("B20:K20").Select Application.CutCopyMode = False Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Instead of copying from row 20, i want the macro to copy from row 21 and paste on row 22 the next time I run the macro. Please help! Thank you!
0debug
static inline void gen_efsneg(DisasContext *ctx) { if (unlikely(!ctx->spe_enabled)) { gen_exception(ctx, POWERPC_EXCP_APU); return; } tcg_gen_xori_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], 0x80000000); }
1threat
Running the Haskell compiled to JavaScript on the JVM : <p>Java 8 has an inbuilt JavaScript engine called Nashorn so it is actually possible to run Haskell compiled to JavaScript on the JVM.</p> <p>The following program works:</p> <pre><code>{-# LANGUAGE JavaScriptFFI #-} module Main where foreign import javascript unsafe "console={log: function(s) { java.lang.System.out.print(s); }}" setupConsole :: IO () foreign import javascript unsafe "java.lang.System.exit($1)" sysexit :: Int -&gt; IO () main = do setupConsole putStrLn "Hello from Haskell!" sysexit 0 </code></pre> <p>We can run it with: (<em>Side note:</em> It is possible to run this as a normal Java program.<code>jjs</code> is just a convenient way to run pure JavaScript code on the JVM)</p> <pre><code>$ ghcjs -o Main Main.hs [1 of 1] Compiling Main ( Main.hs, Main.js_o ) Linking Main.jsexe (Main) $ which jjs ~/bin/jdk/bin/jjs $ jjs Main.jsexe/all.js Hello from Haskell! </code></pre> <p>In the above code, <code>console.log</code> needs to be defined using <code>java.lang.System.print</code> as Nashorn doesn't provide the default global <code>console</code> object and Haskell's <code>putStrLn</code> otherwise doesn't seem to be printing anything.</p> <p>The other thing is that the JVM needs to be exited with <code>sysexit</code> FFI function implemented with <code>java.lang.System.exit</code>. </p> <p>I have 2 questions:</p> <ol> <li>Similar to <code>console.log</code>, what other host dependencies are assumed in ghcjs that have to be defined?</li> <li>Is the JVM not shutting down normally because of ghcjs creating an event loop in the background or some other reason? Is there any way to avoid that and make the program exit normally?</li> </ol>
0debug
static void do_dcbz(CPUPPCState *env, target_ulong addr, int dcache_line_size, uintptr_t raddr) { int i; addr &= ~(dcache_line_size - 1); for (i = 0; i < dcache_line_size; i += 4) { cpu_stl_data_ra(env, addr + i, 0, raddr); } if (env->reserve_addr == addr) { env->reserve_addr = (target_ulong)-1ULL; } }
1threat
Add reference to a .NET Core 2.0 DLL on a Full Framework 4.7 project : <p>I looked for this question in here but I didn't find the answer.</p> <p>I have a Class Library project targeting .NET Core 2.0 and a WPF project targeting .NET Full Framework 4.7. I can't reference the class library on the WPF project. I get the following error:</p> <blockquote> <p>Project 'xxxxxxxx' targets '.NETCoreApp,Version=v2.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.7'.</p> </blockquote> <p>Is there any way to reference a .NET Core project in a Full Framework one?</p>
0debug
python : What's the error here ? output keep on generating try again : output keep on generating "try again" whats the error here ? import random x = int(input("guess a number between 0 and 10: \n")) y = random.randint(0,10) n = "try again" while n == "try again": if y == x: print("congradulations\n") break; else: input("try again\n")
0debug
pandas concat generates nan values : <p>I am curious why a simple concatenation of two data frames in pandas:</p> <pre><code>shape: (66441, 1) dtypes: prediction int64 dtype: object isnull().sum(): prediction 0 dtype: int64 shape: (66441, 1) CUSTOMER_ID int64 dtype: object isnull().sum() CUSTOMER_ID 0 dtype: int64 </code></pre> <p>of the same shape and both without NaN values </p> <pre><code>foo = pd.concat([initId, ypred], join='outer', axis=1) print(foo.shape) print(foo.isnull().sum()) </code></pre> <p>can result in a lot of NaN values if joined.</p> <pre><code>(83384, 2) CUSTOMER_ID 16943 prediction 16943 </code></pre> <h2>How can I fix this problem and prevent NaN values being introduced?</h2> <p>Trying to reproduce it like </p> <pre><code>aaa = pd.DataFrame([0,1,0,1,0,0], columns=['prediction']) print(aaa) bbb = pd.DataFrame([0,0,1,0,1,1], columns=['groundTruth']) print(bbb) pd.concat([aaa, bbb], axis=1) </code></pre> <p>failed e.g. worked just fine as no NaN values were introduced.</p>
0debug
static void filter0(int32_t *dst, const int32_t *src, int32_t coeff, ptrdiff_t len) { int i; for (i = 0; i < len; i++) dst[i] -= mul22(src[i], coeff); }
1threat
How can the code coverage data from Flutter tests be displayed? : <p>I'm working on a Flutter app using Android Studio as my IDE.<br> I'm attempting to write tests and check the code coverage but I can't work out how to view the data in the IDE or any other application.<br> By running <code>flutter test --coverage</code><br> A coverage report seems to be generated into a file <code>/coverage/Icov.info</code><br> That file looks something like this:</p> <pre><code>SF:lib\data\Customer.g.dart DA:9,2 DA:10,2 DA:11,2 DA:12,2 DA:13,2 DA:20,0 DA:21,0 DA:22,0 DA:23,0 DA:24,0 .... </code></pre> <p>Looking at the file it seems to have a list of my project files with line by line coverage data. Is there a way to view this information in Android Studio?</p>
0debug
I can't find what *exactly* the syntax error is in mysql : <p>I am creating a simple database and it's table for learning purpose:</p> <p>This is my php code(script.php)</p> <pre><code>&lt;?php $sql = file_get_contents("init.sql"); $servername = "localhost"; $username = "root"; $password = ""; // connect to database $conn = new mysqli($servername, $username, $password); if ($conn-&gt;connect_error) { die("Connection error: " . $conn-&gt;connect_error); } if($conn-&gt;query($sql) == True){ echo "Database and Table has been created succesfully!"; } else { echo "\nError creating database and table: . $conn-&gt;error"; } ?&gt; </code></pre> <p>And this is mysql file(init.mysql)</p> <pre><code>CREATE DATABASE test; USE test; CREATE TABLE Users ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, email VARCHAR(50), date_of_registration TIMESTAMP) </code></pre> <p>The exact error I am seeing is:-</p> <blockquote> <p>Error creating database and table: . You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USE test; CREATE TABLE Users ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY ' at line 2</p> </blockquote> <p>In my opinion, the code is syntactically correct but as you see I am getting an error So I am struggling to find <em>where</em> is the error but no luck :( Or I am blind enough to see it.</p>
0debug
static void taihu_cpld_writew (void *opaque, hwaddr addr, uint32_t value) { taihu_cpld_writeb(opaque, addr, (value >> 8) & 0xFF); taihu_cpld_writeb(opaque, addr + 1, value & 0xFF); }
1threat
static void mirror_start_job(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, int64_t speed, uint32_t granularity, int64_t buf_size, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, bool unmap, BlockCompletionFunc *cb, void *opaque, Error **errp, const BlockJobDriver *driver, bool is_none_mode, BlockDriverState *base) { MirrorBlockJob *s; if (granularity == 0) { granularity = bdrv_get_default_bitmap_granularity(target); } assert ((granularity & (granularity - 1)) == 0); if (buf_size < 0) { error_setg(errp, "Invalid parameter 'buf-size'"); return; } if (buf_size == 0) { buf_size = DEFAULT_MIRROR_BUF_SIZE; } s = block_job_create(job_id, driver, bs, speed, cb, opaque, errp); if (!s) { return; } s->target = blk_new(); blk_insert_bs(s->target, target); s->replaces = g_strdup(replaces); s->on_source_error = on_source_error; s->on_target_error = on_target_error; s->is_none_mode = is_none_mode; s->backing_mode = backing_mode; s->base = base; s->granularity = granularity; s->buf_size = ROUND_UP(buf_size, granularity); s->unmap = unmap; s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp); if (!s->dirty_bitmap) { g_free(s->replaces); blk_unref(s->target); block_job_unref(&s->common); return; } bdrv_op_block_all(target, s->common.blocker); s->common.co = qemu_coroutine_create(mirror_run, s); trace_mirror_start(bs, s, s->common.co, opaque); qemu_coroutine_enter(s->common.co); }
1threat
Why is output of variable NaN : <p>I wrote simple code like this</p> <pre><code>var value = function(a){return a*3;} var number = value(a); </code></pre> <p>when i type <code>value(5);</code> i will get number 15 thats OK, but after typing <code>number;</code> ill get <code>NaN</code>. I just want to write in variable the result of function.</p>
0debug
If statement JAVA : <pre><code>int num=6; num=num+1; if (num&gt;6) jTextField1.setText(Integer.toString(num)); else jTextField1.setText(Integer.toString(num+5)); </code></pre> <p><strong>I am confused with the output which will be displayed in jTextField1 if it should be 12 or 11</strong>.</p> <p><em>My one more question,</em> in the below case what would we use "num=7" or "num==7"?</p> <pre><code>int num=6; if (num==7) jTextField1.setText("a"); else jTextField1.setText("b"); </code></pre>
0debug
How to find multiples of 3 and 5, push to an array, and then sum the array in Ruby : I am trying to sum the multiples of 3 and 5 that are less than 1000 using an .each do command, and then a .push to store them all in my array 'multiples'. However, when I try to do this, I get an error message. I am trying to learn how to use these commands and so don't want to use the .select and .inject I've been seeing everywhere. I have controllers set up to print @your_output on another page, and have done this successfully with other, simpler problems. However, when I try to do the conditional and store it in div, I get an error. def third_program numbers = (1..999).to_a # Your code goes below. multiples = [] numbers.each do |num| div = num % 3 == 0 || num % 5 == 0 multiples.push(div) end @your_output = div.sum render("programs_templates/third_program.html.erb") end
0debug
static void adb_register_types(void) { type_register_static(&adb_bus_type_info); type_register_static(&adb_device_type_info); type_register_static(&adb_kbd_type_info); type_register_static(&adb_mouse_type_info); }
1threat
Using VBA to scrape Youtube Data: Issue with Pulling View Data, Type Mismatch Error : I am getting a type mismatch for this line: Set QuestionField = html.getElementsByClassName("view-count style-scope yt-view-count-renderer") I'm pretty sure the view information I'm trying to pull is in a class tag, and I am unsure why getElementsByClassName isn't working to pull this information. Here is the relevant HTML code from YouTube: < span class="view-count style-scope yt-view-count-renderer">952 views < /span> Here is the VBA Code: Enum READYSTATE READYSTATE_UNINITIALIZED = 0 READYSTATE_LOADING = 1 READYSTATE_LOADED = 2 READYSTATE_INTERACTIVE = 3 READYSTATE_COMPLETE = 4 End Enum Sub ImportYTData() Dim ie As InternetExplorer Dim html As HTMLDocument Set ie = New InternetExplorer ie.Visible = True ie.navigate "https://www.youtube.com/watch? v=0YNJQNpP9Do&list=PL_Lt8vbVLfk_pzt-TWzfk_GNAKp-ePXc1&index=22" Do While ie.READYSTATE <> READYSTATE_COMPLETE Application.StatusBar = "Trying to go to the YouTube Video ..." DoEvents Loop Set html = ie.document MsgBox html.DocumentElement.innerHTML Application.StatusBar = "" Dim RowNumber As Long Dim QuestionField As IHTMLElement Dim views As String Set QuestionField = html.getElementsByClassName("view-count style-scope yt-view-count-renderer") RowNumber = 4 views = QuestionField.innerText views = Replace(views, "views", "") views = Replace(views, "view", "") Cells(RowNumber, 3).Value = Trim(views) Set html = Nothing End Sub
0debug
ASP.NET Core 2.0 JWT Validation fails with `Authorization failed for user: (null)` error : <p>I'm using ASP.NET Core 2.0 application (Web API) as a JWT issuer to generate a token consumable by a mobile app. Unfortunately, this token couldn't be validated by one controller while can be validated by another (using the same validation setting within the same asp.net core 2.0 app).</p> <p>So I have a token which is valid and could be decoded, has all the required claims and timestamps. But one endpoint accepts it, while another gives me 401 error and debug output: </p> <blockquote> <p>Microsoft.AspNetCore.Authorization.DefaultAuthorizationService:Information: Authorization failed for user: (null).</p> </blockquote> <pre><code>[40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2] Authorization failed for user: (null). Microsoft.AspNetCore.Authorization.DefaultAuthorizationService:Information: Authorization failed for user: (null). [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3] Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter'. Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter'. Microsoft.AspNetCore.Mvc.ChallengeResult:Information: Executing ChallengeResult with authentication schemes (). [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Mvc.ChallengeResult[1] Executing ChallengeResult with authentication schemes (). [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[12] AuthenticationScheme: Bearer was challenged. Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler:Information: AuthenticationScheme: Bearer was challenged. [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2] Executed action MyController.Get (WebApi) in 72.105ms Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action MyController.Get (WebApi) in 72.105ms Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 271.077ms 401 [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[2] Request finished in 271.077ms 401 </code></pre> <p>My validation setup is below:</p> <pre><code>var secretKey = Configuration["Authentication:OAuth:IssuerSigningKey"]; var signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(secretKey)); var tokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = signingKey, ValidateIssuer = true, ValidIssuer = Configuration["Authentication:OAuth:Issuer"], ValidateAudience = true, ValidAudience = Configuration["Authentication:OAuth:Audience"], ValidateLifetime = true, ClockSkew = TimeSpan.Zero, }; services.AddAuthentication(options =&gt; { options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(options =&gt; { options.RequireHttpsMetadata = false; options.TokenValidationParameters = tokenValidationParameters; }); </code></pre> <p>These two endpoints are identical, just live in different controllers, both marked with the <code>Authorize</code> attribute.</p> <p>How is that possible?</p>
0debug
static void tap_send(void *opaque) { TAPState *s = opaque; int size; int packets = 0; while (qemu_can_send_packet(&s->nc)) { uint8_t *buf = s->buf; size = tap_read_packet(s->fd, s->buf, sizeof(s->buf)); if (size <= 0) { break; } if (s->host_vnet_hdr_len && !s->using_vnet_hdr) { buf += s->host_vnet_hdr_len; size -= s->host_vnet_hdr_len; } size = qemu_send_packet_async(&s->nc, buf, size, tap_send_completed); if (size == 0) { tap_read_poll(s, false); break; } else if (size < 0) { break; } packets++; if (packets >= 50) { break; } } }
1threat
static int uhci_handle_td(UHCIState *s, UHCI_TD *td, uint32_t *int_mask, int completion) { uint8_t pid; int len = 0, max_len, err, ret = 0; if (td->ctrl & TD_CTRL_IOC) { *int_mask |= 0x01; } if (!(td->ctrl & TD_CTRL_ACTIVE)) return 1; max_len = ((td->token >> 21) + 1) & 0x7ff; pid = td->token & 0xff; if (completion && (s->async_qh || s->async_frame_addr)) { ret = s->usb_packet.len; if (ret >= 0) { len = ret; if (len > max_len) { len = max_len; ret = USB_RET_BABBLE; } if (len > 0) { cpu_physical_memory_write(td->buffer, s->usb_buf, len); } } else { len = 0; } s->async_qh = 0; s->async_frame_addr = 0; } else if (!completion) { s->usb_packet.pid = pid; s->usb_packet.devaddr = (td->token >> 8) & 0x7f; s->usb_packet.devep = (td->token >> 15) & 0xf; s->usb_packet.data = s->usb_buf; s->usb_packet.len = max_len; s->usb_packet.complete_cb = uhci_async_complete_packet; s->usb_packet.complete_opaque = s; switch(pid) { case USB_TOKEN_OUT: case USB_TOKEN_SETUP: cpu_physical_memory_read(td->buffer, s->usb_buf, max_len); ret = uhci_broadcast_packet(s, &s->usb_packet); len = max_len; break; case USB_TOKEN_IN: ret = uhci_broadcast_packet(s, &s->usb_packet); if (ret >= 0) { len = ret; if (len > max_len) { len = max_len; ret = USB_RET_BABBLE; } if (len > 0) { cpu_physical_memory_write(td->buffer, s->usb_buf, len); } } else { len = 0; } break; default: s->status |= UHCI_STS_HCPERR; uhci_update_irq(s); return -1; } } if (ret == USB_RET_ASYNC) { return 2; } if (td->ctrl & TD_CTRL_IOS) td->ctrl &= ~TD_CTRL_ACTIVE; if (ret >= 0) { td->ctrl = (td->ctrl & ~0x7ff) | ((len - 1) & 0x7ff); td->ctrl &= ~(TD_CTRL_ACTIVE | TD_CTRL_NAK); if (pid == USB_TOKEN_IN && (td->ctrl & TD_CTRL_SPD) && len < max_len) { *int_mask |= 0x02; return 1; } else { return 0; } } else { switch(ret) { default: case USB_RET_NODEV: do_timeout: td->ctrl |= TD_CTRL_TIMEOUT; err = (td->ctrl >> TD_CTRL_ERROR_SHIFT) & 3; if (err != 0) { err--; if (err == 0) { td->ctrl &= ~TD_CTRL_ACTIVE; s->status |= UHCI_STS_USBERR; uhci_update_irq(s); } } td->ctrl = (td->ctrl & ~(3 << TD_CTRL_ERROR_SHIFT)) | (err << TD_CTRL_ERROR_SHIFT); return 1; case USB_RET_NAK: td->ctrl |= TD_CTRL_NAK; if (pid == USB_TOKEN_SETUP) goto do_timeout; return 1; case USB_RET_STALL: td->ctrl |= TD_CTRL_STALL; td->ctrl &= ~TD_CTRL_ACTIVE; return 1; case USB_RET_BABBLE: td->ctrl |= TD_CTRL_BABBLE | TD_CTRL_STALL; td->ctrl &= ~TD_CTRL_ACTIVE; return -1; } } }
1threat
static void hpet_ram_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { int i; HPETState *s = opaque; uint64_t old_val, new_val, val, index; DPRINTF("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value); index = addr; old_val = hpet_ram_read(opaque, addr, 4); new_val = value; if (index >= 0x100 && index <= 0x3ff) { uint8_t timer_id = (addr - 0x100) / 0x20; HPETTimer *timer = &s->timer[timer_id]; DPRINTF("qemu: hpet_ram_writel timer_id = %#x\n", timer_id); if (timer_id > s->num_timers) { DPRINTF("qemu: timer id out of range\n"); return; } switch ((addr - 0x100) % 0x20) { case HPET_TN_CFG: DPRINTF("qemu: hpet_ram_writel HPET_TN_CFG\n"); if (activating_bit(old_val, new_val, HPET_TN_FSB_ENABLE)) { update_irq(timer, 0); } val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK); timer->config = (timer->config & 0xffffffff00000000ULL) | val; if (new_val & HPET_TN_32BIT) { timer->cmp = (uint32_t)timer->cmp; timer->period = (uint32_t)timer->period; } if (activating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_set_timer(timer); } else if (deactivating_bit(old_val, new_val, HPET_TN_ENABLE)) { hpet_del_timer(timer); } break; case HPET_TN_CFG + 4: DPRINTF("qemu: invalid HPET_TN_CFG+4 write\n"); break; case HPET_TN_CMP: DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP\n"); if (timer->config & HPET_TN_32BIT) { new_val = (uint32_t)new_val; } if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffff00000000ULL) | new_val; } if (timer_is_periodic(timer)) { new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffff00000000ULL) | new_val; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_CMP + 4: high order DPRINTF("qemu: hpet_ram_writel HPET_TN_CMP + 4\n"); if (!timer_is_periodic(timer) || (timer->config & HPET_TN_SETVAL)) { timer->cmp = (timer->cmp & 0xffffffffULL) | new_val << 32; } else { new_val &= (timer->config & HPET_TN_32BIT ? ~0u : ~0ull) >> 1; timer->period = (timer->period & 0xffffffffULL) | new_val << 32; } timer->config &= ~HPET_TN_SETVAL; if (hpet_enabled(s)) { hpet_set_timer(timer); } break; case HPET_TN_ROUTE: timer->fsb = (timer->fsb & 0xffffffff00000000ULL) | new_val; break; case HPET_TN_ROUTE + 4: timer->fsb = (new_val << 32) | (timer->fsb & 0xffffffff); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } return; } else { switch (index) { case HPET_ID: return; case HPET_CFG: val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK); s->config = (s->config & 0xffffffff00000000ULL) | val; if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) { s->hpet_offset = ticks_to_ns(s->hpet_counter) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); for (i = 0; i < s->num_timers; i++) { if ((&s->timer[i])->cmp != ~0ULL) { hpet_set_timer(&s->timer[i]); } } } else if (deactivating_bit(old_val, new_val, HPET_CFG_ENABLE)) { s->hpet_counter = hpet_get_ticks(s); for (i = 0; i < s->num_timers; i++) { hpet_del_timer(&s->timer[i]); } } if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) { qemu_set_irq(s->pit_enabled, 0); qemu_irq_lower(s->irqs[0]); qemu_irq_lower(s->irqs[RTC_ISA_IRQ]); } else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) { qemu_irq_lower(s->irqs[0]); qemu_set_irq(s->pit_enabled, 1); qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level); } break; case HPET_CFG + 4: DPRINTF("qemu: invalid HPET_CFG+4 write\n"); break; case HPET_STATUS: val = new_val & s->isr; for (i = 0; i < s->num_timers; i++) { if (val & (1 << i)) { update_irq(&s->timer[i], 0); } } break; case HPET_COUNTER: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffff00000000ULL) | value; DPRINTF("qemu: HPET counter written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; case HPET_COUNTER + 4: if (hpet_enabled(s)) { DPRINTF("qemu: Writing counter while HPET enabled!\n"); } s->hpet_counter = (s->hpet_counter & 0xffffffffULL) | (((uint64_t)value) << 32); DPRINTF("qemu: HPET counter + 4 written. ctr = %#x -> %" PRIx64 "\n", value, s->hpet_counter); break; default: DPRINTF("qemu: invalid hpet_ram_writel\n"); break; } } }
1threat
oracle query that can filter paired data : I need some help with an oracle query that can skip 'pairs' and only pick non paired data. example my data is as follows Id - cost - hour - type 123 $1.00 1 Input 123 $1.00 1 Output 234 $2.00 4 Input 345 $5.00 4 Output 236 $3.00 5 Input 236 $3.00 3 Output In the above example - only the first one is a 'pair' as the first 3 fields match - in the case of the next 2 - the first three fields data do not exactly match
0debug
static int tee_write_header(AVFormatContext *avf) { TeeContext *tee = avf->priv_data; unsigned nb_slaves = 0, i; const char *filename = avf->filename; char *slaves[MAX_SLAVES]; int ret; while (*filename) { if (nb_slaves == MAX_SLAVES) { av_log(avf, AV_LOG_ERROR, "Maximum %d slave muxers reached.\n", MAX_SLAVES); ret = AVERROR_PATCHWELCOME; goto fail; } if (!(slaves[nb_slaves++] = av_get_token(&filename, slave_delim))) { ret = AVERROR(ENOMEM); goto fail; } if (strspn(filename, slave_delim)) filename++; } for (i = 0; i < nb_slaves; i++) { if ((ret = open_slave(avf, slaves[i], &tee->slaves[i])) < 0) goto fail; log_slave(&tee->slaves[i], avf, AV_LOG_VERBOSE); av_freep(&slaves[i]); } tee->nb_slaves = nb_slaves; for (i = 0; i < avf->nb_streams; i++) { int j, mapped = 0; for (j = 0; j < tee->nb_slaves; j++) mapped += tee->slaves[j].stream_map[i] >= 0; if (!mapped) av_log(avf, AV_LOG_WARNING, "Input stream #%d is not mapped " "to any slave.\n", i); } return 0; fail: for (i = 0; i < nb_slaves; i++) av_freep(&slaves[i]); close_slaves(avf); return ret; }
1threat
Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$LayoutParams : <p>I'm getting Multiple dex files define error in my project.</p> <p>I'm using these two tags in <strong>build.gradle</strong> as well</p> <pre><code>dexOptions { preDexLibraries = false } defaultConfig { multiDexEnabled true } </code></pre> <p>but still getting this error.</p> <pre><code> Information:Gradle tasks [:app:assembleDebug] Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$LayoutParams; Error:com.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$LayoutParams; Error: at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661) Error: at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616) Error: at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598) Error: at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) Error: at com.android.dx.merge.DexMerger.merge(DexMerger.java:198) Error: at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61) Error: at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36) Error: at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424) Error: at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) Error: at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) Error: at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) Error: at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'. &gt; com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$LayoutParams; </code></pre>
0debug
static int bitplane_decoding(BitPlane *bp, VC9Context *v) { GetBitContext *gb = &v->s.gb; int imode, x, y, code, use_vertical_tile, tile_w, tile_h; uint8_t invert, *planep = bp->data; invert = get_bits(gb, 1); imode = get_vlc2(gb, vc9_imode_vlc.table, VC9_IMODE_VLC_BITS, 2); bp->is_raw = 0; switch (imode) { case IMODE_RAW: bp->is_raw = 1; return invert; case IMODE_DIFF2: case IMODE_NORM2: if ((bp->height*bp->width) & 1) *(++planep) = get_bits(gb, 1); for(x=0; x<(bp->height*bp->width)>>1; x++){ code = get_vlc2(gb, vc9_norm2_vlc.table, VC9_NORM2_VLC_BITS, 2); *(++planep) = code&1; *(++planep) = (code>>1)&1; } break; case IMODE_DIFF6: case IMODE_NORM6: use_vertical_tile= bp->height%3==0 && bp->width%3!=0; tile_w= use_vertical_tile ? 2 : 3; tile_h= use_vertical_tile ? 3 : 2; for(y= bp->height%tile_h; y< bp->height; y+=tile_h){ for(x= bp->width%tile_w; x< bp->width; x+=tile_w){ #if VLC_NORM6_METH0D == 1 code = get_vlc2(gb, vc9_norm6_vlc.table, VC9_NORM6_VLC_BITS, 2); if(code<0){ av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } #endif #if VLC_NORM6_METH0D == 2 code = get_vlc2(gb, vc9_norm6_first_vlc.table, VC9_NORM6_FIRST_BITS, 2); if (code == 22) { code = vc9_norm6_flc_val[get_bits(gb, 5)]; } else if (code == 23) { # if TRACE code = get_vlc2(gb, vc9_norm6_second_vlc.table, VC9_NORM6_SECOND_BITS, 2); assert(code>-1 && code<22); code = vc9_norm6_second_val[code]; # else code = vc9_norm6_second_val[get_vlc2(gb, vc9_norm6_second_vlc.table, VC9_NORM6_SECOND_BITS, 2)]; # endif } #endif planep[x + 0*bp->stride]= (code>>0)&1; planep[x + 1 + 0*bp->stride]= (code>>1)&1; if(use_vertical_tile){ planep[x + 0 + 1*bp->stride]= (code>>2)&1; planep[x + 1 + 1*bp->stride]= (code>>3)&1; planep[x + 0 + 2*bp->stride]= (code>>4)&1; planep[x + 1 + 2*bp->stride]= (code>>5)&1; }else{ planep[x + 2 + 0*bp->stride]= (code>>2)&1; planep[x + 0 + 1*bp->stride]= (code>>3)&1; planep[x + 1 + 1*bp->stride]= (code>>4)&1; planep[x + 2 + 1*bp->stride]= (code>>5)&1; } } } x= bp->width % tile_w; decode_colskip(bp->data , x, bp->height , bp->stride, v); decode_rowskip(bp->data+x, bp->width - x, bp->height % tile_h, bp->stride, v); break; case IMODE_ROWSKIP: decode_rowskip(bp->data, bp->width, bp->height, bp->stride, v); break; case IMODE_COLSKIP: decode_colskip(bp->data, bp->width, bp->height, bp->stride, v); break; default: break; } if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6) { planep = bp->data; planep[0] ^= invert; for (x=1; x<bp->width; x++) planep[x] ^= planep[x-1]; for (y=1; y<bp->height; y++) { planep += bp->stride; planep[0] ^= planep[-bp->stride]; for (x=1; x<bp->width; x++) { if (planep[x-1] != planep[x-bp->stride]) planep[x] ^= invert; else planep[x] ^= planep[x-1]; } } } else if (invert) { planep = bp->data; for (x=0; x<bp->width*bp->height; x++) planep[x] = !planep[x]; } return (imode<<1) + invert; }
1threat
Weird behavior when assigning one char array to another char array using char : <p>When I try to copy one element from char array to a char and then from same char to another char array, second char array gives weird output, usually containing whole string from first char array. This happens only when second char array is not initialized. My question is how char is able to transfer whole string to another char array.</p> <pre><code>int main() { char a[10] = "ababababa"; char b[5]; char temp; temp=a[1]; b[0]=temp; std::cout&lt;&lt;b; } </code></pre> <p>While using g++ I get <code>b{�Uarabababa</code> While using clang++ I get <code>b�U</code></p> <p>Content between <code>b</code> and <code>U</code> changes every time program is run.</p>
0debug
Running a program after compiling with Javac : I have a source file named Plane.java. I am trying to compile and run the program in terminal but i can't ! I am compiling it with : javac Plane.java So , i am getting with ls my classes CargoBay.class CleaningEmployee.class Employee.class EquipmentComponent.class MaintenanceEmployee.class PassengerComponent.class Plane.class Plane.java PlaneComponent.class PrivateComponent.class SecurityEmployee.class Now , i have no idea how to run it ! I am trying with java Plane but i am getting errors , any ideas ? The program runs just fine in netbeans
0debug
char *object_property_print(Object *obj, const char *name, bool human, Error **errp) { StringOutputVisitor *sov; char *string = NULL; Error *local_err = NULL; sov = string_output_visitor_new(human); object_property_get(obj, string_output_get_visitor(sov), name, &local_err); if (local_err) { error_propagate(errp, local_err); goto out; } string = string_output_get_string(sov); out: visit_free(string_output_get_visitor(sov)); return string; }
1threat
window.location.href = 'http://attack.com?user=' + user_input;
1threat
How to set timeout on before hook in mocha? : <p>I want to set timeout value on before hook in mocha test cases. I know I can do that by adding <code>-t 10000</code> on the command line of mocha but this will change every test cases timeout value. I want to find a way to change the timeout programmatically below is my code:</p> <pre><code>describe('test ', () =&gt; { before((done) =&gt; { this.timeout(10000); ... </code></pre> <p>it will complain about the line <code>this.timeout(1000)</code> that <code>timeout</code> is not defined. How to set the timeout on before hook.</p>
0debug
Passing over variables from a file to another using jQuery/AJAX shows empty result : <p>I want to fetch the list of transactions through jQuery/AJAX so it will update on any page I have that list on, when I update the content of this file I want to use. But I don't want to have the SQL queries in the file that I get through jQuery/AJAX since I use different queries for different pages on my website.</p> <ul> <li>The file <strong>transactions.php</strong> contains all the SQL queries that I need. In that file, I also have this line: <code>&lt;div id="transactions"&gt;&lt;/div&gt;</code>.</li> <li>The file <strong>fetch-transactions.php</strong> contains this list I want to show on the page. In it I have 2 globals (you know, <code>global $thevariable</code>) for 2 required variables (<code>$count_transactions</code> (to count the transactions) and <code>$get_transactions</code> (to loop the transactions into the list)) that can be found in transactions.php.</li> <li>The <strong>javascripts.js</strong> contains all the needed JavaScript codes I have for my website, including this line: <code>$.get(folder_name + 'ajax/fetch-transactions.php', function(s) { $('div#transactions').html(s); });</code></li> </ul> <p>As you maybe already have figure out, <strong>s</strong> contains the content of <strong>fetch-transactions.php</strong>.</p> <p>The thing is that none of the variables I have set globally in <strong>fetch-transactions.php</strong> have any data in them. The are empty! Why is that? Is it because they are not globally set? I don't want to use <code>define</code> as a variable. I don't think that is even possible for fetching data from the database :P</p> <p>How can I fix this problem?</p>
0debug
e1000e_intrmgr_delay_tx_causes(E1000ECore *core, uint32_t *causes) { static const uint32_t delayable_causes = E1000_ICR_TXQ0 | E1000_ICR_TXQ1 | E1000_ICR_TXQE | E1000_ICR_TXDW; if (msix_enabled(core->owner)) { return false; } core->delayed_causes |= *causes & delayable_causes; *causes &= ~delayable_causes; if (causes != 0) { return false; } e1000e_intrmgr_rearm_timer(&core->tidv); if (!core->tadv.running && (core->mac[TADV] != 0)) { e1000e_intrmgr_rearm_timer(&core->tadv); } return true; }
1threat
bootstrap 2014 theme running slow on godaddy linux hosting : <p>I am unable to fix the speed of bootstrap website used in www.bengalwools.co.in ...</p> <p>please help me fix the CDN for the javascript and css or anything else to speed up my website...</p> <p>the code for the index.html is : <a href="http://www.bengalwool.co.in" rel="nofollow noreferrer">all links available in inspect element</a></p>
0debug
static int dxtory_decode_v1_rgb(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size, int id, int bpp) { int h; uint8_t *dst; int ret; if (src_size < avctx->width * avctx->height * bpp) { av_log(avctx, AV_LOG_ERROR, "packet too small\n"); return AVERROR_INVALIDDATA; } avctx->pix_fmt = id; if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) return ret; dst = pic->data[0]; for (h = 0; h < avctx->height; h++) { memcpy(dst, src, avctx->width * bpp); src += avctx->width * bpp; dst += pic->linesize[0]; } return 0; }
1threat
static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d){ #if CONFIG_SMALL #define ROT(x,s) ((x<<s)|(x>>(32-s))) return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24); #else return multbl[0][a] ^ multbl[1][b] ^ multbl[2][c] ^ multbl[3][d]; #endif }
1threat
Failed to resolve: junit:junit: 4.12 What is the solution to this pro blem : Failed to resolve: junit:junit:4.12 --------- What is the solution to this problem I have tried several solutions
0debug
Can docker have multiple logging drivers? : <p>is it possible to use multiple logging drivers for the same container - say fluentd and json?</p> <p>Thank you.</p>
0debug
static float32 addFloat32Sigs( float32 a, float32 b, flag zSign STATUS_PARAM) { int16 aExp, bExp, zExp; uint32_t aSig, bSig, zSig; int16 expDiff; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); bSig = extractFloat32Frac( b ); bExp = extractFloat32Exp( b ); expDiff = aExp - bExp; aSig <<= 6; bSig <<= 6; if ( 0 < expDiff ) { if ( aExp == 0xFF ) { if ( aSig ) return propagateFloat32NaN( a, b STATUS_VAR ); return a; } if ( bExp == 0 ) { --expDiff; } else { bSig |= 0x20000000; } shift32RightJamming( bSig, expDiff, &bSig ); zExp = aExp; } else if ( expDiff < 0 ) { if ( bExp == 0xFF ) { if ( bSig ) return propagateFloat32NaN( a, b STATUS_VAR ); return packFloat32( zSign, 0xFF, 0 ); } if ( aExp == 0 ) { ++expDiff; } else { aSig |= 0x20000000; } shift32RightJamming( aSig, - expDiff, &aSig ); zExp = bExp; } else { if ( aExp == 0xFF ) { if ( aSig | bSig ) return propagateFloat32NaN( a, b STATUS_VAR ); return a; } if ( aExp == 0 ) { if ( STATUS(flush_to_zero) ) return packFloat32( zSign, 0, 0 ); return packFloat32( zSign, 0, ( aSig + bSig )>>6 ); } zSig = 0x40000000 + aSig + bSig; zExp = aExp; goto roundAndPack; } aSig |= 0x20000000; zSig = ( aSig + bSig )<<1; --zExp; if ( (int32_t) zSig < 0 ) { zSig = aSig + bSig; ++zExp; } roundAndPack: return roundAndPackFloat32( zSign, zExp, zSig STATUS_VAR ); }
1threat
how to compare two string [][] arrays in golang : func assertEq(test [][]string,ans [][]string){ for i:=0;i<len(test);i++ { for j:=0;j<len(ans);j++{ if(test[i][j]!=ans[i][j]){ fmt.Print(test) fmt.Print(" ! ") fmt.Print(ans) } } } fmt.Println() } // In my code its not checking i have use two different string arrays to compare each every character .please help me
0debug
Javascript recreate multidimensional array : <p>I have the following multidimensional array stored in a variable named <code>posts</code></p> <pre><code>{ID: 141, categories: ["candy", "fruits", "vegetables"]} {ID: 142, categories: ["fruits"]} {ID: 143, categories: ["candy", "vegetables"]} </code></pre> <p>Is it possible to create a new array only with items containing <code>candy</code> in the categories? </p> <p>So the new <code>posts</code> variable will have the following array:</p> <pre><code>{ID: 141, categories: ["candy", "fruits", "vegetables"]} {ID: 143, categories: ["candy", "vegetables"]} </code></pre>
0debug
Ruby on Rails: undefined method `join' for "product line":String : def nameize self.split.map do |word| if word.length > 3 word.capitalize else word.downcase end end self.join(" ") end Hi for some reason or another i have not been able to join my it back together does anyone know why? please do help
0debug
VBA Excel Error 424 search textbox to display listbox, error display listbox header : Private Sub SearchCommand_Click() Dim i As Long Sheet1.Activate Me.ResultListbox.AddItem For a = 1 To 5 **Me.ResultListbox.List(0, a - 1) = Sheet1.Cells(1, a)** Next a Me.ResultListbox.Selected(0) = True End sub [enter image description here][1] [1]: https://i.stack.imgur.com/sZatD.png
0debug
Counting number of words in a file using c++ : <p>I have been asked to develop program to count no. of lines and words in the file, this is my trial, my teacher said that I cant use >> operator for counting words and comparing but I could not handle it.</p> <pre><code> #include &lt;iostream&gt; #include &lt;fstream&gt; using namespace std; int numberLines = 0; int numberWords = 0; void numberOfLines(){ cout&lt;&lt;"number of lines is " &lt;&lt; numberLines &lt;&lt; endl; } void numberWords(){ cout &lt;&lt; "number of words is " &lt;&lt; numberWords &lt;&lt;endl; } int main(){ string line; char a = ''; ifstream myfile("files.txt"); if(myfile.is_open()){ while(!myfile.eof()){ getline(myfile,line); cout&lt;&lt; line &lt;&lt; endl; numberLines++; } if ( a == ' '){ NumberWords++; } } myfile.close(); } numberOfLines(); numberOfWords (); } </code></pre>
0debug
int qio_channel_readv_all(QIOChannel *ioc, const struct iovec *iov, size_t niov, Error **errp) { int ret = -1; struct iovec *local_iov = g_new(struct iovec, niov); struct iovec *local_iov_head = local_iov; unsigned int nlocal_iov = niov; nlocal_iov = iov_copy(local_iov, nlocal_iov, iov, niov, 0, iov_size(iov, niov)); while (nlocal_iov > 0) { ssize_t len; len = qio_channel_readv(ioc, local_iov, nlocal_iov, errp); if (len == QIO_CHANNEL_ERR_BLOCK) { if (qemu_in_coroutine()) { qio_channel_yield(ioc, G_IO_IN); } else { qio_channel_wait(ioc, G_IO_IN); } continue; } else if (len < 0) { goto cleanup; } else if (len == 0) { error_setg(errp, "Unexpected end-of-file before all bytes were read"); goto cleanup; } iov_discard_front(&local_iov, &nlocal_iov, len); } ret = 0; cleanup: g_free(local_iov_head); return ret; }
1threat
static void floor_encode(venc_context_t * venc, floor_t * fc, PutBitContext * pb, int * posts, float * floor, int samples) { int range = 255 / fc->multiplier + 1; int coded[fc->values]; int i, counter; int lx, ly; put_bits(pb, 1, 1); put_bits(pb, ilog(range - 1), posts[0]); put_bits(pb, ilog(range - 1), posts[1]); for (i = 2; i < fc->values; i++) { int predicted = render_point(fc->list[fc->list[i].low].x, posts[fc->list[i].low], fc->list[fc->list[i].high].x, posts[fc->list[i].high], fc->list[i].x); int highroom = range - predicted; int lowroom = predicted; int room = FFMIN(highroom, lowroom); if (predicted == posts[i]) { coded[i] = 0; continue; } else { if (!coded[fc->list[i].low]) coded[fc->list[i].low] = -1; if (!coded[fc->list[i].high]) coded[fc->list[i].high] = -1; } if (posts[i] > predicted) { if (posts[i] - predicted > room) coded[i] = posts[i] - predicted + lowroom; else coded[i] = (posts[i] - predicted) << 1; } else { if (predicted - posts[i] > room) coded[i] = predicted - posts[i] + highroom - 1; else coded[i] = ((predicted - posts[i]) << 1) - 1; } } counter = 2; for (i = 0; i < fc->partitions; i++) { floor_class_t * c = &fc->classes[fc->partition_to_class[i]]; int k, cval = 0, csub = 1<<c->subclass; if (c->subclass) { codebook_t * book = &venc->codebooks[c->masterbook]; int cshift = 0; for (k = 0; k < c->dim; k++) { int l; for (l = 0; l < csub; l++) { int maxval = 1; if (c->books[l] != -1) maxval = venc->codebooks[c->books[l]].nentries; if (coded[counter + k] < maxval) break; } assert(l != csub); cval |= l << cshift; cshift += c->subclass; } assert(cval < book->nentries); put_bits(pb, book->entries[cval].len, book->entries[cval].codeword); } for (k = 0; k < c->dim; k++) { int book = c->books[cval & (csub-1)]; int entry = coded[counter++]; cval >>= c->subclass; if (book == -1) continue; if (entry == -1) entry = 0; assert(entry < venc->codebooks[book].nentries); assert(entry >= 0); put_bits(pb, venc->codebooks[book].entries[entry].len, venc->codebooks[book].entries[entry].codeword); } } lx = 0; ly = posts[0] * fc->multiplier; coded[0] = coded[1] = 1; for (i = 1; i < fc->values; i++) { int pos = fc->list[i].sort; if (coded[pos]) { render_line(lx, ly, fc->list[pos].x, posts[pos] * fc->multiplier, floor, samples); lx = fc->list[pos].x; ly = posts[pos] * fc->multiplier; } if (lx >= samples) break; } if (lx < samples) render_line(lx, ly, samples, ly, floor, samples); }
1threat
static void tcg_commit(MemoryListener *listener) { CPUAddressSpace *cpuas; AddressSpaceDispatch *d; cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener); cpu_reloading_memory_map(); d = atomic_rcu_read(&cpuas->as->dispatch); cpuas->memory_dispatch = d; tlb_flush(cpuas->cpu, 1); }
1threat
C programming, segmentation fault core dunmp : I am trying to make a program which takes in a input of "Hello" and outputs "olleH" from reversing the order of the characters. However I keep getting a segmentation fault and I don't understand why #include <stdio.h> #include<string.h> int main() { int i; int size; char s[100],a[100]; printf("Enter the word you want to get reversed: "); scanf("%s",s); while(s[i]!='\0') { a[i]=s[i]; i++; } size=sizeof(s); while(i<sizeof(s)) { s[i]=a[size]; } printf("The reversed string is : %s",s); }
0debug
int v9fs_co_readlink(V9fsPDU *pdu, V9fsPath *path, V9fsString *buf) { int err; ssize_t len; V9fsState *s = pdu->s; if (v9fs_request_cancelled(pdu)) { return -EINTR; } buf->data = g_malloc(PATH_MAX); v9fs_path_read_lock(s); v9fs_co_run_in_worker( { len = s->ops->readlink(&s->ctx, path, buf->data, PATH_MAX - 1); if (len > -1) { buf->size = len; buf->data[len] = 0; err = 0; } else { err = -errno; } }); v9fs_path_unlock(s); if (err) { g_free(buf->data); buf->data = NULL; buf->size = 0; } return err; }
1threat
Flutter: Get the filename of a File : <p>I thought this would be pretty straight-forward, but can't seem to get this. I have a <code>File file</code> and it has a path <code>file.path</code> which spits out something like <code>/storage/emulated/0/Android/data/my_app/files/Pictures/ca04f332.png</code> but I can't seem to find anything to get just <code>ca04f332.png</code>.</p>
0debug
static void free_duplicate_context(MpegEncContext *s){ if(s==NULL) return; av_freep(&s->allocated_edge_emu_buffer); s->edge_emu_buffer= NULL; av_freep(&s->me.scratchpad); s->me.temp= s->rd_scratchpad= s->b_scratchpad= s->obmc_scratchpad= NULL; av_freep(&s->dct_error_sum); av_freep(&s->me.map); av_freep(&s->me.score_map); av_freep(&s->blocks); av_freep(&s->ac_val_base); s->block= NULL; }
1threat
How to interpret LDA components (using sklearn)? : <p>I used <strong>Latent Dirichlet Allocation</strong> (<strong>sklearn</strong> implementation) to analyse about 500 scientific article-abstracts and I got topics containing most important words (in german language). My problem is to interpret these values associated with the most important words. I assumed to get probabilities for all words per topic which add up to 1, which is not the case. </p> <p>How can I interpret these values? For example I would like to be able to tell why topic #20 has words with much higher values than other topics. Has their absolute height to do with Bayesian probability? Is the topic more common in the corpus? Im not yet able to bring together theses values with the math behind the LDA.</p> <pre class="lang-py prettyprint-override"><code>from sklearn.feature_extraction.text import CountVectorizer from sklearn.decomposition import LatentDirichletAllocation tf_vectorizer = CountVectorizer(max_df=0.95, min_df=1, top_words=stop_ger, analyzer='word', tokenizer = stemmer_sklearn.stem_ger()) tf = tf_vectorizer.fit_transform(texts) n_topics = 10 lda = LatentDirichletAllocation(n_topics=n_topics, max_iter=5, learning_method='online', learning_offset=50., random_state=0) lda.fit(tf) def print_top_words(model, feature_names, n_top_words): for topic_id, topic in enumerate(model.components_): print('\nTopic Nr.%d:' % int(topic_id + 1)) print(''.join([feature_names[i] + ' ' + str(round(topic[i], 2)) +' | ' for i in topic.argsort()[:-n_top_words - 1:-1]])) n_top_words = 4 tf_feature_names = tf_vectorizer.get_feature_names() print_top_words(lda, tf_feature_names, n_top_words) Topic Nr.1: demenzforsch 1.31 | fotus 1.21 | umwelteinfluss 1.16 | forschungsergebnis 1.04 | Topic Nr.2: fur 1.47 | zwisch 0.94 | uber 0.81 | kontext 0.8 | ... Topic Nr.20: werd 405.12 | fur 399.62 | sozial 212.31 | beitrag 177.95 | </code></pre>
0debug
JavaScript cant get element from object : <p>I can't use the html elment with the id </p> <blockquote> <p>notification-panel-sidebar</p> </blockquote> <p>in my JavaScript, but I can Access it directly using jquery.</p> <p>This is the Code:</p> <pre><code>const notificationContainer = { elements: { notificationPanelSidebar: $('#notification-panel-sidebar'), notificationPanelSidebarContainer: $('#notification-panel-sidebar-container') }, classes: { notificationContainerActive: 'notification-container-active' }, render () { this.toggleNotificationContainer(); }, toggleNotificationContainer () { console.log(this.elements.notificationPanelSidebar); this.elements.notificationPanelSidebar.click((e) =&gt; { // this does not work // $('#notification-panel-sidebar').click((e) =&gt; { // this works let _this = $(e.currentTarget); if (_this.hasClass(this.classes.notificationContainerActive)) { console.log("+++++++"); this.hideNotificationContainer(); } else { console.log("-------"); _this.addClass(this.classes.notificationContainerActive); this.elements.notificationPanelSidebarContainer.show(); } }); }, hideNotificationContainer () { this.elements.notificationPanelSidebar.removeClass(this.classes.notificationContainerActive); this.elements.notificationPanelSidebarContainer.hide(); } } $(document).ready(function () { notificationContainer.render(); }); </code></pre> <p>I get no error message.</p>
0debug
Flutter Inspector in Visual Studio code : <p>Is there any way to inspect Flutter App elements in emulator? I am using VS code not android studio I want to inspect element from running emulator .</p>
0debug
PHP not selecting my first row from mysql database : <p>My connection to the database works fine. My application can display all my data, except the first row. When I run it locally through MySQL workbench, it fetches my first row, and every row after that. It is just my PHP code that is not getting the first row, and I am unsure why. </p> <pre><code>&lt;?php //connect with database $connect= new mysqli($host,$user,$pass,$db) or die("ERROR:could not connect to the database!"); $query="select * from college"; $result=$connect-&gt;query($query); $jsonData = array(); while ($array = mysqli_fetch_assoc($result)) { $jsonData[] = $array; } echo json_encode($jsonData); ?&gt; </code></pre>
0debug
How to splice array and merge back in Ruby? : Say I have 2D array like so: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> [ 3, 4, 8, 12 ] [ 2, 6, 7, 16 ] [ 1, 10, 11, 15 ] [ 5, 9, 13, 14 ] <!-- end snippet --> I want to `shift` 6 in **`[1][1]`** and `unshift` it into **`[2][2]`** So that I can get the following: <!-- language: ruby --> [ 3, 4, 8, 12 ] [ 2, 7, 11, 16 ] [ 1, 6, 10, 15 ] [ 5, 9, 13, 14 ] <!-- end snippet --> I thought I'd `splice(1,1)` 2nd and 3rd array to get: a: [6, 7] b: [10, 11] and then do: b.unshift(a.shift) a << b.pop
0debug
Error ArrayIndexOutOfBoundsException on android : <p>i create login and register </p> <p>build and run working but after register filed name if use put name surname it working can register but if i put onlu name no have surname don't work error </p> <pre><code>String name = nameField.getText().toString().trim(); if (email != null &amp;&amp; email.length() == 0 &amp;&amp; !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) { emailField.setError(getString(R.string.com_parse_ui_no_email_toast)); } else if (name != null &amp;&amp; name.length() == 0 &amp;&amp; config.isParseSignupNameFieldEnabled()) { nameField.setError(getString(R.string.com_parse_ui_no_name_toast)); } else if (dateCheck == null) { mBirthday.setError(getString(R.string.signup_user_date)); } else if (password.length() == 0) { passwordField.setError(getString(R.string.com_parse_ui_no_password_toast)); } else if (password.length() &lt; minPasswordLength) { passwordField.setError(getResources().getQuantityString(R.plurals.com_parse_ui_password_too_short_toast, minPasswordLength, minPasswordLength)); } else if (gender == null){ showToast(getString(R.string.gender_missing)); } else { String[] parts = name.split(" "); String firstName = parts[0]; String lastName = parts[1]; String username = (lastName+firstName).toLowerCase().trim().replaceAll(" ", ""); User user = ParseObject.create(User.class); </code></pre>
0debug
why type hint cannot be used in the for loop : ```for i: str in test_string:``` I received the **invalid syntax** error, I would like to know the reason behind.
0debug
static void convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64], const uint16_t *quant_matrix, int bias, int qmin, int qmax) { int qscale; for(qscale=qmin; qscale<=qmax; qscale++){ int i; if (dsp->fdct == ff_jpeg_fdct_islow #ifdef FAAN_POSTSCALE || dsp->fdct == ff_faandct #endif ) { for(i=0;i<64;i++) { const int j= dsp->idct_permutation[i]; qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j])); } } else if (dsp->fdct == fdct_ifast #ifndef FAAN_POSTSCALE || dsp->fdct == ff_faandct #endif ) { for(i=0;i<64;i++) { const int j= dsp->idct_permutation[i]; qmat[qscale][i] = (int)((uint64_t_C(1) << (QMAT_SHIFT + 14)) / (aanscales[i] * qscale * quant_matrix[j])); } } else { for(i=0;i<64;i++) { const int j= dsp->idct_permutation[i]; qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j])); qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[j]); if(qmat16[qscale][0][i]==0 || qmat16[qscale][0][i]==128*256) qmat16[qscale][0][i]=128*256-1; qmat16[qscale][1][i]= ROUNDED_DIV(bias<<(16-QUANT_BIAS_SHIFT), qmat16[qscale][0][i]); } } } }
1threat
@Autowired object is always null : <p>I've started playing with spring data elasticsearch and have been looking at the example <a href="https://github.com/eugenp/tutorials/tree/master/persistence-modules/spring-data-elasticsearch" rel="nofollow noreferrer">here</a>.</p> <p>I am having trouble understanding how <code>@Autowired</code> works. Consider the following:</p> <p><strong>IMessageProcessor.java:</strong></p> <pre><code>package message.processor; public interface IMessageProcessor { void processMessage(); } </code></pre> <p><strong>MyMessageProcessor.java</strong></p> <pre><code>package message.processor; @Component public class MyMessageProcessor implements IMessageProcessor { @Autowired private ArticleServiceImpl articleService; private final Author johnSmith = new Author("John Smith"); private final Author johnDoe = new Author("John Doe"); @Override public void processMessage() { Article article = new Article("Spring Data Elasticsearch"); article.setAuthors(asList(johnSmith, johnDoe)); article.setTags("elasticsearch", "spring data"); articleService.save(article); } } </code></pre> <p><strong>MyMessageProcessorIT.java</strong></p> <pre><code>package message.processor; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = Config.class) public class MyMessageProcessorIT { @Autowired private ElasticsearchTemplate elasticsearchTemplate; @Before public void before() { elasticsearchTemplate.deleteIndex(Article.class); elasticsearchTemplate.createIndex(Article.class); } @Test void testProcessMessage() { MyMessageProcessor msgProcessor = new MyMessageProcessor(); msgProcessor.processMessage(); } } </code></pre> <p>Whenever I run the unit test, <code>articleService</code> in <code>MyMessageProcessor</code> is always <code>null</code>. Do I need extra configuration for the autowiring to work? All other code is the same as what is in the github repo linked above.</p> <p>How do I ensure that wherever in my project I need to use <code>ArticleServiceImpl</code>, it is autowired correctly?</p> <p>I have seem other posts with the same issue but none of the solutions seem to work for my example below.</p>
0debug
How can I store the content of a resolved promise in a variable : <p>I have a function that contains a promise. The function do an HTTP request and I want to resolve it and return the response as a value in a variable.</p> <pre><code>function sendCommand(auth, playerId, command) { return new Promise((resolve, reject) =&gt; { request.post(`https://test.com/${playerId}/command`,{ headers: { Authorization: auth }, json: { "arg": `${command}` } }, function status(err, response, body) { if (response.statusCode === 200) { resolve(body) } else { reject(err) } } ) }) } </code></pre> <p>I run this function from a different file so I do the following: </p> <pre><code>module.exports = { doSomething: (playerId, command) =&gt; { loginHelper.getToken().then(token =&gt; sendCommand(token, playerId, command)) } } </code></pre> <p>On the other file, I want to store the resolved response in a variable such as this:</p> <pre><code>const commandHelper = require(__helpers + 'command-helper') let test = commandHelper.doSomething(playerId, 'command') </code></pre> <p>I expect the test variable to contain response data.</p>
0debug
uint8_t cpu_inb(CPUState *env, pio_addr_t addr) { uint8_t val; val = ioport_read(0, addr); LOG_IOPORT("inb : %04"FMT_pioaddr" %02"PRIx8"\n", addr, val); #ifdef CONFIG_KQEMU if (env) env->last_io_time = cpu_get_time_fast(); #endif return val; }
1threat
Properly start Activity from Notification regardless of app state : <p>I have an app with a splash screen Activity, followed by a main Activity. The splash screen loads stuff (database, etc.) before starting the main Activity. From this main Activity the user can navigate to multiple other child Activities and back. Some of the child Activities are started using <code>startActivityForResult()</code>, others just <code>startActivity()</code>.</p> <p>The Activity hierarchy are as depicted below. </p> <pre><code>| Child A (startActivityForResult) | / |--&gt; Splash --&gt; Main -- Child B (startActivityForResult) | ^ \ | | Child C (startActivity) | \ | This Activity is currently skipped if a Notification is started | while the app is not running or in the background. </code></pre> <p>I need to achieve the following behavior <strong>when clicking a Notification</strong>:</p> <ol> <li><strong>The state in the Activity must be maintained</strong>, since the user has selected some recipes to create a shopping list. If a new Activity is started, I believe the state will be lost.</li> <li>If the app is in the Main Activity, bring that to the front and let me know in code that I arrived from a Notification.</li> <li>If the app is in a child Activity started with <code>startActivityForResult()</code>, I need to add data to an Intent before going back to the Main Activity so that it can catch the result properly.</li> <li>If the app is in a child Activity started with <code>startActivity()</code> I just need to go back since there is nothing else to do (this currently works).</li> <li>If the app is not in the background, nor the foreground (i.e. it is <em>not</em> running) I must start the Main Activity and also know that I arrived from a Notification, so that I can set up things that are not set up yet, since the Splash Activity is skipped in this case in my current setup.</li> </ol> <p>I have tried lots of various suggestions here on SO and elsewhere, but I have not been able to successfully get the behavior described above. I have also tried reading the <a href="http://developer.android.com/guide/topics/ui/notifiers/notifications.html">documentation</a> without becoming a lot wiser, just a little. My current situation for the cases above when clicking my Notification is:</p> <ol> <li>I arrive in the Main Activity in <code>onNewIntent()</code>. I do not arrive here if the app is not running (or in the background). This seems to be expected and desired behavior.</li> <li>I am not able to catch that I am coming from a Notification in any child Activities, thus I am not able to properly call <code>setResult()</code> in those Activities. <strong>How should I do this?</strong></li> <li>This currently works, since the Notification just closes the child Activity, which is ok.</li> <li>I am able to get the Notification Intent in <code>onCreate()</code> by using <code>getIntent()</code> and <code>Intent.getBooleanExtra()</code> with a boolean set in the Notification. I should thus be able to make it work, but I am not sure that this is the best way. <strong>What is the preferred way of doing this?</strong></li> </ol> <h2>Current code</h2> <p><strong>Creating Notification:</strong></p> <p>The Notification is created when an HTTP request inside a Service returns some data.</p> <pre><code>NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setSmallIcon(getNotificationIcon()) .setAutoCancel(true) .setColor(ContextCompat.getColor(context, R.color.my_brown)) .setContentTitle(getNotificationTitle(newRecipeNames)) .setContentText(getContentText(newRecipeNames)) .setStyle(new NotificationCompat.BigTextStyle().bigText("foo")); Intent notifyIntent = new Intent(context, MainActivity.class); notifyIntent.setAction(Intent.ACTION_MAIN); notifyIntent.addCategory(Intent.CATEGORY_LAUNCHER); notifyIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); /* Add a thing to let MainActivity know that we came from a Notification. */ notifyIntent.putExtra("intent_bool", true); PendingIntent notifyPendingIntent = PendingIntent.getActivity(context, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(notifyPendingIntent); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(111, builder.build()); </code></pre> <p><strong>MainActivity.java:</strong></p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { Intent intent = getIntent(); if (intent.getBooleanExtra("intent_bool", false)) { // We arrive here if the app was not running, as described in point 4 above. } ... } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case CHILD_A: // Intent data is null here when starting from Notification. We will thus crash and burn if using it. Normally data has values when closing CHILD_A properly. // This is bullet point 2 above. break; case CHILD_B: // Same as CHILD_A break; } ... } @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); boolean arrivedFromNotification = intent.getBooleanExtra("intent_bool", false); // arrivedFromNotification is true, but onNewIntent is only called if the app is already running. // This is bullet point 1 above. // Do stuff with Intent. ... } </code></pre> <p><strong>Inside a child Activity started with <code>startActivityForResult()</code>:</strong></p> <pre><code>@Override protected void onNewIntent(Intent intent) { // This point is never reached when opening a Notification while in the child Activity. super.onNewIntent(intent); } @Override public void onBackPressed() { // This point is never reached when opening a Notification while in the child Activity. Intent resultIntent = getResultIntent(); setResult(Activity.RESULT_OK, resultIntent); // NOTE! super.onBackPressed() *must* be called after setResult(). super.onBackPressed(); this.finish(); } private Intent getResultIntent() { int recipeCount = getRecipeCount(); Recipe recipe = getRecipe(); Intent recipeIntent = new Intent(); recipeIntent.putExtra(INTENT_RECIPE_COUNT, recipeCount); recipeIntent.putExtra(INTENT_RECIPE, recipe); return recipeIntent; } </code></pre> <p><strong>AndroidManifest.xml:</strong></p> <pre><code>&lt;application android:allowBackup="true" android:icon="@mipmap/my_launcher_icon" android:label="@string/my_app_name" android:theme="@style/MyTheme" android:name="com.mycompany.myapp.MyApplication" &gt; &lt;activity android:name="com.mycompany.myapp.activities.SplashActivity" android:screenOrientation="portrait" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name="com.mycompany.myapp.activities.MainActivity" android:label="@string/my_app_name" android:screenOrientation="portrait" android:windowSoftInputMode="adjustPan" &gt; &lt;/activity&gt; &lt;activity android:name="com.mycompany.myapp.activities.ChildActivityA" android:label="@string/foo" android:parentActivityName="com.mycompany.myapp.activities.MainActivity" android:screenOrientation="portrait" android:windowSoftInputMode="adjustPan" &gt; &lt;meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.mycompany.myapp.activities.MainActivity" &gt; &lt;/meta-data&gt; &lt;/activity&gt; &lt;activity android:name="com.mycompany.myapp.activities.ChildActivityB" android:label="@string/foo" android:parentActivityName="com.mycompany.myapp.activities.MainActivity" android:screenOrientation="portrait" &gt; &lt;meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.mycompany.myapp.activities.MainActivity" &gt; &lt;/meta-data&gt; &lt;/activity&gt; ... &lt;/manifest&gt; </code></pre>
0debug
While vs For-loop : <p>Are these basically the same?</p> <p>1) While</p> <pre><code>int i = 0, j = 0; while (i &lt; 10) { while (j &lt; 10) { } j++; } i++; </code></pre> <p>2) For</p> <pre><code>for (int i = 0; i &lt; 10; i++) { for (int j = 0; j &lt; 10; j++) { } } </code></pre> <p>Still kind of new to programming and I just wanted to know. Which one would be more efficient if they are the same?</p>
0debug
static int t27(InterplayACMContext *s, unsigned ind, unsigned col) { GetBitContext *gb = &s->gb; unsigned i, b; int n1, n2, n3; for (i = 0; i < s->rows; i++) { b = get_bits(gb, 7); n1 = (mul_3x5[b] & 0x0F) - 2; n2 = ((mul_3x5[b] >> 4) & 0x0F) - 2; n3 = ((mul_3x5[b] >> 8) & 0x0F) - 2; set_pos(s, i++, col, n1); if (i >= s->rows) break; set_pos(s, i++, col, n2); if (i >= s->rows) break; set_pos(s, i, col, n3); return 0;
1threat
static av_cold int nvenc_encode_init(AVCodecContext *avctx) { NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS encode_session_params = { 0 }; NV_ENC_PRESET_CONFIG preset_config = { 0 }; CUcontext cu_context_curr; CUresult cu_res; GUID encoder_preset = NV_ENC_PRESET_HQ_GUID; GUID codec; NVENCSTATUS nv_status = NV_ENC_SUCCESS; int surfaceCount = 0; int i, num_mbs; int isLL = 0; int res = 0; int dw, dh; NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs; if (!nvenc_dyload_nvenc(avctx)) return AVERROR_EXTERNAL; avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) { res = AVERROR(ENOMEM); goto error; } ctx->last_dts = AV_NOPTS_VALUE; ctx->encode_config.version = NV_ENC_CONFIG_VER; ctx->init_encode_params.version = NV_ENC_INITIALIZE_PARAMS_VER; preset_config.version = NV_ENC_PRESET_CONFIG_VER; preset_config.presetCfg.version = NV_ENC_CONFIG_VER; encode_session_params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER; encode_session_params.apiVersion = NVENCAPI_VERSION; if (ctx->gpu >= dl_fn->nvenc_device_count) { av_log(avctx, AV_LOG_FATAL, "Requested GPU %d, but only %d GPUs are available!\n", ctx->gpu, dl_fn->nvenc_device_count); res = AVERROR(EINVAL); goto error; } ctx->cu_context = NULL; cu_res = dl_fn->cu_ctx_create(&ctx->cu_context, 0, dl_fn->nvenc_devices[ctx->gpu]); if (cu_res != CUDA_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed creating CUDA context for NVENC: 0x%x\n", (int)cu_res); res = AVERROR_EXTERNAL; goto error; } cu_res = dl_fn->cu_ctx_pop_current(&cu_context_curr); if (cu_res != CUDA_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed popping CUDA context: 0x%x\n", (int)cu_res); res = AVERROR_EXTERNAL; goto error; } encode_session_params.device = ctx->cu_context; encode_session_params.deviceType = NV_ENC_DEVICE_TYPE_CUDA; nv_status = p_nvenc->nvEncOpenEncodeSessionEx(&encode_session_params, &ctx->nvencoder); if (nv_status != NV_ENC_SUCCESS) { ctx->nvencoder = NULL; av_log(avctx, AV_LOG_FATAL, "OpenEncodeSessionEx failed: 0x%x - invalid license key?\n", (int)nv_status); res = AVERROR_EXTERNAL; goto error; } if (ctx->preset) { if (!strcmp(ctx->preset, "hp")) { encoder_preset = NV_ENC_PRESET_HP_GUID; } else if (!strcmp(ctx->preset, "hq")) { encoder_preset = NV_ENC_PRESET_HQ_GUID; } else if (!strcmp(ctx->preset, "bd")) { encoder_preset = NV_ENC_PRESET_BD_GUID; } else if (!strcmp(ctx->preset, "ll")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID; isLL = 1; } else if (!strcmp(ctx->preset, "llhp")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HP_GUID; isLL = 1; } else if (!strcmp(ctx->preset, "llhq")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID; isLL = 1; } else if (!strcmp(ctx->preset, "default")) { encoder_preset = NV_ENC_PRESET_DEFAULT_GUID; } else { av_log(avctx, AV_LOG_FATAL, "Preset \"%s\" is unknown! Supported presets: hp, hq, bd, ll, llhp, llhq, default\n", ctx->preset); res = AVERROR(EINVAL); goto error; } } switch (avctx->codec->id) { case AV_CODEC_ID_H264: codec = NV_ENC_CODEC_H264_GUID; break; case AV_CODEC_ID_H265: codec = NV_ENC_CODEC_HEVC_GUID; break; default: av_log(avctx, AV_LOG_ERROR, "nvenc: Unknown codec name\n"); res = AVERROR(EINVAL); goto error; } nv_status = p_nvenc->nvEncGetEncodePresetConfig(ctx->nvencoder, codec, encoder_preset, &preset_config); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "GetEncodePresetConfig failed: 0x%x\n", (int)nv_status); res = AVERROR_EXTERNAL; goto error; } ctx->init_encode_params.encodeGUID = codec; ctx->init_encode_params.encodeHeight = avctx->height; ctx->init_encode_params.encodeWidth = avctx->width; if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den && (avctx->sample_aspect_ratio.num != 1 || avctx->sample_aspect_ratio.num != 1)) { av_reduce(&dw, &dh, avctx->width * avctx->sample_aspect_ratio.num, avctx->height * avctx->sample_aspect_ratio.den, 1024 * 1024); ctx->init_encode_params.darHeight = dh; ctx->init_encode_params.darWidth = dw; } else { ctx->init_encode_params.darHeight = avctx->height; ctx->init_encode_params.darWidth = avctx->width; } if (avctx->width == 720 && (avctx->height == 480 || avctx->height == 576)) { av_reduce(&dw, &dh, ctx->init_encode_params.darWidth * 44, ctx->init_encode_params.darHeight * 45, 1024 * 1024); ctx->init_encode_params.darHeight = dh; ctx->init_encode_params.darWidth = dw; } ctx->init_encode_params.frameRateNum = avctx->time_base.den; ctx->init_encode_params.frameRateDen = avctx->time_base.num * avctx->ticks_per_frame; num_mbs = ((avctx->width + 15) >> 4) * ((avctx->height + 15) >> 4); ctx->max_surface_count = (num_mbs >= 8160) ? 32 : 48; ctx->init_encode_params.enableEncodeAsync = 0; ctx->init_encode_params.enablePTD = 1; ctx->init_encode_params.presetGUID = encoder_preset; ctx->init_encode_params.encodeConfig = &ctx->encode_config; memcpy(&ctx->encode_config, &preset_config.presetCfg, sizeof(ctx->encode_config)); ctx->encode_config.version = NV_ENC_CONFIG_VER; if (avctx->refs >= 0) { switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.maxNumRefFrames = avctx->refs; break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.maxNumRefFramesInDPB = avctx->refs; break; } } if (avctx->gop_size > 0) { if (avctx->max_b_frames >= 0) { ctx->encode_config.frameIntervalP = avctx->max_b_frames + 1; } ctx->encode_config.gopLength = avctx->gop_size; switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = avctx->gop_size; break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = avctx->gop_size; break; } } else if (avctx->gop_size == 0) { ctx->encode_config.frameIntervalP = 0; ctx->encode_config.gopLength = 1; switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = 1; break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = 1; break; } } if (ctx->encode_config.frameIntervalP >= 2) ctx->last_dts = -2; if (avctx->bit_rate > 0) ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate; if (avctx->rc_max_rate > 0) ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate; if (ctx->cbr) { if (!ctx->twopass) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR; } else if (ctx->twopass == 1 || isLL) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_2_PASS_QUALITY; if (avctx->codec->id == AV_CODEC_ID_H264) { ctx->encode_config.encodeCodecConfig.h264Config.adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE; ctx->encode_config.encodeCodecConfig.h264Config.fmoMode = NV_ENC_H264_FMO_DISABLE; } if (!isLL) av_log(avctx, AV_LOG_WARNING, "Twopass mode is only known to work with low latency (ll, llhq, llhp) presets.\n"); } else { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR; } } else if (avctx->global_quality > 0) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CONSTQP; ctx->encode_config.rcParams.constQP.qpInterB = avctx->global_quality; ctx->encode_config.rcParams.constQP.qpInterP = avctx->global_quality; ctx->encode_config.rcParams.constQP.qpIntra = avctx->global_quality; avctx->qmin = -1; avctx->qmax = -1; } else if (avctx->qmin >= 0 && avctx->qmax >= 0) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR; ctx->encode_config.rcParams.enableMinQP = 1; ctx->encode_config.rcParams.enableMaxQP = 1; ctx->encode_config.rcParams.minQP.qpInterB = avctx->qmin; ctx->encode_config.rcParams.minQP.qpInterP = avctx->qmin; ctx->encode_config.rcParams.minQP.qpIntra = avctx->qmin; ctx->encode_config.rcParams.maxQP.qpInterB = avctx->qmax; ctx->encode_config.rcParams.maxQP.qpInterP = avctx->qmax; ctx->encode_config.rcParams.maxQP.qpIntra = avctx->qmax; } if (avctx->rc_buffer_size > 0) ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size; if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) { ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD; } else { ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME; } switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourDescriptionPresentFlag = 1; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoSignalTypePresentFlag = 1; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourMatrix = avctx->colorspace; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourPrimaries = avctx->color_primaries; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.transferCharacteristics = avctx->color_trc; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = avctx->color_range == AVCOL_RANGE_JPEG; ctx->encode_config.encodeCodecConfig.h264Config.disableSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; ctx->encode_config.encodeCodecConfig.h264Config.repeatSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; if (!ctx->profile) { switch (avctx->profile) { case FF_PROFILE_H264_BASELINE: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID; break; case FF_PROFILE_H264_MAIN: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID; break; case FF_PROFILE_H264_HIGH: case FF_PROFILE_UNKNOWN: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; break; default: av_log(avctx, AV_LOG_WARNING, "Unsupported profile requested, falling back to high\n"); ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; break; } } else { if (!strcmp(ctx->profile, "high")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; avctx->profile = FF_PROFILE_H264_HIGH; } else if (!strcmp(ctx->profile, "main")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID; avctx->profile = FF_PROFILE_H264_MAIN; } else if (!strcmp(ctx->profile, "baseline")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID; avctx->profile = FF_PROFILE_H264_BASELINE; } else { av_log(avctx, AV_LOG_FATAL, "Profile \"%s\" is unknown! Supported profiles: high, main, baseline\n", ctx->profile); res = AVERROR(EINVAL); goto error; } } if (ctx->level) { res = input_string_to_uint32(avctx, nvenc_h264_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.h264Config.level); if (res) { av_log(avctx, AV_LOG_FATAL, "Level \"%s\" is unknown! Supported levels: auto, 1, 1b, 1.1, 1.2, 1.3, 2, 2.1, 2.2, 3, 3.1, 3.2, 4, 4.1, 4.2, 5, 5.1\n", ctx->level); goto error; } } else { ctx->encode_config.encodeCodecConfig.h264Config.level = NV_ENC_LEVEL_AUTOSELECT; } break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.disableSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; ctx->encode_config.encodeCodecConfig.hevcConfig.repeatSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; ctx->encode_config.profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID; avctx->profile = FF_PROFILE_HEVC_MAIN; if (ctx->level) { res = input_string_to_uint32(avctx, nvenc_hevc_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.hevcConfig.level); if (res) { av_log(avctx, AV_LOG_FATAL, "Level \"%s\" is unknown! Supported levels: auto, 1, 2, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2\n", ctx->level); goto error; } } else { ctx->encode_config.encodeCodecConfig.hevcConfig.level = NV_ENC_LEVEL_AUTOSELECT; } if (ctx->tier) { if (!strcmp(ctx->tier, "main")) { ctx->encode_config.encodeCodecConfig.hevcConfig.tier = NV_ENC_TIER_HEVC_MAIN; } else if (!strcmp(ctx->tier, "high")) { ctx->encode_config.encodeCodecConfig.hevcConfig.tier = NV_ENC_TIER_HEVC_HIGH; } else { av_log(avctx, AV_LOG_FATAL, "Tier \"%s\" is unknown! Supported tiers: main, high\n", ctx->tier); res = AVERROR(EINVAL); goto error; } } break; } nv_status = p_nvenc->nvEncInitializeEncoder(ctx->nvencoder, &ctx->init_encode_params); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "InitializeEncoder failed: 0x%x\n", (int)nv_status); res = AVERROR_EXTERNAL; goto error; } ctx->input_surfaces = av_malloc(ctx->max_surface_count * sizeof(*ctx->input_surfaces)); if (!ctx->input_surfaces) { res = AVERROR(ENOMEM); goto error; } ctx->output_surfaces = av_malloc(ctx->max_surface_count * sizeof(*ctx->output_surfaces)); if (!ctx->output_surfaces) { res = AVERROR(ENOMEM); goto error; } for (surfaceCount = 0; surfaceCount < ctx->max_surface_count; ++surfaceCount) { NV_ENC_CREATE_INPUT_BUFFER allocSurf = { 0 }; NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 }; allocSurf.version = NV_ENC_CREATE_INPUT_BUFFER_VER; allocOut.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER; allocSurf.width = (avctx->width + 31) & ~31; allocSurf.height = (avctx->height + 31) & ~31; allocSurf.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED; switch (avctx->pix_fmt) { case AV_PIX_FMT_YUV420P: allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_YV12_PL; break; case AV_PIX_FMT_NV12: allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_NV12_PL; break; case AV_PIX_FMT_YUV444P: allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_YUV444_PL; break; default: av_log(avctx, AV_LOG_FATAL, "Invalid input pixel format\n"); res = AVERROR(EINVAL); goto error; } nv_status = p_nvenc->nvEncCreateInputBuffer(ctx->nvencoder, &allocSurf); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "CreateInputBuffer failed\n"); res = AVERROR_EXTERNAL; goto error; } ctx->input_surfaces[surfaceCount].lockCount = 0; ctx->input_surfaces[surfaceCount].input_surface = allocSurf.inputBuffer; ctx->input_surfaces[surfaceCount].format = allocSurf.bufferFmt; ctx->input_surfaces[surfaceCount].width = allocSurf.width; ctx->input_surfaces[surfaceCount].height = allocSurf.height; allocOut.size = 1024 * 1024; allocOut.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED; nv_status = p_nvenc->nvEncCreateBitstreamBuffer(ctx->nvencoder, &allocOut); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "CreateBitstreamBuffer failed\n"); ctx->output_surfaces[surfaceCount++].output_surface = NULL; res = AVERROR_EXTERNAL; goto error; } ctx->output_surfaces[surfaceCount].output_surface = allocOut.bitstreamBuffer; ctx->output_surfaces[surfaceCount].size = allocOut.size; ctx->output_surfaces[surfaceCount].busy = 0; } if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { uint32_t outSize = 0; char tmpHeader[256]; NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 }; payload.version = NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER; payload.spsppsBuffer = tmpHeader; payload.inBufferSize = sizeof(tmpHeader); payload.outSPSPPSPayloadSize = &outSize; nv_status = p_nvenc->nvEncGetSequenceParams(ctx->nvencoder, &payload); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "GetSequenceParams failed\n"); goto error; } avctx->extradata_size = outSize; avctx->extradata = av_mallocz(outSize + FF_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { res = AVERROR(ENOMEM); goto error; } memcpy(avctx->extradata, tmpHeader, outSize); } if (ctx->encode_config.frameIntervalP > 1) avctx->has_b_frames = 2; if (ctx->encode_config.rcParams.averageBitRate > 0) avctx->bit_rate = ctx->encode_config.rcParams.averageBitRate; return 0; error: for (i = 0; i < surfaceCount; ++i) { p_nvenc->nvEncDestroyInputBuffer(ctx->nvencoder, ctx->input_surfaces[i].input_surface); if (ctx->output_surfaces[i].output_surface) p_nvenc->nvEncDestroyBitstreamBuffer(ctx->nvencoder, ctx->output_surfaces[i].output_surface); } if (ctx->nvencoder) p_nvenc->nvEncDestroyEncoder(ctx->nvencoder); if (ctx->cu_context) dl_fn->cu_ctx_destroy(ctx->cu_context); av_frame_free(&avctx->coded_frame); nvenc_unload_nvenc(avctx); ctx->nvencoder = NULL; ctx->cu_context = NULL; return res; }
1threat
Get date in golang like "2018-07-13" : <p>how to get date in golang like this formate "2018-07-13"</p> <p>main.go file</p> <pre><code>package main import ( "fmt" "time" ) func main() { fmt.Println(time.Now()) } </code></pre> <blockquote> <p>$ go run main.go</p> </blockquote> <p>otuput:</p> <blockquote> <p>2018-07-13 21:25:16.796379489 +0500 +05 m=+0.000120455</p> </blockquote> <p>how to write function to return date in string like this formate "2018-07-13"?</p>
0debug
static void video_refresh(void *opaque, double *remaining_time) { VideoState *is = opaque; VideoPicture *vp; double time; SubPicture *sp, *sp2; if (!is->paused && get_master_sync_type(is) == AV_SYNC_EXTERNAL_CLOCK && is->realtime) check_external_clock_speed(is); if (!display_disable && is->show_mode != SHOW_MODE_VIDEO && is->audio_st) { time = av_gettime() / 1000000.0; if (is->force_refresh || is->last_vis_time + rdftspeed < time) { video_display(is); is->last_vis_time = time; } *remaining_time = FFMIN(*remaining_time, is->last_vis_time + rdftspeed - time); } if (is->video_st) { int redisplay = 0; if (is->force_refresh) redisplay = pictq_prev_picture(is); retry: if (is->pictq_size == 0) { SDL_LockMutex(is->pictq_mutex); if (is->frame_last_dropped_pts != AV_NOPTS_VALUE && is->frame_last_dropped_pts > is->frame_last_pts) { update_video_pts(is, is->frame_last_dropped_pts, is->frame_last_dropped_pos, is->frame_last_dropped_serial); is->frame_last_dropped_pts = AV_NOPTS_VALUE; } SDL_UnlockMutex(is->pictq_mutex); } else { double last_duration, duration, delay; vp = &is->pictq[is->pictq_rindex]; if (vp->serial != is->videoq.serial) { pictq_next_picture(is); redisplay = 0; goto retry; } if (is->paused) goto display; last_duration = vp->pts - is->frame_last_pts; if (!isnan(last_duration) && last_duration > 0 && last_duration < is->max_frame_duration) { is->frame_last_duration = last_duration; } if (redisplay) delay = 0.0; else delay = compute_target_delay(is->frame_last_duration, is); time= av_gettime()/1000000.0; if (time < is->frame_timer + delay && !redisplay) { *remaining_time = FFMIN(is->frame_timer + delay - time, *remaining_time); return; } is->frame_timer += delay; if (delay > 0 && time - is->frame_timer > AV_SYNC_THRESHOLD_MAX) is->frame_timer = time; SDL_LockMutex(is->pictq_mutex); if (!redisplay && !isnan(vp->pts)) update_video_pts(is, vp->pts, vp->pos, vp->serial); SDL_UnlockMutex(is->pictq_mutex); if (is->pictq_size > 1) { VideoPicture *nextvp = &is->pictq[(is->pictq_rindex + 1) % VIDEO_PICTURE_QUEUE_SIZE]; duration = nextvp->pts - vp->pts; if(!is->step && (redisplay || framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) && time > is->frame_timer + duration){ if (!redisplay) is->frame_drops_late++; pictq_next_picture(is); redisplay = 0; goto retry; } } if (is->subtitle_st) { while (is->subpq_size > 0) { sp = &is->subpq[is->subpq_rindex]; if (is->subpq_size > 1) sp2 = &is->subpq[(is->subpq_rindex + 1) % SUBPICTURE_QUEUE_SIZE]; else sp2 = NULL; if (sp->serial != is->subtitleq.serial || (is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000))) || (sp2 && is->vidclk.pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000)))) { free_subpicture(sp); if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE) is->subpq_rindex = 0; SDL_LockMutex(is->subpq_mutex); is->subpq_size--; SDL_CondSignal(is->subpq_cond); SDL_UnlockMutex(is->subpq_mutex); } else { break; } } } display: if (!display_disable && is->show_mode == SHOW_MODE_VIDEO) video_display(is); pictq_next_picture(is); if (is->step && !is->paused) stream_toggle_pause(is); } } is->force_refresh = 0; if (show_status) { static int64_t last_time; int64_t cur_time; int aqsize, vqsize, sqsize; double av_diff; cur_time = av_gettime(); if (!last_time || (cur_time - last_time) >= 30000) { aqsize = 0; vqsize = 0; sqsize = 0; if (is->audio_st) aqsize = is->audioq.size; if (is->video_st) vqsize = is->videoq.size; if (is->subtitle_st) sqsize = is->subtitleq.size; av_diff = 0; if (is->audio_st && is->video_st) av_diff = get_clock(&is->audclk) - get_clock(&is->vidclk); else if (is->video_st) av_diff = get_master_clock(is) - get_clock(&is->vidclk); else if (is->audio_st) av_diff = get_master_clock(is) - get_clock(&is->audclk); av_log(NULL, AV_LOG_INFO, "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r", get_master_clock(is), (is->audio_st && is->video_st) ? "A-V" : (is->video_st ? "M-V" : (is->audio_st ? "M-A" : " ")), av_diff, is->frame_drops_early + is->frame_drops_late, aqsize / 1024, vqsize / 1024, sqsize, is->video_st ? is->video_st->codec->pts_correction_num_faulty_dts : 0, is->video_st ? is->video_st->codec->pts_correction_num_faulty_pts : 0); fflush(stdout); last_time = cur_time; } } }
1threat
I have an image with a css overlay that slides up from the bottom, and it's on the left. I want it in the center, but nothing is working on the image : I just need to know how to make it go to the center. I have tried moving it to the left by 25, 50, and 75%, same with the right. It just won't move.
0debug
CSS Flexbox bug on IE : https://jsfiddle.net/6yuh90cd/3/ code if you load this in IE .. you will see that the content of the gray box is extending over to the yellow box, which doesn't happen on other browsers. What i am trying to achieve is: -let the gray box expand according to its content -let the yellow box take the remaining height of its parent -if the content yellow box has more content, overflow it properly Can someone help me?
0debug
static int ffat_encode(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { ATDecodeContext *at = avctx->priv_data; OSStatus ret; AudioBufferList out_buffers = { .mNumberBuffers = 1, .mBuffers = { { .mNumberChannels = avctx->channels, .mDataByteSize = at->pkt_size, } } }; AudioStreamPacketDescription out_pkt_desc = {0}; if ((ret = ff_alloc_packet2(avctx, avpkt, at->pkt_size, 0)) < 0) return ret; av_frame_unref(&at->new_in_frame); if (frame) { if ((ret = ff_af_queue_add(&at->afq, frame)) < 0) return ret; if ((ret = av_frame_ref(&at->new_in_frame, frame)) < 0) return ret; } else { at->eof = 1; } out_buffers.mBuffers[0].mData = avpkt->data; *got_packet_ptr = avctx->frame_size / at->frame_size; ret = AudioConverterFillComplexBuffer(at->converter, ffat_encode_callback, avctx, got_packet_ptr, &out_buffers, (avctx->frame_size > at->frame_size) ? NULL : &out_pkt_desc); if ((!ret || ret == 1) && *got_packet_ptr) { avpkt->size = out_buffers.mBuffers[0].mDataByteSize; ff_af_queue_remove(&at->afq, out_pkt_desc.mVariableFramesInPacket ? out_pkt_desc.mVariableFramesInPacket : avctx->frame_size, &avpkt->pts, &avpkt->duration); } else if (ret && ret != 1) { av_log(avctx, AV_LOG_WARNING, "Encode error: %i\n", ret); } return 0; }
1threat
Ionic with Android Emulator: Automatically send location? : <p>I'm having an issue with my android emulator. When I close and re-open my app, the location is not sent automatically. I have to go into Extended Controls -> Location and click the 'Send' button for the Ionic Geolocation getCurrentPosition function to receive it.</p> <p>When I boot up the android emulator and the app opens for the first time, this is not necessary. Any idea how to send the location automatically no matter what?</p>
0debug
to which class/Interface/Abstract class does it belongs to or it is defined in? : <p>I know main() method is a static method, I have seen the Object class methods but main() method is not defined there, then how we are using main() method in our java classes without importing related class?</p>
0debug
Uncaught TypeError: $(...).datepicker is not a function(anonymous function) : <p>I found few answers on stack overflow but still cant resolve my problem. I am running on Django but I dont think it is relevant for this error.</p> <p>I try to make work my date picker java script but I am getting the error </p> <p>1:27 Uncaught TypeError: $(...).datepicker is not a function(anonymous function) @ 1:27fire @ jquery-1.9.1.js:1037self.fireWith @ jquery-1.9.1.js:1148jQuery.extend.ready @ jquery-1.9.1.js:433completed @ jquery-1.9.1.js:103 jquery-2.1.0.min.js:4 XHR finished loading: POST "<a href="https://localhost:26143/skypectoc/v1/pnr/parse">https://localhost:26143/skypectoc/v1/pnr/parse</a>".l.cors.a.crossDomain.send @ jquery-2.1.0.min.js:4o.extend.ajax @ jquery-2.1.0.min.js:4PNR.findNumbers @ pnr.js:43parseContent @ contentscript.js:385processMutatedElements @ contentscript.js:322</p> <p>This is all my scripts :</p> <pre><code>&lt;meta charset="utf-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /&gt; &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('.dateinput').datepicker({ format: "yyyy/mm/dd" }); }); &lt;/script&gt; &lt;!-- Bootstrap core JavaScript ================================================== --&gt; &lt;!-- Placed at the end of the document so the pages load faster --&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt;window.jQuery || document.write('&lt;script src="../../assets/js/vendor/jquery.min.js"&gt;&lt;\/script&gt;')&lt;/script&gt; &lt;script src="http://getbootstrap.com/dist/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;!-- Just to make our placeholder images work. Don't actually copy the next line! --&gt; &lt;script src="http://getbootstrap.com/assets/js/vendor/holder.min.js"&gt;&lt;/script&gt; &lt;!-- IE10 viewport hack for Surface/desktop Windows 8 bug --&gt; &lt;script src="http://getbootstrap.com/assets/js/ie10-viewport-bug-workaround.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $("#extra-content").hide(); $("#toggle-content").click(function(){ $("#extra-content").toggle(); }); }); &lt;/script&gt; </code></pre> <p>any feedback will be very appreciated </p>
0debug
static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) { VAAPIEncodeContext *ctx = avctx->priv_data; int hrd_buffer_size; int hrd_initial_buffer_fullness; if (avctx->rc_buffer_size) hrd_buffer_size = avctx->rc_buffer_size; else hrd_buffer_size = avctx->bit_rate; if (avctx->rc_initial_buffer_occupancy) hrd_initial_buffer_fullness = avctx->rc_initial_buffer_occupancy; else hrd_initial_buffer_fullness = hrd_buffer_size * 3 / 4; ctx->rc_params.misc.type = VAEncMiscParameterTypeRateControl; ctx->rc_params.rc = (VAEncMiscParameterRateControl) { .bits_per_second = avctx->bit_rate, .target_percentage = 66, .window_size = 1000, .initial_qp = (avctx->qmax >= 0 ? avctx->qmax : 40), .min_qp = (avctx->qmin >= 0 ? avctx->qmin : 18), .basic_unit_size = 0, }; ctx->global_params[ctx->nb_global_params] = &ctx->rc_params.misc; ctx->global_params_size[ctx->nb_global_params++] = sizeof(ctx->rc_params); ctx->hrd_params.misc.type = VAEncMiscParameterTypeHRD; ctx->hrd_params.hrd = (VAEncMiscParameterHRD) { .initial_buffer_fullness = hrd_initial_buffer_fullness, .buffer_size = hrd_buffer_size, }; ctx->global_params[ctx->nb_global_params] = &ctx->hrd_params.misc; ctx->global_params_size[ctx->nb_global_params++] = sizeof(ctx->hrd_params); return 0; }
1threat
av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c) { mm_flags = mm_support(); #if HAVE_YASM if (mm_flags & FF_MM_MMX) { c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx; c->vp8_idct_add = ff_vp8_idct_add_mmx; c->put_vp8_epel_pixels_tab[0][0][0] = c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmx; c->put_vp8_epel_pixels_tab[1][0][0] = c->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmx; c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmx; c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmx; c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmx; c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmx; c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmx; c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmx; } if (mm_flags & FF_MM_MMX2) { c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_mmxext; VP8_LUMA_MC_FUNC(0, 16, mmxext); VP8_MC_FUNC(1, 8, mmxext); VP8_MC_FUNC(2, 4, mmxext); VP8_BILINEAR_MC_FUNC(0, 16, mmxext); VP8_BILINEAR_MC_FUNC(1, 8, mmxext); VP8_BILINEAR_MC_FUNC(2, 4, mmxext); c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmxext; c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmxext; c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmxext; c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmxext; c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmxext; c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmxext; } if (mm_flags & FF_MM_SSE) { c->put_vp8_epel_pixels_tab[0][0][0] = c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_sse; } if (mm_flags & FF_MM_SSE2) { VP8_LUMA_MC_FUNC(0, 16, sse2); VP8_MC_FUNC(1, 8, sse2); VP8_BILINEAR_MC_FUNC(0, 16, sse2); VP8_BILINEAR_MC_FUNC(1, 8, sse2); c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_sse2; c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_sse2; c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_sse2; c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_sse2; c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_sse2; c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_sse2; } if (mm_flags & FF_MM_SSSE3) { VP8_LUMA_MC_FUNC(0, 16, ssse3); VP8_MC_FUNC(1, 8, ssse3); VP8_MC_FUNC(2, 4, ssse3); VP8_BILINEAR_MC_FUNC(0, 16, ssse3); VP8_BILINEAR_MC_FUNC(1, 8, ssse3); VP8_BILINEAR_MC_FUNC(2, 4, ssse3); } if (mm_flags & FF_MM_SSE4) { c->vp8_idct_dc_add = ff_vp8_idct_dc_add_sse4; } #endif }
1threat
static int mjpegb_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MJpegDecodeContext *s = avctx->priv_data; const uint8_t *buf_end, *buf_ptr; GetBitContext hgb; uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs; uint32_t field_size, sod_offs; int ret; buf_ptr = buf; buf_end = buf + buf_size; s->got_picture = 0; read_header: s->restart_interval = 0; s->restart_count = 0; s->mjpb_skiptosod = 0; if (buf_end - buf_ptr >= 1 << 28) return AVERROR_INVALIDDATA; init_get_bits(&hgb, buf_ptr, (buf_end - buf_ptr)*8); skip_bits(&hgb, 32); if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g')) { av_log(avctx, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n"); return AVERROR_INVALIDDATA; } field_size = get_bits_long(&hgb, 32); av_log(avctx, AV_LOG_DEBUG, "field size: 0x%x\n", field_size); skip_bits(&hgb, 32); second_field_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "second_field_offs is %d and size is %d\n"); av_log(avctx, AV_LOG_DEBUG, "second field offs: 0x%x\n", second_field_offs); dqt_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dqt is %d and size is %d\n"); av_log(avctx, AV_LOG_DEBUG, "dqt offs: 0x%x\n", dqt_offs); if (dqt_offs) { init_get_bits(&s->gb, buf_ptr+dqt_offs, (buf_end - (buf_ptr+dqt_offs))*8); s->start_code = DQT; if (ff_mjpeg_decode_dqt(s) < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; } dht_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dht is %d and size is %d\n"); av_log(avctx, AV_LOG_DEBUG, "dht offs: 0x%x\n", dht_offs); if (dht_offs) { init_get_bits(&s->gb, buf_ptr+dht_offs, (buf_end - (buf_ptr+dht_offs))*8); s->start_code = DHT; ff_mjpeg_decode_dht(s); } sof_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n"); av_log(avctx, AV_LOG_DEBUG, "sof offs: 0x%x\n", sof_offs); if (sof_offs) { init_get_bits(&s->gb, buf_ptr+sof_offs, (buf_end - (buf_ptr+sof_offs))*8); s->start_code = SOF0; if (ff_mjpeg_decode_sof(s) < 0) return -1; } sos_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sos is %d and size is %d\n"); av_log(avctx, AV_LOG_DEBUG, "sos offs: 0x%x\n", sos_offs); sod_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n"); av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs); if (sos_offs) { init_get_bits(&s->gb, buf_ptr + sos_offs, 8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs)); s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16)); s->start_code = SOS; if (ff_mjpeg_decode_sos(s, NULL, NULL) < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; } if (s->interlaced) { s->bottom_field ^= 1; if (s->bottom_field != s->interlace_polarity && second_field_offs) { buf_ptr = buf + second_field_offs; goto read_header; } } if(!s->got_picture) { av_log(avctx, AV_LOG_WARNING, "no picture\n"); return buf_size; } if ((ret = av_frame_ref(data, s->picture_ptr)) < 0) return ret; *got_frame = 1; if (!s->lossless && avctx->debug & FF_DEBUG_QP) { av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2])); } return buf_size; }
1threat
error: not found: value StructType/StructField/StringType : <p>I am running scala on my local machine, version 2.0.</p> <pre><code>val schema = StructType(schemaString.split("|^").map(fieldName =&gt;StructField(fieldName, StringType, true))) &lt;console&gt;:45: error: not found: value StructType val schema = StructType(schemaString.split("|^").map(fieldName =&gt;StructField(fieldName, StringType, true))) ^ &lt;console&gt;:45: error: not found: value StructField val schema = StructType(schemaString.split("|^").map(fieldName =&gt; StructField(fieldName, StringType, true))) ^ &lt;console&gt;:45: error: not found: value StringType val schema = StructType(schemaString.split("|^").map(fieldName =&gt; StructField(fieldName, StringType, true))) ^ </code></pre> <p>i loaded import org.apache.spark.sql._ but still getting this error. am i missing any packages?</p>
0debug
android BottomSheet how to collapse when clicked outside? : <p>I have implemented bottomsheet behavior with NestedScrollView. And was wondering if it is possible to hide the bottomsheet view when touched outside.</p>
0debug
Pointer of slice of pointers panicking when making : <p>I have the following code :</p> <pre><code>var ANIMATIONS *[]*SDL.Animable .... func main() { *ANIMATIONS = make([]*SDL.Animable, 0, 100) </code></pre> <p>But its panicking when running. What is the right way of initializing this?</p> <p>Error : </p> <pre><code>panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x4afe3a] goroutine 1 [running, locked to thread]: main.main() </code></pre>
0debug
react-native link only for one project (Android or iOS) : <p>I want to link only one of my project (Android or iOS) with the npm package. Is there any way to do it?</p>
0debug
Foreach loop returning database search results to a view in cshtml - MVC Null Reference Exception : Cannot implicitly convert type 'RedPandaCourses.Models.CourseSearchResultModel' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?) Controller: namespace RedPandaCourses.Controllers { public class SearchController : Controller { [HttpGet] public ActionResult CourseSearchView() { var courses = new CourseSearchResultModel(); return View(courses); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult CourseSearchView(CourseSearchResultModel vm) { var courses = new CourseSearchResultModel(); return View(courses); } 2 Models: namespace RedPandaCourses.Models { public class CourseSearchModel { public CourseSearchModel() { } public string courseName { get; set; } public int courseNumber { get; set; } public string courseInstructor { get; set; } public List<CourseSearchResultModel> results { get; set; } } } and namespace RedPandaCourses.Models { public class CourseSearchResultModel { public CourseSearchResultModel() { } public decimal courseID { get; set; } public string courseName { get; set; } public string courseNumber { get; set; } public string courseInstructorFirstName { get; set; } public string courseInstructorLastName { get; set; } public string courseInstructor { get; set; } public string courseSchedule { get; set; } } } It will send text box text to the database, search it from a select class, and return the results to the table using a foreach loop, however the foreach loop throws the error above. View: @Model RedPandaCourses.Models.CourseSearchResultModel; @using RedPandaCourses.Models; @{ ViewBag.Title = "CourseSearchView"; Layout = "~/Views/Shared/_AdminLayout.cshtml"; } <div class="container-fluid no-main-border"> <div class="row-fluid main-bg"> <div class="span12"> <h2 class="labelHide">&nbsp;</h2> <div class="row-fluid"> <div class="negMargin"> <div class="span9 inner-container"> <div class="streamlined-subhead"> <h1>Search Courses</h1> </div> @using (Html.BeginForm("CourseSearchView", "Search")) { var model = new CourseSearchModel(); <div id="the_id" class="question"> <div class="control-group" id="the_id_control-group"> <fieldset> <div id="the_id_1_control-group" class="control-group"> <label class="control-label" for="courseName">Course Name: </label> <div id="the_id_1_controls" class="controls"> @Html.TextBoxFor(m => model.courseName) </div> </div> <div id="the_id_2_control-group" class="control-group"> <label class="control-label" for="courseNumber">Course Number: </label> <div id="the_id_2_controls" class="controls"> @Html.TextBoxFor(m => model.courseNumber) </div> </div> <div id="the_id_3_control-group" class="control-group"> <label class="control-label" for="instructor">Instructor: </label> <div id="the_id_3_controls" class="controls"> @Html.TextBoxFor(m => model.courseInstructor) </div> </div> <div class="previous-next-bar"> <button type="submit" class="btn btn-primary" id="courseSearch" onclick="location.href='@Url.Action("CourseSearchView","Search")'">Search</button> </div> </fieldset> </div> </div> } <div> <h2>Search Results</h2> <table id="example" class="table table-bordered table-striped table-hover dataTable width80"> <thead class="tableHeader" role="rowgroup"> <tr role="row"> <th class="sorting" role="columnheader"><a href="#">Course Title</a></th> <th class="sorting" role="columnheader"><a href="#">Course Number</a></th> <th class="sorting" role="columnheader"><a href="#">Instructor</a></th> <th class="sorting" role="columnheader"><a href="#">Schedule</a></th> </tr> </thead> <tbody> @if (Model == null) { <tr> <td colspan="4">no results</td> </tr> } else { foreach (var item in Model) { Html.AntiForgeryToken(); <tr class="clickableRow" onclick="location.href='@Url.Action("InstructorCourseDetailView", "Instructor")'"> <td>@Html.Encode(item.courseName)</td> <td>@Html.Encode(item.courseNumber)</td> <td>@Html.Encode(item.courseInstructor)</td> <td>@Html.Encode(item.courseSchedule)</td> </tr> } } <tr> <td colspan="4"> <button class="btn btn-default" onclick="location.href='@Url.Action("AdminAddCourseView","Admin")'">Add Course</button> </td> </tr> </tbody> </table> </div> </div> </div> </div> <div class="row-fluid"> <div class="span12"> <div class="previous-next-bar"> <button type="submit" class="btn btn-default" onclick="location.href='@Url.Action("AdminHome","Admin")'">Return</button> </div> </div> </div> </div> </div> </div> I've looked everywhere including a bunch of questions on this site and cannot find anything that has helped me in this situation. I'm new to coding, this is the training application I'm doing for my new job and any help would be appreciated!
0debug
IntelliJ IDEA - Fold for loop and/or if/else statements : <p>I'd love to have a way of IntelliJ letting me fold <code>for</code> loops and <code>if/else</code> statements. But, I can't seem to find a way to do it automatically. I know you can use the <code>//region</code> and <code>//endregion</code> comments, or that you can do it manually with Ctrl+Shift+period, but is there a way to avoid all that and have it fold like methods or classes, without doing all that other stuff?</p>
0debug
How to start iteration from specific item? : Suppose that inside a `List<Contact>` named `contacts` I want start the iteration by the contact that have the property `Selected` to true. This is the structure of `Contact`: public class Contact { public string Name { get; set; } public bool Selected { get; set; } } now inside the list I have three contacts, one of these have the property `Selected` true, when I start the iteration: foreach(contact in contacts) I want that the first item in iteration is the contact with property setted to true. How can I do that? Thanks.
0debug
One activity and one layout with different content : This might be an example of how I want it : Click on one of these items in the list view : http://imgur.com/a/bhWhR And get content (content differs based on click on list view) in an activity (same layout) : http://imgur.com/a/agGma I did explore for quite some time and I could not find any solution that helped me .
0debug
how to create custom data table directive using JavaScript and Angularjs : Right now i am using **ng-datatable** for displaying data in table but i want to write **custom directive** to display data in table grid.
0debug
Reinterpreting a union to a different union : <p>I have a standard-layout union that has a whole bunch of types in it:</p> <pre><code>union Big { Hdr h; A a; B b; C c; D d; E e; F f; }; </code></pre> <p>Each of the types <code>A</code> thru <code>F</code> is standard-layout and has as its first member an object of type <code>Hdr</code>. The <code>Hdr</code> identifies what the active member of the union is, so this is variant-like. Now, I'm in a situation where I know for certain (because I checked) that the active member is either a <code>B</code> or a <code>C</code>. Effectively, I've reduced the space to:</p> <pre><code>union Little { Hdr h; B b; C c; }; </code></pre> <p>Now, is the following well-defined or undefined behavior?</p> <pre><code>void given_big(Big const&amp; big) { switch(big.h.type) { case B::type: // fallthrough case C::type: given_b_or_c(reinterpret_cast&lt;Little const&amp;&gt;(big)); break; // ... other cases here ... } } void given_b_or_c(Little const&amp; little) { if (little.h.type == B::type) { use_a_b(little.b); } else { use_a_c(little.c); } } </code></pre> <p>The goal of <code>Little</code> is to effectively serve as documentation, that I've already checked that it's a <code>B</code> or <code>C</code> so in the future nobody adds code to check that it's an <code>A</code> or something. </p> <p>Is the fact that I am reading the <code>B</code> subobject as a <code>B</code> enough to make this well-formed? Can the common initial sequence rule meaningfully be used here?</p>
0debug
Hyperlinking text in a ggplot2 visualization : <p>Currently if I want to show data in a table in R I can hyperlink text via markdown, html href, or LaTeX href. This is often nice for giving access to more info about a particular element w/o cluttering the table. </p> <p><strong>How is it possible to give the same kinds of hyperlinked text in a visualization made with ggplot2?</strong></p> <p>So for example if I make this plot:</p> <p><a href="https://i.stack.imgur.com/i8oHm.png"><img src="https://i.stack.imgur.com/i8oHm.png" alt="enter image description here"></a></p> <p>With the code below, how can I make the axis text hyperlink to the wikipedia pages that correspond?</p> <pre><code>library(tidyverse) mtcars %&gt;% rownames_to_column('car') %&gt;% slice(5:8) %&gt;% mutate( link = c( 'https://de.wikipedia.org/wiki/AMC_Hornet', 'https://en.wikipedia.org/wiki/Plymouth_Valiant', 'https://en.wikipedia.org/wiki/Plymouth_Duster', 'https://en.wikipedia.org/wiki/Mercedes-Benz_W123' ) ) %&gt;% ggplot(aes(x = mpg, y = car)) + geom_point(size = 2) </code></pre>
0debug
static int blk_mig_save_dirty_block(QEMUFile *f, int is_async) { BlkMigDevState *bmds; int ret = 1; QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { ret = mig_save_device_dirty(f, bmds, is_async); if (ret <= 0) { break; } } return ret; }
1threat
static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, MemTxAttrs attrs) { ARMCPU *cpu = s->cpu; switch (offset) { case 0x380 ... 0x3bf: { int startvec = 32 * (offset - 0x380) + NVIC_FIRST_IRQ; int i; if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { break; } for (i = 0; i < 32 && startvec + i < s->num_irq; i++) { s->itns[startvec + i] = (value >> i) & 1; } nvic_irq_update(s); break; } case 0xd04: if (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) { if (value & (1 << 31)) { armv7m_nvic_set_pending(s, ARMV7M_EXCP_NMI, false); } else if (value & (1 << 30) && arm_feature(&cpu->env, ARM_FEATURE_V8)) { armv7m_nvic_clear_pending(s, ARMV7M_EXCP_NMI, false); } } if (value & (1 << 28)) { armv7m_nvic_set_pending(s, ARMV7M_EXCP_PENDSV, attrs.secure); } else if (value & (1 << 27)) { armv7m_nvic_clear_pending(s, ARMV7M_EXCP_PENDSV, attrs.secure); } if (value & (1 << 26)) { armv7m_nvic_set_pending(s, ARMV7M_EXCP_SYSTICK, attrs.secure); } else if (value & (1 << 25)) { armv7m_nvic_clear_pending(s, ARMV7M_EXCP_SYSTICK, attrs.secure); } break; case 0xd08: cpu->env.v7m.vecbase[attrs.secure] = value & 0xffffff80; break; case 0xd0c: if ((value >> R_V7M_AIRCR_VECTKEY_SHIFT) == 0x05fa) { if (value & R_V7M_AIRCR_SYSRESETREQ_MASK) { if (attrs.secure || !(cpu->env.v7m.aircr & R_V7M_AIRCR_SYSRESETREQS_MASK)) { qemu_irq_pulse(s->sysresetreq); } } if (value & R_V7M_AIRCR_VECTCLRACTIVE_MASK) { qemu_log_mask(LOG_GUEST_ERROR, "Setting VECTCLRACTIVE when not in DEBUG mode " "is UNPREDICTABLE\n"); } if (value & R_V7M_AIRCR_VECTRESET_MASK) { qemu_log_mask(LOG_GUEST_ERROR, "Setting VECTRESET when not in DEBUG mode " "is UNPREDICTABLE\n"); } s->prigroup[attrs.secure] = extract32(value, R_V7M_AIRCR_PRIGROUP_SHIFT, R_V7M_AIRCR_PRIGROUP_LENGTH); if (attrs.secure) { cpu->env.v7m.aircr = value & (R_V7M_AIRCR_SYSRESETREQS_MASK | R_V7M_AIRCR_BFHFNMINS_MASK | R_V7M_AIRCR_PRIS_MASK); if (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) { s->sec_vectors[ARMV7M_EXCP_HARD].prio = -3; s->vectors[ARMV7M_EXCP_HARD].enabled = 1; } else { s->sec_vectors[ARMV7M_EXCP_HARD].prio = -1; s->vectors[ARMV7M_EXCP_HARD].enabled = 0; } } nvic_irq_update(s); } break; case 0xd10: qemu_log_mask(LOG_UNIMP, "NVIC: SCR unimplemented\n"); break; case 0xd14: value &= (R_V7M_CCR_STKALIGN_MASK | R_V7M_CCR_BFHFNMIGN_MASK | R_V7M_CCR_DIV_0_TRP_MASK | R_V7M_CCR_UNALIGN_TRP_MASK | R_V7M_CCR_USERSETMPEND_MASK | R_V7M_CCR_NONBASETHRDENA_MASK); if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { value |= R_V7M_CCR_NONBASETHRDENA_MASK | R_V7M_CCR_STKALIGN_MASK; } if (attrs.secure) { cpu->env.v7m.ccr[M_REG_NS] = (cpu->env.v7m.ccr[M_REG_NS] & ~R_V7M_CCR_BFHFNMIGN_MASK) | (value & R_V7M_CCR_BFHFNMIGN_MASK); value &= ~R_V7M_CCR_BFHFNMIGN_MASK; } cpu->env.v7m.ccr[attrs.secure] = value; break; case 0xd24: if (attrs.secure) { s->sec_vectors[ARMV7M_EXCP_MEM].active = (value & (1 << 0)) != 0; s->sec_vectors[ARMV7M_EXCP_USAGE].active = (value & (1 << 3)) != 0; s->sec_vectors[ARMV7M_EXCP_SVC].active = (value & (1 << 7)) != 0; s->sec_vectors[ARMV7M_EXCP_PENDSV].active = (value & (1 << 10)) != 0; s->sec_vectors[ARMV7M_EXCP_SYSTICK].active = (value & (1 << 11)) != 0; s->sec_vectors[ARMV7M_EXCP_USAGE].pending = (value & (1 << 12)) != 0; s->sec_vectors[ARMV7M_EXCP_MEM].pending = (value & (1 << 13)) != 0; s->sec_vectors[ARMV7M_EXCP_SVC].pending = (value & (1 << 15)) != 0; s->sec_vectors[ARMV7M_EXCP_MEM].enabled = (value & (1 << 16)) != 0; s->sec_vectors[ARMV7M_EXCP_BUS].enabled = (value & (1 << 17)) != 0; s->sec_vectors[ARMV7M_EXCP_USAGE].enabled = (value & (1 << 18)) != 0; s->sec_vectors[ARMV7M_EXCP_HARD].pending = (value & (1 << 21)) != 0; s->vectors[ARMV7M_EXCP_SECURE].active = (value & (1 << 4)) != 0; s->vectors[ARMV7M_EXCP_SECURE].enabled = (value & (1 << 19)) != 0; s->vectors[ARMV7M_EXCP_SECURE].pending = (value & (1 << 20)) != 0; } else { s->vectors[ARMV7M_EXCP_MEM].active = (value & (1 << 0)) != 0; if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { s->vectors[ARMV7M_EXCP_HARD].pending = (value & (1 << 21)) != 0; } s->vectors[ARMV7M_EXCP_USAGE].active = (value & (1 << 3)) != 0; s->vectors[ARMV7M_EXCP_SVC].active = (value & (1 << 7)) != 0; s->vectors[ARMV7M_EXCP_PENDSV].active = (value & (1 << 10)) != 0; s->vectors[ARMV7M_EXCP_SYSTICK].active = (value & (1 << 11)) != 0; s->vectors[ARMV7M_EXCP_USAGE].pending = (value & (1 << 12)) != 0; s->vectors[ARMV7M_EXCP_MEM].pending = (value & (1 << 13)) != 0; s->vectors[ARMV7M_EXCP_SVC].pending = (value & (1 << 15)) != 0; s->vectors[ARMV7M_EXCP_MEM].enabled = (value & (1 << 16)) != 0; s->vectors[ARMV7M_EXCP_USAGE].enabled = (value & (1 << 18)) != 0; } if (attrs.secure || (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { s->vectors[ARMV7M_EXCP_BUS].active = (value & (1 << 1)) != 0; s->vectors[ARMV7M_EXCP_BUS].pending = (value & (1 << 14)) != 0; s->vectors[ARMV7M_EXCP_BUS].enabled = (value & (1 << 17)) != 0; } if (!attrs.secure && cpu->env.v7m.secure && (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) && (value & (1 << 5)) == 0) { s->vectors[ARMV7M_EXCP_NMI].active = 0; } if (!attrs.secure && cpu->env.v7m.secure && (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) && (value & (1 << 2)) == 0) { s->vectors[ARMV7M_EXCP_HARD].active = 0; } s->vectors[ARMV7M_EXCP_DEBUG].active = (value & (1 << 8)) != 0; nvic_irq_update(s); break; case 0xd28: cpu->env.v7m.cfsr[attrs.secure] &= ~value; if (attrs.secure) { cpu->env.v7m.cfsr[M_REG_NS] &= ~(value & R_V7M_CFSR_BFSR_MASK); } break; case 0xd2c: cpu->env.v7m.hfsr &= ~value; break; case 0xd30: cpu->env.v7m.dfsr &= ~value; break; case 0xd34: cpu->env.v7m.mmfar[attrs.secure] = value; return; case 0xd38: cpu->env.v7m.bfar = value; return; case 0xd3c: qemu_log_mask(LOG_UNIMP, "NVIC: Aux fault status registers unimplemented\n"); break; case 0xd90: return; case 0xd94: if ((value & (R_V7M_MPU_CTRL_HFNMIENA_MASK | R_V7M_MPU_CTRL_ENABLE_MASK)) == R_V7M_MPU_CTRL_HFNMIENA_MASK) { qemu_log_mask(LOG_GUEST_ERROR, "MPU_CTRL: HFNMIENA and !ENABLE is " "UNPREDICTABLE\n"); } cpu->env.v7m.mpu_ctrl[attrs.secure] = value & (R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK | R_V7M_MPU_CTRL_PRIVDEFENA_MASK); tlb_flush(CPU(cpu)); break; case 0xd98: if (value >= cpu->pmsav7_dregion) { qemu_log_mask(LOG_GUEST_ERROR, "MPU region out of range %" PRIu32 "/%" PRIu32 "\n", value, cpu->pmsav7_dregion); } else { cpu->env.pmsav7.rnr[attrs.secure] = value; } break; case 0xd9c: case 0xda4: case 0xdac: case 0xdb4: { int region; if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { int aliasno = (offset - 0xd9c) / 8; region = cpu->env.pmsav7.rnr[attrs.secure]; if (aliasno) { region = deposit32(region, 0, 2, aliasno); } if (region >= cpu->pmsav7_dregion) { return; } cpu->env.pmsav8.rbar[attrs.secure][region] = value; tlb_flush(CPU(cpu)); return; } if (value & (1 << 4)) { region = extract32(value, 0, 4); if (region >= cpu->pmsav7_dregion) { qemu_log_mask(LOG_GUEST_ERROR, "MPU region out of range %u/%" PRIu32 "\n", region, cpu->pmsav7_dregion); return; } cpu->env.pmsav7.rnr[attrs.secure] = region; } else { region = cpu->env.pmsav7.rnr[attrs.secure]; } if (region >= cpu->pmsav7_dregion) { return; } cpu->env.pmsav7.drbar[region] = value & ~0x1f; tlb_flush(CPU(cpu)); break; } case 0xda0: case 0xda8: case 0xdb0: case 0xdb8: { int region = cpu->env.pmsav7.rnr[attrs.secure]; if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { int aliasno = (offset - 0xd9c) / 8; region = cpu->env.pmsav7.rnr[attrs.secure]; if (aliasno) { region = deposit32(region, 0, 2, aliasno); } if (region >= cpu->pmsav7_dregion) { return; } cpu->env.pmsav8.rlar[attrs.secure][region] = value; tlb_flush(CPU(cpu)); return; } if (region >= cpu->pmsav7_dregion) { return; } cpu->env.pmsav7.drsr[region] = value & 0xff3f; cpu->env.pmsav7.dracr[region] = (value >> 16) & 0x173f; tlb_flush(CPU(cpu)); break; } case 0xdc0: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (cpu->pmsav7_dregion) { cpu->env.pmsav8.mair0[attrs.secure] = value; } break; case 0xdc4: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (cpu->pmsav7_dregion) { cpu->env.pmsav8.mair1[attrs.secure] = value; } break; case 0xdd0: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return; } cpu->env.sau.ctrl = value & 3; break; case 0xdd4: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } break; case 0xdd8: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return; } if (value >= cpu->sau_sregion) { qemu_log_mask(LOG_GUEST_ERROR, "SAU region out of range %" PRIu32 "/%" PRIu32 "\n", value, cpu->sau_sregion); } else { cpu->env.sau.rnr = value; } break; case 0xddc: { int region = cpu->env.sau.rnr; if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return; } if (region >= cpu->sau_sregion) { return; } cpu->env.sau.rbar[region] = value & ~0x1f; tlb_flush(CPU(cpu)); break; } case 0xde0: { int region = cpu->env.sau.rnr; if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return; } if (region >= cpu->sau_sregion) { return; } cpu->env.sau.rlar[region] = value & ~0x1c; tlb_flush(CPU(cpu)); break; } case 0xde4: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return; } cpu->env.v7m.sfsr &= ~value; break; case 0xde8: if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } if (!attrs.secure) { return; } cpu->env.v7m.sfsr = value; break; case 0xf00: { int excnum = (value & 0x1ff) + NVIC_FIRST_IRQ; if (excnum < s->num_irq) { armv7m_nvic_set_pending(s, excnum, false); } break; } default: bad_offset: qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad write offset 0x%x\n", offset); } }
1threat