problem
stringlengths
26
131k
labels
class label
2 classes
How to geocode address by google maps iOS API? : <p>I found one way to send request:</p> <blockquote> <p>A Google Maps Geocoding API request takes the following form:</p> <p><a href="https://maps.googleapis.com/maps/api/geocode/outputFormat?parameters" rel="noreferrer">https://maps.googleapis.com/maps/api/geocode/outputFormat?parameters</a> where outputFormat may be either of the following values:</p> <p>json (recommended) indicates output in JavaScript Object Notation (JSON); or xml indicates output in XML To access the Google Maps Geocoding API over HTTP, use:</p> </blockquote> <p>But it's really inconvenient, is there any native way in swift?</p> <p>I looked into GMSGeocoder interface and only reverse geocoding can be done by it's API.</p>
0debug
static int ra288_decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; float *out; int i, ret; RA288Context *ractx = avctx->priv_data; GetBitContext gb; if (buf_size < avctx->block_align) { av_log(avctx, AV_LOG_ERROR, "Error! Input buffer is too small [%d<%d]\n", buf_size, avctx->block_align); return AVERROR_INVALIDDATA; } frame->nb_samples = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; out = (float *)frame->data[0]; init_get_bits8(&gb, buf, avctx->block_align); for (i=0; i < RA288_BLOCKS_PER_FRAME; i++) { float gain = amptable[get_bits(&gb, 3)]; int cb_coef = get_bits(&gb, 6 + (i&1)); decode(ractx, gain, cb_coef); memcpy(out, &ractx->sp_hist[70 + 36], RA288_BLOCK_SIZE * sizeof(*out)); out += RA288_BLOCK_SIZE; if ((i & 7) == 3) { backward_filter(ractx, ractx->sp_hist, ractx->sp_rec, syn_window, ractx->sp_lpc, syn_bw_tab, 36, 40, 35, 70); backward_filter(ractx, ractx->gain_hist, ractx->gain_rec, gain_window, ractx->gain_lpc, gain_bw_tab, 10, 8, 20, 28); } } *got_frame_ptr = 1; return avctx->block_align; }
1threat
Validate multiple textbox in javascript? : i want to validate name, email,zip code on button click, but it's showing only last error msg, not specific to the filed, i m wirtting this code in javascript & jquery. anyone please help us . thanks
0debug
How do i alter my Current code to read directly from the IDR register : <p>Modify the code for <strong>ReadJoystick()</strong> to read the <strong>IDR register</strong> directly for the ports associated with the joystick inputs. The aim is to minimise the number of reads to the register. The code in the template makes an individual call for each of the inputs pins, even though some of the pins are on the same ports. You can refer to the HAL code for inspiration. Use the defined values in the HAL for addressing registers rather than creating new ones.</p> <p>Example Code Given to Me</p> <pre><code>GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) { GPIO_PinState bitstatus; /* Check the parameters */ assert_param(IS_GPIO_PIN(GPIO_Pin)); if ((GPIOx-&gt;IDR &amp; GPIO_Pin) != (uint32_t)GPIO_PIN_RESET) { bitstatus = GPIO_PIN_SET; } else { bitstatus = GPIO_PIN_RESET; } return bitstatus; </code></pre> <p>}</p> <hr> <p><strong>Code I require to Alter</strong></p> <p>// REPLACE THE FOLLOW CODE WITH YOUR SOLUTION </p> <pre><code>uint8_t ReadJoystick () { uint8_t JoystickPosition = 0; // Get current joystick value if (HAL_GPIO_ReadPin (JOY_A_GPIO_Port, JOY_A_Pin) == GPIO_PIN_RESET) { JoystickPosition = 'L'; } else if (HAL_GPIO_ReadPin (JOY_B_GPIO_Port, JOY_B_Pin) == GPIO_PIN_RESET) { JoystickPosition = 'U'; } else if (HAL_GPIO_ReadPin (JOY_C_GPIO_Port, JOY_C_Pin) == GPIO_PIN_RESET) { JoystickPosition = 'D'; } else if (HAL_GPIO_ReadPin (JOY_D_GPIO_Port, JOY_D_Pin) == GPIO_PIN_RESET) { JoystickPosition = 'R'; } else if (HAL_GPIO_ReadPin (JOY_CTR_GPIO_Port, JOY_CTR_Pin) == GPIO_PIN_RESET) { JoystickPosition = 'C'; } return JoystickPosition; } </code></pre> <p>So I Understand that my current code is reading each pin although i've been asked to alter this to read directly from the IDR register. I'm really new to embedded systems programming and just looking for someone to guide me with altering this code</p>
0debug
Tabs for ios web browsing application (Swift 4) : How would I go about making a web browser application (in Swift) with tabs for multiple websites? I can not find any references or examples online to demonstrate this. I would greatly appreciate any help with this (:
0debug
SSL Certificates leading zeros are displayed in Windows but not Unix | ksh shell : <p>I'm trying to get the SSL serial number from a certificate but windows is displaying leading zeros but unix is not, I'm using openssl x509 in unix to extract the serial number, do you know why or how could solve this issue?</p> <p>Unix Example: </p> <pre><code>openssl x509 -noout -in ssl.extracted.crt -serial </code></pre> <p>Unix Output Example:</p> <pre><code>D01E408B </code></pre> <p>Open the certififcate in windows and looks like this the serial number:</p> <pre><code>00D01E408B </code></pre>
0debug
Flexbox Header Footer Sidebar : <p>How can we make something like this using flexbox? <a href="https://i.stack.imgur.com/svF1J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/svF1J.png" alt="enter image description here"></a></p>
0debug
How do i add features like upload, preview and download in android cloud app : currently i am working on a cloud app with aws and i have successfully configured sign in and sign up process all i want to know is how to cach that data from cloud and preview it without downloading. please add scripts for that. Thanks
0debug
Do I need to scale my target variable in regression analysis? : I have a data which has some features (some kind of products, country in which it is sold etc.) and a Target Variable (the product's price in the country's local currency). So, do I have to scale my Target variable with respect to one common currency for regression analysis?
0debug
static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr, uint64_t asc, uint64_t asce, int level, target_ulong *raddr, int *flags, int rw) { CPUState *cs = CPU(s390_env_get_cpu(env)); uint64_t offs = 0; uint64_t origin; uint64_t new_asce; PTE_DPRINTF("%s: 0x%" PRIx64 "\n", __func__, asce); if (((level != _ASCE_TYPE_SEGMENT) && (asce & _REGION_ENTRY_INV)) || ((level == _ASCE_TYPE_SEGMENT) && (asce & _SEGMENT_ENTRY_INV))) { DPRINTF("%s: invalid region\n", __func__); trigger_page_fault(env, vaddr, PGM_SEGMENT_TRANS, asc, rw); return -1; } if ((level <= _ASCE_TYPE_MASK) && ((asce & _ASCE_TYPE_MASK) != level)) { trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw); return -1; } if (asce & _ASCE_REAL_SPACE) { *raddr = vaddr; return 0; } origin = asce & _ASCE_ORIGIN; switch (level) { case _ASCE_TYPE_REGION1 + 4: offs = (vaddr >> 50) & 0x3ff8; break; case _ASCE_TYPE_REGION1: offs = (vaddr >> 39) & 0x3ff8; break; case _ASCE_TYPE_REGION2: offs = (vaddr >> 28) & 0x3ff8; break; case _ASCE_TYPE_REGION3: offs = (vaddr >> 17) & 0x3ff8; break; case _ASCE_TYPE_SEGMENT: offs = (vaddr >> 9) & 0x07f8; origin = asce & _SEGMENT_ENTRY_ORIGIN; break; } new_asce = ldq_phys(cs->as, origin + offs); PTE_DPRINTF("%s: 0x%" PRIx64 " + 0x%" PRIx64 " => 0x%016" PRIx64 "\n", __func__, origin, offs, new_asce); if (level == _ASCE_TYPE_SEGMENT) { return mmu_translate_pte(env, vaddr, asc, new_asce, raddr, flags, rw); } else if (level - 4 == _ASCE_TYPE_SEGMENT && (new_asce & _SEGMENT_ENTRY_FC) && (env->cregs[0] & CR0_EDAT)) { return mmu_translate_sfaa(env, vaddr, asc, new_asce, raddr, flags, rw); } else { return mmu_translate_asce(env, vaddr, asc, new_asce, level - 4, raddr, flags, rw); } }
1threat
having a pointer to pointer in main and create an array in other function : I have this : #include <stdio.h> #include <stdlib.h> void mad(int ***,int ,int ); int main(void){ int **x; int n,m; scanf("%d%d",&n,&m); mad(x,n,m); x[0][0] = 5; printf:("%d\n",x[0][0]); return 0; } void mad(int ***x,int n, int m){ int i; **x = malloc(sizeof(int *)); for(i=0;i<n;i++) ***(x + i) = malloc(m * sizeof(int)); } This is wrong can someone explain why this is wrong and give me the right code
0debug
how do I query array element in impala : I created a table in impala ,the have two columns , +-----------+---------------------+---------+ | name | type | comment | +-----------+---------------------+---------+ | unique_id | string | | | cmap | array<struct< | | | | fieldname:string, | | | | fieldid:string, | | | | fielddata:string | | | | >> | | +-----------+---------------------+---------+ i need set condictions for cmap to query unique_id,such as (fieldname="ip"and fielddata="192.168.1.145" ) and(fieldname="wid" and fielddata="15") i wrote a this sql but can't query nothing data,but i've insert data in the table ,pls help me to find is something wrong? appricate your help. sql: select unique_id from s_click_parquet,s_click_parquet.cmap as lst where ( fieldname="ip" and fieldData="192.168.1.145") and(fieldname="wid" and fielddata="15");
0debug
int net_init_tap(const NetClientOptions *opts, const char *name, NetClientState *peer, Error **errp) { const NetdevTapOptions *tap; assert(opts->kind == NET_CLIENT_OPTIONS_KIND_TAP); tap = opts->tap; if (!tap->has_ifname) { error_report("tap: no interface name"); return -1; } if (tap_win32_init(peer, "tap", name, tap->ifname) == -1) { return -1; } return 0; }
1threat
int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info) { assert(con != NULL); con->ui_info = *info; if (!con->hw_ops->ui_info) { return -1; } timer_mod(con->ui_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 1000); return 0; }
1threat
static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s) { int i, j; if (!avctx->channel_layout) { av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The " "encoder will guess the layout, but it " "might be incorrect.\n"); } if (set_channel_info(s, avctx->channels, &avctx->channel_layout)) { av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n"); return -1; } for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) if ((ff_ac3_sample_rate_tab[j] >> i) == avctx->sample_rate) goto found; } return -1; found: s->sample_rate = avctx->sample_rate; s->bit_alloc.sr_shift = i; s->bit_alloc.sr_code = j; s->bitstream_id = 8 + s->bit_alloc.sr_shift; s->bitstream_mode = 0; for (i = 0; i < 19; i++) { if ((ff_ac3_bitrate_tab[i] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate) break; } if (i == 19) return -1; s->bit_rate = avctx->bit_rate; s->frame_size_code = i << 1; return 0; }
1threat
target_ulong helper_udiv(target_ulong a, target_ulong b) { uint64_t x0; uint32_t x1; x0 = (a & 0xffffffff) | ((int64_t) (env->y) << 32); x1 = (b & 0xffffffff); if (x1 == 0) { raise_exception(TT_DIV_ZERO); } x0 = x0 / x1; if (x0 > 0xffffffff) { env->cc_src2 = 1; return 0xffffffff; } else { env->cc_src2 = 0; return x0; } }
1threat
static void host_signal_handler(int host_signum, siginfo_t *info, void *puc) { int sig; target_siginfo_t tinfo; if (host_signum == SIGSEGV || host_signum == SIGBUS) { if (cpu_signal_handler(host_signum, info, puc)) return; } sig = host_to_target_signal(host_signum); if (sig < 1 || sig > TARGET_NSIG) return; #if defined(DEBUG_SIGNAL) fprintf(stderr, "qemu: got signal %d\n", sig); dump_regs(puc); #endif host_to_target_siginfo_noswap(&tinfo, info); if (queue_signal(sig, &tinfo) == 1) { cpu_interrupt(global_env, CPU_INTERRUPT_EXIT); } }
1threat
int pci_piix3_xen_ide_unplug(DeviceState *dev) { PCIIDEState *pci_ide; DriveInfo *di; int i = 0; pci_ide = PCI_IDE(dev); for (; i < 3; i++) { di = drive_get_by_index(IF_IDE, i); if (di != NULL && !di->media_cd) { BlockBackend *blk = blk_by_legacy_dinfo(di); DeviceState *ds = blk_get_attached_dev(blk); if (ds) { blk_detach_dev(blk, ds); } pci_ide->bus[di->bus].ifs[di->unit].blk = NULL; blk_unref(blk); } } qdev_reset_all(DEVICE(dev)); return 0; }
1threat
Prevent "use strict" in typescript? : <p>When trying to load my app on an iOS device I get the following error;</p> <p><code>VMundefined bundle.js:1722 SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.</code></p> <p>This error occurred on iPhone 5s/6s + a couple of different iPad's I tried (can't remember which). It also did not work on the HTC one. This error did not occur on any samsung/windows phones I tried. It also worked on desktops. (I have not tried to run it on a mac yet). </p> <p>Here is that line of code from the bundle.js;</p> <pre><code>{}],12:[function(require,module,exports){ "use strict"; const guage_1 = require("./charts/kpi/guage"); const stacked_1 = require("./charts/area/stacked"); const barChart_1 = require("./charts/compare/barChart"); </code></pre> <p>When I remove the "use strict" from the bundle.js it works fine on all devices. Just wondering if there is a way to make sure typescript does not compile with "use strict" or a fix for the problem with iOS devices?</p> <p>Here is my gulpfile for compiling (followed the guide published on typescripts <a href="https://www.typescriptlang.org/docs/handbook/gulp.html" rel="noreferrer">website</a>)</p> <pre><code>var gulp = require('gulp'), sourcemaps = require('gulp-sourcemaps'), source = require('vinyl-source-stream'), tsify = require('tsify'), browserSync = require('browser-sync'), postcss = require('gulp-postcss'), uglify = require('gulp-uglify'), concat = require('gulp-concat'), rename = require('gulp-rename'), watchify = require("watchify"), browserify = require('browserify'), gutil = require("gulp-util"), buffer = require('vinyl-buffer'), processorArray = [ ... ], watchedBrowserify = watchify(browserify({ basedir: '.', debug: true, entries: ['src/main.ts'], cache: {}, packageCache: {} }).plugin(tsify)), devPlugin = './src/plugins/'; function bundle() { return watchedBrowserify .bundle() .pipe(source('bundle.js')) .pipe(gulp.dest("dist")); } gulp.task('default', ['styles', 'browser-sync', 'watch'], bundle, function() { return browserify({ basedir: '.', debug: true, entries: ['src/main.ts'], cache: {}, packageCache: {} }) .plugin(tsify) .transform("babelify") .bundle() .pipe(source('bundle.js')) .pipe(buffer()) .pipe(sourcemaps.init({ loadMaps: true })) .pipe(sourcemaps.write('./')) .pipe(gulp.dest('dist')) }); watchedBrowserify.on("update", bundle); watchedBrowserify.on("log", gutil.log); </code></pre>
0debug
How can I manually read/write a PNG image file in C#? : There are already lots of classes and functions supplied with the .NET to manipulate Images including PNG. Like [Image, Bitmap, etc. classes][1]. But, if I want to manually read/write a PNG image as a binary file, what should I do? Where should I start? [1]: http://stackoverflow.com/questions/100247/reading-a-png-image-file-in-net-2-0
0debug
int net_slirp_parse_legacy(QemuOptsList *opts_list, const char *optarg, int *ret) { if (strcmp(opts_list->name, "net") != 0 || strncmp(optarg, "channel,", strlen("channel,")) != 0) { return 0; } error_report("The '-net channel' option is deprecated. " "Please use '-netdev user,guestfwd=...' instead."); optarg += strlen("channel,"); if (QTAILQ_EMPTY(&slirp_stacks)) { struct slirp_config_str *config; config = g_malloc(sizeof(*config)); pstrcpy(config->str, sizeof(config->str), optarg); config->flags = SLIRP_CFG_LEGACY; config->next = slirp_configs; slirp_configs = config; *ret = 0; } else { *ret = slirp_guestfwd(QTAILQ_FIRST(&slirp_stacks), optarg, 1); } return 1; }
1threat
static int xen_host_pci_get_resource(XenHostPCIDevice *d) { int i, rc, fd; char path[PATH_MAX]; char buf[XEN_HOST_PCI_RESOURCE_BUFFER_SIZE]; unsigned long long start, end, flags, size; char *endptr, *s; uint8_t type; rc = xen_host_pci_sysfs_path(d, "resource", path, sizeof (path)); if (rc) { return rc; } fd = open(path, O_RDONLY); if (fd == -1) { XEN_HOST_PCI_LOG("Error: Can't open %s: %s\n", path, strerror(errno)); return -errno; } do { rc = read(fd, &buf, sizeof (buf) - 1); if (rc < 0 && errno != EINTR) { rc = -errno; goto out; } } while (rc < 0); buf[rc] = 0; rc = 0; s = buf; for (i = 0; i < PCI_NUM_REGIONS; i++) { type = 0; start = strtoll(s, &endptr, 16); if (*endptr != ' ' || s == endptr) { break; } s = endptr + 1; end = strtoll(s, &endptr, 16); if (*endptr != ' ' || s == endptr) { break; } s = endptr + 1; flags = strtoll(s, &endptr, 16); if (*endptr != '\n' || s == endptr) { break; } s = endptr + 1; if (start) { size = end - start + 1; } else { size = 0; } if (flags & IORESOURCE_IO) { type |= XEN_HOST_PCI_REGION_TYPE_IO; } if (flags & IORESOURCE_MEM) { type |= XEN_HOST_PCI_REGION_TYPE_MEM; } if (flags & IORESOURCE_PREFETCH) { type |= XEN_HOST_PCI_REGION_TYPE_PREFETCH; } if (flags & IORESOURCE_MEM_64) { type |= XEN_HOST_PCI_REGION_TYPE_MEM_64; } if (i < PCI_ROM_SLOT) { d->io_regions[i].base_addr = start; d->io_regions[i].size = size; d->io_regions[i].type = type; d->io_regions[i].bus_flags = flags & IORESOURCE_BITS; } else { d->rom.base_addr = start; d->rom.size = size; d->rom.type = type; d->rom.bus_flags = flags & IORESOURCE_BITS; } } if (i != PCI_NUM_REGIONS) { rc = -ENODEV; } out: close(fd); return rc; }
1threat
How to mount a postgresql volume using Aws EBS in Kubernete : <ol> <li>I've created the persistent volume (EBS 10G) and corresponding persistent volume claim first. But when I try to deploy the postgresql pods as below (yaml file) :</li> </ol> <p><a href="https://i.stack.imgur.com/1bM88.png" rel="noreferrer">test-postgresql.yaml</a></p> <p>Receive the errors from pod:</p> <p><strong>initdb: directory "/var/lib/postgresql/data" exists but is not empty It contains a lost+found directory, perhaps due to it being a mount point. Using a mount point directly as the data directory is not recommended. Create a subdirectory under the mount point.</strong></p> <p>Why the pod can't use this path? I've tried the same tests on minikube. I didn't meet any problem. </p> <ol start="2"> <li>I tried to change volume mount directory path to "/var/lib/test/data", the pods can be running. I created a new table and some data on it, and then killed this pod. Kubernete created a new pod. But the new one didn't preserve the previous data and table. </li> </ol> <p>So what's the way to correctly mount a postgresql volume using Aws EBS in Kubernete, which allows the recreated pods can reuse initial data base stored in EBS?</p>
0debug
static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) { AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); AVFilterContext *ctx = inlink->dst; OverlayContext *over = ctx->priv; av_unused AVFilterLink *outlink = ctx->outputs[0]; inlink->dst->outputs[0]->out_buf = outpicref; outpicref->pts = av_rescale_q(outpicref->pts, ctx->inputs[MAIN]->time_base, ctx->outputs[0]->time_base); if (!over->overpicref || over->overpicref->pts < outpicref->pts) { if (!over->overpicref_next) avfilter_request_frame(ctx->inputs[OVERLAY]); if (over->overpicref && over->overpicref_next && over->overpicref_next->pts <= outpicref->pts) { avfilter_unref_buffer(over->overpicref); over->overpicref = over->overpicref_next; over->overpicref_next = NULL; } } av_dlog(ctx, "main_pts:%s main_pts_time:%s", av_ts2str(outpicref->pts), av_ts2timestr(outpicref->pts, &outlink->time_base)); if (over->overpicref) av_dlog(ctx, " over_pts:%s over_pts_time:%s", av_ts2str(over->overpicref->pts), av_ts2timestr(over->overpicref->pts, &outlink->time_base)); av_dlog(ctx, "\n"); avfilter_start_frame(inlink->dst->outputs[0], outpicref); }
1threat
Angular2, HostListener, how can I target an element? can I target based on class? : <p>In Angular2, how can I target an element within the HostListener decorator?</p> <pre><code>@HostListener('dragstart', ['$event']) onDragStart(ev:Event) { console.log(ev); } @HostListener('document: dragstart', ['$event']) onDragStart(ev:Event) { console.log(ev); } @HostListener('myElement: dragstart', ['$event']) onDragStart(ev:Event) { console.log(ev); } @HostListener('myElement.myClass: dragstart', ['$event']) onDragStart(ev:Event) { console.log(ev); } </code></pre> <p>The two first work. Any other thing I've tried raises an <code>EXCEPTION: Unsupported event target undefined for event dragstart</code></p> <p>So, can I implement it to a targeted element? How?</p>
0debug
HTML and JS, having input but want different output : I want to put a word in an input and have a changed output. For example, Input= Peter; Output= From Peter Parker My JS CODE: function impf1(){ var first = document.getElementById("imp1").value; var out1 = "print(" + first +")"; return out1; console.log(out1); window.alert(out1); return false; } My HTML <center><input type="text" id="imp1" width="35px" length="40px" /></center> <h5></h5> <div class="hr"><hr /></div> <h3></h3> <center><select> <option value="python">Python</option> </select></center> <center> <button onclick="impf1()">GET CODE</button></center> [This is the Output I need Please help me!][1] [1]: https://i.stack.imgur.com/jykX9.png
0debug
Is there something like a backtrace to indicate which path a variable has reached to its current value? : <p>I have a source like this</p> <pre><code> //file1.cpp int var_1=getDB(" Table_name","column_name"); ... //file2.cpp int var2=func2(var_1); ... //filen.cpp int var_n=funcn(var_n_1); </code></pre> <p>In debugging, I first diagnose var_n error message type, but the goal is to modify the table, is there an easy way like backtrace to get to the source of the error, namely the table and field name?</p>
0debug
TPMVersion tpm_tis_get_tpm_version(Object *obj) { TPMState *s = TPM(obj); return tpm_backend_get_tpm_version(s->be_driver);
1threat
TC6393xbState *tc6393xb_init(MemoryRegion *sysmem, uint32_t base, qemu_irq irq) { TC6393xbState *s; DriveInfo *nand; static const MemoryRegionOps tc6393xb_ops = { .read = tc6393xb_readb, .write = tc6393xb_writeb, .endianness = DEVICE_NATIVE_ENDIAN, .impl = { .min_access_size = 1, .max_access_size = 1, }, }; s = (TC6393xbState *) g_malloc0(sizeof(TC6393xbState)); s->irq = irq; s->gpio_in = qemu_allocate_irqs(tc6393xb_gpio_set, s, TC6393XB_GPIOS); s->l3v = qemu_allocate_irq(tc6393xb_l3v, s, 0); s->blanked = 1; s->sub_irqs = qemu_allocate_irqs(tc6393xb_sub_irq, s, TC6393XB_NR_IRQS); nand = drive_get(IF_MTD, 0, 0); s->flash = nand_init(nand ? blk_by_legacy_dinfo(nand) : NULL, NAND_MFR_TOSHIBA, 0x76); memory_region_init_io(&s->iomem, NULL, &tc6393xb_ops, s, "tc6393xb", 0x10000); memory_region_add_subregion(sysmem, base, &s->iomem); memory_region_init_ram(&s->vram, NULL, "tc6393xb.vram", 0x100000, &error_abort); vmstate_register_ram_global(&s->vram); s->vram_ptr = memory_region_get_ram_ptr(&s->vram); memory_region_add_subregion(sysmem, base + 0x100000, &s->vram); s->scr_width = 480; s->scr_height = 640; s->con = graphic_console_init(NULL, 0, &tc6393xb_gfx_ops, s); return s; }
1threat
static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) { bool page_aligned = false; unsigned int n, begin; const uint16_t block_size = s->blksize & 0x0fff; uint32_t boundary_chk = 1 << (((s->blksize & 0xf000) >> 12) + 12); uint32_t boundary_count = boundary_chk - (s->sdmasysad % boundary_chk); if ((s->sdmasysad % boundary_chk) == 0) { page_aligned = true; } if (s->trnmod & SDHC_TRNS_READ) { s->prnsts |= SDHC_DOING_READ | SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE; while (s->blkcnt) { if (s->data_count == 0) { for (n = 0; n < block_size; n++) { s->fifo_buffer[n] = sdbus_read_data(&s->sdbus); } } begin = s->data_count; if (((boundary_count + begin) < block_size) && page_aligned) { s->data_count = boundary_count + begin; boundary_count = 0; } else { s->data_count = block_size; boundary_count -= block_size - begin; if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) { s->blkcnt--; } } dma_memory_write(&address_space_memory, s->sdmasysad, &s->fifo_buffer[begin], s->data_count - begin); s->sdmasysad += s->data_count - begin; if (s->data_count == block_size) { s->data_count = 0; } if (page_aligned && boundary_count == 0) { break; } } } else { s->prnsts |= SDHC_DOING_WRITE | SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE; while (s->blkcnt) { begin = s->data_count; if (((boundary_count + begin) < block_size) && page_aligned) { s->data_count = boundary_count + begin; boundary_count = 0; } else { s->data_count = block_size; boundary_count -= block_size - begin; } dma_memory_read(&address_space_memory, s->sdmasysad, &s->fifo_buffer[begin], s->data_count); s->sdmasysad += s->data_count - begin; if (s->data_count == block_size) { for (n = 0; n < block_size; n++) { sdbus_write_data(&s->sdbus, s->fifo_buffer[n]); } s->data_count = 0; if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) { s->blkcnt--; } } if (page_aligned && boundary_count == 0) { break; } } } if (s->blkcnt == 0) { sdhci_end_transfer(s); } else { if (s->norintstsen & SDHC_NISEN_DMA) { s->norintsts |= SDHC_NIS_DMA; } sdhci_update_irq(s); } }
1threat
what's an easy way to cast one object to another (same props) : <p>What's an easy way to cast one object to another when they have the same properties? For example: </p> <pre><code>public class Test1 { public string FirstName{ get; set; } public string LastName{ get; set; } } public class Test2 { public string FirstName{ get; set; } public string LastName{ get; set; } } </code></pre> <p>So if I have a populated Test1 object and I want all of its values to be populated into Test2, then what's the easiest way to do that? I know I can set values 1-by-1 from Test1 to Test2 but I was wondering if you could recommend a quicker, easier way? Like test1.Map(test2) or something like that?</p>
0debug
calculate percentage with java : I have a form where I want the user to input a few fields and the form will calculate the total and percentage of goal. I'm new to java, and I don't know how to calculate a percentage. When I try parseint(total)/parseint(goal)*100 I get a NaN error. <html> <head> <style media="screen"> .testform INPUT{display: block;margin-bottom:10px;border:1px solid #212121;height:35px;font-size: 16px;} </style> <script type="text/javascript"> calculate = function() { var cash = document.getElementById('a1').value; var checks = document.getElementById('a2').value; var coin = document.getElementById('a3').value; var goal = document.getElementById('goalamount').value; var total = document.getElementById('a4').value; document.getElementById('a4').value = parseInt(cash)+parseInt(checks)+parseInt(coin); document.getElementById('a5').value = parseInt(total)+parseInt(goal); } </script> </head> <body> <form class="testform"> Goal amount <input id="goalamount" type="text" value="3000"/> Cash Collected <input id="a1" type="text" /> Checks Collected <input id="a2" type="text" /> Coins Collected <input id="a3" type="text" /> Total Collected <input id="a4" type="text" name="total_amt" onblur="calculate()" /> Percent of Goal<input id="a5" type="text" name="goal_amt" /> </form> </body> </html>
0debug
Can I use annotations in java to perform some actions e.g. Upper casing of values coming from a form. : <p>I am starting with a utility projects which will give out of the box annotations to perform some tasks such as uppercasing, lowercasing, validating, performing some more trasnformation. As far I have seen that annotations are actually have no impact on code. So I want to know if there is a way that where I put the annotation on let say </p> <pre><code>@Casing(type="MyEnum.UpperCase") private String name; </code></pre> <p>and while saving or retrieving the value it gives UpperCase String of the input.</p>
0debug
Why putting a macros argument in parentheses leads to an error? : <p>I have one very interesting question about preprocessor directives in c++.</p> <p>Consider the following macros and his usage:</p> <pre><code> #define FUNCTION(a, b) void (a)(int &amp;current, int candidate)\ {\ if ((current b candidate) == false){\ // Marked Line current = candidate;\ }\ } FUNCTION(minimum, &lt;) FUNCTION(maximum, &gt;) </code></pre> <p>My question is why changing the "Marked Line" with the following line of code won't even compile:</p> <pre><code> ... if ((current (b) candidate) == false) ... </code></pre>
0debug
Where to get msbuild for Linux : <p>I want to build a .net core project on Windows and Linux.</p> <p>For Windows I use MSBuild, simply downloaded the <code>Build Tools für Visual Studio 2017</code> from <a href="https://www.visualstudio.com/en/downloads/" rel="noreferrer">visualstudio.com</a>.</p> <p>But where do I get MSBuild for Linux from? Based on the GitHub Project site, it should be available on some Linux distributions (<a href="https://github.com/Microsoft/msbuild/blob/master/README.md" rel="noreferrer">README.md</a>). I do not want to compile it myself (for some reasons).</p> <p>I <strong>do not</strong> want to use xbuild, but pure MSBuild.</p>
0debug
Taking a 2 or more digit number as char in c : i have to write a program which i take a number as a character then find its binary so i used this code [screenshotofmycode][1] but it only works for numbers from 0 to 9.. it should work on 2 or more digit numbers. I have to take the number as char because the user might enter the number in base 16 and i have to ask the number first then the basetype.... we are not allowed to use arrays.. Thanks in advanced.. [1]: https://i.stack.imgur.com/vByYL.jpg
0debug
def count_Set_Bits(n) : n += 1; powerOf2 = 2; cnt = n // 2; while (powerOf2 <= n) : totalPairs = n // powerOf2; cnt += (totalPairs // 2) * powerOf2; if (totalPairs & 1) : cnt += (n % powerOf2) else : cnt += 0 powerOf2 <<= 1; return cnt;
0debug
Rendering a pandas dataframe as HTML with same styling as Jupyter Notebook : <p>I would like to render a pandas dataframe to HTML in the same way as the Jupyter Notebook does it, i.e. with all the bells and wistles like nice looking styling, column highlighting, and column sorting on click.</p> <p><a href="https://i.stack.imgur.com/arn6R.png" rel="noreferrer"><img src="https://i.stack.imgur.com/arn6R.png" alt="enter image description here"></a></p> <p><a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_html.html" rel="noreferrer">pandas.to_html</a> outputs just a plain HTML table and requires manual styling etc. </p> <p>Is the dataframe rendering code used by jupyter available as a standalone module that can be used in any web app? </p> <p>Also, are the assets such as js/css files decoupled from jupyter so that they can be easily reused?</p>
0debug
How to write sub quries in mysql : Here i joining three tables and taking count [MY SQL FIDDLE][1].In this query i want to take one more count like total_trip that means i already join trip_details tables, **in this table take all count that is total trip count**, i am not able to write sub query, if any one know kindly update my sql fiddle SELECT COUNT(T.tripId) as Escort_Count, ( SELECT COUNT(*) FROM ( SELECT a.allocationId FROM escort_allocation a INNER JOIN cab_allocation c ON a.allocationId = c.allocationId WHERE c.allocationType = 'Adhoc Trip' GROUP BY a.allocationId ) AS Ad ) AS Adhoc_Trip_Count FROM ( SELECT a.tripId FROM trip_details a INNER JOIN escort_allocation b ON a.allocationId = b.allocationId GROUP BY a.allocationId ) AS T [1]: http://sqlfiddle.com/#!9/e34392/25
0debug
Timeout in async/await : <p>I'm with Node.js and TypeScript and I'm using <code>async/await</code>. This is my test case:</p> <pre><code>async function doSomethingInSeries() { const res1 = await callApi(); const res2 = await persistInDB(res1); const res3 = await doHeavyComputation(res1); return 'simle'; } </code></pre> <p>I'd like to set a timeout for the overall function. I.e. if <code>res1</code> takes 2 seconds, <code>res2</code> takes 0.5 seconds, <code>res3</code> takes 5 seconds I'd like to have a timeout that after 3 seconds let me throw an error.</p> <p>With a normal <code>setTimeout</code> call is a problem because the scope is lost:</p> <pre><code>async function doSomethingInSeries() { const timerId = setTimeout(function() { throw new Error('timeout'); }); const res1 = await callApi(); const res2 = await persistInDB(res1); const res3 = await doHeavyComputation(res1); clearTimeout(timerId); return 'simle'; } </code></pre> <p>And I cannot catch it with normal <code>Promise.catch</code>:</p> <pre><code>doSomethingInSeries().catch(function(err) { // errors in res1, res2, res3 will be catched here // but the setTimeout thing is not!! }); </code></pre> <p>Any ideas on how to resolve?</p>
0debug
How i can count "\n\n" in a string with python? : this ist my string: (info: i parse it with python from an array to string with str(myString) ) myString = "[('das ist ein Test', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam\norem ipsum dolor sit amet\n\norem ipsum dolor sit amet\n\norem ipsum dolor sit amet\n\norem ipsum dolor sit amet')]" when i try: print(myString.count("\n\n")) i get the answer: 0 but i should be 3
0debug
Adding OnCLick listener to the view in android : I am developing an android application in which I want to achieve this: [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/i3kfU.png The android layout xml code is given below: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/track_image" android:layout_width="150dp" android:layout_height="150dp" android:layout_marginTop="40dp" android:layout_marginStart="30dp"/> <TextView android:id="@+id/track_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" android:textSize="20dp" android:textAppearance="@style/TextAppearance.AppCompat.Body2" android:layout_marginTop="42dp" android:layout_alignTop="@+id/track_image" android:layout_toEndOf="@+id/track_image" /> <android.support.v7.widget.Toolbar android:background="#333333" android:theme="@style/Base.ThemeOverlay.AppCompat.Dark.ActionBar" android:layout_width="match_parent" android:layout_height="110dp" android:layout_alignParentBottom="true"> <ImageView android:id="@+id/selected_track_image" android:layout_width="50dp" android:layout_height="50dp" android:background="@drawable/play"/> <TextView android:id="@+id/selected_track_title" android:paddingLeft="8dp" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <ImageView android:id="@+id/player_control" android:layout_gravity="right" android:layout_width="60dp" android:layout_height="60dp"/> </android.support.v7.widget.Toolbar> </RelativeLayout> I want that whenever user click on any of the area with in the whole view shown with image and text the audio gets play. But in my xml code I can only add image onClick listener. Every kind of help is appreciated. Thanks in advance.
0debug
when I ssh into RHEL7 AWS instance I get 'Permission denied (publickey,gssapi-keex,gssapi-with-mic)' : Ok so I know this question has been asked before. I tried everything that was posted in the closest related question and none of that worked. I was able to log in before but am not able to now. - I have tried ssh-ing in with both root@ipadress and ec2-user@ipaddress neither have worked. When I use root it tells me to use ec2-user. I am ssh-ing from ubuntu 16.04 - I have the correct permissions on my pem file. - Also I do not have a /etc/sshd_special_user file and not sure that adding one will do anything but it does seem to try to authenticate against my local user after failing the first time. - When I ssh-keygen -f " ~/.ssh/known_hosts" -R xx.xx.xxx.xxx I get 'mkstemp: No such file or directory'. I am getting this even thought the file is there and I am able to open it in vim. I am really confused as to what is going on here and am going to include the extra verbose log file with this question. I read through it and am not sure why it is doing what it is doing. output from ssh -vvv is -OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016 -debug1: Reading configuration data /etc/ssh/ssh_config -debug1: /etc/ssh/ssh_config line 19: Applying options for * -debug2: resolving "52.53.159.22" port 22 -debug2: ssh_connect_direct: needpriv 0 -debug1: Connecting to 52.53.159.22 [52.53.159.22] port 22. -debug1: Connection established. -debug1: key_load_public: No such file or directory -debug1: identity file .ssh/RH17-06-11.pem type -1 -debug1: key_load_public: No such file or directory -debug1: identity file .ssh/RH17-06-11.pem-cert type -1 -debug1: Enabling compatibility mode for protocol 2.0 -debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 -debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1 -debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000 -debug2: fd 3 setting O_NONBLOCK -debug1: Authenticating to 52.53.159.22:22 as 'ec2-user' -debug3: hostkeys_foreach: reading file "/home/dingofarmers/.ssh/known_hosts" -debug3: record_hostkey: found key type ECDSA in file /home/dingofarmers/.ssh/known_hosts:21 -debug3: load_hostkeys: loaded 1 keys from 52.53.159.22 -debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521 -debug3: send packet: type 20 -debug1: SSH2_MSG_KEXINIT sent -debug3: receive packet: type 20 -debug1: SSH2_MSG_KEXINIT received -debug2: local client KEXINIT proposal -debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c -debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa -debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc -debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc -debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1 -debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1 -debug2: compression ctos: none,zlib@openssh.com,zlib -debug2: compression stoc: none,zlib@openssh.com,zlib -debug2: languages ctos: -debug2: languages stoc: -debug2: first_kex_follows 0 -debug2: reserved 0 -debug2: peer server KEXINIT proposal -debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 -debug2: host key algorithms: ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519 -debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se -debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se -debug2: MACs ctos: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 -debug2: MACs stoc: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 -debug2: compression ctos: none,zlib@openssh.com -debug2: compression stoc: none,zlib@openssh.com -debug2: languages ctos: -debug2: languages stoc: -debug2: first_kex_follows 0 -debug2: reserved 0 -debug1: kex: algorithm: curve25519-sha256@libssh.org -debug1: kex: host key algorithm: ecdsa-sha2-nistp256 -debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none -debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none -debug3: send packet: type 30 -debug1: expecting SSH2_MSG_KEX_ECDH_REPLY -debug3: receive packet: type 31 -debug1: Server host key: ecdsa-sha2-nistp256 SHA256:qaPtcCft8A+sNZTbFvAsKBPQVvKRqdBYEV93An/SY+w -debug3: hostkeys_foreach: reading file "/home/dingofarmers/.ssh/known_hosts" -debug3: record_hostkey: found key type ECDSA in file /home/dingofarmers/.ssh/known_hosts:21 -debug3: load_hostkeys: loaded 1 keys from 52.53.159.22 -debug1: Host '52.53.159.22' is known and matches the ECDSA host key. -debug1: Found key in /home/dingofarmers/.ssh/known_hosts:21 -debug3: send packet: type 21 -debug2: set_newkeys: mode 1 -debug1: rekey after 134217728 blocks -debug1: SSH2_MSG_NEWKEYS sent -debug1: expecting SSH2_MSG_NEWKEYS -debug3: receive packet: type 21 -debug2: set_newkeys: mode 0 -debug1: rekey after 134217728 blocks -debug1: SSH2_MSG_NEWKEYS received -debug2: key: dingofarmers@ubuntu (0x55ce58f7d660), agent -debug2: key: dingofarmers@ubuntu (0x55ce58f7e920), agent -debug2: key: .ssh/RH17-06-11.pem ((nil)), explicit -debug3: send packet: type 5 -debug3: receive packet: type 6 -debug2: service_accept: ssh-userauth -debug1: SSH2_MSG_SERVICE_ACCEPT received -debug3: send packet: type 50 -debug3: receive packet: type 51 -debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic -debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic -debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password -debug3: authmethod_lookup gssapi-keyex -debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password -debug3: authmethod_is_enabled gssapi-keyex -debug1: Next authentication method: gssapi-keyex -debug1: No valid Key exchange context -debug2: we did not send a packet, disable method -debug3: authmethod_lookup gssapi-with-mic -debug3: remaining preferred: publickey,keyboard-interactive,password -debug3: authmethod_is_enabled gssapi-with-mic -debug1: Next authentication method: gssapi-with-mic -debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available -debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available -debug1: Unspecified GSS failure. Minor code may provide more information -debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available -debug2: we did not send a packet, disable method -debug3: authmethod_lookup publickey -debug3: remaining preferred: keyboard-interactive,password -debug3: authmethod_is_enabled publickey -debug1: Next authentication method: publickey -debug1: Offering RSA public key: dingofarmers@ubuntu -debug3: send_pubkey_test -debug3: send packet: type 50 -debug2: we sent a publickey packet, wait for reply -debug3: receive packet: type 51 -debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic -debug1: Offering RSA public key: dingofarmers@ubuntu -debug3: send_pubkey_test -debug3: send packet: type 50 -debug2: we sent a publickey packet, wait for reply -debug3: receive packet: type 51 -debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic -debug1: Trying private key: .ssh/RH17-06-11.pem -debug3: sign_and_send_pubkey: RSA SHA256:gwWpJTQxOFvICvYC7ILZ8rTnS9F/TjWaYCmxj6toatY -debug3: send packet: type 50 -debug2: we sent a publickey packet, wait for reply -debug3: receive packet: type 51 -debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic -debug2: we did not send a packet, disable method -debug1: No more authentication methods to try. Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
0debug
Sql programming logic- beginner level : I am a beginner in Sql programming. any pointers would help me. Say we have table 1, table 2 say for one Server ID column in table 1 you have many application ID columns corresponding in table 2 Filter out many application ID columns for one particular server ID, then match it up with another markuptable (joining based on applicationtable. applnid= markup table.logical_name) you need to output the markup id listed for all the application ids for that particular server
0debug
Cannot use optional chaining on non-optional value of type 'Bool' : <p>Why I can't use c? 1 : 2 syntax in swiftui? Is there any solution? </p> <pre><code>import SwiftUI struct ContentView: View { var c: Bool = false var body: some View { Text("Hello World") .foregroundColor(c? .red : .blue) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } </code></pre>
0debug
Try Catch for error message in google maps api : <p>I an using javascript and am getting an message that I have exceeded my daily request quota for this API. Is there a way to capture this error message in a try catch block so when I go over my quota I can execute another piece of code. I have seen several similar posts, but nothing that has been helpful. Here is my code.</p> <pre><code>(function (window, google, lat, lng) { var options = { center: { lat: Number(lat), lng: Number(lng) }, zoom: 5, disableDefaultUI: true, scrollwheel: true, draggable: false }, element = document.getElementById('map-canvas') var map = new google.maps.Map(element, options) }(window, window.google, result[i]['latitude'], result[i]['longitude'])); </code></pre>
0debug
What exactly is a Set in COQ : <p>I'm still puzzled what the sort <strong>Set</strong> means in COQ. When do I use <strong>Set</strong> and when do I use <strong>Type</strong>?</p> <p>In Hott a <strong>Set</strong> is defined as a type, where identity proofs are unique. But I think in Coq it has a different interpretation. </p>
0debug
Android layout design : <p>I am developing app where i want circuler image. it will rotate as songs play. can anyone help me to develop this layout.</p> <p><a href="https://i.stack.imgur.com/cK6qY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cK6qY.png" alt="enter image description here"></a></p>
0debug
How to stop form submission if email address is already available in MySQL db ? : <p>I have coded the following form with PHP &amp; MySQL as database. I want to prevent the form from submitting data, if email address already exists in database. I also want to disable the submit button, if email exists in database. </p> <h2>Index.php:</h2> <pre><code> &lt;?php require_once './include/user.php'; $user_obj = new user(); if (isset($_POST['submit'])) { $message = $user_obj-&gt;save_user($_POST); } ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;PHP Form With JS Validation&lt;/title&gt; &lt;meta charset="UTF-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;link rel="stylesheet" type="text/css" href="css/style.css"&gt; &lt;script type="text/javascript" src="js/country.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/jsval.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;PHP Form With JS Validation&lt;/p&gt; &lt;div id="id1"&gt; &lt;form id="myForm" name="myForm" action="index.php" method="POST" onsubmit="return validateStandard(this)"&gt; &lt;table&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="text" name="name" value="" placeholder="name" required="required" regexp="JSVAL_RX_ALPHA"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="email" name="email" value="" placeholder="email" required="required" required regexp="JSVAL_RX_EMAIL"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="password" name="user_password" value="" placeholder="password" required="required"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="tel" name="phone" value="" placeholder="phone no" required="required"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="radio" name="gender" value="male" checked&gt;Male &lt;input type="radio" name="gender" value="female"&gt;Female &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;textarea name="address" placeholder="address" required="required"&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="text" name="city" value="" placeholder="city" required regexp="JSVAL_RX_ALPHA"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt; &lt;select name="country" required="required" exclude=" "&gt; &lt;option value=" "&gt;Please Select Country&lt;/option&gt; &lt;script type="text/javascript"&gt;printCountryOptions();&lt;/script&gt; &lt;/select&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="text" name="zipcode" value="" placeholder="zipcode" required="required" regexp="JSVAL_RX_ALPHA_NUMERIC"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="checkbox" name="agree" value="on" required="required"&gt; I agreed with all the terms!&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="submit" id="sbtn" name="submit" value="Register"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; &lt;script&gt; document.forms['myForm'].reset(); &lt;/script&gt; </code></pre> <h2>db: user.php</h2> <pre><code> &lt;?php class user { public function save_user($data) { $hostname = "localhost"; $username = "root"; $password = ""; $dbname = "db_user_info"; $conn = mysqli_connect($hostname, $username, $password, $dbname); $user_password = md5($data['user_password']); $sql = "INSERT INTO tbl_user (name, email, user_password, phone, gender, address, city, country, zipcode, agree) VALUES ('$data[name]','$data[email]','$user_password', '$data[phone]','$data[gender]','$data[address]','$data[city]','$data[country]','$data[zipcode]','$data[agree]')"; if (!mysqli_query($conn, $sql)) { die('Sql Error:' . mysqli_error($conn)); } else { header('Location:thanks.php'); } mysqli_close($conn); } } </code></pre>
0debug
void qxl_guest_bug(PCIQXLDevice *qxl, const char *msg, ...) { #if SPICE_INTERFACE_QXL_MINOR >= 1 qxl_send_events(qxl, QXL_INTERRUPT_ERROR); #endif if (qxl->guestdebug) { va_list ap; va_start(ap, msg); fprintf(stderr, "qxl-%d: guest bug: ", qxl->id); vfprintf(stderr, msg, ap); fprintf(stderr, "\n"); va_end(ap); } }
1threat
static void tgen_andi(TCGContext *s, TCGType type, TCGReg dest, uint64_t val) { static const S390Opcode ni_insns[4] = { RI_NILL, RI_NILH, RI_NIHL, RI_NIHH }; static const S390Opcode nif_insns[2] = { RIL_NILF, RIL_NIHF }; uint64_t valid = (type == TCG_TYPE_I32 ? 0xffffffffull : -1ull); int i; if ((val & valid) == 0xffffffff) { tgen_ext32u(s, dest, dest); return; } if (facilities & FACILITY_EXT_IMM) { if ((val & valid) == 0xff) { tgen_ext8u(s, TCG_TYPE_I64, dest, dest); return; } if ((val & valid) == 0xffff) { tgen_ext16u(s, TCG_TYPE_I64, dest, dest); return; } } for (i = 0; i < 4; i++) { tcg_target_ulong mask = ~(0xffffull << i*16); if (((val | ~valid) & mask) == mask) { tcg_out_insn_RI(s, ni_insns[i], dest, val >> i*16); return; } } if (facilities & FACILITY_EXT_IMM) { for (i = 0; i < 2; i++) { tcg_target_ulong mask = ~(0xffffffffull << i*32); if (((val | ~valid) & mask) == mask) { tcg_out_insn_RIL(s, nif_insns[i], dest, val >> i*32); return; } } } if ((facilities & FACILITY_GEN_INST_EXT) && risbg_mask(val)) { int msb, lsb; if ((val & 0x8000000000000001ull) == 0x8000000000000001ull) { msb = 63 - ctz64(~val); lsb = clz64(~val) + 1; } else { msb = clz64(val); lsb = 63 - ctz64(val); } tcg_out_risbg(s, dest, dest, msb, lsb, 0, 1); return; } tcg_out_movi(s, type, TCG_TMP0, val); if (type == TCG_TYPE_I32) { tcg_out_insn(s, RR, NR, dest, TCG_TMP0); } else { tcg_out_insn(s, RRE, NGR, dest, TCG_TMP0); } }
1threat
I want to assign strings to the student constructor's parameters based on what is typed into the JOptionPane : I want to assign strings to the student constructor's parameters based on what is typed into the JOptionPane input boxes . I have the user inputted information set to go to a variable but when I try and use those variables as my Parameters for the constructor I get an error. This is the Main import javax.swing.JOptionPane; public class main { public static void main (String [] args) { String nameinput ; String gradeinput ; String resourceinput ; String whatMissinginput; int infoComformation = 1; if ( infoComformation == 1) { nameinput =JOptionPane.showInputDialog("What is the students name"); gradeinput =JOptionPane.showInputDialog("What is the students grade"); resourceinput =JOptionPane.showInputDialog("What resource are you pulling the child out for "); whatMissinginput =JOptionPane.showInputDialog("What subject are you pulling the child out of "); infoComformation = JOptionPane.showConfirmDialog (null, "Is this the correct informtion \n " +"Name = " + nameinput + "\n" + "Grade = " + gradeinput + "\n" +"Resouce = " + resourceinput + "\n" +"Subject Missing = " + whatMissinginput ); } else if (infoComformation == 0) //THIS IS WHERE THE PROBLEM IS {student pupil = new student( nameinput, gradeinput ,resourceinput,whatMissinginput); } } } Here is the Constructor Class import javax.swing.JOptionPane; public class student { public String studentinfo (String nameinput, String gradeinput , String resourceinput,String whatMissinginput ) { String name ="" ; String grade= ""; String resource =""; String whatMissing=""; name=nameinput; grade=gradeinput; resource=resourceinput; whatMissing=whatMissinginput ; return name+grade+resource+whatMissing; } } What do I Do?
0debug
Not Able to Get Index of Element in Array in JavaScript : <p>Can you please take a look at this code and let me know why I am not getting the index of each array element which is not 0 in this loop properly?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let st = "0,1,0,0,1,1"; let arr = []; arr = st.split(','); for(var i = 0; i &lt; arr.length; i++){ if( arr[i] != 0){ console.log(arr.indexOf(i)) } }</code></pre> </div> </div> </p>
0debug
av_cold int ff_h264_decode_init(AVCodecContext *avctx) { H264Context *h = avctx->priv_data; int ret; ret = h264_init_context(avctx, h); if (ret < 0) return ret; memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t)); memset(h->pps.scaling_matrix8, 16, 2 * 64 * sizeof(uint8_t)); if (!avctx->has_b_frames) h->low_delay = 1; ff_h264_decode_init_vlc(); ff_init_cabac_states(); if (avctx->codec_id == AV_CODEC_ID_H264) { if (avctx->ticks_per_frame == 1) h->avctx->framerate.num *= 2; avctx->ticks_per_frame = 2; } if (avctx->extradata_size > 0 && avctx->extradata) { ret = ff_h264_decode_extradata(h); if (ret < 0) { ff_h264_free_context(h); return ret; } } if (h->sps.bitstream_restriction_flag && h->avctx->has_b_frames < h->sps.num_reorder_frames) { h->avctx->has_b_frames = h->sps.num_reorder_frames; h->low_delay = 0; } avctx->internal->allocate_progress = 1; if (h->enable_er) { av_log(avctx, AV_LOG_WARNING, "Error resilience is enabled. It is unsafe and unsupported and may crash. " "Use it at your own risk\n"); } return 0; }
1threat
my code will not exicute the if/ elif part in this : so When I run this code(a portion of it) and I get to the word = input, it will run that and let me input my answer. But instead of doing the if / elif code, it will say exit code 0. I do not understand why this is happening so please help. I tried to remove code here and there but it changed nothing. rand1 = random.randint(1, 2) rand2 = random.randint(1, 4) rand = random.randint(1, 1) word = input("use a word that is 1-10 letters on a space, type a number 1 - 100 for the space: ") if rand == "1": print("randomly generating") elif rand1 == "1": a1 = word[0] a2 = word[1] a3 = word[2] a4 = word[3] a5 = word[4] a6 = word[5] a7 = word[6] a8 = word[7] a9 = word[8] a10 = word[9] letters() this is just a portion as the entire code is too long to post in here
0debug
Why does this loop only once? : <pre><code>while count &gt; 0: if count = 0: return n elif count &lt; 0: print(" ") # prints empty if n is below 0 else: count = count - 1 collect += math.ceil((n - 5)/2) return collect </code></pre> <p>The inputs are (1003, 3) - result is 499, which means it just loop once and subtracts 5 and then divides by 2, then it stops. Anyone know why?</p>
0debug
Cannot read property 'history' of undefined (useHistory hook of React Router 5) : <p>I am using the new useHistory hook of React Router, which came out a few weeks ago. My React-router version is 5.1.2. My React is at version 16.10.1. You can find my code at the bottom.</p> <p>Yet when I import the new useHistory from react-router, I get this error:</p> <p><code>Uncaught TypeError: Cannot read property 'history' of undefined</code></p> <p>which is caused by this line in React-router</p> <pre><code>function useHistory() { if (process.env.NODE_ENV !== "production") { !(typeof useContext === "function") ? process.env.NODE_ENV !== "production" ? invariant(false, "You must use React &gt;= 16.8 in order to use useHistory()") : invariant(false) : void 0; } return useContext(context).history; &lt;---------------- ERROR IS ON THIS LINE !!!!!!!!!!!!!!!!! } </code></pre> <p>Since it is related to useContext and perhaps a conflict with context is at fault, I tried completely removing all calls to useContext, creating the provider, etc. However, that did nothing. Tried with React v16.8; same thing. I have no idea what could be causing this, as every other feature of React router works fine.</p> <p>***Note that the same thing happens when calling the other React router hooks, such as useLocation or useParams. </p> <p>Has anyone else encountered this? Any ideas to what may cause this? Any help would be greatly appreciated, as I found nothing on the web related to this issue.</p> <pre><code>import React, {useEffect, useContext} from 'react'; import { BrowserRouter as Router, Route, Link } from "react-router-dom"; import { Switch, useHistory } from 'react-router' import { useTranslation } from 'react-i18next'; import lazyLoader from 'CommonApp/components/misc/lazyLoader'; import {AppContext} from 'CommonApp/context/context'; export default function App(props) { const { i18n } = useTranslation(); const { language } = useContext(AppContext); let history = useHistory(); useEffect(() =&gt; { i18n.changeLanguage(language); }, []); return( &lt;Router&gt; &lt;Route path="/"&gt; &lt;div className={testClass}&gt;HEADER&lt;/div&gt; &lt;/Route&gt; &lt;/Router&gt; ) } </code></pre>
0debug
why file_get_content($url) return the empty string : Code: <?php $url = "oooff.com"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $curl_scraped_page = curl_exec($ch); curl_close($ch); echo $curl_scraped_page; ?> above code display the blank page why please anyone help to me
0debug
react-router Redirect vs history.push : <p>I was reading <a href="https://github.com/ReactTraining/react-router/tree/master/packages/react-router-redux/examples" rel="noreferrer">react-router-redux examples</a> and I confused, what is the difference beetween:</p> <pre><code>import { Redirect } from 'react-router-dom' ... &lt;Redirect to='/login' /&gt; </code></pre> <p>and </p> <pre><code>import { push } from 'react-router-redux' ... push('/login') </code></pre>
0debug
uint32_t qemu_devtree_get_phandle(void *fdt, const char *path) { uint32_t r; r = fdt_get_phandle(fdt, findnode_nofail(fdt, path)); if (r <= 0) { fprintf(stderr, "%s: Couldn't get phandle for %s: %s\n", __func__, path, fdt_strerror(r)); exit(1); } return r; }
1threat
I have an issue for getting the inserting multiple dropdown values. After submitting it gets a database error. : **View:** <select class="form-control" data-placeholder="Choose a Category" tabindex="1" name="venues[]" multiple > <option value="">Select One</option> <?php foreach($list_of_venues as $venues){ ?> <option value="<?php echo $venues->activity_venue_id; ?>"><?php echo $venues->venue_title; ?></option> <?php } ?> </select> **Controller** <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Create_activity_session extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('vendor_model'); $this->load->database(); } public function index() { error_reporting(0); $session_data = $this->session->userdata('logged_in'); $data['account_name'] = $session_data['account_name']; if($session_data['account_name']){ $data['id'] = $session_data['id']; $id = $data['id']; $data['list_of_activities'] = $this->vendor_model->list_of_activities_by_vendor($id); $data['list_of_venues'] = $this->vendor_model->list_of_venues_by_vendor($id); $data['list_of_booking_fields'] = $this->vendor_model->list_of_booking_fields_by_vendor_by_venue($id); $this->form_validation->set_rules('activity_title','Activity Title','required'); $this->form_validation->set_rules('venues[]','Selecting Venue','required'); $this->form_validation->set_rules('start_date','Start Date','required'); $this->form_validation->set_rules('end_date','End Date','required'); $this->form_validation->set_rules('start_time','Start Time','required'); $this->form_validation->set_rules('end_time','End Time','required'); $this->form_validation->set_rules('number_of_seats','Number of Bookings','required'); $this->form_validation->set_rules('price','Price','required'); if($this->form_validation->run()==FALSE){ $data['list_of_activities'] = $this->vendor_model->list_of_activities_by_vendor($id); $data['list_of_venues'] = $this->vendor_model->list_of_venues_by_vendor($id); $data['list_of_booking_fields'] = $this->vendor_model->list_of_booking_fields_by_vendor_by_venue($id); $this->load->view('vendor/create_activity_session',$data); } else { $end_date = $this->input->post('end_date'); $start_date = $this->input->post('start_date'); if($end_date < $start_date){ $data['error'] = 'Start Date should not be greater than the End Date.'; $this->load->view('vendor/create_activity_session',$data); } else { $activity_id = $this->input->post('activity_title'); $venue_id = implode(',',$this->input->post('venues')); $data = array( 'activity_by_id' => $this->input->post('activity_title'), 'venue_id' => $venue_id, 'start_date' => $this->input->post('start_date'), 'end_date' => $this->input->post('end_date'), 'start_time' => $this->input->post('start_time'), 'end_time' => $this->input->post('end_time'), 'number_of_seats' => $this->input->post('number_of_seats'), 'price' => $this->input->post('price'), 'vendor_id' => $id, 'status' => 1, 'created_on' => date('Y-m-d h:i:s') ); $result = $this->vendor_model->create_activity_dates_time($data); $session_id = $this->db->insert_id(); // $venues = $this->input->post('venues'); $data = array( 'venue_activity_id' => $venue_id, ); $result2 = $this->vendor_model->update_activity($data,$activity_id); $venues = $this->input->post('venues'); $venue_count = count($venues); for($i = 0;$i<=$venue_count; $i++){ $data = array( 'session_by_id' => $session_id, 'venue_by_id' => $venues[$i] ); $result3 = $this->vendor_model->create_venues_by_session($data); } $data['success'] = 'You have created the new Activity Session'; $data['list_of_activities'] = $this->vendor_model->list_of_activities_by_vendor($id); $data['list_of_venues'] = $this->vendor_model->list_of_venues_by_vendor($id); $data['list_of_booking_fields'] = $this->vendor_model->list_of_booking_fields_by_vendor_by_venue($id); $this->load->view('vendor/create_activity_session',$data); } } } else { redirect('http://localhost/bookleisure/vendor/login'); } } } I have an issue with inserting the multiple dropdown values that shows the database error such as "venue_by_id cannot be null. I wanted to insert the multiple dropdown rows. So please kindly resolve that issue. [1]: https://i.stack.imgur.com/5kZ99.jpg
0debug
uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr, uint64_t new_lo, uint64_t new_hi) { uintptr_t ra = GETPC(); Int128 oldv, cmpv, newv; bool success; cmpv = int128_make128(env->exclusive_val, env->exclusive_high); newv = int128_make128(new_lo, new_hi); if (parallel_cpus) { #ifndef CONFIG_ATOMIC128 cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); #else int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra); success = int128_eq(oldv, cmpv); #endif } else { uint64_t o0, o1; #ifdef CONFIG_USER_ONLY uint64_t *haddr = g2h(addr); o1 = ldq_be_p(haddr + 0); o0 = ldq_be_p(haddr + 1); oldv = int128_make128(o0, o1); success = int128_eq(oldv, cmpv); if (success) { stq_be_p(haddr + 0, int128_gethi(newv)); stq_be_p(haddr + 1, int128_getlo(newv)); } #else int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi0 = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); TCGMemOpIdx oi1 = make_memop_idx(MO_BEQ, mem_idx); o1 = helper_be_ldq_mmu(env, addr + 0, oi0, ra); o0 = helper_be_ldq_mmu(env, addr + 8, oi1, ra); oldv = int128_make128(o0, o1); success = int128_eq(oldv, cmpv); if (success) { helper_be_stq_mmu(env, addr + 0, int128_gethi(newv), oi1, ra); helper_be_stq_mmu(env, addr + 8, int128_getlo(newv), oi1, ra); } #endif } return !success; }
1threat
Java Swing Error with format (I think) : I can't solve this, Note that I'm new to swing, thanks. http://prntscr.com/bpz2ve http://hastebin.com/oyucefasah.java
0debug
How to write a modal with a nested array in spring? : I am writing a new class in spring boot where I need to write a modal class in which there will be a sub modal classes(I mean an array with a nested arrays), but when I try to run it I am getting the sub modal class names as attributes not the real attributes which I mentioned in sub modals. **********ChangeBin Modal*********** package com.demo.model; import java.io.Serializable; import java.util.List; import org.springframework.data.mongodb.core.mapping.Field; public class Changebin implements Serializable{ @Field(value = "Change_bin_Past") private ChangebinPast changebinpast; @Field(value = "Change_bin_Present") private ChangebinPresent changebinpresent; public ChangebinPast getChangebinpast() { return changebinpast; } public void setChangebinpast(ChangebinPast changebinpast) { this.changebinpast = changebinpast; } public ChangebinPresent getChangebinpresent() { return changebinpresent; } public void setChangebinpresent(ChangebinPresent changebinpresent) { this.changebinpresent = changebinpresent; } } ***********ChangebinPast -- Sub modal ****************** package com.demo.model; import java.io.Serializable; import org.springframework.data.mongodb.core.mapping.Field; public class ChangebinPast implements Serializable { @Field(value = "ID_A") private String ID_A; public String getID_A() { return ID_A; } public void setID_A(String ID_A) { this.ID_A = ID_A; } public String getID_B() { return ID_B; } public void setID_B(String ID_B) { this.ID_B = ID_B; } @Field(value = "ID_B") private String ID_B; } ***************Changebinpresent -- Sub Modal*************** package com.demo.model; import java.io.Serializable; import org.springframework.data.mongodb.core.mapping.Field; public class ChangebinPresent implements Serializable { @Field(value = "ID_A1") private String ID_A1; @Field(value = "ID_B1") private String ID_B1; public String getID_A1() { return ID_A1; } public void setID_A1(String ID_A1) { this.ID_A1 = ID_A1; } public String getID_B1() { return ID_B1; } public void setID_B1(String ID_B1) { this.ID_B1 = ID_B1; } } Expected : ChangeBin [ { ID_A : "", ID_B : "" }, { ID_A1: "", ID_B1: "" } ] But got like this : ChangeBin [ { changebinpast: "", changebinpresent : "" }, { changebinpast: "", changebinpresent : "" } ]
0debug
static void qmp_output_add_obj(QmpOutputVisitor *qov, const char *name, QObject *value) { QStackEntry *e = QTAILQ_FIRST(&qov->stack); QObject *cur = e ? e->value : NULL; if (!cur) { qobject_decref(qov->root); qov->root = value; } else { switch (qobject_type(cur)) { case QTYPE_QDICT: assert(name); qdict_put_obj(qobject_to_qdict(cur), name, value); break; case QTYPE_QLIST: qlist_append_obj(qobject_to_qlist(cur), value); break; default: g_assert_not_reached(); } } }
1threat
static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, int64_t offset_in_cluster, const uint8_t *buf, int nb_sectors, int64_t sector_num) { int ret; VmdkGrainMarker *data = NULL; uLongf buf_len; const uint8_t *write_buf = buf; int write_len = nb_sectors * 512; if (extent->compressed) { if (!extent->has_marker) { ret = -EINVAL; goto out; } buf_len = (extent->cluster_sectors << 9) * 2; data = g_malloc(buf_len + sizeof(VmdkGrainMarker)); if (compress(data->data, &buf_len, buf, nb_sectors << 9) != Z_OK || buf_len == 0) { ret = -EINVAL; goto out; } data->lba = sector_num; data->size = buf_len; write_buf = (uint8_t *)data; write_len = buf_len + sizeof(VmdkGrainMarker); } ret = bdrv_pwrite(extent->file, cluster_offset + offset_in_cluster, write_buf, write_len); if (ret != write_len) { ret = ret < 0 ? ret : -EIO; goto out; } ret = 0; out: g_free(data); return ret; }
1threat
Show records on userInput store PROCEDURE : <p>I want to show records based on user input.</p> <pre><code> CREATE PROCEDURE [dbo].[ShowRecords] @recordsToShow int AS BEGIN select top @recordsToShow * from usermaster END </code></pre>
0debug
Hi, Im trying to edit my blog (blogspot) very new to this I keep getting an error code that my xml must start and end with the same entity : </div> {/block:Answer} {block:PermalinkPage} <div style="margin-top:20px;">{block:Date} <b>Posted:</b> {Month} {DayOfMonth}, {Year} &bull; {12Hour}:{Minutes} {CapitalAmPm}{/block:Date}{block:NoteCount}<br><b>With:</b>&nbsp;{NoteCountWithLabel}{/block:NoteCount}<br>{block:HasTags}<b>Filed Under:</b>{block:Tags} #{Tag}{/block:Tags}{/block:HasTags}{/block:Date} </div> {/block:PermalinkPage} {block:PostNotes} {PostNotes} {/block:PostNotes} {/block:Posts} {block:IfInfiniteScroll}</div>{/block:IfInfiniteScroll} </div> </body> </html/> I think code I'm using is poorly formatted but again I HAVE NO IDEA WHAT IM DOING!
0debug
START_TEST(vararg_string) { int i; struct { const char *decoded; } test_cases[] = { { "hello world" }, { "the quick brown fox jumped over the fence" }, {} }; for (i = 0; test_cases[i].decoded; i++) { QObject *obj; QString *str; obj = qobject_from_jsonf("%s", test_cases[i].decoded); fail_unless(obj != NULL); fail_unless(qobject_type(obj) == QTYPE_QSTRING); str = qobject_to_qstring(obj); fail_unless(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0); QDECREF(str); } }
1threat
how to read 2d array with only semicolon in java : I hava an 2d array somthing like this int[][] arr1 = {,}; And i am trying to check no. of col and rows it contains.<br> I used below technique to calculate int rws=arr1.length,col=arr1[0].length; but getting the error `java.lang.ArrayIndexOutOfBoundsException: 0` obviously it throwing this error but i am unable to hoe read this 2d array.
0debug
keycloak CORS filter spring boot : <p>I am using keycloak to secure my rest service. I am refering to the tutorial given <a href="http://slackspace.de/articles/authentication-with-spring-boot-angularjs-and-keycloak/" rel="noreferrer">here</a>. I created the rest and front end. Now when I add keycloak on the backend I get CORS error when my front end makes api call.</p> <p>Application.java file in spring boot looks like</p> <pre><code>@SpringBootApplication public class Application { public static void main( String[] args ) { SpringApplication.run(Application.class, args); } @Bean public WebMvcConfigurer corsConfiguration() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/*") .allowedMethods(HttpMethod.GET.toString(), HttpMethod.POST.toString(), HttpMethod.PUT.toString(), HttpMethod.DELETE.toString(), HttpMethod.OPTIONS.toString()) .allowedOrigins("*"); } }; } } </code></pre> <p>The keycloak properties in the application.properties file look like</p> <pre><code>keycloak.realm = demo keycloak.auth-server-url = http://localhost:8080/auth keycloak.ssl-required = external keycloak.resource = tutorial-backend keycloak.bearer-only = true keycloak.credentials.secret = 123123-1231231-123123-1231 keycloak.cors = true keycloak.securityConstraints[0].securityCollections[0].name = spring secured api keycloak.securityConstraints[0].securityCollections[0].authRoles[0] = admin keycloak.securityConstraints[0].securityCollections[0].authRoles[1] = user keycloak.securityConstraints[0].securityCollections[0].patterns[0] = /api/* </code></pre> <p>The sample REST API that I am calling</p> <pre><code>@RestController public class SampleController { @RequestMapping(value ="/api/getSample",method=RequestMethod.GET) public string home() { return new string("demo"); } } </code></pre> <p>the front end keycloak.json properties include</p> <pre><code>{ "realm": "demo", "auth-server-url": "http://localhost:8080/auth", "ssl-required": "external", "resource": "tutorial-frontend", "public-client": true } </code></pre> <p>The CORS error that I get</p> <pre><code>XMLHttpRequest cannot load http://localhost:8090/api/getSample. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access. The response had HTTP status code 401. </code></pre>
0debug
Display DIV's like Bee hive : <p>What is the right way to display DIV's as a sequence of box's with no space between them ? <a href="https://i.stack.imgur.com/aqxK4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aqxK4.png" alt="enter image description here"></a></p>
0debug
Cannot find any elements using Internet Explorer 11 and Selenium (any version) and IEWebDriver (any version) : <p>I've searched all over for an answer and I can't find any fix to my issue. I am trying to run my Selenium tests in IE11. All other browsers work fine (including Edge). A simple test as follows will cause the issue...</p> <pre><code>System.setProperty("webdriver.ie.driver.loglevel","TRACE"); System.setProperty("webdriver.ie.driver.logfile", "C:/Projects/logme.txt"); driver = new InternetExplorerDriver(); driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); driver.manage().deleteAllCookies(); driver.manage().window().maximize(); driver.get("http:www.google.com"); driver.findElement(By.id("lst-ib")).click; </code></pre> <p>IE11 will launch and navigate to a URL but it cannot find any elements anywhere on any page. Again, I'm aware people have had this issue but no suggestions have fixed my problem. This is the error i get back every time: </p> <pre><code>org.openqa.selenium.NoSuchElementException: Unable to find element with id == lst-ib (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 3.23 seconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '3.2.0', revision: '8c03df6b79', time: '2017-02-23 10:51:31 +0000'System info: host: 'DESKTOP-63BRP93', ip: '10.0.110.68', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_121' Driver info: org.openqa.selenium.ie.InternetExplorerDriverCapabilities [{browserAttachTimeout=0, ie.enableFullPageScreenshot=true, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.forceShellWindowsApi=false, pageLoadStrategy=normal, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:38992/, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}] Session ID: 0fbcebc8-6775-4a6c-b10a-47350502598f *** Element info: {Using=id, value=lst-ib} at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) </code></pre> <p>Here is what I've tried/done...</p> <ol> <li>Set Enabled Protected Mode to disabled for all zones</li> <li>Set Allow Scripting option on the advanced tab or IE options</li> <li>Tried every IEDriver capability known to man e.g. setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION,true);</li> <li>Tried IE11 32 and 64bit</li> <li>Attempted to find an element by, class, tagname and all the rest of the locators to no avail.</li> <li>Added the 2 registry keys BFCACHE for both 32 and 64bit instances of IE</li> <li>Cried a lot</li> </ol> <p>Below is the attached logs and I've located where the code falls over. It seems to be security related but JavaScript is enabled and I don't know where else to look...</p> <pre><code>T 2017-03-06 17:27:41:529 Browser.cpp(613) Entering Browser::GetDocumentFromWindow T 2017-03-06 17:27:41:532 Script.cpp(49) Entering Script::Initialize T 2017-03-06 17:27:41:532 Script.cpp(70) Entering Script::AddArgument(std::wstring) T 2017-03-06 17:27:41:532 Script.cpp(105) Entering Script::AddArgument(VARIANT) T 2017-03-06 17:27:41:532 Script.cpp(70) Entering Script::AddArgument(std::wstring) T 2017-03-06 17:27:41:532 Script.cpp(105) Entering Script::AddArgument(VARIANT) T 2017-03-06 17:27:41:532 Script.cpp(169) Entering Script::Execute T 2017-03-06 17:27:41:532 Script.cpp(477) Entering Script::CreateAnonymousFunction W 2017-03-06 17:27:41:539 Script.cpp(494) -2147024891 [Access is denied.]: Unable to execute code, call to IHTMLWindow2::execScript failed W 2017-03-06 17:27:41:540 Script.cpp(180) Cannot create anonymous function W 2017-03-06 17:27:41:540 ElementFinder.cpp(98) A JavaScript error was encountered executing the findElement atom. </code></pre> <p>If anyone has seen or fixed this issue, please help me!</p> <p>Thanks</p>
0debug
How to create nice-to-use type-checked aliases for primitive types in C++? : <p>I'm writing code where I'm creating multiple aliases for primitive types, e.g. <em>Address</em> and <em>Id</em> being <em>int</em>s.</p> <p>I want to avoid using Addresses and Ids together, e.g. in arithmetic operations.</p> <p>Thus I would like to have type-checking on these aliases, so that the following result can be obtained:</p> <pre><code>typedef int A; typedef int B; A f(A a) { return a+a; }; int main() { A a = 5; B b = 5; f(a); // I would like this to work... f(b); // and this not to compile. } </code></pre> <p>Now this does not work, but I know I can use a wrapper struct/class with just one member:</p> <pre><code>class A { public: int x; A(int xx) { x = xx; }}; class B { public: int x; B(int xx) { x = xx; }}; A f(A a) { return A(a.x+a.x); }; // this is ugly and I'd want to be able to use: return a+a int main() { A a = 5; B b = 5; f(a); // This will work... f(b); // This won't compile... } </code></pre> <p><strong>My question is</strong> - what's the best way I can get code working like the 2nd snippet, but without having to explicitly getting <em>x</em> all the time and construct new objects (as noted in the line with the "this is ugly" comment)?</p> <p>I guess I can overload all relevant operators for all my 'aliases' but that's a lot of work and I'm hoping there's a faster/nicer solution.</p> <p>Thanks.</p> <p>PS To make this a concrete SO question, not a discussion: I'm just asking for a different way of achieving the result I want, than overloading everything. Thank you.</p>
0debug
Handle 404 error with Express 4 : <p>I am using Express 4 and I have about 50 html pages. I'm trying to handle 404 errors but can't figure out how. I don't want to manually define all the routers within node. Is there a way to dynamically redirect to a 404 Jade template if a page doesn't exist?</p> <p>I tried this code but didn't work:</p> <pre><code>app.enable('verbose errors'); app.set('port', 3000); app.use(express.static(__dirname + '/html/')); var server = http.createServer(app); server.listen(app.get('port'), function() { console.log('ONLINE !'); }); app.use(function(req, res, next) { console.log('GET ' + req.originalUrl) console.log('At %d', Date.now()); next(); }); // Handle 404 app.use(function(req, res, next) { if(req.accepts('html') &amp;&amp; res.status(404)) { res.render('404.jade'); return; } }); </code></pre>
0debug
static int sap_write_close(AVFormatContext *s) { struct SAPState *sap = s->priv_data; int i; for (i = 0; i < s->nb_streams; i++) { AVFormatContext *rtpctx = s->streams[i]->priv_data; if (!rtpctx) continue; av_write_trailer(rtpctx); url_fclose(rtpctx->pb); av_metadata_free(&rtpctx->streams[0]->metadata); av_metadata_free(&rtpctx->metadata); av_free(rtpctx->streams[0]); av_free(rtpctx); s->streams[i]->priv_data = NULL; } if (sap->last_time && sap->ann && sap->ann_fd) { sap->ann[0] |= 4; url_write(sap->ann_fd, sap->ann, sap->ann_size); } av_freep(&sap->ann); if (sap->ann_fd) url_close(sap->ann_fd); ff_network_close(); return 0; }
1threat
How do I reverse a sentence in python? : <p>I've been searching for a way to reverse sentences, but I can't seem to find one. I was hoping to find a way in Python; however, I'm not sure if there is a way to do it. If anybody knows of a way to do it, I would really appreciate the help.</p>
0debug
static int ac3_eac3_probe(AVProbeData *p, enum AVCodecID expected_codec_id) { int max_frames, first_frames = 0, frames; const uint8_t *buf, *buf2, *end; enum AVCodecID codec_id = AV_CODEC_ID_AC3; max_frames = 0; buf = p->buf; end = buf + p->buf_size; for(; buf < end; buf++) { if(buf > p->buf && !(buf[0] == 0x0B && buf[1] == 0x77) && !(buf[0] == 0x77 && buf[1] == 0x0B) ) continue; buf2 = buf; for(frames = 0; buf2 < end; frames++) { uint8_t buf3[4096]; uint8_t bitstream_id; uint16_t frame_size; int i, ret; if(!memcmp(buf2, "\x1\x10\0\0\0\0\0\0", 8)) buf2+=16; if (buf[0] == 0x77 && buf[1] == 0x0B) { for(i=0; i<8; i+=2) { buf3[i ] = buf2[i+1]; buf3[i+1] = buf2[i ]; } ret = av_ac3_parse_header(buf3, 8, &bitstream_id, &frame_size); }else ret = av_ac3_parse_header(buf2, end - buf2, &bitstream_id, &frame_size); if (ret < 0) break; if(buf2 + frame_size > end) break; if (buf[0] == 0x77 && buf[1] == 0x0B) { av_assert0(frame_size <= sizeof(buf3)); for(i = 8; i < frame_size; i += 2) { buf3[i ] = buf2[i+1]; buf3[i+1] = buf2[i ]; } if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf3 + 2, frame_size - 2)) break; } else { if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, frame_size - 2)) break; } if (bitstream_id > 10) codec_id = AV_CODEC_ID_EAC3; buf2 += frame_size; } max_frames = FFMAX(max_frames, frames); if(buf == p->buf) first_frames = frames; } if(codec_id != expected_codec_id) return 0; if (first_frames>=7) return AVPROBE_SCORE_EXTENSION + 1; else if(max_frames>200)return AVPROBE_SCORE_EXTENSION; else if(max_frames>=4) return AVPROBE_SCORE_EXTENSION/2; else if(max_frames>=1) return 1; else return 0; }
1threat
int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num, uint64_t *cluster_offset) { BDRVQcowState *s = bs->opaque; unsigned int l2_index; uint64_t l1_index, l2_offset, *l2_table; int l1_bits, c; unsigned int index_in_cluster, nb_clusters; uint64_t nb_available, nb_needed; int ret; index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1); nb_needed = *num + index_in_cluster; l1_bits = s->l2_bits + s->cluster_bits; nb_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1)); nb_available = (nb_available >> 9) + index_in_cluster; if (nb_needed > nb_available) { nb_needed = nb_available; } *cluster_offset = 0; l1_index = offset >> l1_bits; if (l1_index >= s->l1_size) { ret = QCOW2_CLUSTER_UNALLOCATED; goto out; } l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK; if (!l2_offset) { ret = QCOW2_CLUSTER_UNALLOCATED; goto out; } ret = l2_load(bs, l2_offset, &l2_table); if (ret < 0) { return ret; } l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); *cluster_offset = be64_to_cpu(l2_table[l2_index]); nb_clusters = size_to_clusters(s, nb_needed << 9); ret = qcow2_get_cluster_type(*cluster_offset); switch (ret) { case QCOW2_CLUSTER_COMPRESSED: c = 1; *cluster_offset &= L2E_COMPRESSED_OFFSET_SIZE_MASK; break; case QCOW2_CLUSTER_ZERO: if (s->qcow_version < 3) { qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); return -EIO; } c = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], QCOW_OFLAG_ZERO); *cluster_offset = 0; break; case QCOW2_CLUSTER_UNALLOCATED: c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]); *cluster_offset = 0; break; case QCOW2_CLUSTER_NORMAL: c = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], QCOW_OFLAG_ZERO); *cluster_offset &= L2E_OFFSET_MASK; break; default: abort(); } qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); nb_available = (c * s->cluster_sectors); out: if (nb_available > nb_needed) nb_available = nb_needed; *num = nb_available - index_in_cluster; return ret; }
1threat
what is the max line limit for uitextview in swift : I want to know that what is the maximum line limit to display text into uitextview. if the content is more than the max line number into uitextview that what is the alternative of uitextview to display text
0debug
static uint32_t get_cmd(ESPState *s, uint8_t *buf) { uint32_t dmalen; int target; dmalen = s->rregs[ESP_TCLO] | (s->rregs[ESP_TCMID] << 8); target = s->wregs[ESP_WBUSID] & 7; DPRINTF("get_cmd: len %d target %d\n", dmalen, target); if (s->dma) { s->dma_memory_read(s->dma_opaque, buf, dmalen); } else { buf[0] = 0; memcpy(&buf[1], s->ti_buf, dmalen); dmalen++; } s->ti_size = 0; s->ti_rptr = 0; s->ti_wptr = 0; if (s->current_dev) { s->current_dev->cancel_io(s->current_dev, 0); s->async_len = 0; } if (target >= ESP_MAX_DEVS || !s->scsi_dev[target]) { s->rregs[ESP_RSTAT] = 0; s->rregs[ESP_RINTR] = INTR_DC; s->rregs[ESP_RSEQ] = SEQ_0; esp_raise_irq(s); return 0; } s->current_dev = s->scsi_dev[target]; return dmalen; }
1threat
static void vfio_pci_reset(DeviceState *dev) { PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, dev); VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev); if (!vdev->reset_works) { return; } if (ioctl(vdev->fd, VFIO_DEVICE_RESET)) { error_report("vfio: Error unable to reset physical device " "(%04x:%02x:%02x.%x): %m\n", vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); } }
1threat
How to prevent RecyclerView item from blinking after notifyItemChanged(pos)? : <p>I currently have a recycler view whose data updates every 5 secs. To update the data on the list, I am using </p> <pre><code>notifyItemChanged(position); notifyItemRangeChanged(position, mList.size()); </code></pre> <p>Each time I call notifyItemChanged(), the items on my recycler view update properly, however, it will blink because this causes onBindViewHolder to be called again. So it's as though it is a fresh load each time. How can I prevent this from happening, if possible?</p>
0debug
SEAGLASS THEME FOR JAVA NO PAINTING : i had implemented a seaglass jar theme for my apllication, but the theme no works i had tried add it into diferentes places of my code but no one location works, someone who help me.. private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 577, 443); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); try { UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { // TODO Auto-generated catch block e.printStackTrace(); } JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); frame.getContentPane().add(tabbedPane, BorderLayout.CENTER); JPanel panel = new JPanel(); tabbedPane.addTab("New tab", null, panel, null); JPanel panel_1 = new JPanel(); tabbedPane.addTab("New tab", null, panel_1, null); JPanel panel_2 = new JPanel(); tabbedPane.addTab("New tab", null, panel_2, null); ......... rest of components. I have already import it as reference into my project, linked it into the build path.
0debug
JavaScript classes exist? : <p>I know classes do not exist in javascript. </p> <p>But, Is there any indirect way to create a class in javascript?</p> <p>what is the use of defining a class in javascript</p>
0debug
a function that takes a character (i.e. a string of length 1) and returns true if it is a vowel, false otherwise in javascript : below is my code for finding out if a character is a vowel or not. But when I run it, it doesn't print out true or false. Can someone please help me to see what I am doing wrong? BTW, I am new to JS. TIA. > <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>finding the vowels in a string</title> </head> <body> <form> <input type = "text" name = 't1'> <input type = 'submit' value = "SUBMIT" onClick = 'return vowel(this.form.t1.v'> <div id="p"></div> </form> <script> var vowel = function(str) { var matches = str.match(/[aeiou]/gi); var count = matches ? matches.length: 0; document.getElementByID('p').innerHTML = "'"+str+"contains"+count+"vowel(s)"; return false; }; vowel(str); </script> </body> </html>
0debug
static void rtsp_cmd_teardown(HTTPContext *c, const char *url, RTSPHeader *h) { HTTPContext *rtp_c; rtp_c = find_rtp_session_with_url(url, h->session_id); if (!rtp_c) { rtsp_reply_error(c, RTSP_STATUS_SESSION); return; } close_connection(rtp_c); rtsp_reply_header(c, RTSP_STATUS_OK); url_fprintf(c->pb, "Session: %s\r\n", rtp_c->session_id); url_fprintf(c->pb, "\r\n"); }
1threat
static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe) { H264BSFContext *ctx = bsfc->priv_data; uint8_t unit_type; int32_t nal_size; uint32_t cumul_size = 0; const uint8_t *buf_end = buf + buf_size; if (!avctx->extradata || avctx->extradata_size < 6) { *poutbuf = (uint8_t*) buf; *poutbuf_size = buf_size; return 0; } if (!ctx->extradata_parsed) { uint16_t unit_size; uint64_t total_size = 0; uint8_t *out = NULL, unit_nb, sps_done = 0; const uint8_t *extradata = avctx->extradata+4; static const uint8_t nalu_header[4] = {0, 0, 0, 1}; ctx->length_size = (*extradata++ & 0x3) + 1; if (ctx->length_size == 3) return AVERROR(EINVAL); unit_nb = *extradata++ & 0x1f; if (!unit_nb) { unit_nb = *extradata++; sps_done++; } while (unit_nb--) { void *tmp; unit_size = AV_RB16(extradata); total_size += unit_size+4; if (total_size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE || extradata+2+unit_size > avctx->extradata+avctx->extradata_size) { av_free(out); return AVERROR(EINVAL); } tmp = av_realloc(out, total_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!tmp) { av_free(out); return AVERROR(ENOMEM); } out = tmp; memcpy(out+total_size-unit_size-4, nalu_header, 4); memcpy(out+total_size-unit_size, extradata+2, unit_size); extradata += 2+unit_size; if (!unit_nb && !sps_done++) unit_nb = *extradata++; } memset(out + total_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); av_free(avctx->extradata); avctx->extradata = out; avctx->extradata_size = total_size; ctx->first_idr = 1; ctx->extradata_parsed = 1; } *poutbuf_size = 0; *poutbuf = NULL; do { if (buf + ctx->length_size > buf_end) goto fail; if (ctx->length_size == 1) { nal_size = buf[0]; } else if (ctx->length_size == 2) { nal_size = AV_RB16(buf); } else nal_size = AV_RB32(buf); buf += ctx->length_size; unit_type = *buf & 0x1f; if (buf + nal_size > buf_end || nal_size < 0) goto fail; if (ctx->first_idr && unit_type == 5) { if (alloc_and_copy(poutbuf, poutbuf_size, avctx->extradata, avctx->extradata_size, buf, nal_size) < 0) goto fail; ctx->first_idr = 0; } else { if (alloc_and_copy(poutbuf, poutbuf_size, NULL, 0, buf, nal_size) < 0) goto fail; if (!ctx->first_idr && unit_type == 1) ctx->first_idr = 1; } buf += nal_size; cumul_size += nal_size + ctx->length_size; } while (cumul_size < buf_size); return 1; fail: av_freep(poutbuf); *poutbuf_size = 0; return AVERROR(EINVAL); }
1threat
static void replication_start(ReplicationState *rs, ReplicationMode mode, Error **errp) { BlockDriverState *bs = rs->opaque; BDRVReplicationState *s; BlockDriverState *top_bs; int64_t active_length, hidden_length, disk_length; AioContext *aio_context; Error *local_err = NULL; aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); s = bs->opaque; if (s->replication_state != BLOCK_REPLICATION_NONE) { error_setg(errp, "Block replication is running or done"); aio_context_release(aio_context); return; } if (s->mode != mode) { error_setg(errp, "The parameter mode's value is invalid, needs %d," " but got %d", s->mode, mode); aio_context_release(aio_context); return; } switch (s->mode) { case REPLICATION_MODE_PRIMARY: break; case REPLICATION_MODE_SECONDARY: s->active_disk = bs->file; if (!s->active_disk || !s->active_disk->bs || !s->active_disk->bs->backing) { error_setg(errp, "Active disk doesn't have backing file"); aio_context_release(aio_context); return; } s->hidden_disk = s->active_disk->bs->backing; if (!s->hidden_disk->bs || !s->hidden_disk->bs->backing) { error_setg(errp, "Hidden disk doesn't have backing file"); aio_context_release(aio_context); return; } s->secondary_disk = s->hidden_disk->bs->backing; if (!s->secondary_disk->bs || !bdrv_has_blk(s->secondary_disk->bs)) { error_setg(errp, "The secondary disk doesn't have block backend"); aio_context_release(aio_context); return; } active_length = bdrv_getlength(s->active_disk->bs); hidden_length = bdrv_getlength(s->hidden_disk->bs); disk_length = bdrv_getlength(s->secondary_disk->bs); if (active_length < 0 || hidden_length < 0 || disk_length < 0 || active_length != hidden_length || hidden_length != disk_length) { error_setg(errp, "Active disk, hidden disk, secondary disk's length" " are not the same"); aio_context_release(aio_context); return; } if (!s->active_disk->bs->drv->bdrv_make_empty || !s->hidden_disk->bs->drv->bdrv_make_empty) { error_setg(errp, "Active disk or hidden disk doesn't support make_empty"); aio_context_release(aio_context); return; } reopen_backing_file(bs, true, &local_err); if (local_err) { error_propagate(errp, local_err); aio_context_release(aio_context); return; } error_setg(&s->blocker, "Block device is in use by internal backup job"); top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL); if (!top_bs || !bdrv_is_root_node(top_bs) || !check_top_bs(top_bs, bs)) { error_setg(errp, "No top_bs or it is invalid"); reopen_backing_file(bs, false, NULL); aio_context_release(aio_context); return; } bdrv_op_block_all(top_bs, s->blocker); bdrv_op_unblock(top_bs, BLOCK_OP_TYPE_DATAPLANE, s->blocker); backup_start(NULL, s->secondary_disk->bs, s->hidden_disk->bs, 0, MIRROR_SYNC_MODE_NONE, NULL, false, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT, BLOCK_JOB_INTERNAL, backup_job_completed, bs, NULL, &local_err); if (local_err) { error_propagate(errp, local_err); backup_job_cleanup(bs); aio_context_release(aio_context); return; } break; default: aio_context_release(aio_context); abort(); } s->replication_state = BLOCK_REPLICATION_RUNNING; if (s->mode == REPLICATION_MODE_SECONDARY) { secondary_do_checkpoint(s, errp); } s->error = 0; aio_context_release(aio_context); }
1threat
Connecting to multiple CloudSQL instances using Cloud sql proxy? : <p>I'm attempting to use the cloud sql proxy to connect to 2 different cloud sql instances...</p> <p>In the docs I found a line about <code>Use -instances parameter. For multiple instances, use a comma-separated list.</code> but not sure how to make that look. <a href="https://cloud.google.com/sql/docs/sql-proxy" rel="noreferrer">https://cloud.google.com/sql/docs/sql-proxy</a>. I'm using Google Container engine, and with a single CloudSQL instance it works great:</p> <pre><code>- name: cloudsql-proxy image: b.gcr.io/cloudsql-docker/gce-proxy:1.05 command: ["/cloud_sql_proxy", "--dir=/cloudsql", "-instances=starchup-147119:us-central1:first-db=tcp:3306", "-credential_file=/secrets/cloudsql/credentials.json"] volumeMounts: - name: cloudsql-oauth-credentials mountPath: /secrets/cloudsql readOnly: true - name: ssl-certs mountPath: /etc/ssl/certs </code></pre> <p>But for multiple I've tried the <code>-instances</code> section as such:</p> <pre><code>-instances=starchup-147119:us-central1:first-db,starchup-147119:us-central1:second-db=tcp:3306 and -instances=starchup-147119:us-central1:first-db=tcp:3306,starchup-147119:us-central1:second-db=tcp:3306 </code></pre> <p>but they all give various errors; <code>ECONNREFUSED 127.0.0.1:3306</code>, <code>ER_DBACCESS_DENIED_ERROR</code>, and <code>ER_ACCESS_DENIED_ERROR</code></p> <p>Any help is much appreciated!</p>
0debug
static int bmdma_rw_buf(IDEDMA *dma, int is_write) { BMDMAState *bm = DO_UPCAST(BMDMAState, dma, dma); IDEState *s = bmdma_active_if(bm); struct { uint32_t addr; uint32_t size; } prd; int l, len; for(;;) { l = s->io_buffer_size - s->io_buffer_index; if (l <= 0) break; if (bm->cur_prd_len == 0) { if (bm->cur_prd_last || (bm->cur_addr - bm->addr) >= BMDMA_PAGE_SIZE) return 0; cpu_physical_memory_read(bm->cur_addr, (uint8_t *)&prd, 8); bm->cur_addr += 8; prd.addr = le32_to_cpu(prd.addr); prd.size = le32_to_cpu(prd.size); len = prd.size & 0xfffe; if (len == 0) len = 0x10000; bm->cur_prd_len = len; bm->cur_prd_addr = prd.addr; bm->cur_prd_last = (prd.size & 0x80000000); } if (l > bm->cur_prd_len) l = bm->cur_prd_len; if (l > 0) { if (is_write) { cpu_physical_memory_write(bm->cur_prd_addr, s->io_buffer + s->io_buffer_index, l); } else { cpu_physical_memory_read(bm->cur_prd_addr, s->io_buffer + s->io_buffer_index, l); } bm->cur_prd_addr += l; bm->cur_prd_len -= l; s->io_buffer_index += l; } } return 1; }
1threat
Converting non existing ASCII char to int in C : <pre><code>int i = 65537; char c = (char) i; printf("%d", c); </code></pre> <p>I'm getting "1" from that and I'm wondering why</p>
0debug
HTML Range Input Sliders disappear on mobile. Why? : <p>Why do HTML5 inputs of type range disappear on mobile? See <a href="http://www.html5tutorial.info/html5-range.php" rel="noreferrer">this</a> page, inspect as a mobile device. I'm working on a simple site with a form but need the form to work on mobile. Thanks!</p>
0debug
need help to fix the compile error of erfc function vba code : Hi I tried to use erfc in my code but it gave me error. it says argument not optional . could you please help me fixing this problem I'm new to programming. an example on that is given below For j = 0 To 150 f = 1 For m = 1 To j f = f * m Next Application.WorksheetFunction.Erf = (Application.WorksheetFunction.Erf) + (-1) ^ j * b ^ (2 * j + 1) / ((2 * j + 1) * f) Next Application.WorksheetFunction.ErfC = 1 - 2 / Sqr(3.14) * Application.WorksheetFunction.Erf MsgBox (Application.WorksheetFunction.ErfC) xf1 = (wa + 2 * sp) * q / (4 * cl ^ 2 * 3.14 * hf) xf2 = Exp(b ^ 2) * Application.WorksheetFunction.ErfC xf3 = 2 * b / Sqr(3.14) - 1 xf = xf1 * (xf2 + xf3) thank you in advance
0debug
Build complex mustach with complex array : I have the following json : { "data":{ "page":{["x":1,"y":2],["x":1,"y":2],["x":1,"y":2]}, "page":{["x":2,"y":2],["x":1,"y":2],["x":1,"y":2]}, "page":{["x":3,"y":2],["x":1,"y":2],["x":1,"y":2]}, } } How can I print the following HTML with a mustache : I tried to do #page then /#page and /data and #data inside but it does not work I would like to print after mustache the following HTML <div class="page"> <div class="data"> <div>x value here></div> <div>y value here></div> </div> <div class="data"> <div>x value here></div> <div>y value here></div> </div> <div class="data"> <div>x value here></div> <div>y value here></div> </div> </div> <div class="page"> <div class="data"> <div>x value here></div> <div>y value here></div> </div> <div class="data"> <div>x value here></div> <div>y value here></div> </div> <div class="data"> <div>x value here></div> <div>y value here></div> </div> </div> <div class="page"> <div class="data"> <div>x value here></div> <div>y value here></div> </div> <div class="data"> <div>x value here></div> <div>y value here></div> </div> <div class="data"> <div>x value here></div> <div>y value here></div> </div> </div>
0debug
Jquery check checkbox value then set checked : <p>I had a checkbox </p> <pre><code>&lt;input type="checkbox" name="paid" id="paid-change"&gt; </code></pre> <p>which will have value = "1" or "0".I want to check if checkbox value = "1" the checkbox will add checked status on it. Tks for your help!</p>
0debug
Android Studio - Firebase : I am building an android app using android studio, and using Firebase as a back-end system. I was trying for hours to find the reason why firebase wasn't working on the emulator of genymotion, however then after I uploaded the app to my personal phone, it worked perfectly. Any idea why firebase doesn't work sometimes on the emulator while it works on an actual device?
0debug
DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error) { const char *buf; const char *file = NULL; char devname[128]; const char *serial; const char *mediastr = ""; BlockInterfaceType type; enum { MEDIA_DISK, MEDIA_CDROM } media; int bus_id, unit_id; int cyls, heads, secs, translation; BlockDriver *drv = NULL; int max_devs; int index; int ro = 0; int bdrv_flags = 0; int on_read_error, on_write_error; const char *devaddr; DriveInfo *dinfo; int snapshot = 0; int ret; *fatal_error = 1; translation = BIOS_ATA_TRANSLATION_AUTO; if (default_to_scsi) { type = IF_SCSI; max_devs = MAX_SCSI_DEVS; pstrcpy(devname, sizeof(devname), "scsi"); } else { type = IF_IDE; max_devs = MAX_IDE_DEVS; pstrcpy(devname, sizeof(devname), "ide"); } media = MEDIA_DISK; bus_id = qemu_opt_get_number(opts, "bus", 0); unit_id = qemu_opt_get_number(opts, "unit", -1); index = qemu_opt_get_number(opts, "index", -1); cyls = qemu_opt_get_number(opts, "cyls", 0); heads = qemu_opt_get_number(opts, "heads", 0); secs = qemu_opt_get_number(opts, "secs", 0); snapshot = qemu_opt_get_bool(opts, "snapshot", 0); ro = qemu_opt_get_bool(opts, "readonly", 0); file = qemu_opt_get(opts, "file"); serial = qemu_opt_get(opts, "serial"); if ((buf = qemu_opt_get(opts, "if")) != NULL) { pstrcpy(devname, sizeof(devname), buf); if (!strcmp(buf, "ide")) { type = IF_IDE; max_devs = MAX_IDE_DEVS; } else if (!strcmp(buf, "scsi")) { type = IF_SCSI; max_devs = MAX_SCSI_DEVS; } else if (!strcmp(buf, "floppy")) { type = IF_FLOPPY; max_devs = 0; } else if (!strcmp(buf, "pflash")) { type = IF_PFLASH; max_devs = 0; } else if (!strcmp(buf, "mtd")) { type = IF_MTD; max_devs = 0; } else if (!strcmp(buf, "sd")) { type = IF_SD; max_devs = 0; } else if (!strcmp(buf, "virtio")) { type = IF_VIRTIO; max_devs = 0; } else if (!strcmp(buf, "xen")) { type = IF_XEN; max_devs = 0; } else if (!strcmp(buf, "none")) { type = IF_NONE; max_devs = 0; } else { error_report("unsupported bus type '%s'", buf); return NULL; } } if (cyls || heads || secs) { if (cyls < 1 || (type == IF_IDE && cyls > 16383)) { error_report("invalid physical cyls number"); return NULL; } if (heads < 1 || (type == IF_IDE && heads > 16)) { error_report("invalid physical heads number"); return NULL; } if (secs < 1 || (type == IF_IDE && secs > 63)) { error_report("invalid physical secs number"); return NULL; } } if ((buf = qemu_opt_get(opts, "trans")) != NULL) { if (!cyls) { error_report("'%s' trans must be used with cyls,heads and secs", buf); return NULL; } if (!strcmp(buf, "none")) translation = BIOS_ATA_TRANSLATION_NONE; else if (!strcmp(buf, "lba")) translation = BIOS_ATA_TRANSLATION_LBA; else if (!strcmp(buf, "auto")) translation = BIOS_ATA_TRANSLATION_AUTO; else { error_report("'%s' invalid translation type", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "media")) != NULL) { if (!strcmp(buf, "disk")) { media = MEDIA_DISK; } else if (!strcmp(buf, "cdrom")) { if (cyls || secs || heads) { error_report("'%s' invalid physical CHS format", buf); return NULL; } media = MEDIA_CDROM; } else { error_report("'%s' invalid media", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "cache")) != NULL) { if (!strcmp(buf, "off") || !strcmp(buf, "none")) { bdrv_flags |= BDRV_O_NOCACHE; } else if (!strcmp(buf, "writeback")) { bdrv_flags |= BDRV_O_CACHE_WB; } else if (!strcmp(buf, "unsafe")) { bdrv_flags |= BDRV_O_CACHE_WB; bdrv_flags |= BDRV_O_NO_FLUSH; } else if (!strcmp(buf, "writethrough")) { } else { error_report("invalid cache option"); return NULL; } } #ifdef CONFIG_LINUX_AIO if ((buf = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(buf, "native")) { bdrv_flags |= BDRV_O_NATIVE_AIO; } else if (!strcmp(buf, "threads")) { } else { error_report("invalid aio option"); return NULL; } } #endif if ((buf = qemu_opt_get(opts, "format")) != NULL) { if (strcmp(buf, "?") == 0) { error_printf("Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL); error_printf("\n"); return NULL; } drv = bdrv_find_whitelisted_format(buf); if (!drv) { error_report("'%s' invalid format", buf); return NULL; } } on_write_error = BLOCK_ERR_STOP_ENOSPC; if ((buf = qemu_opt_get(opts, "werror")) != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("werror is not supported by this bus type"); return NULL; } on_write_error = parse_block_error_action(buf, 0); if (on_write_error < 0) { return NULL; } } on_read_error = BLOCK_ERR_REPORT; if ((buf = qemu_opt_get(opts, "rerror")) != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); return NULL; } on_read_error = parse_block_error_action(buf, 1); if (on_read_error < 0) { return NULL; } } if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) { if (type != IF_VIRTIO) { error_report("addr is not supported by this bus type"); return NULL; } } if (index != -1) { if (bus_id != 0 || unit_id != -1) { error_report("index cannot be used with bus and unit"); return NULL; } if (max_devs == 0) { unit_id = index; bus_id = 0; } else { unit_id = index % max_devs; bus_id = index / max_devs; } } if (unit_id == -1) { unit_id = 0; while (drive_get(type, bus_id, unit_id) != NULL) { unit_id++; if (max_devs && unit_id >= max_devs) { unit_id -= max_devs; bus_id++; } } } if (max_devs && unit_id >= max_devs) { error_report("unit %d too big (max is %d)", unit_id, max_devs - 1); return NULL; } if (drive_get(type, bus_id, unit_id) != NULL) { *fatal_error = 0; return NULL; } dinfo = qemu_mallocz(sizeof(*dinfo)); if ((buf = qemu_opts_id(opts)) != NULL) { dinfo->id = qemu_strdup(buf); } else { dinfo->id = qemu_mallocz(32); if (type == IF_IDE || type == IF_SCSI) mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; if (max_devs) snprintf(dinfo->id, 32, "%s%i%s%i", devname, bus_id, mediastr, unit_id); else snprintf(dinfo->id, 32, "%s%s%i", devname, mediastr, unit_id); } dinfo->bdrv = bdrv_new(dinfo->id); dinfo->devaddr = devaddr; dinfo->type = type; dinfo->bus = bus_id; dinfo->unit = unit_id; dinfo->opts = opts; if (serial) strncpy(dinfo->serial, serial, sizeof(dinfo->serial) - 1); QTAILQ_INSERT_TAIL(&drives, dinfo, next); bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: switch(media) { case MEDIA_DISK: if (cyls != 0) { bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs); bdrv_set_translation_hint(dinfo->bdrv, translation); } break; case MEDIA_CDROM: bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM); break; } break; case IF_SD: case IF_FLOPPY: bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_FLOPPY); break; case IF_PFLASH: case IF_MTD: break; case IF_VIRTIO: opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0); qemu_opt_set(opts, "driver", "virtio-blk-pci"); qemu_opt_set(opts, "drive", dinfo->id); if (devaddr) qemu_opt_set(opts, "addr", devaddr); break; case IF_COUNT: abort(); } if (!file || !*file) { *fatal_error = 0; return NULL; } if (snapshot) { bdrv_flags &= ~BDRV_O_CACHE_MASK; bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH); } if (media == MEDIA_CDROM) { ro = 1; } else if (ro == 1) { if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) { error_report("readonly not supported by this bus type"); return NULL; } } bdrv_flags |= ro ? 0 : BDRV_O_RDWR; ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv); if (ret < 0) { error_report("could not open disk image %s: %s", file, strerror(-ret)); return NULL; } if (bdrv_key_required(dinfo->bdrv)) autostart = 0; *fatal_error = 0; return dinfo; }
1threat
static int shift_data(AVFormatContext *s) { int ret = 0, moov_size; MOVMuxContext *mov = s->priv_data; int64_t pos, pos_end = avio_tell(s->pb); uint8_t *buf, *read_buf[2]; int read_buf_id = 0; int read_size[2]; AVIOContext *read_pb; if (mov->flags & FF_MOV_FLAG_FRAGMENT) moov_size = compute_sidx_size(s); else moov_size = compute_moov_size(s); if (moov_size < 0) return moov_size; buf = av_malloc(moov_size * 2); if (!buf) return AVERROR(ENOMEM); read_buf[0] = buf; read_buf[1] = buf + moov_size; avio_flush(s->pb); ret = avio_open(&read_pb, s->filename, AVIO_FLAG_READ); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Unable to re-open %s output file for " "the second pass (faststart)\n", s->filename); goto end; } pos_end = avio_tell(s->pb); avio_seek(s->pb, mov->reserved_header_pos + moov_size, SEEK_SET); avio_seek(read_pb, mov->reserved_header_pos, SEEK_SET); pos = avio_tell(read_pb); #define READ_BLOCK do { \ read_size[read_buf_id] = avio_read(read_pb, read_buf[read_buf_id], moov_size); \ read_buf_id ^= 1; \ } while (0) READ_BLOCK; do { int n; READ_BLOCK; n = read_size[read_buf_id]; if (n <= 0) break; avio_write(s->pb, read_buf[read_buf_id], n); pos += n; } while (pos < pos_end); avio_close(read_pb); end: av_free(buf); return ret; }
1threat
static int process_input(int file_index) { InputFile *ifile = input_files[file_index]; AVFormatContext *is; InputStream *ist; AVPacket pkt; int ret, i, j; is = ifile->ctx; ret = get_input_packet(ifile, &pkt); if (ret == AVERROR(EAGAIN)) { ifile->eagain = 1; return ret; } if (ret < 0) { if (ret != AVERROR_EOF) { print_error(is->filename, ret); if (exit_on_error) exit_program(1); } ifile->eof_reached = 1; for (i = 0; i < ifile->nb_streams; i++) { ist = input_streams[ifile->ist_index + i]; if (ist->decoding_needed) output_packet(ist, NULL); for (j = 0; j < nb_output_streams; j++) { OutputStream *ost = output_streams[j]; if (ost->source_index == ifile->ist_index + i && (ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE)) close_output_stream(ost); } } return AVERROR(EAGAIN); } reset_eagain(); if (do_pkt_dump) { av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump, is->streams[pkt.stream_index]); } if (pkt.stream_index >= ifile->nb_streams) { report_new_stream(file_index, &pkt); goto discard_packet; } ist = input_streams[ifile->ist_index + pkt.stream_index]; if (ist->discard) goto discard_packet; if(!ist->wrap_correction_done && input_files[file_index]->ctx->start_time != AV_NOPTS_VALUE && ist->st->pts_wrap_bits < 64){ uint64_t stime = av_rescale_q(input_files[file_index]->ctx->start_time, AV_TIME_BASE_Q, ist->st->time_base); uint64_t stime2= stime + (1LL<<ist->st->pts_wrap_bits); ist->wrap_correction_done = 1; if(pkt.dts != AV_NOPTS_VALUE && pkt.dts > stime && pkt.dts - stime > stime2 - pkt.dts) { pkt.dts -= 1LL<<ist->st->pts_wrap_bits; ist->wrap_correction_done = 0; } if(pkt.pts != AV_NOPTS_VALUE && pkt.pts > stime && pkt.pts - stime > stime2 - pkt.pts) { pkt.pts -= 1LL<<ist->st->pts_wrap_bits; ist->wrap_correction_done = 0; } } if (pkt.dts != AV_NOPTS_VALUE) pkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts *= ist->ts_scale; if (pkt.dts != AV_NOPTS_VALUE) pkt.dts *= ist->ts_scale; if (debug_ts) { av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s " "next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%"PRId64"\n", ifile->ist_index + pkt.stream_index, av_get_media_type_string(ist->st->codec->codec_type), av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &AV_TIME_BASE_Q), av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &AV_TIME_BASE_Q), av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base), av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base), input_files[ist->file_index]->ts_offset); } if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && !copy_ts) { int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); int64_t delta = pkt_dts - ist->next_dts; if (is->iformat->flags & AVFMT_TS_DISCONT) { if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE || (delta > 1LL*dts_delta_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || pkt_dts+1<ist->pts){ ifile->ts_offset -= delta; av_log(NULL, AV_LOG_DEBUG, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, ifile->ts_offset); pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); if (pkt.pts != AV_NOPTS_VALUE) pkt.pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); } } else { if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE || (delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ) { av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt.dts, ist->next_dts, pkt.stream_index); pkt.dts = AV_NOPTS_VALUE; } if (pkt.pts != AV_NOPTS_VALUE){ int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q); delta = pkt_pts - ist->next_dts; if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE || (delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ) { av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt.pts, ist->next_dts, pkt.stream_index); pkt.pts = AV_NOPTS_VALUE; } } } } sub2video_heartbeat(ist, pkt.pts); ret = output_packet(ist, &pkt); if (ret < 0) { char buf[128]; av_strerror(ret, buf, sizeof(buf)); av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n", ist->file_index, ist->st->index, buf); if (exit_on_error) exit_program(1); } discard_packet: av_free_packet(&pkt); return 0; }
1threat