problem
stringlengths
26
131k
labels
class label
2 classes
static inline void gen_op_eval_fbule(TCGv dst, TCGv src, unsigned int fcc_offset) { gen_mov_reg_FCC0(dst, src, fcc_offset); tcg_gen_xori_tl(dst, dst, 0x1); gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); tcg_gen_and_tl(dst, dst, cpu_tmp0); tcg_gen_xori_tl(dst, dst, 0x1); }
1threat
How to exclude a value : I need to create a clause to restrict the data returned. if supplier returns values 'approved' and 'in process' then do not return supplier. Is there a way of doing this? thanks
0debug
static int xen_remove_from_physmap(XenIOState *state, hwaddr start_addr, ram_addr_t size) { unsigned long i = 0; int rc = 0; XenPhysmap *physmap = NULL; hwaddr phys_offset = 0; physmap = get_physmapping(state, start_addr, size); if (physmap == NULL) { return -1; } phys_offset = physmap->phys_offset; size = physmap->size; DPRINTF("unmapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx", from ", "%"HWADDR_PRIx"\n", phys_offset, phys_offset + size, start_addr); size >>= TARGET_PAGE_BITS; start_addr >>= TARGET_PAGE_BITS; phys_offset >>= TARGET_PAGE_BITS; for (i = 0; i < size; i++) { unsigned long idx = start_addr + i; xen_pfn_t gpfn = phys_offset + i; rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn); if (rc) { fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN %" PRI_xen_pfn" failed: %d\n", idx, gpfn, rc); return -rc; } } QLIST_REMOVE(physmap, list); if (state->log_for_dirtybit == physmap) { state->log_for_dirtybit = NULL; } free(physmap); return 0; }
1threat
API to allow user with a (+) signed in their username to log in : <p>Currently right now, user with an email such as test+test@email.com are not getting through are API because of the (+) sign. When making a database call with such a user ID, it brings results. However, when making an api call such as this.</p> <pre><code>api.hq.org/user?token=1234567&amp;username=test+test@email.com </code></pre> <p>it does not bring any results. I am trying to find a way to allow such users to return results. I know its an URL encoding but I am wondering if anyone has encounter this at one point?</p>
0debug
How do I Generate a Text Message to a Predefined Phone Number in Swift for iOS 10? : Let's say I have the user of my app define a phone number in a setup step of my program, saved in the plist as a number with the key "PhoneNum". Now lets say that I want to have a button in the program which, when pressed, generates a text message that says "Hi! How are you today?" to the phone number saved under "PhoneNum". How would I do this? Also, would it be possible to auto-send the text message, or is user confirmation required to send the message?
0debug
Is there a Java library for all HTML tag names? : <p>I was wondering if there exists any Java library that contains all HTML tags. I am writing selenium tests for fairly complex web sites using the Java binding, and often needing to find an element by tag name. I thought having a class with constants referring to each tag name would be nice. Since there is a finite list of HTML tags, I'm thinking this must already exist. I could begin writing mine, of course, but why reinvent the wheel if there is one out there. I have checked the Selenium Java API documentation but can't find any. Any suggestions?</p>
0debug
How to disable splash highlight of FlatButton in Flutter? : <p>I have a FlatButton. I don't want the splash highlight when the button is clicked. I tried changing the splash colour to transparent, but that didn't work. Here is the code for my FlatButton.</p> <pre><code>Widget button = new Container( child: new Container( padding: new EdgeInsets.only(bottom: 20.0), alignment: Alignment.center, child: new FlatButton( onPressed: () { _onClickSignInButton(); }, splashColor: Colors.transparent, child: new Stack( alignment: Alignment.center, children: &lt;Widget&gt;[ new Image.asset('images/1.0x/button1.png', ), new Text("SIGN IN", style: new TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16.0 ), ) ], ), ), ), ); </code></pre>
0debug
Cypress: Test if element does not exist : <p>I want to be able to click on a check box and test that an element is no longer in the DOM in Cypress. Can someone suggest how you do it?</p> <pre><code>//This is the Test when the check box is clicked and the element is there cy.get('[type="checkbox"]').click(); cy.get('.check-box-sub-text').contains('Some text in this div.') </code></pre> <p>I want to do the opposite of the test above. So when I click it again the div with the class should not be in the DOM.</p>
0debug
static struct omap_32khz_timer_s *omap_os_timer_init(MemoryRegion *memory, target_phys_addr_t base, qemu_irq irq, omap_clk clk) { struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) g_malloc0(sizeof(struct omap_32khz_timer_s)); s->timer.irq = irq; s->timer.clk = clk; s->timer.timer = qemu_new_timer_ns(vm_clock, omap_timer_tick, &s->timer); omap_os_timer_reset(s); omap_timer_clk_setup(&s->timer); memory_region_init_io(&s->iomem, &omap_os_timer_ops, s, "omap-os-timer", 0x800); memory_region_add_subregion(memory, base, &s->iomem); return s; }
1threat
av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx) { int cpu_flags = av_get_cpu_flags(); #if HAVE_7REGS && HAVE_INLINE_ASM if (cpu_flags & AV_CPU_FLAG_CMOV) c->add_hfyu_median_prediction = ff_add_hfyu_median_prediction_cmov; #endif if (cpu_flags & AV_CPU_FLAG_MMX) dsputil_init_mmx(c, avctx, cpu_flags); if (cpu_flags & AV_CPU_FLAG_MMXEXT) dsputil_init_mmxext(c, avctx, cpu_flags); if (cpu_flags & AV_CPU_FLAG_SSE) dsputil_init_sse(c, avctx, cpu_flags); if (cpu_flags & AV_CPU_FLAG_SSE2) dsputil_init_sse2(c, avctx, cpu_flags); if (cpu_flags & AV_CPU_FLAG_SSSE3) dsputil_init_ssse3(c, avctx, cpu_flags); if (cpu_flags & AV_CPU_FLAG_SSE4) dsputil_init_sse4(c, avctx, cpu_flags); if (CONFIG_ENCODERS) ff_dsputilenc_init_mmx(c, avctx); }
1threat
How can I store objects into an ArrayList without them duplicating in Java? : <p>So i have some code that takes a bunch of data and creates objects from that data. Here is the pseudo code. The main class looks like this:</p> <pre><code>public static void main(String[] args) { storage.addObject(2, 20, Jake, JE); storage.addObject(5, 34, Kate, KI); storage.addObject(3, 26, Joe, JL); </code></pre> <p>Then another class called storage will create and store these objects into an ArrayList</p> <pre><code>public void addObject(int number, int age, String name, String code) { Object newObject = new Object(number, age, name, code); objects.add(newObject); </code></pre> <p>The problem that I am getting is that when I try </p> <pre><code>System.out.println(objects); </code></pre> <p>Each bit of data in the array list is storing multiple objects so the output looks like this</p> <pre><code>[2 20 Jake JE] [2 20 Jake JE, 5 34 Kate KI] [2 20 Jake JE, 5 34 Kate KI, 3 26 Joe JL] </code></pre> <p>I don't know why it's repeating the objects but I am trying to make it so 1 object is in 1 part of the arrayList so the output looks like</p> <pre><code>[2 20 Jake JE] [5 34 Kate KI] [3 26 Joe JL] </code></pre> <p>The object creating class has a toString part so that all of the data gets converted to a string I'm not getting any compiling errors</p>
0debug
I know Redis is fast for a database, but is Redis cheap? : <p>RAM storage costs many times what hard disc storage does. </p> <p>Wouldn't that make storing data in Redis many times more expensive than if you used MongoDB or mySQL?</p>
0debug
I wanna create a timestamp folder with today's date and time and copy some folder to it, how to do this? : I'm trying to create a folder in windows with current timestamp details and copy some folder to it. I tried as below bat 'for /f "tokens=2-4 delims=/ " %%i in ("%date%") do SET today_fname=%%i_%%j_%%k' bat 'for /f "tokens=2-4 delims=/ " %%i in ("%date%") do md today_fname' bat 'cd %today_fname%' bat 'copy "C:/Program Files (x86)/Jenkins/workspace/jenkins Pipeline/application/bin/Debug/netcoreapp2.1/os/publish"' It ends up creating a folder with a timestamp name and copying the folder contains to current directory instead of Cd to newly created folder i'm trying to create a folder with a name 05_14_18_7_31 and copy the contains present in this location "C:/Program Files (x86)/Jenkins/workspace/jenkins Pipeline/application/bin/Debug/netcoreapp2.1/os/publish" to 05_14_18_7_31
0debug
static av_cold int vc1_decode_init(AVCodecContext *avctx) { VC1Context *v = avctx->priv_data; MpegEncContext *s = &v->s; GetBitContext gb; int ret; v->output_width = avctx->width; v->output_height = avctx->height; if (!avctx->extradata_size || !avctx->extradata) return -1; if (!(avctx->flags & CODEC_FLAG_GRAY)) avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts); else avctx->pix_fmt = AV_PIX_FMT_GRAY8; v->s.avctx = avctx; if ((ret = ff_vc1_init_common(v)) < 0) return ret; if ((ret = ff_msmpeg4_decode_init(avctx)) < 0) return ret; if ((ret = ff_vc1_decode_init_alloc_tables(v)) < 0) return ret; ff_vc1_decode_end(avctx); ff_blockdsp_init(&s->bdsp, avctx); ff_h264chroma_init(&v->h264chroma, 8); ff_qpeldsp_init(&s->qdsp); if (avctx->codec_id == AV_CODEC_ID_WMV3 || avctx->codec_id == AV_CODEC_ID_WMV3IMAGE) { int count = 0; init_get_bits(&gb, avctx->extradata, avctx->extradata_size*8); if ((ret = ff_vc1_decode_sequence_header(avctx, v, &gb)) < 0) return ret; count = avctx->extradata_size*8 - get_bits_count(&gb); if (count > 0) { av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n", count, get_bits(&gb, count)); } else if (count < 0) { av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count); } } else { const uint8_t *start = avctx->extradata; uint8_t *end = avctx->extradata + avctx->extradata_size; const uint8_t *next; int size, buf2_size; uint8_t *buf2 = NULL; int seq_initialized = 0, ep_initialized = 0; if (avctx->extradata_size < 16) { av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", avctx->extradata_size); return -1; } buf2 = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); start = find_next_marker(start, end); next = start; for (; next < end; start = next) { next = find_next_marker(start + 4, end); size = next - start - 4; if (size <= 0) continue; buf2_size = vc1_unescape_buffer(start + 4, size, buf2); init_get_bits(&gb, buf2, buf2_size * 8); switch (AV_RB32(start)) { case VC1_CODE_SEQHDR: if ((ret = ff_vc1_decode_sequence_header(avctx, v, &gb)) < 0) { av_free(buf2); return ret; } seq_initialized = 1; break; case VC1_CODE_ENTRYPOINT: if ((ret = ff_vc1_decode_entry_point(avctx, v, &gb)) < 0) { av_free(buf2); return ret; } ep_initialized = 1; break; } } av_free(buf2); if (!seq_initialized || !ep_initialized) { av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n"); return -1; } v->res_sprite = (avctx->codec_id == AV_CODEC_ID_VC1IMAGE); } v->sprite_output_frame = av_frame_alloc(); if (!v->sprite_output_frame) avctx->profile = v->profile; if (v->profile == PROFILE_ADVANCED) avctx->level = v->level; avctx->has_b_frames = !!avctx->max_b_frames; if (v->color_prim == 1 || v->color_prim == 5 || v->color_prim == 6) avctx->color_primaries = v->color_prim; if (v->transfer_char == 1 || v->transfer_char == 7) avctx->color_trc = v->transfer_char; if (v->matrix_coef == 1 || v->matrix_coef == 6 || v->matrix_coef == 7) avctx->colorspace = v->matrix_coef; s->mb_width = (avctx->coded_width + 15) >> 4; s->mb_height = (avctx->coded_height + 15) >> 4; if (v->profile == PROFILE_ADVANCED || v->res_fasttx) { ff_vc1_init_transposed_scantables(v); } else { memcpy(v->zz_8x8, ff_wmv1_scantable, 4*64); v->left_blk_sh = 3; v->top_blk_sh = 0; } if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) { v->sprite_width = avctx->coded_width; v->sprite_height = avctx->coded_height; avctx->coded_width = avctx->width = v->output_width; avctx->coded_height = avctx->height = v->output_height; if (v->sprite_width > 1 << 14 || v->sprite_height > 1 << 14 || v->output_width > 1 << 14 || v->output_height > 1 << 14) return -1; if ((v->sprite_width&1) || (v->sprite_height&1)) { avpriv_request_sample(avctx, "odd sprites support"); return AVERROR_PATCHWELCOME; } } return 0; }
1threat
static int enable_write_target(BlockDriverState *bs, Error **errp) { BDRVVVFATState *s = bs->opaque; BlockDriver *bdrv_qcow = NULL; BlockDriverState *backing; QemuOpts *opts = NULL; int ret; int size = sector2cluster(s, s->sector_count); QDict *options; s->used_clusters = calloc(size, 1); array_init(&(s->commits), sizeof(commit_t)); s->qcow_filename = g_malloc(PATH_MAX); ret = get_tmp_filename(s->qcow_filename, PATH_MAX); if (ret < 0) { error_setg_errno(errp, -ret, "can't create temporary file"); goto err; } bdrv_qcow = bdrv_find_format("qcow"); if (!bdrv_qcow) { error_setg(errp, "Failed to locate qcow driver"); ret = -ENOENT; goto err; } opts = qemu_opts_create(bdrv_qcow->create_opts, NULL, 0, &error_abort); qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s->sector_count * 512, &error_abort); qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, "fat:", &error_abort); ret = bdrv_create(bdrv_qcow, s->qcow_filename, opts, errp); qemu_opts_del(opts); if (ret < 0) { goto err; } options = qdict_new(); qdict_put(options, "write-target.driver", qstring_from_str("qcow")); s->qcow = bdrv_open_child(s->qcow_filename, options, "write-target", bs, &child_vvfat_qcow, false, errp); QDECREF(options); if (!s->qcow) { ret = -EINVAL; goto err; } #ifndef _WIN32 unlink(s->qcow_filename); #endif backing = bdrv_new(); bdrv_set_backing_hd(s->bs, backing); bdrv_unref(backing); s->bs->backing->bs->drv = &vvfat_write_target; s->bs->backing->bs->opaque = g_new(void *, 1); *(void**)s->bs->backing->bs->opaque = s; return 0; err: g_free(s->qcow_filename); s->qcow_filename = NULL; return ret; }
1threat
static void qemu_clock_init(QEMUClockType type) { QEMUClock *clock = qemu_clock_ptr(type); clock->type = type; clock->enabled = true; clock->last = INT64_MIN; QLIST_INIT(&clock->timerlists); notifier_list_init(&clock->reset_notifiers); main_loop_tlg.tl[type] = timerlist_new(type, NULL, NULL); }
1threat
static int rtp_read_header(AVFormatContext *s) { uint8_t recvbuf[RTP_MAX_PACKET_LENGTH]; char host[500], sdp[500]; int ret, port; URLContext* in = NULL; int payload_type; AVCodecContext codec = { 0 }; struct sockaddr_storage addr; AVIOContext pb; socklen_t addrlen = sizeof(addr); RTSPState *rt = s->priv_data; if (!ff_network_init()) return AVERROR(EIO); if (!rt->protocols) { rt->protocols = ffurl_get_protocols(NULL, NULL); if (!rt->protocols) return AVERROR(ENOMEM); } ret = ffurl_open(&in, s->filename, AVIO_FLAG_READ, &s->interrupt_callback, NULL, rt->protocols); if (ret) goto fail; while (1) { ret = ffurl_read(in, recvbuf, sizeof(recvbuf)); if (ret == AVERROR(EAGAIN)) continue; if (ret < 0) goto fail; if (ret < 12) { av_log(s, AV_LOG_WARNING, "Received too short packet\n"); continue; } if ((recvbuf[0] & 0xc0) != 0x80) { av_log(s, AV_LOG_WARNING, "Unsupported RTP version packet " "received\n"); continue; } if (RTP_PT_IS_RTCP(recvbuf[1])) continue; payload_type = recvbuf[1] & 0x7f; break; } getsockname(ffurl_get_file_handle(in), (struct sockaddr*) &addr, &addrlen); ffurl_close(in); in = NULL; if (ff_rtp_get_codec_info(&codec, payload_type)) { av_log(s, AV_LOG_ERROR, "Unable to receive RTP payload type %d " "without an SDP file describing it\n", payload_type); goto fail; } if (codec.codec_type != AVMEDIA_TYPE_DATA) { av_log(s, AV_LOG_WARNING, "Guessing on RTP content - if not received " "properly you need an SDP file " "describing it\n"); } av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, NULL, 0, s->filename); snprintf(sdp, sizeof(sdp), "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n", addr.ss_family == AF_INET ? 4 : 6, host, codec.codec_type == AVMEDIA_TYPE_DATA ? "application" : codec.codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio", port, payload_type); av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp); ffio_init_context(&pb, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL); s->pb = &pb; ff_network_close(); rt->media_type_mask = (1 << (AVMEDIA_TYPE_DATA+1)) - 1; ret = sdp_read_header(s); s->pb = NULL; return ret; fail: if (in) ffurl_close(in); ff_network_close(); return ret; }
1threat
static void dump_json_image_check(ImageCheck *check, bool quiet) { Error *local_err = NULL; QString *str; QmpOutputVisitor *ov = qmp_output_visitor_new(); QObject *obj; visit_type_ImageCheck(qmp_output_get_visitor(ov), NULL, &check, &local_err); obj = qmp_output_get_qobject(ov); str = qobject_to_json_pretty(obj); assert(str != NULL); qprintf(quiet, "%s\n", qstring_get_str(str)); qobject_decref(obj); qmp_output_visitor_cleanup(ov); QDECREF(str); }
1threat
polymorphic_allocator: when and why should I use it? : <p><a href="http://en.cppreference.com/w/cpp/memory/polymorphic_allocator">Here</a> is the documentation on <em>cppreference</em>, <a href="http://eel.is/c++draft/memory.polymorphic.allocator.class">here</a> is the working draft.</p> <p>I must admit that I didn't understand what's the real purpose of <code>polymorphic_allocator</code> and when/why/how I should use it.<br> As an example, the <a href="http://eel.is/c++draft/vector.syn"><code>pmr::vector</code></a> has the following signature:</p> <pre><code>namespace pmr { template &lt;class T&gt; using vector = std::vector&lt;T, polymorphic_allocator&lt;T&gt;&gt;; } </code></pre> <p>What does the <code>polymorphic_allocator</code> offer? What does the <code>std::pmr::vector</code> offer as well in regard of the old-fashioned <code>std::vector</code>? What can I do now that I wasn't able to do till now?<br> What's the real purpose of that allocator and when should I use it actually?</p>
0debug
static void net_slirp_cleanup(VLANClientState *vc) { SlirpState *s = vc->opaque; slirp_cleanup(s->slirp); slirp_smb_cleanup(s); TAILQ_REMOVE(&slirp_stacks, s, entry); qemu_free(s); }
1threat
Mouse wheel events in Reactjs : <p>How do you go about getting mouse wheel events in reactjs?</p> <p>I have tried onWheel</p> <pre><code> render: function() { return &lt;div onWheel = {this.wheel} &gt; &lt; /div&gt;; }, </code></pre> <p>and I have tried onScroll</p> <pre><code> render: function() { return &lt;div onScroll = {this.wheel} &gt; &lt; /div&gt;; }, </code></pre> <p>But neither of these events are picked up. See the fiddle below :</p> <p><a href="https://jsfiddle.net/812jnppf/2/" rel="noreferrer">https://jsfiddle.net/812jnppf/2/</a></p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Laravel migrations change default value of column : <p>I have a table with a default value already assigned. For an example we can look at the following:</p> <pre><code>Schema::create('users', function (Blueprint $table) { $table-&gt;increments('id')-&gt;unsigned(); $table-&gt;integer('active')-&gt;default(1); }); </code></pre> <p>I now want to change my default value on the active field. I am expecting to do something like this:</p> <pre><code>if (Schema::hasTable('users')) { Schema::table('users', function (Blueprint $table) { if (Schema::hasColumn('users', 'active')) { $table-&gt;integer('active')-&gt;default(0); } }); } </code></pre> <p>But of course it tells me the column is already there. How can I simply update the default value of column x without dropping the column?</p>
0debug
how to implement the cutomize button for facebbok and goolge in swift3 : Hi implement facebbok and google button but i cant set the corner radious for the button here is my code @IBOutlet var fb_login_btn: FBSDKLoginButton! fb_login_btn.layer.cornerRadius = 20 @IBOutlet var google_login_btn: GIDSignInButton! google_login_btn.layer.cornerRadius = 20 how can i customize the button in swift3 anyone help me to solve this issues Thanks in advance
0debug
What are the possible reasons to get APNs responses BadDeviceToken or Unregistered? : <p>When sending notifications to iOS users, for some of them I get response status code 400 (BadDeviceToken) or code 410 (Unregistered).</p> <p>From Apple documentation about "BadDeviceToken":</p> <blockquote> <p>The specified device token was bad. Verify that the request contains a valid token and that the token matches the environment.</p> </blockquote> <p>What is the meaning of "bad"? I know for a fact that the device token was valid at some earlier time. What does a user do to make its device token bad? </p> <p>From documentation about "Unregistered":</p> <blockquote> <p>The device token is inactive for the specified topic.</p> </blockquote> <p>Does this necceserally mean that the app has been deleted? Or there can be some other reasons for this response. </p>
0debug
Should cookie values be URL encoded? : <p>When setting cookies, PHP url-encodes the cookie value (at least when not using <code>setrawcookie</code>) <strong>and it url-decodes the cookie value</strong> before making it available to the application in <code>$_COOKIE</code>.</p> <p>Is this an accepted standard? If I set a raw cookie value of <code>a%3Db</code>, would I get back <code>a=b</code> in most web programming languages (through their respective cookie-reading mechanisms)?</p>
0debug
av_cold int ff_ac3_encode_close(AVCodecContext *avctx) { int blk, ch; AC3EncodeContext *s = avctx->priv_data; av_freep(&s->windowed_samples); for (ch = 0; ch < s->channels; ch++) av_freep(&s->planar_samples[ch]); av_freep(&s->planar_samples); av_freep(&s->bap_buffer); av_freep(&s->bap1_buffer); av_freep(&s->mdct_coef_buffer); av_freep(&s->fixed_coef_buffer); av_freep(&s->exp_buffer); av_freep(&s->grouped_exp_buffer); av_freep(&s->psd_buffer); av_freep(&s->band_psd_buffer); av_freep(&s->mask_buffer); av_freep(&s->qmant_buffer); av_freep(&s->cpl_coord_exp_buffer); av_freep(&s->cpl_coord_mant_buffer); for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; av_freep(&block->mdct_coef); av_freep(&block->fixed_coef); av_freep(&block->exp); av_freep(&block->grouped_exp); av_freep(&block->psd); av_freep(&block->band_psd); av_freep(&block->mask); av_freep(&block->qmant); av_freep(&block->cpl_coord_exp); av_freep(&block->cpl_coord_mant); } s->mdct_end(s); return 0; }
1threat
import math def even_binomial_Coeff_Sum( n): return (1 << (n - 1))
0debug
How to git commit & push as another user : <p>I've heard it is possible to push a commit as another user but unsure how is that possible or done, as an example where i saw it was <a href="https://github.com/jayphelps/git-blame-someone-else/commit/e5cfe4bb2190a2ae406d5f0b8f49c32ac0f01cd7" rel="nofollow noreferrer">https://github.com/jayphelps/git-blame-someone-else/commit/e5cfe4bb2190a2ae406d5f0b8f49c32ac0f01cd7</a> i tried using</p> <pre><code>git commit -am "message" --author="Linus Torvalds &lt;torvalds@linux-foundation.org&gt;" </code></pre> <p>but that's just as commit name, the history in github will still show as yourself, any way to do what happened in that commit url i sent?</p>
0debug
How do i change my code to not include build in functions : I've got a assignment for school with the test to make a code that checks password strength. as you cn see below i've made this code and turned it in but received it back afterwards beccause it's to convenient to use the build in function any. how can i adjust or change my program to not include the any function. import time print ("Check of uw wachtwoord veilig genoeg is in dit programma.") time.sleep(1) print ("Uw wachtwoord moet tussen minimaal 6 en maximaal 12 karakters bestaan") print ("U kunt gebruik maken van hoofdletters,getallen en symbolen (@,#,$,%)") klein = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] groot = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] nummers = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'] symbolen= [' ', '!', '#', '$', '%', '&', '"', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~',"'"] def ok(passwd,l): return any(k in passwd for k in l) # checkt of een letter in de lijst in het wachtwoord zit. while True: inp = input("Wilt u dit programma gebruiken? ja/nee: ") if inp == "nee" and "Nee" and "NEE": break elif inp == "ja" and "Ja" and "JA": ww = input("Voer uw wachtwoord in: ") if len(ww) < 6: print ("uw wachtwoord is te kort, uw wachtwoord moet uit minimaal 6 en maximaal 12 karakters bestaan!") elif len(ww) > 12: print ("uw wachtwoord is te lang, uw wachtwoord moet uit minimaal 6 en maximaal 12 karakters bestaan!") elif len(ww) >= 6 and len(ww)<= 12: sww = set(ww) # set is een onorganiseerde verzameling dat betekent dat het niet op order is bijv. SaUj%2F3 = Oonorganiseerd if all(ok(sww,l) for l in [klein,groot,nummers,symbolen]): print ("uw wachtwoord is Zeer sterk") elif all(ok(sww,l) for l in [klein,groot,nummers]): print ("uw wachtwoord is Sterk") elif all(ok(sww,l) for l in [klein,groot,symbolen]): print ("uw wachtwoord is Sterk") elif all(ok(sww,l) for l in [groot,nummers,symbolen]): print ("uw wachtwoord is Sterk") elif all(ok(sww,l) for l in [nummers,symbolen,klein]): print ("uw wachtwoord is Sterk") elif all(ok(sww,l) for l in [nummers,symbolen]): print ("uw wachtwoord is Medium") elif all(ok(sww,l) for l in [groot,nummers]): print ("uw wachtwoord is Medium") elif all(ok(sww,l) for l in [groot,symbolen]): print ("uw wachtwoord is Medium") elif all(ok(sww,l) for l in [klein,groot]): print ("uw wachtwoord is Medium") elif all(ok(sww,l) for l in [klein,nummers]): print ("uw wachtwoord is Medium") elif all(ok(sww,l) for l in [klein,symbolen]): print ("uw wachtwoord is Medium") elif all(ok(sww,l) for l in [klein]): print ("uw wachtwoord is Zwak") elif all(ok(sww,l) for l in [symbolen]): print ("uw wachtwoord is Zwak") elif all(ok(sww,l) for l in [nummers]): print ("uw wachtwoord is Zwak") elif all(ok(sww,l) for l in [groot]): print ("uw wachtwoord is Zwak")
0debug
Nunjucks: 'if' with multiple 'and' or 'or' condition : <p>Today my team mate was struggling on how to add multiple conditions with 'and' or 'or' in an if statement in Nunjucks template. After a lot of search he found the answer but not on Stackoverflow. I am not sure if the answer is already posted somewhere in SO but thought to post it now to narrow down future searches.</p> <p>Below is the answer:</p>
0debug
Reshape an array in Python : <p>I have an NumPy array of size <code>100x32</code> that I would like to reshape it to <code>10x10x32</code>. Therefore, the first 10 rows to be the first element of the new matrix 1x10x32, the next 10 rows to be the second element and so on. I tried to use reshape, however, I am not sure if it is quite a smooth solution, for example I did the following:</p> <pre><code>pred = pred.reshape(10, 10, 32) # pred initial is of size 100x32 </code></pre> <p>Does that code do what I want properly?</p>
0debug
static inline void RENAME(palToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width, uint32_t *pal) { int i; assert(src1 == src2); for(i=0; i<width; i++) { int p= pal[src1[i]]; dstU[i]= p>>8; dstV[i]= p>>16; } }
1threat
static inline int l2_unscale_group(int steps, int mant, int scale_factor) { int shift, mod, val; shift = scale_factor_modshift[scale_factor]; mod = shift & 3; shift >>= 2; val = (2 * (mant - (steps >> 1))) * scale_factor_mult2[steps >> 2][mod]; return (val + (1 << (shift - 1))) >> shift; }
1threat
convert "23-11-2016" format string to date in javascript : <p>Hi i have a variable result of some function with string in a date format (mm-dd-yyyy). I need to convert this string to date in same format like String "23-11-2016" should be converted to Date as 23-11-2016. I dont want any hours or minutes just date like 23-11-206 as i need to pass it to another function. i Have tried all solutions but nothing worked. some lines of code from my script are as follows</p> <pre><code>date2 = calendar_page.verifyNthDay(today); //date2 = 23-12-2016 var date_two = new Date(date2); console.log(date_two); //Output shows as Invalid Date on console. </code></pre>
0debug
VS Code quick fix always give "no code actions available" : <p>VS Code with Go, the quick fix always give "no code actions available". No matter what's the error or warning, no fix is given.</p> <p><a href="https://i.stack.imgur.com/UXNZQ.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/UXNZQ.gif" alt="enter image description here"></a></p> <p>Is this my config/environment problem or is it a vscode bug/expected? Any help will be highly appreciated!</p>
0debug
Python Charecter Casing : From a given string need o/p as If Index Position is Even - Upper Case If Index Position is Odd - Lower Case What's wrong with my code please help me. def Fun_Case(*args): n=0 for x in (args): if n%2==0: print(x[n].upper()) else: print(x[n].lower()) n+=1 Fun_Case('python PRogrammING') Its not iterating. Just printing the first letter and exiting.
0debug
Using tkinter to input into a variable, to be called : <p>I'm currently working on a scraper-sort of program, which will enter a Wikipedia page, and in its current form, will scrape the references from the page.</p> <p>I'd like to have a gui that will allow the user to input a Wikipedia page. I want the input to be attached to the <code>selectWikiPage</code> variable, but have had no luck as of far.</p> <p>Below is my current code.</p> <pre><code>import requests from bs4 import BeautifulSoup import re from tkinter import * #begin tkinter gui def show_entry_fields(): print("Wikipedia URL: %s" % (e1.get())) e1.delete(0,END) master = Tk() Label(master, text="Wikipedia URL").grid(row=0) e1 = Entry(master) e1.insert(10,"http://en.wikipedia.org/wiki/randomness") e1.grid(row=0, column=1) Button(master, text='Scrape', command=master.quit).grid(row=3, column=0, sticky=W, pady=4) mainloop( ) session = requests.Session() selectWikiPage = input(print("Please enter the Wikipedia page you wish to scrape from")) if "wikipedia" in selectWikiPage: html = session.post(selectWikiPage) bsObj = BeautifulSoup(html.text, "html.parser") findReferences = bsObj.find('ol', {'class': 'references'}) #isolate refereces section of page href = BeautifulSoup(str(findReferences), "html.parser") links = [a["href"] for a in href.find_all("a", href=True)] for link in links: print("Link: " + link) else: print("Error: Please enter a valid Wikipedia URL") </code></pre> <p>Many thanks in advance.</p>
0debug
A debugger has been found running in your system : When I try to use Delphi Tokyo debugging an application that uses functions of a DLL, when I run LoadLibrary, it shows a message that there is a debugger running and does not allow loading it. I've disabled everything I could, antivirus, firewall, windows defender, etc ... The DLL Manufacturer says it has no debug lock. My suspicion may be that Windows 10, after some update, installed some mechanism to block this type of debug with LoadLibray. Original message: "A debugger has been found running in your system. Please, unload it from memory and restart your program."
0debug
What does the "!!" operator mean in Kotlin? : <p>I'm reading this <a href="https://developer.android.com/jetpack/docs/guide" rel="nofollow noreferrer">guide</a> from Google for Android and they have the snippet bellow.</p> <p>What does the <code>!!</code> do in <code>userDao.save(response.body()!!)</code>?</p> <pre><code>private fun refreshUser(userId: String) { // Runs in a background thread. executor.execute { // Check if user data was fetched recently. val userExists = userDao.hasUser(FRESH_TIMEOUT) if (!userExists) { // Refreshes the data. val response = webservice.getUser(userId).execute() // Check for errors here. // Updates the database. The LiveData object automatically // refreshes, so we don't need to do anything else here. userDao.save(response.body()!!) } } } </code></pre>
0debug
static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val) { if (val != 0) { if (val == (val & 0xfff)) tcg_out_arithi(s, reg, reg, val, ARITH_ADD); else fprintf(stderr, "unimplemented addi %ld\n", (long)val); } }
1threat
void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { sPAPRCPUCore *core = SPAPR_CPU_CORE(OBJECT(dev)); PowerPCCPU *cpu = POWERPC_CPU(core->threads); int id = ppc_get_vcpu_dt_id(cpu); sPAPRDRConnector *drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, id); sPAPRDRConnectorClass *drck; Error *local_err = NULL; g_assert(drc); drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); drck->detach(drc, dev, spapr_core_release, NULL, &local_err); if (local_err) { error_propagate(errp, local_err); return; } spapr_hotplug_req_remove_by_index(drc); }
1threat
I want to draw a flow chart using HTML, what are the best packages out there : <p>I want to draw a flow chart in my app using HTML. I was wondering if there are libraries or examples out there.</p>
0debug
What is the difference between a node, stage, and step in Jenkins pipelines? : <p>I'm trying to understand how to structure my Jenkins 2.7 pipeline groovy script. I've read through the <a href="https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md" rel="noreferrer">pipeline tutorial</a>, but feel that it could expand more on these topics.</p> <p>I can understand that a pipeline can have many <code>stage</code>s and each <code>stage</code> can have many <code>step</code>s. But what is the difference between a <code>step();</code> and a method call inside a <code>stage</code>, say <code>sh([script: "echo hello"]);</code>. Should <code>node</code>s be inside or outside of <code>stage</code>s? Should the overall properties of a job be inside or outside a <code>node</code>?</p> <p>Here is my current structure on an ubuntu master node:</p> <pre><code>#!/usr/bin/env groovy node('master') { properties([ [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '10']] ]); stage 'Checkout' checkout scm stage 'Build' sh([script: "make build"]); archive("bin/*"); } </code></pre>
0debug
How to use InputFormatter on Flutter TextField? : <p>What do I need to insert into <code>TextField(inputFormatters:</code>?</p> <p>I want to disallow <kbd>\</kbd> and <kbd>/</kbd> in one <code>TextField</code> and only allow <kbd>a</kbd> to <kbd>Z</kbd> in another.</p>
0debug
Changing to uppercase letters using ASCII : <p>I have to create a function that changes lower case letters to upper case letters using only the ord and chr functions. </p> <p>This is what I have so far, but the problem is it is not returning all the letters, only the first letter.</p> <pre><code>def changeToUpperCase(text): for i in text: i = ord(i) - 32 text = chr(i) return text def main(): text = input("Please type a random sentence.") text = changeToUpperCase(text) print("Step 2 -&gt; ", text) </code></pre>
0debug
Error on dump or dd laravel adding a character before result : <p>All request and dumps in laravel add a ^before a result, that's only do that in dd or dump</p> <p><a href="https://i.stack.imgur.com/Apq0X.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Apq0X.png" alt="exemple of error"></a></p> <p><a href="https://i.stack.imgur.com/1f26t.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1f26t.png" alt="exemple dd Request:all()"></a></p> <p>This effect generate a lot of errors on my code, someone past some like that?</p>
0debug
Adding timestamp to each line on Zsh : <p>I just fresh installed Sierra and wanted to use zsh with oh-my-zsh and power shell...</p> <p>I ended up with a terminal like this:</p> <p><a href="https://i.stack.imgur.com/M9lh1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/M9lh1.png" alt="enter image description here"></a></p> <p>But I want to add a timestamp to every output. Semething linke:</p> <p><code>[14:23] acytryn ~ Projects %</code></p> <p>Is there a way to do this with zsh?</p>
0debug
Scopes and Pointers : <p>This is the code that I have a question about: </p> <pre><code>int* getPtrToFive() { int x = 5; return &amp;x; } int main() { int *p = getPtrToFive(); cout &lt;&lt; *p &lt;&lt; endl; // ??? } </code></pre> <p>The lecture slides say that *p wouldn't give a valid result because as getPtrToFive is returned, x goes out of scope. However, I thought that getPtrToFive would already contain the value of 5, which would validate *p? Is it because of the pointer trying to direct me to getPtrToFive which has an out of scope x? </p>
0debug
Django: How to edit value and store back in database : <p>I'm working on an attendance register. So I've got an HTMl checkbox form where user can tick if person is here. If they are then the views will pull out the number of lessons person has in database and subtract 1 from the value. How can I achieve this? This is done using Django.</p> <p>views.py:</p> <pre><code>def present(request): students = Student.objects.filter(squad='LearnToSwim1') completed = request.GET.get('pre') for stu in students: if request.POST.get('completed', '') == 'on': print("Present!") #I don't know what to do here to extract the lessons_left and subtract 1 from it. else: print("Not present") </code></pre> <p>models.py:</p> <pre><code>class Student(models.Model): student_name = models.CharField(max_length=200) squad = models.CharField(max_length=30, choices=SQUAD, default='INSERT_SQUAD') lessons_left=models.IntegerField(default=0) def __str__(self): return self.student_name </code></pre> <p>presentform.html:</p> <pre><code>&lt;form action="/present/" method="POST"&gt; {% csrf_token %} &lt;p&gt; &lt;input type="checkbox" id="completed" name="completed" /&gt; &lt;label for="completed"&gt;Present&lt;/label&gt; &lt;/p&gt; &lt;input class="waves-effect waves-light btn" type='submit'/&gt; &lt;/form&gt; </code></pre>
0debug
Parse error: syntax error, unexpected '$query' (T_VARIABLE) in c : <p>I am trying to upload information to a database. The page I created is a registration page where users can type in their email username and password. The below code is the database connection and upload code I have written. But I keep getting the above error. Can someone tell me what I am missing, please?</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-html lang-html prettyprint-override"><code>&lt;?php $db_host= $db_username= $db_pass= $db_name= $connectToServer =mysqli_query($host,$db_username,$db_pass) or die("server problem"); $selectDb =mysqli_select_db($connectToServer,$db_name) or die("database not found"); if(isset($_POST['submit'])) { $username=$_POST['username']; $email=$_POST['eml']; $password =$_POST['password']; if(!empty($username)&amp;&amp;!empty($email)&amp;&amp;!empty($password)) { $username = striplashes($username); $email=striplashes($email); $password=striplashes($password); $username = mysql_real_escape_string($connectToServer,$username); $selectTable = "SELECT * FROM user_info WHERE username='$username'" $query = mysqli_query($connectToServer,$selectTable); $insert = "INSERT INTO user_info (username, email, password) VALUES ($username, $eml, $password)" $mquery = mysqli_query($connectToServer,,$insert); if ($mquery) { session_start(); $_SESSION['login_user'] =$username ; header("Location ; profile.php"); } } else { echo &lt;script&gt;('please enter details')&lt;/script&gt;; header("Location: register.html"); } } ?&gt;</code></pre> </div> </div> </p>
0debug
object oriented programming in C plus plus : when I use following code than priority is given first to the constructor rather than cast operator so did there is any priority which will be called first #include<iostream> using namespace std; class C1; class C2 { int x; public: operator C2() { C2 temp; cout<<"operator function called"<<endl; return temp; } }; class C1 { int x; public: C1():x(10){} C1(C2) { cout<<"constructor called"<<endl; } }; int main() { C1 obj1; C2 obj2; obj1=obj2; } > Output Constructor called
0debug
(Very simple) JavaScript error : <p>I have this JS code, the commented line of which prevents a JSON to work correctly (when I comment the line, it works; when I uncomment it, it stops working):</p> <pre><code>function GenSpecieChg() { var selText = document.getElementById("textGenSpecie"); var sca = selText.value; //if (sca &lt;&gt; "" &amp;&amp; sca.indexOf("%") == -1) selText.value += "%"; localStorage.setItem("34_Delta", selText.value); alert("GenSpecie changed !"); } </code></pre> <p>What is my error ?</p>
0debug
Make a custom progress bar in Android : <p>I need to make a custom progress bar that looks like this: <a href="https://i.stack.imgur.com/Tp13k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tp13k.png" alt="enter image description here"></a></p> <p>I'd love some advice for the best way to do this. thanks!</p>
0debug
C# application permenant store variable value : I m using Properties.setting.default.var trick to store permanently a value in c# application on same pc. Now I m facing a problem that when I saves the value but copy the application to another pc the permanent value does not remains. Is properties.setting trick not work on this scenario? If yes? Please advise the solution. Thanks
0debug
C# - Parse Array from Checkbox Post : I'm trying to parse posted checkbox's into an array variable in csharp. Example: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <input type="checkbox" name="ID[]" value="1" /> <input type="checkbox" name="ID[]" value="2" /> <input type="checkbox" name="ID[]" value="3" /> <input type="checkbox" name="ID[]" value="4" /> <!-- end snippet --> That will be parsed from Request into something like this: int[] IDs = new int[] { 1, 2, 3, 4 };
0debug
static int av_thread_message_queue_send_locked(AVThreadMessageQueue *mq, void *msg, unsigned flags) { while (!mq->err_send && av_fifo_space(mq->fifo) < mq->elsize) { if ((flags & AV_THREAD_MESSAGE_NONBLOCK)) return AVERROR(EAGAIN); pthread_cond_wait(&mq->cond, &mq->lock); } if (mq->err_send) return mq->err_send; av_fifo_generic_write(mq->fifo, msg, mq->elsize, NULL); pthread_cond_signal(&mq->cond); return 0; }
1threat
static void dct_unquantize_mpeg2_c(MpegEncContext *s, DCTELEM *block, int n, int qscale) { int i, level, nCoeffs; const UINT16 *quant_matrix; if(s->alternate_scan) nCoeffs= 64; else nCoeffs= s->block_last_index[n]+1; if (s->mb_intra) { if (n < 4) block[0] = block[0] * s->y_dc_scale; else block[0] = block[0] * s->c_dc_scale; quant_matrix = s->intra_matrix; for(i=1;i<nCoeffs;i++) { int j= zigzag_direct[i]; level = block[j]; if (level) { if (level < 0) { level = -level; level = (int)(level * qscale * quant_matrix[j]) >> 3; level = -level; } else { level = (int)(level * qscale * quant_matrix[j]) >> 3; } #ifdef PARANOID if (level < -2048 || level > 2047) fprintf(stderr, "unquant error %d %d\n", i, level); #endif block[j] = level; } } } else { int sum=-1; i = 0; quant_matrix = s->non_intra_matrix; for(;i<nCoeffs;i++) { int j= zigzag_direct[i]; level = block[j]; if (level) { if (level < 0) { level = -level; level = (((level << 1) + 1) * qscale * ((int) (quant_matrix[j]))) >> 4; level = -level; } else { level = (((level << 1) + 1) * qscale * ((int) (quant_matrix[j]))) >> 4; } #ifdef PARANOID if (level < -2048 || level > 2047) fprintf(stderr, "unquant error %d %d\n", i, level); #endif block[j] = level; sum+=level; } } block[63]^=sum&1; } }
1threat
Why do i keep throwing a NullPointerException? : <p>I am trying to load the active users information into a new activity and display it. I have done similar things in different activities and they have worked fine, but for some reason this is not and I am not sure. Whenever android studio tries to invoke a method on user, it throws a NullPointerException.</p> <p>I have tried everything I can think of, reformatting the way its written, nesting in different methods, passing data through to it in different ways. Nothing is working and every article I've found on the subject doesnt help at all</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user_edit); int userID = getIntent().getIntExtra("sessionUser", 0); tuckBoxDao = TuckBoxDB.createTuckBoxDB(this).tbDao(); Email = findViewById(R.id.email); Username = findViewById(R.id.username); Password = findViewById(R.id.password); Mobile = findViewById(R.id.phoneNumber); Notifications = findViewById(R.id.notificationBox); Emails = findViewById(R.id.emailBox); registerButton = findViewById(R.id.registerButton); registerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { registerUser(user); } }); backButton = findViewById(R.id.backButton); backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { goBack(); } }); user = LoginActivity.tuckBoxDB.tbDao().searchById(userID); String username = user.getUsername(); Username.setText(username); String email = user.getEmail(); Email.setHint(email); String mobile = user.getMobile(); Mobile.setHint(mobile); Boolean notifications = user.getNotifications(); Notifications.setChecked(notifications); Boolean emails = user.getEmails(); Emails.setChecked(emails); } </code></pre> <p>I would have expected this to work fine and update and display the right information, as it has done exactly that in a fragment I made earlier, but for some reason it is throwing as soon as it gets to user.getUsername();</p>
0debug
Python: create a Class which attributes are objects from another classes possible? : <p>Is it possible to create a class with some of its attributes = object of other classes?</p> <p>class SENSORS:</p> <pre><code>def __init__(self): # The attributes of the class that will be available for external use self.temperature = None self.humidity = None self.distance = None self.light = None self.sound = None self.url = None self.base_url = "http://..." # Instantiating sensor objects self.SOUND = NEW OBJECT FROM CLASS SOUND self.LIGHT = NEW OBJECT FROM CLASS LIGHT self.DISTANCE = NEW OBJECT FROM CLASS DISTANCE self.TEMP = NEW OBJECT FROM CLASS TEMPERATURE </code></pre>
0debug
How to create web push notification wen insert data in database with php : <pre><code>&lt;script src='push.min.js' type="text/javascript"&gt;&lt;/script&gt; &lt;?php require_once 'dbconfig.php'; $task = $db_con-&gt;prepare('SELECT * FROM table WHERE notification = "unread"'); $task-&gt;execute(); while($rows=$task-&gt;fetch(PDO::FETCH_ASSOC)) { ?&gt; </code></pre> Push.create("title", { body: "Add deposit", icon: 'icon', link: 'link', });
0debug
static void raw_aio_cancel(BlockDriverAIOCB *blockacb) { int ret; RawAIOCB *acb = (RawAIOCB *)blockacb; RawAIOCB **pacb; ret = aio_cancel(acb->aiocb.aio_fildes, &acb->aiocb); if (ret == AIO_NOTCANCELED) { while (aio_error(&acb->aiocb) == EINPROGRESS); } pacb = &posix_aio_state->first_aio; for(;;) { if (*pacb == NULL) { break; } else if (*pacb == acb) { *pacb = acb->next; raw_fd_pool_put(acb); qemu_aio_release(acb); break; } pacb = &acb->next; } }
1threat
Issue with gist indentation : <p>When creating a Gist on Github there is a setting for indentation (tabs or spaces; size 2, 4, or 8). After setting indents to tabs size 4, it changes to tabs size 8 after I save it. Editing it afterwords doesn't do anything. Other settings don't produce the expected result either. Am I misunderstanding this feature somehow? Can't find any documentation regarding this.</p>
0debug
static int decode_band(IVI5DecContext *ctx, int plane_num, IVIBandDesc *band, AVCodecContext *avctx) { int result, i, t, idx1, idx2; IVITile *tile; band->buf = band->bufs[ctx->dst_buf]; band->ref_buf = band->bufs[ctx->ref_buf]; band->data_ptr = ctx->frame_data + (get_bits_count(&ctx->gb) >> 3); result = decode_band_hdr(ctx, band, avctx); if (result) { av_log(avctx, AV_LOG_ERROR, "Error while decoding band header: %d\n", result); return -1; } if (band->is_empty) { av_log(avctx, AV_LOG_ERROR, "Empty band encountered!\n"); return -1; } band->rv_map = &ctx->rvmap_tabs[band->rvmap_sel]; for (i = 0; i < band->num_corr; i++) { idx1 = band->corr[i*2]; idx2 = band->corr[i*2+1]; FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]); FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]); } for (t = 0; t < band->num_tiles; t++) { tile = &band->tiles[t]; tile->is_empty = get_bits1(&ctx->gb); if (tile->is_empty) { ff_ivi_process_empty_tile(avctx, band, tile, (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3)); align_get_bits(&ctx->gb); } else { tile->data_size = ff_ivi_dec_tile_data_size(&ctx->gb); result = decode_mb_info(ctx, band, tile, avctx); if (result < 0) break; if (band->blk_size == 8) { band->intra_base = &ivi5_base_quant_8x8_intra[band->quant_mat][0]; band->inter_base = &ivi5_base_quant_8x8_inter[band->quant_mat][0]; band->intra_scale = &ivi5_scale_quant_8x8_intra[band->quant_mat][0]; band->inter_scale = &ivi5_scale_quant_8x8_inter[band->quant_mat][0]; } else { band->intra_base = ivi5_base_quant_4x4_intra; band->inter_base = ivi5_base_quant_4x4_inter; band->intra_scale = ivi5_scale_quant_4x4_intra; band->inter_scale = ivi5_scale_quant_4x4_inter; } result = ff_ivi_decode_blocks(&ctx->gb, band, tile); if (result < 0) { av_log(avctx, AV_LOG_ERROR, "Corrupted blocks data encountered!\n"); break; } } } for (i = band->num_corr-1; i >= 0; i--) { idx1 = band->corr[i*2]; idx2 = band->corr[i*2+1]; FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]); FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]); } #if IVI_DEBUG if (band->checksum_present) { uint16_t chksum = ivi_calc_band_checksum(band); if (chksum != band->checksum) { av_log(avctx, AV_LOG_ERROR, "Band checksum mismatch! Plane %d, band %d, received: %x, calculated: %x\n", band->plane, band->band_num, band->checksum, chksum); } } #endif return result; }
1threat
MariaDB - cannot login as root : <p>I am trying to setup MariaDB (10.0.29) on Ubuntu (16.04.02). After I installed it and started the process (<code>sudo service mysql start</code>), I cannot login as <code>root</code> even though I originally set the password to blank.</p> <p>Ie <code>mysql -u root</code> will deny me access. I logged in through <code>sudo mysql</code> and checked the user table, ie. <code>select user, password, authentication_string from mysql.user</code> and as expected:</p> <pre><code>+---------+----------+-----------------------+ | User | password | authentication_string | +---------+----------+-----------------------+ | root | | | +---------+----------+-----------------------+ </code></pre> <p>I also created a new user, ie. <code>create user 'test'@'localhost' identified by '';</code> and when I try to do <code>mysql -u test</code> (empty password), it works as expected and logs me in.</p> <p>The user table looks like this:</p> <pre><code>+---------+----------+-----------------------+ | User | password | authentication_string | +---------+----------+-----------------------+ | root | | | | test | | | +---------+----------+-----------------------+ </code></pre> <p>So, can anyone tell me why I cannot login as <code>root</code> with empty password but I can login as <code>test</code>?</p>
0debug
how to create and save doc file using php and database : im doing a program for online leave application after loging in the data is to be saved in a .doc file , which will be used afterwards. the creation of .doc file is completed using the following code ... $pdf_data = $pdf->Output('C:\wamp\www\finalproject\mywork\fpdf\lvapp.doc','F'); using this code i am able to create .doc file...... but i need to change the name of file each time and dynamically .... ie. according to the username of the user....the doc file should have the same name..... plz help
0debug
OAuth 2.0 and Azure Active Directory - error AADSTS90009 : <p>I'm trying to authorize access to our web application by using OAuth 2.0 and Azure AD. Guide <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-code" rel="noreferrer">here</a>.</p> <p>The user is redirected to similar URL:</p> <pre><code>https://login.microsoftonline.com/common/oauth2/authorize? client_id=d220846b-1916-48d2-888b-9e16f6d9848b&amp; response_type=code&amp; response_mode=query&amp; state=[secure-random]&amp; redirect_uri=[my_uri]&amp; resource=[my app ID uri taken from app settings] </code></pre> <p>I'm getting the following error then:</p> <blockquote> <p>AADSTS90009: Application 'd220846b-1916-48d2-888b-9e16f6d9848b' is requesting a token for itself. This scenario is supported only if resource is specified using the GUID based App Identifier.</p> </blockquote> <p>This description does not really help me. I've checked this <a href="https://social.msdn.microsoft.com/Forums/azure/en-US/3de0c14d-808f-47c3-bdd6-c29758045de9/azure-ad-authentication-issue-aadsts90009?forum=WindowsAzureAD#cf3986f5-3422-44d1-bcb7-3a4201f68fa2(I" rel="noreferrer">thread</a>, but I'm still lost.</p> <p>What does this error mean and which is the GUID based App Identifier? How should the value of the resource look like? Help much appreciated.</p>
0debug
Does a thread waiting on IO also block a core? : <p>In the synchronous/blocking model of computation we usually say that a thread of execution will wait (be <em>blocked</em>) while it waits for an IO task to complete.</p> <p>My question is simply will this usually cause the CPU core executing the thread to be idle, or will a thread waiting on IO usually be context switched out and put into a waiting state until the IO is ready to be processed?</p>
0debug
Does random.randint() generate the random number? All my guesses are always wrong? : <p>I have set the guess_limit to 6 and random.randint(0, 6), even if I guess 1,2,3,4,5,6, it will always return "Out of guesses!" So my question is does random.randint() is calling the function or there is no random number if the function is not called. Please help</p> <pre class="lang-py prettyprint-override"><code>import random guess = "" guess_limit = 6 guess_count = 0 out_of_guesses = False hiden_number = random.randint(1, 6) while guess != hiden_number and not (out_of_guesses): if guess_count &lt; guess_limit: guess = input("Enter the number: ") guess_count += 1 else: out_of_guesses = True if out_of_guesses: print("Out of guesses!") else: print("You Win") </code></pre> <pre><code> Enter the number: 1 Enter the number: 2 Enter the number: 3 Enter the number: 4 Enter the number: 5 Enter the number: 6 Out of guesses! </code></pre> <p>"If the random.randint(1, 6) range is 1 to 6 how is it possible that I am missing to guess the random number"</p>
0debug
Encrypt a String in Python That Just Can Decrypt with str encrypted with : <p>I Want To Encrypt User Passwords With Their Password <br /> I Mean That The Encrypted String <br /> Can Only Decrypt With The Main Password User Entered</p> <blockquote> <p>User Entered 12345 for Password <br /> The Encrypted Value Only Can Decrypt With 12345 Key</p> </blockquote>
0debug
static void inc_refcounts(BlockDriverState *bs, BdrvCheckResult *res, uint16_t *refcount_table, int refcount_table_size, int64_t offset, int64_t size) { BDRVQcowState *s = bs->opaque; int64_t start, last, cluster_offset; int k; if (size <= 0) return; start = start_of_cluster(s, offset); last = start_of_cluster(s, offset + size - 1); for(cluster_offset = start; cluster_offset <= last; cluster_offset += s->cluster_size) { k = cluster_offset >> s->cluster_bits; if (k < 0) { fprintf(stderr, "ERROR: invalid cluster offset=0x%" PRIx64 "\n", cluster_offset); res->corruptions++; } else if (k >= refcount_table_size) { fprintf(stderr, "Warning: cluster offset=0x%" PRIx64 " is after " "the end of the image file, can't properly check refcounts.\n", cluster_offset); res->check_errors++; } else { if (++refcount_table[k] == 0) { fprintf(stderr, "ERROR: overflow cluster offset=0x%" PRIx64 "\n", cluster_offset); res->corruptions++; } } } }
1threat
android rxjava sort list with comparator class : <p>I started to use rxjava with my android projects. I need to sort returning event list from api call. I wrote comparator class to sort list :</p> <pre><code>public class EventParticipantComparator { public static class StatusComparator implements Comparator&lt;EventParticipant&gt; { @Override public int compare(EventParticipant participant1, EventParticipant participant2) { return participant1.getStatus() - participant2.getStatus(); } } } </code></pre> <p>I can use this class with classic Collections class.</p> <pre><code>Collections.sort(participants, new EventParticipantComparator.StatusComparator()); </code></pre> <p>how can I achieve this situation with reactive way ? <strong>also if there are any way to sort list asynchronously, I will prefer that way.</strong></p> <p>Reactive way without sorting list :</p> <pre><code>dataManager.getEventImplementer().getParticipants(event.getId()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Subscriber&lt;List&lt;EventParticipant&gt;&gt;() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(List&lt;EventParticipant&gt; eventParticipants) { } }); </code></pre>
0debug
Java sorting ArrayList of String Array : <p>I have an ArrayList in the form <code>ArrayList&lt;String[]&gt; table_list = new ArrayList&lt;String[]&gt;();</code></p> <p>So for example <code>table_list.get(0)</code> would look like <code>{"Title", "Yes", "No"}</code>.</p> <p>Now let's say I have a lot of titles and want tot sort those titles in my table alphabetically, what do I do? <code>Collections.sort()</code> does not seem to work.</p> <p>Thanks.</p>
0debug
How to use css modules with create-react-app? : <p>According to a <a href="https://twitter.com/dan_abramov/status/953651118147604480" rel="noreferrer">tweet</a> by Dan Abramov, CSS modules support is there in create-react-app (CRA). One just needs to give extension of <code>module.css</code> to his stylesheets to enable the feature, but this is not working with me. I am having version 1.1.4 of <code>react-scripts</code>. How can I enable css modules with CRA? Thanks</p>
0debug
INLINE float32 packFloat32( flag zSign, int16 zExp, bits32 zSig ) { return ( ( (bits32) zSign )<<31 ) + ( ( (bits32) zExp )<<23 ) + zSig; }
1threat
How to use pipenv to install package from github : <p>Using pipenv to install the spaCy package from github with</p> <pre><code>pipenv install -e git+https://github.com/explosion/spaCy#egg=spacy </code></pre> <p>I run into two problems:</p> <p>(1) Install fails, because the following packages need to be installed before: <code>cython, preshed, murmurhash, thinc</code>. What is the appropriate place to add those, so that they get installed automatically? I tried <code>setup_requires</code> in <code>setup.py</code> but that didn't work.</p> <p>(2) After installing the required packages the install runs through, but the creation of the Pipfile.lock fails with:</p> <pre><code>Adding -e git+https://github.com/explosion/spaCy#egg=spacy to Pipfile's [packages]… Pipfile.lock not found, creating… Locking [dev-packages] dependencies… Locking [packages] dependencies… _dependencies(best_match): File "/home/me/.local/lib/python3.5/site-packages/pipenv/patched/piptools/resolver.py", line 275, in _iter_dependencies for dependency in self.repository.get_dependencies(ireq): File "/home/me/.local/lib/python3.5/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 202, in get_dependencies legacy_results = self.get_legacy_dependencies(ireq) File "/home/me/.local/lib/python3.5/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 221, in get_legacy_dependencies dist = ireq.get_dist() File "/home/me/.local/lib/python3.5/site-packages/pipenv/vendor/pip9/req/req_install.py", line 1069, in get_dist egg_info = self.egg_info_path('').rstrip('/') File "/home/me/.local/lib/python3.5/site-packages/pipenv/vendor/pip9/req/req_install.py", line 515, in egg_info_path 'No files/directories in %s (from %s)' % (base, filename) pip9.exceptions.InstallationError: No files/directories in None (from ) </code></pre> <p>What is the correct way to do this?</p>
0debug
Questions regarding default integer value : <p>I noticed some differences when I make some minor changes on the following codes:</p> <pre><code>#include&lt;stdio.h&gt; int main() { int arrow; printf("%d\n", arrow); int wheel[12]={17, 38, 23, 17, 19, 41, 13, 17, 12, 11, 15, 23}; int initialValue = wheel[arrow]; printf("%d\n", initialValue); arrow = (arrow + 1) % 12; printf("%d\n", arrow); } </code></pre> <p>As I erased the final two rows the initial value of arrow is 1 which corresponds to the value '38' in the array. However, with the complete code the initial value of arrow turns to 0, which points to the value '17' in the array. I want to know why that is the case?</p> <p>Thanks a lot!</p>
0debug
int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device, VdpGetProcAddress *get_proc, unsigned flags) { VDPAUHWContext *hwctx; if (flags != 0) return AVERROR(EINVAL); if (av_reallocp(&avctx->hwaccel_context, sizeof(*hwctx))) return AVERROR(ENOMEM); hwctx = avctx->hwaccel_context; memset(hwctx, 0, sizeof(*hwctx)); hwctx->context.decoder = VDP_INVALID_HANDLE; hwctx->device = device; hwctx->get_proc_address = get_proc; hwctx->reset = 1; return 0; }
1threat
void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, float* L, float* R) { int downsampled = ac->m4ac.ext_sample_rate < sbr->sample_rate; int ch; int nch = (id_aac == TYPE_CPE) ? 2 : 1; if (sbr->start) { sbr_dequant(sbr, id_aac); } for (ch = 0; ch < nch; ch++) { sbr_qmf_analysis(&ac->dsp, &sbr->mdct_ana, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, (float*)sbr->qmf_filter_scratch, sbr->data[ch].W); sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W); if (sbr->start) { sbr_hf_inverse_filter(sbr->alpha0, sbr->alpha1, sbr->X_low, sbr->k[0]); sbr_chirp(sbr, &sbr->data[ch]); sbr_hf_gen(ac, sbr, sbr->X_high, sbr->X_low, sbr->alpha0, sbr->alpha1, sbr->data[ch].bw_array, sbr->data[ch].t_env, sbr->data[ch].bs_num_env); sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); sbr_env_estimate(sbr->e_curr, sbr->X_high, sbr, &sbr->data[ch]); sbr_gain_calc(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a); sbr_hf_assemble(sbr->data[ch].Y, sbr->X_high, sbr, &sbr->data[ch], sbr->data[ch].e_a); } sbr_x_gen(sbr, sbr->X[ch], sbr->X_low, sbr->data[ch].Y, ch); } if (ac->m4ac.ps == 1) { if (sbr->ps.start) { ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); } else { memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0])); } nch = 2; } sbr_qmf_synthesis(&ac->dsp, &sbr->mdct, L, sbr->X[0], sbr->qmf_filter_scratch, sbr->data[0].synthesis_filterbank_samples, &sbr->data[0].synthesis_filterbank_samples_offset, downsampled); if (nch == 2) sbr_qmf_synthesis(&ac->dsp, &sbr->mdct, R, sbr->X[1], sbr->qmf_filter_scratch, sbr->data[1].synthesis_filterbank_samples, &sbr->data[1].synthesis_filterbank_samples_offset, downsampled); }
1threat
Javascript change .css with variable from text box : Seems real simple but im missing something... lets say I want this code below but I dont want the "12px" to be static.. i want to use the variable fontInput . How would I rewrite this? ``` var fontInput = document.getElementById("changesize").value; $('.schedule-show').css({"font-size":"12px"}); ```
0debug
Strange symbol shows up on website (L SEP)? : <p>I noticed on my website, <a href="http://www.cscc.org.sg/" rel="noreferrer">http://www.cscc.org.sg/</a>, there's this odd symbol that shows up.</p> <p><a href="https://i.stack.imgur.com/NR8n9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NR8n9.png" alt="enter image description here"></a></p> <p>It says L SEP. In the HTML Code, it display the same thing.</p> <p><a href="https://i.stack.imgur.com/NiO8L.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NiO8L.png" alt="enter image description here"></a></p> <p>Can someone shows me how to remove them?</p>
0debug
Can't use System.Configuration.Configuration manager in a .NET Standard2.0 library on .NET FX4.6 : <p>I have an assembly created in <em>NetStandard2.0</em>. It reads AppSettings using <strong>System.Configuration.ConfigurationManager</strong>. I have installed nuget package of <strong>System.Configuration.ConfigurationManager</strong> with version 4.4.X which is suitable for <em>NetStandard2.0</em>.</p> <p>When I refer this assembly in console app (.Net Core) it is reading AppSettings properly, but when I refer this assembly in old .NetFramework(4.6.X) console app it is not working and throwing an exception.</p> <p>Please see the code below.</p> <p><strong>Assembly 1: NetStandard 2.0</strong></p> <p><strong>Nuget: System.Configuration.ConfigurationManager 4.4.0</strong></p> <pre><code>using System.Configuration; namespace Bootstrapper.Lib { public class Bootstrapper { public Bootstrapper() { } public void LoadAppSettings() { string serachPattern= ConfigurationManager.AppSettings["AssemblySearchPattern"]; } } } </code></pre> <p><strong>Console App: NetFx 4.6.X</strong></p> <pre><code>using System; using Bootstrapper.Lib; namespace Bootstrapper.Console { class Program { static void Main(string[] args) { new Bootstrapper().LoadAppSettings(); } } } </code></pre> <p><strong>Exception After Run:</strong></p> <pre><code>'Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.' </code></pre> <p>It will work with Console App developed using .NetCore.</p> <p>Please help!!!</p>
0debug
static void reclaim_list_el(struct rcu_head *prcu) { struct list_element *el = container_of(prcu, struct list_element, rcu); g_free(el); atomic_add(&n_reclaims, 1); }
1threat
xampp phpmyadmin, Incorrect format parameter : <p>Im trying to import the database of my client side (wordpress platform) to localhost (using xampp). </p> <p>Other clients' sites work OK, except for this one particular site. When I want to import it, it just showed "phpMyAdmin - Error. Incorrect format parameter". <a href="https://i.stack.imgur.com/Q0zyd.jpg" rel="noreferrer">The error image</a></p> <p>I tried googled it, but it's like no one having this error when importing a database.</p> <p>Do you guys have any idea? Feel free to ask anything, I'm not sure what information I need to provide since I just using quick exporting and the import setting I just let it remain default.</p>
0debug
Group same object key in array javascript : I have data like this : [ { "ru":"R401", "tot":[1, 1, 1, 1], "unit":["OFFSITE","OFFSITE","OFFSITE","RCU"] } ] I want to groupping the object 'tot' and 'unit' then push it into a new array if the 'tot' and 'unit' is same, but my logic is bad. And I want the output become like this : [ { "ru":"R401", "tot":[1, 1], "unit":["OFFSITE","RCU"] } ] How can I did it ? some people wanna help me ? thx before it.
0debug
3dtouch to present(peek without pop) UIView like contacts app : <p>I'm trying to implement 3D Touch feature that presents a summary of information (like Peek). But I don't want that it pops. I just want to preview the information like contacts app does with contatcs:</p> <p><a href="https://i.stack.imgur.com/71H3o.png" rel="noreferrer"><img src="https://i.stack.imgur.com/71H3o.png" alt="enter image description here"></a></p> <p>It only presents an UIView and doesn't deal with two levels of force (peek and pop).</p> <p>How can I do something like this?</p> <p>Ps.: I don't want to deal with long press gesture.</p>
0debug
static int encode_codebook(CinepakEncContext *s, int *codebook, int size, int chunk_type_yuv, int chunk_type_gray, unsigned char *buf) { int x, y, ret, entry_size = s->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4; ret = write_chunk_header(buf, s->pix_fmt == AV_PIX_FMT_YUV420P ? chunk_type_yuv : chunk_type_gray, entry_size * size); for(x = 0; x < size; x++) for(y = 0; y < entry_size; y++) buf[ret++] = codebook[y + x*entry_size] ^ (y >= 4 ? 0x80 : 0); return ret; }
1threat
Pure CSS Continuous Horizontal Text Scroll Without Break : <p>I'm trying to create a news ticker with horizontal text that scrolls continuously without a break between loops. Ideally, the solution would be pure css/html, but I don't know if that's possible. Here's my rudimentary attempt so far: <a href="http://jsfiddle.net/lgants/ncgsrnza/" rel="noreferrer">http://jsfiddle.net/lgants/ncgsrnza/</a>. Note that the fiddle contains an unwanted break between each loop. </p> <pre><code>&lt;p class="marquee"&gt;&lt;span&gt;This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text&lt;/span&gt;&lt;/p&gt; .marquee { margin: 0 auto; white-space: nowrap; overflow: hidden; } .marquee span { display: inline-block; padding-left: 100%; animation: marquee 5s linear infinite; } </code></pre>
0debug
CSS background-image width 100% height auto : <p>I need some kind of an elegant solution for background-image width 100% height auto. It must be the same way as it behaves like as if you use image src. I will use the example of another question on stackoverflow as the answers there did not work for me, nor did they work correctly at all. </p> <p>Note: I will be putting this in css grids which will have an auto width and the image itself will have a border. </p> <p>If there is a js solution, as long as it works, i don't mind.</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-css lang-css prettyprint-override"><code>#image { background-image: url(http://www.w3schools.com/css/trolltunga.jpg); background-size: 100% auto; background-position: center top; background-repeat: no-repeat; width: 100%; height: auto; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="image"&gt;some content here&lt;/div&gt;</code></pre> </div> </div> </p>
0debug
Does Azure WebJob look at the app.config once deployed : <p>I have a Web site running on Azure App Services. It has a WebJob that deploys with it, and thus gets put in it's App_data folder once deployed.</p> <p>If I FTP to the wwwroot/app_data folder of my site once deployed, the app.config file has none of the configured settings that I set up in the "Application Settings Blade" in the Azure portal. The settings are changed in my web.config for the Website though.</p> <p>The most curious thing is that when I run the WebJob, the log output indicates that the correct settings are being used!!</p> <p>So as per my title, does the WebJob use the App.Settings file once deployed or does it use some kind of in-memory copy of the app-settings from the azure portal, or does it use what is in the web.config of the website?</p> <p>Just to pre-emt a possible question, I know that the app.settings gets renamed to myappname.exe.config</p>
0debug
Optional value returning nil with ?? operator : <p>I'm trying to convert an optional string to a Double, but when I unwrap my value is not taken:</p> <pre><code>let currentSwimDistanceTravelled = defaults.string(forKey: "SwimTotal") ?? "0.0" </code></pre> <p>After this code is run currentSwimDistanceTravelled is assigned a String value of "" as opposed to "0.0".</p> <p>Sorry if I've missed something basic here, but I thought ?? was the best way to unwrap an optional.</p>
0debug
Remove same value in associative array : <p>I have following associative array I wanna remove those ones that which have same value and keep one of theme(for example there is tow 124 value one of theme should be removed):</p> <pre><code>Array ( [0] =&gt; 124 [1] =&gt; 124 [2] =&gt; 35 ) </code></pre>
0debug
LDAP Authentication with a service account in Java : <p>I am trying to authenticate users from LDAP with a service account created. Im getting below error on <strong>ctx = new InitialDirContext(env);</strong></p> <blockquote> <p>[LDAP: error code 49 - 8009030C: LdapErr: DSID-0C0903A8, comment: AcceptSecurityContext error, data 2030, v1db1</p> </blockquote> <p><strong><em>Can someone help me to understand where am I going wrong ?</em></strong></p> <p>This is my java file</p> <pre><code>/** * */ package com.dei; import java.util.Hashtable; import javax.naming.AuthenticationException; import javax.naming.Context; import javax.naming.NameNotFoundException; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.SizeLimitExceededException; import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; import javax.naming.directory.DirContext; import javax.naming.directory.InitialDirContext; import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; public class LdapConnector { private static final String LDAP_SERVER_PORT = "389"; private static final String LDAP_SERVER = "server"; private static final String LDAP_BASE_DN = "OU=role,OU=roles,OU=de,OU=apps,DC=meta,DC=company,DC=com"; private static final String LDAP_BIND_DN = "cn=service_account";//service account userid provided by LDAP team private static final String LDAP_BIND_PASSWORD = "password";///service account pwd provided by LDAP team public Boolean validateLogin(String userName, String userPassword) { Hashtable&lt;String, String&gt; env = new Hashtable&lt;String, String&gt;(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://" + LDAP_SERVER + ":" + LDAP_SERVER_PORT + "/" + LDAP_BASE_DN); // To get rid of the PartialResultException when using Active Directory env.put(Context.REFERRAL, "follow"); // Needed for the Bind (User Authorized to Query the LDAP server) env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, LDAP_BIND_DN); env.put(Context.SECURITY_CREDENTIALS, LDAP_BIND_PASSWORD); DirContext ctx; try { ctx = new InitialDirContext(env); } catch (NamingException e) { throw new RuntimeException(e); } NamingEnumeration&lt;SearchResult&gt; results = null; try { SearchControls controls = new SearchControls(); controls.setSearchScope(SearchControls.SUBTREE_SCOPE); // Search Entire Subtree controls.setCountLimit(1); //Sets the maximum number of entries to be returned as a result of the search controls.setTimeLimit(5000); // Sets the time limit of these SearchControls in milliseconds String searchString = "(&amp;(objectCategory=user)(sAMAccountName=" + userName + "))"; results = ctx.search("", searchString, controls); if (results.hasMore()) { SearchResult result = (SearchResult) results.next(); Attributes attrs = result.getAttributes(); Attribute dnAttr = attrs.get("distinguishedName"); String dn = (String) dnAttr.get(); // User Exists, Validate the Password env.put(Context.SECURITY_PRINCIPAL, dn); env.put(Context.SECURITY_CREDENTIALS, userPassword); new InitialDirContext(env); // Exception will be thrown on Invalid case System.out.println("Login successful"); return true; } else return false; } catch (AuthenticationException e) { // Invalid Login System.out.println("Login failed" +e.getMessage()); return false; } catch (NameNotFoundException e) { // The base context was not found. System.out.println("Login failed" +e.getMessage()); return false; } catch (SizeLimitExceededException e) { throw new RuntimeException("LDAP Query Limit Exceeded, adjust the query to bring back less records", e); } catch (NamingException e) { throw new RuntimeException(e); } finally { if (results != null) { try { results.close(); } catch (Exception e) { /* Do Nothing */ } } if (ctx != null) { try { ctx.close(); } catch (Exception e) { /* Do Nothing */ } } } } } </code></pre>
0debug
What is the difference between kafka earliest and latest offset values : <p><code>producer</code> sends messages 1, 2, 3, 4</p> <p><code>consumer</code> receives messages 1, 2, 3, 4</p> <p><code>consumer</code> crashes/disconnects</p> <p><code>producer</code> sends messages 5, 6, 7</p> <p><code>consumer</code> comes back up and should receive messages starting from 5 instead of 7</p> <p>For this kind of result, which <code>offset</code> value I have to use and what are the other changes/configurations need to do</p>
0debug
void OPPROTO op_srli_T0 (void) { T0 = T0 >> PARAM1; RETURN(); }
1threat
Searching in XML file - PHP : <p>My XML looks like this</p> <pre><code>&lt;root lastUpdated="20180101120330" ttl="24"&gt; &lt;Parent1&gt;...&lt;/Parent1&gt; &lt;Parent2&gt; &lt;sub parm1="google.com" parm2="email@email.com" parm3="5343243434" parm4="google" parm5="876787" parm6="" parm7="ACTIVE"&gt;...&lt;/sub&gt; &lt;sub parm1="yahoo.com" parm2="email2@email.com" parm3="4434343" parm4="yahoo" parm5="232322" parm6="" parm7="ACTIVE"&gt;...&lt;/sub&gt; &lt;sub parm1="facebook.com" parm2="email3@email.com" parm3="222334" parm4="facebook" parm5="12233" parm6="" parm7="ACTIVE"&gt;...&lt;/sub&gt; &lt;/Parent2&gt; &lt;/root&gt; </code></pre> <p>I want to look for parm3 and if it matches it should return parm1. XML is stored in local directory.</p>
0debug
CSS Grid Layout Gap Box Sizing : <p>I have a CSS grid that occupies 100% width and 100% height of a window (the body element has <code>display: grid;</code>). The grid has row and column templates and elements which occupy 100% of their allocated space. However, when I add a <code>grid-gap</code> to the grid, it makes the grid too large for the window, forcing scrollbars to appear. How can I stop the <code>grid-gap</code> from adding to the dimensions of the grid - similar to how <code>box-sizing: border-box;</code> stops padding from adding to the dimensions of an element? Instead, I want the gaps to shrink the cells of the grid.</p> <p>Thanks. <a href="https://i.stack.imgur.com/pnTCY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pnTCY.png" alt="like this"></a></p>
0debug
static void generate_codebook(RoqContext *enc, RoqTempdata *tempdata, int *points, int inputCount, roq_cell *results, int size, int cbsize) { int i, j, k; int c_size = size*size/4; int *buf; int *codebook = av_malloc(6*c_size*cbsize*sizeof(int)); int *closest_cb; if (size == 4) closest_cb = av_malloc(6*c_size*inputCount*sizeof(int)); else closest_cb = tempdata->closest_cb2; ff_init_elbg(points, 6*c_size, inputCount, codebook, cbsize, 1, closest_cb, &enc->randctx); ff_do_elbg(points, 6*c_size, inputCount, codebook, cbsize, 1, closest_cb, &enc->randctx); if (size == 4) av_free(closest_cb); buf = codebook; for (i=0; i<cbsize; i++) for (k=0; k<c_size; k++) { for(j=0; j<4; j++) results->y[j] = *buf++; results->u = (*buf++ + CHROMA_BIAS/2)/CHROMA_BIAS; results->v = (*buf++ + CHROMA_BIAS/2)/CHROMA_BIAS; results++; } av_free(codebook); }
1threat
def sum_difference(n): sumofsquares = 0 squareofsum = 0 for num in range(1, n+1): sumofsquares += num * num squareofsum += num squareofsum = squareofsum ** 2 return squareofsum - sumofsquares
0debug
What is the best C++ data structure that could be used for storing and managing a collection of integers? : <p>this is my first StackOverflow question so please let me know if I didn't follow community guidelines with this question and if I should delete it.</p> <p>I got my first ever interview question and I got rejected because of my implementation.</p> <p>The question is:</p> <p>Design and implement a C++ class that stores a collection of integers. On construction, the collection should be empty. The same number may be stored more than once. </p> <p>Implement the following methods: </p> <ol> <li><p>Insert(int x). Insert an entry for the value “x”. </p></li> <li><p>Erase(int x). Remove one entry with the value “x” (if one exists) from the collection. </p></li> <li><p>Erase(int from, int to). Remove all the entries with a value in the range [from, to). </p></li> <li><p>Count(int from, int to). Count how many entries have a value in the range [from, to). </p></li> </ol> <p>I thought a good implementation would be to use linked lists since it uses non-contiguous memory and removing entries would not require shuffling a lot of data (like in vectors or arrays). However, I got feedback from the company saying my implementation was O(n^2) time complexity and was very inefficient so I was rejected. I don't want to repeat the same mistake if a similar question pops up in another interview so I'd like to know what is the best way to approach this question (a friend suggested using maps but he is also unsure).</p> <p>My code is:</p> <pre><code>void IntegerCollector::insert(int x) { entries.push_back(x); } void IntegerCollector::erase(int x) { list&lt;int&gt;::iterator position = find(entries.begin(), entries.end(), x); if (position != entries.end()) entries.erase(position); } void IntegerCollector::erase(int from, int to) { list&lt;int&gt;::iterator position = entries.begin(); while (position != entries.end()) { if (*position &gt;= from &amp;&amp; *position &lt;= to) position = entries.erase(position); else position++; } } int IntegerCollector::count(int from, int to) { list&lt;int&gt;::iterator position = entries.begin(); int count = 0; while (position != entries.end()) { if (*position &gt;= from &amp;&amp; *position &lt;= to) count++; position++; } return count; } </code></pre> <p>The feedback mentioned that they would only hire candidates that can implement solutions with O(nlogn) complexity.</p>
0debug