problem
stringlengths
26
131k
labels
class label
2 classes
jenkins fails on building a downstream job : <p>I'm trying to trigger a downstream job from my current job like so</p> <pre><code>pipeline { stages { stage('foo') { steps{ build job: 'my-job', propagate: true, wait: true } } } } </code></pre> <p>The purpose is to wait on the job result and fail or succeed according to that result. Jenkins is always failing with the message <code>Waiting for non-job items is not supported</code> . The job mentioned above does not have any parameters and is defined like the rest of my jobs, using multibranch pipeline plugin. </p> <p>All i can think of is that this type of jenkins item is not supported as a build step input, but that seems counterintuitive and would prove to be a blocker to me. Can anyone confirm if this is indeed the case?</p> <p>If so, can anyone suggest any workarounds?</p> <p>Thank you</p>
0debug
Rendering problems in Android studio in the layouts android android-studio : I have installed android studio,and when it started it is showing these messages Rendering problems The following classes could not be found android.support.design.widget.appbarlayout(Fix build path, Create class) android.support.design.widget.CoordinatorLayout(Fix build path,Create class) I have searched alot on the Internet but not getting any correct solution Please help. Thank you. My limits were finished to ask questions. So I edited previous one. But now I am asking it newly once again. Please suggest me a solution.
0debug
How do I view crash reason in iTunes Connect? : <p>Is there any way to get crash information in iTunes Connect? I notice under App Analytics it displays the number of "Opt-in Only Crashes". I press the number under it (in my case 2). This takes me to a page that only seems to show the days that the crash happened. Is there any way I can see useful crash information, for example line of code, etc.?</p>
0debug
When HttpStatusCodeException exception raiesed? : when i use below code , what is the case to get HttpStatusCodeException exception . ResponseEntity<Object> response = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.GET, entity, Object.class); Please can anyone help out ????????
0debug
static struct XenDevice *xen_be_del_xendev(int dom, int dev) { struct XenDevice *xendev, *xnext; xnext = xendevs.tqh_first; while (xnext) { xendev = xnext; xnext = xendev->next.tqe_next; if (xendev->dom != dom) { continue; } if (xendev->dev != dev && dev != -1) { continue; } if (xendev->ops->free) { xendev->ops->free(xendev); } if (xendev->fe) { char token[XEN_BUFSIZE]; snprintf(token, sizeof(token), "fe:%p", xendev); xs_unwatch(xenstore, xendev->fe, token); g_free(xendev->fe); } if (xendev->evtchndev != XC_HANDLER_INITIAL_VALUE) { xc_evtchn_close(xendev->evtchndev); } if (xendev->gnttabdev != XC_HANDLER_INITIAL_VALUE) { xc_gnttab_close(xendev->gnttabdev); } QTAILQ_REMOVE(&xendevs, xendev, next); g_free(xendev); } return NULL; }
1threat
static void notify_event_cb(void *opaque) { }
1threat
Why does `new Array(4).join(""+10) + " Batman!"` return "NaNNaNNaNNaN Batman!" : <p>I saw this snippet in a video online (if anyone can find the link, please feel free to add it to the question). </p> <p>The video was quite short, so there was no explanation as to why JavaScript returns this really random string.</p> <p>This probably has something to do with how JavaScript handles certain types...</p>
0debug
Concatenating two lists : <p>I have a list of lists that looks as follows (I hope I'm right when I said list of lists):</p> <pre><code>['[175', '178', '182', '172', '167', '164]', "['b']"] </code></pre> <p>How can I concatenate the two lists? That is, having a list that looks as follows:</p> <pre><code>[175, 178, 182, 172, 167, 164, b] </code></pre> <p>Any thoughts?</p> <p>Thanks.</p>
0debug
Why does I get the following error " class name" is either invalid or does not result in a WebElement. : Here is the HTML: <button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-dialog-titlebar-close" type="button" role="button" aria-disabled="false" title="close"> The error also includes "InvalidSelectorError: Compound class names not permitted". I am on Selenium 2.53.1, if that helps. I am using Java to write automation scripts.
0debug
importing d3.event into a custom build using rollup : <p>I've got a file <code>d3.custom.build.js</code> like this (simplified):</p> <pre><code>import { range } from 'd3-array'; import { select, selectAll, event } from 'd3-selection'; import { transition } from 'd3-transition'; export default { range, select, selectAll, event, transition }; </code></pre> <p>And a <code>rollup.config.js</code> like this:</p> <pre><code>import nodeResolve from 'rollup-plugin-node-resolve'; export default { entry: './js/vendor/d3-custom-build.js', dest: './js/vendor/d3-custom-built.js', format: 'iife', globals: { d3: 'd3' }, moduleId: 'd3', moduleName: 'd3', plugins: [nodeResolve({ jsnext: true })] }; </code></pre> <p>I want to export to a plain old browser global named 'd3'. I'm calling rollup from a simple npm script. The good news is that almost everything works in the output file, except for one thing: <code>d3.event</code> in browser is always null. No, it's not an issue with events being hijacked on the page. When I swap in the standard full d3 4.0 library into the script tag everything works fine. It's definitely a build issue.</p> <p>The <a href="https://github.com/d3/d3-selection/blob/master/README.md#customEvent" rel="noreferrer">d3 docs</a> warn that bundling <code>event</code> is tricky:</p> <blockquote> <p>If you use Babel, Webpack, or another ES6-to-ES5 bundler, be aware that the value of d3.event changes during an event! An import of d3.event must be a live binding, so you may need to configure the bundler to import from D3’s ES6 modules rather than from the generated UMD bundle; not all bundlers observe jsnext:main. Also beware of conflicts with the window.event global.</p> </blockquote> <p>It appears that setting <code>nodeResolve({ jsnext: true })</code> isn't sufficing. How do I get a live binding in the bundle? Any guidance very appreciated.</p>
0debug
How to check if an integer is already in a list : <p>i'm currently coding my own Sudoku in Windows Forms C# and I currently have Problems how to check if an integer is already in my list.</p> <pre><code>for (int i = 0; i &lt; 9; i++) { List&lt;int&gt; list = new List&lt;int&gt;(); for(int j = 0; j &lt; 9; j++) { list.Add(sodukuPlayfield.grid[i, j]); } } </code></pre> <p>So I add all the number in a row to a list. But after that I wanna check if there is only one number from 1 - 9. How can I solve this?</p> <p>Thank you.</p>
0debug
Typescript tells me property 'padStart' does not exist on type 'string'. Why? : <p>When I type in the chrome dev tools:</p> <pre><code>"1".padStart(2,0) </code></pre> <p>I get </p> <pre><code>"01" </code></pre> <p>But when I write </p> <pre><code>"1".padStart(2,0) </code></pre> <p>in my typescript project</p> <p>I get</p> <pre><code>Property 'padStart' does not exist on type 'string'. </code></pre> <p>Why does Typescript complain? How do I fix this?</p>
0debug
MAKE_ACCESSORS(AVVDPAUContext, vdpau_hwaccel, AVVDPAU_Render2, render2) int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, int level) { VDPAUHWContext *hwctx = avctx->hwaccel_context; VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data; VdpDecoderCreate *create; void *func; VdpStatus status; uint32_t width = (avctx->coded_width + 1) & ~1; uint32_t height = (avctx->coded_height + 3) & ~3; if (hwctx->context.decoder != VDP_INVALID_HANDLE) { vdctx->decoder = hwctx->context.decoder; vdctx->render = hwctx->context.render; return 0; vdctx->device = hwctx->device; vdctx->get_proc_address = hwctx->get_proc_address; status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE, &func); if (status != VDP_STATUS_OK) return vdpau_error(status); else create = func; status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER, &func); if (status != VDP_STATUS_OK) return vdpau_error(status); else vdctx->render = func; status = create(vdctx->device, profile, width, height, avctx->refs, &vdctx->decoder); return vdpau_error(status);
1threat
Unexpected token, expected "," in JSX : <p>I am currently a student working on a react app, and keep getting returned syntax errors for unexpected tokens in my onSubmit() function. It wants commas instead of closing curly brackets, and I do not understand why. I add commas, swap out curly brackets for commas, then do it all over again to no avail. Any ideas where I might be making a mistake?</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>import React from 'react'; import axios from 'axios'; import Info from './Info'; export default class Search extends React.Component{ state = { ingredientName: '', }; change = e =&gt; { this.setState({ [e.target.name] : e.target.value, }); }; onSubmit() { e.preventDefault(); const userInput = JSON.stringify(this.state); axios.get(`https://www.recipepuppy.com/api/?i=${this.state}`).then((res) =&gt; { console.log(res.data), } }; }; render(){ return ( &lt;div&gt; &lt;form&gt; &lt;input name="ingredientName" placeholder="chicken, rice, tomatoes, etc" value={this.state.ingredientName} onChange={e =&gt; this.change(e)}/&gt; &lt;button onClick={e =&gt; this.onSubmit(e)}&gt;Submit&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; ) } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"&gt;&lt;/script&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"&gt;&lt;/script&gt;</code></pre> </div> </div> </p>
0debug
static int mpegts_read_header(AVFormatContext *s) { MpegTSContext *ts = s->priv_data; AVIOContext *pb = s->pb; uint8_t buf[8 * 1024] = {0}; int len; int64_t pos, probesize = #if AV_HAVE_INCOMPATIBLE_LIBAV_ABI s->probesize ? s->probesize : s->probesize2; #else s->probesize; #endif if (ffio_ensure_seekback(pb, probesize) < 0) av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n"); pos = avio_tell(pb); len = avio_read(pb, buf, sizeof(buf)); ts->raw_packet_size = get_packet_size(buf, len); if (ts->raw_packet_size <= 0) { av_log(s, AV_LOG_WARNING, "Could not detect TS packet size, defaulting to non-FEC/DVHS\n"); ts->raw_packet_size = TS_PACKET_SIZE; } ts->stream = s; ts->auto_guess = 0; if (s->iformat == &ff_mpegts_demuxer) { seek_back(s, pb, pos); mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1); mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1); handle_packets(ts, probesize / ts->raw_packet_size); ts->auto_guess = 1; av_log(ts->stream, AV_LOG_TRACE, "tuning done\n"); s->ctx_flags |= AVFMTCTX_NOHEADER; } else { AVStream *st; int pcr_pid, pid, nb_packets, nb_pcrs, ret, pcr_l; int64_t pcrs[2], pcr_h; int packet_count[2]; uint8_t packet[TS_PACKET_SIZE]; const uint8_t *data; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 60, 1, 27000000); st->codec->codec_type = AVMEDIA_TYPE_DATA; st->codec->codec_id = AV_CODEC_ID_MPEG2TS; pcr_pid = -1; nb_pcrs = 0; nb_packets = 0; for (;;) { ret = read_packet(s, packet, ts->raw_packet_size, &data); if (ret < 0) return ret; pid = AV_RB16(data + 1) & 0x1fff; if ((pcr_pid == -1 || pcr_pid == pid) && parse_pcr(&pcr_h, &pcr_l, data) == 0) { finished_reading_packet(s, ts->raw_packet_size); pcr_pid = pid; packet_count[nb_pcrs] = nb_packets; pcrs[nb_pcrs] = pcr_h * 300 + pcr_l; nb_pcrs++; if (nb_pcrs >= 2) break; } else { finished_reading_packet(s, ts->raw_packet_size); } nb_packets++; } ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]); ts->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0]; s->bit_rate = TS_PACKET_SIZE * 8 * 27000000LL / ts->pcr_incr; st->codec->bit_rate = s->bit_rate; st->start_time = ts->cur_pcr; av_log(ts->stream, AV_LOG_TRACE, "start=%0.3f pcr=%0.3f incr=%d\n", st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr); } seek_back(s, pb, pos); return 0; }
1threat
void vnc_flush(VncState *vs) { if (vs->output.offset) vnc_client_write(vs); }
1threat
static void do_video_out(AVFormatContext *s, AVOutputStream *ost, AVInputStream *ist, AVPicture *picture1, int *frame_size) { int n1, n2, nb, i, ret, frame_number, dec_frame_rate; AVPicture *picture, *picture2, *pict; AVPicture picture_tmp1, picture_tmp2; UINT8 *video_buffer; UINT8 *buf = NULL, *buf1 = NULL; AVCodecContext *enc, *dec; #define VIDEO_BUFFER_SIZE (1024*1024) enc = &ost->st->codec; dec = &ist->st->codec; frame_number = ist->frame_number; dec_frame_rate = ist->st->r_frame_rate; n1 = ((INT64)frame_number * enc->frame_rate) / dec_frame_rate; n2 = (((INT64)frame_number + 1) * enc->frame_rate) / dec_frame_rate; nb = n2 - n1; if (nb <= 0) return; video_buffer= av_malloc(VIDEO_BUFFER_SIZE); if(!video_buffer) return; if (do_deinterlace) { int size; size = avpicture_get_size(dec->pix_fmt, dec->width, dec->height); buf1 = av_malloc(size); if (!buf1) return; picture2 = &picture_tmp2; avpicture_fill(picture2, buf1, dec->pix_fmt, dec->width, dec->height); if (avpicture_deinterlace(picture2, picture1, dec->pix_fmt, dec->width, dec->height) < 0) { av_free(buf1); buf1 = NULL; picture2 = picture1; } } else { picture2 = picture1; } if (enc->pix_fmt != dec->pix_fmt) { int size; size = avpicture_get_size(enc->pix_fmt, dec->width, dec->height); buf = av_malloc(size); if (!buf) return; pict = &picture_tmp1; avpicture_fill(pict, buf, enc->pix_fmt, dec->width, dec->height); if (img_convert(pict, enc->pix_fmt, picture2, dec->pix_fmt, dec->width, dec->height) < 0) { fprintf(stderr, "pixel format conversion not handled\n"); goto the_end; } } else { pict = picture2; } if (ost->video_resample) { picture = &ost->pict_tmp; img_resample(ost->img_resample_ctx, picture, pict); } else { picture = pict; } nb=1; for(i=0;i<nb;i++) { if (enc->codec_id != CODEC_ID_RAWVIDEO) { if (same_quality) { enc->quality = dec->quality; } ret = avcodec_encode_video(enc, video_buffer, VIDEO_BUFFER_SIZE, picture); s->oformat->write_packet(s, ost->index, video_buffer, ret, 0); *frame_size = ret; } else { write_picture(s, ost->index, picture, enc->pix_fmt, enc->width, enc->height); } } the_end: av_free(buf); av_free(buf1); av_free(video_buffer); }
1threat
def sum_negativenum(nums): sum_negativenum = list(filter(lambda nums:nums<0,nums)) return sum(sum_negativenum)
0debug
static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { PNGDecContext *psrc = src->priv_data; PNGDecContext *pdst = dst->priv_data; int ret; if (dst == src) return 0; ff_thread_release_buffer(dst, &pdst->picture); if (psrc->picture.f->data[0] && (ret = ff_thread_ref_frame(&pdst->picture, &psrc->picture)) < 0) return ret; if (CONFIG_APNG_DECODER && dst->codec_id == AV_CODEC_ID_APNG) { pdst->width = psrc->width; pdst->height = psrc->height; pdst->bit_depth = psrc->bit_depth; pdst->color_type = psrc->color_type; pdst->compression_type = psrc->compression_type; pdst->interlace_type = psrc->interlace_type; pdst->filter_type = psrc->filter_type; pdst->cur_w = psrc->cur_w; pdst->cur_h = psrc->cur_h; pdst->x_offset = psrc->x_offset; pdst->y_offset = psrc->y_offset; pdst->has_trns = psrc->has_trns; memcpy(pdst->transparent_color_be, psrc->transparent_color_be, sizeof(pdst->transparent_color_be)); pdst->dispose_op = psrc->dispose_op; memcpy(pdst->palette, psrc->palette, sizeof(pdst->palette)); pdst->state |= psrc->state & (PNG_IHDR | PNG_PLTE); ff_thread_release_buffer(dst, &pdst->last_picture); if (psrc->last_picture.f->data[0] && (ret = ff_thread_ref_frame(&pdst->last_picture, &psrc->last_picture)) < 0) return ret; ff_thread_release_buffer(dst, &pdst->previous_picture); if (psrc->previous_picture.f->data[0] && (ret = ff_thread_ref_frame(&pdst->previous_picture, &psrc->previous_picture)) < 0) return ret; } return 0; }
1threat
static av_cold int dfa_decode_init(AVCodecContext *avctx) { DfaContext *s = avctx->priv_data; avctx->pix_fmt = PIX_FMT_PAL8; s->frame_buf = av_mallocz(avctx->width * avctx->height + AV_LZO_OUTPUT_PADDING); if (!s->frame_buf) return AVERROR(ENOMEM); return 0; }
1threat
How to define string literal union type from constants in Typescript : <p>I know I can define string union types to restrict variables to one of the possible string values:</p> <pre><code>type MyType = 'first' | 'second' let myVar:MyType = 'first' </code></pre> <p>I need to construct a type like that from constant strings, e.g:</p> <pre><code>const MY_CONSTANT = 'MY_CONSTANT' const SOMETHING_ELSE = 'SOMETHING_ELSE' type MyType = MY_CONSTANT | SOMETHING_ELSE </code></pre> <p>But for some reason it doesn't work; it says <code>MY_CONSTANT refers to a value, but it being used as a type here</code>.</p> <p>Why does Typescript allow the first example, but doesn't allow the second case? I'm on Typescript 3.4.5</p>
0debug
static int write_elf64_note(DumpState *s) { Elf64_Phdr phdr; int endian = s->dump_info.d_endian; target_phys_addr_t begin = s->memory_offset - s->note_size; int ret; memset(&phdr, 0, sizeof(Elf64_Phdr)); phdr.p_type = cpu_convert_to_target32(PT_NOTE, endian); phdr.p_offset = cpu_convert_to_target64(begin, endian); phdr.p_paddr = 0; phdr.p_filesz = cpu_convert_to_target64(s->note_size, endian); phdr.p_memsz = cpu_convert_to_target64(s->note_size, endian); phdr.p_vaddr = 0; ret = fd_write_vmcore(&phdr, sizeof(Elf64_Phdr), s); if (ret < 0) { dump_error(s, "dump: failed to write program header table.\n"); return -1; } return 0; }
1threat
int pic_read_irq(DeviceState *d) { PICCommonState *s = DO_UPCAST(PICCommonState, dev.qdev, d); int irq, irq2, intno; irq = pic_get_irq(s); if (irq >= 0) { if (irq == 2) { irq2 = pic_get_irq(slave_pic); if (irq2 >= 0) { pic_intack(slave_pic, irq2); } else { if (no_spurious_interrupt_hack) { s->irr &= ~(1<<irq); s->last_irr &= ~(1<<irq); s->isr &= ~(1<<irq); return -1; } irq2 = 7; } intno = slave_pic->irq_base + irq2; } else { intno = s->irq_base + irq; } pic_intack(s, irq); } else { if (no_spurious_interrupt_hack) { return -1; } irq = 7; intno = s->irq_base + irq; } #if defined(DEBUG_PIC) || defined(DEBUG_IRQ_LATENCY) if (irq == 2) { irq = irq2 + 8; } #endif #ifdef DEBUG_IRQ_LATENCY printf("IRQ%d latency=%0.3fus\n", irq, (double)(qemu_get_clock_ns(vm_clock) - irq_time[irq]) * 1000000.0 / get_ticks_per_sec()); #endif DPRINTF("pic_interrupt: irq=%d\n", irq); return intno; }
1threat
Null terminated c chars : **1. Which of the following has , a null terminated character is added at the end?** int main() { char arr[]="sample"; char arr2[6]="sample"; char arr3[7]="sample"; char* strarr="sample"; char* strarr1=arr; char* strarr2=arr2; char* strarr3=arr3; char* str = arr; return 0; } **2. Would `printf("%s",somestr)` fail incase :** - `somestr` is an array of char with no null termination character at end? - `somestr` is a `char*` pointing to a continous location of chars with no null termination character at end?
0debug
Is there still a way to fetch instagram feed without using access token now (06/2016)? : <p>I have an issue that my Instagram API access token keeps expiring frequently and I red the document and understood that although the token wouldn't expire generally, Instagram may decide to expire a token any time for any security reason or whatever reasons. </p> <p>I know that when it expires, I need to set up an authentication process and request for a new token and all those of things. But the problem is that my app is just retrieving my own feeds to show on my own website, once the token expires it doesn't make sense to set up such a process, the only thing I can do is to manually retrieve and update the token in my code. </p> <p>So I was wondering if there is still a way to get feeds without using access token as I am just pulling in my own feeds. Or is there any other way I can solve this issue?</p> <p>Thanks for your help.</p>
0debug
react-native start EACCESS error for setup_env.sh : <p>So, I got my first project in ReactNative to run from Windows for Android OS. Took a checkout on a Mac, configured it in an identical manner and as I try to start the react package manager using <code>react-native start</code> and get the following error:</p> <pre><code>child_process.js:506 throw err; ^ Error: spawnSync /Users/UserName/Desktop/Path/node_modules/react-native/local-cli/setup_env.sh EACCES at exports._errnoException (util.js:1022:11) at spawnSync (child_process.js:461:20) at Object.execFileSync (child_process.js:498:13) at Object.run (/Users/UserName/Desktop/Path/node_modules/react-native/local-cli/cliEntry.js:156:16) at Object.&lt;anonymous&gt; (/usr/local/lib/node_modules/react-native-cli/index.js:117:7) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) </code></pre> <p>I am aware that it only tries to set the ulimit (open file limit) to 2048 which is permissible for non root users. Also tried running the command with sudo giving it root permissions. Running <code>ulimit -a</code> on the machine revealed an open file limit of 256 and I tried changing the default 2048 to this. Tried increasing it to 4096 as well removing the command altogether. Seems to make no difference what so ever and the error persists.</p> <p>Created a new project using <code>react-native init DemoProject</code> and the packager seems to start within that folder so the issue is something else?</p> <p>My package.json is:</p> <pre><code>{ "name": "React Native", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest" }, "dependencies": { "native-base": "^0.5.18", "react": "15.4.1", "react-addons-shallow-compare": "^15.4.1", "react-native": "0.39.2", "react-native-drawer": "^2.3.0", "react-native-icons": "^0.7.1", "react-native-loading-spinner-overlay": "^0.4.1", "react-native-md-textinput": "^2.0.4", "react-native-overlay": "^0.5.0", "react-native-scrollable-tab-view": "^0.7.0", "react-native-tab-view": "0.0.40", "react-redux": "^4.4.6", "react-timer-mixin": "^0.13.3", "redux": "^3.6.0" }, "devDependencies": { "babel-jest": "17.0.2", "babel-preset-react-native": "1.9.0", "jest": "17.0.3", "react-test-renderer": "15.4.1" }, "jest": { "preset": "react-native" } } </code></pre> <p>Also, if it matters I have sinopia, browserify and yarn installed globally.</p> <p>To start with, I am not sure if I should add all local dependencies through npm yet again on the Mac and then just copy my code or that should be fine and something else is amiss.</p> <p>It would be great if I can sort this out without re-adding dependencies. Thanks in advance.</p>
0debug
Why does ffmpeg ignore protocol_whitelist flag when converting https m3u8 stream? : <p>I am attempting to download and convert an m3u8 stream to mp4 using ffmpeg. The command I first tried was</p> <pre><code>ffmpeg -i MIE.m3u8 -c copy -bsf:a aac_adtstoasc -safe 0 -protocol_whitelist file,http,https,tcp,tls,crypto MIE.mp4 </code></pre> <p><em>(see below for contents of <code>MIE.m3u8</code>)</em></p> <p>This failed immediately with error</p> <pre><code>[https @ 0x7fb419607d40] Protocol 'https' not on whitelist 'file,crypto'! MIE.m3u8: Invalid argument </code></pre> <p>(Note that the memory address changes each time.)</p> <p>I discovered the <code>-protocol_whitelist</code> flag and appended <code>-protocol_whitelist file,http,https,tcp,tls,crypto</code> to my command</p> <pre><code>ffmpeg -i MIE.m3u8 -c copy -bsf:a aac_adtstoasc -safe 0 -protocol_whitelist file,http,https,tcp,tls,crypto MIE.mp4 </code></pre> <p>but this still resulted in the same error.</p> <p>Why does <code>ffmpeg</code> appear to ignore the <code>protocol_whitelist</code> flag and parameters?</p> <hr> <p><code>MIE.m3u8</code> (which I managed to fetch from the <a href="http://www.nhk.or.jp/eigo/mission/?das_id=D0005140255_00000" rel="noreferrer">website</a> I am trying to scrape video from) looks like this:</p> <pre><code>#EXTM3U #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=508000,RESOLUTION=640x360,CODECS="avc1.77.30, mp4a.40.2" https://nhk-vh.akamaihd.net/i/das/D0005140/D0005140255_00000_V_000.f4v/index_0_av.m3u8?null=0&amp;id=AgBdrl8GX2UAVyUXA1tF7MYlFTbSF88WtA7oAMDksTsiVdAKPuuREVfi8iXMsOWFp6eQU2sk6dnE9g%3d%3d #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=47000,CODECS="mp4a.40.2" https://nhk-vh.akamaihd.net/i/das/D0005140/D0005140255_00000_V_000.f4v/index_0_a.m3u8?null=0&amp;id=AgBdrl8GX2UAVyUXA1tF7MYlFTbSF88WtA7oAMDksTsiVdAKPuuREVfi8iXMsOWFp6eQU2sk6dnE9g%3d%3d </code></pre>
0debug
X264_init(AVCodecContext *avctx) { X264Context *x4 = avctx->priv_data; x264_param_default(&x4->params); x4->params.pf_log = X264_log; x4->params.p_log_private = avctx; x4->params.i_keyint_max = avctx->gop_size; x4->params.rc.i_bitrate = avctx->bit_rate / 1000; x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000; x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000; x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1; if(avctx->flags & CODEC_FLAG_PASS2) x4->params.rc.b_stat_read = 1; else{ if(avctx->crf){ x4->params.rc.i_rc_method = X264_RC_CRF; x4->params.rc.f_rf_constant = avctx->crf; }else if(avctx->cqp > -1){ x4->params.rc.i_rc_method = X264_RC_CQP; x4->params.rc.i_qp_constant = avctx->cqp; } } if(!(avctx->crf || (avctx->cqp > -1))) x4->params.rc.i_rc_method = X264_RC_ABR; x4->params.i_bframe = avctx->max_b_frames; x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC; x4->params.b_bframe_adaptive = avctx->b_frame_strategy; x4->params.i_bframe_bias = avctx->bframebias; x4->params.b_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID; avctx->has_b_frames= avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames; x4->params.i_keyint_min = avctx->keyint_min; if(x4->params.i_keyint_min > x4->params.i_keyint_max) x4->params.i_keyint_min = x4->params.i_keyint_max; x4->params.i_scenecut_threshold = avctx->scenechange_threshold; x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER; x4->params.i_deblocking_filter_alphac0 = avctx->deblockalpha; x4->params.i_deblocking_filter_beta = avctx->deblockbeta; x4->params.rc.i_qp_min = avctx->qmin; x4->params.rc.i_qp_max = avctx->qmax; x4->params.rc.i_qp_step = avctx->max_qdiff; x4->params.rc.f_qcompress = avctx->qcompress; x4->params.rc.f_qblur = avctx->qblur; x4->params.rc.f_complexity_blur = avctx->complexityblur; x4->params.i_frame_reference = avctx->refs; x4->params.i_width = avctx->width; x4->params.i_height = avctx->height; x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num; x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den; x4->params.i_fps_num = avctx->time_base.den; x4->params.i_fps_den = avctx->time_base.num; x4->params.analyse.inter = 0; if(avctx->partitions){ if(avctx->partitions & X264_PART_I4X4) x4->params.analyse.inter |= X264_ANALYSE_I4x4; if(avctx->partitions & X264_PART_I8X8) x4->params.analyse.inter |= X264_ANALYSE_I8x8; if(avctx->partitions & X264_PART_P8X8) x4->params.analyse.inter |= X264_ANALYSE_PSUB16x16; if(avctx->partitions & X264_PART_P4X4) x4->params.analyse.inter |= X264_ANALYSE_PSUB8x8; if(avctx->partitions & X264_PART_B8X8) x4->params.analyse.inter |= X264_ANALYSE_BSUB16x16; } x4->params.analyse.i_direct_mv_pred = avctx->directpred; x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED; if(avctx->me_method == ME_EPZS) x4->params.analyse.i_me_method = X264_ME_DIA; else if(avctx->me_method == ME_HEX) x4->params.analyse.i_me_method = X264_ME_HEX; else if(avctx->me_method == ME_UMH) x4->params.analyse.i_me_method = X264_ME_UMH; else if(avctx->me_method == ME_FULL) x4->params.analyse.i_me_method = X264_ME_ESA; else if(avctx->me_method == ME_TESA) x4->params.analyse.i_me_method = X264_ME_TESA; else x4->params.analyse.i_me_method = X264_ME_HEX; x4->params.analyse.i_me_range = avctx->me_range; x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; x4->params.analyse.b_bidir_me = avctx->bidir_refine > 0; x4->params.analyse.b_bframe_rdo = avctx->flags2 & CODEC_FLAG2_BRDO; x4->params.analyse.b_mixed_references = avctx->flags2 & CODEC_FLAG2_MIXED_REFS; x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA; x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT; x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP; x4->params.analyse.i_trellis = avctx->trellis; x4->params.analyse.i_noise_reduction = avctx->noise_reduction; if(avctx->level > 0) x4->params.i_level_idc = avctx->level; x4->params.rc.f_rate_tolerance = (float)avctx->bit_rate_tolerance/avctx->bit_rate; if((avctx->rc_buffer_size != 0) && (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)){ x4->params.rc.f_vbv_buffer_init = (float)avctx->rc_initial_buffer_occupancy/avctx->rc_buffer_size; } else x4->params.rc.f_vbv_buffer_init = 0.9; x4->params.rc.f_ip_factor = 1/fabs(avctx->i_quant_factor); x4->params.rc.f_pb_factor = avctx->b_quant_factor; x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; x4->params.rc.psz_rc_eq = avctx->rc_eq; x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR; x4->params.i_log_level = X264_LOG_DEBUG; x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD; x4->params.i_threads = avctx->thread_count; x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT; if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){ x4->params.b_repeat_headers = 0; } x4->enc = x264_encoder_open(&x4->params); if(!x4->enc) return -1; avctx->coded_frame = &x4->out_pic; if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){ x264_nal_t *nal; int nnal, i, s = 0; x264_encoder_headers(x4->enc, &nal, &nnal); for(i = 0; i < nnal; i++) s += 5 + nal[i].i_payload * 4 / 3; avctx->extradata = av_malloc(s); avctx->extradata_size = encode_nals(avctx->extradata, s, nal, nnal); } return 0; }
1threat
def Sum_of_Inverse_Divisors(N,Sum): ans = float(Sum)*1.0 /float(N); return round(ans,2);
0debug
Android - Self Updating app : I'm new to Android development and I would like to ask if a self-updating feature could be possible. The details are: 1. The application is designed as an In House App, not going to be published on Google Play. 2. Will need to run only in Kiosk mode. 3. The self-updating feature will have to work as following: In the settings screen, there will be an Update button that will start downloading the new version of apk. After the apk will be downloaded, it will have to start the updating process automatically. Is this even possible? Thank You.
0debug
static int pte64_check(struct mmu_ctx_hash64 *ctx, target_ulong pte0, target_ulong pte1, int h, int rw, int type) { target_ulong mmask; int access, ret, pp; ret = -1; if ((pte0 & HPTE64_V_VALID) && (h == !!(pte0 & HPTE64_V_SECONDARY))) { mmask = PTE64_CHECK_MASK; pp = (pte1 & HPTE64_R_PP) | ((pte1 & HPTE64_R_PP0) >> 61); ctx->nx = (pte1 & HPTE64_R_N) || (pte1 & HPTE64_R_G); if (HPTE64_V_COMPARE(pte0, ctx->ptem)) { if (ctx->raddr != (hwaddr)-1ULL) { if ((ctx->raddr & mmask) != (pte1 & mmask)) { qemu_log("Bad RPN/WIMG/PP\n"); return -3; } } access = ppc_hash64_pp_check(ctx->key, pp, ctx->nx); ctx->raddr = pte1; ctx->prot = access; ret = ppc_hash64_check_prot(ctx->prot, rw, type); if (ret == 0) { LOG_MMU("PTE access granted !\n"); } else { LOG_MMU("PTE access rejected\n"); } } } return ret; }
1threat
static int write_object(int fd, char *buf, uint64_t oid, int copies, unsigned int datalen, uint64_t offset, bool create, bool cache) { return read_write_object(fd, buf, oid, copies, datalen, offset, true, create, cache); }
1threat
How to remove Chart Copyright? : <p>Look here : <a href="https://jsfiddle.net/oscar11/4qdan7k7/5/" rel="nofollow">https://jsfiddle.net/oscar11/4qdan7k7/5/</a></p> <p>How to remove the words <code>JS chart by amCharts</code>?</p>
0debug
HOW CAN I DO A RECURSIVE PRINT USING CLASS LINKED LIST : //PROTOYPE void Display(); //CALL list.Display(); /*********************************** * Print the contents of the list * ***********************************/ void EmployeeList::Display() { // Temporary pointer newEmployee * tmp; tmp = head; // No employees in the list if(tmp == NULL ) { cout << "\n\n\t\t***THERE IS NO EMPLOYEE INFORMATION STORED YET***\n"; return; } cout << "\n\n" << "\t\t************************************************\n" << "\t\t* Employee IDs and Yearly Salary DataBase *\n" << "\t\t************************************************\n\n"; cout << "\t\t\tEmployee IDs" << setw(20) << right << "Yearly Salaries\n"; // One employee in the list if(tmp->Next() == NULL ) { cout << "\t\t\t " << tmp->empID() << setw(13) << right << " " << "$" << setw(2) << tmp->ySalary() << endl; } else { do { cout << "\t\t\t " << tmp->empID() << setw(13) << " " << right << "$" << setw(2) << tmp->ySalary() << endl; tmp = tmp->Next(); }while(tmp != NULL ); cout << "\n\t\t\t ***Thank You***" << endl; } } I NEED HELP ON WHAT TO WRITE IN ORDER TO DO A RECURSIVE function call FOR Display function. I need to display the list in reverse order from last to first. HOW CAN I DO A RECURSIVE PRINT USING CLASS LINKED LIST I NEED HELP ON WHAT TO WRITE IN ORDER TO DO A RECURSIVE function call FOR Display function. I need to display the list in reverse order from last to first.
0debug
Excel VBA - Understanding of code - use of not, application.intersect, if condition in one line : ***Private Sub Worksheet_Change(ByVal Target as Range) Dim Keycells as range Set Keycells = Range("Search_String") *If not application.intersect(Keycells, Range(Target.Address)) is nothing then msgbox "Working" End If* end sub***
0debug
sumofsubset always returning 1 : can anyone help ! ** <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> #include<iostream> using namespace std; bool sum1(int arr[],int sum,int k,int tsum,int m,int n) { if(sum+arr[k]==m) { return true; } else if(sum+arr[k]+arr[k+1]<=m) { sum1(arr,sum+arr[k],k+1,tsum-arr[k],m,n); } if((sum+tsum-arr[k]>=m) && (sum+arr[k+1]<=m)) { sum1(arr,sum,k+1,tsum-arr[k],m,n); } else if(k>n) { return false; } //return false; } int main() { int arr[]={7,11,13,24}; if(sum1(arr,0,1,55,1,4)) { cout<<1; } else{ cout<<0; } } <!-- end snippet --> ** why this code is always returning 1 as result ,i am finding out the sum of subset ..this code is always returning true !!can anyone help me .
0debug
static void sdram_set_bcr (uint32_t *bcrp, uint32_t bcr, int enabled) { if (*bcrp & 0x00000001) { #ifdef DEBUG_SDRAM printf("%s: unmap RAM area " TARGET_FMT_plx " " TARGET_FMT_lx "\n", __func__, sdram_base(*bcrp), sdram_size(*bcrp)); #endif cpu_register_physical_memory(sdram_base(*bcrp), sdram_size(*bcrp), IO_MEM_UNASSIGNED); } *bcrp = bcr & 0xFFDEE001; if (enabled && (bcr & 0x00000001)) { #ifdef DEBUG_SDRAM printf("%s: Map RAM area " TARGET_FMT_plx " " TARGET_FMT_lx "\n", __func__, sdram_base(bcr), sdram_size(bcr)); #endif cpu_register_physical_memory(sdram_base(bcr), sdram_size(bcr), sdram_base(bcr) | IO_MEM_RAM); } }
1threat
An unknown bug in my simple inline assembly code : inline void addition(double * x, const double * vx,uint32_t size){ /*for (uint32_t i=0;i<size;++i){ x[i] = x[i] + vx[i]; }*/ __asm__ __volatile__ ( "1: \n\t" "vmovupd -32(%0), %%ymm1\n\t" "vmovupd (%0), %%ymm0\n\t" "vaddpd -32(%1), %%ymm0, %%ymm0\n\t" "vaddpd (%1), %%ymm1, %%ymm1\n\t" "vmovupd %%ymm0, -32(%0)\n\t" "vmovupd %%ymm1, (%0)\n\t" "addq $128, %0\n\t" "addq $128, %1\n\t" "addl $-8, %2\n\t" "jne 1b" : : "r" (x),"r"(vx),"r"(size) : "ymm0", "ymm1" ); } I am practicing assembly(AVX instructions) right now so I write the above piece of code in inline assembly to replace the c code in the original function(which is commented out). The compiling process is successful but when I try to run the program, An error happens: `Bus error: 10` Any thoughts to this bug? I didn't know what's wrong here. The compiler version is clang 602.0.53. Thank you!
0debug
static void tcx_rstip_writel(void *opaque, hwaddr addr, uint64_t val, unsigned size) { TCXState *s = opaque; int i; uint32_t col; if (!(addr & 4)) { s->tmpblit = val; } else { addr = (addr >> 3) & 0xfffff; col = cpu_to_be32(s->tmpblit); if (s->depth == 24) { for (i = 0; i < 32; i++) { if (val & 0x80000000) { s->vram[addr + i] = s->tmpblit; s->vram24[addr + i] = col; s->cplane[addr + i] = col; } val <<= 1; } } else { for (i = 0; i < 32; i++) { if (val & 0x80000000) { s->vram[addr + i] = s->tmpblit; } val <<= 1; } } memory_region_set_dirty(&s->vram_mem, addr, 32); } }
1threat
(Beginner) Switching letters in a character string with "#" if they aren't in a char array : void funOne(char a[], string b, int aL, int bL){ int cnt[aL]={0}; for(int i=0; i<bL; i++){ for(int j=0; j<aL; j++){ if((char)b[i]==a[j];{ cnt[j]++; break; } } } for(int i=0; i<bL; i++){ for(int j=0; j<aL; j++){ if((char)b[i]==a[j]&&cnt=0) { b[i]='#'; break; }}} There is a char arr[]={'H', 't', 'h', 's', 'e', 'i'}; and a character string "Sherlock Holmes is a fiction private detective" Every character that's not in the array should be replaced with "#" in the string. The output should be "She##### H###es is # #i#ti#n ##i##te #ete#ti#e" There is something wrong with my code but I don't know what.
0debug
How to reconnect to RabbitMQ? : <p>My python script constantly has to send messages to RabbitMQ once it receives one from another data source. The frequency in which the python script sends them can vary, say, 1 minute - 30 minutes.</p> <p>Here's how I establish a connection to RabbitMQ:</p> <pre><code> rabt_conn = pika.BlockingConnection(pika.ConnectionParameters("some_host")) channel = rbt_conn.channel() </code></pre> <p>I just got an exception </p> <pre><code>pika.exceptions.ConnectionClosed </code></pre> <p>How can I reconnect to it? What's the best way? Is there any "strategy"? Is there an ability to send pings to keep a connection alive or set timeout?</p> <p>Any pointers will be appreciated.</p>
0debug
Using timestamp as a key in python dict : #My code import time timestamp = lambda: int(round(time.time() * 1000)) a = [1 ,2 ,3 , 4 , 5] b = {} for i in a: b[timestamp()] = i print(b) #My output > {1535959066086: 5} #The problem The timestamp is not unique... The process is too fast that the timestamp stays the same and it does not make different keys any advice to have a different timestamp would be appreciated
0debug
How to show random texts from a .txt file on my webpage each time the visitor reloads? : <p>As example I have a list of texts on my .txt file.</p> <pre><code>text1 text2 text3 </code></pre> <p>And I want to show only one text of them randomly selected from the .txt file using php.</p>
0debug
React Native Android: Fetch Requests only working when React Native Debugger is connected : <p>I have a weird issue with making fetch requests to my API on Android (using React Apollo). In the dev build as well as the release build fetch does not work. As soon as I power up React Native Debugger and enable <em>Enable Network Inspect</em> the requests work.</p> <p>I have no idea how to debug the requests as they are not shown in the debugger without Network Inspect enabled.</p> <p>Any ideas how I could find the error or did anyone of you run into the same issue?</p>
0debug
Error Messages when I try to load ggplot2 after installatio : I get an error message when i try to load ggplot2 even after download. Even when i tried: install.packages('ggplot2',dependencies = T) I get the following error message: No package called 'Rcpp' Error:package or namespace load failed for ggplot2. Then i try: install.packages('Rcpp') i get Rcpp successfully downloaded, but when i try to load ggplot2 i get thesame error message: No package called 'Rcpp' Error:package or namespace load failed for ggplot2. I was using R 3.2.1 but updated to R 3.2.3 I would appreciate any meaningful help.
0debug
java.lang.IllegalArgumentException: Invalid character (CR or LF) found in method name : <p>I have a Spring MVC application running on Tomcat8. Once in a day or two I get an exception in my log file</p> <pre><code>15-Jun-2016 10:43:39.832 INFO [http-nio-8080-exec-50] org.apache.coyote.http11.AbstractHttp11Processor.process Error parsing HTTP request header Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level. java.lang.IllegalArgumentException: Invalid character (CR or LF) found in method name at org.apache.coyote.http11.AbstractNioInputBuffer.parseRequestLine(AbstractNioInputBuffer.java:228) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) </code></pre> <p>does anybody have an idea what this might be?</p>
0debug
How to undo a commit in freshly initialized repository (not pushed) : <p>I intialized a repo but now want to <a href="https://stackoverflow.com/questions/2845731/how-to-uncommit-my-last-commit-in-git">undo</a> the <strong>first</strong> (and only) commit. </p> <p>These <a href="https://stackoverflow.com/a/2846154/5783745">three solutions</a> for undoing a commit all error because the <a href="https://stackoverflow.com/questions/12267912/git-fatal-ambiguous-argument-head-unknown-revision-or-path-not-in-the-workin">freshly created repo points to a ref that doesn't exist yet</a></p> <p>So my question is how do I undo a commit in a repo that hasn't been pushed and hence hasn't got a ref yet? </p> <p>Note: I have also tried <code>git commit -amend</code> without success</p>
0debug
static void test_visitor_out_native_list_int32(TestOutputVisitorData *data, const void *unused) { test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S32); }
1threat
no persistent volumes available for this claim and no storage class is set : <p>my pvc.yaml</p> <pre><code>kind: PersistentVolumeClaim apiVersion: v1 metadata: name: database-disk labels: stage: production name: database app: mysql spec: accessModes: - ReadWriteOnce volumeMode: Filesystem resources: requests: storage: 2Gi </code></pre> <p>when i ran <code>kubectl apply -f pvc.yaml</code> i got the following error <code>Normal FailedBinding 12h (x83 over 13h) persistentvolume-controller no persistent volumes available for this claim and no storage class is set</code></p> <p>same pvc worked fine on "GKE" (Google Kubernetes Engine) but failing in my local cluster using <a href="https://github.com/ubuntu/microk8s" rel="noreferrer">microk8s</a></p>
0debug
Rename branch in Gitkraken? : <p>How do you rename a branch in Gitkraken?</p> <p>I know how to do it from the CLI, can you do it from the GUI (or terminal - if there is some - in Gitkraken?)</p> <p>Thanks!</p>
0debug
int xen_pt_msix_init(XenPCIPassthroughState *s, uint32_t base) { uint8_t id = 0; uint16_t control = 0; uint32_t table_off = 0; int i, total_entries, bar_index; XenHostPCIDevice *hd = &s->real_device; PCIDevice *d = &s->dev; int fd = -1; XenPTMSIX *msix = NULL; int rc = 0; rc = xen_host_pci_get_byte(hd, base + PCI_CAP_LIST_ID, &id); if (rc) { return rc; } if (id != PCI_CAP_ID_MSIX) { XEN_PT_ERR(d, "Invalid id %#x base %#x\n", id, base); return -1; } xen_host_pci_get_word(hd, base + PCI_MSIX_FLAGS, &control); total_entries = control & PCI_MSIX_FLAGS_QSIZE; total_entries += 1; s->msix = g_malloc0(sizeof (XenPTMSIX) + total_entries * sizeof (XenPTMSIXEntry)); msix = s->msix; msix->total_entries = total_entries; for (i = 0; i < total_entries; i++) { msix->msix_entry[i].pirq = XEN_PT_UNASSIGNED_PIRQ; } memory_region_init_io(&msix->mmio, OBJECT(s), &pci_msix_ops, s, "xen-pci-pt-msix", (total_entries * PCI_MSIX_ENTRY_SIZE + XC_PAGE_SIZE - 1) & XC_PAGE_MASK); xen_host_pci_get_long(hd, base + PCI_MSIX_TABLE, &table_off); bar_index = msix->bar_index = table_off & PCI_MSIX_FLAGS_BIRMASK; table_off = table_off & ~PCI_MSIX_FLAGS_BIRMASK; msix->table_base = s->real_device.io_regions[bar_index].base_addr; XEN_PT_LOG(d, "get MSI-X table BAR base 0x%"PRIx64"\n", msix->table_base); fd = open("/dev/mem", O_RDWR); if (fd == -1) { rc = -errno; XEN_PT_ERR(d, "Can't open /dev/mem: %s\n", strerror(errno)); goto error_out; } XEN_PT_LOG(d, "table_off = %#x, total_entries = %d\n", table_off, total_entries); msix->table_offset_adjust = table_off & 0x0fff; msix->phys_iomem_base = mmap(NULL, total_entries * PCI_MSIX_ENTRY_SIZE + msix->table_offset_adjust, PROT_READ, MAP_SHARED | MAP_LOCKED, fd, msix->table_base + table_off - msix->table_offset_adjust); close(fd); if (msix->phys_iomem_base == MAP_FAILED) { rc = -errno; XEN_PT_ERR(d, "Can't map physical MSI-X table: %s\n", strerror(errno)); goto error_out; } msix->phys_iomem_base = (char *)msix->phys_iomem_base + msix->table_offset_adjust; XEN_PT_LOG(d, "mapping physical MSI-X table to %p\n", msix->phys_iomem_base); memory_region_add_subregion_overlap(&s->bar[bar_index], table_off, &msix->mmio, 2); return 0; error_out: g_free(s->msix); s->msix = NULL; return rc; }
1threat
static void test_vector_dmul_scalar(const double *src0, const double *src1) { LOCAL_ALIGNED_32(double, cdst, [LEN]); LOCAL_ALIGNED_32(double, odst, [LEN]); int i; declare_func(void, double *dst, const double *src, double mul, int len); call_ref(cdst, src0, src1[0], LEN); call_new(odst, src0, src1[0], LEN); for (i = 0; i < LEN; i++) { if (!double_near_abs_eps(cdst[i], odst[i], DBL_EPSILON)) { fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", i, cdst[i], odst[i], cdst[i] - odst[i]); fail(); break; } } bench_new(odst, src0, src1[0], LEN); }
1threat
def merge(a,b): c = [] while len(a) != 0 and len(b) != 0: if a[0] < b[0]: c.append(a[0]) a.remove(a[0]) else: c.append(b[0]) b.remove(b[0]) if len(a) == 0: c += b else: c += a return c def merge_sort(x): if len(x) == 0 or len(x) == 1: return x else: middle = len(x)//2 a = merge_sort(x[:middle]) b = merge_sort(x[middle:]) return merge(a,b)
0debug
beginner level: button not calling my js function : Why does the alert not work? Actually I wanted to ask something else but I cannot get this working since 20 minutes, what's the problem? `<button id="mybutton" type="button" onclick="add()">Add</button>` https://jsfiddle.net/k86mg0aj/
0debug
How to fix NoSuchElementExeption in Java : <p>I've made a simple game with 2 classes. It uses a scanner and when I try it it says java.util.NoSuchElementExeption. It also says the errors are on row 19 in RNGlog and 24 in RNG. Please help</p> <p>First class: RNG</p> <pre><code>public class RNG { public static void main(String[] args) { RNGlog log = new RNGlog(); int max = log.max(); int min = log.min(); double counter = 3; //Variables outside of loop System.out.println("Write a number between " + max + " and " + min + "."); System.out.println("If your number is higher than " + max + ", it will be " + max + ". Vice versa for " + min + "."); System.out.println("If your number is higher than the random number, you win credits!"); System.out.println("You start with 2 credits."); System.out.println("You lose if you hit 0 credits. Good luck!"); //Introduction while(counter &gt; 0) { //Loop start double r = Math.random() * 10; float in = log.getIn(); //Error here //Random number generator, input double credit = 6 - in; //Credit Win generator if(in &gt; r) { counter = counter + credit; //Counter refresh System.out.println("Great job! The number was " + r + "."); System.out.println("You won " + credit + " credits. Nice."); System.out.println("Credit counter:" + counter + "."); //Winning messages } else { counter = counter - 1; //Counter refresh System.out.println("Nearly, n00b! It was " + r + ", how did u no realize."); System.out.println("You lost 1 credits!"); System.out.println("Credit counter:" + counter + "."); //Losing messages } if(counter &lt;= 0) { System.out.println("Game over! Better luck next time."); //Game ender } } } </code></pre> <p>}</p> <p>Second class: RNGlog</p> <pre><code>import java.util.Scanner; public class RNGlog { int max() { int max = 6; return max; } int min() { int min = 0; return min; } float getIn() { Scanner scan = new Scanner(System.in); float imp = scan.nextFloat(); //Error here if(imp &lt; min()) { imp = min(); } //Stops number lower than 0 if(imp &gt; max()) { imp = max(); } //Stops numbers higher than 6 scan.close(); return imp; } </code></pre> <p>}</p> <p>Would be really apriciated if someone could help!</p>
0debug
How to properly include css/js in an Angular2+ distribution : I'm trying to implement an Admin Template I used in classic my classic php application in a new Angular5 project. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="icon" type="image/png" sizes="16x16" href="/plugins/images/favicon.png"> <title>Ample Admin Template - The Ultimate Multipurpose admin template</title> <link href="/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> <link href="/plugins/bower_components/sidebar-nav/dist/sidebar-nav.min.css" rel="stylesheet"> <link href="/css/animate.css" rel="stylesheet"> <link href="/css/style.css" rel="stylesheet"> <link href="/css/colors/blue-dark.css" id="theme" rel="stylesheet"> </head> <body> <app-root></app-root> </body> </html> The application is properly rendered by now I have some questions: 1. How can I include these css/js package (and all the dependencies) in an Angular distribution? 2. What is the properly way to includes external css/libraries in Angular2+ ? Thanks to support
0debug
int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags) { return set_format(obj, name, fmt, search_flags, AV_OPT_TYPE_SAMPLE_FMT, "sample", AV_SAMPLE_FMT_NB-1); }
1threat
Failed to make the following project runnable (Object reference not set to an instance of an object.) : <p>When I create default web project in Visual Studio 2015 (Update 3) with installed .NET Core 1.0 SDK and Tooling (preview 2) and restart the Visual Studio after reverting local source control changes I am getting the following <strong>compilation error</strong>:</p> <blockquote> <p>Failed to make the following project runnable: MyDefaultWebProject (.NETCoreApp,Version=v1.0) reason: Object reference not set to an instance of an object.</p> </blockquote> <p>According to Visual Studio the error is located in <code>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets</code> on line 262</p> <p>On this line there is the following code:</p> <pre><code>&lt;Dnx RuntimeExe="$(SDKToolingExe)" Condition="'$(_DesignTimeHostBuild)' != 'true'" ProjectFolder="$(MSBuildProjectDirectory)" Arguments="$(_BuildArguments)" /&gt; </code></pre> <p>How can I fix such a problem?</p>
0debug
CSS Color overlay with background image : <p>I am able to set a background image that covers a page but the green overlay does not work. What am I doing wrong? Thank you.</p> <pre><code>body { margin: 0 auto; padding: 0; background: url("../images/worldmap.jpg") no-repeat rgba(0,255,0,.5); /*background-image: url("../images/worldmap.jpg");*/ /*background-repeat: no-repeat;*/ } </code></pre>
0debug
Which is Best web server for JAVA applications in terms of resources and features? : <p>I am going to select a web server for java based web application which requires access to all features of Java Enterprise Edition and have no issue in terms of resources required for my application. Which is BEST WEB SERVER to choose in this case.</p>
0debug
CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, void (*init)(struct CharDriverState *s), Error **errp) { CharDriver *cd; CharDriverState *chr; GSList *i; if (qemu_opts_id(opts) == NULL) { error_setg(errp, "chardev: no id specified"); goto err; } if (qemu_opt_get(opts, "backend") == NULL) { error_setg(errp, "chardev: \"%s\" missing backend", qemu_opts_id(opts)); goto err; } for (i = backends; i; i = i->next) { cd = i->data; if (strcmp(cd->name, qemu_opt_get(opts, "backend")) == 0) { break; } } if (i == NULL) { error_setg(errp, "chardev: backend \"%s\" not found", qemu_opt_get(opts, "backend")); goto err; } if (!cd->open) { ChardevBackend *backend = g_new0(ChardevBackend, 1); ChardevReturn *ret = NULL; const char *id = qemu_opts_id(opts); const char *bid = NULL; if (qemu_opt_get_bool(opts, "mux", 0)) { bid = g_strdup_printf("%s-base", id); } chr = NULL; backend->kind = cd->kind; if (cd->parse) { cd->parse(opts, backend, errp); if (error_is_set(errp)) { goto qapi_out; } } ret = qmp_chardev_add(bid ? bid : id, backend, errp); if (error_is_set(errp)) { goto qapi_out; } if (bid) { qapi_free_ChardevBackend(backend); qapi_free_ChardevReturn(ret); backend = g_new0(ChardevBackend, 1); backend->mux = g_new0(ChardevMux, 1); backend->kind = CHARDEV_BACKEND_KIND_MUX; backend->mux->chardev = g_strdup(bid); ret = qmp_chardev_add(id, backend, errp); if (error_is_set(errp)) { goto qapi_out; } } chr = qemu_chr_find(id); qapi_out: qapi_free_ChardevBackend(backend); qapi_free_ChardevReturn(ret); return chr; } chr = cd->open(opts); if (!chr) { error_setg(errp, "chardev: opening backend \"%s\" failed", qemu_opt_get(opts, "backend")); goto err; } if (!chr->filename) chr->filename = g_strdup(qemu_opt_get(opts, "backend")); chr->init = init; if (!chr->explicit_be_open) { qemu_chr_be_event(chr, CHR_EVENT_OPENED); } QTAILQ_INSERT_TAIL(&chardevs, chr, next); if (qemu_opt_get_bool(opts, "mux", 0)) { CharDriverState *base = chr; int len = strlen(qemu_opts_id(opts)) + 6; base->label = g_malloc(len); snprintf(base->label, len, "%s-base", qemu_opts_id(opts)); chr = qemu_chr_open_mux(base); chr->filename = base->filename; chr->avail_connections = MAX_MUX; QTAILQ_INSERT_TAIL(&chardevs, chr, next); } else { chr->avail_connections = 1; } chr->label = g_strdup(qemu_opts_id(opts)); chr->opts = opts; return chr; err: qemu_opts_del(opts); return NULL; }
1threat
static int probe(AVProbeData *p) { unsigned i, frames, checked = 0; if (p->buf_size < 22 || AV_RL16(p->buf) || AV_RL16(p->buf + 2) != 1) return 0; frames = AV_RL16(p->buf + 4); if (!frames) return 0; for (i = 0; i < frames && i * 16 + 22 <= p->buf_size; i++) { unsigned offset; if (AV_RL16(p->buf + 10 + i * 16) & ~1) return FFMIN(i, AVPROBE_SCORE_MAX / 4); if (p->buf[13 + i * 16]) return FFMIN(i, AVPROBE_SCORE_MAX / 4); if (AV_RL32(p->buf + 14 + i * 16) < 40) return FFMIN(i, AVPROBE_SCORE_MAX / 4); offset = AV_RL32(p->buf + 18 + i * 16); if (offset < 22) return FFMIN(i, AVPROBE_SCORE_MAX / 4); if (offset + 8 > p->buf_size) continue; if (p->buf[offset] != 40 && AV_RB64(p->buf + offset) != PNGSIG) return FFMIN(i, AVPROBE_SCORE_MAX / 4); checked++; } if (checked < frames) return AVPROBE_SCORE_MAX / 4 + FFMIN(checked, 1); return AVPROBE_SCORE_MAX / 2 + 1; }
1threat
Multiples-keys dictionary where key order doesn't matter : <p>I am trying to create a dictionary with two strings as a key and I want the keys to be in whatever order.</p> <pre><code>myDict[('A', 'B')] = 'something' myDict[('B', 'A')] = 'something else' print(myDict[('A', 'B')]) </code></pre> <p>I want this piece of code to print 'something else'. Unfortunately, it seems that the ordering matters with tuples. What would be the best data structure to use as the key?</p>
0debug
static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts) { CharDriverState *chr; if (is_daemonized()) { error_report("cannot use stdio with -daemonize"); return NULL; } old_fd0_flags = fcntl(0, F_GETFL); tcgetattr (0, &oldtty); qemu_set_nonblock(0); atexit(term_exit); chr = qemu_chr_open_fd(0, 1); chr->chr_close = qemu_chr_close_stdio; chr->chr_set_echo = qemu_chr_set_echo_stdio; if (opts->has_signal) { stdio_allow_signal = opts->signal; } qemu_chr_fe_set_echo(chr, false); return chr; }
1threat
ALIGN JLABEL TO LEFT OR RIGHT ON JPANEL : Please how do i move/align the Yellow colored Jlabel in the JPanel to right AND other Jlabel to the left.
0debug
How to ask ruby pry to stop all other threads : <p>I'm trying to debug a multithreaded ruby script, the problem is when I do</p> <pre><code>binding.pry </code></pre> <p>The other threads continue sending output to the console. How do I make them stop at binding.pry and then start up again when I exit? I'm thinking there's a way to do this in .pryrc</p>
0debug
static void aio_rfifolock_cb(void *opaque) { aio_notify(opaque); }
1threat
Offline sync and event sourcing : <p>The CRUD-based part of our application needs:</p> <ol> <li>Offline bidirectional "two-way" syncing</li> <li>Ability to modify data until ready and then "publish".</li> <li>Audit log</li> </ol> <p>Event Sourcing (or the "command pattern") is what I'm looking at to accomplish these items. I feel comfortable with solving 2&amp;3 with this, but not clear for item one, syncing. </p> <p>If timestamps are used for each command (if needed), do the offline commands need to be applied to master system as they would have been in real-time (coalesced), or can I just consider them applied as happening at the end of any command (with a more recent timestamp)? </p> <p>Any basic algorithm description for command-based sync would be helpful.</p>
0debug
static inline void stl_phys_internal(hwaddr addr, uint32_t val, enum device_endian endian) { uint8_t *ptr; MemoryRegionSection *section; hwaddr l = 4; hwaddr addr1; section = address_space_translate(&address_space_memory, addr, &addr1, &l, true); if (l < 4 || !memory_region_is_ram(section->mr) || section->readonly) { if (memory_region_is_ram(section->mr)) { section = &phys_sections[phys_section_rom]; } #if defined(TARGET_WORDS_BIGENDIAN) if (endian == DEVICE_LITTLE_ENDIAN) { val = bswap32(val); } #else if (endian == DEVICE_BIG_ENDIAN) { val = bswap32(val); } #endif io_mem_write(section->mr, addr1, val, 4); } else { addr1 += memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK; ptr = qemu_get_ram_ptr(addr1); switch (endian) { case DEVICE_LITTLE_ENDIAN: stl_le_p(ptr, val); break; case DEVICE_BIG_ENDIAN: stl_be_p(ptr, val); break; default: stl_p(ptr, val); break; } invalidate_and_set_dirty(addr1, 4); } }
1threat
Exporting In-House iOS app says certificate "Unknown", profile "none"? : <p>I put together a test app simply to test In-House distribution through our Enterprise Developer Account.</p> <p>Before archiving I checked that all signing settings looked good. Debug and Release show the correct provisioning profile and certificate.</p> <p>Then I ARCHIVE the app. The prompts show this:</p> <p><a href="https://i.stack.imgur.com/hqg9O.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hqg9O.png" alt="enter image description here"></a></p> <p>The correct cert and provisioning profile are shown. As the archive route continues I get to this screen:</p> <p><a href="https://i.stack.imgur.com/0UHYo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0UHYo.png" alt="enter image description here"></a></p> <p>I am trying to understand why it says: Certificate "Unknown" and Profile "None"</p> <p>As I then try to distribute this through our MDM solution it never installs.</p> <p>My question is: when distributing in-house enterprise apps, is it correct to see Certificate "Unknown" and Profile "None"?</p>
0debug
Spark Yarn Architecture : <p><a href="https://i.stack.imgur.com/cheHp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cheHp.png" alt="enter image description here"></a></p> <p>I had a question regarding this image in a tutorial I was following. So based on this image in a yarn based architecture does the execution of a spark application look something like this:</p> <p>First you have a driver which is running on a client node or some data node. In this driver (similar to a driver in java?) consists of your code (written in java, python, scala, etc.) that you submit to the Spark Context. Then that spark context represents the connection to HDFS and submits your request to the Resource manager in the Hadoop ecosystem. Then the resource manager communicates with the Name node to figure out which data nodes in the cluster contain the information the client node asked for. The spark context will also put a executor on the worker node that will run the tasks. Then the node manager will start the executor which will run the tasks given to it by the Spark Context and will return back the data the client asked for from the HDFS to the driver. </p> <p>Is the above interpretation correct?</p> <p>Also would a driver send out three executors to each data node to retrieve the data from the HDFS, since the data in HDFS is replicated 3 times on various data nodes?</p>
0debug
def intersection_nested_lists(l1, l2): result = [[n for n in lst if n in l1] for lst in l2] return result
0debug
Karabiner for Linux? : <p><strong>Background</strong>: for the past five years or so, I have been using Mac hardware (high end MacBook Pro laptops for the most part) and software after many years of using Gnu/Linux on typical PC hardware with ergonomic keyboards. More importantly, as a heavy Emacs user, the switch to Mac was painful, with the Apple standard short keyboard both maddening and unavoidable. I prevented <a href="https://www.emacswiki.org/emacs/RepeatedStrainInjury" rel="noreferrer">RSI</a> onset by using the <a href="https://pqrs.org/osx/karabiner/" rel="noreferrer">Karabiner</a> tool to make two small but very important changes: 1) changing the capslock key to generate a menu (f13) key when pressed alone and a control key modified keycode when pressed with another key; 2) changing the return key in a similar fashion, get return when pressed alone and a control key modified keycode when pressed with another key. Disappointed with recent Apple decisions for both hardware and software, I am now moving back to Gnu/Linux (Ubuntu if it matters) but sticking with Mac laptops.</p> <p><strong>Question</strong>: since Karabiner is an OS X only tool with no readily available Gnu/Linux counterpart, it looks like I will have to write and/or modify some code to achieve the capslock and return key dual function behaviors Karabiner enables. The Karabiner author <a href="https://groups.google.com/forum/#!topic/osx-karabiner/nHbAJ2U5eLw" rel="noreferrer">writes</a> that xbindkeys and rbindkeys do key remapping but at first glance they do not seem to handle the dual function behaviors. Now I am wrestling with porting Karabiner or creating a new tool entirely. And no doubt there may be other approaches as well. So my question is: what programming advice would you suggest for solving this problem? Especially one that can be developed in hours, days or weeks rather than in months.</p> <p><strong>Notes</strong>:</p> <p>1) There are different approaches involving changes of behavior such as swapping control and command keys. Many have been tried with varying degrees of satisfaction. Karabiner's dual function approach is, IMHO, far and away, the most effective in that it provides control key symmetry on the keyboard home row, and for all applications!</p> <p>2) Different hardware is also likely to be suggested. I've tried Dell, HP, Lenovo, Acer systems and looked at a lot more. None are comparable to the combined power, size, feel, and style of the Apple top end products, albeit at a premium price. For example, the Dell Precision 7510 is bulky and has a trackpad that feels like sandpaper; the Lenovo X1 (a very nice system) lacks a Thunderbolt port; etc.</p> <p>3) External keyboards are also a non-starter because of the laptop requirement; an external keyboard on the plane or train is not happening.</p>
0debug
Correct way to use php openssl_encrypt : <p>I'm working with cryptography on a project and I need a little help on how to work with <code>openssl_encrypt</code> and <code>openssl_decrypt</code>, I just want to know the most basic and correct way to do it. Here is what I got so far:</p> <pre><code>// To encrypt a string $dataToEncrypt = 'Hello World'; $cypherMethod = 'AES-256-CBC'; $key = random_bytes(32); $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($cypherMethod)); $encryptedData = openssl_encrypt($dataToEncrypt, $cypherMethod, $key, $options=0, $iv); </code></pre> <p>I then store <code>$cypherMethod</code>, <code>$key</code>, and <code>$iv</code> for use when decrypting the <code>$encryptedData</code>. <em>(Let's not elaborate how I store the values, thanks!)</em></p> <pre><code>// To decrypt an encrypted string $decryptedData = openssl_decrypt($encryptedData, $cypherMethod, $key, $options=0, $iv); </code></pre> <hr> <p>First off, is the above example code a correct example of how to use <code>php openssl_encrypt</code>?</p> <p>Second, is my method to generate the <code>$key</code> and <code>$iv</code> correct and secure? Because I keep on reading, keys should be cryptographically secure.</p> <p>Lastly, isn't a <code>32-byte</code> value required for <code>AES-256-CBC</code>? If yes, then why is it that <code>openssl_cipher_iv_length()</code> returns only <code>int(16)</code> as the length? Shouldn't it be <code>int(32)</code>?</p>
0debug
static void pl080_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); dc->no_user = 1; dc->vmsd = &vmstate_pl080; }
1threat
Why is my React component is rendering twice? : <p>I don't know why my React component is rendering twice. So I am pulling a phone number from params and saving it to state so I can search through Firestore. Everything seems to be working fine except it renders twice... The first one renders the phone number and zero points. The second time it renders all the data is displayed correctly. Can someone guide me to the solution. </p> <pre><code>class Update extends Component { constructor(props) { super(props); const { match } = this.props; this.state = { phoneNumber: match.params.phoneNumber, points: 0, error: '' } } getPoints = () =&gt; { firebase.auth().onAuthStateChanged((user) =&gt; { if(user) { const docRef = database.collection('users').doc(user.uid).collection('customers').doc(this.state.phoneNumber); docRef.get().then((doc) =&gt; { if (doc.exists) { const points = doc.data().points; this.setState(() =&gt; ({ points })); console.log(points); } else { // doc.data() will be undefined in this case console.log("No such document!"); const error = 'This phone number is not registered yet...' this.setState(() =&gt; ({ error })); } }).catch(function(error) { console.log("Error getting document:", error); }); } else { history.push('/') } }); } componentDidMount() { if(this.state.phoneNumber) { this.getPoints(); } else { return null; } } render() { return ( &lt;div&gt; &lt;div&gt; &lt;p&gt;{this.state.phoneNumber} has {this.state.points} points...&lt;/p&gt; &lt;p&gt;Would you like to redeem or add points?&lt;/p&gt; &lt;/div&gt; &lt;div&gt; &lt;button&gt;Redeem Points&lt;/button&gt; &lt;button&gt;Add Points&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; ); } } export default Update; </code></pre>
0debug
How do I check for 2 seperate classes when using the .is_a? method : I am trying to define a method that returns true if the array contains any strings or numbers. Basically I want it to return true as long as their is something in the array. This is what I have tried so far and it is not working: def any_strings_or_numbers?(a) a.any? {|num| num.is_a?(String || Integer) } end And here's what I mean for what I want this method to return a = [ 1, 2, 3, "string" ] any_strings_or_numbers?(a) #=> true b = [ "no numbers" ] any_strings_or_numbers?(b) #=> true c = [ 1.0 ] any_strings_or_numbers?(c) #=> true c = [ ] any_strings_or_numbers?(c) #=> false
0debug
Postman programmatically set collection variables in pre-request script : <p>Currently, it is possible to set and get variables from the <code>global</code> and <code>environment</code> scope, as well as the generic <code>variable</code> in a pre-request script. However, the documentation is not clear if it is possible to programmaticaly set <code>collection</code> scoped variables. </p> <p>For example</p> <pre><code>pm.environment.set("timestamp", timestamp); //acceptable pm.global.set("signature", hash); //acceptable pm.variable.set("signature", hash); //acceptable pm.collection.set("signature", hash); //not possible? </code></pre> <p>Is this possible?</p>
0debug
Check if the last char of a string is odd or even c# : I have a problem to check the last char of a string. I want to get the last char from a string whether odd or even. String id = "030711026098" //if the last is odd then gender = male //if the last is even then gender = female
0debug
static int check_opt(const CmdArgs *cmd_args, const char *name, QDict *args) { if (!cmd_args->optional) { qerror_report(QERR_MISSING_PARAMETER, name); return -1; } if (cmd_args->type == '-') { qdict_put(args, name, qint_from_int(0)); } return 0; }
1threat
static av_cold void uninit(AVFilterContext *ctx) { DynamicAudioNormalizerContext *s = ctx->priv; int c; av_freep(&s->prev_amplification_factor); av_freep(&s->dc_correction_value); av_freep(&s->compress_threshold); av_freep(&s->fade_factors[0]); av_freep(&s->fade_factors[1]); for (c = 0; c < s->channels; c++) { cqueue_free(s->gain_history_original[c]); cqueue_free(s->gain_history_minimum[c]); cqueue_free(s->gain_history_smoothed[c]); } av_freep(&s->gain_history_original); av_freep(&s->gain_history_minimum); av_freep(&s->gain_history_smoothed); av_freep(&s->weights); ff_bufqueue_discard_all(&s->queue); }
1threat
hwaddr memory_region_section_get_iotlb(CPUArchState *env, MemoryRegionSection *section, target_ulong vaddr, hwaddr paddr, int prot, target_ulong *address) { hwaddr iotlb; CPUWatchpoint *wp; if (memory_region_is_ram(section->mr)) { iotlb = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK) + memory_region_section_addr(section, paddr); if (!section->readonly) { iotlb |= phys_section_notdirty; } else { iotlb |= phys_section_rom; } } else { iotlb = section - phys_sections; iotlb += memory_region_section_addr(section, paddr); } QTAILQ_FOREACH(wp, &env->watchpoints, entry) { if (vaddr == (wp->vaddr & TARGET_PAGE_MASK)) { if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) { iotlb = phys_section_watch + paddr; *address |= TLB_MMIO; break; } } } return iotlb; }
1threat
Can not use both bias and batch normalization in convolution layers : <p>I use slim framework for tensorflow, because of its simplicity. But I want to have convolutional layer with both biases and batch normalization. In vanilla tensorflow, I have:</p> <pre><code>def conv2d(input_, output_dim, k_h=5, k_w=5, d_h=2, d_w=2, name="conv2d"): with tf.variable_scope(name): w = tf.get_variable('w', [k_h, k_w, input_.get_shape()[-1], output_dim], initializer=tf.contrib.layers.xavier_initializer(uniform=False)) conv = tf.nn.conv2d(input_, w, strides=[1, d_h, d_w, 1], padding='SAME') biases = tf.get_variable('biases', [output_dim], initializer=tf.constant_initializer(0.0)) conv = tf.reshape(tf.nn.bias_add(conv, biases), conv.get_shape()) tf.summary.histogram("weights", w) tf.summary.histogram("biases", biases) return conv d_bn1 = BatchNorm(name='d_bn1') h1 = lrelu(d_bn1(conv2d(h0, df_dim + y_dim, name='d_h1_conv'))) </code></pre> <p>and I rewrote it to slim by this:</p> <pre><code>h1 = slim.conv2d(h0, num_outputs=self.df_dim + self.y_dim, scope='d_h1_conv', kernel_size=[5, 5], stride=[2, 2], activation_fn=lrelu, normalizer_fn=layers.batch_norm, normalizer_params=batch_norm_params, weights_initializer=layers.xavier_initializer(uniform=False), biases_initializer=tf.constant_initializer(0.0) ) </code></pre> <p>But this code does not add bias to conv layer. That is because of <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/layers/python/layers/layers.py#L1025" rel="noreferrer">https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/layers/python/layers/layers.py#L1025</a> where is </p> <pre><code> layer = layer_class(filters=num_outputs, kernel_size=kernel_size, strides=stride, padding=padding, data_format=df, dilation_rate=rate, activation=None, use_bias=not normalizer_fn and biases_initializer, kernel_initializer=weights_initializer, bias_initializer=biases_initializer, kernel_regularizer=weights_regularizer, bias_regularizer=biases_regularizer, activity_regularizer=None, trainable=trainable, name=sc.name, dtype=inputs.dtype.base_dtype, _scope=sc, _reuse=reuse) outputs = layer.apply(inputs) </code></pre> <p>in the construction of layer, which results in not having bias when using batch normalization. Does that mean that I can not have both biases and batch normalization using slim and layers library? Or is there another way to achieve having both bias and batch normalization in layer when using slim?</p>
0debug
int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { return bdrv_get_block_status_above(bs, backing_bs(bs), sector_num, nb_sectors, pnum); }
1threat
Java script Boolean value error : In my below java script i get a error in the if condition called Reference Error{value is not defined} I don't understand why its not defined as you can see it already defined as false. Any idea ? $("input:radio[name=aboriginal]").click(function() { var DifferentOccasionP = false; DifferentOccasionP = false; alert(DifferentOccasionP); // false console.log(DifferentOccasionP);//false console.log(!!DifferentOccasionP); // false console.log(typeof DifferentOccasionP); // boolean if (DifferentOccasionP === false){ alert("ab" + value); }else{ alert("ddddd"); } });
0debug
Trying to convert the value of a textbox to an int C# .NET : <p>I am currently trying to use the value of a textbox as the value of an integer in a Timer so its like this</p> <p>User inputs a value my application reads it and uses the input as a value of interval in a timer but its giving me this error, whats going on? <a href="http://i.stack.imgur.com/uow8s.png" rel="nofollow">Here is what it looks like</a></p>
0debug
static int img_rebase(int argc, char **argv) { BlockDriverState *bs, *bs_old_backing = NULL, *bs_new_backing = NULL; BlockDriver *old_backing_drv, *new_backing_drv; char *filename; const char *fmt, *cache, *out_basefmt, *out_baseimg; int c, flags, ret; int unsafe = 0; int progress = 0; fmt = NULL; cache = BDRV_DEFAULT_CACHE; out_baseimg = NULL; out_basefmt = NULL; for(;;) { c = getopt(argc, argv, "uhf:F:b:pt:"); if (c == -1) { break; } switch(c) { case '?': case 'h': help(); return 0; case 'f': fmt = optarg; break; case 'F': out_basefmt = optarg; break; case 'b': out_baseimg = optarg; break; case 'u': unsafe = 1; break; case 'p': progress = 1; break; case 't': cache = optarg; break; } } if ((optind >= argc) || (!unsafe && !out_baseimg)) { help(); } filename = argv[optind++]; qemu_progress_init(progress, 2.0); qemu_progress_print(0, 100); flags = BDRV_O_RDWR | (unsafe ? BDRV_O_NO_BACKING : 0); ret = bdrv_parse_cache_flags(cache, &flags); if (ret < 0) { error_report("Invalid cache option: %s", cache); return -1; } bs = bdrv_new_open(filename, fmt, flags); if (!bs) { return 1; } old_backing_drv = NULL; new_backing_drv = NULL; if (!unsafe && bs->backing_format[0] != '\0') { old_backing_drv = bdrv_find_format(bs->backing_format); if (old_backing_drv == NULL) { error_report("Invalid format name: '%s'", bs->backing_format); ret = -1; goto out; } } if (out_basefmt != NULL) { new_backing_drv = bdrv_find_format(out_basefmt); if (new_backing_drv == NULL) { error_report("Invalid format name: '%s'", out_basefmt); ret = -1; goto out; } } if (unsafe) { bs_old_backing = NULL; bs_new_backing = NULL; } else { char backing_name[1024]; bs_old_backing = bdrv_new("old_backing"); bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name)); ret = bdrv_open(bs_old_backing, backing_name, BDRV_O_FLAGS, old_backing_drv); if (ret) { error_report("Could not open old backing file '%s'", backing_name); goto out; } bs_new_backing = bdrv_new("new_backing"); ret = bdrv_open(bs_new_backing, out_baseimg, BDRV_O_FLAGS, new_backing_drv); if (ret) { error_report("Could not open new backing file '%s'", out_baseimg); goto out; } } if (!unsafe) { uint64_t num_sectors; uint64_t old_backing_num_sectors; uint64_t new_backing_num_sectors; uint64_t sector; int n; uint8_t * buf_old; uint8_t * buf_new; float local_progress; buf_old = qemu_blockalign(bs, IO_BUF_SIZE); buf_new = qemu_blockalign(bs, IO_BUF_SIZE); bdrv_get_geometry(bs, &num_sectors); bdrv_get_geometry(bs_old_backing, &old_backing_num_sectors); bdrv_get_geometry(bs_new_backing, &new_backing_num_sectors); local_progress = (float)100 / (num_sectors / MIN(num_sectors, IO_BUF_SIZE / 512)); for (sector = 0; sector < num_sectors; sector += n) { if (sector + (IO_BUF_SIZE / 512) <= num_sectors) { n = (IO_BUF_SIZE / 512); } else { n = num_sectors - sector; } ret = bdrv_is_allocated(bs, sector, n, &n); if (ret) { continue; } if (sector >= old_backing_num_sectors) { memset(buf_old, 0, n * BDRV_SECTOR_SIZE); } else { if (sector + n > old_backing_num_sectors) { n = old_backing_num_sectors - sector; } ret = bdrv_read(bs_old_backing, sector, buf_old, n); if (ret < 0) { error_report("error while reading from old backing file"); goto out; } } if (sector >= new_backing_num_sectors) { memset(buf_new, 0, n * BDRV_SECTOR_SIZE); } else { if (sector + n > new_backing_num_sectors) { n = new_backing_num_sectors - sector; } ret = bdrv_read(bs_new_backing, sector, buf_new, n); if (ret < 0) { error_report("error while reading from new backing file"); goto out; } } uint64_t written = 0; while (written < n) { int pnum; if (compare_sectors(buf_old + written * 512, buf_new + written * 512, n - written, &pnum)) { ret = bdrv_write(bs, sector + written, buf_old + written * 512, pnum); if (ret < 0) { error_report("Error while writing to COW image: %s", strerror(-ret)); goto out; } } written += pnum; } qemu_progress_print(local_progress, 100); } qemu_vfree(buf_old); qemu_vfree(buf_new); } ret = bdrv_change_backing_file(bs, out_baseimg, out_basefmt); if (ret == -ENOSPC) { error_report("Could not change the backing file to '%s': No " "space left in the file header", out_baseimg); } else if (ret < 0) { error_report("Could not change the backing file to '%s': %s", out_baseimg, strerror(-ret)); } qemu_progress_print(100, 0); out: qemu_progress_end(); if (!unsafe) { if (bs_old_backing != NULL) { bdrv_delete(bs_old_backing); } if (bs_new_backing != NULL) { bdrv_delete(bs_new_backing); } } bdrv_delete(bs); if (ret) { return 1; } return 0; }
1threat
static void gen_read_xer(TCGv dst) { TCGv t0 = tcg_temp_new(); TCGv t1 = tcg_temp_new(); TCGv t2 = tcg_temp_new(); tcg_gen_mov_tl(dst, cpu_xer); tcg_gen_shli_tl(t0, cpu_so, XER_SO); tcg_gen_shli_tl(t1, cpu_ov, XER_OV); tcg_gen_shli_tl(t2, cpu_ca, XER_CA); tcg_gen_or_tl(t0, t0, t1); tcg_gen_or_tl(dst, dst, t2); tcg_gen_or_tl(dst, dst, t0); tcg_temp_free(t0); tcg_temp_free(t1); tcg_temp_free(t2); }
1threat
JWT authentication & refresh token implementation : <p>I am developing a REST application with its own authentication and authorization mechanism. I want to use JSON Web Tokens for authentication. Is the following a valid and safe implementation?</p> <ol> <li>A REST API will be developed to accept username and password and do the authentication. The HTTP method to be used is POST so that there is no caching. Also, there will be SSL for security at the time of transit</li> <li>At the time of authentication, two JWTs will be created - access token and refresh token. Refresh token will have longer validity. Both the tokens will be written in cookies, so that they are sent in every subsequent requests</li> <li>On every REST API call, the tokens will be retrieved from the HTTP header. If the access token is not expired, check the privileges of the user and allow access accordingly. If the access token is expired but the refresh token is valid, recreate new access token and refresh token with new expiry dates (do all necessary checks to ensure that the user rights to authenticate are not revoked) and sent back through Cookies</li> <li>Provide a logout REST API that will reset the cookie and hence subsequent API calls will be rejected until login is done.</li> </ol> <p>My understanding of refresh token here is:</p> <p>Due to the presence of refresh token, we can keep shorter validity period for access token and check frequently (at the expiry of access token) that the user is still authorized to login.</p> <p>Please correct me if I am wrong.</p>
0debug
How can i scale the dates (from oldest to most recent) in my file using python? : <p>i am currently trying to use datetime to re-organize dates from oldest to most recent in a .txt file. In the file i am reading in, the dates have the following format: 1 2019 06 27 05 47 57 464. The first column is the ID number, second is the year, third is the month, forth is the day, fifth is the hour, sixth is minutes, seventh is seconds and eight is millisecs. Is there an efficient way to organize it from oldest (in this case: 2000 2018 07 16 08 57 34 344) to most recent (1 2019 06 27 05 47 57 464)?</p> <p>I have tried importing datetime in python and reading in my file and setting the variables equal to their appropriate positions, but i cannot figure it out.</p>
0debug
maven-source-plugin not work for kotlin : <p>I am trying to use maven-source-plugin to create a source.jar for my kotlin project, but seems the maven-source-plugin not work well for kotlin project.</p> <p>when i run "mvn source:jar", the output message always says:</p> <pre><code>[INFO] No sources in project. Archive not created. </code></pre> <p>here is the maven-source-plugin configuration in my pom file of the project:</p> <pre><code> &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-source-plugin&lt;/artifactId&gt; &lt;version&gt;2.2.1&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;attach-sources&lt;/id&gt; &lt;phase&gt;package&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;jar&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;attach&gt;true&lt;/attach&gt; &lt;includes&gt; &lt;!-- i am trying to specify the include dir manually, but not work --&gt; &lt;include&gt;${project.basedir}/src/main/kotlin/*&lt;/include&gt; &lt;/includes&gt; &lt;forceCreation&gt;true&lt;/forceCreation&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; </code></pre> <p>my question is: how to attach kotlin source files using maven-source-plugin?</p> <p>thanks ~~</p>
0debug
Python - read in txt file as numpy array per block : I would like to print an array per block of data loaded from a txt file. my data looks like this, blocks are separated with a white/blank line in between: 2 3 4 1 9 3 3 7 2 2 3 2 0 9 8 2 8 2 1 1 1 8 2 0 3 8 2 I would like to print the blocks in a for loop.
0debug
Angular CLI route : <p>When executing command:</p> <pre><code>ng generate route someName </code></pre> <p>I am getting error like this:</p> <blockquote> <p>Could not start watchman; falling back to NodeWatcher for file system events. Visit <a href="http://ember-cli.com/user-guide/#watchman" rel="noreferrer">http://ember-cli.com/user-guide/#watchman</a> for more info. Due to changes in the router, route generation has been temporarily disabled. You can find more information about the new router here: <a href="http://victorsavkin.com/post/145672529346/angular-router" rel="noreferrer">http://victorsavkin.com/post/145672529346/angular-router</a></p> </blockquote> <p>Provided links are not helpful</p>
0debug
How to use collect and include for multidimensional array in Ruby on Rails : I have code that currently checks the multidimensional array and if the array includes student id replace the element with 'X'. When I tested it with single input. For example, `@student_ids` is only `1` then it works but if `@student_ids` has more then one elements such as `1,2,3`, it makes errors. What I am trying to implement is if the `array1` includes elements that are @student_ids, I want to replace them with `X`. Any help? array1 = [[1,2,3,4,5]+[7,8,9,10]+[11,12,13,14]] @student_ids = 1,2,3 array1.collect! do |i| if i.include?(@student_ids) # i[i.index(@student_ids)] = 'X'; i # I want to replace all with X else i end end so I want to see [[X,X,X,4,5]+[7,8,9,10]+[11,12,13,14]] like this.
0debug
how to import jquery in wordpress plugin? : i just wrote a plugin but i don know how to include js here can any body help me,i am making a form ,which will store into database <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> jquery(document).ready(function() { jquery('#type_of_moving').click(function(){ jquery(".option_wrap").css("display", "block"); jquery('#disable_option :not(:selected)').attr('disabled','disabled'); var select_type = jquery('.option_wrap :selected').val(); jquery('#type_of_moving').val(select_type); }); jquery(document).ready(function(){ var current = 1,current_step,next_step,steps; steps = jquery("fieldset").length; jquery(".next").click(function(){ jquery(".previous").css("display", "block"); current_step = jquery(this).parent(); next_step = jquery(this).parent().next(); next_step.show(); current_step.hide(); }); jquery(".previous").click(function(){ current_step = jquery(this).parent(); next_step = jquery(this).parent().prev(); next_step.show(); current_step.hide(); }); }); }); <!-- end snippet -->
0debug
Android Studio Changing Shape of The Back Button : [Screenshot of App][1] [1]: https://i.stack.imgur.com/0p6ah.png The back button on the action bar of my app seems a little large. When I hold my finger on it on my phone the button highlights and I can see the right side of it is rounded out pushing over the text. How can I make the button square and move the text closer to the left side of the action bar instead of being more out to the middle?
0debug
Hasekll, why this (let x = x+3 in fst (snd (x+1,(5,x-2)))) Equals 5 : Can someone explain to me why this equals 5? let x = x+3 in fst (snd (x+1,(5,x-2))) It will help me out so much, i bless you for you replies
0debug
Printing out all titles ending in '.txt' ( Python ) : <p>My objective is to print out all available files that end in '.txt' inside a folder, I'm unsure how to do so. Thank you for reading.</p>
0debug
CNAME and TXT record for same subdomain not working : <p>I need to add a TXT record for the subdomain test.domain.com in the zone file. In this zone file there is an existing CNAME for the same subdomain. The two records looking like this:</p> <pre><code>test IN CNAME asdf.someotherdomain.com. test IN TXT "Some text i need to add" </code></pre> <p>But when I try to save this I get an error:</p> <pre><code>dns_master_load: :45: test.domain.com: CNAME and other data zone domain.com/IN: loading from master file failed: CNAME and other data zone domain.com/IN: not loaded due to errors. status: FAIL </code></pre> <p>It works if I do it with different subdomains, for example:</p> <pre><code>test IN CNAME asdf.someotherdomain.com. testing IN TXT "Some text i need to add" </code></pre> <p>I'm not exactly the best there is when it comes to DNS. Is it not possible to have the same subdomain in this scenario? Or am I missing something?</p> <p>The servers are running bind.</p>
0debug
static uint64_t cs_read (void *opaque, target_phys_addr_t addr, unsigned size) { CSState *s = opaque; uint32_t saddr, iaddr, ret; saddr = addr; iaddr = ~0U; switch (saddr) { case Index_Address: ret = s->regs[saddr] & ~0x80; break; case Index_Data: if (!(s->dregs[MODE_And_ID] & MODE2)) iaddr = s->regs[Index_Address] & 0x0f; else iaddr = s->regs[Index_Address] & 0x1f; ret = s->dregs[iaddr]; if (iaddr == Error_Status_And_Initialization) { if (s->aci_counter) { ret |= 1 << 5; s->aci_counter -= 1; } } break; default: ret = s->regs[saddr]; break; } dolog ("read %d:%d -> %d\n", saddr, iaddr, ret); return ret; }
1threat