problem
stringlengths
26
131k
labels
class label
2 classes
How to add a property to a class : <p>I'm working on a new application, based on templates, STL, namespaces, ... (my collegues have taken all necessary steps to make a mess), now I just want to add a property to a class, and this does not work, let me show you):</p> <p>Within a header-file:</p> <pre><code>namespace utils{ class Logging_Manager : public Singleton&lt;Logging_Manager&gt; { friend Singleton&lt;Logging_Manager&gt;; Logging_Manager(); private: std::vector&lt;std::shared_ptr&lt;Single_Logger&gt;&gt; logging_modules; LogLevelType loglevel; // 0 : no logging, 1 : info logging, (2-4 are not used), 5 : debug, 6 : everything public: Timer getDebuggerTimer; Timer getFileTimer; </code></pre> <p>I've just added the last entries <code>getDebuggerTimer</code> and <code>getFileTimer</code> myself and this does not compile, due to the compiler errors C3646 and C4430.</p> <p>All I mean is that both are properties of the type <code>Timer</code>, I don't mean those things to be templates of some methods which might be abstract, virtual, or whatsoever, no they are just to meant as properties, nothing more nothing less.</p> <p>As I didn't find a way to add both timers to my header file, my boss has just solved the issue as follows:</p> <pre><code>class Timer; // this class is defined elsewhere, how can it be put here and make things work? namespace utils{ class Logging_Manager : public Singleton&lt;Logging_Manager&gt; { friend Singleton&lt;Logging_Manager&gt;; Logging_Manager(); private: std::shared_ptr&lt;Timer&gt; getDebuggerTimer; std::shared_ptr&lt;Timer&gt; getFileTimer; </code></pre> <p>In other words: he did not add an inclusion, but he added a reference to something the header does not know: <code>class Timer</code>.</p> <p>In top of this, he added a shared pointer, which magically did something.</p> <p>I'm completely lost here: it looks like STL has added programming rules like:<br/> - In case you want something to work, don't add an inclusion, but add a reference (but how does your code know what the reference means?) - You can add shared pointers (or other STL inventions), who will make your code work.</p> <p>?????</p> <p>Can anybody shed a light to this?</p>
0debug
static void invalid_dict_comma(void) { QObject *obj = qobject_from_json("{'abc':32,}", NULL); g_assert(obj == NULL); }
1threat
How to iterate array inside array in java script : <p>Can anybody tell how to iterate array inside array in java script</p> <p>eg Var a =[1,3,[6],7,[8]] </p> <p>Thanks</p>
0debug
Counting number of words which starts with 'A' letter? : I just started learning C after Java, so it's a little bit confusing to me. I tried to write a program with idea of counting the numbers of words which start with 'A' letter. The problem is that it only reads the first word I enter and ignore the rest of the sentence. Can somebody help me with this one? I would appreciate it. #include <stdio.h> #include <string.h> void main() { char sentence[200]; int i; int counter = 0; printf("Enter sentence: "); scanf("%s", &sentence); for (i = 0; sentence[i] != 0, sentence[i] != ' '; i++){ if (sentence[i] == 'A') { counter = counter +1; } } printf("No. of A in string %s > %d\n", sentence, counter); return 0; }
0debug
How to run a program from github in Python : <p>I am trying to run a code that was provided on github. I have downloaded and installed all requirements, and I am familiar with accessing json dictionaries. Do I need to input the source url anywhere? Any direction would be helpful. Thanks <a href="https://github.com/hmm/liigadata" rel="nofollow">Git hub </a></p>
0debug
How to add a div ellement inside a file using js or jQuery? : <p>I have 2 different files: "header.php" and "home.php". In the file "header.php" i wrote this code: </p> <pre><code>&lt;div class="slide-area"&gt;&lt;/div&gt; </code></pre> <p>Now, in the file "home.php" i want to add some js or jQuery so i can force the code: </p> <pre><code>&lt;div class="slide-area-child"&gt;&lt;/div&gt; </code></pre> <p>that is already inside the file "home.php" to get applied in the file "header.php" between the div with the class "slide-area" so it will be like that:</p> <pre><code>&lt;div class="slide-area"&gt;&lt;div class="slide-area-child"&gt;&lt;/div&gt;&lt;/div&gt; </code></pre>
0debug
static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s) { int tileno, compno; for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++) { if (s->tile[tileno].comp) { for (compno = 0; compno < s->ncomponents; compno++) { Jpeg2000Component *comp = s->tile[tileno].comp + compno; Jpeg2000CodingStyle *codsty = s->tile[tileno].codsty + compno; ff_jpeg2000_cleanup(comp, codsty); } av_freep(&s->tile[tileno].comp); } } av_freep(&s->tile); s->numXtiles = s->numYtiles = 0; }
1threat
Splitting Word document to multiple .txt files using a macro : Right now.. i am splitting a Single word document to Multiple using a custom delimiter. It Creates Multiple Word Files.. i want to create multiple .txt files instead of MS word Files. the code that i am using right now is Sub SplitNotes(delim As String, strFilename As String) Dim doc As Document Dim arrNotes Dim I As Long Dim X As Long Dim Response As Integer arrNotes = Split(ActiveDocument.Range, delim) Response = MsgBox("This will split the document into " & UBound(arrNotes) + 1 & " sections. Do you wish to proceed?", 4) If Response = 7 Then Exit Sub For I = LBound(arrNotes) To UBound(arrNotes) If Trim(arrNotes(I)) <> "" Then X = X + 1 Set doc = Documents.Add doc.Range = arrNotes(I) doc.SaveAs ThisDocument.Path & "\" & strFilename & Format(X, "000") doc.Close True End If Next I End Sub Sub test() ' delimiter & filename SplitNotes "%%%%%%%%%%%%%%", "Notes " End Sub Can anyone help me with this please.
0debug
int cpu_x86_exec(CPUX86State *env1) { int saved_T0, saved_T1, saved_A0; CPUX86State *saved_env; #ifdef reg_EAX int saved_EAX; #endif #ifdef reg_ECX int saved_ECX; #endif #ifdef reg_EDX int saved_EDX; #endif #ifdef reg_EBX int saved_EBX; #endif #ifdef reg_ESP int saved_ESP; #endif #ifdef reg_EBP int saved_EBP; #endif #ifdef reg_ESI int saved_ESI; #endif #ifdef reg_EDI int saved_EDI; #endif #ifdef __sparc__ int saved_i7, tmp_T0; #endif int code_gen_size, ret; void (*gen_func)(void); TranslationBlock *tb, **ptb; uint8_t *tc_ptr, *cs_base, *pc; unsigned int flags; saved_T0 = T0; saved_T1 = T1; saved_A0 = A0; saved_env = env; env = env1; #ifdef reg_EAX saved_EAX = EAX; EAX = env->regs[R_EAX]; #endif #ifdef reg_ECX saved_ECX = ECX; ECX = env->regs[R_ECX]; #endif #ifdef reg_EDX saved_EDX = EDX; EDX = env->regs[R_EDX]; #endif #ifdef reg_EBX saved_EBX = EBX; EBX = env->regs[R_EBX]; #endif #ifdef reg_ESP saved_ESP = ESP; ESP = env->regs[R_ESP]; #endif #ifdef reg_EBP saved_EBP = EBP; EBP = env->regs[R_EBP]; #endif #ifdef reg_ESI saved_ESI = ESI; ESI = env->regs[R_ESI]; #endif #ifdef reg_EDI saved_EDI = EDI; EDI = env->regs[R_EDI]; #endif #ifdef __sparc__ asm volatile ("mov %%i7, %0" : "=r" (saved_i7)); #endif CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); DF = 1 - (2 * ((env->eflags >> 10) & 1)); CC_OP = CC_OP_EFLAGS; env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); env->interrupt_request = 0; if (setjmp(env->jmp_env) == 0) { T0 = 0; for(;;) { #ifdef __sparc__ tmp_T0 = T0; #endif if (env->interrupt_request) { env->exception_index = EXCP_INTERRUPT; cpu_loop_exit(); } #ifdef DEBUG_EXEC if (loglevel) { env->regs[R_EAX] = EAX; env->regs[R_EBX] = EBX; env->regs[R_ECX] = ECX; env->regs[R_EDX] = EDX; env->regs[R_ESI] = ESI; env->regs[R_EDI] = EDI; env->regs[R_EBP] = EBP; env->regs[R_ESP] = ESP; env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK); cpu_x86_dump_state(env, logfile, 0); env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); } #endif flags = env->seg_cache[R_CS].seg_32bit << GEN_FLAG_CODE32_SHIFT; flags |= env->seg_cache[R_SS].seg_32bit << GEN_FLAG_SS32_SHIFT; flags |= (((unsigned long)env->seg_cache[R_DS].base | (unsigned long)env->seg_cache[R_ES].base | (unsigned long)env->seg_cache[R_SS].base) != 0) << GEN_FLAG_ADDSEG_SHIFT; if (!(env->eflags & VM_MASK)) { flags |= (env->segs[R_CS] & 3) << GEN_FLAG_CPL_SHIFT; } else { flags |= (1 << GEN_FLAG_VM_SHIFT); flags |= (3 << GEN_FLAG_CPL_SHIFT); } flags |= (env->eflags & (IOPL_MASK | TF_MASK)); cs_base = env->seg_cache[R_CS].base; pc = cs_base + env->eip; tb = tb_find(&ptb, (unsigned long)pc, (unsigned long)cs_base, flags); if (!tb) { spin_lock(&tb_lock); tb = tb_alloc((unsigned long)pc); if (!tb) { tb_flush(); tb = tb_alloc((unsigned long)pc); ptb = &tb_hash[tb_hash_func((unsigned long)pc)]; T0 = 0; } tc_ptr = code_gen_ptr; tb->tc_ptr = tc_ptr; tb->cs_base = (unsigned long)cs_base; tb->flags = flags; ret = cpu_x86_gen_code(tb, CODE_GEN_MAX_SIZE, &code_gen_size); if (ret != 0) { spin_unlock(&tb_lock); raise_exception(EXCP06_ILLOP); } *ptb = tb; tb->hash_next = NULL; tb_link(tb); code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1)); spin_unlock(&tb_lock); } #ifdef DEBUG_EXEC if (loglevel) { fprintf(logfile, "Trace 0x%08lx [0x%08lx] %s\n", (long)tb->tc_ptr, (long)tb->pc, lookup_symbol((void *)tb->pc)); } #endif #ifdef __sparc__ T0 = tmp_T0; #endif if (T0 != 0 && !(env->eflags & TF_MASK)) { spin_lock(&tb_lock); tb_add_jump((TranslationBlock *)(T0 & ~3), T0 & 3, tb); spin_unlock(&tb_lock); } tc_ptr = tb->tc_ptr; gen_func = (void *)tc_ptr; #if defined(__sparc__) __asm__ __volatile__("call %0\n\t" "mov %%o7,%%i0" : : "r" (gen_func) : "i0", "i1", "i2", "i3", "i4", "i5"); #elif defined(__arm__) asm volatile ("mov pc, %0\n\t" ".global exec_loop\n\t" "exec_loop:\n\t" : : "r" (gen_func) : "r1", "r2", "r3", "r8", "r9", "r10", "r12", "r14"); #else gen_func(); #endif } } ret = env->exception_index; env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK); #ifdef reg_EAX EAX = saved_EAX; #endif #ifdef reg_ECX ECX = saved_ECX; #endif #ifdef reg_EDX EDX = saved_EDX; #endif #ifdef reg_EBX EBX = saved_EBX; #endif #ifdef reg_ESP ESP = saved_ESP; #endif #ifdef reg_EBP EBP = saved_EBP; #endif #ifdef reg_ESI ESI = saved_ESI; #endif #ifdef reg_EDI EDI = saved_EDI; #endif #ifdef __sparc__ asm volatile ("mov %0, %%i7" : : "r" (saved_i7)); #endif T0 = saved_T0; T1 = saved_T1; A0 = saved_A0; env = saved_env; return ret; }
1threat
static void vmgenid_set_guid_auto_test(void) { const char *cmd; QemuUUID measured; cmd = "-machine accel=tcg -device vmgenid,id=testvgid," "guid=auto"; qtest_start(cmd); read_guid_from_memory(&measured); g_assert(!qemu_uuid_is_null(&measured)); qtest_quit(global_qtest); }
1threat
static uint64_t qemu_opt_get_size_helper(QemuOpts *opts, const char *name, uint64_t defval, bool del) { QemuOpt *opt = qemu_opt_find(opts, name); uint64_t ret = defval; if (opt == NULL) { const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name); if (desc && desc->def_value_str) { parse_option_size(name, desc->def_value_str, &ret, &error_abort); } return ret; } assert(opt->desc && opt->desc->type == QEMU_OPT_SIZE); ret = opt->value.uint; if (del) { qemu_opt_del_all(opts, name); } return ret; }
1threat
static int avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask, int src_pix_fmt, int has_alpha, int loss_mask) { int dist, i, loss, min_dist, dst_pix_fmt; dst_pix_fmt = -1; min_dist = 0x7fffffff; for(i = 0;i < PIX_FMT_NB; i++) { if (pix_fmt_mask & (1 << i)) { loss = avcodec_get_pix_fmt_loss(i, src_pix_fmt, has_alpha) & loss_mask; if (loss == 0) { dist = avg_bits_per_pixel(i); if (dist < min_dist) { min_dist = dist; dst_pix_fmt = i; } } } } return dst_pix_fmt; }
1threat
sorting with first comes up in array : I want to get an answer ['H','H','A',A] from the input ['H','A','H','A'] basically sorting based from the char that comes up first. could someone help me Thanks
0debug
vb.net FileExist returns false : I have a weird problem. I have a folder with 700+ .jpgs Then I have a Textbox with one filename per line. Now I want to check which file does not exist in the folder, but should be there. This is my code: Dim Counter As Integer = 0 For Each Line As String In tbFileNames.Lines Counter = Counter + 1 If (IO.File.Exists(tbFolder.Text & "\" & tbFileNames.Lines(Counter - 1).ToString & ".jpg")) = False Then tbNotExistingFiles.Text = tbNotExistingFiles.Text & vbNewLine & (tbFileNames.Lines(Counter - 1).ToString) Else End If Next Problem: I get more than 300 "missing" files, but there should be only 7. When I search for the output filenames, they are in the folder, so the FileExists functions returns false, but it shouldn´t.. Where is the problem? Is it the amount of files? Thank you.. :) Bets regards
0debug
echo php variable from javascript and javascript is in php function : i have j.query function in P.h.p function. i have id of a div in p.h.p variable .i want to pass this variable to j.query code. public function food(){ echo '<script> $(document).ready(function () { $("#$this->ccid #food").show(); }); </script>'; }
0debug
static int decode_exp_vlc(WMACodecContext *s, int ch) { int last_exp, n, code; const uint16_t *ptr; float v, max_scale; uint32_t *q, *q_end, iv; const float *ptab = pow_tab + 60; const uint32_t *iptab = (const uint32_t*)ptab; ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits]; q = (uint32_t *)s->exponents[ch]; q_end = q + s->block_len; max_scale = 0; if (s->version == 1) { last_exp = get_bits(&s->gb, 5) + 10; v = ptab[last_exp]; iv = iptab[last_exp]; max_scale = v; n = *ptr++; switch (n & 3) do { case 0: *q++ = iv; case 3: *q++ = iv; case 2: *q++ = iv; case 1: *q++ = iv; } while ((n -= 4) > 0); }else last_exp = 36; while (q < q_end) { code = get_vlc2(&s->gb, s->exp_vlc.table, EXPVLCBITS, EXPMAX); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "Exponent vlc invalid\n"); return -1; } last_exp += code - 60; if ((unsigned)last_exp + 60 > FF_ARRAY_ELEMS(pow_tab)) { av_log(s->avctx, AV_LOG_ERROR, "Exponent out of range: %d\n", last_exp); return -1; } v = ptab[last_exp]; iv = iptab[last_exp]; if (v > max_scale) max_scale = v; n = *ptr++; switch (n & 3) do { case 0: *q++ = iv; case 3: *q++ = iv; case 2: *q++ = iv; case 1: *q++ = iv; } while ((n -= 4) > 0); } s->max_exponent[ch] = max_scale; return 0; }
1threat
void rgb16tobgr15(const uint8_t *src, uint8_t *dst, unsigned int src_size) { unsigned i; unsigned num_pixels = src_size >> 1; for(i=0; i<num_pixels; i++) { unsigned b,g,r; register uint16_t rgb; rgb = src[2*i]; r = rgb&0x1F; g = (rgb&0x7E0)>>5; b = (rgb&0xF800)>>11; dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10); } }
1threat
Gradle: List deprecated features : <p>I am getting a warning about the usage of deprecated features in my build. Is there a way to list all the deprecated features so that I may go through and update my code?</p> <p><strong>*clarification</strong></p> <p>I know I can go to the gradle documentation and see what is now deprecated, what I would specifically like is a way to go through MY code and list out MY deprecated features.</p>
0debug
static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags, abi_ulong target_addr, abi_ulong target_addrlen) { socklen_t addrlen; void *addr; void *host_msg; abi_long ret; host_msg = lock_user(VERIFY_WRITE, msg, len, 0); if (!host_msg) return -TARGET_EFAULT; if (target_addr) { if (get_user_u32(addrlen, target_addrlen)) { ret = -TARGET_EFAULT; goto fail; } if (addrlen < 0 || addrlen > MAX_SOCK_ADDR) { ret = -TARGET_EINVAL; goto fail; } addr = alloca(addrlen); ret = get_errno(recvfrom(fd, host_msg, len, flags, addr, &addrlen)); } else { addr = NULL; ret = get_errno(recv(fd, host_msg, len, flags)); } if (!is_error(ret)) { if (target_addr) { host_to_target_sockaddr(target_addr, addr, addrlen); if (put_user_u32(addrlen, target_addrlen)) { ret = -TARGET_EFAULT; goto fail; } } unlock_user(host_msg, msg, len); } else { fail: unlock_user(host_msg, msg, 0); } return ret; }
1threat
Editing locked files from a CocoaPods framework : <p>I have an Xcode workspace that uses CocoaPods to include several third-party frameworks. I would like to edit a line of source code within one of these dependencies. However, when I do so, Xcode warns me that the file is locked and that any changes I make may not be saved. So my question is: will my changes to the source code be discarded when I run a pod install/update? If not, is there any other scenario, possibly unrelated to CocoaPods, that would discard my changes? And finally, is there any good way that I can edit the source code without running into such problems?</p> <p>Thanks in advance.</p>
0debug
Android: Get Notified when the current Mode inside AudioManager gets changed : <p>In Android I need to get notified when the current <strong>audio mode</strong> gets changed.</p> <p>I can get this value through <a href="http://developer.android.com/reference/android/media/AudioManager.html#getMode()" rel="noreferrer">getMode()</a> but this is polling. </p> <p>I don't want to poll every few seconds. </p> <p>What are my options? </p> <p>(Please note that I'm not asking about ringerMode)</p>
0debug
Can someone help me to fix this code? I search everywhere and I found nothing helpful : Please help fix this: Redundant conformance constraint 'T': 'ReusableView' [enter image description here][1] [1]: https://i.stack.imgur.com/9a1ap.png
0debug
ReactJS SetState not rerendering : <p>I have:</p> <p>JobScreen</p> <pre><code>handleSetView(mode, e) { this.setState({ view: mode }); console.log(this.state.view) } render() { return ( &lt;div className="jobs-screen"&gt; &lt;div className="col-xs-12 col-sm-10 job-list"&gt;&lt;JobList view={this.state.view} /&gt;&lt;/div&gt; &lt;div className="col-xs-12 col-sm-2 panel-container"&gt; &lt;div className="right-panel pull-right"&gt;&lt;RightPanel handleSetView={this.handleSetView} /&gt;&lt;/div&gt; ... ) } </code></pre> <p>RightPanel</p> <pre><code>render() { return ( &lt;div&gt; &lt;div className="controls"&gt; &lt;span className="title"&gt;Views &lt;img src="images\ajax-loader-bar.gif" width="24" id="loader" className={this.state.loading ? "pull-right fadeIn" : "pull-right fadeOut"}/&gt;&lt;/span&gt; &lt;button onClick={this.props.handleSetView.bind(this, 'expanded')}&gt;&lt;img src="/images/icons/32px/libreoffice.png" /&gt;&lt;/button&gt; &lt;button onClick={this.props.handleSetView.bind(this, 'condensed')}&gt;&lt;img src="/images/icons/32px/stack.png" /&gt;&lt;/button&gt; &lt;/div&gt; ... )} </code></pre> <p>JobList</p> <pre><code>render() { var jobs = []; this.state.jobs.forEach((job) =&gt; { jobs.push( &lt;Job key={job.id} job={job} view={this.props.view} loading={this.state.loading} toggleTraderModal={this.props.toggleTraderModal} toggleOFTModal={this.props.toggleOFTModal}/&gt; ); }); return ( &lt;div&gt; {jobs} &lt;/div&gt; ); }; </code></pre> <p>The problem is, is that the changing of the view state does not rerender any of the child elements.</p> <p>How can I get this to work?</p>
0debug
static void l2cap_command(struct l2cap_instance_s *l2cap, int code, int id, const uint8_t *params, int len) { int err; #if 0 if (!id || (id != l2cap->last_id && id != l2cap->next_id)) { fprintf(stderr, "%s: out of sequence command packet ignored.\n", __func__); return; } #else l2cap->next_id = id; #endif if (id == l2cap->next_id) { l2cap->last_id = l2cap->next_id; l2cap->next_id = l2cap->next_id == 255 ? 1 : l2cap->next_id + 1; } else { } switch (code) { case L2CAP_COMMAND_REJ: if (unlikely(len != 2 && len != 4 && len != 6)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } fprintf(stderr, "%s: stray Command Reject (%02x, %04x) " "packet, ignoring.\n", __func__, id, le16_to_cpu(((l2cap_cmd_rej *) params)->reason)); break; case L2CAP_CONN_REQ: if (unlikely(len != L2CAP_CONN_REQ_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_channel_open_req_msg(l2cap, le16_to_cpu(((l2cap_conn_req *) params)->psm), le16_to_cpu(((l2cap_conn_req *) params)->scid)); break; case L2CAP_CONN_RSP: if (unlikely(len != L2CAP_CONN_RSP_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } fprintf(stderr, "%s: unexpected Connection Response (%02x) " "packet, ignoring.\n", __func__, id); break; case L2CAP_CONF_REQ: if (unlikely(len < L2CAP_CONF_REQ_SIZE(0))) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_channel_config_req_msg(l2cap, le16_to_cpu(((l2cap_conf_req *) params)->flags) & 1, le16_to_cpu(((l2cap_conf_req *) params)->dcid), ((l2cap_conf_req *) params)->data, len - L2CAP_CONF_REQ_SIZE(0)); break; case L2CAP_CONF_RSP: if (unlikely(len < L2CAP_CONF_RSP_SIZE(0))) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } if (l2cap_channel_config_rsp_msg(l2cap, le16_to_cpu(((l2cap_conf_rsp *) params)->result), le16_to_cpu(((l2cap_conf_rsp *) params)->flags) & 1, le16_to_cpu(((l2cap_conf_rsp *) params)->scid), ((l2cap_conf_rsp *) params)->data, len - L2CAP_CONF_RSP_SIZE(0))) fprintf(stderr, "%s: unexpected Configure Response (%02x) " "packet, ignoring.\n", __func__, id); break; case L2CAP_DISCONN_REQ: if (unlikely(len != L2CAP_DISCONN_REQ_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_channel_close(l2cap, le16_to_cpu(((l2cap_disconn_req *) params)->dcid), le16_to_cpu(((l2cap_disconn_req *) params)->scid)); break; case L2CAP_DISCONN_RSP: if (unlikely(len != L2CAP_DISCONN_RSP_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } fprintf(stderr, "%s: unexpected Disconnection Response (%02x) " "packet, ignoring.\n", __func__, id); break; case L2CAP_ECHO_REQ: l2cap_echo_response(l2cap, params, len); break; case L2CAP_ECHO_RSP: fprintf(stderr, "%s: unexpected Echo Response (%02x) " "packet, ignoring.\n", __func__, id); break; case L2CAP_INFO_REQ: if (unlikely(len != L2CAP_INFO_REQ_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } l2cap_info(l2cap, le16_to_cpu(((l2cap_info_req *) params)->type)); break; case L2CAP_INFO_RSP: if (unlikely(len != L2CAP_INFO_RSP_SIZE)) { err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; goto reject; } fprintf(stderr, "%s: unexpected Information Response (%02x) " "packet, ignoring.\n", __func__, id); break; default: err = L2CAP_REJ_CMD_NOT_UNDERSTOOD; reject: l2cap_command_reject(l2cap, id, err, 0, 0); break; } }
1threat
nodejs,mysql The server closed the connection : I'm trying to Node.js and MySql but im receiving this error : :Error: Connection lost: The server closed the connection. my code here. var mysql = require('mysql'); var config ={ connectionLimit : 100, waitForConnections : true, queueLimit :0, debug : true, wait_timeout : 28800, connect_timeout :10, host : "localhost", user : " root ", password : " root ", database : "mydb" }; var table = 'mytable'; var connection; function handleConnection(){ connection = mysql.createConnection(config); connection.connect(function(err){ console.log("connected"); }); connection.query('select * from' + table, function(err,result,fields){ if (!err){ console.log("result :" + result); } else{ console.log("error1 :" +err); } }); } Thanks in advance.
0debug
How to use lifetimes properly in function that takes IntoIterator and return boxed iterator? : I've grasped the basics of rust lifetimes and how to work with iterators in it, but still have troubles to define a function that basically takes `iterable` and return another `iterable` based on the input `iterable` (doing some form of `map` for example) (Yeah, I know that `iterable` doesn't mean anything in rust but I will still use it instead of IntoInterator) Here is the gist of what I'd like to do. I want to take an iterable of tuples and return iterable of tuples also allocated on the heap. use std::iter::{once, repeat}; fn foo<'a, I>(costs: I) -> Box<Iterator<Item = &'a (i32, f32)>> where I: IntoIterator<Item = &'a (usize, f32)>, { let preliminary_examination_costs = once(10.0).chain(repeat(20.0)); let id_assignment_costs = once(10.0).chain(repeat(20.0)); let batch_fixed = once(10.0).chain(repeat(0.0)); let temp: Vec<(usize, &(i32, f32))> = costs.into_iter().enumerate().collect(); temp.sort_by_key(|&(_, &(n, cost))| {n}); Box::new(temp.into_iter().map( |(i, &(n, cost))| { ( i, cost + preliminary_examination_costs.next().unwrap() + id_assignment_costs.next().unwrap() + batch_fixed.next().unwrap() ) } )) } Here's the errors. error[E0277]: the trait bound `std::vec::Vec<(usize, &(i32, f32))>: std::iter::FromIterator<(usize, &'a (usize, f32))>` is not satisfied --> src/main.rs:10:77 | 10 | let temp: Vec<(usize, &(i32, f32))> = costs.into_iter().enumerate().collect(); | ^^^^^^^ a collection of type `std::vec::Vec<(usize, &(i32, f32))>` cannot be built from an iterator over elements of type `(usize, &'a (usize, f32))` | = help: the trait `std::iter::FromIterator<(usize, &'a (usize, f32))>` is not implemented for `std::vec::Vec<(usize, &(i32, f32))>` error[E0271]: type mismatch resolving `<[closure@src/main.rs:13:13: 21:14 preliminary_examination_costs:_, id_assignment_costs:_, batch_fixed:_] as std::ops::FnOnce<((usize, &(i32, f32)),)>>::Output == &(i32, f32)` --> src/main.rs:12:9 | 12 | / Box::new(temp.into_iter().map( 13 | | |(i, &(n, cost))| { 14 | | ( 15 | | i, ... | 21 | | } 22 | | )) | |__________^ expected tuple, found &(i32, f32) | = note: expected type `(usize, f32)` found type `&(i32, f32)` = note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Map<std::vec::IntoIter<(usize, &(i32, f32))>, [closure@src/main.rs:13:13: 21:14 preliminary_examination_costs:_, id_assignment_costs:_, batch_fixed:_]>` = note: required for the cast to the object type `std::iter::Iterator<Item=&(i32, f32)>` https://play.rust-lang.org/?gist=b2bef2a57f76aae6c70eb0e28f4db44f&version=stable
0debug
Laravel dynamic route error 404 page not found : I am new to laravel and I am using version 5.7. I have problem with my dynamic route because whenever I use this get route: Route::get('users/{$id}', function ($id) { return 'This is the user: ' . $id; }); > localhost/users/John It suppose to display the sentence with the user name specified in the url, but instead of that I am getting error saying 404 page could not be found.
0debug
static av_cold int mss1_decode_init(AVCodecContext *avctx) { MSS1Context * const c = avctx->priv_data; int ret; c->ctx.avctx = avctx; c->pic = av_frame_alloc(); if (!c->pic) return AVERROR(ENOMEM); ret = ff_mss12_decode_init(&c->ctx, 0, &c->sc, NULL); avctx->pix_fmt = AV_PIX_FMT_PAL8; return ret; }
1threat
int kvm_irqchip_add_irq_notifier(KVMState *s, EventNotifier *n, int virq) { return -ENOSYS; }
1threat
static int decode_subframe_fixed(FLACContext *s, int channel, int pred_order) { const int blocksize = s->blocksize; int32_t *decoded = s->decoded[channel]; int a, b, c, d, i; for (i = 0; i < pred_order; i++) { decoded[i] = get_sbits(&s->gb, s->curr_bps); } if (decode_residuals(s, channel, pred_order) < 0) return -1; if (pred_order > 0) a = decoded[pred_order-1]; if (pred_order > 1) b = a - decoded[pred_order-2]; if (pred_order > 2) c = b - decoded[pred_order-2] + decoded[pred_order-3]; if (pred_order > 3) d = c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4]; switch (pred_order) { case 0: break; case 1: for (i = pred_order; i < blocksize; i++) decoded[i] = a += decoded[i]; break; case 2: for (i = pred_order; i < blocksize; i++) decoded[i] = a += b += decoded[i]; break; case 3: for (i = pred_order; i < blocksize; i++) decoded[i] = a += b += c += decoded[i]; break; case 4: for (i = pred_order; i < blocksize; i++) decoded[i] = a += b += c += d += decoded[i]; break; default: av_log(s->avctx, AV_LOG_ERROR, "illegal pred order %d\n", pred_order); return -1; } return 0; }
1threat
static double eval_expr(Parser *p, AVExpr *e) { switch (e->type) { case e_value: return e->value; case e_const: return e->value * p->const_values[e->a.const_index]; case e_func0: return e->value * e->a.func0(eval_expr(p, e->param[0])); case e_func1: return e->value * e->a.func1(p->opaque, eval_expr(p, e->param[0])); case e_func2: return e->value * e->a.func2(p->opaque, eval_expr(p, e->param[0]), eval_expr(p, e->param[1])); case e_squish: return 1/(1+exp(4*eval_expr(p, e->param[0]))); case e_gauss: { double d = eval_expr(p, e->param[0]); return exp(-d*d/2)/sqrt(2*M_PI); } case e_ld: return e->value * p->var[av_clip(eval_expr(p, e->param[0]), 0, VARS-1)]; case e_isnan: return e->value * !!isnan(eval_expr(p, e->param[0])); case e_floor: return e->value * floor(eval_expr(p, e->param[0])); case e_ceil : return e->value * ceil (eval_expr(p, e->param[0])); case e_trunc: return e->value * trunc(eval_expr(p, e->param[0])); case e_sqrt: return e->value * sqrt (eval_expr(p, e->param[0])); case e_not: return e->value * (eval_expr(p, e->param[0]) == 0); case e_if: return e->value * ( eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) : 0); case e_ifnot: return e->value * (!eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) : 0); case e_random:{ int idx= av_clip(eval_expr(p, e->param[0]), 0, VARS-1); uint64_t r= isnan(p->var[idx]) ? 0 : p->var[idx]; r= r*1664525+1013904223; p->var[idx]= r; return e->value * (r * (1.0/UINT64_MAX)); } case e_while: { double d = NAN; while (eval_expr(p, e->param[0])) d=eval_expr(p, e->param[1]); return d; } case e_taylor: { double t = 1, d = 0, v; double x = eval_expr(p, e->param[1]); int id = e->param[2] ? av_clip(eval_expr(p, e->param[2]), 0, VARS-1) : 0; int i; double var0 = p->var[id]; for(i=0; i<1000; i++) { double ld = d; p->var[id] = i; v = eval_expr(p, e->param[0]); d += t*v; if(ld==d && v) break; t *= x / (i+1); } p->var[id] = var0; return d; } case e_root: { int i; double low = -1, high = -1, v, low_v = -DBL_MAX, high_v = DBL_MAX; double var0 = p->var[0]; double x_max = eval_expr(p, e->param[1]); for(i=-1; i<1024; i++) { if(i<255) { p->var[0] = av_reverse[i&255]*x_max/255; } else { p->var[0] = x_max*pow(0.9, i-255); if (i&1) p->var[0] *= -1; if (i&2) p->var[0] += low; else p->var[0] += high; } v = eval_expr(p, e->param[0]); if (v<=0 && v>low_v) { low = p->var[0]; low_v = v; } if (v>=0 && v<high_v) { high = p->var[0]; high_v = v; } if (low>=0 && high>=0){ while (1) { p->var[0] = (low+high)*0.5; if (low == p->var[0] || high == p->var[0]) break; v = eval_expr(p, e->param[0]); if (v<=0) low = p->var[0]; if (v>=0) high= p->var[0]; if (isnan(v)) { low = high = v; break; } } break; } } p->var[0] = var0; return -low_v<high_v ? low : high; } default: { double d = eval_expr(p, e->param[0]); double d2 = eval_expr(p, e->param[1]); switch (e->type) { case e_mod: return e->value * (d - floor(d/d2)*d2); case e_gcd: return e->value * av_gcd(d,d2); case e_max: return e->value * (d > d2 ? d : d2); case e_min: return e->value * (d < d2 ? d : d2); case e_eq: return e->value * (d == d2 ? 1.0 : 0.0); case e_gt: return e->value * (d > d2 ? 1.0 : 0.0); case e_gte: return e->value * (d >= d2 ? 1.0 : 0.0); case e_pow: return e->value * pow(d, d2); case e_mul: return e->value * (d * d2); case e_div: return e->value * (d / d2); case e_add: return e->value * (d + d2); case e_last:return e->value * d2; case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2); case e_hypot:return e->value * (sqrt(d*d + d2*d2)); } } } return NAN; }
1threat
static void tcg_handle_interrupt(CPUArchState *env, int mask) { CPUState *cpu = ENV_GET_CPU(env); int old_mask; old_mask = env->interrupt_request; env->interrupt_request |= mask; if (!qemu_cpu_is_self(cpu)) { qemu_cpu_kick(cpu); return; } if (use_icount) { env->icount_decr.u16.high = 0xffff; if (!can_do_io(env) && (mask & ~old_mask) != 0) { cpu_abort(env, "Raised interrupt while not in I/O function"); } } else { cpu_unlink_tb(cpu); } }
1threat
static av_cold int dct_init(MpegEncContext *s) { ff_blockdsp_init(&s->bdsp, s->avctx); ff_hpeldsp_init(&s->hdsp, s->avctx->flags); ff_me_cmp_init(&s->mecc, s->avctx); ff_mpegvideodsp_init(&s->mdsp); ff_videodsp_init(&s->vdsp, s->avctx->bits_per_raw_sample); s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c; s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_c; s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c; s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c; s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c; if (s->flags & CODEC_FLAG_BITEXACT) s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_bitexact; s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c; if (HAVE_INTRINSICS_NEON) ff_mpv_common_init_neon(s); if (ARCH_ARM) ff_mpv_common_init_arm(s); if (ARCH_PPC) ff_mpv_common_init_ppc(s); if (ARCH_X86) ff_mpv_common_init_x86(s); return 0; }
1threat
Ruby Array Merge Method : How can I merge two `arrays` like a `set` with no duplicates? I'm looking for a method. The `pipe` method ('|') is what I want, and it's described in documentation as `Array.union(another_array)` in version `2.5.1`, but it throws an error. a = [1,2,3] b = [3,4,5] p a|b # => [1, 2, 3, 4, 5] what I want puts p a & b # => [3] intersection puts p a + b # => [1, 2, 3, 3, 4, 5] this is a push puts p a.union(b) # => undefined method `union' for [1, 2, 3]:Array (NoMethodError) Is there such a written method for a `union`?
0debug
How to change label text by the value of Progress View : <p>I'm trying to make an app that, when the progress bar comes 10%, 20%, 30% etc... shows an different text on a label. Can you help me on the code?</p>
0debug
Changing fragment by touch like in Facebook Messenger : <p>How to make a changing fragment by touch like in Facebook Messenger ?<br> Or maybe they are not fragments ?<br> I mean swap screen from Messenges to Active or Groups or Conversations using a touch and swap left or right ( we have 4 in messenger)</p> <p>These are fragments ? Please for any tips. I can not find anything on the net.</p>
0debug
static void flush_change(H264Context *h) { h->outputed_poc = h->next_outputed_poc = INT_MIN; h->prev_interlaced_frame = 1; idr(h); h->prev_frame_num = -1; if (h->s.current_picture_ptr) h->s.current_picture_ptr->f.reference = 0; h->s.first_field = 0; memset(h->ref_list[0], 0, sizeof(h->ref_list[0])); memset(h->ref_list[1], 0, sizeof(h->ref_list[1])); memset(h->default_ref_list[0], 0, sizeof(h->default_ref_list[0])); memset(h->default_ref_list[1], 0, sizeof(h->default_ref_list[1])); ff_h264_reset_sei(h); h->recovery_frame= -1; h->sync= 0; h->list_count = 0; h->current_slice = 0; }
1threat
static int init_filter_param(AVFilterContext *ctx, FilterParam *fp, const char *effect_type, int width) { int z; const char *effect = fp->amount == 0 ? "none" : fp->amount < 0 ? "blur" : "sharpen"; if (!(fp->msize_x & fp->msize_y & 1)) { av_log(ctx, AV_LOG_ERROR, "Invalid even size for %s matrix size %dx%d\n", effect_type, fp->msize_x, fp->msize_y); return AVERROR(EINVAL); } av_log(ctx, AV_LOG_VERBOSE, "effect:%s type:%s msize_x:%d msize_y:%d amount:%0.2f\n", effect, effect_type, fp->msize_x, fp->msize_y, fp->amount / 65535.0); for (z = 0; z < 2 * fp->steps_y; z++) fp->sc[z] = av_malloc(sizeof(*(fp->sc[z])) * (width + 2 * fp->steps_x)); return 0; }
1threat
PPC_OP(addeo) { do_addeo(); RETURN(); }
1threat
Passing ref's content from a child to another VueJS child component : <p>I'm learning VueJS and I got a little confused on the ref, $refs lecture. I tried to understand it from vue's documentation, but I didn't get what I want to know.</p> <p>If for example I have this component:</p> <p><code>&lt;user-item ref="details"&gt;&lt;/user-item&gt;</code></p> <p>and I get the data from this component using </p> <p>this.$refs.details </p> <p>to use that data in the User parent component, because this user-item is a child for User component. </p> <pre><code>&lt;div id="User"&gt; &lt;user-item ref="details"&gt;&lt;/user-item&gt; &lt;/div&gt; </code></pre> <p>In the same time I have another component called, let's say Permissions that's child too, for User component:</p> <pre><code>&lt;div id="User"&gt; &lt;user-item ref="details"&gt;&lt;/user-item&gt; &lt;permissions&gt;&lt;/permissions&gt; &lt;/div&gt; </code></pre> <p>In this Permissions component I need the same this.$refs.details, but from what I test, like an experiment, doesn't work. </p> <p>This is just a simple example.</p> <p>Can someone please tell me how can I do it?</p>
0debug
How optimise code in the scenario ??? instated of writing multiple else if conditions : This My DAOImple class:::: here i have two drop down boxes like 1'st box options are ALL,in pool,out of pool. 2ed box option are ALL,active,inactive,Frozen,Baried,Delete. ------------------- public class FleetDetailsDAOImpl22 extends CustomJdbcDaoSupport implements FleetDetailsDAO { @Autowired private DataManager dataManager; /** This method is called for getting all the vessels. */ /** * @param vesselStatus * @param poolStatus * @param poolid */ @Override public List<FleetDetails> getFleetDetails(String vesselStatus, String poolStatus, int poolid, String fromDate, String toDate)throws CustomException { List<FleetDetails> fleetList =new ArrayList<FleetDetails>(); String poolStatusValue = null; String vesselStatusValue = null; String displayFlag = null; /*---check for poolStatus---------*/ if(poolStatus.equals("yes")) { poolStatusValue = "Y"; } if(poolStatus.equals("no")) { poolStatusValue = "N"; } if(poolStatus.equals("all")) { poolStatusValue = "ALL"; } /*---check for vessel status---------*/ if(vesselStatus.equals("active")) { vesselStatusValue = "Y"; displayFlag = "Y"; } if(vesselStatus.equals("inactive")) { vesselStatusValue = "N"; displayFlag = "Y"; } if(vesselStatus.equals("frozen")) { vesselStatusValue = "F"; displayFlag ="Y"; } if(vesselStatus.equals("buried")) { vesselStatusValue = "B"; displayFlag = "B"; } if(vesselStatus.equals("pending")) { vesselStatusValue = "P"; displayFlag = "P"; } if(vesselStatus.equals("delete")) { vesselStatusValue = "D"; displayFlag = "D"; } if(vesselStatus.equals("all")){ vesselStatusValue = "ALL"; } try { if(poolStatusValue.equals("Y") && vesselStatusValue.equals("ALL") ){ String fleetDetailsQuery = dataManager.getQuery("FLEET_DETAILS", Queries.QUERY_GET_FLEET_DETAILS_ALL_NONPOOL); Object[] params = new Object[] { poolid, poolStatusValue }; fleetList = getJdbcTemplate().query(fleetDetailsQuery,params, new FleetDetails.FleetDetailsRowMapper()); } else if(poolStatusValue.equals("ALL") && vesselStatusValue.equals("ALL")) { String allVesselsQuiry = dataManager.getQuery("FLEET_DETAILS",Queries.QUERY_GET_POOL_NONPOOL_VESSELS); Object[] params = new Object[] { poolid }; fleetList = getJdbcTemplate().query(allVesselsQuiry,params, new FleetDetails.FleetDetailsRowMapper()); } else if(poolStatusValue.equals("N")){ String nonpoolVesselsQuiry = dataManager.getQuery("FLEET_DETAILS", Queries.QUERY_GET_NONPOOL_VESSELS); Object[] params = new Object[] { poolid, vesselStatusValue,poolStatusValue, displayFlag }; fleetList = getJdbcTemplate().query(nonpoolVesselsQuiry,params, new FleetDetails.FleetDetailsRowMapper()); } else if(poolStatusValue.equals("Y")){ String fleetDetailsQuery = dataManager.getQuery("FLEET_DETAILS", Queries.QUERY_GET_FLEET_DETAILS); Object[] params = new Object[] { poolid, vesselStatusValue,poolStatusValue, displayFlag }; fleetList = getJdbcTemplate().query(fleetDetailsQuery,params, new FleetDetails.FleetDetailsRowMapper()); } else { String fleetDetailsQuery = dataManager .getQuery("FLEET_DETAILS",Queries.QUERY_GET_STATUS_VESSELS_FOR_BOTH_POOL_NONPOOL); Object[] params = new Object[] { poolid, vesselStatusValue,displayFlag }; fleetList = getJdbcTemplate().query(fleetDetailsQuery,params, new FleetDetails.FleetDetailsRowMapper()); } } catch(Exception e) { e.getMessage(); } return fleetList; }
0debug
Template factorial function without template specialization : <p>I don't understand the following behavior.</p> <p>The following code, aimed at computing the factorial at compile time, doesn't even compile:</p> <pre><code>#include &lt;iostream&gt; using namespace std; template&lt;int N&gt; int f() { if (N == 1) return 1; // we exit the recursion at 1 instead of 0 return N*f&lt;N-1&gt;(); } int main() { cout &lt;&lt; f&lt;5&gt;() &lt;&lt; endl; return 0; } </code></pre> <p>and throws the following error:</p> <pre><code>...$ g++ factorial.cpp &amp;&amp; ./a.out factorial.cpp: In instantiation of ‘int f() [with int N = -894]’: factorial.cpp:7:18: recursively required from ‘int f() [with int N = 4]’ factorial.cpp:7:18: required from ‘int f() [with int N = 5]’ factorial.cpp:15:16: required from here factorial.cpp:7:18: fatal error: template instantiation depth exceeds maximum of 900 (use ‘-ftemplate-depth=’ to increase the maximum) 7 | return N*f&lt;N-1&gt;(); | ~~~~~~^~ compilation terminated. </code></pre> <p>whereas, upon adding the specialization for <code>N == 0</code> (which the template above doesn't even reach),</p> <pre><code>template&lt;&gt; int f&lt;0&gt;() { cout &lt;&lt; "Hello, I'm the specialization.\n"; return 1; } </code></pre> <p>the code compiles and give the correct output of, even if the specialization is never used:</p> <pre><code>...$ g++ factorial.cpp &amp;&amp; ./a.out 120 </code></pre>
0debug
static void pci_vpb_unmap(SysBusDevice *dev, target_phys_addr_t base) { PCIVPBState *s = (PCIVPBState *)dev; memory_region_del_subregion(get_system_memory(), &s->mem_config); memory_region_del_subregion(get_system_memory(), &s->mem_config2); if (s->realview) { memory_region_del_subregion(get_system_memory(), &s->isa); } }
1threat
Getting Android sdkmanager to run with Java 11 : <p>I am facing a problem while running Android <code>sdkmanager</code> with Java 11 (Not studio, only SDK tools). I don't want to install JDK 8 or something similar. Is there a way to fix this for Android <code>sdkmanager</code> with JDK 11?</p> <p>I have gone through <a href="https://stackoverflow.com/questions/47150410/failed-to-run-sdkmanager-list-android-sdk-with-java-9/47150411">this answer</a> and it doesn't offer command line fix for java 11. Any other workaround possible?</p>
0debug
How to do array from the string ? : <p>I have an adress such as <a href="https://stackoverflow.com/#/schedulePage/some/another">https://stackoverflow.com/#/schedulePage/some/another</a> , how can I make it to an array with elements after # ? </p>
0debug
How to show calander view with day/weak/month wise? : [![][1]][1] [1]: https://i.stack.imgur.com/Do7hE.png I want to show appointment in calendar like above image in my android app. when user click on day then calendar show day view and when user click on weak then calendar show weak view and same for month also. I have search on internet but could not find perfect solution for this. How can I achieve this ?
0debug
how to launch app on specific time in android OS? : i'm looking for a way that i will set specific time in my android app (for example 9 p.m) , i'll terminate the app and then it will launch again the app on 9 p.m and preform a specific method / operation. and at the end close the app again.
0debug
Why can't a visitor open a image at a wordpress site : Lots Of Wordpress websites out there containing lots of advantages. **One of them is that any visitor can't open a image. (If the visitor is not quite good at HTML)** <br> LIKE IN THIS PICTURE: - <br>(Request: anybody please make the pic permanent in this page on this post, please......) [SNAP-SHOT on BBC AMERICA][1] I want to know, How could I do that on my webpage. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title>Trek Butterfly Madone</title> <style type="text/css"> body { margin: 0; margin-top: -30%; } </style> </head> <body> <a href="https://www.youtube.com/watch?v=bD-Wmdm-WdA&t=101s"> <img src="http://images.amcnetworks.com/bbcamerica.com/wp-content/uploads/2018/07/OneAmazingDay_1920x1080-1600x720.jpg" alt="Poster" width="100%" id="poster"/> </a> </body> </html> <!-- end snippet --> [1]: https://i.stack.imgur.com/VxC1P.jpg
0debug
JavaEE / JAX-RS Use JWT authentication (com.auth0) : <p>I'm pretty new in JavaEE and need to create a Rest API with JAX-RS. I used google to get in touch with Java Rest API's and found some articles about JWT. I never used JWT and I'm abit confused. Right now I just know Servlet authentication and most of the articles pointed to Spring-Security.</p> <p>I got few questions..</p> <ul> <li>Do I need to use Spring-Security or can I keep using my Servlet authentication?</li> <li>Is there a good example / tutorial I can use to create a JWT authentication?</li> <li>Is there something better / more secure than JWT?</li> </ul>
0debug
convert list of dict into custom format list : I have below list list_of_dict = [{'flat': ['103'], 'wing': u'C'}, {'flat': ['102', '104'], 'wing': u'B'}, {'flat': ['105'], 'wing': u'D'}] I wish to convert into list_of_dict = [{'flat': [{'103'}], 'wing': u'C'}, {'flat': [{'102'}, {'104'}], 'wing': u'B'}, {'flat': [{'105'}], 'wing': u'D'}] Flat should be list of numbers enclosed in '{ }'
0debug
import math def wind_chill(v,t): windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16) return int(round(windchill, 0))
0debug
sql server sql queries to linq : How i write the linq queries for the following procedure!!!!!! create proc [dbo].[sp_remainUser] @userid int as begin select * from userlog where user_id not in(select followed_id from userfollowing where follower_id=@userid) and user_id not in (select follower_id from userfollowing where follower_id=@userid) end
0debug
Weird problem when i try to format string to date in Angalar : I try to format string to Date. this.deadLine = new Date(this.deadLine); When i console this i got "Invalid Date". The output of this.deadLine without a format is: "2019-10-21T21:00:00.000Z" If i do it without a variable like this its work: const a = new Date("2019-10-21T21:00:00.000Z") console.log (a) The output good Tue Oct 22 2019 00:00:00 GMT+0300 (Israel Daylight Time) Why its not work on this.deadLine in the first line???
0debug
Where to store database credentials in a professional Java web project : <p>I want to know where to store database credentials like username and password of database in a professional Java web project. Please help me</p>
0debug
Could any one help me with grep : I'm new to shell script and i am assigned to grab files that only contains ascii text. I found this code online but just dont get it. ``` grep '[^ -~]' $someargument ``` could anyone help me with it? Thanks! I found this has the same functionality as ``` grep -P -L -r '[^[:ascii:]]' $someargument
0debug
static void timer_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { LM32TimerState *s = opaque; trace_lm32_timer_memory_write(addr, value); addr >>= 2; switch (addr) { case R_SR: s->regs[R_SR] &= ~SR_TO; break; case R_CR: s->regs[R_CR] = value; if (s->regs[R_CR] & CR_START) { ptimer_run(s->ptimer, 1); } if (s->regs[R_CR] & CR_STOP) { ptimer_stop(s->ptimer); } break; case R_PERIOD: s->regs[R_PERIOD] = value; ptimer_set_count(s->ptimer, value); break; case R_SNAPSHOT: error_report("lm32_timer: write access to read only register 0x" TARGET_FMT_plx, addr << 2); break; default: error_report("lm32_timer: write access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } timer_update_irq(s); }
1threat
static void ratelimit_set_speed(RateLimit *limit, uint64_t speed) { limit->slice_quota = speed / (1000000000ULL / SLICE_TIME); }
1threat
void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...)) { unsigned int i; for (i = 0; i < TRACE_BUF_LEN; i++) { TraceRecord record; if (!get_trace_record(i, &record)) { continue; } stream_printf(stream, "Event %" PRIu64 " : %" PRIx64 " %" PRIx64 " %" PRIx64 " %" PRIx64 " %" PRIx64 " %" PRIx64 "\n", record.event, record.x1, record.x2, record.x3, record.x4, record.x5, record.x6); } }
1threat
string concatenation with property binding in angular2 : <p>in Angular 2 we have several way to create property bindings in templates. I could do something like this:</p> <pre><code>&lt;li *ngFor="#course of courses; #i = index" id="someselector-{{i}}"&gt;{{course}}&lt;/li&gt; </code></pre> <p>Is it possible to obtain the same result using the square brakets syntax?</p> <pre><code>&lt;li *ngFor="#course of courses; #i = index" [id]="someselector-i"&gt;{{course}}&lt;/li&gt; ^^^^^^^ how create string concatenation? </code></pre> <p>Thanks, G.</p>
0debug
document.write('<script src="evil.js"></script>');
1threat
I am new to python and I am stuck. it shows error TypeError: unsupported operand type(s) for +=: 'int' and 'str' : shopping_list = ["banana", "orange", "apple"] stock = { "banana": 6, "apple": 0, "orange": 32, "pear": 15 } prices = { "banana": 4, "apple": 2, "orange": 1.5, "pear": 3 } def compute_bill(food): total = 0 for item in food: total += item return total for key in prices: print compute_bill(key)
0debug
can not issue executeupdate() for selects in netbeans : Good day , While I am trying to update data after inserting new ones in the database, This message is showing for me can not issue executeupdate() for selects I have checked [tutorialspoint.com][1] and [codejava][2] and the codes for both update and select are the same and the program is issuing the statement above Here is my codes String Sql="Select * from training where trainID=? "; try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/hr","root","MZaa8891@"); ps= con.prepareStatement(Sql); ps.setString(1, jTextField1.getText()); rs =ps.executeQuery(); while (rs.next()){ jTextField2.setText(rs.getString("traTitle")); } } catch (Exception e){ JOptionPane.showMessageDialog(null, e); } } String Sql="Select * from training where traTitle =? "; try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/hr","root","MZaa8891@"); ps= con.prepareStatement(Sql); ps.setString(1, jTextField1.getText()); rs =ps.executeQuery(); while (rs.next()){ jTextField2.setText(rs.getString("trainID")); } } catch (Exception e){ JOptionPane.showMessageDialog(null, e); } String Sql= "UPDATE training SET traTitle ='"+ jTextField2.getText()+"', Type = "+(String) jComboBox1.getSelectedItem()+"', SDate = '"+sqlDate+"', Edate = '"+sqlDate2+"', location = '"+jTextField3.getText()+"',provider = '"+(String) jComboBox1.getSelectedItem()+"',related = '"+jTextArea1.getText()+"',benefits = '"+jTextArea2.getText()+"'important = '"+jTextArea3.getText()+"' WHERE trainID = "+jTextField1.getText()+""; try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/hr","root","MZaa8891@"); Statement st = con.createStatement(); int i =ps.executeUpdate(); if (i>0) { JOptionPane.showMessageDialog(null, "Data is Saved"); } else { JOptionPane.showMessageDialog(null, "Data is not Saved"); } } catch (Exception e){ JOptionPane.showMessageDialog(this, e.getMessage()); JOptionPane.showMessageDialog(null, e); } Any Solution ? [1]: https://www.tutorialspoint.com/jdbc/jdbc-update-records.htm [2]: http://www.codejava.net/java-se/jdbc/jdbc-tutorial-sql-insert-select-update-and-delete-examples
0debug
using prepared statements and fetchAll() to display to a table : <p>I'm trying to get my code SQL Injection safe, I am having trouble converting the pdo data to an array then comparing row data.</p> <p>I have been reading up on <a href="https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php">how to prevent sql injection</a> as well as <a href="https://www.php.net/manual/en/pdostatement.fetchall.php" rel="nofollow noreferrer">fetchAll() documentation</a> and <a href="https://phpdelusions.net/pdo_examples/select" rel="nofollow noreferrer">how to handle SELECT statements with pdo</a>.</p> <p>Here is the relevant code. I believe it prepares the statement, then executes it, then the table is fetched and stored in $data where it is handed to $row, and then it looks up the player column and compares it with the logged in user to get the context based code to run. Where is the issue?</p> <pre class="lang-php prettyprint-override"><code> $stmt = $pdo-&gt;prepare("SELECT * FROM userdata"); $stmt-&gt;execute(); $data = $stmt-&gt;fetchAll(); echo "&lt;table border='1'&gt; &lt;tr&gt; &lt;th&gt;username&lt;/th&gt; &lt;th&gt;words&lt;/th&gt; &lt;/tr&gt;"; while($row = $data) { echo $row['player']; echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row['player'] . "&lt;/td&gt;"; if($row['player'] == $logedInUsername) { echo "&lt;td&gt;" . $row['words'] . "&lt;a href='edityourword.php?edit=$row[words]'&gt; edit&lt;/a&gt;&lt;/td&gt;"; } else { echo "&lt;td&gt;" . $row['words'] . "&lt;/td&gt;"; } echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; </code></pre> <p>My current error is reoccurring, here is the segment which the while loop keeps printing.</p> <pre><code>Notice: Undefined index: player on line 41 Notice: Undefined index: player on line 43 Notice: Undefined index: player on line 44 Notice: Undefined index: words on line 50 Notice: Undefined index: player on line 41 Notice: Undefined index: player on line 43 Notice: Undefined index: player on line 44 Notice: Undefined index: words on line 50 </code></pre>
0debug
static void vhost_iommu_region_add(MemoryListener *listener, MemoryRegionSection *section) { struct vhost_dev *dev = container_of(listener, struct vhost_dev, iommu_listener); struct vhost_iommu *iommu; if (!memory_region_is_iommu(section->mr)) { return; } iommu = g_malloc0(sizeof(*iommu)); iommu->n.notify = vhost_iommu_unmap_notify; iommu->n.notifier_flags = IOMMU_NOTIFIER_UNMAP; iommu->mr = section->mr; iommu->iommu_offset = section->offset_within_address_space - section->offset_within_region; iommu->hdev = dev; memory_region_register_iommu_notifier(section->mr, &iommu->n); QLIST_INSERT_HEAD(&dev->iommu_list, iommu, iommu_next); }
1threat
Visual Studio: Tab key selects and highlights code : <p>If I place my cursor inside a multi-line comment:</p> <pre><code>/* * place cursor after the asterisk and before the word 'place' */ if (x == 0) { // some code } </code></pre> <p>... and hit <kbd>tab</kbd>, Visual Studio doesn't add whitespace as usual. Instead, it highlights the entire comment (all three lines, in the example). If I hit <kbd>tab</kbd> again, it will select and highlight the next statement or block of statements. In my example, it highlights the entire <code>if</code>.</p> <p>How do I fix this and make Visual Studio tab things over? I want <kbd>tab</kbd> to behave like a <kbd>tab</kbd>.</p> <p>I'm using Visual Studio 2013 Ultimate with Resharper 9. It started doing this yesterday, and I have no idea why.</p>
0debug
PCIBus *pci_device_root_bus(const PCIDevice *d) { PCIBus *bus = d->bus; while (!pci_bus_is_root(bus)) { d = bus->parent_dev; assert(d != NULL); bus = d->bus; } return bus; }
1threat
How can i make image size big usign css? : I want to make image size big but it is not happening with below code, How can i achieve that task using css ? navbar.html <a class="navbar-brand"><img src="assets/images/logo.png" id="logo"></a> css #logo { height: 40px; } .navbar-brand>img { max-height: 100%; height: 100%; width: auto; margin: 0 auto; -o-object-fit: contain; object-fit: contain; }
0debug
How to make Laravel 5 return 404 status code : <p>I am trying to get Laravel 5 (5.1.31) to return a http status response of 404 when a page is not found. I have tried several things and it always returns 200.</p> <p>In my controller I have this:</p> <pre><code>else { header('HTTP/1.0 404 Not Found'); return view('errors.404); } </code></pre> <p>I have also tried:</p> <pre><code>else { http_response_code(404); return view('errors.404); } </code></pre> <p>and </p> <pre><code>else { abort(404, 'Page not found'); } </code></pre> <p>I also tried putting this in the 404.blade</p> <pre><code>@inject( 'response', 'Illuminate\Http\Response' ) {{ $response-&gt;status(404) }} </code></pre> <p>No success. No matter what I try, Laravel returns 200. How do I get it to return 404?</p>
0debug
int pit_get_out(PITState *pit, int channel, int64_t current_time) { PITChannelState *s = &pit->channels[channel]; return pit_get_out1(s, current_time); }
1threat
What can mean "cout << color::green;" : I had this question on the test. I know that I can do something like that enum class Color { red, green = 1, blue }; Color c = Color::blue; if( c == Color::blue ) cout << "blue\n"; But when I replace `cout << "blue\n";` with `cout << color::green`, it doesn't even compile. Any ideas?
0debug
void ff_fix_long_mvs(MpegEncContext * s, uint8_t *field_select_table, int field_select, int16_t (*mv_table)[2], int f_code, int type, int truncate) { MotionEstContext * const c= &s->me; int y, h_range, v_range; int range = (((s->out_format == FMT_MPEG1) ? 8 : 16) << f_code); if(s->msmpeg4_version) range= 16; if(c->avctx->me_range && range > c->avctx->me_range) range= c->avctx->me_range; h_range= range; v_range= field_select_table ? range>>1 : range; for(y=0; y<s->mb_height; y++){ int x; int xy= y*s->mb_stride; for(x=0; x<s->mb_width; x++){ if (s->mb_type[xy] & type){ if(field_select_table==NULL || field_select_table[xy] == field_select){ if( mv_table[xy][0] >=h_range || mv_table[xy][0] <-h_range || mv_table[xy][1] >=v_range || mv_table[xy][1] <-v_range){ if(truncate){ if (mv_table[xy][0] > h_range-1) mv_table[xy][0]= h_range-1; else if(mv_table[xy][0] < -h_range ) mv_table[xy][0]= -h_range; if (mv_table[xy][1] > v_range-1) mv_table[xy][1]= v_range-1; else if(mv_table[xy][1] < -v_range ) mv_table[xy][1]= -v_range; }else{ s->mb_type[xy] &= ~type; s->mb_type[xy] |= CANDIDATE_MB_TYPE_INTRA; mv_table[xy][0]= mv_table[xy][1]= 0; } } } } xy++; } } }
1threat
why is this happening, How do I correct this "mistake"? : <p><a href="https://i.stack.imgur.com/DksIU.png" rel="nofollow noreferrer">enter image description here</a></p> <p>And also when I try to start in the same code the application on the phone stops responding I think the error would be in some code of the connection but I'm not sure because I'm very noob in this question</p> <p>And another question, is my connection correct?</p> <pre><code>public class ConexaoClass { String classs = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/bd_tela"; String un = "admin"; String pass = "96960409w"; @SuppressLint("NewApi") public Connection CONN(){ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); Connection conn = null; String connURL = null; try{ Class.forName(classs); conn = DriverManager.getConnection(url, un, pass); conn = DriverManager.getConnection(connURL); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return conn; } </code></pre>
0debug
Where to start with C++ GUI? : <p>Just wondering what a good place to start would be? The program I eventually hope to make is a calculator for a windows operating system (School project)</p>
0debug
In Laravel, how do I retrieve a random user_id from the Users table for Model Factory seeding data generation? : <p>Currently, in my ModelFactory.php, I have:</p> <pre><code>$factory-&gt;define(App\Reply::class, function (Faker\Generator $faker) { return [ 'thread_id' =&gt; 1, 'user_id' =&gt; 1, 'body' =&gt; $faker-&gt;paragraph ]; }); </code></pre> <p>I would like to generate a random user_id from one of the user ID's already stored in the user table. I'm stumped because I don't know the way to display data output to code properly, and I was wondering how I would be able to allow Laravel to choose a random user ID and insert into the database. Thank you! :)</p>
0debug
How to get the count of no of tags in one element in xml using xml or java code : My .xml doc contains data like this <Test-Set> <Test-Case Name="Verify using Interface user in WebService we are able to do database transactions" /> <Test-Case Name="Verify using Interface user in JMS we are able to post a message to queue and get message from queue" /> <Test-Case Name="Verify using Interface user we are able to login BPD"/> </Test-Set> My excepted output is 3
0debug
Is there an equivalent to mysql IN function in sql-server : <p>On the frontend, I have an array with ID's. I want to request the Rows with These ID's. In MySQL, there is a function IN(). And I want to use a similar function to that in my query. Is there such a function in SQL-Server?</p> <p>Thanks in advance.</p>
0debug
int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg, PCIDevice *dev) { struct kvm_irq_routing_entry kroute = {}; if (kvm_gsi_direct_mapping()) { return 0; } if (!kvm_irqchip_in_kernel()) { return -ENOSYS; } kroute.gsi = virq; kroute.type = KVM_IRQ_ROUTING_MSI; kroute.flags = 0; kroute.u.msi.address_lo = (uint32_t)msg.address; kroute.u.msi.address_hi = msg.address >> 32; kroute.u.msi.data = le32_to_cpu(msg.data); if (kvm_msi_devid_required()) { kroute.flags = KVM_MSI_VALID_DEVID; kroute.u.msi.devid = pci_requester_id(dev); } if (kvm_arch_fixup_msi_route(&kroute, msg.address, msg.data, dev)) { return -EINVAL; } trace_kvm_irqchip_update_msi_route(virq); return kvm_update_routing_entry(s, &kroute); }
1threat
int qcow2_update_snapshot_refcount(BlockDriverState *bs, int64_t l1_table_offset, int l1_size, int addend) { BDRVQcow2State *s = bs->opaque; uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2, refcount; bool l1_allocated = false; int64_t old_offset, old_l2_offset; int i, j, l1_modified = 0, nb_csectors; int ret; assert(addend >= -1 && addend <= 1); l2_table = NULL; l1_table = NULL; l1_size2 = l1_size * sizeof(uint64_t); s->cache_discards = true; if (l1_table_offset != s->l1_table_offset) { l1_table = g_try_malloc0(align_offset(l1_size2, 512)); if (l1_size2 && l1_table == NULL) { ret = -ENOMEM; goto fail; } l1_allocated = true; ret = bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2); if (ret < 0) { goto fail; } for(i = 0;i < l1_size; i++) be64_to_cpus(&l1_table[i]); } else { assert(l1_size == s->l1_size); l1_table = s->l1_table; l1_allocated = false; } for(i = 0; i < l1_size; i++) { l2_offset = l1_table[i]; if (l2_offset) { old_l2_offset = l2_offset; l2_offset &= L1E_OFFSET_MASK; if (offset_into_cluster(s, l2_offset)) { qcow2_signal_corruption(bs, true, -1, -1, "L2 table offset %#" PRIx64 " unaligned (L1 index: %#x)", l2_offset, i); ret = -EIO; goto fail; } ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void**) &l2_table); if (ret < 0) { goto fail; } for(j = 0; j < s->l2_size; j++) { uint64_t cluster_index; offset = be64_to_cpu(l2_table[j]); old_offset = offset; offset &= ~QCOW_OFLAG_COPIED; switch (qcow2_get_cluster_type(offset)) { case QCOW2_CLUSTER_COMPRESSED: nb_csectors = ((offset >> s->csize_shift) & s->csize_mask) + 1; if (addend != 0) { ret = update_refcount(bs, (offset & s->cluster_offset_mask) & ~511, nb_csectors * 512, abs(addend), addend < 0, QCOW2_DISCARD_SNAPSHOT); if (ret < 0) { goto fail; } } refcount = 2; break; case QCOW2_CLUSTER_NORMAL: case QCOW2_CLUSTER_ZERO: if (offset_into_cluster(s, offset & L2E_OFFSET_MASK)) { qcow2_signal_corruption(bs, true, -1, -1, "Data " "cluster offset %#llx " "unaligned (L2 offset: %#" PRIx64 ", L2 index: %#x)", offset & L2E_OFFSET_MASK, l2_offset, j); ret = -EIO; goto fail; } cluster_index = (offset & L2E_OFFSET_MASK) >> s->cluster_bits; if (!cluster_index) { refcount = 0; break; } if (addend != 0) { ret = qcow2_update_cluster_refcount(bs, cluster_index, abs(addend), addend < 0, QCOW2_DISCARD_SNAPSHOT); if (ret < 0) { goto fail; } } ret = qcow2_get_refcount(bs, cluster_index, &refcount); if (ret < 0) { goto fail; } break; case QCOW2_CLUSTER_UNALLOCATED: refcount = 0; break; default: abort(); } if (refcount == 1) { offset |= QCOW_OFLAG_COPIED; } if (offset != old_offset) { if (addend > 0) { qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache); } l2_table[j] = cpu_to_be64(offset); qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); } } qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); if (addend != 0) { ret = qcow2_update_cluster_refcount(bs, l2_offset >> s->cluster_bits, abs(addend), addend < 0, QCOW2_DISCARD_SNAPSHOT); if (ret < 0) { goto fail; } } ret = qcow2_get_refcount(bs, l2_offset >> s->cluster_bits, &refcount); if (ret < 0) { goto fail; } else if (refcount == 1) { l2_offset |= QCOW_OFLAG_COPIED; } if (l2_offset != old_l2_offset) { l1_table[i] = l2_offset; l1_modified = 1; } } } ret = bdrv_flush(bs); fail: if (l2_table) { qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); } s->cache_discards = false; qcow2_process_discards(bs, ret); if (ret == 0 && addend >= 0 && l1_modified) { for (i = 0; i < l1_size; i++) { cpu_to_be64s(&l1_table[i]); } ret = bdrv_pwrite_sync(bs->file, l1_table_offset, l1_table, l1_size2); for (i = 0; i < l1_size; i++) { be64_to_cpus(&l1_table[i]); } } if (l1_allocated) g_free(l1_table); return ret; }
1threat
static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s, hwaddr addr, int *miny, int *maxy) { DisplaySurface *surface = qemu_console_surface(s->con); int src_width, dest_width; drawfn fn = NULL; if (s->dest_width) fn = s->line_fn[s->transp][s->bpp]; if (!fn) return; src_width = (s->xres + 3) & ~3; if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp) src_width *= 3; else if (s->bpp > pxa_lcdc_16bpp) src_width *= 4; else if (s->bpp > pxa_lcdc_8bpp) src_width *= 2; dest_width = s->yres * s->dest_width; *miny = 0; framebuffer_update_display(surface, s->sysmem, addr, s->xres, s->yres, src_width, s->dest_width, -dest_width, s->invalidated, fn, s->dma_ch[0].palette, miny, maxy); }
1threat
Why does java say a semicolon is expected when I already have one? : <p>I tried compiling my code so I could then run it and test it, but it says that there is a semi-colon expected. </p> <p>I tried deleting and re-inserting the semi-colon, but the error keeps appearing when I compile. The error is "GPACalculator.java:430: error: ';' expected"</p> <pre><code>if ((class71Honors.equals("Yes"))||(class71Honors.equals("Yes."))||(class71Honors.equals("yes"))||(class71Honors.equals("yes."))) { double class71GPA+=0.6; } </code></pre> <p>I don't expect a printed output, I just want the code to compile because it's the only error I have at the moment. Thanks! (this is all java by the way)</p>
0debug
How to center text in a div, whick contains an Icon : I got the following question, with a pic to illustrate: [![pic][1]][1] [1]: https://i.stack.imgur.com/ANgZA.png I got a container, containing an icon text. The Icon is always on the left, there can be more icons which are all fixed on the left. Now I want the text to be centered in the whole container. If the text gets too long, it should NOT overlap the icons, but it should expand to the right instead. If the text is too long to fit in the container next to the icon, finally I just ellipse it. But how do I do this? Is there a css solution? Thanks in advance!
0debug
static inline void rgtc_block_internal(uint8_t *dst, ptrdiff_t stride, const uint8_t *block, const int *color_tab) { uint8_t indices[16]; int x, y; decompress_indices(indices, block + 2); for (y = 0; y < 4; y++) { for (x = 0; x < 4; x++) { int i = indices[x + y * 4]; int c = color_tab[i]; uint32_t pixel = RGBA(c, c, c, 255); AV_WL32(dst + x * 4 + y * stride, pixel); } } }
1threat
static void vp6_parse_coeff_huffman(VP56Context *s) { VP56Model *model = s->modelp; uint8_t *permute = s->scantable.permutated; VLC *vlc_coeff; int coeff, sign, coeff_idx; int b, cg, idx; int pt = 0; for (b=0; b<6; b++) { int ct = 0; if (b > 3) pt = 1; vlc_coeff = &s->dccv_vlc[pt]; for (coeff_idx=0; coeff_idx<64; ) { int run = 1; if (coeff_idx<2 && s->nb_null[coeff_idx][pt]) { s->nb_null[coeff_idx][pt]--; if (coeff_idx) break; } else { if (get_bits_count(&s->gb) >= s->gb.size_in_bits) return; coeff = get_vlc2(&s->gb, vlc_coeff->table, 9, 3); if (coeff == 0) { if (coeff_idx) { int pt = (coeff_idx >= 6); run += get_vlc2(&s->gb, s->runv_vlc[pt].table, 9, 3); if (run >= 9) run += get_bits(&s->gb, 6); } else s->nb_null[0][pt] = vp6_get_nb_null(s); ct = 0; } else if (coeff == 11) { if (coeff_idx == 1) s->nb_null[1][pt] = vp6_get_nb_null(s); break; } else { int coeff2 = vp56_coeff_bias[coeff]; if (coeff > 4) coeff2 += get_bits(&s->gb, coeff <= 9 ? coeff - 4 : 11); ct = 1 + (coeff2 > 1); sign = get_bits1(&s->gb); coeff2 = (coeff2 ^ -sign) + sign; if (coeff_idx) coeff2 *= s->dequant_ac; idx = model->coeff_index_to_pos[coeff_idx]; s->block_coeff[b][permute[idx]] = coeff2; } } coeff_idx+=run; cg = FFMIN(vp6_coeff_groups[coeff_idx], 3); vlc_coeff = &s->ract_vlc[pt][ct][cg]; } } }
1threat
static inline void cris_fidx_d(unsigned int x) { register unsigned int v asm("$r10") = x; asm ("fidxd\t[%0]\n" : : "r" (v) ); }
1threat
void wdt_ib700_init(void) { watchdog_add_model(&model); timer = qemu_new_timer(vm_clock, ib700_timer_expired, NULL); }
1threat
static int send_png_rect(VncState *vs, int x, int y, int w, int h, QDict *palette) { png_byte color_type; png_structp png_ptr; png_infop info_ptr; png_colorp png_palette = NULL; size_t offset; int level = tight_conf[vs->tight_compression].raw_zlib_level; uint8_t *buf; int dy; png_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL, NULL, vnc_png_malloc, vnc_png_free); if (png_ptr == NULL) return -1; info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) { png_destroy_write_struct(&png_ptr, NULL); return -1; } png_set_write_fn(png_ptr, (void *) vs, png_write_data, png_flush_data); png_set_compression_level(png_ptr, level); if (palette) { color_type = PNG_COLOR_TYPE_PALETTE; } else { color_type = PNG_COLOR_TYPE_RGB; } png_set_IHDR(png_ptr, info_ptr, w, h, 8, color_type, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); if (color_type == PNG_COLOR_TYPE_PALETTE) { struct palette_cb_priv priv; png_palette = png_malloc(png_ptr, sizeof(*png_palette) * qdict_size(palette)); priv.vs = vs; priv.png_palette = png_palette; qdict_iter(palette, write_png_palette, &priv); png_set_PLTE(png_ptr, info_ptr, png_palette, qdict_size(palette)); offset = vs->tight.offset; if (vs->clientds.pf.bytes_per_pixel == 4) { tight_encode_indexed_rect32(vs->tight.buffer, w * h, palette); } else { tight_encode_indexed_rect16(vs->tight.buffer, w * h, palette); } } png_write_info(png_ptr, info_ptr); buffer_reserve(&vs->tight_png, 2048); buf = qemu_malloc(w * 3); for (dy = 0; dy < h; dy++) { if (color_type == PNG_COLOR_TYPE_PALETTE) { memcpy(buf, vs->tight.buffer + (dy * w), w); } else { rgb_prepare_row(vs, buf, x, y + dy, w); } png_write_row(png_ptr, buf); } qemu_free(buf); png_write_end(png_ptr, NULL); if (color_type == PNG_COLOR_TYPE_PALETTE) { png_free(png_ptr, png_palette); } png_destroy_write_struct(&png_ptr, &info_ptr); vnc_write_u8(vs, VNC_TIGHT_PNG << 4); tight_send_compact_size(vs, vs->tight_png.offset); vnc_write(vs, vs->tight_png.buffer, vs->tight_png.offset); buffer_reset(&vs->tight_png); return 1; }
1threat
how to make structs point to different strings ? : I have a struct and in that a struct i have a character pointer but and i am creating different instances of this struct but when i am changing the pointer in one struct the other is also changing. #include <stdio.h> #include <stdlib.h> typedef struct human{ int age; char* name; }Human; int main(){ Human h; FILE *s = fopen("h.txt","r"); if(s==NULL){ printf("dsdfsf"); } fscanf(s,"%d",&h.age); fscanf(s,"%s",h.name); // add h to linked list // repeat all this code 10 times to fill linked list by 10 humans return 0; } what is happening that all humans in the linked list have different ages but same name!
0debug
MySQL LEFT JOIN with NULL : <p>I have the following querie:</p> <pre><code>SELECT * FROM work LEFT JOIN users ON work.user_id = users.user_id LEFT JOIN customer ON work.customer_id = customer.customer_id WHERE customer.visible = 0 </code></pre> <p>the problem is about the "LEFT JOIN customer ON..." and the WHERE condition "customer.visible = 0 ". I have entries in my table "work" where "customer_id = NULL" and they get removed from the select because there obviously is no customer with ID "NULL" in the customer table.</p> <p>I would like to keep all entries where "customer_id = NULL" in my work table.</p>
0debug
ckfinder 2.6.x does not remember last folder : <p>I downloaded trial version of the ckfinder and i noticed that it does not remember the last folder from previous use. I believe it should remember right since it has a config option. Also tried with different browsers like Chrome, Edge, Opera and set <code>config.rememberLastFolder = true</code> to be sure but still same, it always stars from <code>File</code> folder. Any idea?</p>
0debug
int nbd_client_init(BlockDriverState *bs, QIOChannelSocket *sioc, const char *export, QCryptoTLSCreds *tlscreds, const char *hostname, Error **errp) { NbdClientSession *client = nbd_get_client_session(bs); int ret; logout("session init %s\n", export); qio_channel_set_blocking(QIO_CHANNEL(sioc), true, NULL); ret = nbd_receive_negotiate(QIO_CHANNEL(sioc), export, &client->nbdflags, tlscreds, hostname, &client->ioc, &client->size, errp); if (ret < 0) { logout("Failed to negotiate with the NBD server\n"); return ret; } if (client->nbdflags & NBD_FLAG_SEND_FUA) { bs->supported_write_flags = BDRV_REQ_FUA; } qemu_co_mutex_init(&client->send_mutex); qemu_co_mutex_init(&client->free_sema); client->sioc = sioc; object_ref(OBJECT(client->sioc)); if (!client->ioc) { client->ioc = QIO_CHANNEL(sioc); object_ref(OBJECT(client->ioc)); } qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL); nbd_client_attach_aio_context(bs, bdrv_get_aio_context(bs)); logout("Established connection with NBD server\n"); return 0; }
1threat
How to reference a XML element nested within an unknown amount of other elements : I want to reference an XML element that is nested within an unknown amount of other elements. <br> For example if I have an XML file like this: <root> <Example> </Example> </root> And I want to add an element within the `<Example>` element. When I add an element within the root element I can do it like this (assuming `Doc` is an already defined XDocument) Doc.Element("root").Add(new XElement("Example")); And if there is two I can do Doc.Element("root").Element("Example").Add(new XElement("newExample")) This works fine if I know exactly what elements are going to be within what, because I can hardcode it. This does not work, however, when I don't know what elements are going to be in what.<br><br> My project is a virtual folder system (makes more sense if you read [this][1]), so I don't know what elements will be nested within what. I have thought of saving the directory within the program in a `List<string>`, which works to store the directory, but because the only way I know how to reference elements is with hardcoding every single element. Is there any way I can reference any element nested within any other element without having to hardcode every parent element? [1]: https://github.com/CobaltsDev/Virtual-Folder-System/wiki
0debug
Overlap between values in a row in one dataframe and colums in other dataframe : This should be straightforward, but I am kind of stuck. Dataframe (df1) has column with chr variable, some of these values in that column correspond to column names in other data frame (df2). I would need to find an overlap between values (rows) of that column in df1 and all the columns in df2. Since the number of these columns is > ~1200, I can not filter one by one. Is there another elegant way other than transpose? Thank you in advance.
0debug
Can a site like this be designed in full html and css? : <p>Currently the one shown is designed in html and images. Just wondering if it can be done before I can start including the center piece where it splits and turns. Doesnt have to be responsive but just be full width. I dont want to start and then be stuck where in the middle it does a split</p> <p><a href="https://i.stack.imgur.com/H3xk4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H3xk4.jpg" alt="enter image description here"></a></p>
0debug
IllegalArgumentException: savedInstanceState Specified as Non-Null is Null : <p>I am getting a strange error when I start my <code>MainActivity</code>:</p> <pre><code>06-16 16:01:05.193 2083-2083/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.android.example.github, PID: 2083 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.example.github/com.android.example.github.ui.MainActivity}: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter savedInstanceState at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter savedInstanceState at com.android.example.github.injection.AppInjector$init$1.onActivityCreated(AppInjector.kt) at android.app.Application.dispatchActivityCreated(Application.java:197) at android.app.Activity.onCreate(Activity.java:961) at android.support.v4.app.BaseFragmentActivityGingerbread.onCreate(BaseFragmentActivityGingerbread.java:54) at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:319) at com.android.example.github.ui.MainActivity.onCreate(MainActivity.kt:20) at android.app.Activity.performCreate(Activity.java:6682) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)  at android.app.ActivityThread.-wrap12(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6121)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)  </code></pre> <p>This is my <code>MainActivity</code> class:</p> <pre><code>class MainActivity : LifecycleActivity(), HasSupportFragmentInjector { lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector&lt;Fragment&gt; @Inject set lateinit var navigationController: NavigationController override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.main_activity) if (savedInstanceState == null) { navigationController.navigateToSearch() } } override fun supportFragmentInjector(): AndroidInjector&lt;Fragment&gt; { return dispatchingAndroidInjector } } </code></pre> <p>The error states that the parameter <code>savedInstanceState</code> is null, when it is specified as non-null; but it is nullable (<code>savedInstanceState: Bundle?</code>) and the <code>onCreate()</code> method is marked as <code>@Nullable</code> in the source.</p> <p>I have not come across this error in any of my other Kotlin projects. I am using Kotlin version 1.1.2-5; and had the same error with 1.1.2-3.</p>
0debug
How to use --init parameter in docker run : <p>There are <code>--init</code> and <code>--init-path</code> options for <code>docker run</code>, but it's not clear how to use it.</p> <p>At first, I thought it's something like <a href="https://github.com/Yelp/dumb-init" rel="noreferrer">dumb-init</a>, but included in docker core (kind of "native"). But <code>--init</code> key demands <code>--init-path</code> to be set as well, pointing to 'docker-init binary', and gives no clue on where to take it. Google is silent about 'docker-init'.</p> <p>Okay, maybe I'm supposed to use 'yelp/dumb-init' or 'phusion/baseimage-docker', but those solutions don't seem to use <code>docker run</code>'s <code>--init</code> option.</p> <p>So, I'm curious where do I take this "docker-init binary" to set the <code>--init-path</code> to?</p>
0debug
Ajax call not working with Decrypto : I have to convert a encrypted data response back to plain text. For this I am using a ajax post call to get the data response and than on sucess passing that data response a decrypto function and getting back the response in plain text (this is the idea) Now, when I created a Ajax post call and than passing that decrypto their on success nothing is happening I am sure my decrypto is working Here is working fiddle for that https://jsfiddle.net/yktup39e/ Now, problem is in the Ajax. I have only once make an Ajax call so I pretty much sure there will problem in that. But I am not getting that. This is my code- <!DOCTYPE html> <html> <head> <script src="tripledes.js"></script> <script src="mode-ecb.js"></script> <script type="text/javascript"> $('#action-button').click(function() { $.ajax({ url: 'http://192.168.168.76:8080/HTMLPortingNewService/GetData?ChartName=widget3LineChart&lob=M&carrier=0&enrollmenttype=0&state=0&agent=0&fromdate=04%2F03%2F2015&todate=05%2F03%2F2015&requestID=499F6BF5E4610454A887AB37AF0814E8', error: function() { $('#info').html('<p>An error has occurred</p>'); }, method: "POST", headers: { "cache-control": "no-cache", "postman-token": "ac20a050-a8c8-6d58-4350-66141d519394", "content-type": "application/x-www-form-urlencoded" }, data: { "username": "aHRtbHVzZXIx", "password": "SHRtbDIwMTY=" }, success: function(data, DES) { var keyHex = CryptoJS.enc.Utf8.parse(keyString); var decrypted = CryptoJS.DES.decrypt({ ciphertext: CryptoJS.enc.Base64.parse(cipherTextString) }, keyHex, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }); alert(decrypted); return decrypted.toString(CryptoJS.enc.Utf8); } }); </script> </head> <body> <button id="action-button">Click me to load info!</button> <div id="info"></div> </body> </html> Can anyone please help me with that??
0debug
How does ggplot scale_continuous expand argument work? : <p>I am trying to figure out how <code>scale_continuous()</code> <code>expand</code> argument works. According to <a href="http://ggplot2.tidyverse.org/reference/scale_continuous.html" rel="noreferrer">scale_continuous documentation</a>:</p> <blockquote> <p>A numeric vector of length two giving multiplicative and additive expansion constants. These constants ensure that the data is placed some distance away from the axes. The defaults are c(0.05, 0) for continuous variables, and c(0, 0.6) for discrete variables.</p> </blockquote> <p>Since they are "expansion constants", they are not actual units. Is there any way to convert them to some actual measurement to predict the actual output? For anything except 0, I just try random numbers until it works. There must be a more proper way to approach this.</p>
0debug
R: Combining select() and filter() : Does it matter in which order I have select() and filter()? Can I have select(filter()) or filter(select()) depending on what I want?
0debug
static void s390_cpu_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { MachineState *ms = MACHINE(hotplug_dev); S390CPU *cpu = S390_CPU(dev); g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu); ms->possible_cpus->cpus[cpu->env.core_id].cpu = OBJECT(dev);
1threat
static int rtsp_read_packet(AVFormatContext *s, AVPacket *pkt) { RTSPState *rt = s->priv_data; int ret; RTSPMessageHeader reply1, *reply = &reply1; char cmd[1024]; if (rt->server_type == RTSP_SERVER_REAL) { int i; enum AVDiscard cache[MAX_STREAMS]; for (i = 0; i < s->nb_streams; i++) cache[i] = s->streams[i]->discard; if (!rt->need_subscription) { if (memcmp (cache, rt->real_setup_cache, sizeof(enum AVDiscard) * s->nb_streams)) { av_strlcatf(cmd, sizeof(cmd), "SET_PARAMETER %s RTSP/1.0\r\n" "Unsubscribe: %s\r\n", s->filename, rt->last_subscription); rtsp_send_cmd(s, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return AVERROR_INVALIDDATA; rt->need_subscription = 1; } } if (rt->need_subscription) { int r, rule_nr, first = 1; memcpy(rt->real_setup_cache, cache, sizeof(enum AVDiscard) * s->nb_streams); rt->last_subscription[0] = 0; snprintf(cmd, sizeof(cmd), "SET_PARAMETER %s RTSP/1.0\r\n" "Subscribe: ", s->filename); for (i = 0; i < rt->nb_rtsp_streams; i++) { rule_nr = 0; for (r = 0; r < s->nb_streams; r++) { if (s->streams[r]->priv_data == rt->rtsp_streams[i]) { if (s->streams[r]->discard != AVDISCARD_ALL) { if (!first) av_strlcat(rt->last_subscription, ",", sizeof(rt->last_subscription)); ff_rdt_subscribe_rule( rt->last_subscription, sizeof(rt->last_subscription), i, rule_nr); first = 0; } rule_nr++; } } } av_strlcatf(cmd, sizeof(cmd), "%s\r\n", rt->last_subscription); rtsp_send_cmd(s, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return AVERROR_INVALIDDATA; rt->need_subscription = 0; if (rt->state == RTSP_STATE_PLAYING) rtsp_read_play (s); } } ret = rtsp_fetch_packet(s, pkt); if (ret < 0) { return ret; } if ((rt->server_type == RTSP_SERVER_WMS || rt->server_type == RTSP_SERVER_REAL) && (av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) { if (rt->server_type == RTSP_SERVER_WMS) { snprintf(cmd, sizeof(cmd) - 1, "GET_PARAMETER %s RTSP/1.0\r\n", s->filename); rtsp_send_cmd_async(s, cmd, reply, NULL); } else { rtsp_send_cmd_async(s, "OPTIONS * RTSP/1.0\r\n", reply, NULL); } } return 0; }
1threat