problem
stringlengths
26
131k
labels
class label
2 classes
static always_inline int get_bat (CPUState *env, mmu_ctx_t *ctx, target_ulong virtual, int rw, int type) { target_ulong *BATlt, *BATut, *BATu, *BATl; target_ulong base, BEPIl, BEPIu, bl; int i, pp, pr; int ret = -1; #if defined (DEBUG_BATS) if (loglevel != 0) { fprintf(logfile, "%s: %cBAT v 0x" ADDRX "\n", __func__, type == ACCESS_CODE ? 'I' : 'D', virtual); } #endif pr = msr_pr; switch (type) { case ACCESS_CODE: BATlt = env->IBAT[1]; BATut = env->IBAT[0]; break; default: BATlt = env->DBAT[1]; BATut = env->DBAT[0]; break; } #if defined (DEBUG_BATS) if (loglevel != 0) { fprintf(logfile, "%s...: %cBAT v 0x" ADDRX "\n", __func__, type == ACCESS_CODE ? 'I' : 'D', virtual); } #endif base = virtual & 0xFFFC0000; for (i = 0; i < 4; i++) { BATu = &BATut[i]; BATl = &BATlt[i]; BEPIu = *BATu & 0xF0000000; BEPIl = *BATu & 0x0FFE0000; bl = (*BATu & 0x00001FFC) << 15; #if defined (DEBUG_BATS) if (loglevel != 0) { fprintf(logfile, "%s: %cBAT%d v 0x" ADDRX " BATu 0x" ADDRX " BATl 0x" ADDRX "\n", __func__, type == ACCESS_CODE ? 'I' : 'D', i, virtual, *BATu, *BATl); } #endif if ((virtual & 0xF0000000) == BEPIu && ((virtual & 0x0FFE0000) & ~bl) == BEPIl) { if (((pr == 0) && (*BATu & 0x00000002)) || ((pr != 0) && (*BATu & 0x00000001))) { ctx->raddr = (*BATl & 0xF0000000) | ((virtual & 0x0FFE0000 & bl) | (*BATl & 0x0FFE0000)) | (virtual & 0x0001F000); pp = *BATl & 0x00000003; ctx->prot = 0; if (pp != 0) { ctx->prot = PAGE_READ | PAGE_EXEC; if (pp == 0x2) ctx->prot |= PAGE_WRITE; } ret = check_prot(ctx->prot, rw, type); #if defined (DEBUG_BATS) if (ret == 0 && loglevel != 0) { fprintf(logfile, "BAT %d match: r 0x" PADDRX " prot=%c%c\n", i, ctx->raddr, ctx->prot & PAGE_READ ? 'R' : '-', ctx->prot & PAGE_WRITE ? 'W' : '-'); } #endif break; } } } if (ret < 0) { #if defined (DEBUG_BATS) if (loglevel != 0) { fprintf(logfile, "no BAT match for 0x" ADDRX ":\n", virtual); for (i = 0; i < 4; i++) { BATu = &BATut[i]; BATl = &BATlt[i]; BEPIu = *BATu & 0xF0000000; BEPIl = *BATu & 0x0FFE0000; bl = (*BATu & 0x00001FFC) << 15; fprintf(logfile, "%s: %cBAT%d v 0x" ADDRX " BATu 0x" ADDRX " BATl 0x" ADDRX " \n\t" "0x" ADDRX " 0x" ADDRX " 0x" ADDRX "\n", __func__, type == ACCESS_CODE ? 'I' : 'D', i, virtual, *BATu, *BATl, BEPIu, BEPIl, bl); } } #endif } return ret; }
1threat
Why are we able to compare vector element with string element without initializing the vector? How does it work? : #include<bits/stdc++.h> using namespace std; int main() ` { int t; cin>>t; while(t--) { string x; cin>>x; vector<char> a; for(int i=0;i<x.length();i++) { int f=0; for(int j=0;j<a.size();j++) { if(a[j]==x.at(i)) { f=1; break; } } if(f==0) a.push_back(x.at(i)); } if(a.size()==2) cout<<"YES\n"; else cout<<"NO\n"; } return 0; }
0debug
static GenericList *qobject_input_next_list(Visitor *v, GenericList *tail, size_t size) { QObjectInputVisitor *qiv = to_qiv(v); StackObject *so = QSLIST_FIRST(&qiv->stack); if (!so->entry) { return NULL; } tail->next = g_malloc0(size); return tail->next; }
1threat
library in C11 or C99 good practice : <p>What is better idea: write library which will be used by others in C11 or C99? Is it good justification that many people rather use C99 in theis project than C11 or it's not true? And what is better for microcontrollers? I am not professional and I want to have good excuse to not use generic C11 :P Thank you for your help. I hope it's not 'silly' question.</p>
0debug
Deleteall character from filename before the last underscore _ : Ho to delete all characters up to and including the last underscore `_` before the `.ext` from all filenames recursive in the CWD? Is this best done by split and replace or regex (`^[^_]+_` ?)? The code below does not work (no erros msg.) aaa_bbb_000_xxx.txt ---> xxx.txt __abc123_zzzz.txt ---> zzzz.txt 111222.txt ---> 111222.txt Code: import os cwd = os.getcwd() paths = (os.path.join(cwd, filename) for cwd, _, filenames in os.walk('cwd') for filename in filenames) for path in paths: newname = path.replace(^[^_]+_) if newname != path: os.rename(path, newname)
0debug
How to use forEach in vueJs? : <p>I have a response like below from an API call,</p> <p><a href="https://i.stack.imgur.com/lMr5I.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lMr5I.png" alt="response"></a></p> <p>Now, I have to repeat the whole arrays inside the arrays. How do I do that in VueJS?</p> <p>I have searched for using forEach.. nowhere I found forEach usage like key|value pair.</p> <p>Can anyone help me on how to fetch the values from that arrays by using either forEach or any else(VueJS)?</p> <p>Thanks &amp; Regards,</p>
0debug
Android how can i check if calendar date has been selected : I am making a task manager application where I require the following details:- name (string), description (string), date (long) and importance (int). I am currently stuck on figuring out how to get date and also see if date from calendarView has been selected. TextView name, description, importance; CalendarView calendar; Button submit; ArrayList<Task> myTasks = new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create_task); name = (TextView)findViewById(R.id.CreateTaskNameET); description = (TextView)findViewById(R.id.CreateTaskDescriptionET); importance = (TextView)findViewById(R.id.CreateTaskImportanceET); calendar = (CalendarView) findViewById(R.id.CreateTaskCalender); submit = (Button)findViewById(R.id.CreateTaskSubmitBtn); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Task myTask = new Task(name.getText().toString(), description.getText().toString(), calendar.getDate(), Integer.parseInt(importance.getText().toString())); myTasks.add(myTask); } }); } public void validateRule(EditText name, EditText description, CalendarView calendar, EditText importance){ if(name.getText().equals("")){ } else if(description.getText().equals("")){ } else if(calendar.getDate()){ } } Once again, how can i determine if the date has been selected as it's one of my validation rule. Thanks
0debug
How to write Repository method for .ThenInclude in EF Core 2 : <p>I'm trying to write a repository method for Entity Framework Core 2.0 that can handle returning child collections of properties using .ThenInclude, but I'm having trouble with the second expression. Here is a working method for .Include, which will return child properties (you supply a list of lambdas) of your entity.</p> <pre><code>public T GetSingle(Expression&lt;Func&lt;T, bool&gt;&gt; predicate, params Expression&lt;Func&lt;T, object&gt;&gt;[] includeProperties) { IQueryable&lt;T&gt; query = _context.Set&lt;T&gt;(); foreach (var includeProperty in includeProperties) { query = query.Include(includeProperty); } return query.Where(predicate).FirstOrDefault(); } </code></pre> <p>Now here is my attempt at writing a method that will take a Tuple of two Expressions and feed those into a .Include(a => a.someChild).ThenInclude(b => b.aChildOfSomeChild) chain. This isn't a perfect solution because it only handles one child of a child, but it's a start. </p> <pre><code>public T GetSingle(Expression&lt;Func&lt;T, bool&gt;&gt; predicate, params Tuple&lt;Expression&lt;Func&lt;T, object&gt;&gt;, Expression&lt;Func&lt;T, object&gt;&gt;&gt;[] includeProperties) { IQueryable&lt;T&gt; query = _context.Set&lt;T&gt;(); foreach (var includeProperty in includeProperties) { query = query.Include(includeProperty.Item1).ThenInclude(includeProperty.Item2); } return query.Where(predicate).FirstOrDefault(); } </code></pre> <p>Intellisense returns an error saying "The type cannot be inferred from the usage, try specifying the type explicitly". I have a feeling it's because the expression in Item2 needs to be classified as somehow related to Item1, because it needs to know about the child relationship it has. </p> <p>Any ideas or better techniques for writing a method like this? </p>
0debug
Why I can't get javascript values into my php5 code? : <p>I have this code: </p> <pre><code>&lt;?php $html=file_get_contents('testmaker_html.html'); echo $html; ?&gt; &lt;script type="text/javascript"&gt; document.getElementById('save_finaly_TEST').addEventListener("click", function(){ cover = document.getElementById('cover').value; keywords = document.getElementById('keywords').value.split(","); notificationAboutElement = "Ok!"; notifyMe(notificationAboutElement); html_saver(); &lt;?php $test_html = "&lt;script&gt;document.write(html)&lt;/script&gt;"?&gt; }); &lt;/script&gt; &lt;?php $new_test = rand().".html"; $myfile = fopen($new_test, "w") or die("Unable to create file!"); write($myfile, $test_html) or die("Can't write to file"); fclose($myfile) or die("Can't close the file!"); echo $new_test; ?&gt; &lt;script type="text/javascript"&gt; console.log("$test_html: " + &lt;?php echo $test_html; ?&gt;); console.log("$new_test: " + &lt;?php echo $new_test; ?&gt;); &lt;/script&gt; </code></pre> <p>Why is <code>$test_html</code> empty? I know the php and javascript is not on same server but this methodd to get values many times worked for many people. Than what can be wrong with this?</p>
0debug
static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma, uint64_t offset, uint64_t len) { RDMALocalBlock *block = &(rdma->local_ram_blocks.block[rdma->current_index]); uint8_t *host_addr = block->local_host_addr + (offset - block->offset); uint8_t *chunk_end = ram_chunk_end(block, rdma->current_chunk); if (rdma->current_length == 0) { return 0; } if (offset != (rdma->current_addr + rdma->current_length)) { return 0; } if (rdma->current_index < 0) { return 0; } if (offset < block->offset) { return 0; } if ((offset + len) > (block->offset + block->length)) { return 0; } if (rdma->current_chunk < 0) { return 0; } if ((host_addr + len) > chunk_end) { return 0; } return 1; }
1threat
how can I run wordpress on GCP cloud run? : according to GCP https://cloud.google.com/wordpress/ but so far cloud run i the best option for no teche person however in order to run cloud run wordpresss must be on a container. using the vM with bitnami wordpress still need some kind technicals and management which don't want to deal with. on the other hand wordpress n App engine standard is doing similar job cloud run with some differences. wordpress app engine vs wordpress cloud run? and if cloud run is much better. how?
0debug
Removing duplicates with unique index : <p>I inserted between two tables fields A,B,C,D, believing I had created a Unique Index on A,B,C,D to prevent duplicates. However I somehow simply made a normal index on those. So duplicates got inserted. It is 20 million record table.</p> <p>If I change my existing index from normal to unique or simply a add a new unique index for A,B,C,D will the duplicates be removed or will adding fail since unique records exist? I'd test it yet it is 30 mil records and I neither wish to mess the table up or duplicate it.</p>
0debug
AWS API Gateway ARN : <p>One of the things that drives me nuts is that AWS has loads of docs about the format of an ARN, but doesn't have any kind of generator to make you confident that the ARN is correct.</p> <p>In IAM, I'm trying to set up a policy to allow access to an API Gateway and I've read the following docs about it:</p> <ul> <li><a href="http://docs.aws.amazon.com/apigateway/latest/developerguide/permissions.html#api-gateway-control-access-using-iam-policies" rel="noreferrer">http://docs.aws.amazon.com/apigateway/latest/developerguide/permissions.html#api-gateway-control-access-using-iam-policies</a></li> <li><a href="http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-apigateway" rel="noreferrer">http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-apigateway</a></li> <li><a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.iam.policies.arn.html" rel="noreferrer">http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.iam.policies.arn.html</a></li> </ul> <p>But I can't get any ARN to validate, even just a wide open API Gateway ARN. See screenshot:</p> <p><a href="https://i.stack.imgur.com/sO02S.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sO02S.png" alt="open arn called invalid"></a></p> <p>What am I doing wrong here?</p>
0debug
static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, const int *const_args) { int c; switch (opc) { case INDEX_op_exit_tb: { uint8_t *ld_ptr = s->code_ptr; if (args[0] >> 8) tcg_out_ld32_12(s, COND_AL, TCG_REG_R0, TCG_REG_PC, 0); else tcg_out_dat_imm(s, COND_AL, ARITH_MOV, TCG_REG_R0, 0, args[0]); tcg_out_goto(s, COND_AL, (tcg_target_ulong) tb_ret_addr); if (args[0] >> 8) { *ld_ptr = (uint8_t) (s->code_ptr - ld_ptr) - 8; tcg_out32(s, args[0]); } } break; case INDEX_op_goto_tb: if (s->tb_jmp_offset) { #if defined(USE_DIRECT_JUMP) s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; tcg_out_b_noaddr(s, COND_AL); #else tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_PC, -4); s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; tcg_out32(s, 0); #endif } else { #if 1 c = (int) (s->tb_next + args[0]) - ((int) s->code_ptr + 8); if (c > 0xfff || c < -0xfff) { tcg_out_movi32(s, COND_AL, TCG_REG_R0, (tcg_target_long) (s->tb_next + args[0])); tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_R0, 0); } else tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_PC, c); #else tcg_out_ld32_12(s, COND_AL, TCG_REG_R0, TCG_REG_PC, 0); tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_R0, 0); tcg_out32(s, (tcg_target_long) (s->tb_next + args[0])); #endif } s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf; break; case INDEX_op_call: if (const_args[0]) tcg_out_call(s, args[0]); else tcg_out_callr(s, COND_AL, args[0]); break; case INDEX_op_br: tcg_out_goto_label(s, COND_AL, args[0]); break; case INDEX_op_ld8u_i32: tcg_out_ld8u(s, COND_AL, args[0], args[1], args[2]); break; case INDEX_op_ld8s_i32: tcg_out_ld8s(s, COND_AL, args[0], args[1], args[2]); break; case INDEX_op_ld16u_i32: tcg_out_ld16u(s, COND_AL, args[0], args[1], args[2]); break; case INDEX_op_ld16s_i32: tcg_out_ld16s(s, COND_AL, args[0], args[1], args[2]); break; case INDEX_op_ld_i32: tcg_out_ld32u(s, COND_AL, args[0], args[1], args[2]); break; case INDEX_op_st8_i32: tcg_out_st8(s, COND_AL, args[0], args[1], args[2]); break; case INDEX_op_st16_i32: tcg_out_st16(s, COND_AL, args[0], args[1], args[2]); break; case INDEX_op_st_i32: tcg_out_st32(s, COND_AL, args[0], args[1], args[2]); break; case INDEX_op_mov_i32: tcg_out_dat_reg(s, COND_AL, ARITH_MOV, args[0], 0, args[1], SHIFT_IMM_LSL(0)); break; case INDEX_op_movi_i32: tcg_out_movi32(s, COND_AL, args[0], args[1]); break; case INDEX_op_movcond_i32: tcg_out_dat_rI(s, COND_AL, ARITH_CMP, 0, args[1], args[2], const_args[2]); tcg_out_dat_rI(s, tcg_cond_to_arm_cond[args[5]], ARITH_MOV, args[0], 0, args[3], const_args[3]); break; case INDEX_op_add_i32: c = ARITH_ADD; goto gen_arith; case INDEX_op_sub_i32: c = ARITH_SUB; goto gen_arith; case INDEX_op_and_i32: tcg_out_dat_rIK(s, COND_AL, ARITH_AND, ARITH_BIC, args[0], args[1], args[2], const_args[2]); break; case INDEX_op_andc_i32: tcg_out_dat_rIK(s, COND_AL, ARITH_BIC, ARITH_AND, args[0], args[1], args[2], const_args[2]); break; case INDEX_op_or_i32: c = ARITH_ORR; goto gen_arith; case INDEX_op_xor_i32: c = ARITH_EOR; gen_arith: tcg_out_dat_rI(s, COND_AL, c, args[0], args[1], args[2], const_args[2]); break; case INDEX_op_add2_i32: tcg_out_dat_reg2(s, COND_AL, ARITH_ADD, ARITH_ADC, args[0], args[1], args[2], args[3], args[4], args[5], SHIFT_IMM_LSL(0)); break; case INDEX_op_sub2_i32: tcg_out_dat_reg2(s, COND_AL, ARITH_SUB, ARITH_SBC, args[0], args[1], args[2], args[3], args[4], args[5], SHIFT_IMM_LSL(0)); break; case INDEX_op_neg_i32: tcg_out_dat_imm(s, COND_AL, ARITH_RSB, args[0], args[1], 0); break; case INDEX_op_not_i32: tcg_out_dat_reg(s, COND_AL, ARITH_MVN, args[0], 0, args[1], SHIFT_IMM_LSL(0)); break; case INDEX_op_mul_i32: tcg_out_mul32(s, COND_AL, args[0], args[1], args[2]); break; case INDEX_op_mulu2_i32: tcg_out_umull32(s, COND_AL, args[0], args[1], args[2], args[3]); break; case INDEX_op_muls2_i32: tcg_out_smull32(s, COND_AL, args[0], args[1], args[2], args[3]); break; case INDEX_op_shl_i32: c = const_args[2] ? SHIFT_IMM_LSL(args[2] & 0x1f) : SHIFT_REG_LSL(args[2]); goto gen_shift32; case INDEX_op_shr_i32: c = const_args[2] ? (args[2] & 0x1f) ? SHIFT_IMM_LSR(args[2] & 0x1f) : SHIFT_IMM_LSL(0) : SHIFT_REG_LSR(args[2]); goto gen_shift32; case INDEX_op_sar_i32: c = const_args[2] ? (args[2] & 0x1f) ? SHIFT_IMM_ASR(args[2] & 0x1f) : SHIFT_IMM_LSL(0) : SHIFT_REG_ASR(args[2]); goto gen_shift32; case INDEX_op_rotr_i32: c = const_args[2] ? (args[2] & 0x1f) ? SHIFT_IMM_ROR(args[2] & 0x1f) : SHIFT_IMM_LSL(0) : SHIFT_REG_ROR(args[2]); gen_shift32: tcg_out_dat_reg(s, COND_AL, ARITH_MOV, args[0], 0, args[1], c); break; case INDEX_op_rotl_i32: if (const_args[2]) { tcg_out_dat_reg(s, COND_AL, ARITH_MOV, args[0], 0, args[1], ((0x20 - args[2]) & 0x1f) ? SHIFT_IMM_ROR((0x20 - args[2]) & 0x1f) : SHIFT_IMM_LSL(0)); } else { tcg_out_dat_imm(s, COND_AL, ARITH_RSB, TCG_REG_R8, args[1], 0x20); tcg_out_dat_reg(s, COND_AL, ARITH_MOV, args[0], 0, args[1], SHIFT_REG_ROR(TCG_REG_R8)); } break; case INDEX_op_brcond_i32: tcg_out_dat_rI(s, COND_AL, ARITH_CMP, 0, args[0], args[1], const_args[1]); tcg_out_goto_label(s, tcg_cond_to_arm_cond[args[2]], args[3]); break; case INDEX_op_brcond2_i32: tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, args[1], args[3], SHIFT_IMM_LSL(0)); tcg_out_dat_reg(s, COND_EQ, ARITH_CMP, 0, args[0], args[2], SHIFT_IMM_LSL(0)); tcg_out_goto_label(s, tcg_cond_to_arm_cond[args[4]], args[5]); break; case INDEX_op_setcond_i32: tcg_out_dat_rI(s, COND_AL, ARITH_CMP, 0, args[1], args[2], const_args[2]); tcg_out_dat_imm(s, tcg_cond_to_arm_cond[args[3]], ARITH_MOV, args[0], 0, 1); tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(args[3])], ARITH_MOV, args[0], 0, 0); break; case INDEX_op_setcond2_i32: tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, args[2], args[4], SHIFT_IMM_LSL(0)); tcg_out_dat_reg(s, COND_EQ, ARITH_CMP, 0, args[1], args[3], SHIFT_IMM_LSL(0)); tcg_out_dat_imm(s, tcg_cond_to_arm_cond[args[5]], ARITH_MOV, args[0], 0, 1); tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(args[5])], ARITH_MOV, args[0], 0, 0); break; case INDEX_op_qemu_ld8u: tcg_out_qemu_ld(s, args, 0); break; case INDEX_op_qemu_ld8s: tcg_out_qemu_ld(s, args, 0 | 4); break; case INDEX_op_qemu_ld16u: tcg_out_qemu_ld(s, args, 1); break; case INDEX_op_qemu_ld16s: tcg_out_qemu_ld(s, args, 1 | 4); break; case INDEX_op_qemu_ld32: tcg_out_qemu_ld(s, args, 2); break; case INDEX_op_qemu_ld64: tcg_out_qemu_ld(s, args, 3); break; case INDEX_op_qemu_st8: tcg_out_qemu_st(s, args, 0); break; case INDEX_op_qemu_st16: tcg_out_qemu_st(s, args, 1); break; case INDEX_op_qemu_st32: tcg_out_qemu_st(s, args, 2); break; case INDEX_op_qemu_st64: tcg_out_qemu_st(s, args, 3); break; case INDEX_op_bswap16_i32: tcg_out_bswap16(s, COND_AL, args[0], args[1]); break; case INDEX_op_bswap32_i32: tcg_out_bswap32(s, COND_AL, args[0], args[1]); break; case INDEX_op_ext8s_i32: tcg_out_ext8s(s, COND_AL, args[0], args[1]); break; case INDEX_op_ext16s_i32: tcg_out_ext16s(s, COND_AL, args[0], args[1]); break; case INDEX_op_ext16u_i32: tcg_out_ext16u(s, COND_AL, args[0], args[1]); break; default: tcg_abort(); } }
1threat
def sum_digits_single(x) : ans = 0 while x : ans += x % 10 x //= 10 return ans def closest(x) : ans = 0 while (ans * 10 + 9 <= x) : ans = ans * 10 + 9 return ans def sum_digits_twoparts(N) : A = closest(N) return sum_digits_single(A) + sum_digits_single(N - A)
0debug
How to create a circle with a number in the center that scales to fit the circle in HTML/CSS? : <p>There are many solutions for numbers in circles, but they use fixed sized. How to style the circle div for it to contain centered text or number of largest possible font to fit the circle?</p>
0debug
using regex to make a number of checks : <p>I am very confused by regex expression checks. I am trying to make several checks on two different strings in php. The first string must be 3-8 characters long, begin with a lowercase letter, and consist entirely of lowercase and the second must be 6-12 characters long, begin with a number, and end with any character that is not a letter or number. So if I had $first = "ttyl45" and $second = "6ttyl56*" These would pass the checks. I just don't know how to go about doing this because regex is very confusing to me I looked all over the internet but I'm still stuck</p>
0debug
lodash pick object fields from array : <p>I have array of objects:</p> <pre><code>var results= [ { "_type": "MyType", "_id": "57623535a44b8f1417740a13", "_source": { "info": { "year": 2010, "number": "string", }, "type": "stolen", "date": "2016-06-16T00:00:00", "createdBy": "57469f3c71c8bf2479d225a6" } } ]; </code></pre> <p>I need to select specific fields from array. In result, I want to get the following:</p> <pre><code>[ { "_id": "57623535a44b8f1417740a13", "info": { "year": 2010, "number": "string" }, "type": "stolen", "date": "2016-06-16T00:00:00", "createdBy": "57469f3c71c8bf2479d225a6" } ] </code></pre> <p>As you can see, I want to select <code>_id</code> field and content of <code>_source</code> object. How can I do this with lodash?</p> <p>I've found <code>.map</code> function, but it doesn't take array of keys: <code> var res = _.map(results, "_source"); </code></p>
0debug
Prevent an exception when I cancel an openfiledialog? : <p>I am having a problem when I click cancel on an openfiledialog in c#, it throws an exception. This is my code:</p> <p>I tried to look at some other Stackoverflow solutions but none of them work. Here is a example:</p> <pre><code>private void BtnCargarImagen_Click(object sender, EventArgs e) { //OFD = openfiledialog OFD.ShowDialog(); PicFotografia.Image = Image.FromFile(OFD.FileName); MessageBox.Show("LA IMAGAN HA SIDO CARGADA"); DialogResult result; if (result == DialogResult.OK) { return OFD.FileName; } return null; </code></pre> <p>When the "if" part is placed on the code, it marks error on both "returns". </p> <p>Without the dialog result part from top to bottom when I click on cancel, it marks an exception.</p> <pre><code>private void BtnCargarImagen_Click(object sender, EventArgs e) { //OFD = openfiledialog OFD.ShowDialog(); PicFotografia.Image = Image.FromFile(OFD.FileName); MessageBox.Show("LA IMAGAN HA SIDO CARGADA"); } </code></pre> <p>Thanks in advance.</p>
0debug
get a php variable in java script function : <p>i have this dropdown list and i need to save it's value by javascript but i can't get the name of the php variable (select name ) into the function</p> <p>drop down list :</p> <pre><code> $i=0; while($i&lt;$counter) { $vname=$row['student_id'].'_'.$i; echo" &lt;td&gt; &lt;select name=".$vname."&gt; &lt;option value="."0"."&gt;Choose one&lt;/option&gt; &lt;option value="."1"."&gt;Add&lt;/option&gt; &lt;option value="."2"."&gt;R&lt;/option&gt; &lt;option value="."3"."&gt;TBR&lt;/option&gt; &lt;option value="."4"."&gt;P&lt;/option&gt; &lt;/select&gt; &lt;/td&gt;"; $i++; } </code></pre> <p>java script function :</p> <pre><code> &lt;script src="https://code.jquery.com/jquery-1.9.1.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function() { var item = window.localStorage.getItem('".$vname."'); $('select[name=".$vname."]').val(item); $('select[name=".$vname."]').change(function() { window.localStorage.setItem('".$vname."', $(this).val()); }); }); &lt;/script&gt; </code></pre>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
Haskell Non-exhaustive patterns : <p>The compiler is telling me that this function has Non-exhaustive patterns, but every scenarios are covered, aren't they? </p> <pre><code>allNeighbors :: Ord v =&gt; Graph v -&gt; [v] -&gt; [v] -&gt; [v] allNeighbors graph (x:xs) neighborsList | length (x:xs) &lt;= 0 = neighborsList | length (x:xs) == 1 = neighborsList ++ (neighbors x graph) | length (x:xs) &gt; 1 = allNeighbors graph xs (neighborsList ++ (neighbors x graph)) </code></pre>
0debug
how to get list of inner class inside a class : I want to know who I can get a list of all the inner classes I have in class of FormStore. Please help me. I am using .net 4.5 and C#. namespace test { public class FormStore { public partial class child1 : Form { } public partial class child2 : Form { } public partial class child3 : Form { } } }
0debug
static int megasas_cache_flush(MegasasState *s, MegasasCmd *cmd) { bdrv_drain_all(); return MFI_STAT_OK; }
1threat
Converting Material UI function to a class : <p>How do I convert a React function to a class? I don't understand how to update <code>const { classes } = props;</code> in a function to class use. Here is a button function from Material UI: <a href="https://material-ui-next.com/demos/buttons/" rel="noreferrer">https://material-ui-next.com/demos/buttons/</a></p> <pre><code>import React from 'react'; import PropTypes from 'prop-types'; import { withStyles } from 'material-ui/styles'; import Button from 'material-ui/Button'; const styles = theme =&gt; ({ button: { margin: theme.spacing.unit, }, input: { display: 'none', }, }); function RaisedButtons(props) { const { classes } = props; return ( &lt;div&gt; &lt;Button variant="raised" className={classes.button}&gt; Default &lt;/Button&gt; &lt;Button variant="raised" color="primary" className={classes.button}&gt; Primary &lt;/Button&gt; &lt;Button variant="raised" color="secondary" className={classes.button}&gt; Secondary &lt;/Button&gt; &lt;Button variant="raised" color="secondary" disabled className={classes.button}&gt; Disabled &lt;/Button&gt; &lt;input accept="image/*" className={classes.input} id="raised-button-file" multiple type="file" /&gt; &lt;label htmlFor="raised-button-file"&gt; &lt;Button variant="raised" component="span" className={classes.button}&gt; Upload &lt;/Button&gt; &lt;/label&gt; &lt;/div&gt; ); } RaisedButtons.propTypes = { classes: PropTypes.object.isRequired, }; export default withStyles(styles)(RaisedButtons); </code></pre> <p>Here is my conversion to a React class component. It currently gives me an error message of <code>'classes' is not defined no-undef</code> since I am missing the classes = props part.</p> <pre><code>import React, { Component } from 'react'; import Button from 'material-ui/Button'; import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; import MyTheme from './MyTheme'; import './App.css'; import { withStyles } from 'material-ui/styles'; import PropTypes from 'prop-types'; const styles = theme =&gt; ({ button: { margin: theme.spacing.unit, }, input: { display: 'none', }, }); class App extends Component { constructor(props) { super(props); } render() { return ( &lt;MuiThemeProvider theme={MyTheme}&gt; &lt;Button variant="raised" &gt; Default &lt;/Button&gt; &lt;Button variant="raised" color="primary" className={classes.button}&gt; Primary &lt;/Button&gt; &lt;Button variant="raised" color="secondary" className={classes.button} &gt; Secondary &lt;/Button&gt; &lt;Button variant="raised" color="secondary" className={classes.button}&gt; Disabled &lt;/Button&gt; &lt;input accept="image/*" className={classes.input} id="raised-button-file" multiple type="file" /&gt; &lt;label htmlFor="raised-button-file"&gt; &lt;Button variant="raised" component="span" &gt; Upload &lt;/Button&gt; &lt;/label&gt; &lt;/MuiThemeProvider&gt; ); } } App.propTypes = { classes: PropTypes.object.isRequired, }; export default withStyles(styles)(App); </code></pre>
0debug
Convert Dictionary<int, string> to Json : <p>Very simple question. Hope its easy...</p> <pre class="lang-cs prettyprint-override"><code>Dictionary&lt;int, string&gt; dict = PLCCommunicator.getVarForSchakelingen("iOffsetSun", plc); return Json(new { succeeded = true, dict }, JsonRequestBehavior.AllowGet); </code></pre> <p>Is there a way in which the dict can easily be converted? Something like <code>dict.ToJson()</code></p> <p>My controller returns a <code>JsonResult</code>...</p>
0debug
static int nbd_handle_export_name(NBDClient *client, uint32_t length) { int rc = -EINVAL, csock = client->sock; char name[256]; TRACE("Checking length"); if (length > 255) { LOG("Bad length received"); goto fail; } if (read_sync(csock, name, length) != length) { LOG("read failed"); goto fail; } name[length] = '\0'; client->exp = nbd_export_find(name); if (!client->exp) { LOG("export not found"); goto fail; } QTAILQ_INSERT_TAIL(&client->exp->clients, client, next); nbd_export_get(client->exp); rc = 0; fail: return rc; }
1threat
Using jupyter R kernel with visual studio code : <p>For python jupyter notebooks I am currently using VSCode python extension. However I cannot find any way to use alternative kernels. I am interested in jupyter R kernel in particular. </p> <p>Is there any way to work with jupyter notebooks using R kernel in VSCode?</p>
0debug
Vbscript Split or regex command to pull the task name and lastresult from text file : TaskName=YY_EF LastRunTime="3/14/2016 10:30:00 PM" LastResult=1 TaskCommand="C:\Windows\scripts\Tasks\FC_CREATE" TaskState=Enabled StartTime="10:30:00 PM" RunTime="00:15:00" Days="Every 1 day(s)"
0debug
def binary_to_decimal(binary): binary1 = binary decimal, i, n = 0, 0, 0 while(binary != 0): dec = binary % 10 decimal = decimal + dec * pow(2, i) binary = binary//10 i += 1 return (decimal)
0debug
int kvm_arch_pre_run(CPUState *env, struct kvm_run *run) { if (env->interrupt_request & CPU_INTERRUPT_NMI) { env->interrupt_request &= ~CPU_INTERRUPT_NMI; DPRINTF("injected NMI\n"); kvm_vcpu_ioctl(env, KVM_NMI); } if (!kvm_irqchip_in_kernel()) { if (env->interrupt_request & CPU_INTERRUPT_INIT) { env->exit_request = 1; } if (run->ready_for_interrupt_injection && (env->interrupt_request & CPU_INTERRUPT_HARD) && (env->eflags & IF_MASK)) { int irq; env->interrupt_request &= ~CPU_INTERRUPT_HARD; irq = cpu_get_pic_interrupt(env); if (irq >= 0) { struct kvm_interrupt intr; intr.irq = irq; DPRINTF("injected interrupt %d\n", irq); kvm_vcpu_ioctl(env, KVM_INTERRUPT, &intr); } } if ((env->interrupt_request & CPU_INTERRUPT_HARD)) { run->request_interrupt_window = 1; } else { run->request_interrupt_window = 0; } DPRINTF("setting tpr\n"); run->cr8 = cpu_get_apic_tpr(env->apic_state); } return 0; }
1threat
static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent) { char desc[DESC_SIZE]; uint32_t cid; const char *p_name, *cid_str; size_t cid_str_size; BDRVVmdkState *s = bs->opaque; if (bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE) != DESC_SIZE) { return 0; } if (parent) { cid_str = "parentCID"; cid_str_size = sizeof("parentCID"); } else { cid_str = "CID"; cid_str_size = sizeof("CID"); } p_name = strstr(desc, cid_str); if (p_name != NULL) { p_name += cid_str_size; sscanf(p_name, "%x", &cid); } return cid; }
1threat
How to initalize a string array in a main Java method : I have written some code which creates and initializes a String ArrayList. Is it possible to declare the arguments directly in to the String [] args method itself, rather than creating an extra String arrayList? I have done some searching on youtube/ google etc but didn't find a clear answer. Thanks public class sampleCode{ public static void main(String[] args ) { String[]args2 = {"en", "es"}; if( args2[0].equals("en")) { System.out.println("english option"); } else if( args2[1].equals("es")) { System.out.println("spanish option"); } else System.out.println("this is the default option"); } }
0debug
Make a calendar view for events in python tkinter : <p>So what I'm trying to do is to make a calendar frame, just like the view of google calendar or any other calendar program really, where I can select a day and see the events I have to do on that day and it's time using python tkinter. Currently on my database I have events with date, starting time and ending time. Note that I am using python 3. Can anyone please give me a clue for how to do it or even send a link to a website where it says how to do it. But please, I'm not searching for a date picker just a calendar showing me what thing I should do when. Thank you ;)</p>
0debug
def div_of_nums(nums,m,n): result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums)) return result
0debug
Else / Else If not working : <p>This code runs when i click on a piece of text. The first if works, but the second doesn't want to execute.</p> <pre><code>if (music = true) { music = false; $('#musicButton').html("Music: Off") } if (music = false) { music = true; $('#musicButton').html("Music: On") } </code></pre> <p>I tried else if and else, but none seem to work.</p>
0debug
Extract complex Text pattern using SQL function : I need to extract a text pattern looking like this: NN-NNN-NNNNNNNNN (2digit,minus, 3digits,minus,9digits) from along text field. anyone has a clue? thanks a lot!
0debug
Your branch is ahead of 'origin/xyz' by 3 commits : <p>I am working on a remote branch.I just tried doing git status and it shows your branch is ahead of 'origin/xyz' by 3 commits . What it does mean and how do I resolve this issue ? Being a newbie to version control, I find git bit intimidating when it comes to branches. Note:xyz is the remote branch .</p>
0debug
Creating an object from a class : <p>For example</p> <pre><code>Dictionary webster = new Dictionary(); </code></pre> <p>what does each dictionary mean technically? I understand that I'm creating a object that has its methods and variables. But what causes this?</p> <p>Furthermore I am learning about Data structures.. Same exact question really but can the left and right side be different? Ex</p> <pre><code>ArrayList&lt;String&gt; list = new LinkedList&lt;String&gt;(); </code></pre> <p>I know </p> <pre><code>ArrayList&lt;String list = new ArrayList&lt;String&gt;(); works </code></pre> <p>but like I said I'm confused on what each side brings when my object is created..</p>
0debug
thread.sleep not doing what is supposed to : <p>So, the program is for school and i am having some problems, the basic premise is to have to user choose shape, size and colour, then draw the shape or animate it to move across the screen. </p> <p>My programs works fine without the thread.sleep (it moves across the screen instantly). When i added the thread.sleep it was not working and waited 10 seconds before immediately moving to the end. </p> <p>After testing around, it seems to have some correlation with the for loop it was in as when the for loop was to 1000 it waited 10 seconds then moved 1000 spaces instantly but when the for loop was 100 it only took one second to move 100 spaces instantly.</p> <p>My understanding was that it should just wait 10 milliseconds before going into the for loop again.</p> <pre><code>import java.awt.*; import java.awt.event.*; import java.applet.*; public class AppletAssignemntIsFucked extends Applet implements ActionListener { int colourChoice; int shapeChoice; int location; int x, y; TextField height = new TextField ("00"); TextField width = new TextField ("00"); boolean animating = false; //declare the two types of checkboxes CheckboxGroup shape, colour; //declare all the shape checkboxes Checkbox buttonSquare, buttonCircle, buttonRectangle, buttonOval; //declare all the colour checkboxes Checkbox buttonRed, buttonBlue, buttonGreen, buttonYellow; Button buttonDraw, buttonAnimate, buttonReset; public void init () { setBackground (Color.lightGray); shape = new CheckboxGroup (); colour = new CheckboxGroup (); buttonCircle = new Checkbox ("Circle", shape, true); add (buttonCircle); buttonSquare = new Checkbox ("Square", shape, false); add (buttonSquare); buttonRectangle = new Checkbox ("Rectangle", shape, false); add (buttonRectangle); buttonOval = new Checkbox ("Oval", shape, false); add (buttonOval); buttonRed = new Checkbox ("Red", colour, true); add (buttonRed); buttonBlue = new Checkbox ("Blue", colour, false); add (buttonBlue); buttonGreen = new Checkbox ("Green", colour, false); add (buttonGreen); buttonYellow = new Checkbox ("Yellow", colour, false); add (buttonYellow); buttonDraw = new Button ("draw"); buttonDraw.addActionListener (this); add (buttonDraw); buttonAnimate = new Button ("animate"); buttonAnimate.addActionListener (this); add (buttonAnimate); buttonReset = new Button ("reset"); buttonReset.addActionListener (this); add (buttonReset); add (height); add (width); } public void paint (Graphics g) { switch (colourChoice) { case 1: g.setColor (Color.red); break; case 2: g.setColor (Color.green); break; case 3: g.setColor (Color.yellow); break; case 4: g.setColor (Color.blue); break; } switch (shapeChoice) { case 1: g.fillOval (location, 80, x, x); break; case 2: g.fillRect (location, 80, x, x); break; case 3: g.fillRect (location, 80, x, y); break; case 4: g.fillOval (location, 80, x, y); break; } } public void actionPerformed (ActionEvent evt) { y = Integer.parseInt (height.getText ()); x = Integer.parseInt (width.getText ()); //set the colour if (evt.getSource () == buttonAnimate) { for (int i = 0 ; i &lt; 1000 ; i++) { try { Thread.sleep (10); } catch (InterruptedException ex) { Thread.currentThread ().interrupt (); } location += 1; repaint (); } } if (evt.getSource () == buttonReset) { location = 10; repaint (); } if (evt.getSource () == buttonDraw) { if (buttonRed.getState () == true) { colourChoice = 1; } else if (buttonGreen.getState () == true) { colourChoice = 2; } else if (buttonYellow.getState () == true) { colourChoice = 3; } else if (buttonBlue.getState () == true) { colourChoice = 4; } //set the shape if (buttonCircle.getState () == true) { shapeChoice = 1; } else if (buttonSquare.getState () == true) { shapeChoice = 2; } else if (buttonRectangle.getState () == true) { shapeChoice = 3; } else if (buttonOval.getState () == true) { shapeChoice = 4; } repaint (); } } </code></pre> <p>}</p>
0debug
what does constant property means in swift? : <p>I am learning SWIFT. I don't understand one sentence while reading book. What does the sentence below means?: </p> <blockquote> <p>“Add a constant property called elementList to ViewController.swift and initialize it with the following element names: let elementList = ["Carbon", "Gold", "Chlorine", "Sodium"]” does it mean create new class or I have to create struct? </p> </blockquote>
0debug
How to make visible mobile status bar in React Native Navigation : <p>How to make a visible mobile status bar in React Native Navigation</p> <p>Screenshot: Status bar not visible.</p> <p><a href="https://i.stack.imgur.com/E8Bgh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E8Bgh.png" alt="enter image description here"></a></p>
0debug
static void do_bit_allocation(AC3DecodeContext *ctx, int flags) { ac3_audio_block *ab = &ctx->audio_block; int i, snroffst = 0; if (!flags) return; if (ab->flags & AC3_AB_SNROFFSTE) { snroffst += ab->csnroffst; if (ab->flags & AC3_AB_CPLINU) snroffst += ab->cplfsnroffst; for (i = 0; i < ctx->bsi.nfchans; i++) snroffst += ab->fsnroffst[i]; if (ctx->bsi.flags & AC3_BSI_LFEON) snroffst += ab->lfefsnroffst; if (!snroffst) { memset(ab->cplbap, 0, sizeof (ab->cplbap)); for (i = 0; i < ctx->bsi.nfchans; i++) memset(ab->bap[i], 0, sizeof (ab->bap[i])); memset(ab->lfebap, 0, sizeof (ab->lfebap)); return; } } if ((ab->flags & AC3_AB_CPLINU) && (flags & 64)) do_bit_allocation1(ctx, 5); for (i = 0; i < ctx->bsi.nfchans; i++) if (flags & (1 << i)) do_bit_allocation1(ctx, i); if ((ctx->bsi.flags & AC3_BSI_LFEON) && (flags & 32)) do_bit_allocation1(ctx, 6); }
1threat
static int mjpegb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, 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; AVFrame *picture = data; GetBitContext hgb; uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs; uint32_t field_size, sod_offs; buf_ptr = buf; buf_end = buf + buf_size; 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 0; } 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; second_field_offs = 0; goto read_header; } } *picture= *s->picture_ptr; *data_size = sizeof(AVFrame); if(!s->lossless){ picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]); picture->qstride= 0; picture->qscale_table= s->qscale_table; memset(picture->qscale_table, picture->quality, (s->width+15)/16); if(avctx->debug & FF_DEBUG_QP) av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality); picture->quality*= FF_QP2LAMBDA; } return buf_ptr - buf; }
1threat
static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { VP8Context *ctx = avctx->priv_data; struct vpx_image *rawimg = NULL; struct vpx_image *rawimg_alpha = NULL; int64_t timestamp = 0; int res, coded_size; vpx_enc_frame_flags_t flags = 0; if (frame) { rawimg = &ctx->rawimg; rawimg->planes[VPX_PLANE_Y] = frame->data[0]; rawimg->planes[VPX_PLANE_U] = frame->data[1]; rawimg->planes[VPX_PLANE_V] = frame->data[2]; rawimg->stride[VPX_PLANE_Y] = frame->linesize[0]; rawimg->stride[VPX_PLANE_U] = frame->linesize[1]; rawimg->stride[VPX_PLANE_V] = frame->linesize[2]; if (ctx->is_alpha) { uint8_t *u_plane, *v_plane; rawimg_alpha = &ctx->rawimg_alpha; rawimg_alpha->planes[VPX_PLANE_Y] = frame->data[3]; u_plane = av_malloc(frame->linesize[1] * frame->height); memset(u_plane, 0x80, frame->linesize[1] * frame->height); rawimg_alpha->planes[VPX_PLANE_U] = u_plane; v_plane = av_malloc(frame->linesize[2] * frame->height); memset(v_plane, 0x80, frame->linesize[2] * frame->height); rawimg_alpha->planes[VPX_PLANE_V] = v_plane; rawimg_alpha->stride[VPX_PLANE_Y] = frame->linesize[0]; rawimg_alpha->stride[VPX_PLANE_U] = frame->linesize[1]; rawimg_alpha->stride[VPX_PLANE_V] = frame->linesize[2]; } timestamp = frame->pts; if (frame->pict_type == AV_PICTURE_TYPE_I) flags |= VPX_EFLAG_FORCE_KF; } res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp, avctx->ticks_per_frame, flags, ctx->deadline); if (res != VPX_CODEC_OK) { log_encoder_error(avctx, "Error encoding frame"); return AVERROR_INVALIDDATA; } if (ctx->is_alpha) { res = vpx_codec_encode(&ctx->encoder_alpha, rawimg_alpha, timestamp, avctx->ticks_per_frame, flags, ctx->deadline); if (res != VPX_CODEC_OK) { log_encoder_error(avctx, "Error encoding alpha frame"); return AVERROR_INVALIDDATA; } } coded_size = queue_frames(avctx, pkt, avctx->coded_frame); if (!frame && avctx->flags & CODEC_FLAG_PASS1) { unsigned int b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz); avctx->stats_out = av_malloc(b64_size); if (!avctx->stats_out) { av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc (%d bytes) failed\n", b64_size); return AVERROR(ENOMEM); } av_base64_encode(avctx->stats_out, b64_size, ctx->twopass_stats.buf, ctx->twopass_stats.sz); } if (rawimg_alpha) { av_freep(&rawimg_alpha->planes[VPX_PLANE_U]); av_freep(&rawimg_alpha->planes[VPX_PLANE_V]); } *got_packet = !!coded_size; return 0; }
1threat
static inline int array_ensure_allocated(array_t* array, int index) { if((index + 1) * array->item_size > array->size) { int new_size = (index + 32) * array->item_size; array->pointer = g_realloc(array->pointer, new_size); if (!array->pointer) return -1; array->size = new_size; array->next = index + 1; } return 0; }
1threat
static void handle_arg_reserved_va(const char *arg) { char *p; int shift = 0; reserved_va = strtoul(arg, &p, 0); switch (*p) { case 'k': case 'K': shift = 10; break; case 'M': shift = 20; break; case 'G': shift = 30; break; } if (shift) { unsigned long unshifted = reserved_va; p++; reserved_va <<= shift; if (((reserved_va >> shift) != unshifted) #if HOST_LONG_BITS > TARGET_VIRT_ADDR_SPACE_BITS || (reserved_va > (1ul << TARGET_VIRT_ADDR_SPACE_BITS)) #endif ) { fprintf(stderr, "Reserved virtual address too big\n"); exit(EXIT_FAILURE); } } if (*p) { fprintf(stderr, "Unrecognised -R size suffix '%s'\n", p); exit(EXIT_FAILURE); } }
1threat
static void omap_mpui_init(MemoryRegion *memory, target_phys_addr_t base, struct omap_mpu_state_s *mpu) { memory_region_init_io(&mpu->mpui_iomem, &omap_mpui_ops, mpu, "omap-mpui", 0x100); memory_region_add_subregion(memory, base, &mpu->mpui_iomem); omap_mpui_reset(mpu); }
1threat
Ms SQL 2012: Column names into result values : I need to include table column names into result values like in the below example. How can I do it? SELECT 'John' AS Name, 'Malkovich' AS Surname INTO #T Result table should have 'Name' and 'Surname' as values Name, Surname (column names) Name, Surname, John, Malkovich Regards, Przemek
0debug
How to change the placeholder color in android app created using React Native : <p>I'm creating an Android app using React Native in which there's a form. The placeholder doesn't even appear for the textInput fields so I thought of changing the placeholder color but I don't know how to do that. The docs mentioned some way which I don't understand.</p> <p>Here's the code:</p> <pre><code> &lt;TextInput secureTextEntry={secureTextEntry} style={inputStyle} placeholder={placeholder} value={value} onChangeText={onChangeText} /&gt; inputStyle: { color: '#000', paddingRight: 5, paddingLeft: 5, fontSize: 18, lineHeight: 23, flex: 2, } </code></pre> <p>I also tried: </p> <pre><code> &lt;TextInput placeholderTextColor="blue" style={inputStyle} placeholder={placeholder} value={value} onChangeText={onChangeText} /&gt; </code></pre> <p>and </p> <pre><code> inputStyle: { color: '#000', paddingRight: 5, paddingLeft: 5, fontSize: 18, lineHeight: 23, flex: 2, placeholderTextColor: '#333' } </code></pre>
0debug
Hard understanding 'echo' from associative array structure : <p>So, I get this assoc array structure : </p> <pre><code>pastebin.com/9nEGKsK0 </code></pre> <p>How can I fetch the urls by 'foreach'? Help.</p>
0debug
How do I scan a sentence in Python : <p>Suppose I have a text file : </p> <blockquote> <p>As a manager, he told FIFA TV he communicates his messages in a measured way. “I’m not one of the lads,” Southgate explained.</p> </blockquote> <p>Is there a way to get the sentence inside the quote (") and save that sentence as variable? I know I have to use the scanner method, but I'm new to python language and I don't know how. Can someone give me an example on how to store this?</p>
0debug
Extract Integers, Decimals, and Fractional Numbers from sentence of a string in [swift] [ios] : How to extract the array of string with Integers, Decimals, and Fractions from a sentence. please find below input and output in iOS Swift. Input : array of String["width 32.3", "Length 61 1/4", "height 23 4/5", "measure 5.23"] Output : ["32.3", "61 1/4", "23 4/5", "5.23"] Please do needful.
0debug
static int64_t coroutine_fn qcow2_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { BDRVQcow2State *s = bs->opaque; uint64_t cluster_offset; int index_in_cluster, ret; int64_t status = 0; *pnum = nb_sectors; qemu_co_mutex_lock(&s->lock); ret = qcow2_get_cluster_offset(bs, sector_num << 9, pnum, &cluster_offset); qemu_co_mutex_unlock(&s->lock); if (ret < 0) { return ret; } if (cluster_offset != 0 && ret != QCOW2_CLUSTER_COMPRESSED && !s->cipher) { index_in_cluster = sector_num & (s->cluster_sectors - 1); cluster_offset |= (index_in_cluster << BDRV_SECTOR_BITS); status |= BDRV_BLOCK_OFFSET_VALID | cluster_offset; } if (ret == QCOW2_CLUSTER_ZERO) { status |= BDRV_BLOCK_ZERO; } else if (ret != QCOW2_CLUSTER_UNALLOCATED) { status |= BDRV_BLOCK_DATA; } return status; }
1threat
How to parse several log nginx files using goaccess : <p>I want to parse all my logs of nginx (you can see here):</p> <pre><code>ls /var/log/nginx/ access.log access.log.21.gz error.log.1 error.log.22.gz access.log.1 access.log.22.gz error.log.10.gz error.log.23.gz access.log.10.gz access.log.23.gz error.log.11.gz error.log.24.gz access.log.11.gz access.log.24.gz error.log.12.gz error.log.2.gz access.log.12.gz access.log.2.gz error.log.13.gz error.log.3.gz access.log.13.gz access.log.3.gz error.log.14.gz error.log.4.gz access.log.14.gz access.log.4.gz error.log.15.gz error.log.5.gz access.log.15.gz access.log.5.gz error.log.16.gz error.log.6.gz access.log.16.gz access.log.6.gz error.log.17.gz error.log.7.gz access.log.17.gz access.log.7.gz error.log.18.gz error.log.8.gz access.log.18.gz access.log.8.gz error.log.19.gz error.log.9.gz access.log.19.gz access.log.9.gz error.log.20.gz access.log.20.gz error.log error.log.21.gz </code></pre> <p>but I don't know how to do that. First of all, it seems like goaccess can't parse .gz files.</p> <p>What's the best way of parse all the information contained in these logs?</p>
0debug
Retry logic with CompletableFuture : <p>I need to submit a task in an async framework I'm working on, but I need to catch for exceptions, and retry the same task multiple times before "aborting".</p> <p>The code I'm working with is:</p> <pre><code>int retries = 0; public CompletableFuture&lt;Result&gt; executeActionAsync() { // Execute the action async and get the future CompletableFuture&lt;Result&gt; f = executeMycustomActionHere(); // If the future completes with exception: f.exceptionally(ex -&gt; { retries++; // Increment the retry count if (retries &lt; MAX_RETRIES) return executeActionAsync(); // &lt;--- Submit one more time // Abort with a null value return null; }); // Return the future return f; } </code></pre> <p>This currently doesn't compile because the return type of the lambda is wrong: it expects a <code>Result</code>, but the <code>executeActionAsync</code> returns a <code>CompletableFuture&lt;Result&gt;</code>. </p> <p>How can I implement this fully async retry logic?</p>
0debug
static struct omap_mcbsp_s *omap_mcbsp_init(MemoryRegion *system_memory, hwaddr base, qemu_irq txirq, qemu_irq rxirq, qemu_irq *dma, omap_clk clk) { struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) g_malloc0(sizeof(struct omap_mcbsp_s)); s->txirq = txirq; s->rxirq = rxirq; s->txdrq = dma[0]; s->rxdrq = dma[1]; s->sink_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_mcbsp_sink_tick, s); s->source_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_mcbsp_source_tick, s); omap_mcbsp_reset(s); memory_region_init_io(&s->iomem, NULL, &omap_mcbsp_ops, s, "omap-mcbsp", 0x800); memory_region_add_subregion(system_memory, base, &s->iomem); return s; }
1threat
Android Studio: how to show author of just selected line : <p>I noticed a pretty feature in Visual Studio Code (don't know if it's due to the GitLens extension): when I'm editing a line I can see the GIT annotation of that line including author, time of last edit and commit message.</p> <p><a href="https://i.stack.imgur.com/6ZLRF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6ZLRF.png" alt="enter image description here"></a></p> <p>This is quite cool, since it does not take a big amount of space as the "annotations" pane that you can enable in Android Studio. It's fast, easy, straightforward.</p> <p>My question is: is there any Android Studio extension, as far as you know, allowing a similar visualization?</p> <p>Thank you Marco</p>
0debug
Replace array item with another one without mutating state : <p>This is how example of my state looks:</p> <pre><code>const INITIAL_STATE = { contents: [ {}, {}, {}, etc.. ], meta: {} } </code></pre> <p>I need to be able and somehow replace an item inside contents array knowing its index, I have tried:</p> <pre><code> return { ...state, contents: [ ...state.contents[action.meta.index], { content_type: 7, content_body: { album_artwork_url: action.payload.data.album.images[1].url, preview_url: action.payload.data.preview_url, title: action.payload.data.name, subtitle: action.payload.data.artists[0].name, spotify_link: action.payload.data.external_urls.spotify } } ] } </code></pre> <p>where <code>action.meta.index</code> is index of array item I want to replace with another contents object, but I believe this just replaces whole array to this one object I'm passing. I also thought of using <code>.splice()</code> but that would just mutate the array?</p>
0debug
Php mysqli Call to a member function fetch_all() on boolean : <p>It is my code:</p> <pre><code> public function getEmployees($where='1',$start, $perPage){ $sql="SELECT e.name,e.birthday,d.title_dep,p.title_pos,t.title_type,e.salary FROM `employees` AS e INNER JOIN departments AS d ON e.id_dep=d.id INNER JOIN positions AS p ON e.id_pos=p.id INNER JOIN payment_types AS t ON e.id_type=t.id where ".$where. 'LIMIT 10'; </code></pre> <p>I always get error: <strong>Call to a member function fetch_all() on boolean</strong> </p> <p>It began when I added 'LIMIT 10'. Whithout it my code works fine. How can I solve my problem?</p>
0debug
How to handle observe response in Angular (interfception)? : I use addition option for POST request : return this.http.post("", data, { observe: "response" }); When I try to handle this response in interception I can not get http status: return next.handle(request).pipe( map((event: any) => { console.log(event.status); return event; });
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
Input data to a shell script : <p>How could I create a shell script with input data ?</p> <p>Please enter names separated by a blank: John Marry Sanford Saunders</p> <pre><code>read names </code></pre>
0debug
What's the difference between import java.util.*; and import java.util.stream;? : <p>I'm using Java 8's <code>Stream</code> functionality to manipulate the contents of an array in my program:</p> <pre><code>Obstacle[] closestObstacles = Stream.generate(() -&gt; new Obstacle()).limit(8).toArray(Obstacle[]::new); // one for each line of attack </code></pre> <p>When I try importing <code>Stream</code> like this: <code>import java.util.*;</code> I get a "the symbol Stream cannot be resolved" error. When I instead import <code>Stream</code> like this: <code>java.util.stream;</code> things work as expected. Why does this happen? I don't use <code>Stream</code> or anything named "stream" elsewhere in my program, so I don't think it's a name conflict? </p>
0debug
C++ Copy Constructor error: Assignment of member 'Fraction::numerator' in read-only object : I am having a problem with this error. My Header file: #include <iostream> using namespace std; class Fraction { private: double numerator; double denominator; public: Fraction(); ~Fraction(); Fraction(const Fraction& c); Fraction(double,double); //setter void setNumerator(double newnumerator); void setDenominator(double newdenominator); //getter double getNumerator(); double getDenominator(); //friend overlaoding operators friend ostream& operator<<(ostream& os, Fraction f); }; My CPP file: #include <iostream> #include "Fraction.h" using namespace std; Fraction::Fraction() { cout<<"Empty constructor called"<<endl; } Fraction::~Fraction() { cout<<"Deconstructor called"<<endl; } Fraction::Fraction(const Fraction& c) { c.numerator = numerator; c.denominator = denominator; } Fraction::Fraction(double newnumerator, double newdenominator) { numerator = newnumerator; denominator = newdenominator; } void Fraction::setNumerator(double newnumerator) { numerator = newnumerator; } void Fraction::setDenominator(double newdenominator) { denominator = newdenominator; } double Fraction::getNumerator() { return numerator; } double Fraction::getDenominator() { return denominator; } ostream& operator<<(ostream& os, Fraction f) { os<<f.numerator<<"/"<<f.denominator<<endl; return os; } My testcpp.file: #include <iostream> #include "Fraction.h" using namespace std; int main() { Fraction f1; cout<<f1; return 0; } When I run this code I get this error message: Fraction.cpp: In copy constructor ‘Fraction::Fraction(const Fraction&)’: Fraction.cpp:20:17: error: assignment of member ‘Fraction::numerator’ in read-only object c.numerator = numerator; ^ Fraction.cpp:21:19: error: assignment of member ‘Fraction::denominator’ in read-only object c.denominator = denominator; ^ PS: Once I left out the copy copy constructor and tried if the rest really works, but I get the same error message for the overloading operator(cin>>). Thank you very much.
0debug
Keeping only categories that contain both female and male observations : <p>I'm working with a dataframe where a "job_title" column contains hundreds of titles, and a different column, "gender", specifies whether the person represented by the observation is male or female.</p> <p>(I'm struggling to figure out) how to drop all rows such that the job title value isn't shared by both a male and a female?</p> <p>In other words, I want to keep a row if and only if its "job_title" value is recorded for at least one other row which has the other "gender" value. If only males have a specific job title, I want to drop all the rows with that job title; if only females have a job title, I'm looking to drop all rows with that job title too.</p>
0debug
static int mpc_probe(AVProbeData *p) { const uint8_t *d = p->buf; if (p->buf_size < 32) return 0; if (d[0] == 'M' && d[1] == 'P' && d[2] == '+' && (d[3] == 0x17 || d[3] == 0x7)) return AVPROBE_SCORE_MAX; if (d[0] == 'I' && d[1] == 'D' && d[2] == '3') return AVPROBE_SCORE_MAX / 2; return 0; }
1threat
Separate Int from String on file input : <p>i was wondering if anyone could help me with a little problem in Java: I have a file with some equations like:</p> <pre><code>Z=1X1+3X2 -1X1+5X2&lt;=2 1X1-1X2&lt;=56 </code></pre> <p>and so on..</p> <p>and i wanted to read this file and separate the values 1 and 3 (of Z=1X1+3X2) in one string and -1,5,2,1,-1,56 in another.</p>
0debug
static inline void RENAME(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, unsigned int src_size) { #ifdef HAVE_MMX asm volatile ( "xor %%"REG_a", %%"REG_a" \n\t" ".balign 16 \n\t" "1: \n\t" PREFETCH" 32(%0, %%"REG_a") \n\t" "movq (%0, %%"REG_a"), %%mm0 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm0, %%mm2 \n\t" "pslld $16, %%mm0 \n\t" "psrld $16, %%mm1 \n\t" "pand "MANGLE(mask32r)", %%mm0 \n\t" "pand "MANGLE(mask32g)", %%mm2 \n\t" "pand "MANGLE(mask32b)", %%mm1 \n\t" "por %%mm0, %%mm2 \n\t" "por %%mm1, %%mm2 \n\t" MOVNTQ" %%mm2, (%1, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" "cmp %2, %%"REG_a" \n\t" " jb 1b \n\t" :: "r" (src), "r"(dst), "r" ((long)src_size-7) : "%"REG_a ); __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #else unsigned i; unsigned num_pixels = src_size >> 2; for(i=0; i<num_pixels; i++) { #ifdef WORDS_BIGENDIAN dst[4*i + 1] = src[4*i + 3]; dst[4*i + 2] = src[4*i + 2]; dst[4*i + 3] = src[4*i + 1]; #else dst[4*i + 0] = src[4*i + 2]; dst[4*i + 1] = src[4*i + 1]; dst[4*i + 2] = src[4*i + 0]; #endif } #endif }
1threat
PHP error: Parse error: syntax error, unexpected '->' : <p>I am new to PHP. I am trying to create a textbox in html, and take the input via php and store it in my Mysql database.</p> <p>I can't get past this error.</p> <p><strong>Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)</strong></p> <p>I understand the <code>-&gt;</code> is wrong. But I don't know how to fix it.</p> <p>Also is there any other errors that you guys see in this code? I appreciate your help.</p> <pre class="lang-php prettyprint-override"><code> &lt;form action="user-post.php" method="get"&gt; &lt;input type="post-box" name="postbox" required&gt; &lt;input type="submit" value="Submit"&gt; &lt;/form&gt; &lt;?php session_start(); $_SESSION['message'] = ''; $mysqli = new mysqli('localhost:3306', 'root', '1234', 'status-box'); if ($_SERVER['REQUEST_METHOD'] == 'GET') { $postbox = mysqli-&gt;real_escape_string($_GET['postbox']); $sql = "INSERT INTO post (postbox)" . "VALUES ('$postbox')"; if ($mysqli-&gt;query($sql) === true) { header("location: index.html"); } else { $_SESSION['message'] = "Post could NOT be added to the database!"; } } ?&gt; </code></pre>
0debug
How could i implement automatic YT opening? : <p>Titile basically. </p> <p>How could i implement the opening of my browser and then youtube and a specific music.</p> <p>Ty in advance.</p>
0debug
static void hash32_bat_size(CPUPPCState *env, target_ulong *blp, int *validp, target_ulong batu, target_ulong batl) { target_ulong bl; int valid; bl = (batu & BATU32_BL) << 15; valid = 0; if (((msr_pr == 0) && (batu & BATU32_VS)) || ((msr_pr != 0) && (batu & BATU32_VP))) { valid = 1; } *blp = bl; *validp = valid; }
1threat
What's the point of AsyncSubject in RXJS? : <p>The documentation for <code>RxJS</code> defines <code>AsyncSubject</code> as follows:</p> <blockquote> <p>The AsyncSubject is a variant where only the last value of the Observable execution is sent to its observers, and only when the execution completes.</p> </blockquote> <p>I don't see where / why I would ever need to use this variant of subject. Can someone provide an explanation or a real-world example to illustrate why it exists and its advantages?</p>
0debug
Can someone please explain this Python code? : <p>Whilst I know what this piece of code does i have no clue how it achieves it. Can someone please explain it in the dumbest way?</p> <pre><code>vec = [[1,2,3], [4,5,6], [7,8,9]] [num for elem in vec for num in elem] [1, 2, 3, 4, 5, 6, 7, 8, 9] </code></pre> <p>The first for part of the code returns this:</p> <pre><code>[num for elem in vec] [0, 0, 0] </code></pre> <p>Are they indexes for each nested lists first entry?</p> <p>Thanks!</p>
0debug
Insert data to database using foreach loop php : <p>Ex: If I have code :</p> <pre><code>$data = array('a','b','c'); foreach($data as $val){ mysql_query("INSERT INTO db (`title`)VALUES('$val')"); } </code></pre> <p>I want to insert all data from variable $val how can I coding it ? please help !!! thank !! </p>
0debug
how to get value of Threadlocal from current Thread in java? : <p>How to get value of Thread-local from current Thread? I am trying to get the value of Thread-local from current Thread but can't find any help online.</p>
0debug
size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg) { if (alg >= G_N_ELEMENTS(alg_key_len)) { return 0; } return alg_block_len[alg]; }
1threat
Import Module from different enviroments : Create a module in Python named 'python_1.py' that make the follow: 1. When import the module from Python console ('import python_1'), return 'Imported'. 2. When import the module from iPython console ('import python_1'), return 'Imported from iPython'. 3. When import the module from Command System ('python python_1.py'), return 'Running as script'.
0debug
xmit_seg(E1000State *s) { uint16_t len; unsigned int frames = s->tx.tso_frames, css, sofar; struct e1000_tx *tp = &s->tx; if (tp->props.tse && tp->props.cptse) { css = tp->props.ipcss; DBGOUT(TXSUM, "frames %d size %d ipcss %d\n", frames, tp->size, css); if (tp->props.ip) { stw_be_p(tp->data+css+2, tp->size - css); stw_be_p(tp->data+css+4, lduw_be_p(tp->data + css + 4) + frames); } else { stw_be_p(tp->data+css+4, tp->size - css); } css = tp->props.tucss; len = tp->size - css; DBGOUT(TXSUM, "tcp %d tucss %d len %d\n", tp->props.tcp, css, len); if (tp->props.tcp) { sofar = frames * tp->props.mss; stl_be_p(tp->data+css+4, ldl_be_p(tp->data+css+4)+sofar); if (tp->props.paylen - sofar > tp->props.mss) { tp->data[css + 13] &= ~9; } else if (frames) { e1000x_inc_reg_if_not_full(s->mac_reg, TSCTC); } } else stw_be_p(tp->data+css+4, len); if (tp->props.sum_needed & E1000_TXD_POPTS_TXSM) { unsigned int phsum; void *sp = tp->data + tp->props.tucso; phsum = lduw_be_p(sp) + len; phsum = (phsum >> 16) + (phsum & 0xffff); stw_be_p(sp, phsum); } tp->tso_frames++; } if (tp->props.sum_needed & E1000_TXD_POPTS_TXSM) { putsum(tp->data, tp->size, tp->props.tucso, tp->props.tucss, tp->props.tucse); } if (tp->props.sum_needed & E1000_TXD_POPTS_IXSM) { putsum(tp->data, tp->size, tp->props.ipcso, tp->props.ipcss, tp->props.ipcse); } if (tp->vlan_needed) { memmove(tp->vlan, tp->data, 4); memmove(tp->data, tp->data + 4, 8); memcpy(tp->data + 8, tp->vlan_header, 4); e1000_send_packet(s, tp->vlan, tp->size + 4); } else { e1000_send_packet(s, tp->data, tp->size); } e1000x_inc_reg_if_not_full(s->mac_reg, TPT); e1000x_grow_8reg_if_not_full(s->mac_reg, TOTL, s->tx.size); s->mac_reg[GPTC] = s->mac_reg[TPT]; s->mac_reg[GOTCL] = s->mac_reg[TOTL]; s->mac_reg[GOTCH] = s->mac_reg[TOTH]; }
1threat
urgent!!!!How to write excel formula (checking data from two different sheets) : I have a formula in Sheet6 to look up a value from sheet5 and return it, but sometimes, if values are not in sheet5, I want it to check in sheet7. sheet6 and sheet7 have same pattern in all column, only columns have different values. How can I rewrite the formula in sheet 6 inorder to check data in sheet 5 first and if data were not found, then sheet7 will be automatically match ? ***oringial formula in sheet 6*** =IF(ISNA(INDEX(Sheet5!$A$4:$AG$30,MATCH($C$25,Sheet5!G4:G30,0),2)),"",INDEX(Sheet5!$A$4:$AG$30,MATCH($C$25, Sheet5!G4:G30,0),2)) Thanks for help.
0debug
two progress bars with same styles (default) look different in android : In my android application i am using an open source library. This library has an activity which creates a progress bar (no style) using below code . say it progressBar1 . private void createProgressBar() { LayoutParams params = new LayoutParams(-1, -2); // match_parent , wrap_content params.addRule(13); //center in parent ProgressBar = new ProgressBar(this); ProgressBar.setLayoutParams(params); RootLayout.addView(ProgressBar); ProgressBar.setVisibility(8); //View.GONE } I am also creating a progress bar in my app using exact same code above , Say ProgressBar2. But the two progress bars look different . I donot know whats the reason . I want both the progress bars to look same . I also tried changing the progressBar2 by adding it in xml and using from there using below code: <ProgressBar android:id="@+id/progressBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:indeterminate= "true" android:visibility="gone"/> using it in java as: progressBar = (ProgressBar) findViewById(R.id.progressBar); progressBar.setVisibility(View.VISIBLE); still the progressBar2 Looks the same and both progressBar1 and progressBar2 look different ... do not know why?
0debug
Is there any way to make code organized if I have a super long list? : <p>Is there any way to avoid single lines containing thousands of characters if I happen to have a super long list?</p>
0debug
static void qio_channel_socket_listen_worker(QIOTask *task, gpointer opaque) { QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task)); SocketAddressLegacy *addr = opaque; Error *err = NULL; qio_channel_socket_listen_sync(ioc, addr, &err); qio_task_set_error(task, err); }
1threat
static VFIOGroup *vfio_get_group(int groupid, AddressSpace *as) { VFIOGroup *group; char path[32]; struct vfio_group_status status = { .argsz = sizeof(status) }; QLIST_FOREACH(group, &group_list, next) { if (group->groupid == groupid) { if (group->container->space->as == as) { return group; } else { error_report("vfio: group %d used in multiple address spaces", group->groupid); return NULL; } } } group = g_malloc0(sizeof(*group)); snprintf(path, sizeof(path), "/dev/vfio/%d", groupid); group->fd = qemu_open(path, O_RDWR); if (group->fd < 0) { error_report("vfio: error opening %s: %m", path); goto free_group_exit; } if (ioctl(group->fd, VFIO_GROUP_GET_STATUS, &status)) { error_report("vfio: error getting group status: %m"); goto close_fd_exit; } if (!(status.flags & VFIO_GROUP_FLAGS_VIABLE)) { error_report("vfio: error, group %d is not viable, please ensure " "all devices within the iommu_group are bound to their " "vfio bus driver.", groupid); goto close_fd_exit; } group->groupid = groupid; QLIST_INIT(&group->device_list); if (vfio_connect_container(group, as)) { error_report("vfio: failed to setup container for group %d", groupid); goto close_fd_exit; } if (QLIST_EMPTY(&group_list)) { qemu_register_reset(vfio_pci_reset_handler, NULL); } QLIST_INSERT_HEAD(&group_list, group, next); vfio_kvm_device_add_group(group); return group; close_fd_exit: close(group->fd); free_group_exit: g_free(group); return NULL; }
1threat
Your app contains exposed Google Cloud Platform (GCP) API keys. Please see this Google Help Center article for details : <p>My key is restricted using package name and SHA1, still Google Play store shows this warning.</p> <p>Any idea why it is showing like this. I defined my API key in build.gradle file and using it from there.</p>
0debug
How to print the most common thing in the most_common list? (python) : I need help finding how to print the most common letter of a string as a character after using the `most_common` function is used. My code is: from collections import* message = input("What is the message you would like to decrypt?") messageInt = list(map(ord,list(message))) messageChr = list(map(chr,list(messageInt))) print messageChr fre = Counter(messageChr) mostLett = fre.most_common(1) print mostLett How do I get it to print: ['e', 'x', 'a', 'm', 'p', 'l', 'e'] [('e', 2)] e
0debug
int aio_bh_poll(AioContext *ctx) { QEMUBH *bh, **bhp, *next; int ret; ctx->walking_bh++; ret = 0; for (bh = ctx->first_bh; bh; bh = next) { smp_read_barrier_depends(); next = bh->next; if (!bh->deleted && atomic_xchg(&bh->scheduled, 0)) { if (!bh->idle) ret = 1; bh->idle = 0; bh->cb(bh->opaque); } } ctx->walking_bh--; if (!ctx->walking_bh) { qemu_mutex_lock(&ctx->bh_lock); bhp = &ctx->first_bh; while (*bhp) { bh = *bhp; if (bh->deleted) { *bhp = bh->next; g_free(bh); } else { bhp = &bh->next; } } qemu_mutex_unlock(&ctx->bh_lock); } return ret; }
1threat
Differences between commands run in .bat file and cmd.exe : I wanted to download scoop installer and I find out that my command is not working in a .bat file but works when I copy/paste it in powershell. Here is the command and a picture to make things perfectly clear : iex (new-object net.webclient).downloadstring('https://get.scoop.sh') [output of powershell][1] Could somebody explain to me why it is the case and maybe the things that we need to be aware of when we put commands in .bat file ? [1]: https://i.stack.imgur.com/8lHT0.png
0debug
static int decode_pic(AVSContext *h) { MpegEncContext *s = &h->s; int skip_count; enum cavs_mb mb_type; if (!s->context_initialized) { s->avctx->idct_algo = FF_IDCT_CAVS; if (MPV_common_init(s) < 0) return -1; ff_init_scantable(s->dsp.idct_permutation,&h->scantable,ff_zigzag_direct); } skip_bits(&s->gb,16); if(h->stc == PIC_PB_START_CODE) { h->pic_type = get_bits(&s->gb,2) + FF_I_TYPE; if(h->pic_type > FF_B_TYPE) { av_log(s->avctx, AV_LOG_ERROR, "illegal picture type\n"); return -1; } if(!h->DPB[0].data[0] || (!h->DPB[1].data[0] && h->pic_type == FF_B_TYPE)) return -1; } else { h->pic_type = FF_I_TYPE; if(get_bits1(&s->gb)) skip_bits(&s->gb,24); } if(h->picture.data[0]) s->avctx->release_buffer(s->avctx, (AVFrame *)&h->picture); s->avctx->get_buffer(s->avctx, (AVFrame *)&h->picture); ff_cavs_init_pic(h); h->picture.poc = get_bits(&s->gb,8)*2; if(h->pic_type != FF_B_TYPE) { h->dist[0] = (h->picture.poc - h->DPB[0].poc + 512) % 512; } else { h->dist[0] = (h->DPB[0].poc - h->picture.poc + 512) % 512; } h->dist[1] = (h->picture.poc - h->DPB[1].poc + 512) % 512; h->scale_den[0] = h->dist[0] ? 512/h->dist[0] : 0; h->scale_den[1] = h->dist[1] ? 512/h->dist[1] : 0; if(h->pic_type == FF_B_TYPE) { h->sym_factor = h->dist[0]*h->scale_den[1]; } else { h->direct_den[0] = h->dist[0] ? 16384/h->dist[0] : 0; h->direct_den[1] = h->dist[1] ? 16384/h->dist[1] : 0; } if(s->low_delay) get_ue_golomb(&s->gb); h->progressive = get_bits1(&s->gb); h->pic_structure = 1; if(!h->progressive) h->pic_structure = get_bits1(&s->gb); if(!h->pic_structure && h->stc == PIC_PB_START_CODE) skip_bits1(&s->gb); skip_bits1(&s->gb); skip_bits1(&s->gb); h->qp_fixed = get_bits1(&s->gb); h->qp = get_bits(&s->gb,6); if(h->pic_type == FF_I_TYPE) { if(!h->progressive && !h->pic_structure) skip_bits1(&s->gb); skip_bits(&s->gb,4); } else { if(!(h->pic_type == FF_B_TYPE && h->pic_structure == 1)) h->ref_flag = get_bits1(&s->gb); skip_bits(&s->gb,4); h->skip_mode_flag = get_bits1(&s->gb); } h->loop_filter_disable = get_bits1(&s->gb); if(!h->loop_filter_disable && get_bits1(&s->gb)) { h->alpha_offset = get_se_golomb(&s->gb); h->beta_offset = get_se_golomb(&s->gb); } else { h->alpha_offset = h->beta_offset = 0; } if(h->pic_type == FF_I_TYPE) { do { check_for_slice(h); decode_mb_i(h, 0); } while(ff_cavs_next_mb(h)); } else if(h->pic_type == FF_P_TYPE) { do { check_for_slice(h); if(h->skip_mode_flag) { skip_count = get_ue_golomb(&s->gb); while(skip_count--) { decode_mb_p(h,P_SKIP); if(!ff_cavs_next_mb(h)) goto done; } check_for_slice(h); mb_type = get_ue_golomb(&s->gb) + P_16X16; } else mb_type = get_ue_golomb(&s->gb) + P_SKIP; if(mb_type > P_8X8) { decode_mb_i(h, mb_type - P_8X8 - 1); } else decode_mb_p(h,mb_type); } while(ff_cavs_next_mb(h)); } else { do { check_for_slice(h); if(h->skip_mode_flag) { skip_count = get_ue_golomb(&s->gb); while(skip_count--) { decode_mb_b(h,B_SKIP); if(!ff_cavs_next_mb(h)) goto done; } check_for_slice(h); mb_type = get_ue_golomb(&s->gb) + B_DIRECT; } else mb_type = get_ue_golomb(&s->gb) + B_SKIP; if(mb_type > B_8X8) { decode_mb_i(h, mb_type - B_8X8 - 1); } else decode_mb_b(h,mb_type); } while(ff_cavs_next_mb(h)); } done: if(h->pic_type != FF_B_TYPE) { if(h->DPB[1].data[0]) s->avctx->release_buffer(s->avctx, (AVFrame *)&h->DPB[1]); h->DPB[1] = h->DPB[0]; h->DPB[0] = h->picture; memset(&h->picture,0,sizeof(Picture)); } return 0; }
1threat
Find position where the member of two lists differs : <p>I have the following two lists of strings with the same size:</p> <pre><code>l1 = ['foo', 'foo','bar','cho'] l2 = ['foo', 'qux','bar','cxx'] * * </code></pre> <p>What I want to do is to find the position where the members differs, yielding:</p> <pre><code>1, 3 </code></pre> <p>How can we do that?</p>
0debug
returning or redoing the for statement : <p>i want to scan a number from 0 to 100 and when it found a certain number it will execute a function then i want it to return back to the for statement and continue in scanning other numbers. </p> <p>i have tried changing if statement with while statement but it only repeat the function that are inside the while statement. i want to go back to the for statement to scan the number. </p> <p>here is an example of what i am trying to do:</p> <pre><code>// returning from if statement back to for statement for(int number = 0;number &lt; 100;number++){ if(number == 5){ // do something // come back and keep scanning other number } } </code></pre>
0debug
Invoking a function without parentheses : <p>I was told today that it's possible to invoke a function without parentheses. The only ways I could think of was using functions like <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply"><code>apply</code></a> or <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call"><code>call</code></a>.</p> <pre><code>f.apply(this); f.call(this); </code></pre> <p>But these require parentheses on <code>apply</code> and <code>call</code> leaving us at square one. I also considered the idea of passing the function to some sort of event handler such as <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout"><code>setTimeout</code></a>:</p> <pre><code>setTimeout(f, 500); </code></pre> <p>But then the question becomes "how do you invoke <code>setTimeout</code> without parentheses?"</p> <p>So what's the solution to this riddle? How can you invoke a function in Javascript without using parentheses?</p>
0debug
How to console imput and store a line of numbers in c++? : There is a line full of a specific number (N) of numbers. For example: if N = 5 then the line can be: 0 1 5 3 4 How can I read in a line like that? If I store it in a string (string temp; cin >> temp;), it becomes '00' for some reason... Also, I need to put them into a number array. Can you help me please?
0debug
the differences between Jboss Fuse and MuleSoft for System Integration : <p>What are the deference between JBoss Fuse and MuleSoft ESB? which one recommended to use for System Integration?</p>
0debug
Error Gephi Plugin : I am currently trying to write a plugin for Gephi and get the following error message: java.lang.ClassCastException: org.gephi.graph.impl.GraphStore$NodeIterableWrapper cannot be cast to org.gephi.graph.api.Node at org.............execute(.....java:92) The code in which the error occured is as follows: Node[] nodes = graph.getNodes().toArray(); for (Node n: nodes){ ..... List<Node> neighborNodes = new LinkedList<Node>(); for(Node m: nodes){ NodeIterable iter = graph.getNeighbors(m); neighborNodes.add((Node) iter); The last line causes the error. Is it possible via NodeIterable to insert the neighbors as nodes in the list "neighborNodes" without this cast. I'm new in writing java plugins. Thanks in advance
0debug
data change in one column of the file from javascript : I have a request coming in for the javascript coding and since I am very new to the javascript i am asking for some help in here. We have around 25 columns from the data being loaded from the csv file, and one of the column is coming with below format :- "By <b>AAA</b>this is a test <b>BBB</b>this is a test2 <b>CCC</b>this is a test3" Now i want to extract only the data between the <b></b> and have to bring the html<br> so it looks AAA BBB CCC Requesting for any help on this.
0debug
Toollbar Background ImageSIze : I am working in android application. Actually there I have to set an image in place of toolbar . But I Don't know what the exact sizes of that image . I googled it a lot. but unable to find the solution. here is my requirement [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/bYb7u.jpg
0debug
dropdown autosuggest hides list items from selection : <p>Not able to select from auto-suggest drop-down list items after first 3/4 items. because it is hided by table grid. how could we do this.? any hint ? which css/properties i need to set for table or auto-suggest drop-down list.?</p> <p><a href="https://i.stack.imgur.com/EbGGR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EbGGR.png" alt="enter image description here"></a></p>
0debug
How to validate time in laravel : <p>I want to validate time in Laravel. Ex:- I want that when user input the time between 8 PM to 10 PM then it will show the validation error. How can I achieve that in Laravel</p>
0debug
static int init_quantization_noise(DCAEncContext *c, int noise) { int ch, band, ret = 0; c->consumed_bits = 132 + 493 * c->fullband_channels; if (c->lfe_channel) c->consumed_bits += 72; for (ch = 0; ch < c->fullband_channels; ch++) { for (band = 0; band < 32; band++) { int snr_cb = c->peak_cb[band][ch] - c->band_masking_cb[band] - noise; if (snr_cb >= 1312) { c->abits[band][ch] = 26; ret |= USED_26ABITS; } else if (snr_cb >= 222) { c->abits[band][ch] = 8 + mul32(snr_cb - 222, 69000000); ret |= USED_NABITS; } else if (snr_cb >= 0) { c->abits[band][ch] = 2 + mul32(snr_cb, 106000000); ret |= USED_NABITS; } else { c->abits[band][ch] = 1; ret |= USED_1ABITS; } } } for (band = 0; band < 32; band++) for (ch = 0; ch < c->fullband_channels; ch++) { c->consumed_bits += bit_consumption[c->abits[band][ch]]; } return ret; }
1threat