problem
stringlengths
26
131k
labels
class label
2 classes
How to use vutify's custom sort? : <p>I'd like to use <a href="https://vuetifyjs.com/en/components/data-tables#api" rel="noreferrer">custom-sort</a> in my data table. My goal is to sort the table DESC as opposed to the default ASC. But I don't know how.</p> <p>This is the start of my data table component:</p> <pre><code> &lt;v-data-table :headers="headers" :items="acts" hide-actions class="elevation-1" &gt; &lt;template slot="items" slot-scope="props"&gt; &lt;td&gt;{{ props.item.id }}&lt;/td&gt; &lt;td&gt;{{ props.item.name }}&lt;/td&gt; &lt;td class="text-xs-center"&gt;{{ props.item.provider.id }}&lt;/td&gt; &lt;td class="text-xs-center"&gt;{{ props.item.category.name }}&lt;/td&gt; &lt;td class="text-xs-center"&gt;{{ props.item.budget }}&lt;/td&gt; &lt;td class="text-xs-center"&gt;{{ props.item.location.name }}&lt;/td&gt; &lt;td class="text-xs-center"&gt;{{ props.item.deets }}&lt;/td&gt; &lt;td class="text-xs-center"&gt;{{ props.item.keeping_it_100 }}&lt;/td&gt; &lt;td class="text-xs-center"&gt;&lt;img width="50" height="50" :src="props.item.inspiration.inspiration"&gt;&lt;/td&gt; &lt;td class="justify-center layout px-0"&gt;.... </code></pre> <p>And this is the script I'm using:</p> <pre><code>&lt;script&gt; export default { data () { return { dialog: false, customerSort: { isDescending: true,// I tried this? as the kabab format throws an error }, headers: [ { text: 'ID', value: 'id'}, { text: 'Name', value: 'name' }, { text: 'Provider', value: 'provider' }, { text: 'Category', value: 'category' }, { text: 'Budget', value: 'budget' }, { text: 'Country', value: 'location', sortable: true }, { text: 'Keeping it 100%', value: 'keeping_it_100', sortable: false }, { text: 'deets', value: 'deets', sortable: false }, { text: 'inspiration', value: 'inspiration', sortable: false }, { text: 'Cover', value: 'cover', sortable: false }, { text: 'Actions', value: 'actions', sortable: false } ], </code></pre> <p>According to docs it is a <code>function prop</code>. But I haven't found an example on how to pass it.</p> <p><a href="https://i.stack.imgur.com/5Ekor.jpg" rel="noreferrer">This is a screenshot of the function...</a></p>
0debug
how to change the content of two tabs container by using one tab using bootstrap 4.x? : I'm trying to create two tabs containers one of them are used to describe the content of a set of files and the second are used as a list of download links for the described files. now what I did is try to control the two containers using one tab only, I saw a solution used {data-trigger} with two ID's like data-trigger="#TabA1, #TabB1" but it seems this option is not working with bootstrap 4.x, so is there any solution or workaround to solve this issue. anyway here is my code, if anyone can help me in this. <div class="row"> <div class="col-sm-8"> <div class="card text-center "> <div class="card-header"> <ul class="nav nav-tabs card-header-tabs"> <li class="nav-item"> <a class="nav-link active" href="#TabA1" data-trigger="#A1, #B1" data-toggle="tab" role="tab" aria-selected="true">A1/B1</a> </li> <li class="nav-item"> <a class="nav-link" href="#TabA2" data-trigger="#A2, #B2" data-toggle="tab" role="tab" aria-selected="false">A2/B2</a> </li> <li class="nav-item"> <a class="nav-link" href="#TabA3" data-trigger="#A3, #B3" data-toggle="tab" role="tab" aria-selected="false">A3/B3</a> </li> <li class="nav-item"> <a class="nav-link" href="#TabA4" data-trigger="#A4, #B4" data-toggle="tab" role="tab" aria-selected="false">A4/B4</a> </li> </ul> </div> <div class="card-body" style="text-align: left; overflow-y: scroll; max-height: 600px;"> <div class="tab-content" id="myTabContent_A"> <div class="tab-pane fade show active" id="TabA1" role="tabpanel"> A1 </div> <div class="tab-pane fade" id="TabA2" role="tabpanel"> A2 </div> <div class="tab-pane fade" id="TabA3" role="tabpanel"> A3 </div> <div class="tab-pane fade" id="TabA4" role="tabpanel"> A4 </div> </div> </div> </div> </div> <div class="col-sm-4"> <div class="card"> <h5 class="card-header">Files</h5> <div class="card-body"> <h5 class="card-title"></h5> <div class="tab-content" id="myTabContent_B"> <div class="tab-pane fade show active" id="TabB1" role="tabpanel"> B1 </div> <div class="tab-pane fade" id="TabB2" role="tabpanel"> B2 </div> <div class="tab-pane fade" id="TabB3" role="tabpanel"> B3 </div> <div class="tab-pane fade" id="TabB4" role="tabpanel"> B4 </div> </div> </div> </div> </div> </div> with the mentioned HTML code only I can see changes happened to the first tabs container. but I expected to see the changes happened in both of the containers A and B.
0debug
Can anyone explain how this recursion code works exactly and what happens in the programs stack or in memory step by step? : <p>Here is my code:</p> <pre><code>#include &lt;stdio.h&gt; void fun(int n) { if(n &gt; 0) { fun(n-1); printf("%d ", n); fun(n-1); } } int main() { fun(4); return 0; } </code></pre> <p>and the output of this code is <code>1 2 1 3 1 2 1 4 1 2 1 3 1 2 1</code>. But I can't understand what happens exactly between to recursive calls, When the print statement will be executed and what is the value of <code>n</code> at every call. I'm beginner in coding please explain step by step. </p>
0debug
int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end, unsigned int flags) { const uint8_t *p = *bufp; uint32_t top; uint64_t code; int ret = 0; if (p >= buf_end) return 0; code = *p++; if ((code & 0xc0) == 0x80 || code >= 0xFE) { ret = AVERROR(EILSEQ); goto end; } top = (code & 128) >> 1; while (code & top) { int tmp; if (p >= buf_end) { (*bufp) ++; return AVERROR(EILSEQ); } tmp = *p++ - 128; if (tmp>>6) { (*bufp) ++; return AVERROR(EILSEQ); } code = (code<<6) + tmp; top <<= 5; } code &= (top << 1) - 1; if (code >= 1<<31) { ret = AVERROR(EILSEQ); goto end; } *codep = code; if (code > 0x10FFFF && !(flags & AV_UTF8_FLAG_ACCEPT_INVALID_BIG_CODES)) ret = AVERROR(EILSEQ); if (code < 0x20 && code != 0x9 && code != 0xA && code != 0xD && flags & AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES) ret = AVERROR(EILSEQ); if (code >= 0xD800 && code <= 0xDFFF && !(flags & AV_UTF8_FLAG_ACCEPT_SURROGATES)) ret = AVERROR(EILSEQ); if ((code == 0xFFFE || code == 0xFFFF) && !(flags & AV_UTF8_FLAG_ACCEPT_NON_CHARACTERS)) ret = AVERROR(EILSEQ); end: *bufp = p; return ret; }
1threat
static gboolean fd_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque) { CharDriverState *chr = opaque; FDCharDriver *s = chr->opaque; int len; uint8_t buf[READ_BUF_LEN]; GIOStatus status; gsize bytes_read; len = sizeof(buf); if (len > s->max_size) { len = s->max_size; } if (len == 0) { return FALSE; } status = g_io_channel_read_chars(chan, (gchar *)buf, len, &bytes_read, NULL); if (status == G_IO_STATUS_EOF) { qemu_chr_be_event(chr, CHR_EVENT_CLOSED); return FALSE; } if (status == G_IO_STATUS_NORMAL) { qemu_chr_be_write(chr, buf, bytes_read); } return TRUE; }
1threat
static uint32_t taihu_cpld_readw (void *opaque, hwaddr addr) { uint32_t ret; ret = taihu_cpld_readb(opaque, addr) << 8; ret |= taihu_cpld_readb(opaque, addr + 1); return ret; }
1threat
Undefined variable : <p>I still get this error for some I guess stupid reason. I was following Laracast fundamentals tutorials then I decided to create my own app and it's the same. Probably I've messed something up and can't see it.</p> <p>Here's the error:</p> <blockquote> <p>Undefined variable: movies (View: C:\Users\username\PhpstormProjects\movie_app\resources\views\movies\show.blade.php)</p> </blockquote> <p>This is my controller:</p> <pre><code>public function show($id) { $movie = Movie::findOrFail($id); return view('movies.show', compact('movie')); } </code></pre> <p>View:</p> <pre><code>@extends('layouts.app') @section('content') @foreach($movies as $movie) &lt;h4&gt;{{$movie-&gt;name}}&lt;/h4&gt; @endforeach @endsection </code></pre>
0debug
How to filter the lines of a text file which does not match with any of the elements in an array in Ruby : I have a text file with lines of it mostly matching with the elements of an array. How to filter the lines which don't find a match with any of the elements in the given array Example: sample text files looks like the following "Joe is in London Sathish in Newyork Pandu in Sydney" Array = [London, Newyork] How to filter the line "Pandu in Sydney" line from text file Please note: text file and array are dynamic nature Ruby Beginner...Please help Thanks
0debug
how to get the outuput in the correct format : def read_ndfa(file : open) -> {str:{str:{str}}}: pass file = start;0;start;1;start;0;near \n near;1;end \n end correct output = {'end': {}, 'start': {'1': {'start'}, '0': {'start', 'near'}}, 'near': {'1': {'end'}}} I need to write a function that takes a file as an input to get the correct output as above. however, I have no idea how to create the inner dictionary by using zip function. can someone show me the correct way to do it? Many thanks.
0debug
void idct_add_altivec(uint8_t* dest, int stride, vector_s16_t* block) { POWERPC_TBL_DECLARE(altivec_idct_add_num, 1); #ifdef ALTIVEC_USE_REFERENCE_C_CODE POWERPC_TBL_START_COUNT(altivec_idct_add_num, 1); void simple_idct_add(uint8_t *dest, int line_size, int16_t *block); simple_idct_add(dest, stride, (int16_t*)block); POWERPC_TBL_STOP_COUNT(altivec_idct_add_num, 1); #else vector_u8_t tmp; vector_s16_t tmp2, tmp3; vector_u8_t perm0; vector_u8_t perm1; vector_u8_t p0, p1, p; POWERPC_TBL_START_COUNT(altivec_idct_add_num, 1); IDCT p0 = vec_lvsl (0, dest); p1 = vec_lvsl (stride, dest); p = vec_splat_u8 (-1); perm0 = vec_mergeh (p, p0); perm1 = vec_mergeh (p, p1); #define ADD(dest,src,perm) \ \ tmp = vec_ld (0, dest); \ tmp2 = (vector_s16_t)vec_perm (tmp, (vector_u8_t)zero, perm); \ tmp3 = vec_adds (tmp2, src); \ tmp = vec_packsu (tmp3, tmp3); \ vec_ste ((vector_u32_t)tmp, 0, (unsigned int *)dest); \ vec_ste ((vector_u32_t)tmp, 4, (unsigned int *)dest); ADD (dest, vx0, perm0) dest += stride; ADD (dest, vx1, perm1) dest += stride; ADD (dest, vx2, perm0) dest += stride; ADD (dest, vx3, perm1) dest += stride; ADD (dest, vx4, perm0) dest += stride; ADD (dest, vx5, perm1) dest += stride; ADD (dest, vx6, perm0) dest += stride; ADD (dest, vx7, perm1) POWERPC_TBL_STOP_COUNT(altivec_idct_add_num, 1); #endif }
1threat
C++ Borland Builder 6 : I have program for semester pass and have problem. It read text into TStrings then operate on it in memo. Everything is ok when compiling. But when I run exe file witout borland it hang when doing anything else than just this program f.ex. run browser on top of it. It happens only with big files like 3000 lines. How to solve this?
0debug
static struct iovec *cap_sg(struct iovec *sg, int cap, int *cnt) { int i; int total = 0; for (i = 0; i < *cnt; i++) { if ((total + sg[i].iov_len) > cap) { sg[i].iov_len -= ((total + sg[i].iov_len) - cap); i++; break; } total += sg[i].iov_len; } *cnt = i; return sg; }
1threat
How to make someone else's firebase iOS application mine? : What should I do to make someone else's firebase application mine ? I made a new firebase account with my bundle identifier , and replaced the googleserviceinfo file , but it's not working. What have I missed
0debug
static int decode_block(ALSDecContext *ctx, ALSBlockData *bd) { unsigned int smp; if (*bd->const_block) decode_const_block_data(ctx, bd); else if (decode_var_block_data(ctx, bd)) return -1; if (*bd->shift_lsbs) for (smp = 0; smp < bd->block_length; smp++) bd->raw_samples[smp] <<= *bd->shift_lsbs; return 0; }
1threat
Can dask parralelize reading fom a csv file? : <p>I'm converting a large textfile to a hdf storage in hopes of a faster data access. The conversion works allright, however reading from the csv file is not done in parallel. It is really slow (takes about 30min for a 1GB textfile on an SSD, so my guess is that it is not IO-bound). </p> <p>Is there a way to have it read in multiple threads in parralel? Sice it might be important, I'm currently forced to run under Windows -- just in case that makes any difference.</p> <pre><code>from dask import dataframe as ddf df = ddf.read_csv("data/Measurements*.csv", sep=';', parse_dates=["DATETIME"], blocksize=1000000, ) df.categorize([ 'Type', 'Condition', ]) df.to_hdf("data/data.hdf", "Measurements", 'w') </code></pre>
0debug
Correct way of error handling in React-Redux : <p>I want to understand what is more general or correct way of error handling with React-Redux. </p> <p>Suppose, I have phone number sign up component.</p> <p>That Component throws an error say if the input phone number is invalid </p> <p>What would be a best way to handle that error? </p> <p><strong>Idea 1:</strong> Create a component, which takes an error and dispatches an action whenever an error is passed to it</p> <p><strong>idea 2:</strong> Since the error is related to that component, pass that error to a component (which isn't connected to redux i.e the error handler component won't dispatch the action)</p> <p><strong>Question:</strong> Can someone guide me on proper-way of error handling in React-Redux for large-scale app? </p>
0debug
static int decode_nal_sei_frame_packing_arrangement(HEVCContext *s) { GetBitContext *gb = &s->HEVClc->gb; get_ue_golomb(gb); s->sei_frame_packing_present = !get_bits1(gb); if (s->sei_frame_packing_present) { s->frame_packing_arrangement_type = get_bits(gb, 7); s->quincunx_subsampling = get_bits1(gb); s->content_interpretation_type = get_bits(gb, 6); skip_bits(gb, 6); if (!s->quincunx_subsampling && s->frame_packing_arrangement_type != 5) skip_bits(gb, 16); skip_bits(gb, 8); skip_bits1(gb); } skip_bits1(gb); return 0; }
1threat
SwiftUI: How to implement a custom init with @Binding variables : <p>I'm working on a money input screen and need to implement a custom <code>init</code> to set a state variable based on the initialized amount.</p> <p>I thought this would work, but I'm getting a compiler error of:</p> <p><code>Cannot assign value of type 'Binding&lt;Double&gt;' to type 'Double'</code></p> <pre><code>struct AmountView : View { @Binding var amount: Double @State var includeDecimal = false init(amount: Binding&lt;Double&gt;) { self.amount = amount self.includeDecimal = round(amount)-amount &gt; 0 } ... } </code></pre>
0debug
I imported Selenium2Library, there were no errors but in Test case section of Robot framework its not getting recognised : [enter image description here][1] [1]: https://i.stack.imgur.com/OZSog.png clearly, under settings section, we see that the library seleniumlibrary is not being recognised?
0debug
void spapr_register_hypercall(target_ulong opcode, spapr_hcall_fn fn) { spapr_hcall_fn *slot; if (opcode <= MAX_HCALL_OPCODE) { assert((opcode & 0x3) == 0); slot = &papr_hypercall_table[opcode / 4]; } else { assert((opcode >= KVMPPC_HCALL_BASE) && (opcode <= KVMPPC_HCALL_MAX)); slot = &kvmppc_hypercall_table[opcode - KVMPPC_HCALL_BASE]; } assert(!(*slot) || (fn == *slot)); *slot = fn; }
1threat
static void spapr_nmi(NMIState *n, int cpu_index, Error **errp) { CPUState *cs; CPU_FOREACH(cs) { async_run_on_cpu(cs, ppc_cpu_do_nmi_on_cpu, RUN_ON_CPU_NULL); } }
1threat
PHP or jq code for opening multiple links in new tab but in only one tab : <p>I have site in php and and i have multiple links to open in new tab (by using _blank). But i want to that all links will in only one tab. So i open first links it open in new tab and clicked on second link it will open in same tab where first link currently open. So it is possible, If yes then how?</p>
0debug
How to check mimetype from uploaded file in php : <p>i have an mimetype check in my upload function, that checking if the uploaded file is an image or not. I want to allow upload image AND pdf files, but i dont know how to change my function.</p> <pre><code>$verifyimg = getimagesize($_FILES['image']['tmp_name'][$f]); $pattern = "#^(image/)[^\s\n&lt;]+$#i"; if(!preg_match($pattern, $verifyimg['mime'])) { $err; } </code></pre> <p>I hope anybody can tell me how i need to change the $pattern varaible to check images AND pdf files.</p> <p>Have a nice weekend!</p>
0debug
static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp) { CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; target_ulong msr, new_msr, vector; int srr0, srr1, asrr0, asrr1; int lpes0, lpes1, lev, ail; if (0) { lpes0 = (env->spr[SPR_LPCR] >> 1) & 1; lpes1 = (env->spr[SPR_LPCR] >> 2) & 1; } else { lpes0 = 0; lpes1 = 1; } qemu_log_mask(CPU_LOG_INT, "Raise exception at " TARGET_FMT_lx " => %08x (%02x)\n", env->nip, excp, env->error_code); if (excp_model == POWERPC_EXCP_BOOKE) { msr = env->msr; } else { msr = env->msr & ~0x783f0000ULL; } new_msr = env->msr & ((target_ulong)1 << MSR_ME); srr0 = SPR_SRR0; srr1 = SPR_SRR1; asrr0 = -1; asrr1 = -1; #if defined(TARGET_PPC64) if (excp_model == POWERPC_EXCP_POWER7 || excp_model == POWERPC_EXCP_POWER8) { if (excp_model == POWERPC_EXCP_POWER8) { ail = (env->spr[SPR_LPCR] & LPCR_AIL) >> LPCR_AIL_SHIFT; } else { ail = 0; } } else #endif { ail = 0; } switch (excp) { case POWERPC_EXCP_NONE: return; case POWERPC_EXCP_CRITICAL: switch (excp_model) { case POWERPC_EXCP_40x: srr0 = SPR_40x_SRR2; srr1 = SPR_40x_SRR3; break; case POWERPC_EXCP_BOOKE: srr0 = SPR_BOOKE_CSRR0; srr1 = SPR_BOOKE_CSRR1; break; case POWERPC_EXCP_G2: break; default: goto excp_invalid; } goto store_next; case POWERPC_EXCP_MCHECK: if (msr_me == 0) { fprintf(stderr, "Machine check while not allowed. " "Entering checkstop state\n"); if (qemu_log_separate()) { qemu_log("Machine check while not allowed. " "Entering checkstop state\n"); } cs->halted = 1; cs->interrupt_request |= CPU_INTERRUPT_EXITTB; } if (0) { new_msr |= (target_ulong)MSR_HVB; } ail = 0; new_msr &= ~((target_ulong)1 << MSR_ME); switch (excp_model) { case POWERPC_EXCP_40x: srr0 = SPR_40x_SRR2; srr1 = SPR_40x_SRR3; break; case POWERPC_EXCP_BOOKE: srr0 = SPR_BOOKE_MCSRR0; srr1 = SPR_BOOKE_MCSRR1; asrr0 = SPR_BOOKE_CSRR0; asrr1 = SPR_BOOKE_CSRR1; break; default: break; } goto store_next; case POWERPC_EXCP_DSI: LOG_EXCP("DSI exception: DSISR=" TARGET_FMT_lx" DAR=" TARGET_FMT_lx "\n", env->spr[SPR_DSISR], env->spr[SPR_DAR]); if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } goto store_next; case POWERPC_EXCP_ISI: LOG_EXCP("ISI exception: msr=" TARGET_FMT_lx ", nip=" TARGET_FMT_lx "\n", msr, env->nip); if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } msr |= env->error_code; goto store_next; case POWERPC_EXCP_EXTERNAL: cs = CPU(cpu); if (lpes0 == 1) { new_msr |= (target_ulong)MSR_HVB; } if (env->mpic_proxy) { env->spr[SPR_BOOKE_EPR] = ldl_phys(cs->as, env->mpic_iack); } goto store_next; case POWERPC_EXCP_ALIGN: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } env->spr[SPR_DSISR] |= (cpu_ldl_code(env, (env->nip - 4)) & 0x03FF0000) >> 16; goto store_next; case POWERPC_EXCP_PROGRAM: switch (env->error_code & ~0xF) { case POWERPC_EXCP_FP: if ((msr_fe0 == 0 && msr_fe1 == 0) || msr_fp == 0) { LOG_EXCP("Ignore floating point exception\n"); cs->exception_index = POWERPC_EXCP_NONE; env->error_code = 0; return; } if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } msr |= 0x00100000; if (msr_fe0 == msr_fe1) { goto store_next; } msr |= 0x00010000; break; case POWERPC_EXCP_INVAL: LOG_EXCP("Invalid instruction at " TARGET_FMT_lx "\n", env->nip); if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } msr |= 0x00080000; env->spr[SPR_BOOKE_ESR] = ESR_PIL; break; case POWERPC_EXCP_PRIV: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } msr |= 0x00040000; env->spr[SPR_BOOKE_ESR] = ESR_PPR; break; case POWERPC_EXCP_TRAP: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } msr |= 0x00020000; env->spr[SPR_BOOKE_ESR] = ESR_PTR; break; default: cpu_abort(cs, "Invalid program exception %d. Aborting\n", env->error_code); break; } goto store_current; case POWERPC_EXCP_FPU: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } goto store_current; case POWERPC_EXCP_SYSCALL: dump_syscall(env); lev = env->error_code; if ((lev == 1) && cpu_ppc_hypercall) { cpu_ppc_hypercall(cpu); return; } if (lev == 1 || (lpes0 == 0 && lpes1 == 0)) { new_msr |= (target_ulong)MSR_HVB; } goto store_next; case POWERPC_EXCP_APU: goto store_current; case POWERPC_EXCP_DECR: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } goto store_next; case POWERPC_EXCP_FIT: LOG_EXCP("FIT exception\n"); goto store_next; case POWERPC_EXCP_WDT: LOG_EXCP("WDT exception\n"); switch (excp_model) { case POWERPC_EXCP_BOOKE: srr0 = SPR_BOOKE_CSRR0; srr1 = SPR_BOOKE_CSRR1; break; default: break; } goto store_next; case POWERPC_EXCP_DTLB: goto store_next; case POWERPC_EXCP_ITLB: goto store_next; case POWERPC_EXCP_DEBUG: switch (excp_model) { case POWERPC_EXCP_BOOKE: srr0 = SPR_BOOKE_DSRR0; srr1 = SPR_BOOKE_DSRR1; asrr0 = SPR_BOOKE_CSRR0; asrr1 = SPR_BOOKE_CSRR1; break; default: break; } cpu_abort(cs, "Debug exception is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_SPEU: env->spr[SPR_BOOKE_ESR] = ESR_SPV; goto store_current; case POWERPC_EXCP_EFPDI: cpu_abort(cs, "Embedded floating point data exception " "is not implemented yet !\n"); env->spr[SPR_BOOKE_ESR] = ESR_SPV; goto store_next; case POWERPC_EXCP_EFPRI: cpu_abort(cs, "Embedded floating point round exception " "is not implemented yet !\n"); env->spr[SPR_BOOKE_ESR] = ESR_SPV; goto store_next; case POWERPC_EXCP_EPERFM: cpu_abort(cs, "Performance counter exception is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_DOORI: goto store_next; case POWERPC_EXCP_DOORCI: srr0 = SPR_BOOKE_CSRR0; srr1 = SPR_BOOKE_CSRR1; goto store_next; case POWERPC_EXCP_RESET: if (msr_pow) { msr |= 0x10000; } else { new_msr &= ~((target_ulong)1 << MSR_ME); } if (0) { new_msr |= (target_ulong)MSR_HVB; } ail = 0; goto store_next; case POWERPC_EXCP_DSEG: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } goto store_next; case POWERPC_EXCP_ISEG: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } goto store_next; case POWERPC_EXCP_HDECR: srr0 = SPR_HSRR0; srr1 = SPR_HSRR1; new_msr |= (target_ulong)MSR_HVB; new_msr |= env->msr & ((target_ulong)1 << MSR_RI); goto store_next; case POWERPC_EXCP_TRACE: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } goto store_next; case POWERPC_EXCP_HDSI: srr0 = SPR_HSRR0; srr1 = SPR_HSRR1; new_msr |= (target_ulong)MSR_HVB; new_msr |= env->msr & ((target_ulong)1 << MSR_RI); goto store_next; case POWERPC_EXCP_HISI: srr0 = SPR_HSRR0; srr1 = SPR_HSRR1; new_msr |= (target_ulong)MSR_HVB; new_msr |= env->msr & ((target_ulong)1 << MSR_RI); goto store_next; case POWERPC_EXCP_HDSEG: srr0 = SPR_HSRR0; srr1 = SPR_HSRR1; new_msr |= (target_ulong)MSR_HVB; new_msr |= env->msr & ((target_ulong)1 << MSR_RI); goto store_next; case POWERPC_EXCP_HISEG: srr0 = SPR_HSRR0; srr1 = SPR_HSRR1; new_msr |= (target_ulong)MSR_HVB; new_msr |= env->msr & ((target_ulong)1 << MSR_RI); goto store_next; case POWERPC_EXCP_VPU: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } goto store_current; case POWERPC_EXCP_VSXU: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } goto store_current; case POWERPC_EXCP_FU: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } goto store_current; case POWERPC_EXCP_PIT: LOG_EXCP("PIT exception\n"); goto store_next; case POWERPC_EXCP_IO: cpu_abort(cs, "601 IO error exception is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_RUNM: cpu_abort(cs, "601 run mode exception is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_EMUL: cpu_abort(cs, "602 emulation trap exception " "is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_IFTLB: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } switch (excp_model) { case POWERPC_EXCP_602: case POWERPC_EXCP_603: case POWERPC_EXCP_603E: case POWERPC_EXCP_G2: goto tlb_miss_tgpr; case POWERPC_EXCP_7x5: goto tlb_miss; case POWERPC_EXCP_74xx: goto tlb_miss_74xx; default: cpu_abort(cs, "Invalid instruction TLB miss exception\n"); break; } break; case POWERPC_EXCP_DLTLB: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } switch (excp_model) { case POWERPC_EXCP_602: case POWERPC_EXCP_603: case POWERPC_EXCP_603E: case POWERPC_EXCP_G2: goto tlb_miss_tgpr; case POWERPC_EXCP_7x5: goto tlb_miss; case POWERPC_EXCP_74xx: goto tlb_miss_74xx; default: cpu_abort(cs, "Invalid data load TLB miss exception\n"); break; } break; case POWERPC_EXCP_DSTLB: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } switch (excp_model) { case POWERPC_EXCP_602: case POWERPC_EXCP_603: case POWERPC_EXCP_603E: case POWERPC_EXCP_G2: tlb_miss_tgpr: if (!(new_msr & ((target_ulong)1 << MSR_TGPR))) { new_msr |= (target_ulong)1 << MSR_TGPR; hreg_swap_gpr_tgpr(env); } goto tlb_miss; case POWERPC_EXCP_7x5: tlb_miss: #if defined(DEBUG_SOFTWARE_TLB) if (qemu_log_enabled()) { const char *es; target_ulong *miss, *cmp; int en; if (excp == POWERPC_EXCP_IFTLB) { es = "I"; en = 'I'; miss = &env->spr[SPR_IMISS]; cmp = &env->spr[SPR_ICMP]; } else { if (excp == POWERPC_EXCP_DLTLB) { es = "DL"; } else { es = "DS"; } en = 'D'; miss = &env->spr[SPR_DMISS]; cmp = &env->spr[SPR_DCMP]; } qemu_log("6xx %sTLB miss: %cM " TARGET_FMT_lx " %cC " TARGET_FMT_lx " H1 " TARGET_FMT_lx " H2 " TARGET_FMT_lx " %08x\n", es, en, *miss, en, *cmp, env->spr[SPR_HASH1], env->spr[SPR_HASH2], env->error_code); } #endif msr |= env->crf[0] << 28; msr |= env->error_code; msr |= ((env->last_way + 1) & (env->nb_ways - 1)) << 17; break; case POWERPC_EXCP_74xx: tlb_miss_74xx: #if defined(DEBUG_SOFTWARE_TLB) if (qemu_log_enabled()) { const char *es; target_ulong *miss, *cmp; int en; if (excp == POWERPC_EXCP_IFTLB) { es = "I"; en = 'I'; miss = &env->spr[SPR_TLBMISS]; cmp = &env->spr[SPR_PTEHI]; } else { if (excp == POWERPC_EXCP_DLTLB) { es = "DL"; } else { es = "DS"; } en = 'D'; miss = &env->spr[SPR_TLBMISS]; cmp = &env->spr[SPR_PTEHI]; } qemu_log("74xx %sTLB miss: %cM " TARGET_FMT_lx " %cC " TARGET_FMT_lx " %08x\n", es, en, *miss, en, *cmp, env->error_code); } #endif msr |= env->error_code; break; default: cpu_abort(cs, "Invalid data store TLB miss exception\n"); break; } goto store_next; case POWERPC_EXCP_FPA: cpu_abort(cs, "Floating point assist exception " "is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_DABR: cpu_abort(cs, "DABR exception is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_IABR: cpu_abort(cs, "IABR exception is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_SMI: cpu_abort(cs, "SMI exception is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_THERM: cpu_abort(cs, "Thermal management exception " "is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_PERFM: if (lpes1 == 0) { new_msr |= (target_ulong)MSR_HVB; } cpu_abort(cs, "Performance counter exception is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_VPUA: cpu_abort(cs, "VPU assist exception is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_SOFTP: cpu_abort(cs, "970 soft-patch exception is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_MAINT: cpu_abort(cs, "970 maintenance exception is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_MEXTBR: cpu_abort(cs, "Maskable external exception " "is not implemented yet !\n"); goto store_next; case POWERPC_EXCP_NMEXTBR: cpu_abort(cs, "Non maskable external exception " "is not implemented yet !\n"); goto store_next; default: excp_invalid: cpu_abort(cs, "Invalid PowerPC exception %d. Aborting\n", excp); break; store_current: env->spr[srr0] = env->nip - 4; break; store_next: env->spr[srr0] = env->nip; break; } env->spr[srr1] = msr; if (asrr0 != -1) { env->spr[asrr0] = env->spr[srr0]; } if (asrr1 != -1) { env->spr[asrr1] = env->spr[srr1]; } if (env->spr[SPR_LPCR] & LPCR_AIL) { new_msr |= (1 << MSR_IR) | (1 << MSR_DR); } #ifdef TARGET_PPC64 if (excp_model == POWERPC_EXCP_POWER7 || excp_model == POWERPC_EXCP_POWER8) { if (env->spr[SPR_LPCR] & LPCR_ILE) { new_msr |= (target_ulong)1 << MSR_LE; } } else if (msr_ile) { new_msr |= (target_ulong)1 << MSR_LE; } #else if (msr_ile) { new_msr |= (target_ulong)1 << MSR_LE; } #endif vector = env->excp_vectors[excp]; if (vector == (target_ulong)-1ULL) { cpu_abort(cs, "Raised an exception without defined vector %d\n", excp); } vector |= env->excp_prefix; if (!((msr >> MSR_IR) & 1) || !((msr >> MSR_DR) & 1)) { ail = 0; } if (ail) { new_msr |= (1 << MSR_IR) | (1 << MSR_DR); switch(ail) { case AIL_0001_8000: vector |= 0x18000; break; case AIL_C000_0000_0000_4000: vector |= 0xc000000000004000ull; break; default: cpu_abort(cs, "Invalid AIL combination %d\n", ail); break; } } #if defined(TARGET_PPC64) if (excp_model == POWERPC_EXCP_BOOKE) { if (env->spr[SPR_BOOKE_EPCR] & EPCR_ICM) { new_msr |= (target_ulong)1 << MSR_CM; } else { vector = (uint32_t)vector; } } else { if (!msr_isf && !(env->mmu_model & POWERPC_MMU_64)) { vector = (uint32_t)vector; } else { new_msr |= (target_ulong)1 << MSR_SF; } } #endif env->msr = new_msr & env->msr_mask; hreg_compute_hflags(env); env->nip = vector; cs->exception_index = POWERPC_EXCP_NONE; env->error_code = 0; check_tlb_flush(env); }
1threat
how to get the anchor click with existing onlick function : we have a 3rd party code which add anchor tag with inline onclick function. I want to also get the click of that anchor tag. want to get the value of the data-provider
0debug
I want to test if a list of URLs is valid : <p>I have Googled for a solution to read through a bunch of URLs, in a text file, and test if each one is valid. Anything, simple or complex, is fine. Simpler is probably better. Maybe getting a 200 response is the way to go. As I said, I tested some scripts that I found online, and non worked. Sometimes people want to see what has been tried already, but I don't think there is any sense in posting what does NOT work. </p> <p>As a bonus, I'm wondering if there is a way to loop through all bookmarks in a browser, like Firefox specifically, and test if all URLs are valid or not. I'm not sure that's doable, but it would be a nice-to-have!!</p> <p>TIA everyone.</p>
0debug
static void vga_draw_graphic(VGACommonState *s, int full_update) { int y1, y, update, linesize, y_start, double_scan, mask, depth; int width, height, shift_control, line_offset, bwidth, bits; ram_addr_t page0, page1, page_min, page_max; int disp_width, multi_scan, multi_run; uint8_t *d; uint32_t v, addr1, addr; vga_draw_line_func *vga_draw_line; full_update |= update_basic_params(s); if (!full_update) vga_sync_dirty_bitmap(s); s->get_resolution(s, &width, &height); disp_width = width; shift_control = (s->gr[VGA_GFX_MODE] >> 5) & 3; double_scan = (s->cr[VGA_CRTC_MAX_SCAN] >> 7); if (shift_control != 1) { multi_scan = (((s->cr[VGA_CRTC_MAX_SCAN] & 0x1f) + 1) << double_scan) - 1; } else { multi_scan = double_scan; } multi_run = multi_scan; if (shift_control != s->shift_control || double_scan != s->double_scan) { full_update = 1; s->shift_control = shift_control; s->double_scan = double_scan; } if (shift_control == 0) { if (s->sr[VGA_SEQ_CLOCK_MODE] & 8) { disp_width <<= 1; } } else if (shift_control == 1) { if (s->sr[VGA_SEQ_CLOCK_MODE] & 8) { disp_width <<= 1; } } depth = s->get_bpp(s); if (s->line_offset != s->last_line_offset || disp_width != s->last_width || height != s->last_height || s->last_depth != depth) { #if defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) if (depth == 16 || depth == 32) { #else if (depth == 32) { #endif qemu_free_displaysurface(s->ds); s->ds->surface = qemu_create_displaysurface_from(disp_width, height, depth, s->line_offset, s->vram_ptr + (s->start_addr * 4)); #if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) s->ds->surface->pf = qemu_different_endianness_pixelformat(depth); #endif dpy_gfx_resize(s->ds); } else { qemu_console_resize(s->ds, disp_width, height); } s->last_scr_width = disp_width; s->last_scr_height = height; s->last_width = disp_width; s->last_height = height; s->last_line_offset = s->line_offset; s->last_depth = depth; full_update = 1; } else if (is_buffer_shared(s->ds->surface) && (full_update || ds_get_data(s->ds) != s->vram_ptr + (s->start_addr * 4))) { qemu_free_displaysurface(s->ds); s->ds->surface = qemu_create_displaysurface_from(disp_width, height, depth, s->line_offset, s->vram_ptr + (s->start_addr * 4)); dpy_gfx_setdata(s->ds); } s->rgb_to_pixel = rgb_to_pixel_dup_table[get_depth_index(s->ds)]; if (shift_control == 0) { full_update |= update_palette16(s); if (s->sr[VGA_SEQ_CLOCK_MODE] & 8) { v = VGA_DRAW_LINE4D2; } else { v = VGA_DRAW_LINE4; } bits = 4; } else if (shift_control == 1) { full_update |= update_palette16(s); if (s->sr[VGA_SEQ_CLOCK_MODE] & 8) { v = VGA_DRAW_LINE2D2; } else { v = VGA_DRAW_LINE2; } bits = 4; } else { switch(s->get_bpp(s)) { default: case 0: full_update |= update_palette256(s); v = VGA_DRAW_LINE8D2; bits = 4; break; case 8: full_update |= update_palette256(s); v = VGA_DRAW_LINE8; bits = 8; break; case 15: v = VGA_DRAW_LINE15; bits = 16; break; case 16: v = VGA_DRAW_LINE16; bits = 16; break; case 24: v = VGA_DRAW_LINE24; bits = 24; break; case 32: v = VGA_DRAW_LINE32; bits = 32; break; } } vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(s->ds)]; if (!is_buffer_shared(s->ds->surface) && s->cursor_invalidate) s->cursor_invalidate(s); line_offset = s->line_offset; #if 0 printf("w=%d h=%d v=%d line_offset=%d cr[0x09]=0x%02x cr[0x17]=0x%02x linecmp=%d sr[0x01]=0x%02x\n", width, height, v, line_offset, s->cr[9], s->cr[VGA_CRTC_MODE], s->line_compare, s->sr[VGA_SEQ_CLOCK_MODE]); #endif addr1 = (s->start_addr * 4); bwidth = (width * bits + 7) / 8; y_start = -1; page_min = -1; page_max = 0; d = ds_get_data(s->ds); linesize = ds_get_linesize(s->ds); y1 = 0; for(y = 0; y < height; y++) { addr = addr1; if (!(s->cr[VGA_CRTC_MODE] & 1)) { int shift; shift = 14 + ((s->cr[VGA_CRTC_MODE] >> 6) & 1); addr = (addr & ~(1 << shift)) | ((y1 & 1) << shift); } if (!(s->cr[VGA_CRTC_MODE] & 2)) { addr = (addr & ~0x8000) | ((y1 & 2) << 14); } update = full_update; page0 = addr; page1 = addr + bwidth - 1; update |= memory_region_get_dirty(&s->vram, page0, page1 - page0, DIRTY_MEMORY_VGA); update |= (s->invalidated_y_table[y >> 5] >> (y & 0x1f)) & 1; if (update) { if (y_start < 0) y_start = y; if (page0 < page_min) page_min = page0; if (page1 > page_max) page_max = page1; if (!(is_buffer_shared(s->ds->surface))) { vga_draw_line(s, d, s->vram_ptr + addr, width); if (s->cursor_draw_line) s->cursor_draw_line(s, d, y); } } else { if (y_start >= 0) { dpy_gfx_update(s->ds, 0, y_start, disp_width, y - y_start); y_start = -1; } } if (!multi_run) { mask = (s->cr[VGA_CRTC_MODE] & 3) ^ 3; if ((y1 & mask) == mask) addr1 += line_offset; y1++; multi_run = multi_scan; } else { multi_run--; } if (y == s->line_compare) addr1 = 0; d += linesize; } if (y_start >= 0) { dpy_gfx_update(s->ds, 0, y_start, disp_width, y - y_start); } if (page_max >= page_min) { memory_region_reset_dirty(&s->vram, page_min, page_max - page_min, DIRTY_MEMORY_VGA); } memset(s->invalidated_y_table, 0, ((height + 31) >> 5) * 4); }
1threat
static int pxa2xx_rtc_init(SysBusDevice *dev) { PXA2xxRTCState *s = FROM_SYSBUS(PXA2xxRTCState, dev); struct tm tm; int wom; int iomemtype; s->rttr = 0x7fff; s->rtsr = 0; qemu_get_timedate(&tm, 0); wom = ((tm.tm_mday - 1) / 7) + 1; s->last_rcnr = (uint32_t) mktimegm(&tm); s->last_rdcr = (wom << 20) | ((tm.tm_wday + 1) << 17) | (tm.tm_hour << 12) | (tm.tm_min << 6) | tm.tm_sec; s->last_rycr = ((tm.tm_year + 1900) << 9) | ((tm.tm_mon + 1) << 5) | tm.tm_mday; s->last_swcr = (tm.tm_hour << 19) | (tm.tm_min << 13) | (tm.tm_sec << 7); s->last_rtcpicr = 0; s->last_hz = s->last_sw = s->last_pi = qemu_get_clock(rt_clock); s->rtc_hz = qemu_new_timer(rt_clock, pxa2xx_rtc_hz_tick, s); s->rtc_rdal1 = qemu_new_timer(rt_clock, pxa2xx_rtc_rdal1_tick, s); s->rtc_rdal2 = qemu_new_timer(rt_clock, pxa2xx_rtc_rdal2_tick, s); s->rtc_swal1 = qemu_new_timer(rt_clock, pxa2xx_rtc_swal1_tick, s); s->rtc_swal2 = qemu_new_timer(rt_clock, pxa2xx_rtc_swal2_tick, s); s->rtc_pi = qemu_new_timer(rt_clock, pxa2xx_rtc_pi_tick, s); sysbus_init_irq(dev, &s->rtc_irq); iomemtype = cpu_register_io_memory(pxa2xx_rtc_readfn, pxa2xx_rtc_writefn, s, DEVICE_NATIVE_ENDIAN); sysbus_init_mmio(dev, 0x10000, iomemtype); return 0; }
1threat
javascript/HTML mouseover vs. "component-under" : I have some HTML (generated by jsf) that includes images. The user trigger some changes (ajax-calls) when clicking on an image or by pressing a key. To keep track of the latest image-component (client-side), I use javascript and onmouseover, assigning the img-id to a javascript-variable which in turn is used to fill the ajax-calls. Everything works well (even it there might be better ways to do it), but sometimes it takes some time to refresh the image. For a moment, the place is empty, the next-to-right picture *jumps* left, getting under the mouse pointer, triggering the mouseover event. Worse, when the original image is displayed, it fails to trigger the mouseover, so the next operation will get the wrong image a argument. I don't think this has to do with jsf and ajax but could also happen with plain HTML and javascript, so I'm not adding tags jsf nor ajax. Question is: how can I prevent this *unwanted feature*?
0debug
Are there any guarantees for unions that contain a wrapped type and the type itself? : <p>Can I put a <code>T</code> and a wrapped <code>T</code> in an <code>union</code> and inspect them as I like?</p> <pre><code>union Example { T value; struct Wrapped { T wrapped; } wrapper; }; </code></pre> <pre><code>// for simplicity T = int Example ex; ex.value = 12; cout &lt;&lt; ex.wrapper.wrapped; // ? </code></pre> <p>The C++11 standards only guarantee save inspection of the common initial sequence, but <code>value</code> isn't a <code>struct</code>. I <em>guess</em> the answer is <strong>no</strong>, since <a href="https://stackoverflow.com/questions/46425250/does-a-phantom-type-have-the-same-alignment-as-the-original-one">wrapped types aren't even guaranteed to be memory compatible to their unwrapped counterpart</a> and <a href="https://stackoverflow.com/questions/11373203/accessing-inactive-union-member-and-undefined-behavior">accessing inactive members is only well-defined on common initial sequences</a>.</p>
0debug
static void do_info(Monitor *mon, const QDict *qdict, QObject **ret_data) { const mon_cmd_t *cmd; const char *item = qdict_get_try_str(qdict, "item"); if (!item) goto help; for (cmd = info_cmds; cmd->name != NULL; cmd++) { if (compare_cmd(item, cmd->name)) break; } if (cmd->name == NULL) goto help; if (monitor_handler_ported(cmd)) { cmd->mhandler.info_new(mon, ret_data); if (*ret_data) cmd->user_print(mon, *ret_data); } else { cmd->mhandler.info(mon); } return; help: help_cmd(mon, "info"); }
1threat
Sql insert query slow down while inserting 1 lakh records : I have table which contain records of 2 crore. daily i deleted 1 lakh records and daily 1 lakh record is inserted but when i inserting records it takes more time. table having one clustered index i.e one primary key. I already tried sp_updatestats after deleting records
0debug
AFNetworking 3.0 AFHTTPSessionManager using NSOperation : <p>I'm stuck now some time and I need help. So in AFNetworking 2.0 we have <code>AFHTTPRequestOperation</code> so I could easily use <code>NSOperationQueue</code> and have some dependencies. So what we have now is only <code>AFHTTPSessionManager</code>and <code>NSURLSession</code> that does not subclass <code>NSOperation</code>. I have class <code>APIClient</code> that subclasses <code>AFHTTPSessionManager</code>. I am using that class as singleton as <code>sharedClient</code>. I have overriden GET and POST so for example GET looks this: </p> <pre><code>- (NSURLSessionDataTask *)GET:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void (^)(NSURLSessionDataTask *task, id responseObject))success failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure { NSURLSessionDataTask *task = [super GET:URLString parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) { success(task, responseObject); } failure:^(NSURLSessionDataTask *task, NSError *error) { failure(task, [Response createErrorWithAFNetworkingError:error]); }]; return task; } </code></pre> <p>Do you have any idea how to implement in that manner (if it's possible) to wrap that as <code>NSOperation</code>? So what I want to do - I want to be able to run in parallel two network calls, and after that have another method call that depends on second network call of first two calls. Do you have any idea what would be best approach?</p>
0debug
Javascript: find english word in string : <p>i want to find any english word (min 4 letters) in one string.</p> <pre><code>Eg: hello123fdwelcome =&gt; ["hello", "welcome"]; </code></pre> <p>Could you suggest for me any solution or javascript lib to match english word.</p> <p>Thanks</p>
0debug
How to use jdbc with SQL developper : I'm trying to connect with my Eclipse program on my database in SQL developper. I searched on the internet ,but there is just one video and it doesn't work. https://www.youtube.com/watch?v=UGG_N9Mlgdw Mine doesn't turn like in the video. I know I have to insert the following jdbc:oracle:thin@myserver:1521/demodb,but it doesn't work. I think I have to provide a link between sql developper and eclipse ,but i don't know how. PS:I have an account provided from school to use sql developper. I can do that ,or it doesn't work?
0debug
static inline void gen_set_Rc0 (DisasContext *ctx) { gen_op_cmpi(0); gen_op_set_Rc0(); }
1threat
static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; enum AVAudioServiceType *ast; int eac3info, acmod, lfeon, bsmod; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams-1]; ast = (enum AVAudioServiceType*)ff_stream_new_side_data(st, AV_PKT_DATA_AUDIO_SERVICE_TYPE, sizeof(*ast)); if (!ast) return AVERROR(ENOMEM); avio_rb16(pb); eac3info = avio_rb24(pb); bsmod = (eac3info >> 12) & 0x1f; acmod = (eac3info >> 9) & 0x7; lfeon = (eac3info >> 8) & 0x1; st->codec->channel_layout = avpriv_ac3_channel_layout_tab[acmod]; if (lfeon) st->codec->channel_layout |= AV_CH_LOW_FREQUENCY; st->codec->channels = av_get_channel_layout_nb_channels(st->codec->channel_layout); *ast = bsmod; if (st->codec->channels > 1 && bsmod == 0x7) *ast = AV_AUDIO_SERVICE_TYPE_KARAOKE; st->codec->audio_service_type = *ast; return 0; }
1threat
static Suite *qjson_suite(void) { Suite *suite; TCase *string_literals, *number_literals, *keyword_literals; TCase *dicts, *lists, *whitespace, *varargs; string_literals = tcase_create("String Literals"); tcase_add_test(string_literals, simple_string); tcase_add_test(string_literals, escaped_string); tcase_add_test(string_literals, single_quote_string); tcase_add_test(string_literals, vararg_string); number_literals = tcase_create("Number Literals"); tcase_add_test(number_literals, simple_number); tcase_add_test(number_literals, float_number); tcase_add_test(number_literals, vararg_number); keyword_literals = tcase_create("Keywords"); tcase_add_test(keyword_literals, keyword_literal); dicts = tcase_create("Objects"); tcase_add_test(dicts, simple_dict); lists = tcase_create("Lists"); tcase_add_test(lists, simple_list); whitespace = tcase_create("Whitespace"); tcase_add_test(whitespace, simple_whitespace); varargs = tcase_create("Varargs"); tcase_add_test(varargs, simple_varargs); suite = suite_create("QJSON test-suite"); suite_add_tcase(suite, string_literals); suite_add_tcase(suite, number_literals); suite_add_tcase(suite, keyword_literals); suite_add_tcase(suite, dicts); suite_add_tcase(suite, lists); suite_add_tcase(suite, whitespace); suite_add_tcase(suite, varargs); return suite; }
1threat
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
How to limit Max Length of Draft js : <p>How to limit max characters in draft js?</p> <p>I can get length of the state like that, but how to stop updating component?</p> <pre><code>var length = editorState.getCurrentContent().getPlainText('').length; </code></pre>
0debug
Where to store a JWT token properly and safely in a web based application? : <p>I've heard about browser storage and cookies but can't figure what is the best secure way to store a token. Also don't know if other methods exists, or if any third-part libraries does the work correctly.</p> <p>I'd like to have an exhaustive list of available methods to do so, with advantages/inconvenients of each and the best way above all, if any.</p>
0debug
static void virtio_mmio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = virtio_mmio_realizefn; dc->reset = virtio_mmio_reset; set_bit(DEVICE_CATEGORY_MISC, dc->categories); dc->props = virtio_mmio_properties; }
1threat
How to combine forms from two different solutions together C# : <p>I'm new to C# and wrote two different applications using Visual Studio 2015, each with a single Form. I didn't know how to have multiple forms together in one project (should've begun that way, to my everlasting regret), but now I need that to happen. I already found instructions on how to switch between forms in a project, so could someone please help me putting them together first in one application?</p>
0debug
sql server start job at specific step using bat script : I am trying execute the SQL Server job using the batch command. i have the below command to call a job. But i want to skip the first 4 steps. osql -S “[SQL SERVER NAME]” -E -Q”exec msdb.dbo.sp_start_job ‘[SQL JOB NAME]‘”
0debug
Cannot find name '$' in TS file unless referenced in every file : <p>I'm setting up typescript in Visual Studio 2015. I'm going to be using jquery with the TS files. When I use jquery, VS will underline the '$' and say cannot find name, and will not build successfully. The only way it will build is if I add the reference to jquery typings in each TS file. <code>/// &lt;reference path="typings/index.d.ts" /&gt;</code> Is there anyway to use this reference globally instead of adding it to every file?</p> <p>In Visual Studio Code I dont have this issue.</p> <p>My directory looks like this -Scripts --ts ---typings ---main.ts tsconfig.json --js</p> <p>My tasks.json file in the root</p> <pre><code> { "version": "0.1.0", // The command is tsc. Assumes that tsc has been installed using npm install -g typescript "command": "tsc", // The command is a shell script "isShellCommand": true, // Show the output window only if unrecognized errors occur. "showOutput": "silent", // Tell the tsc compiler to use the tsconfig.json from the open folder. "args": ["-p", "../Scripts/Weblink/ts"], // use the standard tsc problem matcher to find compile problems // in the output. "problemMatcher": "$tsc" } </code></pre> <hr> <p>taskconfig.json in Scripts/ts</p> <pre><code>{ "compileOnSave": true, "compilerOptions": { "noImplicitAny": false, "noEmitOnError": true, "removeComments": false, "sourceMap": true, "target": "es5", "outDir": "../lib/" }, "exclude": [ "typings/*" ] } </code></pre>
0debug
static void blkdebug_debug_event(BlockDriverState *bs, BlkDebugEvent event) { BDRVBlkdebugState *s = bs->opaque; struct BlkdebugRule *rule; bool injected; assert((int)event >= 0 && event < BLKDBG_EVENT_MAX); injected = false; s->new_state = s->state; QLIST_FOREACH(rule, &s->rules[event], next) { injected = process_rule(bs, rule, injected); } s->state = s->new_state; }
1threat
static void tlb_flush_nocheck(CPUState *cpu) { CPUArchState *env = cpu->env_ptr; if (!tcg_enabled()) { return; } assert_cpu_is_self(cpu); tlb_debug("(count: %d)\n", tlb_flush_count++); tb_lock(); memset(env->tlb_table, -1, sizeof(env->tlb_table)); memset(env->tlb_v_table, -1, sizeof(env->tlb_v_table)); memset(cpu->tb_jmp_cache, 0, sizeof(cpu->tb_jmp_cache)); env->vtlb_index = 0; env->tlb_flush_addr = -1; env->tlb_flush_mask = 0; tb_unlock(); atomic_mb_set(&cpu->pending_tlb_flush, 0); }
1threat
Where can I find the full contents of the iOS root (/) directory? : <p>I am an exploit developer/penetration tester for Maroon Penetration Testing based in Oklahoma (private organization) and I am currently looking for vulnerabilities in iOS, but I would either need the source code of iOS or the system files (root or / directory). I am running iOS 10.2.1 and it is nearly impossible to jailbreak the device, downgrading is not an option either. If there is anywhere I can download the source of iOS 10.2.1/ the root directory contents that would be awesome, or if there is any way to retrieve them myself that would be even better.</p> <p>Regards, Noodles.</p>
0debug
how to import all css of node_modules in vuejs : <p>I am building a Vue.js app starting with the webpack template and vuetify. To import vuetify css Im doing this in my <strong>App.vue</strong></p> <p><code>&lt;style&gt; @import '../node_modules/vuetify/dist/vuetify.min.css' &lt;/style&gt;</code></p> <p>Is this the correct or only way? because it doesn't seem reliable when using multiple UI components.</p>
0debug
Multiple Queries in active record ruby on rails : `def c program = Program.first ids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] members = Member.where(id: ids) for i in 0..ids.count-1 members.find_by(id: ids[i]).location end end` If I run the above query in rails console. multiple queries(Member object queries) are being fired(one for each value of i). The members are already in memory right(members variable)? How to get above-needed data making a single query. Member Load (0.2ms) SELECT `members`.* FROM `members` WHERE `members`.`id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) AND `members`.`id` = 1 LIMIT 1 ProfileAnswer Load (0.4ms) SELECT `profile_answers`.* FROM `profile_answers` WHERE `profile_answers`.`member_id` = 1 Member Load (0.4ms) SELECT `members`.* FROM `members` WHERE `members`.`id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) AND `members`.`id` = 2 LIMIT 1 ProfileAnswer Load (0.2ms) SELECT `profile_answers`.* FROM `profile_answers` WHERE `profile_answers`.`member_id` = 2 Member Load (0.2ms) SELECT `members`.* FROM `members` WHERE `members`.`id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) AND `members`.`id` = 3 LIMIT 1 ProfileAnswer Load (0.2ms) SELECT `profile_answers`.* FROM `profile_answers` WHERE `profile_answers`.`member_id` = 3 Member Load (0.2ms) SELECT `members`.* FROM `members` WHERE `members`.`id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) AND `members`.`id` = 4 LIMIT 1 ProfileAnswer Load (0.2ms) SELECT `profile_answers`.* FROM `profile_answers` WHERE `profile_answers`.`member_id` = 4 Member Load (0.2ms) SELECT `members`.* FROM `members` WHERE `members`.`id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) AND `members`.`id` = 5 LIMIT 1 ProfileAnswer Load (0.2ms) SELECT `profile_answers`.* FROM `profile_answers` WHERE `profile_answers`.`member_id` = 5 Member Load (0.4ms) SELECT `members`.* FROM `members` WHERE `members`.`id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) AND `members`.`id` = 6 LIMIT 1 P.S: I can't use member.each as the iterator is on different condition.
0debug
static uint64_t memcard_read(void *opaque, target_phys_addr_t addr, unsigned size) { MilkymistMemcardState *s = opaque; uint32_t r = 0; addr >>= 2; switch (addr) { case R_CMD: if (!s->enabled) { r = 0xff; } else { r = s->response[s->response_read_ptr++]; if (s->response_read_ptr > s->response_len) { error_report("milkymist_memcard: " "read more cmd bytes than available. Clipping."); s->response_read_ptr = 0; } } break; case R_DAT: if (!s->enabled) { r = 0xffffffff; } else { r = 0; r |= sd_read_data(s->card) << 24; r |= sd_read_data(s->card) << 16; r |= sd_read_data(s->card) << 8; r |= sd_read_data(s->card); } break; case R_CLK2XDIV: case R_ENABLE: case R_PENDING: case R_START: r = s->regs[addr]; break; default: error_report("milkymist_memcard: read access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } trace_milkymist_memcard_memory_read(addr << 2, r); return r; }
1threat
What to do with old users in /etc/shadow after foramtting the home partition? : My `/home` partition was corrupted, so i had to backup the drive and format it. My all other partitions (including `/root`) do still work. I am willing to setup new users now, but old users like `www-dev`, `avahi`, plus my personal old-user home folder still all exist in `/etc/shadow`. How can I delete them? Can i still use my `/root` partition? I am still able to boot into my Linux OS and login with user root.
0debug
static void rdma_accept_incoming_migration(void *opaque) { RDMAContext *rdma = opaque; int ret; QEMUFile *f; Error *local_err = NULL, **errp = &local_err; DPRINTF("Accepting rdma connection...\n"); ret = qemu_rdma_accept(rdma); if (ret) { ERROR(errp, "RDMA Migration initialization failed!"); return; } DPRINTF("Accepted migration\n"); f = qemu_fopen_rdma(rdma, "rb"); if (f == NULL) { ERROR(errp, "could not qemu_fopen_rdma!"); qemu_rdma_cleanup(rdma); return; } rdma->migration_started_on_destination = 1; process_incoming_migration(f); }
1threat
Telerik Kendo MVC TextBox Multiline Mode : <p>Does anyone know what properties to set to make a Kendo MVC Textbox Multiline?</p> <pre><code> @(Html.Kendo().TextBox() .Name("txtComments") .Value(@Model.Comments) .HtmlAttributes(new { style = "width:100%" }) ) </code></pre> <p>Thanks.</p>
0debug
static int bink_decode_plane(BinkContext *c, AVFrame *frame, BitstreamContext *bc, int plane_idx, int is_chroma) { int blk, ret; int i, j, bx, by; uint8_t *dst, *prev, *ref_start, *ref_end; int v, col[2]; const uint8_t *scan; LOCAL_ALIGNED_16(int16_t, block, [64]); LOCAL_ALIGNED_16(uint8_t, ublock, [64]); LOCAL_ALIGNED_16(int32_t, dctblock, [64]); int coordmap[64]; const int stride = frame->linesize[plane_idx]; int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3; int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3; int width = c->avctx->width >> is_chroma; init_lengths(c, FFMAX(width, 8), bw); for (i = 0; i < BINK_NB_SRC; i++) read_bundle(bc, c, i); ref_start = c->last->data[plane_idx] ? c->last->data[plane_idx] : frame->data[plane_idx]; ref_end = ref_start + (bw - 1 + c->last->linesize[plane_idx] * (bh - 1)) * 8; for (i = 0; i < 64; i++) coordmap[i] = (i & 7) + (i >> 3) * stride; for (by = 0; by < bh; by++) { if ((ret = read_block_types(c->avctx, bc, &c->bundle[BINK_SRC_BLOCK_TYPES])) < 0) return ret; if ((ret = read_block_types(c->avctx, bc, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES])) < 0) return ret; if ((ret = read_colors(bc, &c->bundle[BINK_SRC_COLORS], c)) < 0) return ret; if ((ret = read_patterns(c->avctx, bc, &c->bundle[BINK_SRC_PATTERN])) < 0) return ret; if ((ret = read_motion_values(c->avctx, bc, &c->bundle[BINK_SRC_X_OFF])) < 0) return ret; if ((ret = read_motion_values(c->avctx, bc, &c->bundle[BINK_SRC_Y_OFF])) < 0) return ret; if ((ret = read_dcs(c->avctx, bc, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0)) < 0) return ret; if ((ret = read_dcs(c->avctx, bc, &c->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1)) < 0) return ret; if ((ret = read_runs(c->avctx, bc, &c->bundle[BINK_SRC_RUN])) < 0) return ret; if (by == bh) break; dst = frame->data[plane_idx] + 8*by*stride; prev = (c->last->data[plane_idx] ? c->last->data[plane_idx] : frame->data[plane_idx]) + 8*by*stride; for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) { blk = get_value(c, BINK_SRC_BLOCK_TYPES); if ((by & 1) && blk == SCALED_BLOCK) { bx++; dst += 8; prev += 8; continue; } switch (blk) { case SKIP_BLOCK: c->hdsp.put_pixels_tab[1][0](dst, prev, stride, 8); break; case SCALED_BLOCK: blk = get_value(c, BINK_SRC_SUB_BLOCK_TYPES); switch (blk) { case RUN_BLOCK: scan = bink_patterns[bitstream_read(bc, 4)]; i = 0; do { int run = get_value(c, BINK_SRC_RUN) + 1; i += run; if (i > 64) { av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return AVERROR_INVALIDDATA; } if (bitstream_read_bit(bc)) { v = get_value(c, BINK_SRC_COLORS); for (j = 0; j < run; j++) ublock[*scan++] = v; } else { for (j = 0; j < run; j++) ublock[*scan++] = get_value(c, BINK_SRC_COLORS); } } while (i < 63); if (i == 63) ublock[*scan++] = get_value(c, BINK_SRC_COLORS); break; case INTRA_BLOCK: memset(dctblock, 0, sizeof(*dctblock) * 64); dctblock[0] = get_value(c, BINK_SRC_INTRA_DC); read_dct_coeffs(bc, dctblock, bink_scan, bink_intra_quant, -1); c->binkdsp.idct_put(ublock, 8, dctblock); break; case FILL_BLOCK: v = get_value(c, BINK_SRC_COLORS); c->bdsp.fill_block_tab[0](dst, v, stride, 16); break; case PATTERN_BLOCK: for (i = 0; i < 2; i++) col[i] = get_value(c, BINK_SRC_COLORS); for (j = 0; j < 8; j++) { v = get_value(c, BINK_SRC_PATTERN); for (i = 0; i < 8; i++, v >>= 1) ublock[i + j*8] = col[v & 1]; } break; case RAW_BLOCK: for (j = 0; j < 8; j++) for (i = 0; i < 8; i++) ublock[i + j*8] = get_value(c, BINK_SRC_COLORS); break; default: av_log(c->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", blk); return AVERROR_INVALIDDATA; } if (blk != FILL_BLOCK) c->binkdsp.scale_block(ublock, dst, stride); bx++; dst += 8; prev += 8; break; case MOTION_BLOCK: ret = bink_put_pixels(c, dst, prev, stride, ref_start, ref_end); if (ret < 0) return ret; break; case RUN_BLOCK: scan = bink_patterns[bitstream_read(bc, 4)]; i = 0; do { int run = get_value(c, BINK_SRC_RUN) + 1; i += run; if (i > 64) { av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return AVERROR_INVALIDDATA; } if (bitstream_read_bit(bc)) { v = get_value(c, BINK_SRC_COLORS); for (j = 0; j < run; j++) dst[coordmap[*scan++]] = v; } else { for (j = 0; j < run; j++) dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS); } } while (i < 63); if (i == 63) dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS); break; case RESIDUE_BLOCK: ret = bink_put_pixels(c, dst, prev, stride, ref_start, ref_end); if (ret < 0) return ret; c->bdsp.clear_block(block); v = bitstream_read(bc, 7); read_residue(bc, block, v); c->binkdsp.add_pixels8(dst, block, stride); break; case INTRA_BLOCK: memset(dctblock, 0, sizeof(*dctblock) * 64); dctblock[0] = get_value(c, BINK_SRC_INTRA_DC); read_dct_coeffs(bc, dctblock, bink_scan, bink_intra_quant, -1); c->binkdsp.idct_put(dst, stride, dctblock); break; case FILL_BLOCK: v = get_value(c, BINK_SRC_COLORS); c->bdsp.fill_block_tab[1](dst, v, stride, 8); break; case INTER_BLOCK: ret = bink_put_pixels(c, dst, prev, stride, ref_start, ref_end); if (ret < 0) return ret; memset(dctblock, 0, sizeof(*dctblock) * 64); dctblock[0] = get_value(c, BINK_SRC_INTER_DC); read_dct_coeffs(bc, dctblock, bink_scan, bink_inter_quant, -1); c->binkdsp.idct_add(dst, stride, dctblock); break; case PATTERN_BLOCK: for (i = 0; i < 2; i++) col[i] = get_value(c, BINK_SRC_COLORS); for (i = 0; i < 8; i++) { v = get_value(c, BINK_SRC_PATTERN); for (j = 0; j < 8; j++, v >>= 1) dst[i*stride + j] = col[v & 1]; } break; case RAW_BLOCK: for (i = 0; i < 8; i++) memcpy(dst + i*stride, c->bundle[BINK_SRC_COLORS].cur_ptr + i*8, 8); c->bundle[BINK_SRC_COLORS].cur_ptr += 64; break; default: av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk); return AVERROR_INVALIDDATA; } } } if (bitstream_tell(bc) & 0x1F) bitstream_skip(bc, 32 - (bitstream_tell(bc) & 0x1F)); return 0; }
1threat
How to run a sentence as root in perl : <p>I have made a perl program that add users to the system using apache2. It works when i run as a root but i am using it in a register from a html therefore the program is running by that user (i think) and it doesn't work. The error in /var/log/apache2/error.log is : <code>"AH1215: can't open_a /etc/passwd Permission denied at /usr/lib/cgi-bin/registro.cgi line 60"</code> that line is the following </p> <pre><code>Linux::usermod-&gt;add($user,$password) </code></pre> <p>One solution must be give the permission +s using chmod +s to the registro.cgi but it is not allowed to use that way.</p>
0debug
void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) { GArray *table_offsets; unsigned dsdt, rsdt; VirtAcpiCpuInfo cpuinfo; GArray *tables_blob = tables->table_data; virt_acpi_get_cpu_info(&cpuinfo); table_offsets = g_array_new(false, true , sizeof(uint32_t)); bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE, 64, false ); dsdt = tables_blob->len; build_dsdt(tables_blob, tables->linker, guest_info); acpi_add_table(table_offsets, tables_blob); build_fadt(tables_blob, tables->linker, dsdt); acpi_add_table(table_offsets, tables_blob); build_madt(tables_blob, tables->linker, guest_info, &cpuinfo); acpi_add_table(table_offsets, tables_blob); build_gtdt(tables_blob, tables->linker); acpi_add_table(table_offsets, tables_blob); build_mcfg(tables_blob, tables->linker, guest_info); acpi_add_table(table_offsets, tables_blob); build_spcr(tables_blob, tables->linker, guest_info); rsdt = tables_blob->len; build_rsdt(tables_blob, tables->linker, table_offsets); build_rsdp(tables->rsdp, tables->linker, rsdt); g_array_free(table_offsets, true); }
1threat
i'm trying to catch the number '1' before any '9781612680880' for example : [regex to catch the quantity number only ][1] [1]: https://i.stack.imgur.com/oXfNe.png
0debug
Load image and css in Golang : <p>I setup a route in <code>server.js</code> in package <code>main</code> in root directory of project</p> <p><code>http.HandleFunc("/",route.IndexHandler)</code></p> <p>The <code>IndexHandler</code> is implemented in package <code>route</code> like this:</p> <pre><code>func IndexHandler(w http.ResponseWriter, r *http.Request) { data:=struct{ Name string }{ "My name", } util.RenderTemplate(w, "index", data) } </code></pre> <p>The <code>RenderTemplate</code> function is implemented in package <code>util</code> like this:</p> <pre><code>func RenderTemplate(w http.ResponseWriter, tmpl string, data interface{}) { cwd, _ := os.Getwd() t, err := template.ParseFiles(filepath.Join(cwd, "./view/" + tmpl + ".html")) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } err = t.Execute(w, data) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } } </code></pre> <p>Directory structure in project like this:</p> <pre><code>/ /public/css /public/images /public/js /route /view </code></pre> <p><code>index.html</code> view is located in folder <code>view</code>, router is in folder <code>route</code></p> <p>In <code>index.html</code> I include resources like these:</p> <p><code>&lt;link rel="stylesheet" type="text/css" href="../public/css/style.css"&gt;</code></p> <p><code>&lt;img src="../public/images/img_landing_page_mac.png"&gt;</code></p> <p>When request the appropriate path, <code>index.html</code> is still rendered, but images and stylesheet are not loaded. How can I do to include them in Golang html template engine?</p>
0debug
Check getOne(id) null or entity not found? : I'm try (must) use getOne for get data form DB, and when entity not found, I can not check with obj = repository.getOne(id); if(obj == null){//error ... } I want to check if entity found or not, can you help me in this case ? Thanks all!
0debug
c# string.CompareOrdinal vs operator == : <p>I want to compare two strings in a <code>linq</code> expression. Do I take advantage if I use `string.CompareOrdinal or is it the same?</p> <pre><code>list.Where(str1 =&gt; string.CompareOrdinal(str1, str2) == 0); list.Where(str1 =&gt; str1 == str2); </code></pre>
0debug
What are insets in android? : <p>I am beginner at android development. I was recently looking at some one else code and fond some functions <code>view.onApplyWindowInsets(windowInsets), windowInsets.getSystemWindowInsetTop()</code>. And this word was used again and again in the same app.</p> <p>I tried googling it and found <code>InsetDrwable</code> class with explanation</p> <blockquote> <p>A Drawable that insets another Drawable by a specified distance. This is used when a View needs a background that is smaller than the View's actual bounds.</p> </blockquote> <p>Can some one explain me what is the meaning on <code>Insets</code> and what those piece of code up there meant?</p> <p>A explanation with an example will be appreciated. </p>
0debug
UNIX not being able to access file even after 777 permissio : I have file placed at location /orabin/hrtst/TEST /orabin/hrtst/TEST$ ls -ltr Lookup_code.log -rwxrwxrwx 1 xxhcmuser dba 0 Feb 25 15:08 Lookup_code.log I want the -rwxrwxrwx permission to change to `drwxrwxrwx` what command can i use ?
0debug
Can I call APIs in componentWillMount in React? : <p>I'm working on react for last 1 year. The convention which we follow is make an API call in <code>componentDidMount</code>, fetch the data and setState after the data has come. This will ensure that the component has mounted and setting state will cause a re-render the component but I want to know why we can't setState in <code>componentWillMount</code> or <code>constructor</code></p> <p>The official documentation says that : </p> <blockquote> <p>componentWillMount() is invoked immediately before mounting occurs. It is called before render(), therefore setting state in this method will not trigger a re-rendering. Avoid introducing any side-effects or subscriptions in this method.</p> </blockquote> <p>it says <code>setting state in this method will not trigger a re-rendering</code>, which I don't want while making an API call. If I'm able to get the data and able to set in the state (assuming API calls are really fast) in <code>componentWillMount</code> or in <code>constructor</code> and data is present in the first render, why would I want a re-render at all?</p> <p>and if the API call is slow, then <code>setState</code> will be async and <code>componentWillMount</code> has already returned then I'll be able to setState and a re-render should occur. </p> <p>As a whole, I'm pretty much confused why we shouldn't make API calls in constructor or componentWillMount. Can somebody really help me understand how react works in such case?</p>
0debug
Angular2 component with clipboardData property : <p>I have an Angular2 component with a method to paste data from the clipboard:</p> <pre><code>inputPaste(event){ let clipboardData = event.clipboardData; ... </code></pre> <p>}</p> <p>This way doesn't work for IE10+, but IE have a window object with a property clipboardData, but typescript compilator throws an error:</p> <pre><code>inputPaste(event){ let clipboardData = event.clipboardData || window.clipboardData; //error 'clipboardData' does not exist on type Windows ... </code></pre> <p>}</p> <p>I have found a solution, that we must use angular2-clipboard directive, but I wan't to use it.</p> <p>How can I use <code>'windows.clipboardData'</code> in typescript?</p>
0debug
Laravel: blade foreach looping bootstrap columns : <p>I have a foreach loop and inside that contains html with bootstrap columns.</p> <pre><code>@foreach($address as $add) &lt;div class="col-md-6"&gt; Some data &lt;/div&gt; @endforeach </code></pre> <p>However, bootstrap requires the row div before creating columns, placing that straight in to the foreach loop would create a row div for each col-md-6. I want to know how I can throw in the row div, skip the next loop throwing in only the closing div tag. And then repeat that process.</p> <p>Example output where the loops 4 times:</p> <pre><code>&lt;div class="row"&gt; &lt;div class="col-md-6"&gt; Some data &lt;/div&gt; &lt;div class="col-md-6"&gt; Some data &lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="col-md-6"&gt; Some data &lt;/div&gt; &lt;div class="col-md-6"&gt; Some data &lt;/div&gt; &lt;/div&gt; </code></pre>
0debug
I'm trying to create a Java program to create and write a text file, but : <pre><code>public static void main(String[] args) { File newTxt = new File("C:/Users/cauan/Desktop/newTxt.txt"); if(newTxt.exists()) System.out.println("The file already exists!"); else { try{ newTxt.createNewFile(); FileWriter fw=new FileWriter(newTxt); BufferedWriter bw = new BufferedWriter(fw); bw.write("This is my Prog"); } catch(Exception e){e.printStackTrace();} } } </code></pre> <p>This is my code.... But i dunno why am i getting an error :/</p>
0debug
*****Newbie***** Pimary keys in db : Thanks folks! This from an online Khan tutorial on sql: 1) How do I know that student_id in students_grades is related to id in student? 2) Why is there no value for primary key in students? Thanks a lot. ================================= CREATE TABLE students (id INTEGER PRIMARY KEY, first_name TEXT, last_name TEXT, email TEXT, phone TEXT, birthdate TEXT); INSERT INTO students (first_name, last_name, email, phone, birthdate) VALUES ("Peter", "Rabbit", "peter@rabbit.com", "555-6666", "2002-06-24"); INSERT INTO students (first_name, last_name, email, phone, birthdate) VALUES ("Alice", "Wonderland", "alice@wonderland.com", "555-4444", "2002-07-04"); CREATE TABLE student_grades (id INTEGER PRIMARY KEY, student_id INTEGER, test TEXT, grade INTEGER); INSERT INTO student_grades (student_id, test, grade) VALUES (1, "Nutrition", 95); INSERT INTO student_grades (student_id, test, grade) VALUES (2, "Nutrition", 92); INSERT INTO student_grades (student_id, test, grade) VALUES (1, "Chemistry", 85); INSERT INTO student_grades (student_id, test, grade) VALUES (2, "Chemistry", 95);
0debug
static int check_jni_invocation(void *log_ctx) { int ret = AVERROR_EXTERNAL; void *handle = NULL; void **jni_invocation = NULL; handle = dlopen(NULL, RTLD_LOCAL); if (!handle) { goto done; } jni_invocation = (void **)dlsym(handle, "_ZN13JniInvocation15jni_invocation_E"); if (!jni_invocation) { av_log(log_ctx, AV_LOG_ERROR, "Could not find JniInvocation::jni_invocation_ symbol\n"); goto done; } ret = !(jni_invocation != NULL && *jni_invocation != NULL); done: if (handle) { dlclose(handle); } return ret; }
1threat
What is the difference of static Computational Graphs in tensorflow and dynamic Computational Graphs in Pytorch? : <p>When I was learning tensorflow, one basic concept of tensorflow was computational graphs, and the graphs was said to be static. And I found in Pytorch, the graphs was said to be dynamic. What's the difference of static Computational Graphs in tensorflow and dynamic Computational Graphs in Pytorch?</p>
0debug
static void copy_frame(J2kEncoderContext *s) { int tileno, compno, i, y, x; uint8_t *line; for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){ J2kTile *tile = s->tile + tileno; if (s->planar){ for (compno = 0; compno < s->ncomponents; compno++){ J2kComponent *comp = tile->comp + compno; int *dst = comp->data; line = s->picture->data[compno] + comp->coord[1][0] * s->picture->linesize[compno] + comp->coord[0][0]; for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){ uint8_t *ptr = line; for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++) *dst++ = *ptr++ - (1 << 7); line += s->picture->linesize[compno]; } } } else{ line = s->picture->data[0] + tile->comp[0].coord[1][0] * s->picture->linesize[0] + tile->comp[0].coord[0][0] * s->ncomponents; i = 0; for (y = tile->comp[0].coord[1][0]; y < tile->comp[0].coord[1][1]; y++){ uint8_t *ptr = line; for (x = tile->comp[0].coord[0][0]; x < tile->comp[0].coord[0][1]; x++, i++){ for (compno = 0; compno < s->ncomponents; compno++){ tile->comp[compno].data[i] = *ptr++ - (1 << 7); } } line += s->picture->linesize[0]; } } } }
1threat
Heroku: Connection to log stream failed. Please try again later. When trying to access the logs : <p>I am running a Nodejs server on Heroku, but when I try to view/access the log I get this error message saying:</p> <blockquote> <p>Connection to log stream failed. Please try again later.</p> </blockquote> <p>along with a popup that shows up at top right corner <a href="https://i.stack.imgur.com/7WNMo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7WNMo.png" alt="enter image description here"></a></p> <p>I went to check the logs for another Heroku project that I have and the same thing was happening there as well. Any ideas as for why that's happening?</p>
0debug
How can i parse this json file in android studio? : <p>how can i parse this json file because the text do not have any particular indexing names </p> <pre><code> { "titles": [ " Thoughts On The Works Of Providence", "\"All Is Vanity, Saith the Preacher\"", "\"And the sins of the fathers shall be\"", "\"Arcturus\" is his other name", "\"By the Waters of Babylon.\"", "\"De Gustibus--\"", "\"Faith\" is a fine invention", "\"Faithful to the end\" Amended", "\"Heaven\" -- is what I cannot reach!", "\"Heaven\" has different Signs -- to me --", "\"Heavenly Father\" -- take to thee", "\"Home\"", ] } </code></pre>
0debug
Please help me with converting datas in swift from NSArray to Dictionary : Please help me with converting datas in swift4 I need convert NSArray to Dictionary, but don't know how can I do it((( After fetch request I have result in NSArray ``var results: NSArray = [] print(results)`` give me <Attendee: 0x60c000097750> (entity: Attendee; id: 0x60c000422200 <x-coredata:///Attendee/t9E88E2EE-9258-4FAE-AF80-9B036838C6D631> ; data: { address = "1411 E 31st St"; affiliation = ""; attendeeType = nil; city = Aguanga; degree = MD; email = ""; fax = ""; firstName = Oliver1212; fullStateLicense = ""; id = nil; lastName = Aalami; meeting = nil; needUpdate = 1; phone = ""; signature = nil; signatureTimeStamp = nil; specialty = Surgery; state = CA; stateLicense = ""; status = nil; timeStamp = nil; zip = 92536; }) I need to put these datas to: `let dic4Attendee: [String: Any] = [:]` Maybe somebody can help me?
0debug
Calculate number of overlapping intervals at x : <p>Let's say I have a number of intervals on the same x axis. How do I get the number of intervals for a specific x value?</p> <p>I search for an easy solution with a python package.</p> <p><a href="https://i.stack.imgur.com/Tq5KL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tq5KL.png" alt="enter image description here"></a></p>
0debug
How to Print String without putting it inside double quotes : <p>This string needs to be printed without using double quotes. </p> <pre><code> Class Test{ public static void main(String args[]){ //print "I am khushi" but it should not be printed like //System.out.println("I am khushi"); } } </code></pre>
0debug
Python Lambda return true even with false condition : >>> if lambda x: True == True: ... print('yes') ... yes >>> if lambda x: False == True: ... print('yes')
0debug
static int h263_decode_gob_header(MpegEncContext *s) { unsigned int val, gob_number; int left; val = show_bits(&s->gb, 16); if(val) return -1; skip_bits(&s->gb, 16); left= get_bits_left(&s->gb); for(;left>13; left--){ if(get_bits1(&s->gb)) break; } if(left<=13) return -1; if(s->h263_slice_structured){ if(check_marker(s->avctx, &s->gb, "before MBA")==0) return -1; ff_h263_decode_mba(s); if(s->mb_num > 1583) if(check_marker(s->avctx, &s->gb, "after MBA")==0) return -1; s->qscale = get_bits(&s->gb, 5); if(check_marker(s->avctx, &s->gb, "after SQUANT")==0) return -1; skip_bits(&s->gb, 2); }else{ gob_number = get_bits(&s->gb, 5); s->mb_x= 0; s->mb_y= s->gob_index* gob_number; skip_bits(&s->gb, 2); s->qscale = get_bits(&s->gb, 5); } if(s->mb_y >= s->mb_height) return -1; if(s->qscale==0) return -1; return 0; }
1threat
int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv) { BusChild *kid; I2CSlaveClass *sc; I2CNode *node; if (address == 0x00) { bus->broadcast = true; } QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) { DeviceState *qdev = kid->child; I2CSlave *candidate = I2C_SLAVE(qdev); if ((candidate->address == address) || (bus->broadcast)) { node = g_malloc(sizeof(struct I2CNode)); node->elt = candidate; QLIST_INSERT_HEAD(&bus->current_devs, node, next); if (!bus->broadcast) { break; } } } if (QLIST_EMPTY(&bus->current_devs)) { return 1; } QLIST_FOREACH(node, &bus->current_devs, next) { sc = I2C_SLAVE_GET_CLASS(node->elt); if (sc->event) { sc->event(node->elt, recv ? I2C_START_RECV : I2C_START_SEND); } } return 0; }
1threat
Can't use pip in Jupyter Notebook : <p>I want to use pip in Jupyter Notebook ,but there is a SyntaxError when i ran the code</p> <pre><code>pip install hyperopt File "&lt;ipython-input-3-156c4fe098ed&gt;", line 1 pip install hyperopt ^ SyntaxError: invalid syntax </code></pre> <p><a href="https://i.stack.imgur.com/frs66.jpg" rel="nofollow noreferrer">error image</a></p>
0debug
RDP session is slow : <p>So I am connecting to my work computer from home and the Remote Desktop Connection app is annoyingly slow.</p> <p>I pinged my work pc from my computer and it returned at a reasonable time of 50ms~ with 0 loss. I then attempted to ping my home IP from the RDP session and it timed out every time. Not sure if this might help anyone come to a conclusion but hopefully it does. Note I am also using it in conjunction with <strong>Cisco AnyConnect Secure Mobility Client</strong> if that helps at all. <em>Work is Windows 7</em> and <em>Home is Windows 8</em></p> <p>I attempted switching off my home pc's firewall but that did nothing.</p> <p>Any assistance would be great, surely a setting in the RDP file might make it run a little smoother.</p> <p>I'll edit this post with further attempts at fixes below</p>
0debug
Converting dateTime to different format : <p>There is a <code>dateTime</code> in the format of "dd/mm/yyyy hh:mm:ss tt". A <code>string</code> is required to be created from this, in the format of "yyyyMMddHHmmssfff". </p> <pre><code>string timestamp = (dateTimeUTC.Year).ToString() + (dateTimeUTC.Month).ToString() + (dateTimeUTC.Day).ToString() + (dateTimeUTC.Hour).ToString() + (dateTimeUTC.Minute).ToString() + (dateTimeUTC.Second).ToString() + (dateTimeUTC.Millisecond).ToString(); </code></pre> <p>The problem with this code is that if any of the digits for month or day are 0-9, there is no 0 in front of the digit. For example, suppose we have the <code>dateTime</code> 1/26/2020 11:59:53 PM. This must be converted to 20200126235651100. Instead it will be 20201262359530.</p>
0debug
static void *qpa_thread_out (void *arg) { PAVoiceOut *pa = arg; HWVoiceOut *hw = &pa->hw; int threshold; threshold = conf.divisor ? hw->samples / conf.divisor : 0; if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) { return NULL; } for (;;) { int decr, to_mix, rpos; for (;;) { if (pa->done) { goto exit; } if (pa->live > threshold) { break; } if (audio_pt_wait (&pa->pt, AUDIO_FUNC)) { goto exit; } } decr = to_mix = pa->live; rpos = hw->rpos; if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) { return NULL; } while (to_mix) { int error; int chunk = audio_MIN (to_mix, hw->samples - rpos); struct st_sample *src = hw->mix_buf + rpos; hw->clip (pa->pcm_buf, src, chunk); if (pa_simple_write (pa->s, pa->pcm_buf, chunk << hw->info.shift, &error) < 0) { qpa_logerr (error, "pa_simple_write failed\n"); return NULL; } rpos = (rpos + chunk) % hw->samples; to_mix -= chunk; } if (audio_pt_lock (&pa->pt, AUDIO_FUNC)) { return NULL; } pa->live = 0; pa->rpos = rpos; pa->decr += decr; } exit: audio_pt_unlock (&pa->pt, AUDIO_FUNC); return NULL; }
1threat
How to set custom context for docker.build in jenkinsfile : <p>I'm trying to adapt a docker build for jenkins. I'm following our docker-compose file and I'm creating a Jenkinsfile that is creating each container and linking them together. The problem I'm running into is that the docker-compose files declare a context that is not where the Dockerfile is. As far as I understand, jenkins will set the context to where the Dockerfile is, which puts files to be copied in a different relative location depending on whether the jenkinsfile or docker-compose file is building.</p> <p>The folder structure is:</p> <pre><code>workspace |-docker |-db |-Dockerfile |-entrypoint.sh </code></pre> <p>This is how the Dockerfile declares the COPY instruction for the file in question</p> <pre><code>COPY docker/db/entrypoint.sh / </code></pre> <p>This is how my jenkinsfile builds the file. Which to my knowledge puts the context at that directory</p> <pre><code>docker.build("db", "${WORKSPACE}/docker/db") </code></pre> <p>the docker-compose file declares it like:</p> <pre><code>db: build: context: . dockerfile: docker/db/Dockerfile </code></pre> <p>which puts the context at the root of the project.</p> <p>Is there any way to tell a jenkinsfile to use the same context as the docker-compose file so that the Dockerfile's COPY instruction can remain unchanged and valid for both Jenkins and docker-compose? If that's not possible, does anyone know of any alternative solutions?</p>
0debug
document.write('<script src="evil.js"></script>');
1threat
Ansible Timeout (12s) waiting for privilege escalation prompt : <p>I'm having trouble running my Ansible playbook on AWS instance. Here is my version:</p> <pre><code>$ ansible --version ansible 2.0.0.2 </code></pre> <p>I created an inventory file as:</p> <pre><code>[my_ec2_instance] default ansible_host=MY_EC2_ADDRESS ansible_user='ubuntu' ansible_ssh_private_key_file='/home/MY_USER/MY_KEYS/MY_KEY.pem' </code></pre> <p>Testing connection to my server:</p> <pre><code>$ ansible -i provisioner/inventory my_ec2_instance -m ping default | SUCCESS =&gt; { "changed": false, "ping": "pong" } </code></pre> <p>Now when running my playbook on this inventory I get the error <code>Timeout (12s) waiting for privilege escalation prompt</code> as follows:</p> <pre><code>$ ansible-playbook -i provisioner/inventory -l my_ec2_instance provisioner/playbook.yml PLAY [Ubuntu14/Python3/Postgres/Nginx/Gunicorn/Django stack] ***** TASK [setup] ******************************************************************* fatal: [default]: FAILED! =&gt; {"failed": true, "msg": "ERROR! Timeout (12s) waiting for privilege escalation prompt: "} NO MORE HOSTS LEFT ************************************************************* PLAY RECAP ********************************************************************* default : ok=0 changed=0 unreachable=0 failed=1 </code></pre> <p>If I run the same playbook using the <code>.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory</code> as the inventory parameter it works perfectly on my Vagrant instance.(I believe, proving there is nothing wrong in the playbook/roles itself)</p> <p>Also, if I run it with an <code>-vvvv</code>, copy the <code>exec ssh</code> line and run it manually it indeed connects to AWS without problems.</p> <p>Do I need to add any other parameter on my inventory file to connect an EC2 instance? What am I missing?</p>
0debug
How to create a button Inside a Fragment? : **This is my code**: Iam creating a fragment Were If I click on the button It should Show Tost Message public class Aboutus extends Fragment implements View.OnClickListener{ Button ps,fb; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view= inflater.inflate(R.layout.about_layout, container, false); ps = (Button) view.findViewById(R.id.ps_btn); fb = (Button) view.findViewById(R.id.fb_btn); try { ps.setOnClickListener(this); }catch (ActivityNotFoundException exception) { } //fb.setOnClickListener(this); return view; } @Override public void onClick(View v) { switch (v.getId()) { case R.id.fb_btn: Toast.makeText(getActivity(), "This is my Toast message!", Toast.LENGTH_LONG).show(); break; case R.id.ps_btn: Toast.makeText(getActivity(), "This is my Toast message!", Toast.LENGTH_LONG).show(); break; } } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); //you can set the title for your toolbar here for different fragments different titles getActivity().setTitle("ABOUT US"); } } **My app is Stoped working when i open the fragment..please Help**
0debug
static void rv40_h_loop_filter(uint8_t *src, int stride, int dmode, int lim_q1, int lim_p1, int alpha, int beta, int beta2, int chroma, int edge){ rv40_adaptive_loop_filter(src, stride, 1, dmode, lim_q1, lim_p1, alpha, beta, beta2, chroma, edge); }
1threat
Problem with querying database in mysql 5.7.26 : <p>I am learning php and mysql, and I'm currently reading a book where I'm trying out the examples on my own webserver.</p> <p>I had no problem setting up the database I'm using, and the code I am using to insert new rows into my database table works perfectly when I test it by writing directly in the INSERT code the values I want to insert. However, when I try to insert variables from $_POST into the mysql INSERT code, I get an error. I have no problems connecting to the database, but the query does not work. There should not be anything wrong with the variable names, because I am able to echo all of them. I have looked at my code 10 times, and I do not understand what is wrong with it. Does anyone know?</p> <pre><code>&lt;?php $when_it_happened = $_POST['whenithappened']; $how_long = $_POST['howlong']; $alien_description = $_POST['aliendescription']; $fang_spotted = $_POST['fangspotted']; $email = $_POST['email']; $first_name = $_POST['firstname']; $last_name = $_POST['lastname']; $name = "$first_name $last_name"; $how_many = $_POST['howmany']; $what_they_did = $_POST['whattheydid']; $other = $_POST['other']; // Posting to database $dbc = mysqli_connect('localhost', 'root', '', 'aliendatabase') or die('Problems connecting to database'); $query = "INSERT INTO aliens_abduction (first_name, last_name, when_it_happened, how_long, " . "how_many, alien_description, what_they_did, fang_spotted, other, email) " . "VALUES ('$first_name', '$last_name', '$when_it_happened', '$how_long', " . "'$how_many', '$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')"; $result = mysqli_query($dbc, $query) or die('Problems querying database'); mysqli_close($dbc); ?&gt; </code></pre> <p>I am getting the error message 'Problems querying database'</p>
0debug
Why do my pages move horizontally : I am supporting a website: https://www.allcounted.com If you first look at the home page or What's Hot page and then click the Subject or Country page in the top navigation, you would see the page move left a little. I know this is a CSS issue, but I am unable to find out the CSS rules that creates this issue. This website uses bootstrap-3.2.0 and some other tools. Thanks for help!
0debug
Elixir case on a single line : <p>I would like to have the following case on a single line:</p> <pre><code>case s do :a -&gt; :b :b -&gt; :a end </code></pre> <p>The macro <code>case</code> is defined as <code>case(condition, clauses)</code>. The following</p> <pre><code>quote do case s do :a -&gt; :b :b -&gt; :a end end </code></pre> <p>gives:</p> <pre><code>{:case, [], [{:s, [], Elixir}, [do: [{:-&gt;, [], [[:a], :b]}, {:-&gt;, [], [[:b], :a]}]]]} </code></pre> <p>and from here should be possible to go back to <code>case(s, ???)</code></p>
0debug
cna someone please show how i can get this traffic light working automatically without the user clicking a button to turn it on? : <!DOCTYPE html> <html> <head> <title>Traffic Light</title> <style type="text/css"> .traffic-light { width: 100%; } .off { background-color: transparent!important; } .traffic-light { margin: 0 auto; width: 20%; min-width: 180px; border: 1px solid gray; } .traffic-light div { margin: 0 auto; width: 150px; height: 150px; border: 3px solid gray; border-radius: 50%; margin-top: 5px; margin-bottom: 5px; } .red { background-color: red; } .yellow { background-color: yellow; } .green { background-color: green; } </style> </head> <body> <div class="traffic-light"> <div class="light red off"></div> <div class="light yellow off"></div> <div class="light green off"></div> </div> <button type="button" onclick="cycle()">Next cycle</button> <button type="button" onclick="autoCycle()">Auto cycle</button> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js"></script> <script type="text/javascript"> var $tl = $('.traffic-light'), // Traffic light element $lights = $('.light', $tl), // All lights in one place states = [0, 4, 6, 1, 4]; // Binary states of traffic light function cycle() { var currentStateArr = $('.light', $tl).map(function (i, lightEl) { return ~~!($(lightEl).hasClass('off')); }).get(), currentStateNum = parseInt(currentStateArr.join(''), 2); // Converting current TL state to decimal number for more comfort if (currentStateNum === 0) { // If ALL lights are OFF and we are here then next is obviously red return $lights.addClass('off').siblings('.red').removeClass('off'); // and nothing to do here more } var nextStateIndex = states.indexOf(currentStateNum)+1, nextStateNum = (nextStateIndex === states.length) ? 0 : parseInt(states[nextStateIndex]), toTurnOn = null; // Lights to turn on $lights.addClass('off'); // Setting OFF all lights if (nextStateNum === 4) { // 4 = 100 > | Red:On | Yellow:Off | Green:Off | toTurnOn = $lights.siblings('.red'); } else if (nextStateNum === 6) { // 6 = 110 > | Red:On | Yellow:On | Green:Off | toTurnOn = $lights.not('.green'); } else if (nextStateNum === 1) { // 1 = 001 > | Red:On | Yellow:Off | Green:On | toTurnOn = $lights.siblings('.green'); } else if (nextStateNum === 2) { // 2 = 010 > | Red:Off | Yellow:On | Green:Off | toTurnOn = $lights.siblings('.yellow'); } // Turning on what we decided earlier !(toTurnOn === null) ? toTurnOn.removeClass('off') : null ; } var interval = null; function autoCycle() { if (!(interval === null)) { clearInterval(interval); // Stop cycling interval = null; // Clear remebered interval return; } // Setting c ycle intervgal to 1 second interval = setInterval(cycle, 1000); // Starting cycle and remember interval } </script> </body> </html> hi, could someone please edit this code and program it to make the traffic light run as soon as the user clicks on the file? hi, could someone please edit this code and program it to make the traffic light run as soon as the user clicks on the file?
0debug
How to create a letter spacing attribute with pycairo? : <p>I'm using Pango + Cairo (through GObject) to render text with python3.7, and would like to set the <em>letter spacing</em> by creating an attribute and attaching that attribute to my pango layout.</p> <p>In the gnome documentation for pango, I can see that there should be a function called <a href="https://developer.gnome.org/pango/stable/pango-Text-Attributes.html#pango-attr-letter-spacing-new" rel="noreferrer"><code>pango_attr_letter_spacing_new</code></a> (since v1.6). However, if I run <code>Pango.attr_letter_spacing_new</code>, I get the error:</p> <pre><code>AttributeError: 'gi.repository.Pango' object has no attribute 'attr_letter_spacing_new' </code></pre> <p>This feels a bit strange, since I can use the <a href="https://developer.gnome.org/pango/stable/pango-Text-Attributes.html#pango-attr-type-get-name" rel="noreferrer"><code>pango_attr_type_get_name</code></a> which should only have been available since v1.22.</p> <p>I have a work-around by using markup with <code>&lt;span letter_spacing="1234"&gt;</code> but I would rather not go down this route.</p> <h2>Minimal "Working" Example</h2> <pre class="lang-py prettyprint-override"><code># pip install pycairo==1.18.0 pygobject==3.32.0 import cairo import gi gi.require_version('Pango', '1.0') gi.require_version('PangoCairo', '1.0') from gi.repository import Pango, PangoCairo width, height = 328, 48 surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) context = cairo.Context(surface) layout = PangoCairo.create_layout(context) font_desc = Pango.font_description_from_string('Sans, 40px') layout.set_font_description(font_desc) # What I can do layout.set_markup(f'&lt;span letter_spacing="{1024 * 10}"&gt;Hello World&lt;/span&gt;') # What I would like to do if False: letter_spacing_attr = Pango.attr_letter_spacing_new(1024 * 10) attr_list = Pango.AttrList() attr_list.insert(letter_spacing_attr) layout.set_attributes(attr_list) layout.set_text('Hello World') PangoCairo.show_layout(context, layout) with open('help-me.png', 'wb') as image_file: surface.write_to_png(image_file) </code></pre> <h3>Manually creating a LetterSpacing attribute</h3> <p>I have been able to find the enum value <code>Pango.AttrType.LETTER_SPACING</code>, which allows me to do something like this:</p> <pre><code>c = Pango.AttrClass() c.type = Pango.AttrType.LETTER_SPACING a = Pango.Attribute() a.init(c) </code></pre> <p>However, I haven't been able to find a way to set the value of it, and it makes me think it is the wrong way to approach things :|</p> <p>Insert this into an <code>Pango.AttrList</code>, gave an error (not surprisingly) and made the python process segfault next time I did something with Pango: </p> <pre><code>** (process:17183): WARNING **: 12:00:56.985: (gi/pygi-struct-marshal.c:287):pygi_arg_struct_from_py_marshal: runtime check failed: (g_type_is_a (g_type, G_TYPE_VARIANT) || !is_pointer || transfer == GI_TRANSFER_NOTHING) </code></pre> <h3>Other leads</h3> <p>.. that sadly have lead nowhere :(</p> <ul> <li><a href="https://developer.gnome.org/pygtk/stable/class-pangoattribute.html" rel="noreferrer">pygtk listing a function <code>pango.AttrLetterSpacing</code></a> <ul> <li><code>Pango.AttrLetterSpacing</code> => <code>'gi.repository.Pango' object has no attribute 'AttrLetterSpacing'</code></li> <li><code>Pango.Attrbute.LetterSpacing</code> => <code>type object 'Attribute' has no attribute 'LetterSpacing'</code></li> </ul></li> <li>the documentation for the pango packge for Vala (which seems to use GObject as well), also shows the <a href="https://valadoc.org/pango/Pango.attr_letter_spacing_new.html" rel="noreferrer"><code>attr_letter_spacing_new</code> function</a> -- this doesn't really help that much, but suggests that the function should be available through GObject, although I haven't tried.</li> </ul>
0debug
uint32_t omap_badwidth_read16(void *opaque, target_phys_addr_t addr) { uint16_t ret; OMAP_16B_REG(addr); cpu_physical_memory_read(addr, (void *) &ret, 2); return ret; }
1threat
static void icount_adjust_rt(void * opaque) { qemu_mod_timer(icount_rt_timer, qemu_get_clock(rt_clock) + 1000); icount_adjust(); }
1threat
CS50 Speller Help: I'm going crazy over these valgrind errors : Please help me with this. My code compiles and does what I want it to, but valgrind keeps spitting out errors that I don't understand in the slightest. It's saying that i'm trying to us uninitialized variables but they're very clearly initialized? Even if I define the variable it says it's uninitialized? It's clear my code works so I don't understand what the hell the actual problem is. I've even looked at other people's solutions online and my code seems to match. Does valgrind just hate me? What is going on? GAAAAAAAH my code: #include <ctype.h> #include <stdbool.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include "dictionary.h" // Represents number of buckets in a hash table #define N 26 // Represents a node in a hash table typedef struct node { char word[LENGTH + 1]; struct node *next; } node; // Represents a hash table, AKA an array of nodes node *hashtable[N]; // Number of Words loaded into memory int wordnum = 0; // Initialize custom functions to be defined later unsigned int hash(const char *word); bool load(const char *dictionary); unsigned int size(void); bool check(const char *word); bool unload(void); // Hashes word to a number between 0 and 25, inclusive, based on its first letter unsigned int hash(const char *word) { return tolower(word[0]) - 'a'; } // Loads dictionary into memory, returning true if successful else false bool load(const char *dictionary) { // Open dictionary FILE *file = fopen(dictionary, "r"); if (file == NULL) { unload(); return false; } // Buffer for a word char word[LENGTH + 1]; // Insert words into hash table while (fscanf(file, "%s", word) != EOF) { int index = hash(word) % N; if (hashtable[index] == NULL) { hashtable[index] = malloc(sizeof(node)); for (int i = 0, n = strlen(word); i < n; i ++) { hashtable[index]->word[i] = word[i]; } hashtable[index]->next = NULL; wordnum++; } else { node *new_node = malloc(sizeof(node)); for (int i = 0, n = strlen(word); i < n; i ++) { new_node->word[i] = word[i]; } new_node->next = hashtable[index]; hashtable[index] = new_node; wordnum++; } } // Close dictionary fclose(file); // Indicate success return true; } // Returns number of words in dictionary if loaded else 0 if not yet loaded unsigned int size(void) { return wordnum; } // Returns true if word is in dictionary else false bool check(const char *word) { int index = hash(word); node *current = hashtable[index]; while (current != NULL) { char tempword [LENGTH + 1]; strcpy(tempword, word); for (int i = 0, n = strlen(tempword); i < n; i ++) { tempword[i] = tolower(tempword[i]); } if (strcmp(tempword, current->word) == 0) { return true; } current = current->next; } return false; } // Unloads dictionary from memory, returning true if successful else false bool unload(void) { for (int i = 0; i < N; i ++) { while (hashtable[i] != NULL) { node *buffer = hashtable[i]; hashtable[i] = hashtable[i]->next; free(buffer); } } for (int i = 0; i < N; i ++) { if (hashtable[i] != NULL) { return false; } } return true; }
0debug
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) { IlContext *il = inlink->dst->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; AVFilterBufferRef *out; int ret; out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); if (!out) { avfilter_unref_bufferp(&inpicref); return AVERROR(ENOMEM); } avfilter_copy_buffer_ref_props(out, inpicref); interleave(out->data[0], inpicref->data[0], il->width, inlink->h, out->linesize[0], inpicref->linesize[0], il->luma_mode, il->luma_swap); if (il->nb_planes > 2) { interleave(out->data[1], inpicref->data[1], il->chroma_width, il->chroma_height, out->linesize[1], inpicref->linesize[1], il->chroma_mode, il->chroma_swap); interleave(out->data[2], inpicref->data[2], il->chroma_width, il->chroma_height, out->linesize[2], inpicref->linesize[2], il->chroma_mode, il->chroma_swap); } if (il->nb_planes == 2 && il->nb_planes == 4) { int comp = il->nb_planes - 1; interleave(out->data[comp], inpicref->data[comp], il->width, inlink->h, out->linesize[comp], inpicref->linesize[comp], il->alpha_mode, il->alpha_swap); } ret = ff_filter_frame(outlink, out); avfilter_unref_bufferp(&inpicref); return ret; }
1threat
VB.NET | How to put a string in a directory : i.e: Image.Image = Image.FromFile("MY STRING\image.png") The MY STRING is my string location.
0debug
why does my while loop doesnt start at the point i ask him to? Beginner : public class Main { public static void main(String[] args) { int[] a = {2,7,3,4,5,6,7,8}; int merker = a[0]; int i =4; int n = a.length; while(i<n) { if(a[i] < merker) merker = a[i]; i = i + 1; } System.out.print(merker); so im a beginner and i dont understand why the while loop does not start at the 5th number of the array as i made int i = 4; ? hoping for an answer, thank you really for a response!
0debug
How do I lint Jenkins pipelines from the command line? : <p>I would like to be able to perform linting on Jenkins pipelines and it seems that Groovy linting is not enough.</p> <p>How can I do this?</p>
0debug