problem
stringlengths
26
131k
labels
class label
2 classes
python asyncio add_done_callback with async def : <p>I have 2 functions: The first one, <code>def_a</code>, is an asynchronous function and the second one is <code>def_b</code> which is a regular function and called with the result of <code>def_a</code> as a callback with the <code>add_done_callback</code> function.</p> <p>My code looks like this:</p> <pre><code>import asyncio def def_b(result): next_number = result.result() # some work on the next_number print(next_number + 1) async def def_a(number): await some_async_work(number) return number + 1 loop = asyncio.get_event_loop() task = asyncio.ensure_future(def_a(1)) task.add_done_callback(def_b) response = loop.run_until_complete(task) loop.close() </code></pre> <p>And it's work perfectly.</p> <p>The problem began when also the second function, <code>def_b</code>, became asynchronous. Now it looks like this:</p> <pre><code>async def def_b(result): next_number = result.result() # some asynchronous work on the next_number print(next_number + 1) </code></pre> <p>But now I can not provide it to the <code>add_done_callback</code> function, because it's not a regular function.</p> <p>My question is- Is it possible and how can I provide <code>def_b</code> to the <code>add_done_callback</code> function if <code>def_b</code> is asynchronous?</p>
0debug
Is it (`?:`) typescript ternary operator : <p>I'm new to angular 2 and typescript. I am seeing </p> <pre><code> export interface EjectTaskOptions extends BuildOptions { force?: boolean; app?: string; } </code></pre> <p>in some typescript examples. What is it (<code>?:</code>) mean ? Is it a ternary operator (with only false condition)or some other ?</p> <p>Thanks in advance.</p>
0debug
static void gen_load_store_alignment(DisasContext *dc, int shift, TCGv_i32 addr, bool no_hw_alignment) { if (!option_enabled(dc, XTENSA_OPTION_UNALIGNED_EXCEPTION)) { tcg_gen_andi_i32(addr, addr, ~0 << shift); } else if (option_enabled(dc, XTENSA_OPTION_HW_ALIGNMENT) && no_hw_alignment) { int label = gen_new_label(); TCGv_i32 tmp = tcg_temp_new_i32(); tcg_gen_andi_i32(tmp, addr, ~(~0 << shift)); tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label); gen_exception_cause_vaddr(dc, LOAD_STORE_ALIGNMENT_CAUSE, addr); gen_set_label(label); tcg_temp_free(tmp); } }
1threat
static int ipvideo_decode_block_opcode_0x2(IpvideoContext *s) { unsigned char B; int x, y; CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 1); B = *s->stream_ptr++; if (B < 56) { x = 8 + (B % 7); y = B / 7; } else { x = -14 + ((B - 56) % 29); y = 8 + ((B - 56) / 29); } debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y); return copy_from(s, &s->second_last_frame, x, y); }
1threat
error with creating dynamic number of threads - c programming : I am trying to create dynamic number of thread..... #include<stdio.h> #include<pthread.h> void* thread_function(void) { printf("hello"); } int main(int argc,char *argv[]) { int noOfThread= atoi(argv[1]); pthread_t thread_id[noOfThread]; int i; int status; for(i=0;i<noOfThread;i++) { pthread_create (&thread_id[i], NULL , &thread_function, NULL); } for(i=0;i<noOfThread;i++) pthread_join(thread_id[i],NULL); } 3 errors: 1. implicit declaration of function atoi.... 2. passing arguement 3 of 'pthread_create' from incompatible pointer type 3. expected 'void * (*)(void *)' but arguement is of typr'void * (*) (void)'......
0debug
static int aio_read_f(BlockBackend *blk, int argc, char **argv) { int nr_iov, c; struct aio_ctx *ctx = g_new0(struct aio_ctx, 1); ctx->blk = blk; while ((c = getopt(argc, argv, "CP:qv")) != EOF) { switch (c) { case 'C': ctx->Cflag = 1; break; case 'P': ctx->Pflag = 1; ctx->pattern = parse_pattern(optarg); if (ctx->pattern < 0) { g_free(ctx); return 0; } break; case 'q': ctx->qflag = 1; break; case 'v': ctx->vflag = 1; break; default: g_free(ctx); return qemuio_command_usage(&aio_read_cmd); } } if (optind > argc - 2) { g_free(ctx); return qemuio_command_usage(&aio_read_cmd); } ctx->offset = cvtnum(argv[optind]); if (ctx->offset < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); g_free(ctx); return 0; } optind++; if (ctx->offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned\n", ctx->offset); g_free(ctx); return 0; } nr_iov = argc - optind; ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov, 0xab); if (ctx->buf == NULL) { g_free(ctx); return 0; } gettimeofday(&ctx->t1, NULL); block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size, BLOCK_ACCT_READ); blk_aio_readv(blk, ctx->offset >> 9, &ctx->qiov, ctx->qiov.size >> 9, aio_read_done, ctx); return 0; }
1threat
Need a way to refresh automatically update HTML if a text file changes : <p>I'm trying to create a non intrusive pop up that refreshes it's displayed text on the fly if the content in a local txt file has been changed. Not sure of the best method to go about this. Using html and js for this. </p> <p>The popup reads from a txt file, pops up on screen for a few seconds then pops back down, but how could I read the file and change what is displayed automatically?</p> <p>Any help would be appreciated.</p>
0debug
PHP Calculation - Modulus 10 check digit generation : <p>I got a problem here figuring out how to do this:</p> <ol> <li>I got a document no for example <code>5843</code></li> <li>Starting with the right-most digit, multiply every other digit by 2 and 1 (For example, <code>(3x2)+(4x1)+(8x2)+(5x1)</code> and so on)</li> <li>For every multiplication that results a number more than 9, add them digits. (For example, from the calculation on (no.2) we will get this : <code>(6)+(4)+(16)+(5)</code>. So we got a number (16) which is more that 9. We need to add them <code>(1+6=7)</code>. Now the output will be like this : <code>(6)+(4)+(7)+(5)</code>.</li> <li>Next, we add them <code>(6)+(4)+(7)+(5)=22</code></li> <li>Now, we <code>divide 22 by 10</code> and get the remainder which is <code>2</code> in this case.</li> <li>Lastly we minus the remainder with <code>10</code>. </li> <li>So the last output will be <code>8</code></li> </ol> <p>Can you guys guide me on how to do this? Thank you very much !</p>
0debug
static size_t buffered_get_rate_limit(void *opaque) { QEMUFileBuffered *s = opaque; return s->xfer_limit; }
1threat
Jade include with parameter : <p>In an older version of Jade I was able to include partials and pass variables into them like this: !=partial('partials/video', {title:video.title, artist:video.artist}) now the partial connotation does not exist any more. How do I achieve the same thing using the include connotations?</p>
0debug
static int vvfat_open(BlockDriverState *bs, QDict *options, int flags) { BDRVVVFATState *s = bs->opaque; int cyls, heads, secs; bool floppy; const char *dirname; QemuOpts *opts; Error *local_err = NULL; int ret; #ifdef DEBUG vvv = s; #endif DLOG(if (stderr == NULL) { stderr = fopen("vvfat.log", "a"); setbuf(stderr, NULL); }) opts = qemu_opts_create_nofail(&runtime_opts); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); error_free(local_err); ret = -EINVAL; goto fail; } dirname = qemu_opt_get(opts, "dir"); if (!dirname) { qerror_report(ERROR_CLASS_GENERIC_ERROR, "vvfat block driver requires " "a 'dir' option"); ret = -EINVAL; goto fail; } s->fat_type = qemu_opt_get_number(opts, "fat-type", 0); floppy = qemu_opt_get_bool(opts, "floppy", false); if (floppy) { if (!s->fat_type) { s->fat_type = 12; secs = 36; s->sectors_per_cluster = 2; } else { secs = s->fat_type == 12 ? 18 : 36; s->sectors_per_cluster = 1; } s->first_sectors_number = 1; cyls = 80; heads = 2; } else { if (!s->fat_type) { s->fat_type = 16; } cyls = s->fat_type == 12 ? 64 : 1024; heads = 16; secs = 63; } switch (s->fat_type) { case 32: fprintf(stderr, "Big fat greek warning: FAT32 has not been tested. " "You are welcome to do so!\n"); break; case 16: case 12: break; default: qerror_report(ERROR_CLASS_GENERIC_ERROR, "Valid FAT types are only " "12, 16 and 32"); ret = -EINVAL; goto fail; } s->bs = bs; s->sectors_per_cluster=0x10; s->current_cluster=0xffffffff; s->first_sectors_number=0x40; bs->read_only = 1; s->qcow = s->write_target = NULL; s->qcow_filename = NULL; s->fat2 = NULL; s->downcase_short_names = 1; fprintf(stderr, "vvfat %s chs %d,%d,%d\n", dirname, cyls, heads, secs); s->sector_count = cyls * heads * secs - (s->first_sectors_number - 1); if (qemu_opt_get_bool(opts, "rw", false)) { if (enable_write_target(s)) { ret = -EIO; goto fail; } bs->read_only = 0; } bs->total_sectors = cyls * heads * secs; if (init_directories(s, dirname, heads, secs)) { ret = -EIO; goto fail; } s->sector_count = s->faked_sectors + s->sectors_per_cluster*s->cluster_count; if (s->first_sectors_number == 0x40) { init_mbr(s, cyls, heads, secs); } qemu_co_mutex_init(&s->lock); if (s->qcow) { error_set(&s->migration_blocker, QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED, "vvfat (rw)", bs->device_name, "live migration"); migrate_add_blocker(s->migration_blocker); } ret = 0; fail: qemu_opts_del(opts); return ret; }
1threat
Show page by variable ?page= and some help needed? : <p>Hi m i want to display some page via the variable ?page= its giving error Parse error: syntax error, unexpected '/' in C:\AppServ\www\index.php on line 11</p> <pre><code>&lt;?php include 'assets/config.php'; $page = $_GET["page"]; if ($page == "script") { include("/pages/script.php"); } if ($page == "how") { include(/pages/"how.php"); ?&gt; </code></pre> <p>Please i need help on that and also</p> <p>i want to redirect urls via a new variable ?go= page on my website my code Please customize it .... </p> <pre><code>*&lt;?php include '/assets/config.php'; $goto = $_SERVER['QUERY_STRING']; $RedirectTo = "$goto"; header("Location: $RedirectTo"); exit; ?&gt;* </code></pre> <p>Thanks </p>
0debug
In regular expressions, how to exclude a specific character? : {"url": "http://res1.icourses.cn/share/process17//mp4/2017/3/17/6332c641-28b5-43a0-894c-972bd804f4e1_SD.mp4", "name": "1-课程导学"}, {"url": "http://res2.icourses.cn/share/process17//mp4/2017/3/17/a21902b6-8680-4bdf-8f47-4f99d1354475_SD.mp4", "name": "2-计算机网络的定义与分类"} I want to extract `6332c641-28b5-43a0-894c-972bd804f4e1_SD.mp4` and `a21902b6-8680-4bdf-8f47-4f99d1354475_SD.mp4` How to write a regular expression to match the string at this location?
0debug
What does directly setting a pointer with a variable means? : <p>PS, I know what a pointer is and how to use one, but confused on one thing. I have already tried searching stackoverflow on this question:</p> <pre><code>int *ptr = 20 //why illegal or seg fault or crash? printf("%i", *ptr) // Seg Fault printf("%i", ptr) // Output -&gt; 20 printf("%p", &amp;ptr) // Returns a valid address. </code></pre> <p>and found that, By directly assigning a value to a pointer without initializing with malloc or null, means that we are saying to the compiler, Hey CPU, Make a space in the memory to store an integer at the exact address given as value, which in this case 20. So basically saying to the compiler make a place for an INT in the ram with the address 20. By doing this we are touching system memory or illegal space.</p> <p>But what I don't get is, </p> <ol> <li><blockquote> <p>How the integer 20 can directly be referenced as a memory?</p> </blockquote></li> <li><blockquote> <p>What happens when we do the same for float or char? for example float *ptr = 20.25</p> </blockquote></li> <li><blockquote> <p>I tried directly converting c code to assembly with a website, for a legal and illegal pointer example, where I see that the same registers are called, same MOV operations are done, And no explicit "MAKE SPACE AT given ADDRESS" instructions were set.</p> </blockquote></li> <li>Lastly, What exactly happens when we declare strings by doing char *ptr = "Hello"?</li> </ol> <p>I have tried every possible way to understand this, but couldn't. Can you guys point me to the right direction? Thanks ...</p>
0debug
static int filter_frame(AVFilterLink *link, AVFrame *in) { AVFilterContext *ctx = link->dst; AVFilterLink *outlink = ctx->outputs[0]; ColorSpaceContext *s = ctx->priv; AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h); int res; ptrdiff_t rgb_stride = FFALIGN(in->width * sizeof(int16_t), 32); unsigned rgb_sz = rgb_stride * in->height; struct ThreadData td; if (!out) { av_frame_free(&in); return AVERROR(ENOMEM); } av_frame_copy_props(out, in); out->color_primaries = s->user_prm == AVCOL_PRI_UNSPECIFIED ? default_prm[FFMIN(s->user_all, CS_NB)] : s->user_prm; if (s->user_trc == AVCOL_TRC_UNSPECIFIED) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(out->format); out->color_trc = default_trc[FFMIN(s->user_all, CS_NB)]; if (out->color_trc == AVCOL_TRC_BT2020_10 && desc && desc->comp[0].depth >= 12) out->color_trc = AVCOL_TRC_BT2020_12; } else { out->color_trc = s->user_trc; } out->colorspace = s->user_csp == AVCOL_SPC_UNSPECIFIED ? default_csp[FFMIN(s->user_all, CS_NB)] : s->user_csp; out->color_range = s->user_rng == AVCOL_RANGE_UNSPECIFIED ? in->color_range : s->user_rng; if (rgb_sz != s->rgb_sz) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(out->format); int uvw = in->width >> desc->log2_chroma_w; av_freep(&s->rgb[0]); av_freep(&s->rgb[1]); av_freep(&s->rgb[2]); s->rgb_sz = 0; av_freep(&s->dither_scratch_base[0][0]); av_freep(&s->dither_scratch_base[0][1]); av_freep(&s->dither_scratch_base[1][0]); av_freep(&s->dither_scratch_base[1][1]); av_freep(&s->dither_scratch_base[2][0]); av_freep(&s->dither_scratch_base[2][1]); s->rgb[0] = av_malloc(rgb_sz); s->rgb[1] = av_malloc(rgb_sz); s->rgb[2] = av_malloc(rgb_sz); s->dither_scratch_base[0][0] = av_malloc(sizeof(*s->dither_scratch_base[0][0]) * (in->width + 4)); s->dither_scratch_base[0][1] = av_malloc(sizeof(*s->dither_scratch_base[0][1]) * (in->width + 4)); s->dither_scratch_base[1][0] = av_malloc(sizeof(*s->dither_scratch_base[1][0]) * (uvw + 4)); s->dither_scratch_base[1][1] = av_malloc(sizeof(*s->dither_scratch_base[1][1]) * (uvw + 4)); s->dither_scratch_base[2][0] = av_malloc(sizeof(*s->dither_scratch_base[2][0]) * (uvw + 4)); s->dither_scratch_base[2][1] = av_malloc(sizeof(*s->dither_scratch_base[2][1]) * (uvw + 4)); s->dither_scratch[0][0] = &s->dither_scratch_base[0][0][1]; s->dither_scratch[0][1] = &s->dither_scratch_base[0][1][1]; s->dither_scratch[1][0] = &s->dither_scratch_base[1][0][1]; s->dither_scratch[1][1] = &s->dither_scratch_base[1][1][1]; s->dither_scratch[2][0] = &s->dither_scratch_base[2][0][1]; s->dither_scratch[2][1] = &s->dither_scratch_base[2][1][1]; if (!s->rgb[0] || !s->rgb[1] || !s->rgb[2] || !s->dither_scratch_base[0][0] || !s->dither_scratch_base[0][1] || !s->dither_scratch_base[1][0] || !s->dither_scratch_base[1][1] || !s->dither_scratch_base[2][0] || !s->dither_scratch_base[2][1]) { uninit(ctx); return AVERROR(ENOMEM); } s->rgb_sz = rgb_sz; } res = create_filtergraph(ctx, in, out); if (res < 0) return res; s->rgb_stride = rgb_stride / sizeof(int16_t); td.in = in; td.out = out; td.in_linesize[0] = in->linesize[0]; td.in_linesize[1] = in->linesize[1]; td.in_linesize[2] = in->linesize[2]; td.out_linesize[0] = out->linesize[0]; td.out_linesize[1] = out->linesize[1]; td.out_linesize[2] = out->linesize[2]; td.in_ss_h = av_pix_fmt_desc_get(in->format)->log2_chroma_h; td.out_ss_h = av_pix_fmt_desc_get(out->format)->log2_chroma_h; if (s->yuv2yuv_passthrough) { res = av_frame_copy(out, in); if (res < 0) return res; } else { ctx->internal->execute(ctx, convert, &td, NULL, FFMIN((in->height + 1) >> 1, ctx->graph->nb_threads)); } av_frame_free(&in); return ff_filter_frame(outlink, out); }
1threat
static void spapr_phb_add_pci_device(sPAPRDRConnector *drc, sPAPRPHBState *phb, PCIDevice *pdev, Error **errp) { sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); DeviceState *dev = DEVICE(pdev); int drc_index = drck->get_index(drc); void *fdt = NULL; int fdt_start_offset = 0, fdt_size; if (dev->hotplugged) { fdt = create_device_tree(&fdt_size); fdt_start_offset = spapr_create_pci_child_dt(phb, pdev, drc_index, NULL, fdt, 0); if (!fdt_start_offset) { error_setg(errp, "Failed to create pci child device tree node"); goto out; } } drck->attach(drc, DEVICE(pdev), fdt, fdt_start_offset, !dev->hotplugged, errp); out: if (*errp) { g_free(fdt); } }
1threat
c++ : invalid operands to binary expression : <p>I don't know what's wrong here ? It's just running errors !!!</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { cout &lt;&lt; string("hello world"); return 0; } </code></pre>
0debug
Excel VBA copy heperlink from a cell to a collumn in a table : I would like to copy rows from a source sheet to a target table. Coping the values is no problem. The column A in the source sheet contains a hyperlink to a website. I would like to copy the hyperlink too. However this code gives an error (type mismatch). Sub Copy_Hyperlink() Dim ActiveSheet As Worksheet Dim ActiveTable As ListObject Dim Row_Number As Integer Dim Last_Row As Integer Dim ActiveRow As ListRow Dim Hyperlink As Hyperlink Set ActiveSheet = Sheets("Sheet2") Set ActiveTable = ActiveSheet.ListObjects("Table1") Set ActiveSheet = Sheets("Sheet1") ActiveSheet.Activate Last_Row = ActiveSheet.Cells(Cells.Rows.Count, 1).End(xlUp).Row For Row_Number = 2 To Last_Row Set ActiveRow = ActiveTable.ListRows.Add ActiveRow.Range(1, 1).Value = Range("A" & Row_Number).Value ActiveRow.Range(1, 2).Value = Range("B" & Row_Number).Value ActiveRow.Range(1, 2).Hyperlinks.Add Range _ ("A" & Row_Number).Hyperlinks.Item(1).Address Next Row_Number End Sub
0debug
Python Finding Missing Elements among a range of number lines. : Let's say I have a list of ranges (ie. [[1,100][102, 200], etc]]. I want to find the number of missing elements in the total range. I have a working algorithm below: def missing(numranges): (minimum, maximum) = (min(map(lambda x: x[0], numranges)), max(map(lambda x: x[1], numranges))) (count, i) = (0, minimum) while i < maximum: if any(j <= i <= k for j, k in numranges): count += 1 i += 1 return maximum - minimum - count The problem is if you have say a number line that say is like [[1, 10000], [10002, 20000]], then i goes over over all 20,000 elements and it seems to me that this is very inefficient. I'm trying to find a way to make the algorithm better but I'm a bit stumped.
0debug
void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { MachineState *machine = MACHINE(OBJECT(hotplug_dev)); sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(OBJECT(hotplug_dev)); sPAPRMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev)); int spapr_max_cores = max_cpus / smp_threads; int index; Error *local_err = NULL; CPUCore *cc = CPU_CORE(dev); char *base_core_type = spapr_get_cpu_core_type(machine->cpu_model); const char *type = object_get_typename(OBJECT(dev)); if (strcmp(base_core_type, type)) { error_setg(&local_err, "CPU core type should be %s", base_core_type); goto out; } if (!smc->dr_cpu_enabled && dev->hotplugged) { error_setg(&local_err, "CPU hotplug not supported for this machine"); goto out; } if (cc->nr_threads != smp_threads) { error_setg(&local_err, "threads must be %d", smp_threads); goto out; } if (cc->core_id % smp_threads) { error_setg(&local_err, "invalid core id %d\n", cc->core_id); goto out; } index = cc->core_id / smp_threads; if (index < 0 || index >= spapr_max_cores) { error_setg(&local_err, "core id %d out of range", cc->core_id); goto out; } if (spapr->cores[index]) { error_setg(&local_err, "core %d already populated", cc->core_id); goto out; } out: g_free(base_core_type); error_propagate(errp, local_err); }
1threat
Why threads are needed in my given assignment in java? : <p><strong>I'm not asking to do my assignment. Read carefully</strong></p> <blockquote> <p>Write a program to simulate a bus traveling between 5 different stations and repeats the cycle, the bus can take up to a maximum of 50 persons, at each station random number of persons get off the bus and random number of persons get on the bus, consider these cases.</p> <ul> <li>If bus does not have enough space for all persons, persons will have to stay in station for next cycle</li> <li>Persons cannot mount on bus until persons on bus dismount first.</li> <li>You can simulate bus trip with a fixed delay between each stop to simulate travel time.</li> <li>Persons can not mount/dismount the bus until bus arrives to the designated station.</li> </ul> <p>Use semaphores to control access to the bus and other utilities to control access to bus. Use thread pools to manage thread management. You can use latches, cyclic barriers, re-entrant locks and condition variables to write your code.</p> </blockquote> <p>I have implemented this in java without making threads and using semaphores. I Just used nested loop to cycle the bus and the whole procedure is working fine. I'm not asking you to do my assignment, all I need to know where should I use threads in this code. </p> <p>Here is my code :</p> <pre><code>import java.util.*; import java.lang.*; public class buses { int capacity; int station; ArrayList&lt;Integer&gt; remaining=new ArrayList&lt;&gt;(); public void run(int n) { System.out.println("--Station "+(n+1)+"--"); if(this.capacity&lt;50) { Random rand1 = new Random(); int unload = rand1.nextInt(50); unload += 1; while(unload&gt;50-this.capacity) { rand1 = new Random(); unload = rand1.nextInt(50); unload += 1; } System.out.println("Unloaded : "+unload); this.capacity+=unload; System.out.println("Capacity "+this.capacity); } Random rand = new Random(); int load = rand.nextInt(50); load += 1; System.out.println("random load:"+load); int val=remaining.get(n); System.out.println("Remaining pessenger at station"+(n+1)+" were:"+val); load=load+val; System.out.println("random load:"+load); if(load&lt;=this.capacity) { System.out.println("Loaded "+(load)); capacity-=load; System.out.println("Capacity "+this.capacity); remaining.set(n, 0); } else if(load&gt;this.capacity) { int notToBeLoaded=load-this.capacity; System.out.println("Loaded "+(load-notToBeLoaded)); capacity=0; System.out.println("Capacity "+this.capacity); remaining.set(n, notToBeLoaded); } station++; } public buses() { this.capacity=50; this.station=1; this.delay=2000; } public static void main(String[] args) { buses obj=new buses(); obj.remaining.add(0); obj.remaining.add(0); obj.remaining.add(0); obj.remaining.add(0); obj.remaining.add(0); for(int j=0;j&lt;2;j++) { for(int i=0;i&lt;5;i++) { obj.run(i); } } //System.out.println("remaining 0:"+obj.remaining.get(0)); //System.out.println("remaining 1:"+obj.remaining.get(1)); //System.out.println("remaining 2:"+obj.remaining.get(2)); //System.out.println("remaining 3:"+obj.remaining.get(3)); //System.out.println("remaining 4:"+obj.remaining.get(4)); } } </code></pre>
0debug
static void network_to_control(RDMAControlHeader *control) { control->type = ntohl(control->type); control->len = ntohl(control->len); control->repeat = ntohl(control->repeat); }
1threat
static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) { CPUState *cpu = current_cpu; CPUClass *cc = CPU_GET_CLASS(cpu); CPUArchState *env = cpu->env_ptr; target_ulong pc, cs_base; target_ulong vaddr; CPUWatchpoint *wp; uint32_t cpu_flags; assert(tcg_enabled()); if (cpu->watchpoint_hit) { cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); return; } vaddr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset; vaddr = cc->adjust_watchpoint_address(cpu, vaddr, len); QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { if (cpu_watchpoint_address_matches(wp, vaddr, len) && (wp->flags & flags)) { if (flags == BP_MEM_READ) { wp->flags |= BP_WATCHPOINT_HIT_READ; } else { wp->flags |= BP_WATCHPOINT_HIT_WRITE; } wp->hitaddr = vaddr; wp->hitattrs = attrs; if (!cpu->watchpoint_hit) { if (wp->flags & BP_CPU && !cc->debug_check_watchpoint(cpu, wp)) { wp->flags &= ~BP_WATCHPOINT_HIT; continue; } cpu->watchpoint_hit = wp; tb_lock(); tb_check_watchpoint(cpu); if (wp->flags & BP_STOP_BEFORE_ACCESS) { cpu->exception_index = EXCP_DEBUG; cpu_loop_exit(cpu); } else { cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags); tb_gen_code(cpu, pc, cs_base, cpu_flags, 1 | curr_cflags()); cpu_loop_exit_noexc(cpu); } } } else { wp->flags &= ~BP_WATCHPOINT_HIT; } } }
1threat
lcd clear but then wont come back : #include <IRremote.h> #include <LiquidCrystal.h> LiquidCrystal lcd(2, 3, 4, 5, 6, 7); int TempPin = A0; float realTemp = 0; int FakeTemp = 0; int target = 20; int IRPin = 11; IRrecv irrecv(IRPin); decode_results results; void setup() { // put your setup code here, to run once: lcd.begin(16, 2); Serial.begin(9600); while (! Serial); irrecv.enableIRIn(); //enables ir receiver } void loop() { FakeTemp = analogRead(TempPin); realTemp = (5.0 * FakeTemp * 1000.0) / (1024 * 10); // math for the temperature Serial.println(realTemp); lcd.print("Temperature"); lcd.setCursor(0, 13); lcd.print(realTemp); //prints the temperature delay(3000); lcd.clear(); if (irrecv.decode(16754775)) { //input from ir remote lcd.clear(); lcd.print("Target="); lcd.print(target + 1); delay(3000); irrecv.resume(); lcd.clear(); target = target + 1; // adds to target } if (irrecv.decode(16769055)) { //this is were everything goes wrong lcd.clear(); lcd.print("Target="); lcd.print(target - 1); delay(3000); irrecv.resume(); lcd.clear(); target = target - 1; } } I have been at this for quite some time and i dont know what is wrong when ever i add that one if statement it will display the temp on the lcd once. But then it wont do it again i can see in the serial monitor it is still grabbing the temp but wont print it on the lcd.
0debug
Multidimensional variable length array in C++ : <pre><code>void drawTable(int arg[], int length); int main() { int length=0; int counter=0; int *pointer2ArrSize = new int[length]; cout &lt;&lt; "Enter length of array: " &lt;&lt; endl; cin &gt;&gt; length; do{ for(int j=0; j&lt;length; j++){ cout &lt;&lt; "Enter array elements: \n"; cin &gt;&gt; pointer2ArrSize[j]; cout &lt;&lt; "You entered: " &lt;&lt; pointer2ArrSize[j] &lt;&lt; " in position: " &lt;&lt; j+1 &lt;&lt; endl; counter++; } cout &lt;&lt; drawTable(pointer2ArrSize[j],length) &lt;&lt; endl; }while(!counter == length); return 0; } void drawTable(int arg[], int length){ for(int i=0; i&lt;length; i++){ cout &lt;&lt; arg[i] &lt;&lt; " "; cout &lt;&lt; '/n'; } } </code></pre> <blockquote> <p>error: invalid conversion from 'int' to 'int*' [-fpermissive] </p> </blockquote> <p>My goal is to display a 2D variable length array. I want the user to define the length of the array and the elements in it. However, am not too familiar with vectors yet. how could I approach this?</p>
0debug
How to have a file or string available to multiple computers and be able to changed and rewritten in C#? : <br> I have a bit of an issue/question. <br> I am trying to write a program that generates a specific serial number but it will be able to be accessed by multiple computers in different locations. <br> The serial number will look something like this:<br> (2 letters)AA(month)02(year)16(four numbers)0000<br> Full thing: AA02160000<br> The last 4 digits will increment by one every time the user clicks a button. I need to be able to get that serial number from multiple computers in different locations not on the same network and edit it and rewrite it. I can't have any sort of overlap being a serial number and unique to a specific item. I also can't use a guid for the number otherwise it would be much easier. What is the best way to do this in C#? I have considered making a server for it but I was running into problems when trying to create directories to pull the number from because of the drive letter. Can I access a website that is hosted on a computer in one location and have it grab that serial number and increment it and then place the new value on the website? Quite honestly I'm spinning in circles with a million ways to do and not knowing the proper/best way to do it. A bit of help here would be much appreciated.
0debug
static void gen_spr_power5p_lpar(CPUPPCState *env) { #if !defined(CONFIG_USER_ONLY) spr_register_kvm(env, SPR_LPCR, "LPCR", &spr_read_generic, &spr_write_lpcr, KVM_REG_PPC_LPCR, LPCR_LPES0 | LPCR_LPES1); #endif }
1threat
static int check_tag(AVIOContext *s, int offset, unsigned int len) { char tag[4]; if (len > 4 || avio_seek(s, offset, SEEK_SET) < 0 || avio_read(s, tag, len) < len) return -1; else if (!AV_RB32(tag) || is_tag(tag, len)) return 1; return 0; }
1threat
static void x86_cpu_load_features(X86CPU *cpu, Error **errp) { CPUX86State *env = &cpu->env; FeatureWord w; GList *l; Error *local_err = NULL; if (cpu->max_features) { for (w = 0; w < FEATURE_WORDS; w++) { env->features[w] = x86_cpu_get_supported_feature_word(w, cpu->migratable); } } for (l = plus_features; l; l = l->next) { const char *prop = l->data; object_property_set_bool(OBJECT(cpu), true, prop, &local_err); if (local_err) { goto out; } } for (l = minus_features; l; l = l->next) { const char *prop = l->data; object_property_set_bool(OBJECT(cpu), false, prop, &local_err); if (local_err) { goto out; } } if (!kvm_enabled() || !cpu->expose_kvm) { env->features[FEAT_KVM] = 0; } x86_cpu_enable_xsave_components(cpu); x86_cpu_adjust_feat_level(cpu, FEAT_7_0_EBX); if (cpu->full_cpuid_auto_level) { x86_cpu_adjust_feat_level(cpu, FEAT_1_EDX); x86_cpu_adjust_feat_level(cpu, FEAT_1_ECX); x86_cpu_adjust_feat_level(cpu, FEAT_6_EAX); x86_cpu_adjust_feat_level(cpu, FEAT_7_0_ECX); x86_cpu_adjust_feat_level(cpu, FEAT_8000_0001_EDX); x86_cpu_adjust_feat_level(cpu, FEAT_8000_0001_ECX); x86_cpu_adjust_feat_level(cpu, FEAT_8000_0007_EDX); x86_cpu_adjust_feat_level(cpu, FEAT_C000_0001_EDX); x86_cpu_adjust_feat_level(cpu, FEAT_SVM); x86_cpu_adjust_feat_level(cpu, FEAT_XSAVE); if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM) { x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000000A); } } if (env->cpuid_level == UINT32_MAX) { env->cpuid_level = env->cpuid_min_level; } if (env->cpuid_xlevel == UINT32_MAX) { env->cpuid_xlevel = env->cpuid_min_xlevel; } if (env->cpuid_xlevel2 == UINT32_MAX) { env->cpuid_xlevel2 = env->cpuid_min_xlevel2; } out: if (local_err != NULL) { error_propagate(errp, local_err); } }
1threat
How to create table with field of checkbox in mysql? : <p>I want to create a table with field of checkbox. like when user select many options with select checkbox then how to store data in mysql database.</p> <p>Simply, Which datatype is used for checkbox &amp; which values are pass ? I have 4 checkbox. </p>
0debug
How can I convert variable float type data to string in c? : For example: f= ((100+x)/x)*1.5. So my float is variable type. then how can I make it to string with having precision. I am new in C. Please help.
0debug
Getting the first paragraph of wikipedia, and storing it into a text file : I wanted to make a system in which we give something to be search onto the terminal of a Raspberry Pi and the Pi gives a voice output. I've solved the text-to-speech conversion problem using pico TTS. Now what I wanted to do is go to the Wikipedia page of the term to be searched, and store the _first paragraph_ of the page to a text file. For example, the result for input [Tiger][1] in Simple English should make a text file containing - **The tiger (Panthera tigris) is a carnivorous mammal. It is the largest living member of the cat family, the Felidae. It lives in Asia, mainly India, Bhutan, China and Siberia.** [1]: https://simple.wikipedia.org/wiki/Tiger/ "Tiger"
0debug
def test_three_equal(x,y,z): result= set([x,y,z]) if len(result)==3: return 0 else: return (4-len(result))
0debug
static int cmp_color(const void *a, const void *b) { const struct range_box *box1 = a; const struct range_box *box2 = b; return box1->color - box2->color; }
1threat
static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { switch (vf->priv->mode) { case 0: case 3: return ff_vf_next_config(vf,width,height*2,d_width,d_height*2,flags,outfmt); case 1: case 2: case 4: return ff_vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } return 0; }
1threat
Trying to simulate a linux shell.Problems with simulating mkdir : <p>I am trying to make a c++ program to simulate a Linux shell. Nothing to fancy, just a few commands.</p> <p>I am trying to do it like this:</p> <p>I made a Class that tries to simulate a file system with Nodes and children. Every node can have n children and every child has a pointer pointing to its parent.</p> <p>The Node class looks like this:</p> <pre><code>class Node { public: Node(); Node(bool isFile); Node(string name); friend class Tree; bool isFile; vector&lt;Node*&gt; childs; string name; string text; Node *parrent; string names = "-"; protected: private: }; </code></pre> <p>I made an addNode method that I want to use to add Nodes to my "Tree". And what I tried to do is have it like this:</p> <pre><code>void Tree::addNode(string name,bool isFile,string pwd) { size_t pos=0; string delimiter = "\\"; string token; Node *inserter = new Node(); Node *aux; inserter-&gt;name=name; inserter-&gt;isFile=isFile; aux=&amp;this-&gt;root; pos = pwd.find(delimiter); token = pwd.substr(0,pos); pwd.erase(0,pos + delimiter.length()); if((pos = pwd.find(delimiter)) == string::npos) { inserter-&gt;parrent=aux; if(aux-&gt;names.find(name) == string::npos) { aux-&gt;childs.push_back(inserter); aux-&gt;names.append(name); aux-&gt;names.append(" "); } else { cout &lt;&lt; "The directory already exists" &lt;&lt; endl; } } else { while((pos = pwd.find(delimiter)) != string::npos) { token = pwd.substr(0,pos); pwd.erase(0,pos + delimiter.length()); for(int i = 0; i&lt;aux-&gt;childs.size(); i++) { if(aux-&gt;childs[i]-&gt;name.compare(token)) { aux=aux-&gt;childs[i]; cout &lt;&lt; token &lt;&lt; endl; } } } inserter-&gt;parrent=aux; if(aux-&gt;names.find(name) == string::npos) { aux-&gt;childs.push_back(inserter); aux-&gt;names.append(name); aux-&gt;names.append(" "); } else { cout &lt;&lt; "The directory already exists" &lt;&lt; endl; } } } </code></pre> <p>So, basically, every time I call this method, I want to make sure that every directory exists, and I change the pointer aux to point at the child address, and so on.</p> <p>The first if is for making directories in the root, and what's in the while for every other directory.</p> <p>But, due to my bad understanding of pointers, I can't see where I go wrong. When I add nodes in the "root" node everything works fine , but when I add nodes in any children things go bad, and I can't quite put my finger on it.</p> <p>I also have a ls and cd implemented The ls works fine, but the cd doesn't.I try to do the same thing when checking for the existance of directories, but sometmes, even if a directory doesn't exist, if you type cd "name of directroy that you are in" it just adds to pdw even if that directory doesn't exist.</p> <p>Here is the cd method</p> <pre><code>bool Tree::exitsChild(string name,string pwd) { size_t pos=0; string delimiter = "\\"; string token; Node *aux; aux=&amp;root; pos = pwd.find(delimiter); token = pwd.substr(0,pos); pwd.erase(0,pos + delimiter.length()); if((pos = pwd.find(delimiter)) == string::npos) { if(aux-&gt;names.find(name)!= string::npos) { return true; } else return false; } else { while((pos = pwd.find(delimiter)) != string::npos) { token = pwd.substr(0,pos); pwd.erase(0,pos + delimiter.length()); for(int i = 0; i&lt;aux-&gt;childs.size(); i++) { if(aux-&gt;childs[i]-&gt;name.compare(token)) { aux=aux-&gt;childs[i]; } } } if(aux-&gt;names.find(name) != string::npos) { return true; } else { return false; } } } </code></pre>
0debug
Failed to chmod user/Library/Developer/CoreSimulator/Devices NO Such File Or directory : <p>When i try to run my app in iPhone 6 simulator, i am getting following error. I am using Xcode 8.1 can any one please help me to understand this issue</p> <p><a href="https://i.stack.imgur.com/55RUF.png"><img src="https://i.stack.imgur.com/55RUF.png" alt="enter image description here"></a></p>
0debug
Azure active directory - Allow token audiences : <p>I am trying find documentation on "ALLOWED TOKEN AUDIENCES" in Azure, but there does not appear to be any. The value that I have placed in there was the resourceid that was returned with the token. </p> <p>What does this mean? any link to documentation will be much appreciated.</p> <p>PS. the learning link on the actual page mentions nothing about this, and the screenshots appear to be older and do not have this field.</p> <p>thanks in advance</p> <p><a href="https://i.stack.imgur.com/Q1CpX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Q1CpX.png" alt="enter image description here"></a></p>
0debug
static inline void gen_mtcr(CPUTriCoreState *env, DisasContext *ctx, TCGv r1, int32_t offset) { if (ctx->hflags & TRICORE_HFLAG_SM) { if (offset == 0xfe04) { gen_helper_psw_write(cpu_env, r1); } else { switch (offset) { #include "csfr.def" } } } else { } }
1threat
Instanciate the same device under test twice : <p>I want to instanciate two DUT (Device under test) in the same verilog testbench and compare their output signals.</p> <p>Actually the two devices will have the same inputs but diffrent outputs.</p> <p>Any help please?</p>
0debug
PHP Warning: PHP Startup: Unable to load dynamic library : <p>When I run this command <code>php -v</code><br> this error comes up:</p> <blockquote> <p>PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/dom.so' - /usr/lib/php/20160303/dom.so: undefined symbol: php_libxml_node_free_list in Unknown on line 0 </p> <p>PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/xmlreader.so' - /usr/lib/php/20160303/xmlreader.so: undefined symbol: dom_node_class_entry in Unknown on line 0 </p> <p>PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/xsl.so' - /usr/lib/php/20160303/xsl.so: undefined symbol: dom_node_class_entry in Unknown on line 0<br> PHP 7.1.5-1+deb.sury.org~trusty+2 (cli) (built: May 22 2017 13:39:01) ( NTS ) </p> <p>Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.7-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies</p> </blockquote>
0debug
static int slirp_smb(SlirpState* s, const char *exported_dir, struct in_addr vserver_addr) { static int instance; char smb_conf[128]; char smb_cmdline[128]; FILE *f; snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.%ld-%d", (long)getpid(), instance++); if (mkdir(s->smb_dir, 0700) < 0) { error_report("could not create samba server dir '%s'", s->smb_dir); return -1; } snprintf(smb_conf, sizeof(smb_conf), "%s/%s", s->smb_dir, "smb.conf"); f = fopen(smb_conf, "w"); if (!f) { slirp_smb_cleanup(s); error_report("could not create samba server configuration file '%s'", smb_conf); return -1; } fprintf(f, "[global]\n" "private dir=%s\n" "socket address=127.0.0.1\n" "pid directory=%s\n" "lock directory=%s\n" "state directory=%s\n" "log file=%s/log.smbd\n" "smb passwd file=%s/smbpasswd\n" "security = share\n" "[qemu]\n" "path=%s\n" "read only=no\n" "guest ok=yes\n", exported_dir ); fclose(f); snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s", CONFIG_SMBD_COMMAND, smb_conf); if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0) { slirp_smb_cleanup(s); error_report("conflicting/invalid smbserver address"); return -1; } return 0; }
1threat
static void attach_storage_element(SCLPDevice *sclp, SCCB *sccb, uint16_t element) { int i, assigned, subincrement_id; AttachStorageElement *attach_info = (AttachStorageElement *) sccb; sclpMemoryHotplugDev *mhd = get_sclp_memory_hotplug_dev(); assert(mhd); if (element != 1) { sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_SCLP_COMMAND); return; } assigned = mhd->standby_mem_size >> mhd->increment_size; attach_info->assigned = cpu_to_be16(assigned); subincrement_id = ((ram_size >> mhd->increment_size) << 16) + SCLP_STARTING_SUBINCREMENT_ID; for (i = 0; i < assigned; i++) { attach_info->entries[i] = cpu_to_be32(subincrement_id); subincrement_id += SCLP_INCREMENT_UNIT; } sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_COMPLETION); }
1threat
Python - Splitting a list of strings with a delimiter and adding to a new list : This is my list: names = ['blue v orange', 'white v black', 'red v brown'] I want to split them by ' v ' and append to a new list like this: ['blue', 'white', 'red'] #first ['orange', 'black', 'brown'] #second How can I append them after splitting? first = [] second = [] for x in names: first, second = x.split(' v ')
0debug
php remove only wrapper tag : How can remove with preg_replace only wrapper tag. for example: I want remove <p> tag: `$html = "<p><div><p>aaaaaa</p></div></p>";` output should be `<div><p>aaaaaa</p></div>` if input is `$html = "<p>aaaaaa</p><div>bbbb</div>";` output should remind `<div><p>aaaaaa</p></div>`
0debug
Find OS username in NodeJS : <p>How would I find the username that the computer owner is using currently (while logged in), using NodeJS?</p> <p>I have searched around a bit, but haven't found anything...</p>
0debug
static int common_bind(struct common *c) { int mfn; if (xenstore_read_fe_int(&c->xendev, "page-ref", &mfn) == -1) return -1; if (xenstore_read_fe_int(&c->xendev, "event-channel", &c->xendev.remote_port) == -1) return -1; c->page = xc_map_foreign_range(xen_xc, c->xendev.dom, XC_PAGE_SIZE, PROT_READ | PROT_WRITE, mfn); if (c->page == NULL) return -1; xen_be_bind_evtchn(&c->xendev); xen_be_printf(&c->xendev, 1, "ring mfn %d, remote-port %d, local-port %d\n", mfn, c->xendev.remote_port, c->xendev.local_port); return 0; }
1threat
SharePoint Permission : How to create a sharepoint permission that will only allow users to add items but no modify and delete access? this will help me to secure all the data or information that the user input to SP list.
0debug
int32 floatx80_to_int32_round_to_zero( floatx80 a STATUS_PARAM ) { flag aSign; int32 aExp, shiftCount; uint64_t aSig, savedASig; int32 z; aSig = extractFloatx80Frac( a ); aExp = extractFloatx80Exp( a ); aSign = extractFloatx80Sign( a ); if ( 0x401E < aExp ) { if ( ( aExp == 0x7FFF ) && (uint64_t) ( aSig<<1 ) ) aSign = 0; goto invalid; } else if ( aExp < 0x3FFF ) { if ( aExp || aSig ) STATUS(float_exception_flags) |= float_flag_inexact; return 0; } shiftCount = 0x403E - aExp; savedASig = aSig; aSig >>= shiftCount; z = aSig; if ( aSign ) z = - z; if ( ( z < 0 ) ^ aSign ) { invalid: float_raise( float_flag_invalid STATUS_VAR); return aSign ? (int32_t) 0x80000000 : 0x7FFFFFFF; } if ( ( aSig<<shiftCount ) != savedASig ) { STATUS(float_exception_flags) |= float_flag_inexact; } return z; }
1threat
int pci_add_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t offset, uint8_t size) { int ret; Error *local_err = NULL; ret = pci_add_capability2(pdev, cap_id, offset, size, &local_err); if (local_err) { assert(ret < 0); error_report_err(local_err); } else { assert(ret > 0); } return ret; }
1threat
Update columns through SQL Query : <p>I have made a PHP script that upgrades his/her Firewall app (a function of my website). I have written this code:</p> <pre><code>&lt;?php session_start(); include_once 'dbconnect.php'; $servername = "localhost"; $username = "root"; $password = ""; $dbname = "dbtest"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn-&gt;connect_error) { die("Connection failed: " . $conn-&gt;connect_error); } if(!isset($_SESSION['user'])) { header("Location: index.php"); } $query = "UPDATE users SET firewall = firewall + 1, money = money - 300 WHERE user_id=".$_SESSION['user']")"; ?&gt; </code></pre> <p>Please help me and see what I did wrong.</p>
0debug
void s390_pci_iommu_enable(S390PCIBusDevice *pbdev) { uint64_t size = pbdev->pal - pbdev->pba + 1; memory_region_init_iommu(&pbdev->iommu_mr, OBJECT(&pbdev->mr), &s390_iommu_ops, "iommu-s390", size); memory_region_add_subregion(&pbdev->mr, pbdev->pba, &pbdev->iommu_mr); pbdev->iommu_enabled = true; }
1threat
How to set target fragment of a dialog when using navigation components : <p>I'm showing a dialog inside a fragment using <code>childFragmentManager</code> or within an Activity using the <code>supportFragmentManager</code>, in the process I would like to set the target fragment, like this:</p> <pre><code>val textSearchDialog = TextSearchDialogFragment.newInstance() textSearchDialog.setTargetFragment(PlaceSearchFragment@this, 0) </code></pre> <p>But when running that code I get the error:</p> <blockquote> <p>java.lang.IllegalStateException: Fragment TextSearchDialogFragment{b7fce67 #0 0} declared target fragment PlaceSearchFragment{f87414 #0 id=0x7f080078} that does not belong to this FragmentManager!</p> </blockquote> <p>I don't know how to access the <code>FragmentManager</code> the navigation components are using to manage the showing of the fragment, is there a solution for this?</p>
0debug
Appending new key vale pairs to the existing shared preferences : Please can any one tell me how to append new key value pairs to the already exsisting shared preferences.
0debug
static void test_qemu_strtoul_max(void) { const char *str = g_strdup_printf("%lu", ULONG_MAX); char f = 'X'; const char *endptr = &f; unsigned long res = 999; int err; err = qemu_strtoul(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, ULONG_MAX); g_assert(endptr == str + strlen(str)); }
1threat
How to get started with Akka Streams? : <p>The Akka Streams library already comes with quite a <a href="http://doc.akka.io/docs/akka/2.4.2-RC1/scala/stream/index.html">wealth of documentation</a>. However, the main problem for me is that it provides too much material - I feel quite overwhelmed by the number of concepts that I have to learn. Lots of examples shown there feel very heavyweight and can't easily be translated to real world use cases and are therefore quite esoteric. I think it gives way too much details without explaining how to build all the building blocks together and how exactly it helps to solve specific problems.</p> <p>There are sources, sinks, flows, graph stages, partial graphs, materialization, a graph DSL and a lot more and I just don't know where to start. The <a href="http://doc.akka.io/docs/akka/2.4.2-RC1/scala/stream/stream-quickstart.html#stream-quickstart-scala">quick start guide</a> is meant to be a starting place but I don't understand it. It just throws in the concepts mentioned above without explaining them. Furthermore the code examples can't be executed - there are missing parts which makes it more or less impossible for me to follow the text.</p> <p>Can anyone explain the concepts sources, sinks, flows, graph stages, partial graphs, materialization and maybe some other things that I missed in simple words and with easy examples that don't explain every single detail (and which are probably not needed anyway at the beginning)?</p>
0debug
applying arithmetic functiojn on different tables in mysql : i have two tables table1 sanction table2 collection i want to select amount from sanction - amount recovered from collection and output the difference. select SUM(sanction.san_recover-collection.amount) as total where client_id=?
0debug
What is the Time Complexity of my algorithim? : This algorithm was written for LeetCode's climbing stairs problem and it ran at 20ms. I believe the time complexity is O(n), because this link https://towardsdatascience.com/understanding-time-complexity-with-python-examples-2bda6e8158a7 said O(n) is when the running time increases linearly as the size of the input gets bigger, which is what I think is going on here. I was wondering if someone could explain to me the the time complexity here and why it would be that. Any additional info on how I could get it to linear time if I'm not there already would help too. Here is my code: ``` class Solution: def climbStairs(self, n: int) -> int: #n is the step I need to reach cells = n if cells == 0: return 1 else: result = [] for i in range(0, 1*cells + 1): result.append(i) if result[i] == 0: result[i] = 1 else: if result[i] > 1: result[i] = result[i-1] + result[i-2] return result[-1] ```
0debug
Implements ads in libgdx game correctly : <p>I KNOW ITS LONG BUT I NEED HELP PLEASE.</p> <p>I've been working (and struggling) with this libgdx game for the past month now and everything worked out fine but when I added interstitial ad in it then it became unexpectedly slow and the game glitches a lot..it works fine if i remove the code with the ads</p> <p>How my game works is it goes from MenuState>>PlayState>>GameOverState>>PlayState>>GameOverState and so on..(all of the code are given below)</p> <p>I've got a couple questions (a) How do I get my game to work smoothly? (b) Is there any way to show ads only in GameOverState?(I tried introducing a boolean and a 'if' statement on the ad but failed) (c)How do i dispose my assets more effeciently?(They don't dispose if the classes are called too fast repeatedly)</p> <p>If you require any more information about it, do let me know and I would be happy to do so..</p> <p>States:</p> <p>Main libgdx class:GrumpyDemo</p> <pre><code>package com.mygdx.game; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.utils.TimeUtils; import com.mygdx.game.States.AdCloseState; import com.mygdx.game.States.GameOverState; import com.mygdx.game.States.GameStateManager; import com.mygdx.game.States.MenuState; public class GrumpyDemo extends ApplicationAdapter { public static final int WIDTH = 480; public static final int HEIGHT= 800; public static final String TITLE = "Flappy Bird"; private GameStateManager gsm; public static long AdStart = 0; public AdController adController; private SpriteBatch batch; public GrumpyDemo(AdController adController){ this.adController = adController; } @Override public void create () { batch = new SpriteBatch(); gsm = new GameStateManager(); Gdx.gl.glClearColor(1, 0, 0, 1); gsm.push(new MenuState(gsm)); AdStart = TimeUtils.nanoTime(); adController.showBannerAds(); } @Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); gsm.update(Gdx.graphics.getDeltaTime()); gsm.render(batch); if (TimeUtils.timeSinceMillis(AdStart)&gt; 30000){ adController.showInterstitialAds(new Runnable() { @Override public void run() { gsm.pop(); gsm.push(new AdCloseState(gsm)); } }); } } @Override public void dispose () { batch.dispose(); } } </code></pre> <p>My abstract class: State</p> <pre><code> package com.mygdx.game.States; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Vector3; /** * Created by Kronos on 28-01-2017. */ public abstract class State { protected OrthographicCamera cam; protected Vector3 mouse; protected GameStateManager gsm; protected State(GameStateManager gsm){ this.gsm = gsm; cam = new OrthographicCamera(); mouse = new Vector3(); } protected abstract void handleInput(); public abstract void update(float dt); public abstract void render(SpriteBatch sb); public abstract void dispose(); </code></pre> <p>MenuState:</p> <pre><code> private Texture background; private Texture playBtn; private Music music; public MenuState(GameStateManager gsm) { super(gsm); cam.setToOrtho(false, GrumpyDemo.WIDTH / 2, GrumpyDemo.HEIGHT / 2); background = new Texture("bg.png"); playBtn = new Texture("playbtn.png"); music = Gdx.audio.newMusic(Gdx.files.internal("mainmusic.mp3")); music.setVolume(0.8f); music.play(); } @Override public void handleInput() { if (Gdx.input.justTouched()) { gsm.set(new PlayState(gsm)); } } @Override public void update(float dt) { handleInput(); } @Override public void render(SpriteBatch sb) { sb.setProjectionMatrix(cam.combined); sb.begin(); sb.draw(background, 0, 0); sb.draw(playBtn, cam.position.x - playBtn.getWidth() / 2, cam.position.y); sb.end(); } @Override public void dispose() { background.dispose(); playBtn.dispose(); music.dispose(); System.out.println("Menu State Disposed"); } </code></pre> <p>PlayState:</p> <pre><code>package com.mygdx.game.States; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.TimeUtils; import com.mygdx.game.GrumpyDemo; import com.mygdx.game.Sprites.Bird; import com.mygdx.game.Sprites.Tube; /** * Created by Kronos on 28-01-2017. */ public class PlayState extends State { private static final int TUBE_SPACING = 75; private static final int TUBE_COUNT = 4; private Bird bird; private Texture actualGamebg; private Tube tube ; private Texture ground; private Vector2 groundPos1,groundPos2; private static final int HIGHEST_GROUND_LIMIT = -30; private Array&lt;Tube&gt; tubes; private int k; long startTime=0; private Music mainMusic; private Music scoreIncrease; private Music wingFlap; public BitmapFont font24; public String SCORE; public int l; public long gameOverStart=0; public PlayState(GameStateManager gsm) { super(gsm); bird = new Bird(0,300); actualGamebg = new Texture("bg.png"); cam.setToOrtho(false, GrumpyDemo.WIDTH/2,GrumpyDemo.HEIGHT/2); tubes =new Array&lt;Tube&gt;(); ground = new Texture("ground.png"); mainMusic = Gdx.audio.newMusic(Gdx.files.internal("mainmusic.mp3")); scoreIncrease = Gdx.audio.newMusic(Gdx.files.internal("smw_coin.ogg")); wingFlap = Gdx.audio.newMusic(Gdx.files.internal("sfx_wing.ogg")); font24= new BitmapFont(); SCORE = new String(); fontGenerator(); groundPos1 = new Vector2(cam.position.x -cam.viewportWidth/2, HIGHEST_GROUND_LIMIT); groundPos2 = new Vector2((cam.position.x - cam.viewportWidth/2) + ground.getWidth(),HIGHEST_GROUND_LIMIT); startTime = TimeUtils.nanoTime(); gameOverStart = TimeUtils.millis(); for(int i=1 ; i&lt;=TUBE_COUNT; i++) { tubes.add(new Tube(i* (TUBE_SPACING + Tube.TUBE_WIDTH))); } mainMusic.play(); mainMusic.setVolume(0.8f); mainMusic.setLooping(true); } @Override protected void handleInput() { if (Gdx.input.justTouched()) bird.jump(); wingFlap.setLooping(false); wingFlap.play(); wingFlap.setVolume(0.1f); } @Override public void update(float dt) { handleInput(); updateGround(); bird.update(dt); if (TimeUtils.timeSinceNanos(startTime) &gt; 1400000000) { Score(); startTime = TimeUtils.nanoTime(); } SCORE = String.valueOf(k); for(int i =0 ; i&lt; tubes.size;i++) { Tube tube= tubes.get(i); if (cam.position.x - (cam.viewportWidth/2) &gt; tube.getPosTopTube().x + tube.getTopTube().getWidth()) { tube.reposition(tube.getPosTopTube().x + ((Tube.TUBE_WIDTH + TUBE_SPACING) *TUBE_COUNT)); } if(tube.collides(bird.getBounds())) { cam.position.x = bird.getPosition().x; mainMusic.stop(); gsm.set(new GameOverState(gsm)); l = k; } else cam.position.x = bird.getPosition().x +80; } if (bird.getPosition().y &lt;= ground.getHeight()){ gsm.set(new GameOverState(gsm)); mainMusic.stop(); l = k; } cam.update(); } @Override public void render(SpriteBatch sb) { sb.setProjectionMatrix(cam.combined); sb.begin(); sb.draw(actualGamebg, cam.position.x - (cam.viewportWidth/2), 0); sb.draw(bird.getTexture(), bird.getPosition().x , bird.getPosition().y); for(Tube tube: tubes) { sb.draw(tube.getTopTube(), tube.getPosTopTube().x, tube.getPosTopTube().y); sb.draw(tube.getBottomTube(), tube.getPosBottomTube().x, tube.getPosBottomTube().y); } sb.draw(ground,groundPos1.x,groundPos1.y); sb.draw(ground,groundPos2.x,groundPos2.y); font24.draw(sb,SCORE,cam.position.x -2,cam.position.y + 15); sb.end(); } /** * spritebatches must be drawn in order .The one at the bottommost acts as the top layer. */ @Override public void dispose() { actualGamebg.dispose(); bird.dispose(); font24.dispose(); for(Tube tube: tubes) { tube.dispose(); } ground.dispose(); mainMusic.dispose(); scoreIncrease.dispose(); wingFlap.dispose(); System.out.println("Play State Disposed"); } private void updateGround() { if (cam.position.x-(cam.viewportWidth/2) &gt; groundPos1.x + ground.getWidth()) { groundPos1.add(ground.getWidth()*2,0); } if (cam.position.x-(cam.viewportWidth/2) &gt; groundPos2.x + ground.getWidth()) { groundPos2.add(ground.getWidth()*2,0); } } public void Score() { k++; scoreIncrease.play(); scoreIncrease.setVolume(0.3f); } public int getL(){ return l; } public void fontGenerator(){ FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("bitmapfont/PressStart2P.ttf")); FreeTypeFontGenerator.FreeTypeFontParameter parameter= new FreeTypeFontGenerator.FreeTypeFontParameter(); parameter.size=12; parameter.color= Color.GOLD; parameter.borderColor= Color.GOLDENROD; font24= generator.generateFont(parameter); font24.setUseIntegerPositions(false); } } </code></pre> <p>GameOverState:</p> <pre><code> private Texture gameOver; private Texture gameOverBg; private Texture playAgainBtn; private Texture ground; private Vector2 groundPos1; private Music gameOverMusic; private BitmapFont totalScore; private String STRING; public PlayState playState; public Boolean AdStart = true; public GameOverState(GameStateManager gsm) { super(gsm); cam.setToOrtho(false, GrumpyDemo.WIDTH/2,GrumpyDemo.HEIGHT/2); gameOver = new Texture("gameover.png"); gameOverBg = new Texture ("bg.png"); playAgainBtn = new Texture("playbtn.png"); ground = new Texture("ground.png"); AdStart = new Boolean(true); gameOverMusic = Gdx.audio.newMusic(Gdx.files.internal("gameoversfx.ogg")); groundPos1 = new Vector2(cam.position.x -cam.viewportWidth/2, -30); totalScore = new BitmapFont(); STRING = new String(); playState = new PlayState(gsm); gameOverMusic.play(); gameOverMusic.setVolume(1.0f); } @Override public void handleInput() { if (Gdx.input.justTouched()) { gsm.set(new PlayState(gsm)); gameOverMusic.stop(); AdStart = false; } } @Override public void update(float dt) { handleInput(); STRING = "SCORE: " + playState.getL(); fontGenerator(); } @Override public void render(SpriteBatch sb) { sb.setProjectionMatrix(cam.combined); sb.begin(); sb.draw(gameOverBg,0,0); sb.draw(gameOver, cam.position.x-gameOver.getWidth()/2 , 5*(cam.position.y/3)); sb.draw(ground,groundPos1.x,groundPos1.y); sb.draw(playAgainBtn,cam.position.x-playAgainBtn.getWidth()/2,2*(cam.position.y/3)); totalScore.draw(sb,STRING,cam.position.x - gameOver.getWidth()/4 ,5*(cam.position.y/4)); sb.end(); } @Override public void dispose() { gameOver.dispose(); gameOverBg.dispose(); playAgainBtn.dispose(); ground.dispose(); totalScore.dispose(); playState.dispose(); System.out.println("Game Over State Disposed"); } public void fontGenerator(){ FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("bitmapfont/PressStart2P.ttf")); FreeTypeFontGenerator.FreeTypeFontParameter parameter= new FreeTypeFontGenerator.FreeTypeFontParameter(); parameter.size=12; parameter.color= Color.GOLD; parameter.borderColor= Color.GOLDENROD; totalScore= generator.generateFont(parameter); totalScore.setUseIntegerPositions(false); } public Boolean getAdStart(){ return AdStart; } </code></pre> <p>Almost forgot it..My game state manager:</p> <pre><code> package com.mygdx.game.States; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import java.util.Stack; /** * Created by Kronos on 28-01-2017. */ public class GameStateManager { private Stack&lt;State&gt; states; public GameStateManager(){ states = new Stack&lt;State&gt;(); } public void push(State state) { states.push(state); } public void pop() { states.pop().dispose(); } public void set(State state) { states.pop().dispose(); states.push(state); } public void update(float dt) { states.peek().update(dt); } public void render(SpriteBatch sb) { states.peek().render(sb); } } </code></pre> <p>Thanks for all the help.</p>
0debug
understanding properties in C# : <p>I'm new to C#, just a question on properties </p> <pre><code>public int Age { get { return empAge; } set { empAge = value; } } </code></pre> <p>I actually know how properties works, but just need to find an easy way to understand why this sugar syntax work in this way.</p> <p>So I used to think the <code>int</code> keyword between <code>public</code> and <code>age</code> is the return type of the getter, but what about the setter? obviously the setter return void which doesn't match the return type of int?</p>
0debug
Spark services in Data Lake : I am trying to use spark sql to query a csv file placed in Data Lake Store. when I query i am getting "java.lang.ClassNotFoundException: Class com.microsoft.azure.datalake.store.AdlFileSystem not found". How can I use spark sql to query a file placed in Data Lake Store? Please help me with a sample. Example csv: Id Name Designation 1 aaa bbb 2 ccc ddd 3 eee fff Thanks in advance, Sowandharya
0debug
static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin) { PCIDevice *pxb = pci_dev->bus->parent_dev; return pin - PCI_SLOT(pxb->devfn); }
1threat
making my code right : <p>can some one tell me if there's something wrong in my code ?</p> <p>i am using bootsrap is js and css files and in this code below it should open a dialog box but i don't know why it's not working. wanted to make sure if it's all ok here </p> <pre><code>&lt;div class="modal fade details-1" id="details-1" tabindex="-1" role="dialog" aria-labelledby="details-1" aria-hidden="true"&gt; &lt;div class="modal-dialog modal-lg"&gt; &lt;div class="modal-header"&gt; &lt;button class="close" type="button" data-dismiss="modal" aria-label="close"&gt; &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt; &lt;/button&gt; &lt;h4 class="modal-title text-center"&gt;Levis Jeans&lt;/h4&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;div class="container-fluid"&gt; &lt;div class="row"&gt; &lt;div class="col-sm-6"&gt; &lt;div class="center-block"&gt; &lt;img src="images/products/men4.png" alt="Levis Jeans" class="details img-responsive"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="col-sm-6"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
0debug
static av_cold int X264_init(AVCodecContext *avctx) { X264Context *x4 = avctx->priv_data; int sw,sh; if (avctx->global_quality > 0) av_log(avctx, AV_LOG_WARNING, "-qscale is ignored, -crf is recommended.\n"); x264_param_default(&x4->params); x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER; if (x4->preset || x4->tune) if (x264_param_default_preset(&x4->params, x4->preset, x4->tune) < 0) { int i; av_log(avctx, AV_LOG_ERROR, "Error setting preset/tune %s/%s.\n", x4->preset, x4->tune); av_log(avctx, AV_LOG_INFO, "Possible presets:"); for (i = 0; x264_preset_names[i]; i++) av_log(avctx, AV_LOG_INFO, " %s", x264_preset_names[i]); av_log(avctx, AV_LOG_INFO, "\n"); av_log(avctx, AV_LOG_INFO, "Possible tunes:"); for (i = 0; x264_tune_names[i]; i++) av_log(avctx, AV_LOG_INFO, " %s", x264_tune_names[i]); av_log(avctx, AV_LOG_INFO, "\n"); return AVERROR(EINVAL); } if (avctx->level > 0) x4->params.i_level_idc = avctx->level; x4->params.pf_log = X264_log; x4->params.p_log_private = avctx; x4->params.i_log_level = X264_LOG_DEBUG; x4->params.i_csp = convert_pix_fmt(avctx->pix_fmt); OPT_STR("weightp", x4->wpredp); if (avctx->bit_rate) { x4->params.rc.i_bitrate = avctx->bit_rate / 1000; x4->params.rc.i_rc_method = X264_RC_ABR; } x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000; x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000; x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1; if (avctx->flags & CODEC_FLAG_PASS2) { x4->params.rc.b_stat_read = 1; } else { if (x4->crf >= 0) { x4->params.rc.i_rc_method = X264_RC_CRF; x4->params.rc.f_rf_constant = x4->crf; } else if (x4->cqp >= 0) { x4->params.rc.i_rc_method = X264_RC_CQP; x4->params.rc.i_qp_constant = x4->cqp; } if (x4->crf_max >= 0) x4->params.rc.f_rf_constant_max = x4->crf_max; } if (avctx->rc_buffer_size && avctx->rc_initial_buffer_occupancy > 0 && (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) { x4->params.rc.f_vbv_buffer_init = (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size; } OPT_STR("level", x4->level); if (avctx->i_quant_factor > 0) x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor); if (avctx->b_quant_factor > 0) x4->params.rc.f_pb_factor = avctx->b_quant_factor; if (avctx->chromaoffset) x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; if (avctx->me_method == ME_EPZS) x4->params.analyse.i_me_method = X264_ME_DIA; else if (avctx->me_method == ME_HEX) x4->params.analyse.i_me_method = X264_ME_HEX; else if (avctx->me_method == ME_UMH) x4->params.analyse.i_me_method = X264_ME_UMH; else if (avctx->me_method == ME_FULL) x4->params.analyse.i_me_method = X264_ME_ESA; else if (avctx->me_method == ME_TESA) x4->params.analyse.i_me_method = X264_ME_TESA; if (avctx->gop_size >= 0) x4->params.i_keyint_max = avctx->gop_size; if (avctx->max_b_frames >= 0) x4->params.i_bframe = avctx->max_b_frames; if (avctx->scenechange_threshold >= 0) x4->params.i_scenecut_threshold = avctx->scenechange_threshold; if (avctx->qmin >= 0) x4->params.rc.i_qp_min = avctx->qmin; if (avctx->qmax >= 0) x4->params.rc.i_qp_max = avctx->qmax; if (avctx->max_qdiff >= 0) x4->params.rc.i_qp_step = avctx->max_qdiff; if (avctx->qblur >= 0) x4->params.rc.f_qblur = avctx->qblur; if (avctx->qcompress >= 0) x4->params.rc.f_qcompress = avctx->qcompress; if (avctx->refs >= 0) x4->params.i_frame_reference = avctx->refs; else if (x4->level) { int i; int mbn = FF_CEIL_RSHIFT(avctx->width, 4) * FF_CEIL_RSHIFT(avctx->height, 4); int level_id = -1; char *tail; int scale = X264_BUILD < 129 ? 384 : 1; if (!strcmp(x4->level, "1b")) { level_id = 9; } else if (strlen(x4->level) <= 3){ level_id = av_strtod(x4->level, &tail) * 10 + 0.5; if (*tail) level_id = -1; } if (level_id <= 0) av_log(avctx, AV_LOG_WARNING, "Failed to parse level\n"); for (i = 0; i<x264_levels[i].level_idc; i++) if (x264_levels[i].level_idc == level_id) x4->params.i_frame_reference = av_clip(x264_levels[i].dpb / mbn / scale, 1, x4->params.i_frame_reference); } if (avctx->trellis >= 0) x4->params.analyse.i_trellis = avctx->trellis; if (avctx->me_range >= 0) x4->params.analyse.i_me_range = avctx->me_range; if (avctx->noise_reduction >= 0) x4->params.analyse.i_noise_reduction = avctx->noise_reduction; if (avctx->me_subpel_quality >= 0) x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; if (avctx->b_frame_strategy >= 0) x4->params.i_bframe_adaptive = avctx->b_frame_strategy; if (avctx->keyint_min >= 0) x4->params.i_keyint_min = avctx->keyint_min; if (avctx->coder_type >= 0) x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC; if (avctx->me_cmp >= 0) x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA; if (x4->aq_mode >= 0) x4->params.rc.i_aq_mode = x4->aq_mode; if (x4->aq_strength >= 0) x4->params.rc.f_aq_strength = x4->aq_strength; PARSE_X264_OPT("psy-rd", psy_rd); PARSE_X264_OPT("deblock", deblock); PARSE_X264_OPT("partitions", partitions); PARSE_X264_OPT("stats", stats); if (x4->psy >= 0) x4->params.analyse.b_psy = x4->psy; if (x4->rc_lookahead >= 0) x4->params.rc.i_lookahead = x4->rc_lookahead; if (x4->weightp >= 0) x4->params.analyse.i_weighted_pred = x4->weightp; if (x4->weightb >= 0) x4->params.analyse.b_weighted_bipred = x4->weightb; if (x4->cplxblur >= 0) x4->params.rc.f_complexity_blur = x4->cplxblur; if (x4->ssim >= 0) x4->params.analyse.b_ssim = x4->ssim; if (x4->intra_refresh >= 0) x4->params.b_intra_refresh = x4->intra_refresh; if (x4->bluray_compat >= 0) { x4->params.b_bluray_compat = x4->bluray_compat; x4->params.b_vfr_input = 0; } if (x4->avcintra_class >= 0) #if X264_BUILD >= 142 x4->params.i_avcintra_class = x4->avcintra_class; #else av_log(avctx, AV_LOG_ERROR, "x264 too old for AVC Intra, at least version 142 needed\n"); #endif if (x4->b_bias != INT_MIN) x4->params.i_bframe_bias = x4->b_bias; if (x4->b_pyramid >= 0) x4->params.i_bframe_pyramid = x4->b_pyramid; if (x4->mixed_refs >= 0) x4->params.analyse.b_mixed_references = x4->mixed_refs; if (x4->dct8x8 >= 0) x4->params.analyse.b_transform_8x8 = x4->dct8x8; if (x4->fast_pskip >= 0) x4->params.analyse.b_fast_pskip = x4->fast_pskip; if (x4->aud >= 0) x4->params.b_aud = x4->aud; if (x4->mbtree >= 0) x4->params.rc.b_mb_tree = x4->mbtree; if (x4->direct_pred >= 0) x4->params.analyse.i_direct_mv_pred = x4->direct_pred; if (x4->slice_max_size >= 0) x4->params.i_slice_max_size = x4->slice_max_size; else { if (avctx->rtp_payload_size) x4->params.i_slice_max_size = avctx->rtp_payload_size; } if (x4->fastfirstpass) x264_param_apply_fastfirstpass(&x4->params); if (!x4->profile) switch (avctx->profile) { case FF_PROFILE_H264_BASELINE: x4->profile = av_strdup("baseline"); break; case FF_PROFILE_H264_HIGH: x4->profile = av_strdup("high"); break; case FF_PROFILE_H264_HIGH_10: x4->profile = av_strdup("high10"); break; case FF_PROFILE_H264_HIGH_422: x4->profile = av_strdup("high422"); break; case FF_PROFILE_H264_HIGH_444: x4->profile = av_strdup("high444"); break; case FF_PROFILE_H264_MAIN: x4->profile = av_strdup("main"); break; default: break; } if (x4->nal_hrd >= 0) x4->params.i_nal_hrd = x4->nal_hrd; if (x4->profile) if (x264_param_apply_profile(&x4->params, x4->profile) < 0) { int i; av_log(avctx, AV_LOG_ERROR, "Error setting profile %s.\n", x4->profile); av_log(avctx, AV_LOG_INFO, "Possible profiles:"); for (i = 0; x264_profile_names[i]; i++) av_log(avctx, AV_LOG_INFO, " %s", x264_profile_names[i]); av_log(avctx, AV_LOG_INFO, "\n"); return AVERROR(EINVAL); } x4->params.i_width = avctx->width; x4->params.i_height = avctx->height; av_reduce(&sw, &sh, avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den, 4096); x4->params.vui.i_sar_width = sw; x4->params.vui.i_sar_height = sh; x4->params.i_timebase_den = avctx->time_base.den; x4->params.i_timebase_num = avctx->time_base.num; x4->params.i_fps_num = avctx->time_base.den; x4->params.i_fps_den = avctx->time_base.num * avctx->ticks_per_frame; x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR; x4->params.i_threads = avctx->thread_count; if (avctx->thread_type) x4->params.b_sliced_threads = avctx->thread_type == FF_THREAD_SLICE; x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT; x4->params.b_open_gop = !(avctx->flags & CODEC_FLAG_CLOSED_GOP); x4->params.i_slice_count = avctx->slices; x4->params.vui.b_fullrange = avctx->pix_fmt == AV_PIX_FMT_YUVJ420P || avctx->pix_fmt == AV_PIX_FMT_YUVJ422P || avctx->pix_fmt == AV_PIX_FMT_YUVJ444P || avctx->color_range == AVCOL_RANGE_JPEG; if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED) x4->params.vui.i_colmatrix = avctx->colorspace; if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED) x4->params.vui.i_colorprim = avctx->color_primaries; if (avctx->color_trc != AVCOL_TRC_UNSPECIFIED) x4->params.vui.i_transfer = avctx->color_trc; if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) x4->params.b_repeat_headers = 0; if(x4->x264opts){ const char *p= x4->x264opts; while(p){ char param[256]={0}, val[256]={0}; if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){ OPT_STR(param, "1"); }else OPT_STR(param, val); p= strchr(p, ':'); p+=!!p; } } if (x4->x264_params) { AVDictionary *dict = NULL; AVDictionaryEntry *en = NULL; if (!av_dict_parse_string(&dict, x4->x264_params, "=", ":", 0)) { while ((en = av_dict_get(dict, "", en, AV_DICT_IGNORE_SUFFIX))) { if (x264_param_parse(&x4->params, en->key, en->value) < 0) av_log(avctx, AV_LOG_WARNING, "Error parsing option '%s = %s'.\n", en->key, en->value); } av_dict_free(&dict); } } avctx->has_b_frames = x4->params.i_bframe ? x4->params.i_bframe_pyramid ? 2 : 1 : 0; if (avctx->max_b_frames < 0) avctx->max_b_frames = 0; avctx->bit_rate = x4->params.rc.i_bitrate*1000; x4->enc = x264_encoder_open(&x4->params); if (!x4->enc) return -1; avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { x264_nal_t *nal; uint8_t *p; int nnal, s, i; s = x264_encoder_headers(x4->enc, &nal, &nnal); avctx->extradata = p = av_malloc(s); for (i = 0; i < nnal; i++) { if (nal[i].i_type == NAL_SEI) { av_log(avctx, AV_LOG_INFO, "%s\n", nal[i].p_payload+25); x4->sei_size = nal[i].i_payload; x4->sei = av_malloc(x4->sei_size); if (!x4->sei) memcpy(x4->sei, nal[i].p_payload, nal[i].i_payload); continue; } memcpy(p, nal[i].p_payload, nal[i].i_payload); p += nal[i].i_payload; } avctx->extradata_size = p - avctx->extradata; } return 0; nomem: X264_close(avctx); return AVERROR(ENOMEM); }
1threat
what is meant by this in c++ *ptr = len : While reading a code about copy constructor in C++,i found a statement like this *ptr=len(which is a int type variable ) .Here *ptr is a int type pointer .I could not make out the statement.Please give me a conveniencing answer.
0debug
Difference between creating ViewModifier and View extension in SwiftUI : <p>I'm trying to find out what is practical difference between these two approaches. For example:</p> <pre><code>struct PrimaryLabel: ViewModifier { func body(content: Content) -&gt; some View { content .padding() .background(Color.black) .foregroundColor(Color.white) .font(.largeTitle) .cornerRadius(10) } } extension View { func makePrimaryLabel() -&gt; some View { self .padding() .background(Color.black) .foregroundColor(Color.white) .font(.largeTitle) .cornerRadius(10) } } </code></pre> <p>Then we can use all of them following way:</p> <pre><code>Text(tech.title) .modifier(PrimaryLabel()) Text(tech.title) .makePrimaryLabel() ModifiedContent( content: Text(tech.title), modifier: PrimaryLabel() ) </code></pre>
0debug
teacher told me not to use static/dynamic vector pointer : <p>But what are those exactly? Is...</p> <pre class="lang-cpp prettyprint-override"><code>vector&lt;float&gt; Vec; Vec.push_back(2); </code></pre> <p>a pointer? If so, what other options can I use instead if I want to implement lists/vectors/arrays.</p> <p>And for my own information: Are pointers a bad way to code or kinda outdated? </p>
0debug
Web Api Go On Try and Return method but Return An error has occurred error : I Wrote an Api To Get Some Objects In Json Format . it get values in Linq Command and go To Return Method . but does not return my wanted values return ({ "Message": "An error has occurred." }) I Searched alot but did not find any thing yet . please Help me . and say what is the problem public IHttpActionResult GetOrdersOfPostman(string postmanId) { try { var postmanCustomersModel = new List<PostmanCustomerModel>(); var id = Convert.ToInt64(postmanId); var orderStatus = (byte) OrderStatus.DeliverToPostman; var orders = _orderRepository.AsQueryable().Where(x => x.PostmanId == id && x.OrderStatus==orderStatus && x.SellerCustomerId > 0).ToList(); return Ok(orders); } catch (Exception ex) { return BadRequest(ex.Message); } }
0debug
static void vda_h264_uninit(AVCodecContext *avctx) { VDAContext *vda = avctx->internal->priv_data; av_freep(&vda->bitstream); }
1threat
void cpu_x86_inject_mce(CPUState *cenv, int bank, uint64_t status, uint64_t mcg_status, uint64_t addr, uint64_t misc, int broadcast) { unsigned bank_num = cenv->mcg_cap & 0xff; CPUState *env; int flag = 0; if (bank >= bank_num || !(status & MCI_STATUS_VAL)) { return; } if (broadcast) { if (!cpu_x86_support_mca_broadcast(cenv)) { fprintf(stderr, "Current CPU does not support broadcast\n"); return; } } if (kvm_enabled()) { if (broadcast) { flag |= MCE_BROADCAST; } kvm_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc, flag); } else { qemu_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc); if (broadcast) { for (env = first_cpu; env != NULL; env = env->next_cpu) { if (cenv == env) { continue; } qemu_inject_x86_mce(env, 1, MCI_STATUS_VAL | MCI_STATUS_UC, MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0); } } } }
1threat
Improve Lombok @Data Code Coverage : <p>I am writing unit tests for my project and am trying to achieve at least 80% code coverage. Problem is that I am using lombok's <code>@Data</code> annotation for generating getters and setters and when I run my unit tests, all those getters and setters along with other methods like <code>toString</code>, <code>equals</code>, <code>hashcode</code> etc are missed and my code coverage takes a hit. Is there any workaround for this. I have been searching a lot about this but haven't been able to find anything which could help out. Any help on this would be appreciated.</p> <p>I am using Eclemma for code coverage analysis.</p>
0debug
Javascript code for Showing and Hiding multiple divs with multiple buttons : Hope all is well? I first off want to say thanks for the Help in advance. I am new to JavaScript I don't understand it that well and have something real urgent to complete. I used this code: but apparent I have no Idea what I am doing wrong. <!-- begin snippet: js hide: false console: true --> <!-- language: lang-html --> <!DOCTYPE HTML> <html> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Untitled 1</title> <script type="text/javascript"> jQuery(function($) { var $bgs = $('.menu-toggle'); $('.menu-item').click(function() { var $target = $($(this).data('target')).stop(true).slideToggle(); $bgs.not($target).filter(':visible').stop(true, true).slideUp(); }) }) </script> </head> <body> <div class="menu-item menu-item-1" data-target=".recovery-bg"> <a href="#">Recovery</a> </div> <div class="menu-item menu-item-2" data-target=".forensic-bg"> <a href="#">Forensics</a> </div> <div class="menu-item menu-item-3" data-target=".erasure-bg"> <a href="#">Erasure</a> </div> <div class="menu-item menu-item-4" data-target=".training-bg"> <a href="#">Training</a> </div> <div class="menu-item menu-item-5" data-target=".product-bg"> <a href="#">Products</a> </div> <div class="menu-toggle recovery-bg"> recovery-bg </div> <div class="menu-toggle forensic-bg"> forensic-bg </div> <div class="menu-toggle erasure-bg"> erasure-bg </div> <div class="menu-toggle training-bg"> training-bg </div> <div class="menu-toggle product-bg"> product-bg </div> </body> </html> <!-- end snippet --> I did get this same code from this website, but like I said no luck what so ever. Please Help Thanks
0debug
static void do_adaptive_prediction(struct G722Band *band, const int cur_diff) { int sg[2], limit, cur_qtzd_reconst; const int cur_part_reconst = band->s_zero + cur_diff < 0; sg[0] = sign_lookup[cur_part_reconst != band->part_reconst_mem[0]]; sg[1] = sign_lookup[cur_part_reconst == band->part_reconst_mem[1]]; band->part_reconst_mem[1] = band->part_reconst_mem[0]; band->part_reconst_mem[0] = cur_part_reconst; band->pole_mem[1] = av_clip((sg[0] * av_clip(band->pole_mem[0], -8191, 8191) >> 5) + (sg[1] << 7) + (band->pole_mem[1] * 127 >> 7), -12288, 12288); limit = 15360 - band->pole_mem[1]; band->pole_mem[0] = av_clip(-192 * sg[0] + (band->pole_mem[0] * 255 >> 8), -limit, limit); s_zero(cur_diff, band); cur_qtzd_reconst = av_clip_int16((band->s_predictor + cur_diff) << 1); band->s_predictor = av_clip_int16(band->s_zero + (band->pole_mem[0] * cur_qtzd_reconst >> 15) + (band->pole_mem[1] * band->prev_qtzd_reconst >> 15)); band->prev_qtzd_reconst = cur_qtzd_reconst; }
1threat
static void qemu_opt_del(QemuOpt *opt) { TAILQ_REMOVE(&opt->opts->head, opt, next); qemu_free(( char*)opt->name); qemu_free(( char*)opt->str); qemu_free(opt); }
1threat
How to create a variable that library code can use and a user can set? : <p>1) I want to use variable <code>n_threads</code> inside my library code (that is distributed in shared library form on Windows and Linux) in multiple <code>.cpp</code> files.</p> <p>2) I want to make library user to set it. </p> <p>How to do such thing in C++?</p> <ul> <li>I tried global file with <code>static</code> variables - it leads to each <code>.cpp</code> file having its copy; </li> <li>I have tried just to keep it in a namespace which leads to variable being already defined in other translation units and thus library not compiling</li> <li>I have tried <code>external</code> (which works on Linux with <code>.so</code> and does compile on Windows MSVC14) which leads to library not compiling due to unresolved externals.</li> </ul> <p>What can be done to make global variable used in multiple library <code>.cpp</code> files be setable from outside (from library user code)?</p>
0debug
Eclipse - C++ - debugger terminating immediatly : [ECLIPSE] when I ran a C program, with breakpoints - it was all fine. now I`m running a C++ program (simple cout print one), and it just "terminates" immediatly - instead of going through some of the breakpoints I put. on debug mode it doesnt even print the cout (that IS printed on a regular run). I dont really know whats going wrong - debugger options? compiler? thanks in advance!
0debug
static void dump(unsigned char *buf,size_t len) { int i; for(i=0;i<len;i++) { if ((i&15)==0) printf("%04x ",i); printf("%02x ",buf[i]); if ((i&15)==15) printf("\n"); } printf("\n"); }
1threat
static int decode_header(MPADecodeContext *s, UINT32 header) { int sample_rate, frame_size, mpeg25, padding; int sample_rate_index, bitrate_index; if (header & (1<<20)) { s->lsf = (header & (1<<19)) ? 0 : 1; mpeg25 = 0; } else { s->lsf = 1; mpeg25 = 1; } s->layer = 4 - ((header >> 17) & 3); sample_rate_index = (header >> 10) & 3; sample_rate = mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); if (sample_rate == 0) return 1; sample_rate_index += 3 * (s->lsf + mpeg25); s->sample_rate_index = sample_rate_index; s->error_protection = ((header >> 16) & 1) ^ 1; bitrate_index = (header >> 12) & 0xf; padding = (header >> 9) & 1; s->mode = (header >> 6) & 3; s->mode_ext = (header >> 4) & 3; if (s->mode == MPA_MONO) s->nb_channels = 1; else s->nb_channels = 2; if (bitrate_index != 0) { frame_size = mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index]; s->bit_rate = frame_size * 1000; switch(s->layer) { case 1: frame_size = (frame_size * 12000) / sample_rate; frame_size = (frame_size + padding) * 4; break; case 2: frame_size = (frame_size * 144000) / sample_rate; frame_size += padding; break; default: case 3: frame_size = (frame_size * 144000) / (sample_rate << s->lsf); frame_size += padding; break; } s->frame_size = frame_size; } else { if (!s->free_format_frame_size) return 1; s->frame_size = s->free_format_frame_size; switch(s->layer) { case 1: s->frame_size += padding * 4; s->bit_rate = (s->frame_size * sample_rate) / 48000; break; case 2: s->frame_size += padding; s->bit_rate = (s->frame_size * sample_rate) / 144000; break; default: case 3: s->frame_size += padding; s->bit_rate = (s->frame_size * (sample_rate << s->lsf)) / 144000; break; } } s->sample_rate = sample_rate; #ifdef DEBUG printf("layer%d, %d Hz, %d kbits/s, ", s->layer, s->sample_rate, s->bit_rate); if (s->nb_channels == 2) { if (s->layer == 3) { if (s->mode_ext & MODE_EXT_MS_STEREO) printf("ms-"); if (s->mode_ext & MODE_EXT_I_STEREO) printf("i-"); } printf("stereo"); } else { printf("mono"); } printf("\n"); #endif return 0; }
1threat
Unit testing iOS 10 notifications : <p>In my app I wish to assert that notifications have been added in the correct format. I'd normally do this with dependency injection, but I can't think of a way to test the new <code>UNUserNotificationCenter</code> API.</p> <p>I started to create a mock object which would capture the notification request:</p> <pre><code>import Foundation import UserNotifications class NotificationCenterMock: UNUserNotificationCenter { var request: UNNotificationRequest? = nil override func add(_ request: UNNotificationRequest, withCompletionHandler completionHandler: ((Error?) -&gt; Void)? = nil) { self.request = request } } </code></pre> <p>However, <code>UNUserNotificationCenter</code> has no accessible initializers I can't instantiate the mock.</p> <p>I'm not even sure I can test by adding the notification request and fetching the current notifications, as the tests would need to request permission on the Simulator which would stall the tests. Currently I've refactored the notification logic into a wrapper, so I can at least mock that throughout my application and manually test.</p> <p>Do I have any better options than manual testing?</p>
0debug
error: incompatible types: Vb0201 cannot be coverted to JFrame : My problem is that i want to make a simple JFrame, but i keep getting the same error with this line of code: JFrame frame = new Vb0201(); The error that i get is: error: incompatible types: Vb0201 cannot be coverted to JFrame The full sourcecode is: import javax.swing.*; public class Vb0201 { public static void main(String[] args) { JFrame frame = new Vb0201(); frame.setSize( 400, 200 ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setTitle( "Eerste applicatie" ); frame.setVisible( true ); } }
0debug
static int mxf_read_track(void *arg, AVIOContext *pb, int tag, int size, UID uid) { MXFTrack *track = arg; switch(tag) { case 0x4801: track->track_id = avio_rb32(pb); break; case 0x4804: avio_read(pb, track->track_number, 4); break; case 0x4B01: track->edit_rate.den = avio_rb32(pb); track->edit_rate.num = avio_rb32(pb); break; case 0x4803: avio_read(pb, track->sequence_ref, 16); break; } return 0; }
1threat
int ff_get_cpu_flags_x86(void) { int rval = 0; #ifdef cpuid int eax, ebx, ecx, edx; int max_std_level, max_ext_level, std_caps = 0, ext_caps = 0; int family = 0, model = 0; union { int i[3]; char c[12]; } vendor; if (!cpuid_test()) return 0; cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]); if (max_std_level >= 1) { cpuid(1, eax, ebx, ecx, std_caps); family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); model = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0); if (std_caps & (1 << 15)) rval |= AV_CPU_FLAG_CMOV; if (std_caps & (1 << 23)) rval |= AV_CPU_FLAG_MMX; if (std_caps & (1 << 25)) rval |= AV_CPU_FLAG_MMXEXT; #if HAVE_SSE if (std_caps & (1 << 25)) rval |= AV_CPU_FLAG_SSE; if (std_caps & (1 << 26)) rval |= AV_CPU_FLAG_SSE2; if (ecx & 1) rval |= AV_CPU_FLAG_SSE3; if (ecx & 0x00000200 ) rval |= AV_CPU_FLAG_SSSE3; if (ecx & 0x00080000 ) rval |= AV_CPU_FLAG_SSE4; if (ecx & 0x00100000 ) rval |= AV_CPU_FLAG_SSE42; #if HAVE_AVX if ((ecx & 0x18000000) == 0x18000000) { xgetbv(0, eax, edx); if ((eax & 0x6) == 0x6) { rval |= AV_CPU_FLAG_AVX; if (ecx & 0x00001000) rval |= AV_CPU_FLAG_FMA3; } } #endif #endif } if (max_std_level >= 7) { cpuid(7, eax, ebx, ecx, edx); #if HAVE_AVX2 if (ebx & 0x00000020) rval |= AV_CPU_FLAG_AVX2; #endif if (ebx & 0x00000008) { rval |= AV_CPU_FLAG_BMI1; if (ebx & 0x00000100) rval |= AV_CPU_FLAG_BMI2; } } cpuid(0x80000000, max_ext_level, ebx, ecx, edx); if (max_ext_level >= 0x80000001) { cpuid(0x80000001, eax, ebx, ecx, ext_caps); if (ext_caps & (1U << 31)) rval |= AV_CPU_FLAG_3DNOW; if (ext_caps & (1 << 30)) rval |= AV_CPU_FLAG_3DNOWEXT; if (ext_caps & (1 << 23)) rval |= AV_CPU_FLAG_MMX; if (ext_caps & (1 << 22)) rval |= AV_CPU_FLAG_MMXEXT; if (!strncmp(vendor.c, "AuthenticAMD", 12) && rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x00000040)) { rval |= AV_CPU_FLAG_SSE2SLOW; } if (rval & AV_CPU_FLAG_AVX) { if (ecx & 0x00000800) rval |= AV_CPU_FLAG_XOP; if (ecx & 0x00010000) rval |= AV_CPU_FLAG_FMA4; } } if (!strncmp(vendor.c, "GenuineIntel", 12)) { if (family == 6 && (model == 9 || model == 13 || model == 14)) { if (rval & AV_CPU_FLAG_SSE2) rval ^= AV_CPU_FLAG_SSE2SLOW | AV_CPU_FLAG_SSE2; if (rval & AV_CPU_FLAG_SSE3) rval ^= AV_CPU_FLAG_SSE3SLOW | AV_CPU_FLAG_SSE3; } if (family == 6 && model == 28) rval |= AV_CPU_FLAG_ATOM; } #endif return rval; }
1threat
How to add tab-index for anchor tag through JavaScript dynamically? : <p>Currently i am Working on Web Accessibility. In that i need to access my project fully on keyboard controls.I have tried a lot to to complete the task and refer the W3c WAI-ARIA Concepts but cant able to done it.Some one guide me here pls if there is any tutorial is also fine for me.</p>
0debug
Automatic library version update for Gradle projects is currently unsupported. Please update your build.gradle manually : <p>I have this in my building.gradle</p> <pre><code>buildscript { ext.kotlin_version = '1.1.2-4' ext.kotlin_version = '1.1.2' repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } </code></pre> <p>and always show me this</p> <pre><code>Outdated Kotlin Runtime Your version of Kotlin runtime in 'kotlin-stdlib-1.1.2' library is 1.1.2, while plugin version is 1.1.2-release-Studio2.3-5. Runtime library should be updated to avoid compatibility problems. </code></pre> <p><a href="https://i.stack.imgur.com/Nf38X.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Nf38X.png" alt="enter image description here"></a></p>
0debug
static void pxa2xx_pcmcia_initfn(Object *obj) { SysBusDevice *sbd = SYS_BUS_DEVICE(obj); PXA2xxPCMCIAState *s = PXA2XX_PCMCIA(obj); memory_region_init(&s->container_mem, obj, "container", 0x10000000); sysbus_init_mmio(sbd, &s->container_mem); memory_region_init_io(&s->iomem, NULL, &pxa2xx_pcmcia_io_ops, s, "pxa2xx-pcmcia-io", 0x04000000); memory_region_add_subregion(&s->container_mem, 0x00000000, &s->iomem); memory_region_init_io(&s->attr_iomem, NULL, &pxa2xx_pcmcia_attr_ops, s, "pxa2xx-pcmcia-attribute", 0x04000000); memory_region_add_subregion(&s->container_mem, 0x08000000, &s->attr_iomem); memory_region_init_io(&s->common_iomem, NULL, &pxa2xx_pcmcia_common_ops, s, "pxa2xx-pcmcia-common", 0x04000000); memory_region_add_subregion(&s->container_mem, 0x0c000000, &s->common_iomem); s->slot.irq = qemu_allocate_irqs(pxa2xx_pcmcia_set_irq, s, 1)[0]; object_property_add_link(obj, "card", TYPE_PCMCIA_CARD, (Object **)&s->card, NULL, 0, NULL); }
1threat
void bdrv_drain(BlockDriverState *bs) { while (bdrv_drain_one(bs)) { } }
1threat
What is raw representation? : I'm reading learn python the hard way (by Zed Shaw) and it says that %r is used for "raw representation and debugging". I'm sorry for such a uninformed question but I have no idea what those mean. Thanks for any help!
0debug
static void vmsvga_init(struct vmsvga_state_s *s, MemoryRegion *address_space, MemoryRegion *io) { DisplaySurface *surface; s->scratch_size = SVGA_SCRATCH_SIZE; s->scratch = g_malloc(s->scratch_size * 4); s->vga.con = graphic_console_init(vmsvga_update_display, vmsvga_invalidate_display, vmsvga_screen_dump, vmsvga_text_update, s); surface = qemu_console_surface(s->vga.con); s->fifo_size = SVGA_FIFO_SIZE; memory_region_init_ram(&s->fifo_ram, "vmsvga.fifo", s->fifo_size); vmstate_register_ram_global(&s->fifo_ram); s->fifo_ptr = memory_region_get_ram_ptr(&s->fifo_ram); vga_common_init(&s->vga); vga_init(&s->vga, address_space, io, true); vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga); s->depth = surface_bits_per_pixel(surface); s->bypp = surface_bytes_per_pixel(surface); }
1threat
Android, setting background color of button loses ripple effect : <p>After adding color to an android button, it loses its ripple effect that makes the user feel like there is a responsive click. How do I fix this? I've searched through many solutions but I couldn't find a definite one that wasn't ambiguous. </p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ClockInOutFragment"&gt; &lt;AnalogClock android:id="@+id/clock" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/date_and_time"/&gt; &lt;RelativeLayout android:id="@+id/date_and_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp"&gt; &lt;TextView android:id="@+id/time_digits" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="12:10" android:textSize="45sp"/&gt; &lt;TextView android:id="@+id/am_pm" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/time_digits" android:layout_toRightOf="@+id/time_digits" android:paddingLeft="3dp" android:text="PM" android:textSize="20sp"/&gt; &lt;TextView android:id="@+id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/time_digits" android:text="Mon, July 11" android:textSize="22sp"/&gt; &lt;/RelativeLayout&gt; &lt;!--Clock in and out buttons--&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:orientation="horizontal"&gt; &lt;Button android:id="@+id/textView3" android:layout_width="0dp" android:layout_height="56dp" android:layout_weight="1" android:background="#4CAF50" android:gravity="center" android:text="Clock In" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#FFFFFF"/&gt; &lt;!--Divider between the clock in and out button--&gt; &lt;View android:layout_width="1dp" android:layout_height="match_parent" android:background="#B6B6B6"/&gt; &lt;Button android:id="@+id/textView4" android:layout_width="0dp" android:layout_height="56dp" android:layout_weight="1" android:background="#FF5252" android:gravity="center" android:text="Clock Out" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#FFFFFF"/&gt; &lt;/LinearLayout&gt; &lt;/RelativeLayout&gt; </code></pre>
0debug
Are files in UNIX always owned by an owner and a group? : <p>For example, when I use <code>ls -l | awk '{print $3, $4 }'</code> on my file/folder, I see my username appearing twice.</p> <p>Does that mean that all files are owned by <strong>one</strong> user and <strong>one</strong> group, which that one group is me? But how can the user also be a group? Why does my name appear twice?</p> <p>Is a file always owned by one group and a user, or is there really only 1 user all along?</p>
0debug
Best way to add/remove class to menu element using pure JavaScript : JQuery code is very simple: $('.nav-menu').on('click','li', function(){ $(this).addClass('selected').siblings().removeClass('selected'); it adds `selected` class to selected menu element and removes that class from all other elements. Best and shortest way to do this with pure JavaScript?
0debug
Algorithm for tree-like connections? : <p>The thing is I need to create an unidimensional array that represents a certain number of objects. Those objects are organized as shown in the picture. <a href="https://i.stack.imgur.com/sddQy.jpg" rel="nofollow noreferrer">Link</a></p> <p>And I have to be able to tell wich one is conected to. The number of objects is the only thing given.</p> <p>Is there any algorithm of some sort to do this?</p>
0debug
sql to retrieve username and password from 3 tables : i have to retrieve username and password from 3 tables (user1, user2, admin, having username and password in each table) with no foreign keys. ... SqlCommand cmd = new SqlCommand("select * from user1 UNION select * from user2 union select * from admin where username=@username and password=@password", con); ...
0debug
How to reload image in Glide from the same url? : <p>I am using Glide image loader to load an image from a specific URL, now if I update the image to the same URL, Glide is still showing the cached image in my imageview. How to reload the image from the same URL?</p>
0debug
int gtod_load(QEMUFile *f, void *opaque, int version_id) { uint64_t tod_low; uint8_t tod_high; int r; if (qemu_get_byte(f) == S390_TOD_CLOCK_VALUE_MISSING) { fprintf(stderr, "WARNING: Guest clock was not migrated. This could " "cause the guest to hang.\n"); return 0; } tod_high = qemu_get_byte(f); tod_low = qemu_get_be64(f); r = s390_set_clock(&tod_high, &tod_low); if (r) { fprintf(stderr, "WARNING: Unable to set guest clock value. " "s390_get_clock returned error %d. This could cause " "the guest to hang.\n", r); } return 0; }
1threat
static int write_refcount_block_entries(BlockDriverState *bs, int64_t refcount_block_offset, int first_index, int last_index) { BDRVQcowState *s = bs->opaque; size_t size; int ret; if (cache_refcount_updates) { first_index &= ~(REFCOUNTS_PER_SECTOR - 1); last_index = (last_index + REFCOUNTS_PER_SECTOR) & ~(REFCOUNTS_PER_SECTOR - 1); size = (last_index - first_index) << REFCOUNT_SHIFT; BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_UPDATE_PART); ret = bdrv_pwrite(bs->file, refcount_block_offset + (first_index << REFCOUNT_SHIFT), &s->refcount_block_cache[first_index], size); if (ret < 0) { return ret;
1threat
How to linq to split string (only if delimer exists) and create array : <pre><code>public class itemObject { public string items; } values - item = "name1,name2" or items = "item3" </code></pre> <p>Need linq to split by ',' if exists else one string array.</p>
0debug
How to test functions cdef'd in Cython? : <p>I have a .pyx file in which I define some functions, e.g.</p> <pre><code>cdef double foo(double a) nogil: return 3. * a </code></pre> <p>How could I unit test the behavior of such functions outside the pyx file? Since they are cdef'd, I am not able to simply import them...</p>
0debug
static void handle_keydown(SDL_Event *ev) { int mod_state, win; struct sdl2_console *scon = get_scon_from_window(ev->key.windowID); if (alt_grab) { mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) == (gui_grab_code | KMOD_LSHIFT); } else if (ctrl_grab) { mod_state = (SDL_GetModState() & KMOD_RCTRL) == KMOD_RCTRL; } else { mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code; gui_key_modifier_pressed = mod_state; if (gui_key_modifier_pressed) { switch (ev->key.keysym.scancode) { case SDL_SCANCODE_2: case SDL_SCANCODE_3: case SDL_SCANCODE_4: case SDL_SCANCODE_5: case SDL_SCANCODE_6: case SDL_SCANCODE_7: case SDL_SCANCODE_8: case SDL_SCANCODE_9: win = ev->key.keysym.scancode - SDL_SCANCODE_1; if (win < sdl2_num_outputs) { sdl2_console[win].hidden = !sdl2_console[win].hidden; if (sdl2_console[win].real_window) { if (sdl2_console[win].hidden) { SDL_HideWindow(sdl2_console[win].real_window); } else { SDL_ShowWindow(sdl2_console[win].real_window); gui_keysym = 1; break; case SDL_SCANCODE_F: toggle_full_screen(scon); gui_keysym = 1; break; case SDL_SCANCODE_U: sdl2_window_destroy(scon); sdl2_window_create(scon); if (!scon->opengl) { sdl2_2d_switch(&scon->dcl, scon->surface); gui_keysym = 1; break; #if 0 case SDL_SCANCODE_KP_PLUS: case SDL_SCANCODE_KP_MINUS: if (!gui_fullscreen) { int scr_w, scr_h; int width, height; SDL_GetWindowSize(scon->real_window, &scr_w, &scr_h); width = MAX(scr_w + (ev->key.keysym.scancode == SDL_SCANCODE_KP_PLUS ? 50 : -50), 160); height = (surface_height(scon->surface) * width) / surface_width(scon->surface); fprintf(stderr, "%s: scale to %dx%d\n", __func__, width, height); sdl_scale(scon, width, height); sdl2_redraw(scon); gui_keysym = 1; #endif default: break; if (!gui_keysym) { sdl2_process_key(scon, &ev->key);
1threat
R: source_gist not working : <p>I am trying to use <code>source_gist</code> from the <code>devtools</code> package but I am encountering an error:</p> <pre><code>&gt; library(devtools) &gt; source_gist("524eade46135f6348140") Error in r_files[[which]] : invalid subscript type 'closure' </code></pre> <p>Thanks for any advice.</p>
0debug