problem
stringlengths
26
131k
labels
class label
2 classes
Can I access a nested dict with a list of keys? : <p>I would like to access a dictionary programmatically. I know how to do this with a recursive function, but is there a simpler way?</p> <pre><code>example = {'a': {'b': 'c'}, '1': {'2': {'3': {'4': '5'}}}} keys = ('a', 'b') example[keys] = 'new' # Now it should be # example = {'a': {'b': 'new'}, # '1': {'2': {'3': {'4': '5'}}}} keys = ('1', '2', '3', '4') example[keys] = 'foo' # Now it should be # example = {'a': {'b': 'new'}, # '1': {'2': {'3': {'4': 'foo'}}}} keys = ('1', '2') example[keys] = 'bar' # Now it should be # example = {'a': {'b': 'new'}, # '1': {'2': 'bar'}} </code></pre>
0debug
I want to generate all possible list from given range of list which will target given input sum : Input:target sum output: count of all possible pairs of given sum from : **list[1,2,3]** Example: Input 4 Output 7 Explanation 1, 1, 1, 1 1, 2, 1 1, 1, 2 1, 3 2, 1, 1 2, 2 3, 1 Note: for these given pairs for explanation of output these all must be taken from only and only.....**[1,2,3]** for any input...
0debug
detect browser refresh/F5/right click reload in angular 5 : <p>I have a requirement where, Users inputs something and submit then angular does a service call which returns if users input is valid/invalid. If valid take user to success page, if service returns invalid/bad input then user needs to be taken to failure page and should never be able to go back(using back button) or user refresh the page, user should still be on same page. Only option provided to the user should be close browser, there by not allowing using to submit one more request(leading to service call).</p>
0debug
How to circumvent "apt-key output should not be parsed"? : <p>I'm automating my Docker installation. Something like this:</p> <pre><code>if apt-key fingerprint 0EBFCD88 | grep "Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88" &gt; /dev/null then # proceed fi </code></pre> <p>This worked fine in older versions of <code>apt-key</code>, but recent versions have two issues:</p> <ol> <li>A different output format: I can hack around that</li> <li><p>A warning:</p> <pre><code>Warning: apt-key output should not be parsed (stdout is not a terminal) </code></pre></li> </ol> <p>Clearly, I can hack around this as well, just redirect <code>stderr</code> to <code>/dev/null</code>. It just made me curious:</p> <p><strong>How do these fine folks suggest I verify my key fingerprints?</strong> Or am I getting this fundamentally wrong by wanting to automate it, does that defeat the point? (I think not, since I still manually lifted the expected fingerprint from the website, but feel free to tell me otherwise...)</p>
0debug
C# Palindrome Test : <p>I need to create a IsPalindrome function where it will determine if a provided string is a palindrome. Alphanumeric chars will be considered when evaluating whether or not the string is a palindrome. With this said, I am having trouble trying to disreguard the spaces and the Caps. Here is what my function looks like now. If this makes a difference: After this function is done I will then have to have parse a JSON file and have each element in the "strings" array, into the IsPalindrome function. Any tips?</p> <pre><code> private static bool IsPalindrome(string value) { var min = 0; var max = value.Length - 1; while (true) { if (min &gt; max) return true; var a = value[min]; var b = value[max]; if (if (char.ToLower(a) == char.ToLower(b)) { return true; } else { return false; } min++; max--; } </code></pre>
0debug
Using def for pyplot - all data plotted, not what is passed to def : I created a basic def function to use with pyplot. I have a csv(UTF8) file has the time and free memory statistics logged every 3 seconds for different file systems. Here is my file structure: time_seconds,filesystem_1_freemem,filesystem_2_freemem,filesystem_3_freemem I am trying to plot freemem data different filesystem data for comparison. I have the following code: def draw_graph (input_file, x_axis, y_axis, label_color, label_name, graph_title): fig = plt.figure() ax = input_file.plot(kind="line") plt.title(graph_title) ax.set_xlabel("Time (seconds)") ax.set_ylabel("freemem") plt.ticklabel_format(style="plain", axis="y") plt.show When I call this function with the following arguments, it draws *all* the data (filesystem_1_freemem, filesystem_2_freemem, filesystem_3_freemem), *not* the argument that I am passing it (filesystem_1_freemem): draw_graph(df, "time_seconds", "filesystem_1_freemem" , "Red", "filesystem_1_freemem","Filesystem 1 - Freemem Values") Obviously, there is something I am missing, so that it is plotting whatever is in the CSV file. How can I correct this? After that, as an improvement, how can I revise the code so that it plots one (or multiple) argument(s) that it is given? (assume a for loop for the arguments?) Thank you very much for your kind assistance!
0debug
Change textView from another XML : I my Android APP, i have somes `XML`, i want to modify a `textView`, but he is not in the primary `XML` fixe for this `activity`. I've try : TextView nav_playerid = (TextView) findViewById(R.id.nav_username); nav_playerid.setText(id_joueur_connect); But that's don't work. How i can tell to the app to get this specific XML File and modify this `textView`? Thanks
0debug
Does every java program's .class file contains public class? : I got a question on the exam. Does every .class file contains a public class? yes/no
0debug
How to make time limit or dealy in gmail send email? : how to make time limit in Gmail send email? I want to add time limit while sending email in Gmail. or like undo email option in Gmail.. Please help!!! Thank you in advance
0debug
Interpret this SQL in to English : <p>I've been given the task of rewriting certain sections of this SQL but am having trouble interpreting it completely. In plain English could an SQL master explain what is happening from "appointments_2015 AS" to the end. </p> <pre><code>CREATE TABLE appointment ( emp_id integer NOT NULL, jobtitle varchar(128) NOT NULL, salary decimal(10,2) NOT NULL, start_date date NOT NULL, end_date date NULL ); ALTER TABLE appointment ADD CONSTRAINT pkey_appointment PRIMARY KEY (emp_id, jobtitle, start_date); ALTER TABLE appointment ADD CONSTRAINT chk_appointment_period CHECK (start_date &lt;= end_date); WITH current_employees AS ( SELECT DISTINCT emp_id FROM appointment WHERE end_date IS NULL ), appointments_2015 AS ( SELECT a.emp_id, salary, CASE WHEN start_date &lt; ’2015-01-01’ THEN ’2015-01-01’ ELSE start_date END AS start_date, CASE WHEN end_date &lt; ’2016-01-01’ THEN end_date ELSE ’2015-12-31’ END AS end_date FROM appointment a JOIN current_employees ce ON a.emp_id = ce.emp_id WHERE start_date &lt; ’2016-01-01’ AND (end_date &gt;= ’2015-01-01’ OR end_date IS NULL) ) SELECT emp_id, SUM( salary * (end_date - start_date + 1) / 365 ) AS total FROM appointments_2015 GROUP BY emp_id </code></pre>
0debug
Should I add the google-services.json (from Firebase) to my repository? : <p>I just signed up with Firebase and I created a new project. Firebase asked me for my app domain and a SHA1 debug key. I input these details and it generated a google-services.json file for me to add in the root of my app module.</p> <p>My question is, should this .json file be added to a public (open source) repo. Is it something that should be secret, like an API key?</p>
0debug
hadamard_func(mmxext) hadamard_func(sse2) hadamard_func(ssse3) av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx) { int cpu_flags = av_get_cpu_flags(); #if HAVE_YASM int bit_depth = avctx->bits_per_raw_sample; if (EXTERNAL_MMX(cpu_flags)) { if (bit_depth <= 8) c->get_pixels = ff_get_pixels_mmx; c->diff_pixels = ff_diff_pixels_mmx; c->pix_sum = ff_pix_sum16_mmx; c->pix_norm1 = ff_pix_norm1_mmx; } if (EXTERNAL_SSE2(cpu_flags)) if (bit_depth <= 8) c->get_pixels = ff_get_pixels_sse2; #endif #if HAVE_INLINE_ASM if (cpu_flags & AV_CPU_FLAG_MMX) { const int dct_algo = avctx->dct_algo; if (avctx->bits_per_raw_sample <= 8 && (dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)) { if (cpu_flags & AV_CPU_FLAG_SSE2) { c->fdct = ff_fdct_sse2; } else if (cpu_flags & AV_CPU_FLAG_MMXEXT) { c->fdct = ff_fdct_mmxext; }else{ c->fdct = ff_fdct_mmx; } } c->diff_bytes= diff_bytes_mmx; c->sum_abs_dctelem= sum_abs_dctelem_mmx; c->sse[0] = sse16_mmx; c->sse[1] = sse8_mmx; c->vsad[4]= vsad_intra16_mmx; c->nsse[0] = nsse16_mmx; c->nsse[1] = nsse8_mmx; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->vsad[0] = vsad16_mmx; } if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_mmx; } c->add_8x8basis= add_8x8basis_mmx; c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx; if (cpu_flags & AV_CPU_FLAG_MMXEXT) { c->sum_abs_dctelem = sum_abs_dctelem_mmxext; c->vsad[4] = vsad_intra16_mmxext; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->vsad[0] = vsad16_mmxext; } c->sub_hfyu_median_prediction = sub_hfyu_median_prediction_mmxext; } if (cpu_flags & AV_CPU_FLAG_SSE2) { c->sum_abs_dctelem= sum_abs_dctelem_sse2; } #if HAVE_SSSE3_INLINE if (cpu_flags & AV_CPU_FLAG_SSSE3) { if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_ssse3; } c->add_8x8basis= add_8x8basis_ssse3; c->sum_abs_dctelem= sum_abs_dctelem_ssse3; } #endif if (cpu_flags & AV_CPU_FLAG_3DNOW) { if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_3dnow; } c->add_8x8basis= add_8x8basis_3dnow; } } #endif if (EXTERNAL_MMX(cpu_flags)) { c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx; c->hadamard8_diff[1] = ff_hadamard8_diff_mmx; if (EXTERNAL_MMXEXT(cpu_flags)) { c->hadamard8_diff[0] = ff_hadamard8_diff16_mmxext; c->hadamard8_diff[1] = ff_hadamard8_diff_mmxext; } if (EXTERNAL_SSE2(cpu_flags)) { c->sse[0] = ff_sse16_sse2; #if HAVE_ALIGNED_STACK c->hadamard8_diff[0] = ff_hadamard8_diff16_sse2; c->hadamard8_diff[1] = ff_hadamard8_diff_sse2; #endif } if (EXTERNAL_SSSE3(cpu_flags) && HAVE_ALIGNED_STACK) { c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3; c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3; } } ff_dsputil_init_pix_mmx(c, avctx); }
1threat
IOS google images search : <p>I want to develop IOS app so I can search images from google and display it on app but i had hard time to to find api is there any way to send request to and get images from google and thank you.</p>
0debug
Why 4.7 is 4.6999999 in c : <p>'</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;math.h&gt; int main(){ int i; float num = 4.700; for(i=1;i&lt;5;i++){ printf("%0.3f\tx%d\t\t=%d\n",num,(int)pow(10,i),(int)(num*pow(10,i))); } return 0; } </code></pre> <p>' This code prints the following to the console: ' </p> <pre><code>4.7000 x10 =46 4.7000 x100 =469 4.7000 x1000 =4699 4.7000 x10000 =46999 </code></pre> <p>' This result is not consistent with all floating point values </p> <p>1.2000 prints out ...120...1200 etc<br> 1.8000 is strange again</p> <p>I am working in Codeblocks and my question is why do some floats react this way?I there something fundamental to C or the mingw compiler that I am missing? Or is there something wrong with my code?<br> Thanks for the help and sorry if it's a repeat question</p>
0debug
how to input the credentials during python automation? : I would like to automate the Facebook login without hard-coding my username and password. Kindly suggest me code for this scenario.
0debug
static av_cold int flic_decode_init(AVCodecContext *avctx) { FlicDecodeContext *s = avctx->priv_data; unsigned char *fli_header = (unsigned char *)avctx->extradata; int depth; if (avctx->extradata_size != 12 && avctx->extradata_size != 128) { av_log(avctx, AV_LOG_ERROR, "Expected extradata of 12 or 128 bytes\n"); return AVERROR_INVALIDDATA; } s->avctx = avctx; s->fli_type = AV_RL16(&fli_header[4]); depth = 0; if (s->avctx->extradata_size == 12) { s->fli_type = FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE; depth = 8; } else { depth = AV_RL16(&fli_header[12]); } if (depth == 0) { depth = 8; } if ((s->fli_type == FLC_FLX_TYPE_CODE) && (depth == 16)) { depth = 15; } switch (depth) { case 8 : avctx->pix_fmt = AV_PIX_FMT_PAL8; break; case 15 : avctx->pix_fmt = AV_PIX_FMT_RGB555; break; case 16 : avctx->pix_fmt = AV_PIX_FMT_RGB565; break; case 24 : avctx->pix_fmt = AV_PIX_FMT_BGR24; av_log(avctx, AV_LOG_ERROR, "24Bpp FLC/FLX is unsupported due to no test files.\n"); return AVERROR_PATCHWELCOME; default : av_log(avctx, AV_LOG_ERROR, "Unknown FLC/FLX depth of %d Bpp is unsupported.\n",depth); return AVERROR_INVALIDDATA; } s->frame.data[0] = NULL; s->new_palette = 0; return 0; }
1threat
static inline void reloc_pc26(tcg_insn_unit *code_ptr, tcg_insn_unit *target) { ptrdiff_t offset = target - code_ptr; assert(offset == sextract64(offset, 0, 26)); *code_ptr = deposit32(*code_ptr, 0, 26, offset); }
1threat
React Native: Custom font renders differently on Android and iOS : <p>In the picture below I have inspected the same Text-component as rendered on Android on the left and iOS on the right. It seems that iOS renders the font in top of the Text-container.</p> <p>I'm using the same TTF font-file for both Android and iOS. (I found an online reference to the font I'm using <a href="https://github.com/zolitariuz/ceuhz/blob/master/fonts/Metric-Regular.ttf">here</a>.)</p> <p>Any ideas how to make the font render the same for both Android and iOS?</p> <p><a href="https://i.stack.imgur.com/Oimjp.png"><img src="https://i.stack.imgur.com/Oimjp.png" alt="enter image description here"></a></p> <p>Just to be clear, the difference is not caused by any styling (margin, font size, etc.). It's exactly the same.</p>
0debug
Elixir Sleep / Wait for 1 Second : <p>How to sleep / wait for one second?</p> <p>Best I could find was something like this (in iex):</p> <pre><code>IO.puts "foo" ; :timer.sleep(1); IO.puts "bar" </code></pre> <p>But both of my puts happen with no delay.</p>
0debug
uint32_t helper_efdctsf (uint64_t val) { CPU_DoubleU u; float64 tmp; u.ll = val; if (unlikely(float64_is_nan(u.d))) return 0; tmp = uint64_to_float64(1ULL << 32, &env->vec_status); u.d = float64_mul(u.d, tmp, &env->vec_status); return float64_to_int32(u.d, &env->vec_status); }
1threat
GraphQL dynamic query building : <p>I have a GraphQL server which is able to serve timeseries data for a specified source (for example, sensor data). An example query to fetch the data for a sensor might be:</p> <pre><code>query fetchData { timeseriesData(sourceId: "source1") { data { time value } } } </code></pre> <p>In my frontend, I want to allow the user to select 1 or more sources and show a chart with a line for each one. It seems like this would be possible by using a query like this:</p> <pre><code>query fetchData { series1: timeseriesData(sourceId: "source1") { data { time value } } series2: timeseriesData(sourceId: "source2") { data { time value } } } </code></pre> <p>Most GraphQL tutorials seem to focus on static queries (e.g. where the only thing that is changing is the variables, but not the actual shape of the request) - but in my case I need the <em>query itself</em> to be dynamic (one timeseriesData request for each of my selected ids).</p> <p>I have the following constraints:</p> <ol> <li>Modifying the server's schema is not an option (so I can't pass an array of IDs to the resolver, for example)</li> <li>My query is specified using a template string e.g. gql`...`</li> <li>I don't want to have to manually build up the query as a string, because that seems like a recipe for disaster and would mean that I lose all tooling benefits (e.g. autocomplete, syntax highlighting, linting)</li> </ol> <p>The stack I'm using is:</p> <ul> <li>Apollo client (specifically apollo-angular)</li> <li>Angular </li> <li>TypeScript</li> <li>graphql-tag (for defining queries)</li> </ul> <p>Ideally, what I want to do is have some way of merging two queries into one, so that I can define them as per the first example but then join them together in an abstraction layer so that I get a single query like the second example to be sent over the wire. </p> <p>However I'm not sure how to achieve this because graphql-tag is parsing the query into an AST and I'm struggling to understand whether it's feasable to manipulate the query in this way.</p> <p><strong>What techniques are there for generating a dynamic query like this, where the <em>shape</em> of the query is not known upfront?</strong></p>
0debug
Combining two data frames : <p>I have two data frames from a study, datlighton and datlightoff, They both have roughly the same data since what separates the observations is that off takes place before midnight and on takes place after. I need to combine them into a single data frame called datlight but I'm not sure how to do it. I've tried using cbind and merge but I'm new to R and I don't quite understand how to make it do exactly what I want. When I try <code>merge(datlighton,datlightoff)</code> it gives me a data frame with all the column names but none of the rows. This is <a href="http://file:///Users/brittabergren/Desktop/Ecology/Term%20Paper/Term%20Paper%20Work/datlighton.html" rel="nofollow">datlighton</a> and <a href="http://file:///Users/brittabergren/Desktop/Ecology/Term%20Paper/Term%20Paper%20Work/datlightoff.html" rel="nofollow">datlightoff</a>, I converted it to an html since I don't know to upload them as dataframes from R. Basically I just need to put all the rows from one frame into the other and have them match up with the appropriate column name.</p>
0debug
Count columns in TXT with C++? : <p>I have these types of data in txt files.</p> <pre><code>1 3 4 5 2 4 5 2 3 5 7 8 2 5 7 8 </code></pre> <p>or even </p> <pre><code>1 3 4 5 2 4 5 2 3 5 7 8 2 5 7 8 </code></pre> <p>Separated with TABs, with one space or exported from excel. I need a function to count columns, that returns an int, how can I do this?</p> <p>Thanks!</p>
0debug
static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec, int copy) { AVStream *fst; fst = av_mallocz(sizeof(AVStream)); if (!fst) return NULL; if (copy) { fst->codec= avcodec_alloc_context(); memcpy(fst->codec, codec, sizeof(AVCodecContext)); if (codec->extradata_size) { fst->codec->extradata = av_malloc(codec->extradata_size); memcpy(fst->codec->extradata, codec->extradata, codec->extradata_size); } } else { fst->codec = codec; } fst->priv_data = av_mallocz(sizeof(FeedData)); fst->index = stream->nb_streams; av_set_pts_info(fst, 33, 1, 90000); fst->sample_aspect_ratio = (AVRational){0,1}; stream->streams[stream->nb_streams++] = fst; return fst; }
1threat
static int sd_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { int ret, fd; uint32_t vid = 0; BDRVSheepdogState *s = bs->opaque; char vdi[SD_MAX_VDI_LEN], tag[SD_MAX_VDI_TAG_LEN]; uint32_t snapid; char *buf = NULL; QemuOpts *opts; Error *local_err = NULL; const char *filename; s->bs = bs; s->aio_context = bdrv_get_aio_context(bs); opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto err_no_fd; } filename = qemu_opt_get(opts, "filename"); QLIST_INIT(&s->inflight_aio_head); QLIST_INIT(&s->failed_aio_head); QLIST_INIT(&s->inflight_aiocb_head); s->fd = -1; memset(vdi, 0, sizeof(vdi)); memset(tag, 0, sizeof(tag)); if (strstr(filename, ": ret = sd_parse_uri(s, filename, vdi, &snapid, tag); } else { ret = parse_vdiname(s, filename, vdi, &snapid, tag); } if (ret < 0) { error_setg(errp, "Can't parse filename"); goto err_no_fd; } s->fd = get_sheep_fd(s, errp); if (s->fd < 0) { ret = s->fd; goto err_no_fd; } ret = find_vdi_name(s, vdi, snapid, tag, &vid, true, errp); if (ret) { goto err; } s->cache_flags = SD_FLAG_CMD_CACHE; if (flags & BDRV_O_NOCACHE) { s->cache_flags = SD_FLAG_CMD_DIRECT; } s->discard_supported = true; if (snapid || tag[0] != '\0') { DPRINTF("%" PRIx32 " snapshot inode was open.\n", vid); s->is_snapshot = true; } fd = connect_to_sdog(s, errp); if (fd < 0) { ret = fd; goto err; } buf = g_malloc(SD_INODE_SIZE); ret = read_object(fd, s->bs, buf, vid_to_vdi_oid(vid), 0, SD_INODE_SIZE, 0, s->cache_flags); closesocket(fd); if (ret) { error_setg(errp, "Can't read snapshot inode"); goto err; } memcpy(&s->inode, buf, sizeof(s->inode)); bs->total_sectors = s->inode.vdi_size / BDRV_SECTOR_SIZE; pstrcpy(s->name, sizeof(s->name), vdi); qemu_co_mutex_init(&s->lock); qemu_co_queue_init(&s->overlapping_queue); qemu_opts_del(opts); g_free(buf); return 0; err: aio_set_fd_handler(bdrv_get_aio_context(bs), s->fd, false, NULL, NULL, NULL, NULL); closesocket(s->fd); err_no_fd: qemu_opts_del(opts); g_free(buf); return ret; }
1threat
How to format minutes to hours - using moment.js : <p>I am using moment.js.</p> <p>I get minutes (max 1440) and i wanted to format that in hours in specific format. </p> <p>Something like this:</p> <p>420 minutes is: <strong>07:00</strong></p> <p>1140 minutes is: <strong>24:00</strong></p> <p>451 minutes is: <strong>07:31</strong></p>
0debug
static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) { int32_t disp21, disp16, disp12 __attribute__((unused)); uint16_t fn11; uint8_t opc, ra, rb, rc, fpfn, fn7, lit; bool islit; TCGv va, vb, vc, tmp; TCGv_i32 t32; ExitStatus ret; opc = extract32(insn, 26, 6); ra = extract32(insn, 21, 5); rb = extract32(insn, 16, 5); rc = extract32(insn, 0, 5); islit = extract32(insn, 12, 1); lit = extract32(insn, 13, 8); disp21 = sextract32(insn, 0, 21); disp16 = sextract32(insn, 0, 16); disp12 = sextract32(insn, 0, 12); fn11 = extract32(insn, 5, 11); fpfn = extract32(insn, 5, 6); fn7 = extract32(insn, 5, 7); if (rb == 31 && !islit) { islit = true; lit = 0; } ret = NO_EXIT; switch (opc) { case 0x00: ret = gen_call_pal(ctx, insn & 0x03ffffff); break; case 0x01: goto invalid_opc; case 0x02: goto invalid_opc; case 0x03: goto invalid_opc; case 0x04: goto invalid_opc; case 0x05: goto invalid_opc; case 0x06: goto invalid_opc; case 0x07: goto invalid_opc; case 0x09: disp16 = (uint32_t)disp16 << 16; case 0x08: va = dest_gpr(ctx, ra); if (rb == 31) { tcg_gen_movi_i64(va, disp16); } else { tcg_gen_addi_i64(va, load_gpr(ctx, rb), disp16); } break; case 0x0A: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX); gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0); break; case 0x0B: gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1); break; case 0x0C: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX); gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 0); break; case 0x0D: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX); gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0); break; case 0x0E: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX); gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0); break; case 0x0F: gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1); break; case 0x10: vc = dest_gpr(ctx, rc); vb = load_gpr_lit(ctx, rb, lit, islit); if (ra == 31) { if (fn7 == 0x00) { tcg_gen_ext32s_i64(vc, vb); break; } if (fn7 == 0x29) { tcg_gen_neg_i64(vc, vb); break; } } va = load_gpr(ctx, ra); switch (fn7) { case 0x00: tcg_gen_add_i64(vc, va, vb); tcg_gen_ext32s_i64(vc, vc); break; case 0x02: tmp = tcg_temp_new(); tcg_gen_shli_i64(tmp, va, 2); tcg_gen_add_i64(tmp, tmp, vb); tcg_gen_ext32s_i64(vc, tmp); tcg_temp_free(tmp); break; case 0x09: tcg_gen_sub_i64(vc, va, vb); tcg_gen_ext32s_i64(vc, vc); break; case 0x0B: tmp = tcg_temp_new(); tcg_gen_shli_i64(tmp, va, 2); tcg_gen_sub_i64(tmp, tmp, vb); tcg_gen_ext32s_i64(vc, tmp); tcg_temp_free(tmp); break; case 0x0F: gen_helper_cmpbge(vc, va, vb); break; case 0x12: tmp = tcg_temp_new(); tcg_gen_shli_i64(tmp, va, 3); tcg_gen_add_i64(tmp, tmp, vb); tcg_gen_ext32s_i64(vc, tmp); tcg_temp_free(tmp); break; case 0x1B: tmp = tcg_temp_new(); tcg_gen_shli_i64(tmp, va, 3); tcg_gen_sub_i64(tmp, tmp, vb); tcg_gen_ext32s_i64(vc, tmp); tcg_temp_free(tmp); break; case 0x1D: tcg_gen_setcond_i64(TCG_COND_LTU, vc, va, vb); break; case 0x20: tcg_gen_add_i64(vc, va, vb); break; case 0x22: tmp = tcg_temp_new(); tcg_gen_shli_i64(tmp, va, 2); tcg_gen_add_i64(vc, tmp, vb); tcg_temp_free(tmp); break; case 0x29: tcg_gen_sub_i64(vc, va, vb); break; case 0x2B: tmp = tcg_temp_new(); tcg_gen_shli_i64(tmp, va, 2); tcg_gen_sub_i64(vc, tmp, vb); tcg_temp_free(tmp); break; case 0x2D: tcg_gen_setcond_i64(TCG_COND_EQ, vc, va, vb); break; case 0x32: tmp = tcg_temp_new(); tcg_gen_shli_i64(tmp, va, 3); tcg_gen_add_i64(vc, tmp, vb); tcg_temp_free(tmp); break; case 0x3B: tmp = tcg_temp_new(); tcg_gen_shli_i64(tmp, va, 3); tcg_gen_sub_i64(vc, tmp, vb); tcg_temp_free(tmp); break; case 0x3D: tcg_gen_setcond_i64(TCG_COND_LEU, vc, va, vb); break; case 0x40: gen_helper_addlv(vc, cpu_env, va, vb); break; case 0x49: gen_helper_sublv(vc, cpu_env, va, vb); break; case 0x4D: tcg_gen_setcond_i64(TCG_COND_LT, vc, va, vb); break; case 0x60: gen_helper_addqv(vc, cpu_env, va, vb); break; case 0x69: gen_helper_subqv(vc, cpu_env, va, vb); break; case 0x6D: tcg_gen_setcond_i64(TCG_COND_LE, vc, va, vb); break; default: goto invalid_opc; } break; case 0x11: if (fn7 == 0x20) { if (rc == 31) { break; } if (ra == 31) { vc = dest_gpr(ctx, rc); if (islit) { tcg_gen_movi_i64(vc, lit); } else { tcg_gen_mov_i64(vc, load_gpr(ctx, rb)); } break; } } vc = dest_gpr(ctx, rc); vb = load_gpr_lit(ctx, rb, lit, islit); if (fn7 == 0x28 && ra == 31) { tcg_gen_not_i64(vc, vb); break; } va = load_gpr(ctx, ra); switch (fn7) { case 0x00: tcg_gen_and_i64(vc, va, vb); break; case 0x08: tcg_gen_andc_i64(vc, va, vb); break; case 0x14: tmp = tcg_temp_new(); tcg_gen_andi_i64(tmp, va, 1); tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx), vb, load_gpr(ctx, rc)); tcg_temp_free(tmp); break; case 0x16: tmp = tcg_temp_new(); tcg_gen_andi_i64(tmp, va, 1); tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx), vb, load_gpr(ctx, rc)); tcg_temp_free(tmp); break; case 0x20: tcg_gen_or_i64(vc, va, vb); break; case 0x24: tcg_gen_movcond_i64(TCG_COND_EQ, vc, va, load_zero(ctx), vb, load_gpr(ctx, rc)); break; case 0x26: tcg_gen_movcond_i64(TCG_COND_NE, vc, va, load_zero(ctx), vb, load_gpr(ctx, rc)); break; case 0x28: tcg_gen_orc_i64(vc, va, vb); break; case 0x40: tcg_gen_xor_i64(vc, va, vb); break; case 0x44: tcg_gen_movcond_i64(TCG_COND_LT, vc, va, load_zero(ctx), vb, load_gpr(ctx, rc)); break; case 0x46: tcg_gen_movcond_i64(TCG_COND_GE, vc, va, load_zero(ctx), vb, load_gpr(ctx, rc)); break; case 0x48: tcg_gen_eqv_i64(vc, va, vb); break; case 0x61: REQUIRE_REG_31(ra); { uint64_t amask = ctx->tb->flags >> TB_FLAGS_AMASK_SHIFT; tcg_gen_andi_i64(vc, vb, ~amask); } break; case 0x64: tcg_gen_movcond_i64(TCG_COND_LE, vc, va, load_zero(ctx), vb, load_gpr(ctx, rc)); break; case 0x66: tcg_gen_movcond_i64(TCG_COND_GT, vc, va, load_zero(ctx), vb, load_gpr(ctx, rc)); break; case 0x6C: REQUIRE_REG_31(ra); tcg_gen_movi_i64(vc, ctx->implver); break; default: goto invalid_opc; } break; case 0x12: vc = dest_gpr(ctx, rc); va = load_gpr(ctx, ra); switch (fn7) { case 0x02: gen_msk_l(ctx, vc, va, rb, islit, lit, 0x01); break; case 0x06: gen_ext_l(ctx, vc, va, rb, islit, lit, 0x01); break; case 0x0B: gen_ins_l(ctx, vc, va, rb, islit, lit, 0x01); break; case 0x12: gen_msk_l(ctx, vc, va, rb, islit, lit, 0x03); break; case 0x16: gen_ext_l(ctx, vc, va, rb, islit, lit, 0x03); break; case 0x1B: gen_ins_l(ctx, vc, va, rb, islit, lit, 0x03); break; case 0x22: gen_msk_l(ctx, vc, va, rb, islit, lit, 0x0f); break; case 0x26: gen_ext_l(ctx, vc, va, rb, islit, lit, 0x0f); break; case 0x2B: gen_ins_l(ctx, vc, va, rb, islit, lit, 0x0f); break; case 0x30: if (islit) { gen_zapnoti(vc, va, ~lit); } else { gen_helper_zap(vc, va, load_gpr(ctx, rb)); } break; case 0x31: if (islit) { gen_zapnoti(vc, va, lit); } else { gen_helper_zapnot(vc, va, load_gpr(ctx, rb)); } break; case 0x32: gen_msk_l(ctx, vc, va, rb, islit, lit, 0xff); break; case 0x34: if (islit) { tcg_gen_shri_i64(vc, va, lit & 0x3f); } else { tmp = tcg_temp_new(); vb = load_gpr(ctx, rb); tcg_gen_andi_i64(tmp, vb, 0x3f); tcg_gen_shr_i64(vc, va, tmp); tcg_temp_free(tmp); } break; case 0x36: gen_ext_l(ctx, vc, va, rb, islit, lit, 0xff); break; case 0x39: if (islit) { tcg_gen_shli_i64(vc, va, lit & 0x3f); } else { tmp = tcg_temp_new(); vb = load_gpr(ctx, rb); tcg_gen_andi_i64(tmp, vb, 0x3f); tcg_gen_shl_i64(vc, va, tmp); tcg_temp_free(tmp); } break; case 0x3B: gen_ins_l(ctx, vc, va, rb, islit, lit, 0xff); break; case 0x3C: if (islit) { tcg_gen_sari_i64(vc, va, lit & 0x3f); } else { tmp = tcg_temp_new(); vb = load_gpr(ctx, rb); tcg_gen_andi_i64(tmp, vb, 0x3f); tcg_gen_sar_i64(vc, va, tmp); tcg_temp_free(tmp); } break; case 0x52: gen_msk_h(ctx, vc, va, rb, islit, lit, 0x03); break; case 0x57: gen_ins_h(ctx, vc, va, rb, islit, lit, 0x03); break; case 0x5A: gen_ext_h(ctx, vc, va, rb, islit, lit, 0x03); break; case 0x62: gen_msk_h(ctx, vc, va, rb, islit, lit, 0x0f); break; case 0x67: gen_ins_h(ctx, vc, va, rb, islit, lit, 0x0f); break; case 0x6A: gen_ext_h(ctx, vc, va, rb, islit, lit, 0x0f); break; case 0x72: gen_msk_h(ctx, vc, va, rb, islit, lit, 0xff); break; case 0x77: gen_ins_h(ctx, vc, va, rb, islit, lit, 0xff); break; case 0x7A: gen_ext_h(ctx, vc, va, rb, islit, lit, 0xff); break; default: goto invalid_opc; } break; case 0x13: vc = dest_gpr(ctx, rc); vb = load_gpr_lit(ctx, rb, lit, islit); va = load_gpr(ctx, ra); switch (fn7) { case 0x00: tcg_gen_mul_i64(vc, va, vb); tcg_gen_ext32s_i64(vc, vc); break; case 0x20: tcg_gen_mul_i64(vc, va, vb); break; case 0x30: tmp = tcg_temp_new(); tcg_gen_mulu2_i64(tmp, vc, va, vb); tcg_temp_free(tmp); break; case 0x40: gen_helper_mullv(vc, cpu_env, va, vb); break; case 0x60: gen_helper_mulqv(vc, cpu_env, va, vb); break; default: goto invalid_opc; } break; case 0x14: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX); vc = dest_fpr(ctx, rc); switch (fpfn) { case 0x04: REQUIRE_REG_31(rb); t32 = tcg_temp_new_i32(); va = load_gpr(ctx, ra); tcg_gen_trunc_i64_i32(t32, va); gen_helper_memory_to_s(vc, t32); tcg_temp_free_i32(t32); break; case 0x0A: REQUIRE_REG_31(ra); vb = load_fpr(ctx, rb); gen_helper_sqrtf(vc, cpu_env, vb); break; case 0x0B: REQUIRE_REG_31(ra); gen_sqrts(ctx, rb, rc, fn11); break; case 0x14: REQUIRE_REG_31(rb); t32 = tcg_temp_new_i32(); va = load_gpr(ctx, ra); tcg_gen_trunc_i64_i32(t32, va); gen_helper_memory_to_f(vc, t32); tcg_temp_free_i32(t32); break; case 0x24: REQUIRE_REG_31(rb); va = load_gpr(ctx, ra); tcg_gen_mov_i64(vc, va); break; case 0x2A: REQUIRE_REG_31(ra); vb = load_fpr(ctx, rb); gen_helper_sqrtg(vc, cpu_env, vb); break; case 0x02B: REQUIRE_REG_31(ra); gen_sqrtt(ctx, rb, rc, fn11); break; default: goto invalid_opc; } break; case 0x15: vc = dest_fpr(ctx, rc); vb = load_fpr(ctx, rb); va = load_fpr(ctx, ra); switch (fpfn) { case 0x00: gen_helper_addf(vc, cpu_env, va, vb); break; case 0x01: gen_helper_subf(vc, cpu_env, va, vb); break; case 0x02: gen_helper_mulf(vc, cpu_env, va, vb); break; case 0x03: gen_helper_divf(vc, cpu_env, va, vb); break; case 0x1E: REQUIRE_REG_31(ra); goto invalid_opc; case 0x20: gen_helper_addg(vc, cpu_env, va, vb); break; case 0x21: gen_helper_subg(vc, cpu_env, va, vb); break; case 0x22: gen_helper_mulg(vc, cpu_env, va, vb); break; case 0x23: gen_helper_divg(vc, cpu_env, va, vb); break; case 0x25: gen_helper_cmpgeq(vc, cpu_env, va, vb); break; case 0x26: gen_helper_cmpglt(vc, cpu_env, va, vb); break; case 0x27: gen_helper_cmpgle(vc, cpu_env, va, vb); break; case 0x2C: REQUIRE_REG_31(ra); gen_helper_cvtgf(vc, cpu_env, vb); break; case 0x2D: REQUIRE_REG_31(ra); goto invalid_opc; case 0x2F: REQUIRE_REG_31(ra); gen_helper_cvtgq(vc, cpu_env, vb); break; case 0x3C: REQUIRE_REG_31(ra); gen_helper_cvtqf(vc, cpu_env, vb); break; case 0x3E: REQUIRE_REG_31(ra); gen_helper_cvtqg(vc, cpu_env, vb); break; default: goto invalid_opc; } break; case 0x16: switch (fpfn) { case 0x00: gen_adds(ctx, ra, rb, rc, fn11); break; case 0x01: gen_subs(ctx, ra, rb, rc, fn11); break; case 0x02: gen_muls(ctx, ra, rb, rc, fn11); break; case 0x03: gen_divs(ctx, ra, rb, rc, fn11); break; case 0x20: gen_addt(ctx, ra, rb, rc, fn11); break; case 0x21: gen_subt(ctx, ra, rb, rc, fn11); break; case 0x22: gen_mult(ctx, ra, rb, rc, fn11); break; case 0x23: gen_divt(ctx, ra, rb, rc, fn11); break; case 0x24: gen_cmptun(ctx, ra, rb, rc, fn11); break; case 0x25: gen_cmpteq(ctx, ra, rb, rc, fn11); break; case 0x26: gen_cmptlt(ctx, ra, rb, rc, fn11); break; case 0x27: gen_cmptle(ctx, ra, rb, rc, fn11); break; case 0x2C: REQUIRE_REG_31(ra); if (fn11 == 0x2AC || fn11 == 0x6AC) { gen_cvtst(ctx, rb, rc, fn11); } else { gen_cvtts(ctx, rb, rc, fn11); } break; case 0x2F: REQUIRE_REG_31(ra); gen_cvttq(ctx, rb, rc, fn11); break; case 0x3C: REQUIRE_REG_31(ra); gen_cvtqs(ctx, rb, rc, fn11); break; case 0x3E: REQUIRE_REG_31(ra); gen_cvtqt(ctx, rb, rc, fn11); break; default: goto invalid_opc; } break; case 0x17: switch (fn11) { case 0x010: REQUIRE_REG_31(ra); vc = dest_fpr(ctx, rc); vb = load_fpr(ctx, rb); gen_cvtlq(vc, vb); break; case 0x020: if (rc == 31) { } else { vc = dest_fpr(ctx, rc); va = load_fpr(ctx, ra); if (ra == rb) { tcg_gen_mov_i64(vc, va); } else { vb = load_fpr(ctx, rb); gen_cpy_mask(vc, va, vb, 0, 0x8000000000000000ULL); } } break; case 0x021: vc = dest_fpr(ctx, rc); vb = load_fpr(ctx, rb); va = load_fpr(ctx, ra); gen_cpy_mask(vc, va, vb, 1, 0x8000000000000000ULL); break; case 0x022: vc = dest_fpr(ctx, rc); vb = load_fpr(ctx, rb); va = load_fpr(ctx, ra); gen_cpy_mask(vc, va, vb, 0, 0xFFF0000000000000ULL); break; case 0x024: va = load_fpr(ctx, ra); gen_helper_store_fpcr(cpu_env, va); if (ctx->tb_rm == QUAL_RM_D) { ctx->tb_rm = -1; } break; case 0x025: va = dest_fpr(ctx, ra); gen_helper_load_fpcr(va, cpu_env); break; case 0x02A: gen_fcmov(ctx, TCG_COND_EQ, ra, rb, rc); break; case 0x02B: gen_fcmov(ctx, TCG_COND_NE, ra, rb, rc); break; case 0x02C: gen_fcmov(ctx, TCG_COND_LT, ra, rb, rc); break; case 0x02D: gen_fcmov(ctx, TCG_COND_GE, ra, rb, rc); break; case 0x02E: gen_fcmov(ctx, TCG_COND_LE, ra, rb, rc); break; case 0x02F: gen_fcmov(ctx, TCG_COND_GT, ra, rb, rc); break; case 0x030: REQUIRE_REG_31(ra); vc = dest_fpr(ctx, rc); vb = load_fpr(ctx, rb); gen_cvtql(vc, vb); break; case 0x130: case 0x530: REQUIRE_REG_31(ra); vc = dest_fpr(ctx, rc); vb = load_fpr(ctx, rb); gen_helper_cvtql_v_input(cpu_env, vb); gen_cvtql(vc, vb); break; default: goto invalid_opc; } break; case 0x18: switch ((uint16_t)disp16) { case 0x0000: break; case 0x0400: break; case 0x4000: break; case 0x4400: break; case 0x8000: break; case 0xA000: break; case 0xC000: va = dest_gpr(ctx, ra); if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); gen_helper_load_pcc(va, cpu_env); gen_io_end(); ret = EXIT_PC_STALE; } else { gen_helper_load_pcc(va, cpu_env); } break; case 0xE000: gen_rx(ra, 0); break; case 0xE800: break; case 0xF000: gen_rx(ra, 1); break; case 0xF800: break; default: goto invalid_opc; } break; case 0x19: #ifndef CONFIG_USER_ONLY REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE); va = dest_gpr(ctx, ra); ret = gen_mfpr(ctx, va, insn & 0xffff); break; #else goto invalid_opc; #endif case 0x1A: vb = load_gpr(ctx, rb); tcg_gen_andi_i64(cpu_pc, vb, ~3); if (ra != 31) { tcg_gen_movi_i64(cpu_ir[ra], ctx->pc); } ret = EXIT_PC_UPDATED; break; case 0x1B: #ifndef CONFIG_USER_ONLY REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE); { TCGv addr = tcg_temp_new(); vb = load_gpr(ctx, rb); va = dest_gpr(ctx, ra); tcg_gen_addi_i64(addr, vb, disp12); switch ((insn >> 12) & 0xF) { case 0x0: gen_helper_ldl_phys(va, cpu_env, addr); break; case 0x1: gen_helper_ldq_phys(va, cpu_env, addr); break; case 0x2: gen_helper_ldl_l_phys(va, cpu_env, addr); break; case 0x3: gen_helper_ldq_l_phys(va, cpu_env, addr); break; case 0x4: goto invalid_opc; case 0x5: goto invalid_opc; break; case 0x6: goto invalid_opc; case 0x7: goto invalid_opc; case 0x8: goto invalid_opc; case 0x9: goto invalid_opc; case 0xA: tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LESL); break; case 0xB: tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LEQ); break; case 0xC: goto invalid_opc; case 0xD: goto invalid_opc; case 0xE: tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LESL); break; case 0xF: tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LEQ); break; } tcg_temp_free(addr); break; } #else goto invalid_opc; #endif case 0x1C: vc = dest_gpr(ctx, rc); if (fn7 == 0x70) { REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX); REQUIRE_REG_31(rb); va = load_fpr(ctx, ra); tcg_gen_mov_i64(vc, va); break; } else if (fn7 == 0x78) { REQUIRE_TB_FLAG(TB_FLAGS_AMASK_FIX); REQUIRE_REG_31(rb); t32 = tcg_temp_new_i32(); va = load_fpr(ctx, ra); gen_helper_s_to_memory(t32, va); tcg_gen_ext_i32_i64(vc, t32); tcg_temp_free_i32(t32); break; } vb = load_gpr_lit(ctx, rb, lit, islit); switch (fn7) { case 0x00: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX); REQUIRE_REG_31(ra); tcg_gen_ext8s_i64(vc, vb); break; case 0x01: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_BWX); REQUIRE_REG_31(ra); tcg_gen_ext16s_i64(vc, vb); break; case 0x30: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX); REQUIRE_REG_31(ra); gen_helper_ctpop(vc, vb); break; case 0x31: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); va = load_gpr(ctx, ra); gen_helper_perr(vc, va, vb); break; case 0x32: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX); REQUIRE_REG_31(ra); gen_helper_ctlz(vc, vb); break; case 0x33: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_CIX); REQUIRE_REG_31(ra); gen_helper_cttz(vc, vb); break; case 0x34: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); REQUIRE_REG_31(ra); gen_helper_unpkbw(vc, vb); break; case 0x35: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); REQUIRE_REG_31(ra); gen_helper_unpkbl(vc, vb); break; case 0x36: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); REQUIRE_REG_31(ra); gen_helper_pkwb(vc, vb); break; case 0x37: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); REQUIRE_REG_31(ra); gen_helper_pklb(vc, vb); break; case 0x38: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); va = load_gpr(ctx, ra); gen_helper_minsb8(vc, va, vb); break; case 0x39: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); va = load_gpr(ctx, ra); gen_helper_minsw4(vc, va, vb); break; case 0x3A: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); va = load_gpr(ctx, ra); gen_helper_minub8(vc, va, vb); break; case 0x3B: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); va = load_gpr(ctx, ra); gen_helper_minuw4(vc, va, vb); break; case 0x3C: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); va = load_gpr(ctx, ra); gen_helper_maxub8(vc, va, vb); break; case 0x3D: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); va = load_gpr(ctx, ra); gen_helper_maxuw4(vc, va, vb); break; case 0x3E: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); va = load_gpr(ctx, ra); gen_helper_maxsb8(vc, va, vb); break; case 0x3F: REQUIRE_TB_FLAG(TB_FLAGS_AMASK_MVI); va = load_gpr(ctx, ra); gen_helper_maxsw4(vc, va, vb); break; default: goto invalid_opc; } break; case 0x1D: #ifndef CONFIG_USER_ONLY REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE); vb = load_gpr(ctx, rb); ret = gen_mtpr(ctx, vb, insn & 0xffff); break; #else goto invalid_opc; #endif case 0x1E: #ifndef CONFIG_USER_ONLY REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE); if (rb == 31) { tmp = tcg_temp_new(); tcg_gen_ld_i64(tmp, cpu_env, offsetof(CPUAlphaState, exc_addr)); gen_helper_hw_ret(cpu_env, tmp); tcg_temp_free(tmp); } else { gen_helper_hw_ret(cpu_env, load_gpr(ctx, rb)); } ret = EXIT_PC_UPDATED; break; #else goto invalid_opc; #endif case 0x1F: #ifndef CONFIG_USER_ONLY REQUIRE_TB_FLAG(TB_FLAGS_PAL_MODE); { TCGv addr = tcg_temp_new(); va = load_gpr(ctx, ra); vb = load_gpr(ctx, rb); tcg_gen_addi_i64(addr, vb, disp12); switch ((insn >> 12) & 0xF) { case 0x0: gen_helper_stl_phys(cpu_env, addr, va); break; case 0x1: gen_helper_stq_phys(cpu_env, addr, va); break; case 0x2: gen_helper_stl_c_phys(dest_gpr(ctx, ra), cpu_env, addr, va); break; case 0x3: gen_helper_stq_c_phys(dest_gpr(ctx, ra), cpu_env, addr, va); break; case 0x4: goto invalid_opc; case 0x5: goto invalid_opc; case 0x6: goto invalid_opc; case 0x7: goto invalid_opc; case 0x8: goto invalid_opc; case 0x9: goto invalid_opc; case 0xA: goto invalid_opc; case 0xB: goto invalid_opc; case 0xC: goto invalid_opc; case 0xD: goto invalid_opc; case 0xE: goto invalid_opc; case 0xF: goto invalid_opc; } tcg_temp_free(addr); break; } #else goto invalid_opc; #endif case 0x20: gen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0); break; case 0x21: gen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0); break; case 0x22: gen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0); break; case 0x23: gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0); break; case 0x24: gen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0); break; case 0x25: gen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0); break; case 0x26: gen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0); break; case 0x27: gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0); break; case 0x28: gen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0); break; case 0x29: gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0); break; case 0x2A: gen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0); break; case 0x2B: gen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0); break; case 0x2C: gen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0); break; case 0x2D: gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0); break; case 0x2E: ret = gen_store_conditional(ctx, ra, rb, disp16, 0); break; case 0x2F: ret = gen_store_conditional(ctx, ra, rb, disp16, 1); break; case 0x30: ret = gen_bdirect(ctx, ra, disp21); break; case 0x31: ret = gen_fbcond(ctx, TCG_COND_EQ, ra, disp21); break; case 0x32: ret = gen_fbcond(ctx, TCG_COND_LT, ra, disp21); break; case 0x33: ret = gen_fbcond(ctx, TCG_COND_LE, ra, disp21); break; case 0x34: ret = gen_bdirect(ctx, ra, disp21); break; case 0x35: ret = gen_fbcond(ctx, TCG_COND_NE, ra, disp21); break; case 0x36: ret = gen_fbcond(ctx, TCG_COND_GE, ra, disp21); break; case 0x37: ret = gen_fbcond(ctx, TCG_COND_GT, ra, disp21); break; case 0x38: ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1); break; case 0x39: ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0); break; case 0x3A: ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0); break; case 0x3B: ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0); break; case 0x3C: ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1); break; case 0x3D: ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0); break; case 0x3E: ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0); break; case 0x3F: ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0); break; invalid_opc: ret = gen_invalid(ctx); break; } return ret; }
1threat
Spring WebFlux WebClient resilience and performance : <p>I just test by sample PoC project some blocking / non blocking solutions in simple common scenario.</p> <h2>Scenario:</h2> <ul> <li>There are rest blocking endpoint which is quite slow - each request tooks 200 ms.</li> <li>There are other - client application, which call this slow endpoint.</li> </ul> <p>I have tested current (blocking) Spring boot client (tomcat), Spring Boot 2.0 (netty) with WebFlux - WebClient, Ratpack and Lagom. In each cases I have stressed client application by gatling test simple scenario (100-1000 users / second). </p> <p>I have tested ratpack and lagom as reference non blocking io servers to compare results to spring boot (blocking and non blocking).</p> <p>In all cases i have results as expected, except spring boot 2.0 test. Its working only for small load levels but even then with high latency. If load level rises up - all requests are time outed.</p> <p>WebClient usage :</p> <pre><code>@RestController public class NonBlockingClientController { private WebClient client = WebClient.create("http://localhost:9000"); @GetMapping("/client") public Mono&lt;String&gt; getData() { return client.get() .uri("/routing") .accept(TEXT_PLAIN) .exchange() .then(response -&gt; response.bodyToMono(String.class)); } } </code></pre> <p>I have no idea what goes wrong or current snapshot version just working that.</p> <p>All sources published at <a href="https://github.com/rutkowskij/blocking-non-blocking-poc" rel="noreferrer">https://github.com/rutkowskij/blocking-non-blocking-poc</a></p> <ul> <li>blocking-service - slow blocking endpoint </li> <li>non-blocking-client - Spring Boot 2.0 and WebClient based client</li> </ul> <p>I just created a simple Spring Boot application using spring-boot-starter-webflux with version 2.0.0.BUILD-SNAPSHOT which brings spring-webflux version 5.0.0.BUILD-SNAPSHOT and same for Spring Core, Beans, Context, etc.</p>
0debug
static void default_drive(int enable, int snapshot, BlockInterfaceType type, int index, const char *optstr) { QemuOpts *opts; if (!enable || drive_get_by_index(type, index)) { return; } opts = drive_add(type, index, NULL, optstr); if (snapshot) { drive_enable_snapshot(opts, NULL); } if (!drive_new(opts, type)) { exit(1); } }
1threat
getting null value in function variable that assign in ajax success function in javascript : <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> function getData(url) { var responseData = null; $.ajax({ type: "GET", url: url, crossDomain: true, async: false, contentType: "application/json; charset=utf-8", dataType: "jsonp", success: function (result) { responseData = result; } }); console.log(responseData); return responseData; } var getapidata= getData('https://jsonplaceholder.typicode.com/todos/1'); console.log('getapidata',getapidata);</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre> </div> </div> </p>
0debug
static int local_unlinkat(FsContext *ctx, V9fsPath *dir, const char *name, int flags) { int ret; V9fsString fullname; char buffer[PATH_MAX]; v9fs_string_init(&fullname); v9fs_string_sprintf(&fullname, "%s/%s", dir->data, name); if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { if (flags == AT_REMOVEDIR) { snprintf(buffer, ARRAY_SIZE(buffer), "%s/%s/%s", ctx->fs_root, fullname.data, VIRTFS_META_DIR); ret = remove(buffer); if (ret < 0 && errno != ENOENT) { goto err_out; } } ret = remove(local_mapped_attr_path(ctx, fullname.data, buffer)); if (ret < 0 && errno != ENOENT) { goto err_out; } } ret = remove(rpath(ctx, fullname.data, buffer)); err_out: v9fs_string_free(&fullname); return ret; }
1threat
Darken or lighten a color in matplotlib : <p>Say I have a color in Matplotlib. Maybe it's a string (<code>'k'</code>) or an rgb tuple (<code>(0.5, 0.1, 0.8)</code>) or even some hex (<code>#05FA2B</code>). Is there a command / convenience function in Matplotlib that would allow me to darken (or lighten) that color. </p> <p>I.e. is there <code>matplotlib.pyplot.darken(c, 0.1)</code> or something like that? I guess what I'm hoping for is something that, behind the scenes, would take a color, convert it to HSL, then either multiply the L value by some given factor (flooring at 0 and capping at 1) or explicitly set the L value to a given value and return the modified color.</p>
0debug
bool vfio_blacklist_opt_rom(VFIOPCIDevice *vdev) { PCIDevice *pdev = &vdev->pdev; uint16_t vendor_id, device_id; int count = 0; vendor_id = pci_get_word(pdev->config + PCI_VENDOR_ID); device_id = pci_get_word(pdev->config + PCI_DEVICE_ID); while (count < ARRAY_SIZE(romblacklist)) { if (romblacklist[count].vendor_id == vendor_id && romblacklist[count].device_id == device_id) { return true; } count++; } return false; }
1threat
PHP: using $_GET to retrieve value from javascript : <p>I'm making travel package website and I want to retrieve data using either GET, POST , REQUEST in php. but I get an error message saying "Array ( ) no Notice: Undefined index:"</p> <hr> <p>Javascript function: </p> <p>calculate total by simply multiplying the values from "package" and "# of person" </p> <hr> <p>below is my code</p> <pre><code>&lt;script type="text/javascript"&gt; function totalPrice(){ document.getElementById("total").value= "CAD "+ (document.getElementById("package").value * document.getElementById("person").value);} &lt;/script&gt; &lt;!-- package selection --&gt; &lt;form action="test.php" method="get"&gt; &lt;select id="package" onchange="totalPrice();" &gt; &lt;option value="2300"&gt;Wild West (Banff, Jasper)&lt;/option&gt; &lt;option value="3300"&gt;East Coast(St.Johns)&lt;/option&gt; &lt;option value="1300"&gt;Winery Tour(Kelowna, Penticton)&lt;/option&gt; &lt;option value="2600"&gt;Northern Light(Yellowknife)&lt;/option&gt; &lt;/select&gt; &lt;select id="person" onchange="totalPrice();"&gt; &lt;option value="1"&gt;1 person&lt;/option&gt; &lt;option value="2"&gt;2 persons&lt;/option&gt; &lt;option value="3"&gt;3 persons&lt;/option&gt; &lt;option value="4"&gt;4 persons&lt;/option&gt; &lt;option value="5"&gt;5 persons&lt;/option&gt; &lt;option value="6"&gt;6 persons&lt;/option&gt; &lt;option value="7"&gt;7 persons&lt;/option&gt; &lt;option value="8"&gt;8 persons&lt;/option&gt; &lt;/select&gt; &lt;input type="submit"&gt; &lt;/form&gt; &lt;!-- total Amount --&gt; &lt;label class="form" &gt;Total Amount&lt;/label&gt; &lt;input size =40 type="text" name="total" id="total" disabled&gt; </code></pre> <p>"test.php"</p> <pre><code>&lt;h1&gt;payment total&lt;/h1&gt; &lt;?php print_r($_GET); if(!isset($_GET['total'])){ echo "no"; } echo $_GET['total']; ?&gt; </code></pre>
0debug
static void qemu_thread_set_name(QemuThread *thread, const char *name) { #ifdef CONFIG_PTHREAD_SETNAME_NP pthread_setname_np(thread->thread, name); #endif }
1threat
int qemu_put_qemu_file(QEMUFile *f_des, QEMUFile *f_src) { int len = 0; if (f_src->buf_index > 0) { len = f_src->buf_index; qemu_put_buffer(f_des, f_src->buf, f_src->buf_index); f_src->buf_index = 0; } return len; }
1threat
React Native: What is the default font that react native uses? : <p>I'm trying to make a graphic using the same font as the one being used by default in React Native but I don't know what the font is. </p> <p>Anyone know?</p>
0debug
ms access find duplicate query and add alais colum : i have a access db name testdb , table name table1, now table having 2 fields BinNo and Prodcode, Binno having many duplicate rows , i want to group binno whereever have dulpicate row to create new alias column ============================================= Binno | Prodcode | ============================================ Bin no1| Pro 1 Bin no1| Pro 2 Bin no1| Pro 3 Bin no2| Pro 4 Bin no2| Pro 5 ================================================ should create query ============================================= Binno | Prodcode1 | Prodcode2| Prodcode3| ============================================== Bin no1| Pro 1 | Pro 2 | Pro 3 Bin no2| Pro 4 | Pro 5 ================================================
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
How do I transform this data set using SQL? : <p>How do I write SQL that will transform data set 1 into data set 2?</p> <blockquote> <p>Data Set 1</p> </blockquote> <pre><code>id Name Home_Phone Work_Phone Mobile_Phone --- ----------------------- ------------ ------------ ------------ 44 Mary James NULL NULL 333-832-1066 44 Mary James 111-747-7048 NULL NULL 46 James Smith NULL NULL 111-354-2092 46 James Smith 111-737-8936 NULL NULL 45 Shelley Berlin NULL NULL 222-960-5115 45 Shelley Berlin NULL 222-845-2422 NULL 39 Brad Saito NULL NULL NULL 39 Brad Saito Invalid Invalid Invalid 55 Debbie Peters NULL NULL NULL 55 Debbie Peters NULL NULL NULL 55 Debbie Peters NULL 222-960-7778 NULL </code></pre> <blockquote> <p>Data Set 2</p> </blockquote> <pre><code>id Name Home_Phone Work_Phone Mobile_Phone --- ----------------------- ------------ ------------ ------------ 44 Mary James 111-747-7048 NULL 333-832-1066 46 James Smith 111-737-8936 NULL 111-354-2092 45 Shelley Berlin NULL 222-845-2422 222-960-5115 39 Brad Saito Invalid Invalid Invalid 55 Debbie Peters NULL 222-960-7778 NULL </code></pre>
0debug
getting rid of blank space between table rows : <p>I am trying to get rid of the red background between the images here. How can I do this using css? </p> <pre><code> &lt;table style="background-color:red; padding:0;margin:0;"&gt; &lt;tr&gt; &lt;td&gt; &lt;img src="/graphics/susSlogan.gif"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;img src="/graphics/susSlogan.gif"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p><a href="https://i.stack.imgur.com/FVKjY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FVKjY.png" alt="enter image description here"></a></p>
0debug
Why can't I save file in external storage or memory card in android : I would like to create a backup file in my memory card but all it does is return a file not found exception. I am specifying the path where the data should be saved. When i choose the Internal storage the file was saved but when i changed it to external storage, it returns me the file not found. Here are the Screenshots: [enter image description here][1] final Preference prefStoragePath = findPreference("key_storage_path"); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getActivity()); String pref_storage_path = settings.getString("set_storage_path",null); startingDir = (pref_storage_path!=null)? pref_storage_path : Environment.getExternalStorageDirectory().toString(); Preference prefBackupManual = findPreference("key_backup_manual"); final String root = Environment.getExternalStorageDirectory().toString(); prefBackupManual.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { createBackupData(startingDir); return false; } }); private void createBackupData(String dir){ String filename = "BackupData.txt"; String data = resultSet().toString(); try{ byte[] sha1hash; File myFile = new File(dir,filename); sha1hash = data.getBytes("UTF-8"); String base64 = Base64.encodeToString(sha1hash, Base64.DEFAULT); FileOutputStream fos = new FileOutputStream(myFile); fos.write(base64.getBytes()); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); Toast.makeText(getActivity(), "no file", Toast.LENGTH_SHORT).show(); } catch (IOException e) { e.printStackTrace(); Toast.makeText(getActivity(), "file not saved", Toast.LENGTH_SHORT).show(); }finally { Toast.makeText(getActivity(),"File saved in " + dir + "/" + filename ,Toast.LENGTH_SHORT).show(); } } [1]: https://i.stack.imgur.com/BG5xs.png
0debug
document.write('<script src="evil.js"></script>');
1threat
def highest_Power_of_2(n): res = 0; for i in range(n, 0, -1): if ((i & (i - 1)) == 0): res = i; break; return res;
0debug
Web specifications and standards : <p>can anyone give me few examples of web specifications standards as i don't understand what are they.</p> <p>I have looked at <a href="https://www.w3.org/" rel="nofollow">https://www.w3.org/</a> , but i still don't pick anything that would make sense to me.</p> <p>Thanks for your help.</p>
0debug
Can React Native apps be tested in a browser? : <p>Realizing that React Native apps are designed to be developed / tested using simulators, is it possible to use a web browser to also test an application?</p> <p>Services such as <a href="https://rnplay.org/" rel="noreferrer">https://rnplay.org/</a> exist, however my concern is it's powered by <a href="https://appetize.io/" rel="noreferrer">https://appetize.io/</a> it might be limited by the # of minutes per month. I'd also like to utilize free / open-source technology to accomplish this, as compared to a paid screen streaming service.</p> <p>Along these lines, in order to test the app in a browser, would the app be required to use one or more libraries which allow the app to be run in both React Native and also simply React? I'd like to find an alternative to this particular approach as I'd like to code for React Native specifically.</p>
0debug
static void complete_collecting_data(Flash *s) { int i; s->cur_addr = 0; for (i = 0; i < get_addr_length(s); ++i) { s->cur_addr <<= 8; s->cur_addr |= s->data[i]; } if (get_addr_length(s) == 3) { s->cur_addr += s->ear * MAX_3BYTES_SIZE; } s->state = STATE_IDLE; switch (s->cmd_in_progress) { case DPP: case QPP: case PP: case PP4: case PP4_4: s->state = STATE_PAGE_PROGRAM; break; case READ: case READ4: case FAST_READ: case FAST_READ4: case DOR: case DOR4: case QOR: case QOR4: case DIOR: case DIOR4: case QIOR: case QIOR4: s->state = STATE_READ; break; case ERASE_4K: case ERASE4_4K: case ERASE_32K: case ERASE4_32K: case ERASE_SECTOR: case ERASE4_SECTOR: flash_erase(s, s->cur_addr, s->cmd_in_progress); break; case WRSR: switch (get_man(s)) { case MAN_SPANSION: s->quad_enable = !!(s->data[1] & 0x02); break; case MAN_MACRONIX: s->quad_enable = extract32(s->data[0], 6, 1); if (s->len > 1) { s->four_bytes_address_mode = extract32(s->data[1], 5, 1); } break; default: break; } if (s->write_enable) { s->write_enable = false; } break; case EXTEND_ADDR_WRITE: s->ear = s->data[0]; break; case WNVCR: s->nonvolatile_cfg = s->data[0] | (s->data[1] << 8); break; case WVCR: s->volatile_cfg = s->data[0]; break; case WEVCR: s->enh_volatile_cfg = s->data[0]; break; default: break; } }
1threat
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
const char *avformat_configuration(void) { return FFMPEG_CONFIGURATION; }
1threat
"You don't have write permissions for the /usr/bin directory." when installing Sass using the Gem command : <p>I'm on Mac and I'm trying to install Sass using the command in terminal, "sudo gem install sass". I then enter my password, and everything works fine until this pops up,</p> <p>"ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /usr/bin directory."</p> <p>I do use sudo, but it still doesn't work, and it's one of those things that you can't give yourself read &amp; write permissions to. Any ideas?</p> <p>Thanks,</p> <p>Wade</p>
0debug
static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { FlicDecodeContext *s = (FlicDecodeContext *)avctx->priv_data; int stream_ptr = 0; int pixel_ptr; unsigned char palette_idx1; unsigned int frame_size; int num_chunks; unsigned int chunk_size; int chunk_type; int i, j; int lines; int compressed_lines; signed short line_packets; int y_ptr; int byte_run; int pixel_skip; int pixel_countdown; unsigned char *pixels; int pixel; int pixel_limit; s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if (avctx->reget_buffer(avctx, &s->frame) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } pixels = s->frame.data[0]; pixel_limit = s->avctx->height * s->frame.linesize[0]; frame_size = LE_32(&buf[stream_ptr]); stream_ptr += 6; num_chunks = LE_16(&buf[stream_ptr]); stream_ptr += 10; frame_size -= 16; while ((frame_size > 0) && (num_chunks > 0)) { chunk_size = LE_32(&buf[stream_ptr]); stream_ptr += 4; chunk_type = LE_16(&buf[stream_ptr]); stream_ptr += 2; switch (chunk_type) { case FLI_256_COLOR: case FLI_COLOR: stream_ptr = stream_ptr + chunk_size - 6; break; case FLI_DELTA: case FLI_DTA_LC: y_ptr = 0; compressed_lines = LE_16(&buf[stream_ptr]); stream_ptr += 2; while (compressed_lines > 0) { line_packets = LE_16(&buf[stream_ptr]); stream_ptr += 2; if (line_packets < 0) { line_packets = -line_packets; y_ptr += line_packets * s->frame.linesize[0]; } else { compressed_lines--; pixel_ptr = y_ptr; pixel_countdown = s->avctx->width; for (i = 0; i < line_packets; i++) { pixel_skip = buf[stream_ptr++]; pixel_ptr += (pixel_skip*2); pixel_countdown -= pixel_skip; byte_run = (signed char)(buf[stream_ptr++]); if (byte_run < 0) { byte_run = -byte_run; pixel = LE_16(&buf[stream_ptr]); stream_ptr += 2; CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++, pixel_countdown -= 2) { *((signed short*)(&pixels[pixel_ptr])) = pixel; pixel_ptr += 2; } } else { CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++, pixel_countdown--) { *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[stream_ptr]); stream_ptr += 2; pixel_ptr += 2; } } } y_ptr += s->frame.linesize[0]; } } break; case FLI_LC: av_log(avctx, AV_LOG_ERROR, "Unexpected FLI_LC chunk in non-paletised FLC\n"); stream_ptr = stream_ptr + chunk_size - 6; break; case FLI_BLACK: memset(pixels, 0x0000, s->frame.linesize[0] * s->avctx->height * 2); break; case FLI_BRUN: y_ptr = 0; for (lines = 0; lines < s->avctx->height; lines++) { pixel_ptr = y_ptr; stream_ptr++; pixel_countdown = (s->avctx->width * 2); while (pixel_countdown > 0) { byte_run = (signed char)(buf[stream_ptr++]); if (byte_run > 0) { palette_idx1 = buf[stream_ptr++]; CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++) { pixels[pixel_ptr++] = palette_idx1; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", pixel_countdown); } } else { byte_run = -byte_run; CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++) { palette_idx1 = buf[stream_ptr++]; pixels[pixel_ptr++] = palette_idx1; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", pixel_countdown); } } } pixel = 0xFF00; if (0xFF00 != LE_16(&pixel)) { pixel_ptr = y_ptr; pixel_countdown = s->avctx->width; while (pixel_countdown > 0) { *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[pixel_ptr]); pixel_ptr += 2; } } y_ptr += s->frame.linesize[0]; } break; case FLI_DTA_BRUN: y_ptr = 0; for (lines = 0; lines < s->avctx->height; lines++) { pixel_ptr = y_ptr; stream_ptr++; pixel_countdown = s->avctx->width; while (pixel_countdown > 0) { byte_run = (signed char)(buf[stream_ptr++]); if (byte_run > 0) { pixel = LE_16(&buf[stream_ptr]); stream_ptr += 2; CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++) { *((signed short*)(&pixels[pixel_ptr])) = pixel; pixel_ptr += 2; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", pixel_countdown); } } else { byte_run = -byte_run; CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++) { *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[stream_ptr]); stream_ptr += 2; pixel_ptr += 2; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", pixel_countdown); } } } y_ptr += s->frame.linesize[0]; } break; case FLI_COPY: case FLI_DTA_COPY: if (chunk_size - 6 > (unsigned int)(s->avctx->width * s->avctx->height)*2) { av_log(avctx, AV_LOG_ERROR, "In chunk FLI_COPY : source data (%d bytes) " \ "bigger than image, skipping chunk\n", chunk_size - 6); stream_ptr += chunk_size - 6; } else { for (y_ptr = 0; y_ptr < s->frame.linesize[0] * s->avctx->height; y_ptr += s->frame.linesize[0]) { pixel_countdown = s->avctx->width; pixel_ptr = 0; while (pixel_countdown > 0) { *((signed short*)(&pixels[y_ptr + pixel_ptr])) = LE_16(&buf[stream_ptr+pixel_ptr]); pixel_ptr += 2; pixel_countdown--; } stream_ptr += s->avctx->width*2; } } break; case FLI_MINI: stream_ptr += chunk_size - 6; break; default: av_log(avctx, AV_LOG_ERROR, "Unrecognized chunk type: %d\n", chunk_type); break; } frame_size -= chunk_size; num_chunks--; } if ((stream_ptr != buf_size) && (stream_ptr != buf_size - 1)) av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \ "and final chunk ptr = %d\n", buf_size, stream_ptr); *data_size=sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size; }
1threat
Add two lists onto another list which : <p>So I have two lists right now.</p> <pre><code>list1 = ['A', 'B', 'C', 'D'] list2 = [1, 2, 3, 4] </code></pre> <p>How can I merge the lists together to make it look something like this:</p> <pre><code>list3 = [['A', 1], ['B', 2], ['C', 3], ['D', 4]] </code></pre> <p>Basically I want to make a list inside a list.</p> <p>I've been trying for loops but nothing seems to be working for me.</p>
0debug
void ff_avg_h264_qpel16_mc11_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hv_qrt_and_aver_dst_16x16_msa(src - 2, src - (stride * 2), stride, dst, stride); }
1threat
int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, int track_index, int sample) { MOVMuxContext *mov = s->priv_data; MOVTrack *trk = &mov->tracks[track_index]; AVFormatContext *rtp_ctx = trk->rtp_ctx; uint8_t *buf = NULL; int size; AVIOContext *hintbuf = NULL; AVPacket hint_pkt; int ret = 0, count; if (!rtp_ctx) return AVERROR(ENOENT); if (!rtp_ctx->pb) return AVERROR(ENOMEM); sample_queue_push(&trk->sample_queue, pkt, sample); ff_write_chained(rtp_ctx, 0, pkt, s); size = avio_close_dyn_buf(rtp_ctx->pb, &buf); if ((ret = url_open_dyn_packet_buf(&rtp_ctx->pb, RTP_MAX_PACKET_SIZE)) < 0) goto done; if (size <= 0) goto done; if ((ret = avio_open_dyn_buf(&hintbuf)) < 0) goto done; av_init_packet(&hint_pkt); count = write_hint_packets(hintbuf, buf, size, trk, &hint_pkt.dts); av_freep(&buf); hint_pkt.size = size = avio_close_dyn_buf(hintbuf, &buf); hint_pkt.data = buf; hint_pkt.pts = hint_pkt.dts; hint_pkt.stream_index = track_index; if (pkt->flags & AV_PKT_FLAG_KEY) hint_pkt.flags |= AV_PKT_FLAG_KEY; if (count > 0) ff_mov_write_packet(s, &hint_pkt); done: av_free(buf); sample_queue_retain(&trk->sample_queue); return ret; }
1threat
Regex validate URL if it does not contain a subdomain : Basically, I would like to check a valid URL that does not have subdomain on it. I can't seem to figure out the correct regex for it. Example of URLs that SHOULD match: * example.com * www.example.com * example.co.uk * example.com/page * example.com?key=value Example of URLs that SHOULD NOT match: * test.example.com * sub.test.example.com
0debug
How to design a image through css : <p><a href="https://i.stack.imgur.com/EmBzm.png." rel="nofollow noreferrer">How to design This Image</a></p> <p>I want to design this type image.</p>
0debug
Client/Server Chat,javafx-working but console shows error : first i just want to say thank you all for your help. i build a client/chat server with multiple users,it works but the console always shows the same error message despite the fact that the program works. could you run it and help me figure out what may be the problem? server code: public class Server extends Application{ private final static int PORT=8000; private TextArea ta=new TextArea(); private Socket socket; private ServerSocket serverSocket; private LinkedList<HandleClientTraffic> serverToOtherClients=new LinkedList<>(); private Vector<Integer> v=null; public void start(Stage primaryStage){ ta.setEditable(false); Scene scene=new Scene(new ScrollPane(ta),450,200); primaryStage.setTitle("Server"); primaryStage.setScene(scene); primaryStage.show(); primaryStage.setAlwaysOnTop(true); primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { Platform.exit(); System.exit(0); } }); new Thread(()->{ try { serverSocket=new ServerSocket(PORT); Platform.runLater( () -> { ta.appendText("MultiThreadServer started at " + new Date() + '\n'); }); while(true){ socket=serverSocket.accept(); Platform.runLater(()->{ InetAddress inetAddress=socket.getInetAddress(); ta.appendText("Connection from Socket[addr="+inetAddress.getHostAddress()+ ".port="+inetAddress.getHostName()+".localport="+PORT+"] at "+new Date()); }); HandleClientTraffic t= new HandleClientTraffic(socket); serverToOtherClients.add(t); t.start(); } } catch (Exception e) { e.printStackTrace(); } }).start(); } class HandleClientTraffic extends Thread{ private Socket socket; private String userName=""; private ObjectOutputStream outputToClient; ObjectInputStream inputFromClient; boolean connect=true; public HandleClientTraffic(Socket socket){ this.socket=socket; } public void run() { try { outputToClient=new ObjectOutputStream(socket.getOutputStream()); inputFromClient=new ObjectInputStream(socket.getInputStream()); //Get name userName=(String)inputFromClient.readObject(); ta.appendText("\n"+userName+" enter the chat\n"); for(int i=0;i<serverToOtherClients.size();i++){ serverToOtherClients.get(i).updateContant(); } while(true){ int sizeIndicator=(Integer)inputFromClient.readObject(); String getText=(String)inputFromClient.readObject(); if(sizeIndicator!=0){ v=new Vector<Integer>(); for(int i=0;i<sizeIndicator;i++){ v.addElement((Integer)inputFromClient.readObject()); } Platform.runLater(()->{ ta.appendText(userName+":"+getText+"\n"); for(int i=0;i<v.size();i++){ int indexSend=v.get(i); HandleClientTraffic a=serverToOtherClients.get(indexSend); try{ if(a.connect){ a.outputToClient.writeObject(userName+":"+getText+"\n"); } }catch(Exception e){ e.printStackTrace(); } } }); }else{ //0=to all Platform.runLater(()->{ ta.appendText(userName+":"+getText+"\n"); for(int i=serverToOtherClients.size();--i>=0;){ HandleClientTraffic a=serverToOtherClients.get(i); try{ if(a.connect){ a.outputToClient.writeObject(userName+":"+getText+"\n"); } }catch(Exception e){ e.printStackTrace(); } } }); } } }catch(SocketException ss){ try{ connect=false; String theName=userName; socket.close(); Platform.runLater(()->{ ta.appendText(theName+" has left the chat!\n"); }); for(int i=0;i<serverToOtherClients.size();i++){ HandleClientTraffic a=serverToOtherClients.get(i); if(a.connect){ a.outputToClient.writeObject(theName+" has left the chat!\n");} } }catch(IOException ioe){ } } catch(ClassNotFoundException er){ System.out.println("class not found problem,in server class"); } catch (IOException e) { System.out.println("input or output stream problem,in server class"); } }//run public String getUserName(){ return userName; } public ObjectOutputStream getOutputToClient(){ return outputToClient; } public ObjectInputStream getInputFromClient(){ return inputFromClient; } public void updateContant(){ try{//Get current online users outputToClient.writeObject("#");//sign outputToClient.flush(); outputToClient.writeObject(serverToOtherClients.size()); outputToClient.flush(); for(int i=0;i<serverToOtherClients.size();i++){ outputToClient.writeObject(serverToOtherClients.get(i).userName); outputToClient.flush();} }catch(IOException ef){} } } public static void main(String[] args) { launch(args); } } client code: public class Client extends Application{ private TextField tfName=new TextField(); private TextField tf=new TextField(); private TextArea ta=new TextArea(); private Socket socket; private ObjectInputStream inputFromServer=null; private ObjectOutputStream outputFromClient=null; private ListView<String> listView=new ListView<String>(); private String myName; public void start(Stage primaryStage){ BorderPane mainPane=new BorderPane(); ta.setEditable(false); tf.setEditable(false); listView.setPrefSize(100,70); listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); GridPane gridPane=new GridPane(); gridPane.add(new Label("Name"), 0, 0); gridPane.add(new Label("Enter text"), 0, 1); gridPane.add(tfName, 1, 0); gridPane.add(tf, 1, 1); gridPane.add(new Label(" Send to\n specified users "),2,0); gridPane.add(new Label("Current online users"),3,0); gridPane.add(listView,3,1); mainPane.setTop(gridPane); mainPane.setCenter(new ScrollPane(ta)); Scene scene=new Scene(mainPane); primaryStage.setTitle("Client"); primaryStage.setScene(scene); primaryStage.show(); primaryStage.setAlwaysOnTop(true); primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { Platform.exit(); System.exit(0); } }); tfName.setOnAction(e->{ try { outputFromClient.writeObject(tfName.getText().trim()); outputFromClient.flush(); myName=tfName.getText().trim(); ta.appendText("Server:Hi "+tfName.getText().trim()+"!\n"); tfName.setText(""); if(!tf.isEditable()){ tf.setEditable(true); tfName.setEditable(false); } } catch (Exception e1) { e1.printStackTrace(); } }); tf.setOnAction(e->{ try { ObservableList<Integer> oList=listView.getSelectionModel().getSelectedIndices(); if(oList.size()!=0){ outputFromClient.writeObject(oList.size()); outputFromClient.flush(); outputFromClient.writeObject(tf.getText()); outputFromClient.flush(); for (Integer i:listView.getSelectionModel().getSelectedIndices()) { outputFromClient.writeObject(i); outputFromClient.flush(); } }else{ outputFromClient.writeObject(0); outputFromClient.flush(); outputFromClient.writeObject(tf.getText()); outputFromClient.flush(); } tf.setText(""); } catch (Exception e1) { e1.printStackTrace(); } }); try { socket=new Socket("localhost",8000); inputFromServer=new ObjectInputStream(socket.getInputStream()); outputFromClient=new ObjectOutputStream(socket.getOutputStream()); new handleMessagesFromServer().start(); }catch(SocketException ee){ ta.appendText("Problem with socket\n"); try{ socket.close(); }catch(IOException e2){ System.out.println("can't close client's socket,in client class"); } } catch (Exception e1) { e1.printStackTrace(); } } public static void main(String[] args) { launch(args); } class handleMessagesFromServer extends Thread{ public void run(){ while(true){ String textFromServer; try { textFromServer = (String)inputFromServer.readObject(); if(textFromServer.equals("#"))//sign that we need to modify ListView { int nSize=(Integer)inputFromServer.readObject(); for(int i=0;i<nSize;i++){ String aName=(String)inputFromServer.readObject(); if(!(listView.getItems().contains(aName))){ listView.getItems().add(aName); } } }else{//just a simple text Platform.runLater(()->{ ta.appendText(textFromServer); }); } } catch (ClassNotFoundException | IOException e) { //e.printStackTrace(); System.out.println("here"); } } } } }
0debug
static int ssd0303_init(I2CSlave *i2c) { ssd0303_state *s = FROM_I2C_SLAVE(ssd0303_state, i2c); s->con = graphic_console_init(ssd0303_update_display, ssd0303_invalidate_display, NULL, NULL, s); qemu_console_resize(s->con, 96 * MAGNIFY, 16 * MAGNIFY); return 0; }
1threat
I am having problem in downloading the VS code here is error i am getting i am using macBook pro : <p>I am not able to install Visual Studio Code can anyone please help me.I am adding image please help me out of this.</p>
0debug
Why does onscroll need (this) bound without parenthesis in this function? : I have made 2 functions on the onscroll function. One of which has extra parenthesis, and the other doesn't. Why does it not work with the extra parenthesis? Here is my code: var windowScroll = function() { var doesNotRun = function() { console.log('running1'); }; var doesRun = function() { console.log('running2'); }; window.onscroll = doesNotRun.bind(this)(); window.onscroll = doesRun.bind(this); }; windowScroll(); here is a link on codepen: http://codepen.io/marcoangelo/pen/KWdWem any help to understand why Javascript does this would be great, thanks
0debug
Error Date and Time in Event Viewer of window log (system) C# : <p>I am trying to fetch date and Time from Event Viewer having level Error for my application but not getting way to fetch by C# please help. </p>
0debug
Android application developemnt - Customer order tracking application : I hope all are doing well, I need to develop an android application for my personal business. **Let me explain my application requirement:** 1) Using this application customer can **track their current order status.** eg: (order placed, under process, under manufacturing, ready to deliver). 2) To store the **customer order history details.** 3) Application publishment is not required. 4) The application does not need any heavy interactive GUI stuff, **simple order tracking is enough for my requirement.** I am an embedded developer, this technology is totally stranger for me. Hopefully, StackOverflow provides the platform where I can directly connect with experts and would use their expertise inputs instead of going blindly. I would like to ask you **below listed queries** 1) Who starts with android application development, suitable IDE to develop an Android App? 2) As you know this It's a starting point for me so I **would like to go with a free server** for this application usage, requesting the community, please **suggest the same.** 3) During the development period which server I can use for the testing purpose? I hope the community will help me to give the vision to build this small activity and encourage me to make this adventure in reality. Any other suggestions will be highly appreciated.
0debug
python - problem with output - iterate over dictionary : <p>I want to print('Doesn't exist') when the input is not a key in dictionary, it looks like its checking every single key in dictionary and prints if its there or not. I would like to ask if its possible to get output only one time if dictionary doesn't' contain input. </p> <pre><code>number = input('Number: ') data = { '1' : 'One', '2' : 'Two', '3' : 'Three', } number = number.upper() for a, value in data.items(): if a == number: print(number, ":", value) else: print('Doesnt exist here') Number: 1 1 : One Doesnt exist here Doesnt exist here </code></pre>
0debug
Sending Push via Postman using Firebase Messaging : <p>I'm trying to use <a href="https://www.getpostman.com/" rel="noreferrer">Postman</a> to send a single Push Notification using <code>Firebase</code> Cloud Messaging service.</p> <p>This is a working <code>cURL</code> command for the same purposal, on which I'm using as a reference.</p> <pre><code>curl -X POST --header "Authorization: key=&lt;API_ACCESS_KEY&gt;" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"to\":\"&lt;YOUR_DEVICE_ID_TOKEN&gt;\",\"notification\":{\"body\":\"Firebase\"} \"priority":\"10"}" </code></pre> <p>What I have done so far..</p> <p>1 - Set the <strong>Headers</strong> appropriately</p> <p><a href="https://i.stack.imgur.com/yH6f9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yH6f9.png" alt="enter image description here"></a></p> <p>2- At <strong>Body</strong> , I'm using <code>raw</code></p> <pre><code>{ "to" : "&lt;YOUR_DEVICE_ID_TOKEN&gt;" , "notification": { "body": "Firebase Cloud Message" } } </code></pre> <p>When executing, I'm getting back <code>401 - Unauthorized</code>.</p> <p>What's missing to correctly send the push notification?</p>
0debug
Go (integer) index of slice as array of structures : Is it possible in GoLang create array with where each element of array will be array of slices or structures. Something like in PHP $a = [1=>"test", 2=>""] // in this example 2 is integer will be for GoLang? $a[2] = [ object, object, object ] Can I do in Golang something like ? I know about incorrect syntax. var a [int][]StructureName b := make([]StructureName, 0) b := append ( b, StructureName{a, b, c, d}) b := append ( b, StructureName{e, f, g, h}) a[0] = append (a[0][0], b)
0debug
Chrome and Firefox are not able to access iPhone Camera : <p>The below code of HTML </p> <pre><code>&lt;video id="video" class="video" height="400" width="400" playsinline autoplay muted loop&gt;&lt;/video&gt; </code></pre> <p>and JavaScript </p> <pre><code>var video = document.getElementById("video"); navigator.mediaDevices.getUserMedia({video: true, audio: false}) .then(function(s) { stream = s; video.srcObject = s; video.play(); }) </code></pre> <p>The link works fine on all Browsers in Android device, also works fine on Safari browser of iPhone devices, but it does not even ask camera permission for other Browsers like Chrome and Firefox on iPhone Devices.</p>
0debug
static int input_initialise(struct XenDevice *xendev) { struct XenInput *in = container_of(xendev, struct XenInput, c.xendev); int rc; if (!in->c.con) { xen_pv_printf(xendev, 1, "ds not set (yet)\n"); return -1; } rc = common_bind(&in->c); if (rc != 0) return rc; qemu_add_kbd_event_handler(xenfb_key_event, in); return 0; }
1threat
Converting ImageProxy to Bitmap : <p>So, I wanted to explore new Google's Camera API - <code>CameraX</code>. What I want to do, is take an image from camera feed every second and then pass it into a function that accepts bitmap for machine learning purposes. </p> <p>I read the documentation on <code>Camera X</code> Image Analyzer:</p> <blockquote> <p>The image analysis use case provides your app with a CPU-accessible image to perform image processing, computer vision, or machine learning inference on. The application implements an Analyzer method that is run on each frame.</p> </blockquote> <p>..which basically is what I need. So, I implemented this image analyzer like this:</p> <pre><code>imageAnalysis.setAnalyzer { image: ImageProxy, _: Int -&gt; viewModel.onAnalyzeImage(image) } </code></pre> <p>What I get is <code>image: ImageProxy</code>. How can I transfer this <code>ImageProxy</code> to <code>Bitmap</code>?</p> <p>I tried to solve it like this:</p> <pre><code>fun decodeBitmap(image: ImageProxy): Bitmap? { val buffer = image.planes[0].buffer val bytes = ByteArray(buffer.capacity()).also { buffer.get(it) } return BitmapFactory.decodeByteArray(bytes, 0, bytes.size) } </code></pre> <p>But it returns <code>null</code> - because <code>decodeByteArray</code> does not receive valid (?) bitmap bytes. Any ideas?</p>
0debug
static int coroutine_fn bdrv_mirror_top_flush(BlockDriverState *bs) { return bdrv_co_flush(bs->backing->bs);
1threat
IntelliJ commit 50-character line length reminder : <p>When committing a change on the IntelliJ platform, is there a way to have it check that the first line of the commit message does not exceed the 50-character length limit? </p> <p>Right now, I'm usually checking this manually, with the position indicator in the lower right corner of the main IDE window (the one that is formatted as <code>line:character</code>). However that indicator is sometimes hidden by other tool windows, and requires me to have the cursor at the end of the first line. Is there some setting I can enable or some plugin I can install to have the IDE check this for me?</p>
0debug
void tb_invalidate_phys_addr(hwaddr addr) { ram_addr_t ram_addr; MemoryRegionSection *section; section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS); if (!(memory_region_is_ram(section->mr) || memory_region_is_romd(section->mr))) { return; } ram_addr = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK) + memory_region_section_addr(section, addr); tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0); }
1threat
How do you provide the user the choice to try my program once again like after typing yes , the user can use my program once again? : print ("Welcome to my Area Calculator") i=raw_input("Please enter the shape whose Area you want to calculate(square/rectangle/right angled triangle/rhombus/parallelogram): ") my_list=["square","rectangle","triangle","right angled triangle","rhombus","parallelogram"] if i in my_list: if i=="square": s=float(input("What is the side of the square: ")) print "Area of the square is : ", s**2 elif i=="rectangle": l=float(input("What is the length of the rectangle: ")) b=float(input("What is the breadth of the rectangle: ")) print "Area of the rectangle is : ", l*b elif i=="right angled triangle": base1=float(input("What is the base of the triangle: ")) height1=float(input("What is the height of the triangle: ")) print "Area of the triangle is : ", 0.5*base1*height1 elif i=="rhombus": d1=float(input("What is the length of the 1st diagnol of the rhombus: ")) d2=float(input("What is the length of the 2nd diagnol of the rhombus: ")) print "Area of the rhombus is : ", 0.5*d1*d2 elif i=="parallelogram": base=float(input("What is the length of 1 side of the parallelogram: ")) height=float(input("What is the length of the other side: ")) print "Area of the parallelogram is : ", height*base print "Thank you so much for using my area calculator"
0debug
static void set_pointer(Object *obj, Visitor *v, Property *prop, int (*parse)(DeviceState *dev, const char *str, void **ptr), const char *name, Error **errp) { DeviceState *dev = DEVICE(obj); Error *local_err = NULL; void **ptr = qdev_get_prop_ptr(dev, prop); char *str; int ret; if (dev->state != DEV_STATE_CREATED) { error_set(errp, QERR_PERMISSION_DENIED); return; } visit_type_str(v, &str, name, &local_err); if (local_err) { error_propagate(errp, local_err); return; } if (!*str) { g_free(str); *ptr = NULL; return; } ret = parse(dev, str, ptr); error_set_from_qdev_prop_error(errp, ret, dev, prop, str); g_free(str); }
1threat
how to pull all of the data from an sql database and display it with php? : <p>so im trying to display countdowns to events which are stored with an my_sql table... the code im using is:</p> <pre><code>&lt;?php // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } $query = "SELECT * FROM `customcountdowns` WHERE `name_of_event` = * ORDER BY name_of_event"; if($query) // will return true if succefull else it will return false { echo "query is working"; // code here } $result = mysqli_query($conn, $query); if(!$result) { echo 'No results found.'; } </code></pre> <p>it puts out query is working and no results found... how would i get all of the data out of the table and display it? thanks in advance!</p>
0debug
How to fix invalid literal for int() with base 10: '' : new to python. Using python3.7 and tkinter to make a GUI, where I grab the input from 2 text boxes, and use a math formula then export it out. I've looked through other forms and tried what they suggested and could not find how to fix it. I've tried global inside and outside of the function, setting the variable before the function. ```python def retrieve_input(): global InputValue global InputValue2 global Delay InputValue=tasks.get() InputValue2=proxies.get() print(InputValue) print(InputValue2) Delay=3500/int(InputValue)*int(InputValue2) print(Delay) retrieve_input() Label (window, width=12, text=Delay,bg="white",fg="Pink", font="none 22 bold") .grid(row=5, column=0,sticky=W) ``` File ", line 29, in retrieve_input Delay=3500/int(InputValue)*int(InputValue2) ValueError: invalid literal for int() with base 10: '' Thank you :)
0debug
Time count - from frontend to backend : <p>I'm thinking to make a simple timer, so when the timer is clicked, the time starts to count and then I can stop it and the time passed will be saved into the DB.</p> <p>But there's some tricks to it, as I figured out:</p> <p>1) When the tab(of the current timer) is switched to another, the time count isn't trusty, due the low priority on the inactive tabs.</p> <p>2) How can I varify the time passed with PHP in backend? (I've thought of making AJAX call every XX seconds to varify it with backend, but how can I make counter like this in my backend with PHP? Is this even possible using PHP?</p> <p>P.S. I don't mind to drop legacy browsers, but I want to support all the modern ones(except the Edge :) )</p>
0debug
Best way to store questionnaires/answers in c#? : <p>I'm working on a project where I need to store a lot of multilanguage questionnaires. I struggled a lot on how to store these questionnaires in my database and finally I went with the resources files. Each questionnaire has his own resource file in which you find the questions, their types and their answers.</p> <p>I store the user's answers in the database with a key to the answer (this key is defined in the comment section of the answer in the resource file).</p> <p>I tried to store them first in my database but it was a real mess when I added the translations.</p> <p>So my question is : Is it a good way to go ? Or there is a better way to store my questionnaires ? </p> <p>I can't really find any documentation on this subject online so I ask you guys :)</p> <p>Thanks !</p>
0debug
static void iv_Decode_Chunk(Indeo3DecodeContext *s, uint8_t *cur, uint8_t *ref, int width, int height, const uint8_t *buf1, long cb_offset, const uint8_t *hdr, const uint8_t *buf2, int min_width_160) { uint8_t bit_buf; unsigned long bit_pos, lv, lv1, lv2; long *width_tbl, width_tbl_arr[10]; const signed char *ref_vectors; uint8_t *cur_frm_pos, *ref_frm_pos, *cp, *cp2; uint32_t *cur_lp, *ref_lp; const uint32_t *correction_lp[2], *correctionloworder_lp[2], *correctionhighorder_lp[2]; uint8_t *correction_type_sp[2]; struct ustr strip_tbl[20], *strip; int i, j, k, lp1, lp2, flag1, cmd, blks_width, blks_height, region_160_width, rle_v1, rle_v2, rle_v3; unsigned short res; bit_buf = 0; ref_vectors = NULL; width_tbl = width_tbl_arr + 1; i = (width < 0 ? width + 3 : width)/4; for(j = -1; j < 8; j++) width_tbl[j] = i * j; strip = strip_tbl; for(region_160_width = 0; region_160_width < (width - min_width_160); region_160_width += min_width_160); strip->ypos = strip->xpos = 0; for(strip->width = min_width_160; width > strip->width; strip->width *= 2); strip->height = height; strip->split_direction = 0; strip->split_flag = 0; strip->usl7 = 0; bit_pos = 0; rle_v1 = rle_v2 = rle_v3 = 0; while(strip >= strip_tbl) { if(bit_pos <= 0) { bit_pos = 8; bit_buf = *buf1++; bit_pos -= 2; cmd = (bit_buf >> bit_pos) & 0x03; if(cmd == 0) { strip++; memcpy(strip, strip-1, sizeof(*strip)); strip->split_flag = 1; strip->split_direction = 0; strip->height = (strip->height > 8 ? ((strip->height+8)>>4)<<3 : 4); continue; } else if(cmd == 1) { strip++; memcpy(strip, strip-1, sizeof(*strip)); strip->split_flag = 1; strip->split_direction = 1; strip->width = (strip->width > 8 ? ((strip->width+8)>>4)<<3 : 4); continue; } else if(cmd == 2) { if(strip->usl7 == 0) { strip->usl7 = 1; ref_vectors = NULL; continue; } else if(cmd == 3) { if(strip->usl7 == 0) { strip->usl7 = 1; ref_vectors = (const signed char*)buf2 + (*buf1 * 2); buf1++; continue; cur_frm_pos = cur + width * strip->ypos + strip->xpos; if((blks_width = strip->width) < 0) blks_width += 3; blks_width >>= 2; blks_height = strip->height; if(ref_vectors != NULL) { ref_frm_pos = ref + (ref_vectors[0] + strip->ypos) * width + ref_vectors[1] + strip->xpos; } else ref_frm_pos = cur_frm_pos - width_tbl[4]; if(cmd == 2) { if(bit_pos <= 0) { bit_pos = 8; bit_buf = *buf1++; bit_pos -= 2; cmd = (bit_buf >> bit_pos) & 0x03; if(cmd == 0 || ref_vectors != NULL) { for(lp1 = 0; lp1 < blks_width; lp1++) { for(i = 0, j = 0; i < blks_height; i++, j += width_tbl[1]) ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j]; cur_frm_pos += 4; ref_frm_pos += 4; } else if(cmd != 1) return; } else { k = *buf1 >> 4; j = *buf1 & 0x0f; buf1++; lv = j + cb_offset; if((lv - 8) <= 7 && (k == 0 || k == 3 || k == 10)) { cp2 = s->ModPred + ((lv - 8) << 7); cp = ref_frm_pos; for(i = 0; i < blks_width << 2; i++) { int v = *cp >> 1; *(cp++) = cp2[v]; if(k == 1 || k == 4) { lv = (hdr[j] & 0xf) + cb_offset; correction_type_sp[0] = s->corrector_type + (lv << 8); correction_lp[0] = correction + (lv << 8); lv = (hdr[j] >> 4) + cb_offset; correction_lp[1] = correction + (lv << 8); correction_type_sp[1] = s->corrector_type + (lv << 8); } else { correctionloworder_lp[0] = correctionloworder_lp[1] = correctionloworder + (lv << 8); correctionhighorder_lp[0] = correctionhighorder_lp[1] = correctionhighorder + (lv << 8); correction_type_sp[0] = correction_type_sp[1] = s->corrector_type + (lv << 8); correction_lp[0] = correction_lp[1] = correction + (lv << 8); switch(k) { case 1: case 0: for( ; blks_height > 0; blks_height -= 4) { for(lp1 = 0; lp1 < blks_width; lp1++) { for(lp2 = 0; lp2 < 4; ) { k = *buf1++; cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2]; ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2]; switch(correction_type_sp[0][k]) { case 0: *cur_lp = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); lp2++; case 1: res = ((le2me_16(((unsigned short *)(ref_lp))[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1; ((unsigned short *)cur_lp)[0] = le2me_16(res); res = ((le2me_16(((unsigned short *)(ref_lp))[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1; ((unsigned short *)cur_lp)[1] = le2me_16(res); buf1++; lp2++; case 2: if(lp2 == 0) { for(i = 0, j = 0; i < 2; i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 += 2; case 3: if(lp2 < 2) { for(i = 0, j = 0; i < (3 - lp2); i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 = 3; case 8: if(lp2 == 0) { RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) if(rle_v1 == 1 || ref_vectors != NULL) { for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) } else { rle_v1 = 1; rle_v2 = *buf1 - 1; case 5: LP2_CHECK(buf1,rle_v3,lp2) case 4: for(i = 0, j = 0; i < (4 - lp2); i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 = 4; case 7: if(rle_v3 != 0) rle_v3 = 0; else { buf1--; rle_v3 = 1; case 6: if(ref_vectors != NULL) { for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 = 4; case 9: lv1 = *buf1++; lv = (lv1 & 0x7F) << 1; lv += (lv << 8); lv += (lv << 16); for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = lv; LV1_CHECK(buf1,rle_v3,lv1,lp2) default: return; cur_frm_pos += 4; ref_frm_pos += 4; cur_frm_pos += ((width - blks_width) * 4); ref_frm_pos += ((width - blks_width) * 4); case 4: case 3: if(ref_vectors != NULL) return; flag1 = 1; for( ; blks_height > 0; blks_height -= 8) { for(lp1 = 0; lp1 < blks_width; lp1++) { for(lp2 = 0; lp2 < 4; ) { k = *buf1++; cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1]; switch(correction_type_sp[lp2 & 0x01][k]) { case 0: cur_lp[width_tbl[1]] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); if(lp2 > 0 || flag1 == 0 || strip->ypos != 0) cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; else cur_lp[0] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); lp2++; case 1: res = ((le2me_16(((unsigned short *)ref_lp)[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1; ((unsigned short *)cur_lp)[width_tbl[2]] = le2me_16(res); res = ((le2me_16(((unsigned short *)ref_lp)[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1; ((unsigned short *)cur_lp)[width_tbl[2]+1] = le2me_16(res); if(lp2 > 0 || flag1 == 0 || strip->ypos != 0) cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; else cur_lp[0] = cur_lp[width_tbl[1]]; buf1++; lp2++; case 2: if(lp2 == 0) { for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = *ref_lp; lp2 += 2; case 3: if(lp2 < 2) { for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) cur_lp[j] = *ref_lp; lp2 = 3; case 6: lp2 = 4; case 7: if(rle_v3 != 0) rle_v3 = 0; else { buf1--; rle_v3 = 1; lp2 = 4; case 8: if(lp2 == 0) { RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) if(rle_v1 == 1) { for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) } else { rle_v2 = (*buf1) - 1; rle_v1 = 1; case 5: LP2_CHECK(buf1,rle_v3,lp2) case 4: for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) cur_lp[j] = *ref_lp; lp2 = 4; case 9: av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n"); lv1 = *buf1++; lv = (lv1 & 0x7F) << 1; lv += (lv << 8); lv += (lv << 16); for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = lv; LV1_CHECK(buf1,rle_v3,lv1,lp2) default: return; cur_frm_pos += 4; cur_frm_pos += (((width * 2) - blks_width) * 4); flag1 = 0; case 10: if(ref_vectors == NULL) { flag1 = 1; for( ; blks_height > 0; blks_height -= 8) { for(lp1 = 0; lp1 < blks_width; lp1 += 2) { for(lp2 = 0; lp2 < 4; ) { k = *buf1++; cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1]; lv1 = ref_lp[0]; lv2 = ref_lp[1]; if(lp2 == 0 && flag1 != 0) { #ifdef WORDS_BIGENDIAN lv1 = lv1 & 0xFF00FF00; lv1 = (lv1 >> 8) | lv1; lv2 = lv2 & 0xFF00FF00; lv2 = (lv2 >> 8) | lv2; #else lv1 = lv1 & 0x00FF00FF; lv1 = (lv1 << 8) | lv1; lv2 = lv2 & 0x00FF00FF; lv2 = (lv2 << 8) | lv2; #endif switch(correction_type_sp[lp2 & 0x01][k]) { case 0: cur_lp[width_tbl[1]] = le2me_32(((le2me_32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1); cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(lv2) >> 1) + correctionhighorder_lp[lp2 & 0x01][k]) << 1); if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) { cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; } else { cur_lp[0] = cur_lp[width_tbl[1]]; cur_lp[1] = cur_lp[width_tbl[1]+1]; lp2++; case 1: cur_lp[width_tbl[1]] = le2me_32(((le2me_32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][*buf1]) << 1); cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(lv2) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1); if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) { cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; } else { cur_lp[0] = cur_lp[width_tbl[1]]; cur_lp[1] = cur_lp[width_tbl[1]+1]; buf1++; lp2++; case 2: if(lp2 == 0) { if(flag1 != 0) { for(i = 0, j = width_tbl[1]; i < 3; i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; } else { for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; lp2 += 2; case 3: if(lp2 < 2) { if(lp2 == 0 && flag1 != 0) { for(i = 0, j = width_tbl[1]; i < 5; i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; } else { for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; lp2 = 3; case 8: if(lp2 == 0) { RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) if(rle_v1 == 1) { if(flag1 != 0) { for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; } else { for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) } else { rle_v1 = 1; rle_v2 = (*buf1) - 1; case 5: LP2_CHECK(buf1,rle_v3,lp2) case 4: if(lp2 == 0 && flag1 != 0) { for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; } else { for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; lp2 = 4; case 6: lp2 = 4; case 7: if(lp2 == 0) { if(rle_v3 != 0) rle_v3 = 0; else { buf1--; rle_v3 = 1; lp2 = 4; case 9: av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n"); lv1 = *buf1; lv = (lv1 & 0x7F) << 1; lv += (lv << 8); lv += (lv << 16); for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) cur_lp[j] = lv; LV1_CHECK(buf1,rle_v3,lv1,lp2) default: return; cur_frm_pos += 8; cur_frm_pos += (((width * 2) - blks_width) * 4); flag1 = 0; } else { for( ; blks_height > 0; blks_height -= 8) { for(lp1 = 0; lp1 < blks_width; lp1 += 2) { for(lp2 = 0; lp2 < 4; ) { k = *buf1++; cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2]; switch(correction_type_sp[lp2 & 0x01][k]) { case 0: lv1 = correctionloworder_lp[lp2 & 0x01][k]; lv2 = correctionhighorder_lp[lp2 & 0x01][k]; cur_lp[0] = le2me_32(((le2me_32(ref_lp[0]) >> 1) + lv1) << 1); cur_lp[1] = le2me_32(((le2me_32(ref_lp[1]) >> 1) + lv2) << 1); cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1); cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1); lp2++; case 1: lv1 = correctionloworder_lp[lp2 & 0x01][*buf1++]; lv2 = correctionloworder_lp[lp2 & 0x01][k]; cur_lp[0] = le2me_32(((le2me_32(ref_lp[0]) >> 1) + lv1) << 1); cur_lp[1] = le2me_32(((le2me_32(ref_lp[1]) >> 1) + lv2) << 1); cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1); cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1); lp2++; case 2: if(lp2 == 0) { for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) { cur_lp[j] = ref_lp[j]; cur_lp[j+1] = ref_lp[j+1]; lp2 += 2; case 3: if(lp2 < 2) { for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) { cur_lp[j] = ref_lp[j]; cur_lp[j+1] = ref_lp[j+1]; lp2 = 3; case 8: if(lp2 == 0) { RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) { ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j]; ((uint32_t *)cur_frm_pos)[j+1] = ((uint32_t *)ref_frm_pos)[j+1]; RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) } else { rle_v1 = 1; rle_v2 = (*buf1) - 1; case 5: case 7: LP2_CHECK(buf1,rle_v3,lp2) case 6: case 4: for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) { cur_lp[j] = ref_lp[j]; cur_lp[j+1] = ref_lp[j+1]; lp2 = 4; case 9: av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n"); lv1 = *buf1; lv = (lv1 & 0x7F) << 1; lv += (lv << 8); lv += (lv << 16); for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)cur_frm_pos)[j+1] = lv; LV1_CHECK(buf1,rle_v3,lv1,lp2) default: return; cur_frm_pos += 8; ref_frm_pos += 8; cur_frm_pos += (((width * 2) - blks_width) * 4); ref_frm_pos += (((width * 2) - blks_width) * 4); case 11: if(ref_vectors == NULL) return; for( ; blks_height > 0; blks_height -= 8) { for(lp1 = 0; lp1 < blks_width; lp1++) { for(lp2 = 0; lp2 < 4; ) { k = *buf1++; cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2]; switch(correction_type_sp[lp2 & 0x01][k]) { case 0: cur_lp[0] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); lp2++; case 1: lv1 = (unsigned short)(correction_lp[lp2 & 0x01][*buf1++]); lv2 = (unsigned short)(correction_lp[lp2 & 0x01][k]); res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[0]) >> 1) + lv1) << 1); ((unsigned short *)cur_lp)[0] = le2me_16(res); res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[1]) >> 1) + lv2) << 1); ((unsigned short *)cur_lp)[1] = le2me_16(res); res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[width_tbl[2]]) >> 1) + lv1) << 1); ((unsigned short *)cur_lp)[width_tbl[2]] = le2me_16(res); res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[width_tbl[2]+1]) >> 1) + lv2) << 1); ((unsigned short *)cur_lp)[width_tbl[2]+1] = le2me_16(res); lp2++; case 2: if(lp2 == 0) { for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 += 2; case 3: if(lp2 < 2) { for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 = 3; case 8: if(lp2 == 0) { RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) } else { rle_v1 = 1; rle_v2 = (*buf1) - 1; case 5: case 7: LP2_CHECK(buf1,rle_v3,lp2) case 4: case 6: for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 = 4; case 9: av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n"); lv1 = *buf1++; lv = (lv1 & 0x7F) << 1; lv += (lv << 8); lv += (lv << 16); for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = lv; LV1_CHECK(buf1,rle_v3,lv1,lp2) default: return; cur_frm_pos += 4; ref_frm_pos += 4; cur_frm_pos += (((width * 2) - blks_width) * 4); ref_frm_pos += (((width * 2) - blks_width) * 4); default: return; if(strip < strip_tbl) return; for( ; strip >= strip_tbl; strip--) { if(strip->split_flag != 0) { strip->split_flag = 0; strip->usl7 = (strip-1)->usl7; if(strip->split_direction) { strip->xpos += strip->width; strip->width = (strip-1)->width - strip->width; if(region_160_width <= strip->xpos && width < strip->width + strip->xpos) strip->width = width - strip->xpos; } else { strip->ypos += strip->height; strip->height = (strip-1)->height - strip->height;
1threat
Which dependence two arrays? If second array had create from the first array : I'm crate two Array, one it has the entries, second empty. Assing a one cell, the first array[0] to the second array. And had applye method pop() for second Array. Why cell, the first array too change his a value. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var t = [[1,1,1], [1,1,1,1,1], [1,1,1,1]]; var t1 = t[0]; t1.pop(); console.log(t[0]); <!-- end snippet --> result 1.1 Why it's happening? Thanks.
0debug
Eclipse install fail : Hi I always use eclipse in the past but recently I try to download eclipse for my new laptop and it keep giving me this problem. ...... ERROR: org.eclipse.equinox.p2.transport.ecf code=1002 HTTP Proxy Authentication Required: http://download.eclipse.org/releases/oxygen/201706281000/content.xml.xz ERROR: org.eclipse.ecf.identity code=0 Proxy Authentication Required ..... Please help!
0debug
alert('Hello ' + user_input);
1threat
How can we pass multiple filters to oData read : I have come across with situation where more than 10 input values has to be passed to back end as filters. is there any other option to create and pass filters instead of creating it in controller for each input filed?
0debug
Is there a recommended way to test if a smart pointer is null? : <p>I'm trying to check if a <code>std::shared_ptr</code> is null. Is there a difference between doing</p> <pre><code>std::shared_ptr&lt;int&gt; p; if (!p) { // method 1 } if (p == nullptr) { // method 2 } </code></pre>
0debug
def find_Max_Num(arr,n) : arr.sort(reverse = True) num = arr[0] for i in range(1,n) : num = num * 10 + arr[i] return num
0debug
remove some line in a java Document : i have a java Document which contains XML, how i can do if i want to take from that Document only some information enclosed in some tags? Example (i want only tag included in <catalog> <catalog/>) //Some VALUES <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> <ORACLE> select * from scott.dept; </ORACLE> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>Bonnie Tyler</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>CBS Records</COMPANY> <PRICE>9.90</PRICE> <YEAR>1988</YEAR> </CD> <ORACLE> begin htp.p('This is the test data'); end; </ORACLE> </CD> </CATALOG> //OTHER VALUES
0debug
static void ppc_prep_init(QEMUMachineInitArgs *args) { ram_addr_t ram_size = args->ram_size; const char *cpu_model = args->cpu_model; const char *kernel_filename = args->kernel_filename; const char *kernel_cmdline = args->kernel_cmdline; const char *initrd_filename = args->initrd_filename; const char *boot_device = args->boot_order; MemoryRegion *sysmem = get_system_memory(); PowerPCCPU *cpu = NULL; CPUPPCState *env = NULL; nvram_t nvram; M48t59State *m48t59; PortioList *port_list = g_new(PortioList, 1); #if 0 MemoryRegion *xcsr = g_new(MemoryRegion, 1); #endif int linux_boot, i, nb_nics1; MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *vga = g_new(MemoryRegion, 1); uint32_t kernel_base, initrd_base; long kernel_size, initrd_size; DeviceState *dev; PCIHostState *pcihost; PCIBus *pci_bus; PCIDevice *pci; ISABus *isa_bus; ISADevice *isa; qemu_irq *cpu_exit_irq; int ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; sysctrl = g_malloc0(sizeof(sysctrl_t)); linux_boot = (kernel_filename != NULL); if (cpu_model == NULL) cpu_model = "602"; for (i = 0; i < smp_cpus; i++) { cpu = cpu_ppc_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } env = &cpu->env; if (env->flags & POWERPC_FLAG_RTC_CLK) { cpu_ppc_tb_init(env, 7812500UL); } else { cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); } qemu_register_reset(ppc_prep_reset, cpu); } memory_region_init_ram(ram, NULL, "ppc_prep.ram", ram_size); vmstate_register_ram_global(ram); memory_region_add_subregion(sysmem, 0, ram); if (linux_boot) { kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_image_targphys(kernel_filename, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { hw_error("qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } if (initrd_filename) { initrd_base = INITRD_LOAD_ADDR; initrd_size = load_image_targphys(initrd_filename, initrd_base, ram_size - initrd_base); if (initrd_size < 0) { hw_error("qemu: could not load initial ram disk '%s'\n", initrd_filename); } } else { initrd_base = 0; initrd_size = 0; } ppc_boot_device = 'm'; } else { kernel_base = 0; kernel_size = 0; initrd_base = 0; initrd_size = 0; ppc_boot_device = '\0'; for (i = 0; boot_device[i] != '\0'; i++) { if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { ppc_boot_device = boot_device[i]; break; } } if (ppc_boot_device == '\0') { fprintf(stderr, "No valid boot device for Mac99 machine\n"); exit(1); } } if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { hw_error("Only 6xx bus is supported on PREP machine\n"); } dev = qdev_create(NULL, "raven-pcihost"); if (bios_name == NULL) { bios_name = BIOS_FILENAME; } qdev_prop_set_string(dev, "bios-name", bios_name); qdev_prop_set_uint32(dev, "elf-machine", ELF_MACHINE); pcihost = PCI_HOST_BRIDGE(dev); object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL); qdev_init_nofail(dev); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0"); if (pci_bus == NULL) { fprintf(stderr, "Couldn't create PCI host controller.\n"); exit(1); } sysctrl->contiguous_map_irq = qdev_get_gpio_in(dev, 0); pci = pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "i82378"); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); cpu = POWERPC_CPU(first_cpu); qdev_connect_gpio_out(&pci->qdev, 0, cpu->env.irq_inputs[PPC6xx_INPUT_INT]); qdev_connect_gpio_out(&pci->qdev, 1, *cpu_exit_irq); sysbus_connect_irq(&pcihost->busdev, 0, qdev_get_gpio_in(&pci->qdev, 9)); sysbus_connect_irq(&pcihost->busdev, 1, qdev_get_gpio_in(&pci->qdev, 11)); sysbus_connect_irq(&pcihost->busdev, 2, qdev_get_gpio_in(&pci->qdev, 9)); sysbus_connect_irq(&pcihost->busdev, 3, qdev_get_gpio_in(&pci->qdev, 11)); isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci), "isa.0")); isa = isa_create(isa_bus, TYPE_PC87312); dev = DEVICE(isa); qdev_prop_set_uint8(dev, "config", 13); qdev_init_nofail(dev); pci_vga_init(pci_bus); memory_region_init_alias(vga, NULL, "vga-alias", pci_address_space(pci), 0xf0000000, 0x1000000); memory_region_add_subregion_overlap(sysmem, 0xf0000000, vga, 10); nb_nics1 = nb_nics; if (nb_nics1 > NE2000_NB_MAX) nb_nics1 = NE2000_NB_MAX; for(i = 0; i < nb_nics1; i++) { if (nd_table[i].model == NULL) { nd_table[i].model = g_strdup("ne2k_isa"); } if (strcmp(nd_table[i].model, "ne2k_isa") == 0) { isa_ne2000_init(isa_bus, ne2000_io[i], ne2000_irq[i], &nd_table[i]); } else { pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL); } } ide_drive_get(hd, MAX_IDE_BUS); for(i = 0; i < MAX_IDE_BUS; i++) { isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i], hd[2 * i], hd[2 * i + 1]); } isa_create_simple(isa_bus, "i8042"); cpu = POWERPC_CPU(first_cpu); sysctrl->reset_irq = cpu->env.irq_inputs[PPC6xx_INPUT_HRESET]; portio_list_init(port_list, NULL, prep_portio_list, sysctrl, "prep"); portio_list_add(port_list, isa_address_space_io(isa), 0x0); #if 0 memory_region_init_io(xcsr, NULL, &PPC_XCSR_ops, NULL, "ppc-xcsr", 0x1000); memory_region_add_subregion(sysmem, 0xFEFF0000, xcsr); #endif if (usb_enabled(false)) { pci_create_simple(pci_bus, -1, "pci-ohci"); } m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59); if (m48t59 == NULL) return; sysctrl->nvram = m48t59; nvram.opaque = m48t59; nvram.read_fn = &m48t59_read; nvram.write_fn = &m48t59_write; PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device, kernel_base, kernel_size, kernel_cmdline, initrd_base, initrd_size, 0, graphic_width, graphic_height, graphic_depth); }
1threat
App shurting down when button clicked : I have this code I have written in android project to open a new view but whenever the button is clicked, the app stops working but returns no error on the debugger console what could I be doing wrong? Here is my code public class LoginActivity extends Activity{ private Button btnLinkToRegister; btnLinkToRegister = (Button) findViewById(R.id.btnLinkToRegisterScreen); // Link to Register Screen btnLinkToRegister.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent i = new Intent(getApplicationContext(), RegisterActivity.class); startActivity(i); finish(); } }); } I have removed other codes to make it easy to identify the problem
0debug
Difference between Throw and Throws in Java- Clarification : <p>I am confused to get a clear understanding of when throw is used and throws is used. Kindly provide me an example to show the difference.</p> <p>Also, I tried the below code:</p> <p>package AccessModifiers;</p> <p>//import java.io.IOException;</p> <p>public class ThrowExceptions {</p> <pre><code>int QAAutoLevel; int QAExp; void QAAutomationHiring(int grade) { if (grade&lt;5) throw new ArithmeticException("Not professionally Qualified"); else System.out.println("Ready to be test"); } void QAExperience(int x,int grade) { QAAutomationHiring(grade); } void checkThrowsExep(int a,int b) throws ArithmeticException { try{ int result=a/b; System.out.println("Result is :"+result); } catch(Exception e) { System.out.println("The error messgae is: "+ e.getMessage()); } } public static void main(String args[]) { ThrowExceptions t=new ThrowExceptions(); //t.QAAutomationHiring(8); t.QAExperience(2,8); t.QAExperience(4,2); t.checkThrowsExep(5, 0); } </code></pre> <p>}</p> <p>In the above code, when I run the program, the line- 't.checkThrowsExp' in main function is not reached. I studied that throw and throws are used to catch the exception and continue with the program execution. But here the execution stops and not proceeding to the next set of statements. Please share your comments.</p>
0debug
get list of packages installed in Anaconda : <p>Over a period of time I have loaded a number of packages into the Anaconda I have been using. Now I am not able to keep track of it. How do we get a list of all packages loaded in Anaconda (windows10)? What is the command?</p>
0debug
int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) { Error *err = NULL; const char *bdrv_name = value ? bdrv_get_device_name(value) : ""; object_property_set_str(OBJECT(dev), bdrv_name, name, &err); if (err) { qerror_report_err(err); error_free(err); return -1; } return 0; }
1threat
void virtio_scsi_common_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(dev); int i; virtio_init(vdev, "virtio-scsi", VIRTIO_ID_SCSI, sizeof(VirtIOSCSIConfig)); s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *)); s->sense_size = VIRTIO_SCSI_SENSE_SIZE; s->cdb_size = VIRTIO_SCSI_CDB_SIZE; s->ctrl_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_ctrl); s->event_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_event); for (i = 0; i < s->conf.num_queues; i++) { s->cmd_vqs[i] = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_cmd); } }
1threat
How to map a dictionary in reactJS? : <p>I am getting a dictionary from an online api in the form of {{key: object}, {key: object},... For like 1000 Objects}. I would like to use reactJS to do something like </p> <pre><code>this.props.dict.map(function(object, key)){ //Do stuff } </code></pre> <p>This map works with arrays but it obviously doesn't work with dictionaries. How can I achieve something similar?</p>
0debug
Regex in java where text on which search is being done is dynamically changing : In java find()+start()+end() can be used for extracting regex pattern which occur more than one time using there functions on matcher object. Patter p = Patter.compile(regex); Matcher matcher = p.matcher(text); while(matcher.find()){ // do something } In my case text is changing with every find() in while loop so next time matcher.start() and matcher.end() gives wrong indices. I mean these indices are correct for old text but as text is changing it gives incorrect indices. Im stuck here, pLease help. Thanks a lot in advance.
0debug
void tb_invalidate_page_range(target_ulong start, target_ulong end) { #if 0 target_ulong phys_addr; phys_addr = get_phys_addr_code(env, start); tb_invalidate_phys_page_range(phys_addr, phys_addr + end - start, 0); #endif }
1threat
int get_osversion(void) { static int osversion; struct new_utsname buf; const char *s; int i, n, tmp; if (osversion) return osversion; if (qemu_uname_release && *qemu_uname_release) { s = qemu_uname_release; } else { if (sys_uname(&buf)) return 0; s = buf.release; } tmp = 0; for (i = 0; i < 3; i++) { n = 0; while (*s >= '0' && *s <= '9') { n *= 10; n += *s - '0'; s++; } tmp = (tmp << 8) + n; if (*s == '.') s++; } osversion = tmp; return osversion; }
1threat
what's mean by KEY_NAME of fingerprint authentication in andriod studio? : I have been finished the code of my project but when I reach to this step, I don't know what should I do, or what is I give a value to this parameter? [please help me!!][1] [1]: https://i.stack.imgur.com/LtsjP.jpg
0debug
void ff_xvmc_init_block(MpegEncContext *s) { struct xvmc_render_state *render = (struct xvmc_render_state*)s->current_picture.data[2]; assert(render); if (!render || render->magic != AV_XVMC_RENDER_MAGIC) { assert(0); return; } s->block = (DCTELEM *)(render->data_blocks + render->next_free_data_block_num * 64); }
1threat
static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, const int16_t bS[4], unsigned int qp, H264Context *h) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { int8_t tc[4]; tc[0] = tc0_table[index_a][bS[0]]; tc[1] = tc0_table[index_a][bS[1]]; tc[2] = tc0_table[index_a][bS[2]]; tc[3] = tc0_table[index_a][bS[3]]; h->h264dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc); } else { h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta); } }
1threat
spring boot test unable to inject TestRestTemplate and MockMvc : <p>I am using spring boot <code>1.4.0.RELEASE</code>. I am writing tests for my controller class. I get the following exception.</p> <pre><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.concur.cognos.authentication.service.ServiceControllerITTest': Unsatisfied dependency expressed through field 'restTemplate': No qualifying bean of type [org.springframework.boot.test.web.client.TestRestTemplate] found for dependency [org.springframework.boot.test.web.client.TestRestTemplate]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.test.web.client.TestRestTemplate] found for dependency [org.springframework.boot.test.web.client.TestRestTemplate]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} </code></pre> <p>Here is my test class</p> <pre><code>public class ServiceControllerITTest extends ApplicationTests { @Autowired private TestRestTemplate restTemplate; @Autowired private MockMvc mvc; @Test public void exampleTest() throws Exception { // test } } </code></pre> <p><code>ApplicationTests.java</code></p> <pre><code>@RunWith(SpringRunner.class) @SpringBootTest @WebAppConfiguration //@DirtiesContext public class ApplicationTests { @Autowired Environment env; @Test public void contextLoads() { } } </code></pre>
0debug
static void ahci_start_transfer(IDEDMA *dma) { AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma); IDEState *s = &ad->port.ifs[0]; uint32_t size = (uint32_t)(s->data_end - s->data_ptr); uint16_t opts = le16_to_cpu(ad->cur_cmd->opts); int is_write = opts & AHCI_CMD_WRITE; int is_atapi = opts & AHCI_CMD_ATAPI; int has_sglist = 0; if (is_atapi && !ad->done_atapi_packet) { ad->done_atapi_packet = true; size = 0; goto out; } if (ahci_dma_prepare_buf(dma, is_write)) { has_sglist = 1; } DPRINTF(ad->port_no, "%sing %d bytes on %s w/%s sglist\n", is_write ? "writ" : "read", size, is_atapi ? "atapi" : "ata", has_sglist ? "" : "o"); if (has_sglist && size) { if (is_write) { dma_buf_write(s->data_ptr, size, &s->sg); } else { dma_buf_read(s->data_ptr, size, &s->sg); } } out: s->data_ptr = s->data_end; ahci_commit_buf(dma, size); s->end_transfer_func(s); if (!(s->status & DRQ_STAT)) { ahci_write_fis_pio(ad, le32_to_cpu(ad->cur_cmd->status)); } }
1threat