problem
stringlengths
26
131k
labels
class label
2 classes
static void s390_init_cpus(MachineState *machine) { MachineClass *mc = MACHINE_GET_CLASS(machine); int i; if (tcg_enabled() && max_cpus > 1) { error_report("Number of SMP CPUs requested (%d) exceeds max CPUs " "supported by TCG (1) on s390x", max_cpus); exit(1); } mc->possible_cpu_arch_ids(machine); for (i = 0; i < smp_cpus; i++) { s390x_new_cpu(machine->cpu_type, i, &error_fatal); } }
1threat
static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb) { const HEVCSPS *sps = s->ps.sps; int max_poc_lsb = 1 << sps->log2_max_poc_lsb; int prev_delta_msb = 0; unsigned int nb_sps = 0, nb_sh; int i; rps->nb_refs = 0; if (!sps->long_term_ref_pics_present_flag) return 0; if (sps->num_long_term_ref_pics_sps > 0) nb_sps = get_ue_golomb_long(gb); nb_sh = get_ue_golomb_long(gb); if (nb_sps > sps->num_long_term_ref_pics_sps) return AVERROR_INVALIDDATA; if (nb_sh + (uint64_t)nb_sps > FF_ARRAY_ELEMS(rps->poc)) return AVERROR_INVALIDDATA; rps->nb_refs = nb_sh + nb_sps; for (i = 0; i < rps->nb_refs; i++) { uint8_t delta_poc_msb_present; if (i < nb_sps) { uint8_t lt_idx_sps = 0; if (sps->num_long_term_ref_pics_sps > 1) lt_idx_sps = get_bits(gb, av_ceil_log2(sps->num_long_term_ref_pics_sps)); rps->poc[i] = sps->lt_ref_pic_poc_lsb_sps[lt_idx_sps]; rps->used[i] = sps->used_by_curr_pic_lt_sps_flag[lt_idx_sps]; } else { rps->poc[i] = get_bits(gb, sps->log2_max_poc_lsb); rps->used[i] = get_bits1(gb); } delta_poc_msb_present = get_bits1(gb); if (delta_poc_msb_present) { int delta = get_ue_golomb_long(gb); if (i && i != nb_sps) delta += prev_delta_msb; rps->poc[i] += s->poc - delta * max_poc_lsb - s->sh.pic_order_cnt_lsb; prev_delta_msb = delta; } } return 0; }
1threat
static void qtrle_decode_24bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change) { int rle_code; int pixel_ptr; int row_inc = s->frame.linesize[0]; unsigned char r, g, b; unsigned char *rgb = s->frame.data[0]; int pixel_limit = s->frame.linesize[0] * s->avctx->height; while (lines_to_change--) { CHECK_STREAM_PTR(2); pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 3; while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) { if (rle_code == 0) { CHECK_STREAM_PTR(1); pixel_ptr += (s->buf[stream_ptr++] - 1) * 3; } else if (rle_code < 0) { rle_code = -rle_code; CHECK_STREAM_PTR(3); r = s->buf[stream_ptr++]; g = s->buf[stream_ptr++]; b = s->buf[stream_ptr++]; CHECK_PIXEL_PTR(rle_code * 3); while (rle_code--) { rgb[pixel_ptr++] = r; rgb[pixel_ptr++] = g; rgb[pixel_ptr++] = b; } } else { CHECK_STREAM_PTR(rle_code * 3); CHECK_PIXEL_PTR(rle_code * 3); while (rle_code--) { rgb[pixel_ptr++] = s->buf[stream_ptr++]; rgb[pixel_ptr++] = s->buf[stream_ptr++]; rgb[pixel_ptr++] = s->buf[stream_ptr++]; } } } row_ptr += row_inc; } }
1threat
How to compile the JDK from sources? : <p>Is there a way to compile the JDK from sources? And is there an official download of the source? I want to compile it for my Smartphone.</p>
0debug
how to retrieve variables values from json using python : i have json file look like this. {"-Kh8M0qTdXJ-vBXr1G8v":{"email":"maad@yahoo.com","user":"amad"},"-Kh8M0v7KubmISGYrzks":{"email":"maad@yahoo.com","user":"amad"},"-KhB5OYsWias6j4Mc-pX":{"email":"faraz@yahoo.com","user":"faraz"},"-KhBBZ5Ii6kHPoUFhbj8":{"email":"zeeshan@gmail.com","user":"zeeshan"},"-KhBDTyGM9LaojajmtQv":{"email":"Ali@gmail.com","user":"Ali"}} and i want to print all email and user values. can any one help, how can i fetch these values from json by using python.
0debug
how i can extract output form cmd using java script : how i can extract an output from cmd and add it as var in javascript i wanna extract this value as an example "11675724" in the screenshot below <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> ar extract = function(string) { var o = {}; string.replace(/(.*?)=(.*?)(?:\|\||$)/g, function(all, key, value) { o[key] = value; }); return o; }; <!-- end snippet --> [enter image description here][1] [1]: https://i.stack.imgur.com/CwWCj.png
0debug
How to chatch this elemenet in BeautifulSoap? : I can not select this div, in the attached images I show you how I tried to select it. Please help me, this is a project for the university, it's very important :( thanks for your attention ;) https://ibb.co/bHxrff`1` https://ibb.co/ecJ8RL`2` https://ibb.co/cJuF6L`3`
0debug
Jbuttons swapping after period of time : - How can I swap two J buttons after period of time? I have a project in which I must swap more than 2 buttons after period of time.
0debug
void qmp_block_dirty_bitmap_remove(const char *node, const char *name, Error **errp) { AioContext *aio_context; BlockDriverState *bs; BdrvDirtyBitmap *bitmap; bitmap = block_dirty_bitmap_lookup(node, name, &bs, &aio_context, errp); if (!bitmap || !bs) { return; bdrv_dirty_bitmap_make_anon(bs, bitmap); bdrv_release_dirty_bitmap(bs, bitmap); aio_context_release(aio_context);
1threat
QPEL_H264(put_, PUT_OP, mmxext) QPEL_H264(avg_, AVG_MMXEXT_OP, mmxext) QPEL_H264_V_XMM(put_, PUT_OP, sse2) QPEL_H264_V_XMM(avg_,AVG_MMXEXT_OP, sse2) QPEL_H264_HV_XMM(put_, PUT_OP, sse2) QPEL_H264_HV_XMM(avg_,AVG_MMXEXT_OP, sse2) QPEL_H264_H_XMM(put_, PUT_OP, ssse3) QPEL_H264_H_XMM(avg_,AVG_MMXEXT_OP, ssse3) QPEL_H264_HV_XMM(put_, PUT_OP, ssse3) QPEL_H264_HV_XMM(avg_,AVG_MMXEXT_OP, ssse3) #undef PAVGB H264_MC_4816(mmxext) H264_MC_816(H264_MC_V, sse2) H264_MC_816(H264_MC_HV, sse2) H264_MC_816(H264_MC_H, ssse3) H264_MC_816(H264_MC_HV, ssse3) #define LUMA_MC_OP(OP, NUM, DEPTH, TYPE, OPT) \ void ff_ ## OP ## _h264_qpel ## NUM ## _ ## TYPE ## _ ## DEPTH ## _ ## OPT \ (uint8_t *dst, uint8_t *src, int stride); #define LUMA_MC_ALL(DEPTH, TYPE, OPT) \ LUMA_MC_OP(put, 4, DEPTH, TYPE, OPT) \ LUMA_MC_OP(avg, 4, DEPTH, TYPE, OPT) \ LUMA_MC_OP(put, 8, DEPTH, TYPE, OPT) \ LUMA_MC_OP(avg, 8, DEPTH, TYPE, OPT) \ LUMA_MC_OP(put, 16, DEPTH, TYPE, OPT) \ LUMA_MC_OP(avg, 16, DEPTH, TYPE, OPT) #define LUMA_MC_816(DEPTH, TYPE, OPT) \ LUMA_MC_OP(put, 8, DEPTH, TYPE, OPT) \ LUMA_MC_OP(avg, 8, DEPTH, TYPE, OPT) \ LUMA_MC_OP(put, 16, DEPTH, TYPE, OPT) \ LUMA_MC_OP(avg, 16, DEPTH, TYPE, OPT) LUMA_MC_ALL(10, mc00, mmxext) LUMA_MC_ALL(10, mc10, mmxext) LUMA_MC_ALL(10, mc20, mmxext) LUMA_MC_ALL(10, mc30, mmxext) LUMA_MC_ALL(10, mc01, mmxext) LUMA_MC_ALL(10, mc11, mmxext) LUMA_MC_ALL(10, mc21, mmxext) LUMA_MC_ALL(10, mc31, mmxext) LUMA_MC_ALL(10, mc02, mmxext) LUMA_MC_ALL(10, mc12, mmxext) LUMA_MC_ALL(10, mc22, mmxext) LUMA_MC_ALL(10, mc32, mmxext) LUMA_MC_ALL(10, mc03, mmxext) LUMA_MC_ALL(10, mc13, mmxext) LUMA_MC_ALL(10, mc23, mmxext) LUMA_MC_ALL(10, mc33, mmxext) LUMA_MC_816(10, mc00, sse2) LUMA_MC_816(10, mc10, sse2) LUMA_MC_816(10, mc10, sse2_cache64) LUMA_MC_816(10, mc10, ssse3_cache64) LUMA_MC_816(10, mc20, sse2) LUMA_MC_816(10, mc20, sse2_cache64) LUMA_MC_816(10, mc20, ssse3_cache64) LUMA_MC_816(10, mc30, sse2) LUMA_MC_816(10, mc30, sse2_cache64) LUMA_MC_816(10, mc30, ssse3_cache64) LUMA_MC_816(10, mc01, sse2) LUMA_MC_816(10, mc11, sse2) LUMA_MC_816(10, mc21, sse2) LUMA_MC_816(10, mc31, sse2) LUMA_MC_816(10, mc02, sse2) LUMA_MC_816(10, mc12, sse2) LUMA_MC_816(10, mc22, sse2) LUMA_MC_816(10, mc32, sse2) LUMA_MC_816(10, mc03, sse2) LUMA_MC_816(10, mc13, sse2) LUMA_MC_816(10, mc23, sse2) LUMA_MC_816(10, mc33, sse2) #define QPEL16_OPMC(OP, MC, MMX)\ void ff_ ## OP ## _h264_qpel16_ ## MC ## _10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst , src , stride);\ ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst+16, src+16, stride);\ src += 8*stride;\ dst += 8*stride;\ ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst , src , stride);\ ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst+16, src+16, stride);\ } #define QPEL16_OP(MC, MMX)\ QPEL16_OPMC(put, MC, MMX)\ QPEL16_OPMC(avg, MC, MMX) #define QPEL16(MMX)\ QPEL16_OP(mc00, MMX)\ QPEL16_OP(mc01, MMX)\ QPEL16_OP(mc02, MMX)\ QPEL16_OP(mc03, MMX)\ QPEL16_OP(mc10, MMX)\ QPEL16_OP(mc11, MMX)\ QPEL16_OP(mc12, MMX)\ QPEL16_OP(mc13, MMX)\ QPEL16_OP(mc20, MMX)\ QPEL16_OP(mc21, MMX)\ QPEL16_OP(mc22, MMX)\ QPEL16_OP(mc23, MMX)\ QPEL16_OP(mc30, MMX)\ QPEL16_OP(mc31, MMX)\ QPEL16_OP(mc32, MMX)\ QPEL16_OP(mc33, MMX) #if ARCH_X86_32 && HAVE_YASM && CONFIG_H264QPEL QPEL16(mmxext) #endif #endif #define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU, PREFIX) \ do { \ c->PFX ## _pixels_tab[IDX][ 0] = PREFIX ## PFX ## SIZE ## _mc00_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 1] = PREFIX ## PFX ## SIZE ## _mc10_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 2] = PREFIX ## PFX ## SIZE ## _mc20_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 3] = PREFIX ## PFX ## SIZE ## _mc30_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 4] = PREFIX ## PFX ## SIZE ## _mc01_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 5] = PREFIX ## PFX ## SIZE ## _mc11_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 6] = PREFIX ## PFX ## SIZE ## _mc21_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 7] = PREFIX ## PFX ## SIZE ## _mc31_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 8] = PREFIX ## PFX ## SIZE ## _mc02_ ## CPU; \ c->PFX ## _pixels_tab[IDX][ 9] = PREFIX ## PFX ## SIZE ## _mc12_ ## CPU; \ c->PFX ## _pixels_tab[IDX][10] = PREFIX ## PFX ## SIZE ## _mc22_ ## CPU; \ c->PFX ## _pixels_tab[IDX][11] = PREFIX ## PFX ## SIZE ## _mc32_ ## CPU; \ c->PFX ## _pixels_tab[IDX][12] = PREFIX ## PFX ## SIZE ## _mc03_ ## CPU; \ c->PFX ## _pixels_tab[IDX][13] = PREFIX ## PFX ## SIZE ## _mc13_ ## CPU; \ c->PFX ## _pixels_tab[IDX][14] = PREFIX ## PFX ## SIZE ## _mc23_ ## CPU; \ c->PFX ## _pixels_tab[IDX][15] = PREFIX ## PFX ## SIZE ## _mc33_ ## CPU; \ } while (0) #define H264_QPEL_FUNCS(x, y, CPU) \ do { \ c->put_h264_qpel_pixels_tab[0][x + y * 4] = put_h264_qpel16_mc ## x ## y ## _ ## CPU; \ c->put_h264_qpel_pixels_tab[1][x + y * 4] = put_h264_qpel8_mc ## x ## y ## _ ## CPU; \ c->avg_h264_qpel_pixels_tab[0][x + y * 4] = avg_h264_qpel16_mc ## x ## y ## _ ## CPU; \ c->avg_h264_qpel_pixels_tab[1][x + y * 4] = avg_h264_qpel8_mc ## x ## y ## _ ## CPU; \ } while (0) #define H264_QPEL_FUNCS_10(x, y, CPU) \ do { \ c->put_h264_qpel_pixels_tab[0][x + y * 4] = ff_put_h264_qpel16_mc ## x ## y ## _10_ ## CPU; \ c->put_h264_qpel_pixels_tab[1][x + y * 4] = ff_put_h264_qpel8_mc ## x ## y ## _10_ ## CPU; \ c->avg_h264_qpel_pixels_tab[0][x + y * 4] = ff_avg_h264_qpel16_mc ## x ## y ## _10_ ## CPU; \ c->avg_h264_qpel_pixels_tab[1][x + y * 4] = ff_avg_h264_qpel8_mc ## x ## y ## _10_ ## CPU; \ } while (0) void ff_h264qpel_init_x86(H264QpelContext *c, int bit_depth) { int high_bit_depth = bit_depth > 8; int mm_flags = av_get_cpu_flags(); #if HAVE_MMXEXT_EXTERNAL if (!high_bit_depth) { SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmxext, ); SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmxext, ); SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmxext, ); SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, mmxext, ); SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmxext, ); SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmxext, ); } else if (bit_depth == 10) { #if !ARCH_X86_64 SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 10_mmxext, ff_); SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 10_mmxext, ff_); SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 10_mmxext, ff_); SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 10_mmxext, ff_); #endif SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 10_mmxext, ff_); SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 10_mmxext, ff_); } #endif #if HAVE_SSE2_EXTERNAL if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW) && !high_bit_depth) { H264_QPEL_FUNCS(0, 0, sse2); } if (!high_bit_depth) { H264_QPEL_FUNCS(0, 1, sse2); H264_QPEL_FUNCS(0, 2, sse2); H264_QPEL_FUNCS(0, 3, sse2); H264_QPEL_FUNCS(1, 1, sse2); H264_QPEL_FUNCS(1, 2, sse2); H264_QPEL_FUNCS(1, 3, sse2); H264_QPEL_FUNCS(2, 1, sse2); H264_QPEL_FUNCS(2, 2, sse2); H264_QPEL_FUNCS(2, 3, sse2); H264_QPEL_FUNCS(3, 1, sse2); H264_QPEL_FUNCS(3, 2, sse2); H264_QPEL_FUNCS(3, 3, sse2); } if (bit_depth == 10) { SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 10_sse2, ff_); SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 10_sse2, ff_); SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 10_sse2, ff_); SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 10_sse2, ff_); H264_QPEL_FUNCS_10(1, 0, sse2_cache64); H264_QPEL_FUNCS_10(2, 0, sse2_cache64); H264_QPEL_FUNCS_10(3, 0, sse2_cache64); } #endif #if HAVE_SSSE3_EXTERNAL if (!high_bit_depth) { H264_QPEL_FUNCS(1, 0, ssse3); H264_QPEL_FUNCS(1, 1, ssse3); H264_QPEL_FUNCS(1, 2, ssse3); H264_QPEL_FUNCS(1, 3, ssse3); H264_QPEL_FUNCS(2, 0, ssse3); H264_QPEL_FUNCS(2, 1, ssse3); H264_QPEL_FUNCS(2, 2, ssse3); H264_QPEL_FUNCS(2, 3, ssse3); H264_QPEL_FUNCS(3, 0, ssse3); H264_QPEL_FUNCS(3, 1, ssse3); H264_QPEL_FUNCS(3, 2, ssse3); H264_QPEL_FUNCS(3, 3, ssse3); } if (bit_depth == 10) { H264_QPEL_FUNCS_10(1, 0, ssse3_cache64); H264_QPEL_FUNCS_10(2, 0, ssse3_cache64); H264_QPEL_FUNCS_10(3, 0, ssse3_cache64); } #endif #if HAVE_AVX_EXTERNAL if (bit_depth == 10) { H264_QPEL_FUNCS_10(1, 0, sse2); H264_QPEL_FUNCS_10(2, 0, sse2); H264_QPEL_FUNCS_10(3, 0, sse2); } #endif }
1threat
Java and enum [Novice] : <p>I've got ome fail in java enums;</p> <p>I'd like to have individual id number for specified enum created, but number seems to propagate to next enum object unfortunately. Look at my case:</p> <pre><code>enum type{ int i;} int id=1; type t1.i=id; id=2; type t2.i=id; </code></pre> <p>But t1 has got t2 id number, but I want to have different id's.</p> <p>Is there any solution in this case ?</p> <p>I inform that it's simplification of my case and I can't change enum type to class.</p>
0debug
How to use sample() in R : <p>Suppose that there is a bag of 20 marbles, 12 white (“1”) and 8 black “0”. Using the sample() function create a sample of size n=5 without replacement.</p> <p>RStudio always tell me that there is an error that cannot take a sample larger than the population when 'replace = FALSE'</p>
0debug
static coroutine_fn int qcow2_co_pdiscard(BlockDriverState *bs, int64_t offset, int count) { int ret; BDRVQcow2State *s = bs->opaque; if (!QEMU_IS_ALIGNED(offset | count, s->cluster_size)) { assert(count < s->cluster_size); if (!QEMU_IS_ALIGNED(offset, s->cluster_size) || offset + count != bs->total_sectors * BDRV_SECTOR_SIZE) { return -ENOTSUP; } } qemu_co_mutex_lock(&s->lock); ret = qcow2_discard_clusters(bs, offset, count >> BDRV_SECTOR_BITS, QCOW2_DISCARD_REQUEST, false); qemu_co_mutex_unlock(&s->lock); return ret; }
1threat
static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp) { ISADevice *d = ISA_DEVICE(dev); PVPanicState *s = ISA_PVPANIC_DEVICE(dev); static bool port_configured; FWCfgState *fw_cfg; isa_register_ioport(d, &s->io, s->ioport); if (!port_configured) { fw_cfg = fw_cfg_find(); if (fw_cfg) { fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", g_memdup(&s->ioport, sizeof(s->ioport)), sizeof(s->ioport)); port_configured = true; } } }
1threat
Matching lines in a text-file with a starting identifer : <p>So I'm a bit stumped on this, I'm reading a file with two types of lines that contain data, and they are started by a number followed by a comma. I need a way in order to match the lines with the same starting digit into a single line and output that. How would I even get started?</p>
0debug
Print all surrounding coordinates given an X and Y : <p>I want to make a function that given a list and a range:</p> <pre><code>coordinate=[x,y] </code></pre> <p>Creates a list that contains all integer points in range. For example,</p> <pre><code>coordinate=[0,0] range=1 </code></pre> <p>Would return</p> <pre><code>[[-1,1],[0,1],[1,1],[-1,0],[0,0],[0,1],[-1,-1],[0,-1],[1,-1]] </code></pre> <p>Likewise for range 2 would return</p> <pre><code>[[-2,2],[-1,2],[0,2]...] </code></pre>
0debug
How to send an SMS with custom sender ID with Amazon SNS and Python and boto3 : <p>The <a href="http://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html#sms_publish_sdk">documentation</a> suggests to use message attributes for that but I can't seem to figure out what attribute name to use.</p> <p>This works so far:</p> <pre><code>sns = boto3.client('sns', region_name='eu-west-1') sns.publish( PhoneNumber='+491701234567', Message='hi there', MessageAttributes={ 'AWS.SNS.SMS.SenderID': { 'DataType': 'String', 'StringValue': 'MySenderID' } } ) </code></pre> <p>The SMS is delivered but with some (random?) value in the sender id field. So it seems my setting of message attributes is silently ignored. What is the correct way to set a custom sender id?</p>
0debug
Sparql Select all diffirent languages appear on Warehouse : I am trying to select all diffirent language that appear on warehouse to display them as a list, but with no luck until now. Is there any way to select languages efficiently? Any idea ? Thanks in advance.
0debug
How to read Cell if it has two dashes (-) in it? : <p>I am trying to read the cell and see if the invoice number has two dashes (-).</p> <p>So for example:</p> <p>4-2949493</p> <p>4-9390023-1</p> <pre><code>If (e.Row.RowType = DataControlRowType.DataRow) Then If (e.Row.Cells(1).Text.ToString = (TWO DASHES) Then Else End If End If </code></pre> <p>How would I check to see if it has two dashes? The invoice length changes every time too.</p>
0debug
Cuda: library nvvm not found : <p>I am trying to run the code below but an error is reported:</p> <p><strong>NvvmSupportError: libNVVM cannot be found. Do <code>conda install cudatoolkit</code>: library nvvm not found</strong></p> <p>My development environment is: Ubuntu 17.04, Spyder/Python3.5 and I have installed via conda (numba and cudatoolkit). Nvidia GPUs (GTX 1070 and GTX 1060).</p> <pre><code>import numpy as np from timeit import default_timer as timer from numba import vectorize @vectorize(["float32(float32, float32)"], target='cuda') def VecADD(a,b): return a+b n = 32000000 a = np.ones (n, dtype=np.float32) b = np.ones (n, dtype=np.float32) c = np.zeros(n, dtype=np.float32) start = timer() C = VecADD(a,b) print (timer() - start) </code></pre> <p>Does anyone know how to solve this problem?</p>
0debug
how to compare two columns in pandas to make a third column ? : <p>i have two columns age and sex in a pandas dataframe </p> <pre><code>sex = ['m', 'f' , 'm', 'f', 'f', 'f', 'f'] age = [16 , 15 , 14 , 9 , 8 , 2 , 56 ] </code></pre> <p>now i want to extract a third column : like this if age &lt;=9 then output ' child' and if age >9 then output the respective gender </p> <pre><code>sex = ['m', 'f' , 'm','f' ,'f' ,'f' , 'f'] age = [16 , 15 , 14 , 9 , 8 , 2 , 56 ] yes = ['m', 'f' ,'m' ,'child','child','child','f' ] </code></pre> <p>please help ps . i am still working on it if i get anything i will immediately update </p>
0debug
How to set image width to be 100% and height to be auto in react native? : <p>I am trying to display list of images in a scrollview. Width should be 100%, while height should be automatic, keeping aspect ratio.</p> <p>The searches I did pointed to various solutions which give fullscreen background style.</p> <pre><code>const styles = StyleSheet.create({ image: { width: null, height: 300, resizeMode: 'cover' } }); &lt;ScrollView style={{flex: 1}}&gt; &lt;Image style={styles.image} source={require('../../../images/collection-imag1.png')}/&gt; &lt;Image style={styles.image} source={require('../../../images/collection-imag2.png')}/&gt; &lt;/ScrollView&gt; </code></pre> <p>I have tried various combinations of width: null, height: null, flex: 1, alignSelf etc. The above solution is almost working, except the height is not dynamic. Parts of the image are not visible.</p>
0debug
Include files without #include : <p>it is possible to include headers files intro visual studio wihtout <code>#include</code> preprocessor ? </p> <p>I mean, i have a .cpp intro a visual studio project, and i don't want to use #include intro header file or source file. I want to be included automatically.</p> <p>I mean some Windows header files are included automatically.. Soo i think is possible with files from my project too..</p> <p>Best regards.</p>
0debug
static void test_bmdma_one_sector_short_prdt(void) { QPCIDevice *dev; void *bmdma_base, *ide_base; uint8_t status; PrdtEntry prdt[] = { { .addr = 0, .size = cpu_to_le32(0x200 | PRDT_EOT), }, }; dev = get_pci_device(&bmdma_base, &ide_base); status = send_dma_request(CMD_READ_DMA, 0, 2, prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, 0); assert_bit_clear(qpci_io_readb(dev, ide_base + reg_status), DF | ERR); status = send_dma_request(CMD_READ_DMA | CMDF_ABORT, 0, 2, prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, 0); assert_bit_clear(qpci_io_readb(dev, ide_base + reg_status), DF | ERR); }
1threat
I am trying to create a pattern using java which looks something like picture below. can someone please correct tell me whats the wrong with my code : [enter image description here][1] package welcome; import java.util.Scanner; public class Welcome { public static void main(String args[]) { Scanner sc= new Scanner(System.in); System.out.println("enter the rows"); int rows= sc.nextInt(); System.out.println("here is the pattern"); int i, j, k=1; for(i=1; i<=rows; i++) { for(j=1; j<=k; j++) { System.out.print("* " +j); } k = k + 2; System.out.println(); } } } [1]: https://i.stack.imgur.com/SSlzW.jpg results are something like this here is the pattern * 1 * 1* 2* 3 * 1* 2* 3* 4* 5 * 1* 2* 3* 4* 5* 6* 7 * 1* 2* 3* 4* 5* 6* 7* 8* 9
0debug
CircleCI 2.0 SSH debug: Failed to enable SSH, No SSH key is found : <p>Config:</p> <ul> <li>CircleCI 2.0</li> <li>Bitbucket private repo</li> </ul> <p>After I click on "Rebuild with SSH", the "Enable SSH" section outputs</p> <blockquote> <p>Failed to enable SSH No SSH key is found. Please make sure you've added at least one SSH key in your VCS account.</p> </blockquote> <p>What does this mean? How do I fix this?</p>
0debug
static int decode_plane(UtvideoContext *c, int plane_no, uint8_t *dst, int step, int stride, int width, int height, const uint8_t *src, int src_size, int use_pred) { int i, j, slice, pix; int sstart, send; VLC vlc; GetBitContext gb; int prev; const int cmask = ~(!plane_no && c->avctx->pix_fmt == PIX_FMT_YUV420P); if (build_huff(src, &vlc)) { av_log(c->avctx, AV_LOG_ERROR, "Cannot build Huffman codes\n"); return AVERROR_INVALIDDATA; } src += 256; src_size -= 256; send = 0; for (slice = 0; slice < c->slices; slice++) { uint8_t *dest; int slice_data_start, slice_data_end, slice_size; sstart = send; send = (height * (slice + 1) / c->slices) & cmask; dest = dst + sstart * stride; slice_data_start = slice ? AV_RL32(src + slice * 4 - 4) : 0; slice_data_end = AV_RL32(src + slice * 4); slice_size = slice_data_end - slice_data_start; if (!slice_size) { for (j = sstart; j < send; j++) { for (i = 0; i < width * step; i += step) dest[i] = 0x80; dest += stride; } continue; } memcpy(c->slice_bits, src + slice_data_start + c->slices * 4, slice_size); memset(c->slice_bits + slice_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); c->dsp.bswap_buf((uint32_t*)c->slice_bits, (uint32_t*)c->slice_bits, (slice_data_end - slice_data_start + 3) >> 2); init_get_bits(&gb, c->slice_bits, slice_size * 8); prev = 0x80; for (j = sstart; j < send; j++) { for (i = 0; i < width * step; i += step) { if (get_bits_left(&gb) <= 0) { av_log(c->avctx, AV_LOG_ERROR, "Slice decoding ran out of bits\n"); goto fail; } pix = get_vlc2(&gb, vlc.table, vlc.bits, 4); if (pix < 0) { av_log(c->avctx, AV_LOG_ERROR, "Decoding error\n"); goto fail; } if (use_pred) { prev += pix; pix = prev; } dest[i] = pix; } dest += stride; } if (get_bits_left(&gb) > 32) av_log(c->avctx, AV_LOG_WARNING, "%d bits left after decoding slice\n", get_bits_left(&gb)); } free_vlc(&vlc); return 0; fail: free_vlc(&vlc); return AVERROR_INVALIDDATA; }
1threat
What does "spec" mean in Javascript Testing : <p>I'm fairly new to the Javascript world (coming from Android) so I've been reading up on how to setup Mocha/Jasmine to get my test environment in place. I've noticed a convention of "spec" in reference to test directories, file suffix, suite names, and/or tests/assertions. </p> <p>Is this specific to testing in Javascript? And what does "spec" actually stand for? Specification, Expectation, or ?</p>
0debug
What to return from collectionView(_:viewForSupplementaryElementOfKind:at:) when you want to return nothing? : <p>I have a UICollectionView that has section headers, but not section footers. As such, I don't have a defined footer view. <a href="https://developer.apple.com/documentation/uikit/uicollectionviewdatasource/1618037-collectionview" rel="noreferrer">Apple's documentation</a> states that <code>You must not return nil from this method.</code> </p> <pre><code>func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -&gt; UICollectionReusableView { switch kind { case UICollectionElementKindSectionHeader: let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "MyHeaderView", for: indexPath) as! MyHeaderView switch indexPath.section { case 0: headerView.label_title.text = "SOME HEADER" case 1: headerView.label_title.text = "ANOTHER HEADER" default: headerView.label_title.text = "UNKNOWN HEADER" } return headerView default: assert(false, "Unexpected element kind") // Not a good idea either } return nil // NOPE, not allowed } </code></pre>
0debug
Stack has not been tested with GHC & Cabal versions : <p>In my Haskell project when I <code>stack run</code>, it is showing the following, but still runs. What warning is this? How can I get rid of it?</p> <pre><code>Stack has not been tested with GHC versions above 8.6, and using 8.8.2, this may fail Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail </code></pre>
0debug
static inline void gen_evmwsmi(DisasContext *ctx) { TCGv_i64 t0, t1; if (unlikely(!ctx->spe_enabled)) { gen_exception(ctx, POWERPC_EXCP_APU); return; } t0 = tcg_temp_new_i64(); t1 = tcg_temp_new_i64(); #if defined(TARGET_PPC64) tcg_gen_ext32s_tl(t0, cpu_gpr[rA(ctx->opcode)]); tcg_gen_ext32s_tl(t1, cpu_gpr[rB(ctx->opcode)]); #else tcg_gen_ext_tl_i64(t0, cpu_gpr[rA(ctx->opcode)]); tcg_gen_ext_tl_i64(t1, cpu_gpr[rB(ctx->opcode)]); #endif tcg_gen_mul_i64(t0, t0, t1); gen_store_gpr64(rD(ctx->opcode), t0); tcg_temp_free_i64(t0); tcg_temp_free_i64(t1); }
1threat
connecting html and css files in flask web app in pycharm : <p>I am trying to connect html and css files in flask app (pycharm ide) but not getting as how to do this.Here is the screenshot <a href="https://i.stack.imgur.com/6YpKW.png" rel="nofollow noreferrer">image link</a></p>
0debug
Runtime exception while table creation in SQLite(Create table has stoped) : > This is my on create DatabaseHelper calss public class DatabaseHelper extends SQLiteOpenHelper { public static final String DATABAE_NAME = "Student.db"; public static final String TABLE_NAME= "Student_table"; public static final String COL_1="ID"; public static final String COL_2="NAMME"; public static final String COL_3="SURNAME"; public static final String COL_4="MARKS"; public DatabaseHelper(Context context) { super(context, DATABAE_NAME, null, 1); SQLiteDatabase db=this.getWritableDatabase(); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL("create table" + TABLE_NAME+" (ID INTEGER PRIMARY KEY ,NAME TEXT,SURNAME TEXT,MARKS INTEGER)"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS"+TABLE_NAME); onCreate(db); } } > this is my main class public class MainActivity extends AppCompatActivity { DatabaseHelper myDB; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); myDB =new DatabaseHelper(this); } } > This is logcat 10-11 15:34:25.793 3807-3807/user_profile.createtable E/AndroidRuntime: FATAL EXCEPTION: main Process: user_profile.createtable, PID: 3807 java.lang.RuntimeException: Unable to start activity ComponentInfo{user_profile.createtable/user_profile.createtable.MainActivity}: android.database.sqlite.SQLiteException: near "tableStudent_table": syntax error (code 1): , while compiling: create tableStudent_table (ID INTEGER PRIMARY KEY ,NAME TEXT,SURNAME TEXT,MARKS INTEGER) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2339) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413) at android.app.ActivityThread.access$800(ActivityThread.java:155) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5343) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) Caused by: android.database.sqlite.SQLiteException: near "tableStudent_table": syntax error (code 1): , while compiling: create tableStudent_table (ID INTEGER PRIMARY KEY ,NAME TEXT,SURNAME TEXT,MARKS INTEGER) at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889) at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500) at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58) at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31) at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1674) at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1605) at user_profile.createtable.DatabaseHelper.onCreate(DatabaseHelper.java:26) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163) at user_profile.createtable.DatabaseHelper.<init>(DatabaseHelper.java:21) at user_profile.createtable.MainActivity.onCreate(MainActivity.java:13) at android.app.Activity.performCreate(Activity.java:6010) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)  at android.app.ActivityThread.access$800(ActivityThread.java:155)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5343)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)  10-11 15:39:26.133 3807-3807/user_profile.createtable I/Process: Sending signal. PID: 3807 SIG: 9
0debug
int kvm_cpu_exec(CPUState *cpu) { struct kvm_run *run = cpu->kvm_run; int ret, run_ret; DPRINTF("kvm_cpu_exec()\n"); if (kvm_arch_process_async_events(cpu)) { cpu->exit_request = 0; return EXCP_HLT; } do { MemTxAttrs attrs; if (cpu->kvm_vcpu_dirty) { kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE); cpu->kvm_vcpu_dirty = false; } kvm_arch_pre_run(cpu, run); if (cpu->exit_request) { DPRINTF("interrupt exit requested\n"); qemu_cpu_kick_self(); } qemu_mutex_unlock_iothread(); run_ret = kvm_vcpu_ioctl(cpu, KVM_RUN, 0); qemu_mutex_lock_iothread(); attrs = kvm_arch_post_run(cpu, run); if (run_ret < 0) { if (run_ret == -EINTR || run_ret == -EAGAIN) { DPRINTF("io window exit\n"); ret = EXCP_INTERRUPT; break; } fprintf(stderr, "error: kvm run failed %s\n", strerror(-run_ret)); #ifdef TARGET_PPC if (run_ret == -EBUSY) { fprintf(stderr, "This is probably because your SMT is enabled.\n" "VCPU can only run on primary threads with all " "secondary threads offline.\n"); } #endif ret = -1; break; } trace_kvm_run_exit(cpu->cpu_index, run->exit_reason); switch (run->exit_reason) { case KVM_EXIT_IO: DPRINTF("handle_io\n"); kvm_handle_io(run->io.port, attrs, (uint8_t *)run + run->io.data_offset, run->io.direction, run->io.size, run->io.count); ret = 0; break; case KVM_EXIT_MMIO: DPRINTF("handle_mmio\n"); address_space_rw(&address_space_memory, run->mmio.phys_addr, attrs, run->mmio.data, run->mmio.len, run->mmio.is_write); ret = 0; break; case KVM_EXIT_IRQ_WINDOW_OPEN: DPRINTF("irq_window_open\n"); ret = EXCP_INTERRUPT; break; case KVM_EXIT_SHUTDOWN: DPRINTF("shutdown\n"); qemu_system_reset_request(); ret = EXCP_INTERRUPT; break; case KVM_EXIT_UNKNOWN: fprintf(stderr, "KVM: unknown exit, hardware reason %" PRIx64 "\n", (uint64_t)run->hw.hardware_exit_reason); ret = -1; break; case KVM_EXIT_INTERNAL_ERROR: ret = kvm_handle_internal_error(cpu, run); break; case KVM_EXIT_SYSTEM_EVENT: switch (run->system_event.type) { case KVM_SYSTEM_EVENT_SHUTDOWN: qemu_system_shutdown_request(); ret = EXCP_INTERRUPT; break; case KVM_SYSTEM_EVENT_RESET: qemu_system_reset_request(); ret = EXCP_INTERRUPT; break; default: DPRINTF("kvm_arch_handle_exit\n"); ret = kvm_arch_handle_exit(cpu, run); break; } break; default: DPRINTF("kvm_arch_handle_exit\n"); ret = kvm_arch_handle_exit(cpu, run); break; } } while (ret == 0); if (ret < 0) { cpu_dump_state(cpu, stderr, fprintf, CPU_DUMP_CODE); vm_stop(RUN_STATE_INTERNAL_ERROR); } cpu->exit_request = 0; return ret; }
1threat
static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) { QObject *req, *rsp = NULL, *id = NULL; QDict *qdict = NULL; const char *cmd_name; Monitor *mon = cur_mon; Error *err = NULL; req = json_parser_parse_err(tokens, NULL, &err); if (!req && !err) { error_setg(&err, QERR_JSON_PARSING); } if (err) { goto err_out; } qdict = qmp_check_input_obj(req, &err); if (!qdict) { goto err_out; } id = qdict_get(qdict, "id"); qobject_incref(id); qdict_del(qdict, "id"); cmd_name = qdict_get_str(qdict, "execute"); trace_handle_qmp_command(mon, cmd_name); rsp = qmp_dispatch(cur_mon->qmp.commands, req); if (mon->qmp.commands == &qmp_cap_negotiation_commands) { qdict = qdict_get_qdict(qobject_to_qdict(rsp), "error"); if (qdict && !g_strcmp0(qdict_get_try_str(qdict, "class"), QapiErrorClass_lookup[ERROR_CLASS_COMMAND_NOT_FOUND])) { qdict_del(qdict, "desc"); qdict_put(qdict, "desc", qstring_from_str("Expecting capabilities negotiation" " with 'qmp_capabilities'")); } } err_out: if (err) { qdict = qdict_new(); qdict_put_obj(qdict, "error", qmp_build_error_object(err)); error_free(err); rsp = QOBJECT(qdict); } if (rsp) { if (id) { qdict_put_obj(qobject_to_qdict(rsp), "id", id); id = NULL; } monitor_json_emitter(mon, rsp); } qobject_decref(id); qobject_decref(rsp); qobject_decref(req); }
1threat
How to make item pairs from the same big list in python : <p>For example: [0,1,2,3] expected results [0,1], [0,2], [0,3], [1,2], [1,3], [2,3]</p>
0debug
How do i stream response in express : <p>I've been trying to get a express app to send the response as stream.</p> <pre><code>var Readable = require('stream').Readable; var rs = Readable(); app.get('/report', function(req,res) { res.statusCode = 200; res.setHeader('Content-type', 'application/csv'); res.setHeader('Access-Control-Allow-Origin', '*'); // Header to force download res.setHeader('Content-disposition', 'attachment; filename=Report.csv'); rs.pipe(res); rs.push("USERID,NAME,FBID,ACCOUNT,SUBSCRIPTION,PRICE,STATE,TIMEPERIOD\n"); for (var i = 0; i &lt; 10; i++) { rs.push("23,John Doe,1234,500,SUBSCRIPITON,100,ACTIVE,30\n"); } rs.push(null); }); </code></pre> <p>It does print in the console when i replace "rs.pipe(res)" by "rs.pipe(process.stdout)" but how to make it work in express app.</p> <pre><code>Error: not implemented at Readable._read (_stream_readable.js:465:22) at Readable.read (_stream_readable.js:341:10) at Readable.on (_stream_readable.js:720:14) at Readable.pipe (_stream_readable.js:575:10) at line "rs.pipe(res);" </code></pre>
0debug
Is there an equivalent of "tools:layout=" for FragmentContainerView? : <p>In order to be able to see the content of a certain view inside a fragment when previewing a layout in Android Studio, it is possible to do <a href="https://developer.android.com/studio/write/tool-attributes#toolslayout" rel="noreferrer">this</a>:</p> <pre class="lang-xml prettyprint-override"><code>&lt;MainLayoutView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"&gt; &lt;fragment ... tools:layout="@layout/my_fragment_view"/&gt; &lt;/MainLayoutView&gt; </code></pre> <p>However, if you switch from <code>fragment</code> to <code>androidx.fragment.app.FragmentContainerView</code>, this handy tool stops working and the fragment just appears blank on the preview screen.</p> <p>Is there any way to show content inside a <code>FragmentContainerView</code> when previewing it in a layout in Android Studio?</p>
0debug
Rename a Project in Visual Studio 2017 : <p>I have a Solution in Visual Studio 2017 and one of the Projects is an ASP.NET Web Forms application. How can I rename the Project? I changed the name in the .sln file but within the IDE it is still showing the old name. The folder name matches the required name.</p>
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
void ff_put_h264_qpel4_mc12_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_midh_qrt_4w_msa(src - (2 * stride) - 2, stride, dst, stride, 4, 0); }
1threat
int vhost_net_start(struct vhost_net *net, VirtIODevice *dev) { struct vhost_vring_file file = { }; int r; if (net->dev.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) { tap_set_vnet_hdr_len(net->vc, sizeof(struct virtio_net_hdr_mrg_rxbuf)); } net->dev.nvqs = 2; net->dev.vqs = net->vqs; r = vhost_dev_start(&net->dev, dev); if (r < 0) { return r; } net->vc->info->poll(net->vc, false); qemu_set_fd_handler(net->backend, NULL, NULL, NULL); file.fd = net->backend; for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file); if (r < 0) { r = -errno; goto fail; } } return 0; fail: file.fd = -1; while (--file.index >= 0) { int r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file); assert(r >= 0); } net->vc->info->poll(net->vc, true); vhost_dev_stop(&net->dev, dev); if (net->dev.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) { tap_set_vnet_hdr_len(net->vc, sizeof(struct virtio_net_hdr)); } return r; }
1threat
Importing Date to R? : <p>I have a dataset including a date column in the format of " yyyy-mm-dd", however, when I import it to R, some random numbers come up. How can I solve this issue?</p> <p>Many thanks. </p>
0debug
Is changing JS code by user is bad thing? : <p>I'm building a recent portal based on Drupal 8.6 as API and Vue.js as SPA.I do for now tones of research about OAuth authentication security etc, but i can't stop thinking about user changing code by Developer Tools. </p> <p>I not worried about data leak, because this should be secured on a backed as well, but what if user change isLogin() to always true and see for example logged user HTML template.</p> <p>Is there some steps I should take and this is real problem or this problem is big only in my head, and this is way that it works ?</p> <p>Thanks! </p>
0debug
I want to set data from following table group by Weeks in SQL. : Date Amount Product 2018-10-25 05:27:35.9070422 1000 P1 2018-10-18 05:27:35.9070422 2000 P2 2018-10-2 05:27:35.9070422 3050 P3 2018-10-10 05:27:35.9070422 1000 P4 2018-10-5 05:27:35.9070422 1000 P5 Let suppose today is 26-05-18 So my result should look like this. Week Amount 1 4050 2 1000 3 2000 4 1000
0debug
Django; AWS Elastic Beanstalk ERROR: Your WSGIPath refers to a file that does not exist : <p>I am using this tutorial: <a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html" rel="noreferrer">http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html</a></p> <p>I create the <code>.ebextensions</code> directory inside the root directory, and put this <code>django.config</code> file in it:</p> <pre><code>option_settings: aws:elasticbeanstalk:container:python: WSGIPath: mysite/wsgi.py </code></pre> <p>I've also tried setting the path to <code>mysite/mysite/wsgi.py</code> because I saw that work somewhere but it did not help me. </p> <p>Everywhere I look shows a different <code>.config</code> file with different arrangements, and I don't know where to go from here. How can I properly set my WSGIPath in Elastic Beanstalk?</p>
0debug
static QObject *parse_array(JSONParserContext *ctxt, va_list *ap) { QList *list = NULL; QObject *token, *peek; token = parser_context_pop_token(ctxt); assert(token && token_get_type(token) == JSON_LSQUARE); list = qlist_new(); peek = parser_context_peek_token(ctxt); if (peek == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } if (token_get_type(peek) != JSON_RSQUARE) { QObject *obj; obj = parse_value(ctxt, ap); if (obj == NULL) { parse_error(ctxt, token, "expecting value"); goto out; } qlist_append_obj(list, obj); token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } while (token_get_type(token) != JSON_RSQUARE) { if (token_get_type(token) != JSON_COMMA) { parse_error(ctxt, token, "expected separator in list"); goto out; } obj = parse_value(ctxt, ap); if (obj == NULL) { parse_error(ctxt, token, "expecting value"); goto out; } qlist_append_obj(list, obj); token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } } } else { (void)parser_context_pop_token(ctxt); } return QOBJECT(list); out: QDECREF(list); return NULL; }
1threat
How to get first and last element in an array in java? : <p>If I have an array of doubles: </p> <pre><code>[10.2, 20, 11.1, 21, 31, 12, 22.5, 32, 42, 13.6, 23, 32, 43.3, 53, 14, 24, 34, 44, 54, 64, 15.1, 25, 35, 45, 55, 65.3, 75.4, 16, 26, 17.5,] </code></pre> <p>and I want to get the first element and last element so that</p> <pre><code>firstNum = 10.2 lastNum = 17.5 </code></pre> <p>how would I do this?</p>
0debug
How to detect the presence of a scrollbar in the Dom using JavaScript? : <p>Is there a way to detect presence of scrollbar in the Dom measuring body height and window height in JavaScript? I want the syntax.</p>
0debug
Openai gym environment for multi-agent games : <p>Is it possible to use <a href="https://openai.com/" rel="noreferrer">openai</a>'s <a href="https://gym.openai.com/docs" rel="noreferrer">gym environments</a> for multi-agent games? Specifically, I would like to model a card game with four players (agents). The player scoring a turn starts the next turn. How would I model the necessary coordination between the players (e.g. who's turn it is next)? Ultimately, I would like to use reinforcement learning on four agents that play against each other.</p>
0debug
static void restore_median(uint8_t *src, int step, int stride, int width, int height, int slices, int rmode) { int i, j, slice; int A, B, C; uint8_t *bsrc; int slice_start, slice_height; const int cmask = ~rmode; for (slice = 0; slice < slices; slice++) { slice_start = ((slice * height) / slices) & cmask; slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start; bsrc = src + slice_start * stride; bsrc[0] += 0x80; A = bsrc[0]; for (i = step; i < width * step; i += step) { bsrc[i] += A; A = bsrc[i]; } bsrc += stride; if (slice_height == 1) continue; C = bsrc[-stride]; bsrc[0] += C; A = bsrc[0]; for (i = step; i < width * step; i += step) { B = bsrc[i - stride]; bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); C = B; A = bsrc[i]; } bsrc += stride; for (j = 2; j < slice_height; j++) { for (i = 0; i < width * step; i += step) { B = bsrc[i - stride]; bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); C = B; A = bsrc[i]; } bsrc += stride; } } }
1threat
void register_cp_regs_for_features(ARMCPU *cpu) { CPUARMState *env = &cpu->env; if (arm_feature(env, ARM_FEATURE_M)) { return; } define_arm_cp_regs(cpu, cp_reginfo); if (!arm_feature(env, ARM_FEATURE_V8)) { define_arm_cp_regs(cpu, not_v8_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_V6)) { ARMCPRegInfo v6_idregs[] = { { .name = "ID_PFR0", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_pfr0 }, { .name = "ID_PFR1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_pfr1 }, { .name = "ID_DFR0", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_dfr0 }, { .name = "ID_AFR0", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_afr0 }, { .name = "ID_MMFR0", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_mmfr0 }, { .name = "ID_MMFR1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_mmfr1 }, { .name = "ID_MMFR2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_mmfr2 }, { .name = "ID_MMFR3", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_mmfr3 }, { .name = "ID_ISAR0", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_isar0 }, { .name = "ID_ISAR1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_isar1 }, { .name = "ID_ISAR2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_isar2 }, { .name = "ID_ISAR3", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_isar3 }, { .name = "ID_ISAR4", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_isar4 }, { .name = "ID_ISAR5", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_isar5 }, { .name = "ID_MMFR4", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_mmfr4 }, { .name = "ID_ISAR7_RESERVED", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, REGINFO_SENTINEL }; define_arm_cp_regs(cpu, v6_idregs); define_arm_cp_regs(cpu, v6_cp_reginfo); } else { define_arm_cp_regs(cpu, not_v6_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_V6K)) { define_arm_cp_regs(cpu, v6k_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_V7MP) && !arm_feature(env, ARM_FEATURE_PMSA)) { define_arm_cp_regs(cpu, v7mp_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_V7)) { #ifndef CONFIG_USER_ONLY ARMCPRegInfo pmcr = { .name = "PMCR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 0, .access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS, .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmcr), .accessfn = pmreg_access, .writefn = pmcr_write, .raw_writefn = raw_write, }; ARMCPRegInfo pmcr64 = { .name = "PMCR_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 0, .access = PL0_RW, .accessfn = pmreg_access, .type = ARM_CP_IO, .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcr), .resetvalue = cpu->midr & 0xff000000, .writefn = pmcr_write, .raw_writefn = raw_write, }; define_one_arm_cp_reg(cpu, &pmcr); define_one_arm_cp_reg(cpu, &pmcr64); #endif ARMCPRegInfo clidr = { .name = "CLIDR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->clidr }; define_one_arm_cp_reg(cpu, &clidr); define_arm_cp_regs(cpu, v7_cp_reginfo); define_debug_regs(cpu); } else { define_arm_cp_regs(cpu, not_v7_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_V8)) { ARMCPRegInfo v8_idregs[] = { { .name = "ID_AA64PFR0_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_aa64pfr0 }, { .name = "ID_AA64PFR1_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_aa64pfr1}, { .name = "ID_AA64PFR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64PFR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64PFR4_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64PFR5_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64PFR6_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64PFR7_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64DFR0_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_aa64dfr0 }, { .name = "ID_AA64DFR1_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_aa64dfr1 }, { .name = "ID_AA64DFR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64DFR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64AFR0_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_aa64afr0 }, { .name = "ID_AA64AFR1_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_aa64afr1 }, { .name = "ID_AA64AFR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64AFR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 5, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64ISAR0_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_aa64isar0 }, { .name = "ID_AA64ISAR1_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_aa64isar1 }, { .name = "ID_AA64ISAR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64ISAR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64ISAR4_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64ISAR5_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64ISAR6_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64ISAR7_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64MMFR0_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_aa64mmfr0 }, { .name = "ID_AA64MMFR1_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->id_aa64mmfr1 }, { .name = "ID_AA64MMFR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64MMFR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64MMFR4_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64MMFR5_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64MMFR6_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ID_AA64MMFR7_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "MVFR0_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->mvfr0 }, { .name = "MVFR1_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->mvfr1 }, { .name = "MVFR2_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->mvfr2 }, { .name = "MVFR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "MVFR4_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "MVFR5_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "MVFR6_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "MVFR7_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "PMCEID0", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 0, .crn = 9, .crm = 12, .opc2 = 6, .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, .resetvalue = cpu->pmceid0 }, { .name = "PMCEID0_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 6, .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, .resetvalue = cpu->pmceid0 }, { .name = "PMCEID1", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 0, .crn = 9, .crm = 12, .opc2 = 7, .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, .resetvalue = cpu->pmceid1 }, { .name = "PMCEID1_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 7, .access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST, .resetvalue = cpu->pmceid1 }, REGINFO_SENTINEL }; if (!arm_feature(env, ARM_FEATURE_EL3) && !arm_feature(env, ARM_FEATURE_EL2)) { ARMCPRegInfo rvbar = { .name = "RVBAR_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 0, .opc2 = 1, .type = ARM_CP_CONST, .access = PL1_R, .resetvalue = cpu->rvbar }; define_one_arm_cp_reg(cpu, &rvbar); } define_arm_cp_regs(cpu, v8_idregs); define_arm_cp_regs(cpu, v8_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_EL2)) { uint64_t vmpidr_def = mpidr_read_val(env); ARMCPRegInfo vpidr_regs[] = { { .name = "VPIDR", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, .access = PL2_RW, .accessfn = access_el3_aa32ns, .resetvalue = cpu->midr, .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, { .name = "VPIDR_EL2", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, .access = PL2_RW, .resetvalue = cpu->midr, .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, { .name = "VMPIDR", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, .access = PL2_RW, .accessfn = access_el3_aa32ns, .resetvalue = vmpidr_def, .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, .access = PL2_RW, .resetvalue = vmpidr_def, .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, REGINFO_SENTINEL }; define_arm_cp_regs(cpu, vpidr_regs); define_arm_cp_regs(cpu, el2_cp_reginfo); if (!arm_feature(env, ARM_FEATURE_EL3)) { ARMCPRegInfo rvbar = { .name = "RVBAR_EL2", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 1, .type = ARM_CP_CONST, .access = PL2_R, .resetvalue = cpu->rvbar }; define_one_arm_cp_reg(cpu, &rvbar); } } else { if (arm_feature(env, ARM_FEATURE_EL3)) { ARMCPRegInfo vpidr_regs[] = { { .name = "VPIDR_EL2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, .access = PL2_RW, .accessfn = access_el3_aa32ns_aa64any, .type = ARM_CP_CONST, .resetvalue = cpu->midr, .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, .access = PL2_RW, .accessfn = access_el3_aa32ns_aa64any, .type = ARM_CP_NO_RAW, .writefn = arm_cp_write_ignore, .readfn = mpidr_read }, REGINFO_SENTINEL }; define_arm_cp_regs(cpu, vpidr_regs); define_arm_cp_regs(cpu, el3_no_el2_cp_reginfo); } } if (arm_feature(env, ARM_FEATURE_EL3)) { define_arm_cp_regs(cpu, el3_cp_reginfo); ARMCPRegInfo el3_regs[] = { { .name = "RVBAR_EL3", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 6, .crn = 12, .crm = 0, .opc2 = 1, .type = ARM_CP_CONST, .access = PL3_R, .resetvalue = cpu->rvbar }, { .name = "SCTLR_EL3", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 0, .opc2 = 0, .access = PL3_RW, .raw_writefn = raw_write, .writefn = sctlr_write, .fieldoffset = offsetof(CPUARMState, cp15.sctlr_el[3]), .resetvalue = cpu->reset_sctlr }, REGINFO_SENTINEL }; define_arm_cp_regs(cpu, el3_regs); } if (arm_feature(env, ARM_FEATURE_EL3)) { if (arm_feature(env, ARM_FEATURE_AARCH64)) { ARMCPRegInfo nsacr = { .name = "NSACR", .type = ARM_CP_CONST, .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, .access = PL1_RW, .accessfn = nsacr_access, .resetvalue = 0xc00 }; define_one_arm_cp_reg(cpu, &nsacr); } else { ARMCPRegInfo nsacr = { .name = "NSACR", .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, .access = PL3_RW | PL1_R, .resetvalue = 0, .fieldoffset = offsetof(CPUARMState, cp15.nsacr) }; define_one_arm_cp_reg(cpu, &nsacr); } } else { if (arm_feature(env, ARM_FEATURE_V8)) { ARMCPRegInfo nsacr = { .name = "NSACR", .type = ARM_CP_CONST, .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2, .access = PL1_R, .resetvalue = 0xc00 }; define_one_arm_cp_reg(cpu, &nsacr); } } if (arm_feature(env, ARM_FEATURE_PMSA)) { if (arm_feature(env, ARM_FEATURE_V6)) { assert(arm_feature(env, ARM_FEATURE_V7)); define_arm_cp_regs(cpu, vmsa_pmsa_cp_reginfo); define_arm_cp_regs(cpu, pmsav7_cp_reginfo); } else { define_arm_cp_regs(cpu, pmsav5_cp_reginfo); } } else { define_arm_cp_regs(cpu, vmsa_pmsa_cp_reginfo); define_arm_cp_regs(cpu, vmsa_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_THUMB2EE)) { define_arm_cp_regs(cpu, t2ee_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { define_arm_cp_regs(cpu, generic_timer_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_VAPA)) { define_arm_cp_regs(cpu, vapa_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_CACHE_TEST_CLEAN)) { define_arm_cp_regs(cpu, cache_test_clean_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_CACHE_DIRTY_REG)) { define_arm_cp_regs(cpu, cache_dirty_status_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_CACHE_BLOCK_OPS)) { define_arm_cp_regs(cpu, cache_block_ops_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_OMAPCP)) { define_arm_cp_regs(cpu, omap_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_STRONGARM)) { define_arm_cp_regs(cpu, strongarm_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_XSCALE)) { define_arm_cp_regs(cpu, xscale_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_DUMMY_C15_REGS)) { define_arm_cp_regs(cpu, dummy_c15_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_LPAE)) { define_arm_cp_regs(cpu, lpae_cp_reginfo); } { ARMCPRegInfo id_pre_v8_midr_cp_reginfo[] = { { .name = "MIDR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = CP_ANY, .access = PL1_R, .resetvalue = cpu->midr, .writefn = arm_cp_write_ignore, .raw_writefn = raw_write, .readfn = midr_read, .fieldoffset = offsetof(CPUARMState, cp15.c0_cpuid), .type = ARM_CP_OVERRIDE }, { .name = "DUMMY", .cp = 15, .crn = 0, .crm = 3, .opc1 = 0, .opc2 = CP_ANY, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "DUMMY", .cp = 15, .crn = 0, .crm = 4, .opc1 = 0, .opc2 = CP_ANY, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "DUMMY", .cp = 15, .crn = 0, .crm = 5, .opc1 = 0, .opc2 = CP_ANY, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "DUMMY", .cp = 15, .crn = 0, .crm = 6, .opc1 = 0, .opc2 = CP_ANY, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "DUMMY", .cp = 15, .crn = 0, .crm = 7, .opc1 = 0, .opc2 = CP_ANY, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, REGINFO_SENTINEL }; ARMCPRegInfo id_v8_midr_cp_reginfo[] = { { .name = "MIDR_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 0, .access = PL1_R, .type = ARM_CP_NO_RAW, .resetvalue = cpu->midr, .fieldoffset = offsetof(CPUARMState, cp15.c0_cpuid), .readfn = midr_read }, { .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST, .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 4, .access = PL1_R, .resetvalue = cpu->midr }, { .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST, .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 7, .access = PL1_R, .resetvalue = cpu->midr }, { .name = "REVIDR_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 6, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, REGINFO_SENTINEL }; ARMCPRegInfo id_cp_reginfo[] = { { .name = "CTR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->ctr }, { .name = "CTR_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 0, .crm = 0, .access = PL0_R, .accessfn = ctr_el0_access, .type = ARM_CP_CONST, .resetvalue = cpu->ctr }, { .name = "TCMTR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, REGINFO_SENTINEL }; ARMCPRegInfo id_tlbtr_reginfo = { .name = "TLBTR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0, }; ARMCPRegInfo id_mpuir_reginfo = { .name = "MPUIR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->pmsav7_dregion << 8 }; ARMCPRegInfo crn0_wi_reginfo = { .name = "CRN0_WI", .cp = 15, .crn = 0, .crm = CP_ANY, .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_W, .type = ARM_CP_NOP | ARM_CP_OVERRIDE }; if (arm_feature(env, ARM_FEATURE_OMAPCP) || arm_feature(env, ARM_FEATURE_STRONGARM)) { ARMCPRegInfo *r; define_one_arm_cp_reg(cpu, &crn0_wi_reginfo); for (r = id_pre_v8_midr_cp_reginfo; r->type != ARM_CP_SENTINEL; r++) { r->access = PL1_RW; } for (r = id_cp_reginfo; r->type != ARM_CP_SENTINEL; r++) { r->access = PL1_RW; } id_tlbtr_reginfo.access = PL1_RW; id_tlbtr_reginfo.access = PL1_RW; } if (arm_feature(env, ARM_FEATURE_V8)) { define_arm_cp_regs(cpu, id_v8_midr_cp_reginfo); } else { define_arm_cp_regs(cpu, id_pre_v8_midr_cp_reginfo); } define_arm_cp_regs(cpu, id_cp_reginfo); if (!arm_feature(env, ARM_FEATURE_PMSA)) { define_one_arm_cp_reg(cpu, &id_tlbtr_reginfo); } else if (arm_feature(env, ARM_FEATURE_V7)) { define_one_arm_cp_reg(cpu, &id_mpuir_reginfo); } } if (arm_feature(env, ARM_FEATURE_MPIDR)) { define_arm_cp_regs(cpu, mpidr_cp_reginfo); } if (arm_feature(env, ARM_FEATURE_AUXCR)) { ARMCPRegInfo auxcr_reginfo[] = { { .name = "ACTLR_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 1, .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = cpu->reset_auxcr }, { .name = "ACTLR_EL2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 1, .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "ACTLR_EL3", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 0, .opc2 = 1, .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, REGINFO_SENTINEL }; define_arm_cp_regs(cpu, auxcr_reginfo); } if (arm_feature(env, ARM_FEATURE_CBAR)) { if (arm_feature(env, ARM_FEATURE_AARCH64)) { uint32_t cbar32 = (extract64(cpu->reset_cbar, 18, 14) << 18) | extract64(cpu->reset_cbar, 32, 12); ARMCPRegInfo cbar_reginfo[] = { { .name = "CBAR", .type = ARM_CP_CONST, .cp = 15, .crn = 15, .crm = 0, .opc1 = 4, .opc2 = 0, .access = PL1_R, .resetvalue = cpu->reset_cbar }, { .name = "CBAR_EL1", .state = ARM_CP_STATE_AA64, .type = ARM_CP_CONST, .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 0, .access = PL1_R, .resetvalue = cbar32 }, REGINFO_SENTINEL }; assert(arm_feature(env, ARM_FEATURE_CBAR_RO)); define_arm_cp_regs(cpu, cbar_reginfo); } else { ARMCPRegInfo cbar = { .name = "CBAR", .cp = 15, .crn = 15, .crm = 0, .opc1 = 4, .opc2 = 0, .access = PL1_R|PL3_W, .resetvalue = cpu->reset_cbar, .fieldoffset = offsetof(CPUARMState, cp15.c15_config_base_address) }; if (arm_feature(env, ARM_FEATURE_CBAR_RO)) { cbar.access = PL1_R; cbar.fieldoffset = 0; cbar.type = ARM_CP_CONST; } define_one_arm_cp_reg(cpu, &cbar); } } if (arm_feature(env, ARM_FEATURE_VBAR)) { ARMCPRegInfo vbar_cp_reginfo[] = { { .name = "VBAR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .crn = 12, .crm = 0, .opc1 = 0, .opc2 = 0, .access = PL1_RW, .writefn = vbar_write, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.vbar_s), offsetof(CPUARMState, cp15.vbar_ns) }, .resetvalue = 0 }, REGINFO_SENTINEL }; define_arm_cp_regs(cpu, vbar_cp_reginfo); } { ARMCPRegInfo sctlr = { .name = "SCTLR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 0, .access = PL1_RW, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.sctlr_s), offsetof(CPUARMState, cp15.sctlr_ns) }, .writefn = sctlr_write, .resetvalue = cpu->reset_sctlr, .raw_writefn = raw_write, }; if (arm_feature(env, ARM_FEATURE_XSCALE)) { sctlr.type |= ARM_CP_SUPPRESS_TB_END; } define_one_arm_cp_reg(cpu, &sctlr); } }
1threat
static void virtio_ccw_save_config(DeviceState *d, QEMUFile *f) { VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); CcwDevice *ccw_dev = CCW_DEVICE(d); SubchDev *s = ccw_dev->sch; VirtIODevice *vdev = virtio_ccw_get_vdev(s); subch_device_save(s, f); if (dev->indicators != NULL) { qemu_put_be32(f, dev->indicators->len); qemu_put_be64(f, dev->indicators->addr); } else { qemu_put_be32(f, 0); qemu_put_be64(f, 0UL); } if (dev->indicators2 != NULL) { qemu_put_be32(f, dev->indicators2->len); qemu_put_be64(f, dev->indicators2->addr); } else { qemu_put_be32(f, 0); qemu_put_be64(f, 0UL); } if (dev->summary_indicator != NULL) { qemu_put_be32(f, dev->summary_indicator->len); qemu_put_be64(f, dev->summary_indicator->addr); } else { qemu_put_be32(f, 0); qemu_put_be64(f, 0UL); } qemu_put_be16(f, vdev->config_vector); qemu_put_be64(f, dev->routes.adapter.ind_offset); qemu_put_byte(f, dev->thinint_isc); qemu_put_be32(f, dev->revision); }
1threat
static uint64_t mips_qemu_read (void *opaque, target_phys_addr_t addr, unsigned size) { return 0; }
1threat
JAVA How to save multiple arrays into a single array : I'm currently trying to save multiple arrays into a single array where the data can later be called in a next function. The data is currently in an ArrayList<ArrayList> which is then getting called. N number of indexes are then output on the console. I want to save those indexes into an array that can be used. Example: You start off with ``` [[1.52101, 13.64, 4.49, 1.1, 71.78, 0.06, 8.75, 0.0, 0.0], [1.51761, 13.89, 3.6, 1.36, 72.73, 0.48, 7.83, 0.0, 0.0], [1.51618, 13.53, 3.55, 1.54, 72.99, 0.39, 7.78, 0.0, 0.0]] ``` If your numCen = 2. You'll get one of these array outputed such as: ``` [1.52101, 13.64, 4.49, 1.1, 71.78, 0.06, 8.75, 0.0, 0.0] [1.51761, 13.89, 3.6, 1.36, 72.73, 0.48, 7.83, 0.0, 0.0] ``` I need to save both arrays into one array now. ``` public static void ranCentroid() { Random randomPoint = new Random(); for (int i = 0; i < numCen; i++) { int randomP = randomPoint.nextInt(Points.size()); System.out.println(Points.get(randomP)); } } ```
0debug
static void esp_do_dma(ESPState *s) { uint32_t len; int to_device; to_device = (s->ti_size < 0); len = s->dma_left; if (s->do_cmd) { DPRINTF("command len %d + %d\n", s->cmdlen, len); s->dma_memory_read(s->dma_opaque, &s->cmdbuf[s->cmdlen], len); s->ti_size = 0; s->cmdlen = 0; s->do_cmd = 0; do_cmd(s, s->cmdbuf); return; } if (s->async_len == 0) { return; } if (len > s->async_len) { len = s->async_len; } if (to_device) { s->dma_memory_read(s->dma_opaque, s->async_buf, len); } else { s->dma_memory_write(s->dma_opaque, s->async_buf, len); } s->dma_left -= len; s->async_buf += len; s->async_len -= len; if (to_device) s->ti_size += len; else s->ti_size -= len; if (s->async_len == 0) { if (to_device) { s->current_dev->info->write_data(s->current_dev, 0); } else { s->current_dev->info->read_data(s->current_dev, 0); if (s->dma_left == 0 && s->ti_size > 0) { esp_dma_done(s); } } } else { esp_dma_done(s); } }
1threat
Android AsyncTask vs Thread + Handler vs rxjava : <p>I know this is the question which was asked many many times. However there is something I never found an answer for. So hopefully someone can shed me some light.</p> <p>We all know that AsyncTask and Thread are options for executing background tasks to avoid ANR issue. It is recommended that asynctask should only be used for short-running tasks while thread can be used for long-running tasks. The reasons why asynctask shouldn't be used for long tasks are well-known which is about the possible leak caused by asynctask since it may continue running after an activity's destroyed. That is convincing. However, it also leads to some other questions:</p> <ol> <li>Isn't thread also independent from activity lifecycle? Thus, the risk with asynctask can also be applied to thread. So why thread is suitable for long-running tasks?</li> <li>Looks like the risk of asynctask is only applicable when using it with activity. If we use it in service (not IntentService since IntentService stops after its work's completed), and as long as we can guarantee to cancel the asyntask when the service's stopped, can we use it for long-running tasks? and doesn't it means it's risk free to use asynctask in services?</li> <li>I've played with rxjava for a while and really like it. It eliminates the need of worrying about threading (except you have to decide in which thread to subscribe and observe the emitted data). From what I can see, rxjava (in conjunction with some other libs like retrofits) seems to be a perfect replacement of asynctask and thread. I'm wondering if we could completely forget about them or there is any specific case that rxjava can't achieve what asynctask and thread can do that I should be aware of?</li> </ol> <p>Thanks</p>
0debug
What is an Enterprise architecture? : <p>I am a web developer, I want to become software architect, and I learn everyday about it, but when I am learning software architecture I see TOGAF framework for enterprise architecture, I want to get solid understand in an <strong>enterprise architecture</strong>.</p>
0debug
How to store access token? (Oauth 2, Auth code flow) : <p>From what i understand the purpose of the Authorization Code flow is to exchange the auth code for access token. This exchange happens between the server which serves the page and authorization server so that the actual access token is not exposed to the client user.</p> <p>How should the page server store the access token once it is obtained? I was learning from a Pluralsight example in which there is this part of code:</p> <pre><code> public static HttpClient GetClient() { HttpClient client = new HttpClient(); var accessToken = RequestAccessTokenAuthorizationCode(); client.SetBearerToken(accessToken); client.BaseAddress = new Uri(IdentityConstants.API); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); return client; } private static string RequestAccessTokenAuthorizationCode() { // did we store the token before? var cookie = HttpContext.Current.Request.Cookies.Get("ClientMVCCookie.AuthCode"); if (cookie != null &amp;&amp; cookie["access_token"] != null &amp;&amp; !string.IsNullOrEmpty(cookie["access_token"])) { return cookie["access_token"]; } // no token found - request one // we'll pass through the URI we want to return to as state var state = HttpContext.Current.Request.Url.OriginalString; var authorizeRequest = new IdentityModel.Client.AuthorizeRequest( IdentityConstants.AuthEndoint); var url = authorizeRequest.CreateAuthorizeUrl(IdentityConstants.MVCClientSecret, "code", "management secret", IdentityConstants.MVCAuthCodeCallback, state); HttpContext.Current.Response.Redirect(url); return null; } } </code></pre> <p>This will cause each request to check if there is an access token stored in the cookie. If not then the flow will be initiated. The callback looks like this:</p> <pre><code>public class CallbackController : Controller { // GET: STSCallback public async Task&lt;ActionResult&gt; Index() { // get the authorization code from the query string var authCode = Request.QueryString["code"]; // with the auth code, we can request an access token. var client = new TokenClient( IdentityConstants.TokenEndoint, "mvc_client_auth_code", IdentityConstants.MVCClientSecretAuthCode); var tokenResponse = await client.RequestAuthorizationCodeAsync( authCode, IdentityConstants.MVCAuthCodeCallback); // we save the token in a cookie for use later on var cookie = Response.Cookies["ClientMVCCookie.AuthCode"]; cookie.Expires = DateTime.Now.AddMinutes(1); cookie["access_token"] = tokenResponse.AccessToken; // get the state (uri to return to) var state = Request.QueryString["state"]; // redirect to the URI saved in state return Redirect(state); } } </code></pre> <p>Doesn't storing the access token in the cookie defeath the whole purpose of the authorization code flow? The cookie will be transmitted to the client browser thus exposing it to the client? Am i missing something? It this is not the correct way to store the token, how should it be stored?</p>
0debug
Hello, I want a formula that counts same String from a column against the rows. : Site ID Node LLR580 PF LLR580 MW LLR580 Fiber LLR580 PTCL LLR581 PF LLR582 PF LLR583 MW LLR581 MW LLR582 PF LLR580 PF When i enter LLR580 in a column it should return: 2PF,1MW,1Fiber,1PTCL in next column of it. Siteid Node LLR580 2PF,1MW,1Fiber,1PTCL And so on. TIA
0debug
static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, int plane_idx, int is_chroma) { int blk, ret; int i, j, bx, by; uint8_t *dst, *prev, *ref, *ref_start, *ref_end; int v, col[2]; const uint8_t *scan; int xoff, yoff; LOCAL_ALIGNED_16(int16_t, block, [64]); LOCAL_ALIGNED_16(uint8_t, ublock, [64]); LOCAL_ALIGNED_16(int32_t, dctblock, [64]); int coordmap[64]; const int stride = frame->linesize[plane_idx]; int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3; int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3; int width = c->avctx->width >> is_chroma; init_lengths(c, FFMAX(width, 8), bw); for (i = 0; i < BINK_NB_SRC; i++) read_bundle(gb, c, i); ref_start = c->last->data[plane_idx] ? c->last->data[plane_idx] : frame->data[plane_idx]; ref_end = ref_start + (bw - 1 + c->last->linesize[plane_idx] * (bh - 1)) * 8; for (i = 0; i < 64; i++) coordmap[i] = (i & 7) + (i >> 3) * stride; for (by = 0; by < bh; by++) { if ((ret = read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_BLOCK_TYPES])) < 0) return ret; if ((ret = read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES])) < 0) return ret; if ((ret = read_colors(gb, &c->bundle[BINK_SRC_COLORS], c)) < 0) return ret; if ((ret = read_patterns(c->avctx, gb, &c->bundle[BINK_SRC_PATTERN])) < 0) return ret; if ((ret = read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_X_OFF])) < 0) return ret; if ((ret = read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_Y_OFF])) < 0) return ret; if ((ret = read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0)) < 0) return ret; if ((ret = read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1)) < 0) return ret; if ((ret = read_runs(c->avctx, gb, &c->bundle[BINK_SRC_RUN])) < 0) return ret; if (by == bh) break; dst = frame->data[plane_idx] + 8*by*stride; prev = (c->last->data[plane_idx] ? c->last->data[plane_idx] : frame->data[plane_idx]) + 8*by*stride; for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) { blk = get_value(c, BINK_SRC_BLOCK_TYPES); if ((by & 1) && blk == SCALED_BLOCK) { bx++; dst += 8; prev += 8; continue; } switch (blk) { case SKIP_BLOCK: c->hdsp.put_pixels_tab[1][0](dst, prev, stride, 8); break; case SCALED_BLOCK: blk = get_value(c, BINK_SRC_SUB_BLOCK_TYPES); switch (blk) { case RUN_BLOCK: scan = bink_patterns[get_bits(gb, 4)]; i = 0; do { int run = get_value(c, BINK_SRC_RUN) + 1; i += run; if (i > 64) { av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return AVERROR_INVALIDDATA; } if (get_bits1(gb)) { v = get_value(c, BINK_SRC_COLORS); for (j = 0; j < run; j++) ublock[*scan++] = v; } else { for (j = 0; j < run; j++) ublock[*scan++] = get_value(c, BINK_SRC_COLORS); } } while (i < 63); if (i == 63) ublock[*scan++] = get_value(c, BINK_SRC_COLORS); break; case INTRA_BLOCK: memset(dctblock, 0, sizeof(*dctblock) * 64); dctblock[0] = get_value(c, BINK_SRC_INTRA_DC); read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1); c->binkdsp.idct_put(ublock, 8, dctblock); break; case FILL_BLOCK: v = get_value(c, BINK_SRC_COLORS); c->bdsp.fill_block_tab[0](dst, v, stride, 16); break; case PATTERN_BLOCK: for (i = 0; i < 2; i++) col[i] = get_value(c, BINK_SRC_COLORS); for (j = 0; j < 8; j++) { v = get_value(c, BINK_SRC_PATTERN); for (i = 0; i < 8; i++, v >>= 1) ublock[i + j*8] = col[v & 1]; } break; case RAW_BLOCK: for (j = 0; j < 8; j++) for (i = 0; i < 8; i++) ublock[i + j*8] = get_value(c, BINK_SRC_COLORS); break; default: av_log(c->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", blk); return AVERROR_INVALIDDATA; } if (blk != FILL_BLOCK) c->binkdsp.scale_block(ublock, dst, stride); bx++; dst += 8; prev += 8; break; case MOTION_BLOCK: xoff = get_value(c, BINK_SRC_X_OFF); yoff = get_value(c, BINK_SRC_Y_OFF); ref = prev + xoff + yoff * stride; if (ref < ref_start || ref > ref_end) { av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n", bx*8 + xoff, by*8 + yoff); return AVERROR_INVALIDDATA; } c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8); break; case RUN_BLOCK: scan = bink_patterns[get_bits(gb, 4)]; i = 0; do { int run = get_value(c, BINK_SRC_RUN) + 1; i += run; if (i > 64) { av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return AVERROR_INVALIDDATA; } if (get_bits1(gb)) { v = get_value(c, BINK_SRC_COLORS); for (j = 0; j < run; j++) dst[coordmap[*scan++]] = v; } else { for (j = 0; j < run; j++) dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS); } } while (i < 63); if (i == 63) dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS); break; case RESIDUE_BLOCK: xoff = get_value(c, BINK_SRC_X_OFF); yoff = get_value(c, BINK_SRC_Y_OFF); ref = prev + xoff + yoff * stride; if (ref < ref_start || ref > ref_end) { av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n", bx*8 + xoff, by*8 + yoff); return AVERROR_INVALIDDATA; } c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8); c->bdsp.clear_block(block); v = get_bits(gb, 7); read_residue(gb, block, v); c->binkdsp.add_pixels8(dst, block, stride); break; case INTRA_BLOCK: memset(dctblock, 0, sizeof(*dctblock) * 64); dctblock[0] = get_value(c, BINK_SRC_INTRA_DC); read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1); c->binkdsp.idct_put(dst, stride, dctblock); break; case FILL_BLOCK: v = get_value(c, BINK_SRC_COLORS); c->bdsp.fill_block_tab[1](dst, v, stride, 8); break; case INTER_BLOCK: xoff = get_value(c, BINK_SRC_X_OFF); yoff = get_value(c, BINK_SRC_Y_OFF); ref = prev + xoff + yoff * stride; c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8); memset(dctblock, 0, sizeof(*dctblock) * 64); dctblock[0] = get_value(c, BINK_SRC_INTER_DC); read_dct_coeffs(gb, dctblock, bink_scan, bink_inter_quant, -1); c->binkdsp.idct_add(dst, stride, dctblock); break; case PATTERN_BLOCK: for (i = 0; i < 2; i++) col[i] = get_value(c, BINK_SRC_COLORS); for (i = 0; i < 8; i++) { v = get_value(c, BINK_SRC_PATTERN); for (j = 0; j < 8; j++, v >>= 1) dst[i*stride + j] = col[v & 1]; } break; case RAW_BLOCK: for (i = 0; i < 8; i++) memcpy(dst + i*stride, c->bundle[BINK_SRC_COLORS].cur_ptr + i*8, 8); c->bundle[BINK_SRC_COLORS].cur_ptr += 64; break; default: av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk); return AVERROR_INVALIDDATA; } } } if (get_bits_count(gb) & 0x1F) skip_bits_long(gb, 32 - (get_bits_count(gb) & 0x1F)); return 0; }
1threat
python: How to fix this "ValueError"? : I loaded some images (with cv2.imread_color) into a list and i'm trying to get hsv (hue, saturnation, value) values from it with function "rgb_to_hsv". I got red, green and blue values but when i'm trying to get hsv values i get ***an error about parameters***: Traceback (most recent call last): File "C:\Users\Downloads\preprocessing\program.py", line 69, in <module> hue_images[i], saturnation_images[i], value_images[i] = rgb_to_hsv(hsv_red[i], hsv_green[i], hsv_blue[i]) File "C:\Users\Downloads\preprocessing\program.py", line 24, in rgb_to_hsv mx = max(r, g, b) ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() This is the code i'm using: ```python hue_images = list(range(len(image))) saturnation_images = list(range(len(image))) value_images = list(range(len(image))) hsv_red = list(range(len(image))) hsv_green = list(range(len(image))) hsv_blue = list(range(len(image))) def rgb_to_hsv(r, g, b): r, g, b = r/255.0, g/255.0, b/255.0 mx = max(r, g, b) mn = min(r, g, b) df = mx-mn if mx == mn: h = 0 elif mx == r: h = (60 * ((g-b)/df) + 360) % 360 elif mx == g: h = (60 * ((b-r)/df) + 120) % 360 elif mx == b: h = (60 * ((r-g)/df) + 240) % 360 if mx == 0: s = 0 else: s = (df/mx)*100 v = mx*100 return h, s, v def hsv_get_red(img): red = img.copy() red[:, :, 0] = 0 red[:, :, 1] = 0 return red[:, :, 2] def hsv_get_green(img): green = img.copy() green[:, :, 0] = 0 green[:, :, 2] = 0 return green[:, :, 1] def hsv_get_blue(img): blue = img.copy() blue[:, :, 2] = 0 blue[:, :, 1] = 0 return blue[:, :, 0] for i in range(len(image)): hsv_red[i] = hsv_get_red(image[i]) hsv_green[i] = hsv_get_green(image[i]) hsv_blue[i] = hsv_get_blue(image[i]) for i in range(len(image)): hue_images[i], saturnation_images[i], value_images[i] = rgb_to_hsv(hsv_red[i], hsv_green[i], hsv_blue[i]) ``` My question is: How can I use list values as parameters in the function (it works with int numbers) to get results (another list values)? Thanks
0debug
Is integer overflow undefined in inline x86 assembly? : <p>Say I have the following C code:</p> <pre><code>int32_t foo(int32_t x) { return x + 1; } </code></pre> <p>This is undefined behavior when <code>x == INT_MAX</code>. Now say I performed the addition with inline assembly instead:</p> <pre><code>int32_t foo(int32_t x) { asm("incl %0" : "+g"(x)); return x; } </code></pre> <p>Question: Does the inline assembly version still invoke undefined behavior when <code>x == INT_MAX</code>? Or does undefined behavior only apply to the C code?</p>
0debug
Error: Connection strategy not found MongoDB : <p>here is a simple connection to use express session store, it keeps banging out this error even though the text is right from the book. I am pretty sure is has something to do with 'new MongoStore' object initialization.</p> <pre><code>var express = require('express'), expressSession = require('express-session'); var MongoStore = require('connect-mongo/es5')(expressSession); var sessionStore = new MongoStore({ host: '127.0.0.1', port: '27017', db: 'session' }); var app = express() .use(expressSession({ secret: 'my secret sign key', store: sessionStore })) .use('/home', function (req, res) { if (req.session.views) { req.session.views++; } else { req.session.views = 1; } res.end('Total views for you:' + req.session.views); }) .use('/reset', function(req, res) { delete req.session.views; res.end('Cleared all your views'); }) .listen(3000); </code></pre>
0debug
What is super(props) doing for my React component? : <p>I am not great with JS and playing around with React.</p> <p>The React docs located <a href="https://facebook.github.io/react/docs/react-component.html#constructor" rel="noreferrer">here</a> state the following: </p> <blockquote> <p>When implementing the constructor for a <code>React.Component</code> subclass, you should call <code>super(props)</code> before any other statement. Otherwise, <code>this.props</code> will be undefined in the constructor, which can lead to bugs.</p> </blockquote> <p>My question is HOW does this actually work? What is <code>super()</code> doing that magically enables <code>this.props</code> within my constructor? </p>
0debug
document.write('<script src="evil.js"></script>');
1threat
how to input a huge number in C string? : I want store a positive integer up to 10^500000 in a string, but i don't know what should i write of the size of string. `char in[?????];` just like that. I tried to write something like that char in[sizeof(long double)]; but it wasn't work.
0debug
static int encode_picture(MpegEncContext *s, int picture_number) { int i, ret; int bits; int context_count = s->slice_context_count; s->picture_number = picture_number; s->me.mb_var_sum_temp = s->me.mc_mb_var_sum_temp = 0; if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO || s->codec_id == AV_CODEC_ID_MPEG2VIDEO || (s->h263_pred && !s->msmpeg4_version)) set_frame_distances(s); if(CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4) ff_set_mpeg4_time(s); s->me.scene_change_score=0; if(s->pict_type==AV_PICTURE_TYPE_I){ if(s->msmpeg4_version >= 3) s->no_rounding=1; else s->no_rounding=0; }else if(s->pict_type!=AV_PICTURE_TYPE_B){ if(s->flipflop_rounding || s->codec_id == AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_MPEG4) s->no_rounding ^= 1; } if(s->flags & CODEC_FLAG_PASS2){ if (estimate_qp(s,1) < 0) return -1; ff_get_2pass_fcode(s); }else if(!(s->flags & CODEC_FLAG_QSCALE)){ if(s->pict_type==AV_PICTURE_TYPE_B) s->lambda= s->last_lambda_for[s->pict_type]; else s->lambda= s->last_lambda_for[s->last_non_b_pict_type]; update_qscale(s); } if(s->codec_id != AV_CODEC_ID_AMV && s->codec_id != AV_CODEC_ID_MJPEG){ if(s->q_chroma_intra_matrix != s->q_intra_matrix ) av_freep(&s->q_chroma_intra_matrix); if(s->q_chroma_intra_matrix16 != s->q_intra_matrix16) av_freep(&s->q_chroma_intra_matrix16); s->q_chroma_intra_matrix = s->q_intra_matrix; s->q_chroma_intra_matrix16 = s->q_intra_matrix16; } s->mb_intra=0; for(i=1; i<context_count; i++){ ret = ff_update_duplicate_context(s->thread_context[i], s); if (ret < 0) return ret; } if(ff_init_me(s)<0) return -1; if(s->pict_type != AV_PICTURE_TYPE_I){ s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8; s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8; if (s->pict_type != AV_PICTURE_TYPE_B) { if((s->avctx->pre_me && s->last_non_b_pict_type==AV_PICTURE_TYPE_I) || s->avctx->pre_me==2){ s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); } } s->avctx->execute(s->avctx, estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); }else { for(i=0; i<s->mb_stride*s->mb_height; i++) s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA; if(!s->fixed_qscale){ s->avctx->execute(s->avctx, mb_var_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); } } for(i=1; i<context_count; i++){ merge_context_after_me(s, s->thread_context[i]); } s->current_picture.mc_mb_var_sum= s->current_picture_ptr->mc_mb_var_sum= s->me.mc_mb_var_sum_temp; s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s->me. mb_var_sum_temp; emms_c(); if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == AV_PICTURE_TYPE_P){ s->pict_type= AV_PICTURE_TYPE_I; for(i=0; i<s->mb_stride*s->mb_height; i++) s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA; if(s->msmpeg4_version >= 3) s->no_rounding=1; av_dlog(s, "Scene change detected, encoding as I Frame %d %d\n", s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum); } if(!s->umvplus){ if(s->pict_type==AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) { s->f_code= ff_get_best_fcode(s, s->p_mv_table, CANDIDATE_MB_TYPE_INTER); if(s->flags & CODEC_FLAG_INTERLACED_ME){ int a,b; a= ff_get_best_fcode(s, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I); b= ff_get_best_fcode(s, s->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I); s->f_code= FFMAX3(s->f_code, a, b); } ff_fix_long_p_mvs(s); ff_fix_long_mvs(s, NULL, 0, s->p_mv_table, s->f_code, CANDIDATE_MB_TYPE_INTER, 0); if(s->flags & CODEC_FLAG_INTERLACED_ME){ int j; for(i=0; i<2; i++){ for(j=0; j<2; j++) ff_fix_long_mvs(s, s->p_field_select_table[i], j, s->p_field_mv_table[i][j], s->f_code, CANDIDATE_MB_TYPE_INTER_I, 0); } } } if(s->pict_type==AV_PICTURE_TYPE_B){ int a, b; a = ff_get_best_fcode(s, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD); b = ff_get_best_fcode(s, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR); s->f_code = FFMAX(a, b); a = ff_get_best_fcode(s, s->b_back_mv_table, CANDIDATE_MB_TYPE_BACKWARD); b = ff_get_best_fcode(s, s->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR); s->b_code = FFMAX(a, b); ff_fix_long_mvs(s, NULL, 0, s->b_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_FORWARD, 1); ff_fix_long_mvs(s, NULL, 0, s->b_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BACKWARD, 1); ff_fix_long_mvs(s, NULL, 0, s->b_bidir_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_BIDIR, 1); ff_fix_long_mvs(s, NULL, 0, s->b_bidir_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BIDIR, 1); if(s->flags & CODEC_FLAG_INTERLACED_ME){ int dir, j; for(dir=0; dir<2; dir++){ for(i=0; i<2; i++){ for(j=0; j<2; j++){ int type= dir ? (CANDIDATE_MB_TYPE_BACKWARD_I|CANDIDATE_MB_TYPE_BIDIR_I) : (CANDIDATE_MB_TYPE_FORWARD_I |CANDIDATE_MB_TYPE_BIDIR_I); ff_fix_long_mvs(s, s->b_field_select_table[dir][i], j, s->b_field_mv_table[dir][i][j], dir ? s->b_code : s->f_code, type, 1); } } } } } } if (estimate_qp(s, 0) < 0) return -1; if(s->qscale < 3 && s->max_qcoeff<=128 && s->pict_type==AV_PICTURE_TYPE_I && !(s->flags & CODEC_FLAG_QSCALE)) s->qscale= 3; if (s->out_format == FMT_MJPEG) { const uint16_t * luma_matrix = ff_mpeg1_default_intra_matrix; const uint16_t *chroma_matrix = ff_mpeg1_default_intra_matrix; if (s->avctx->intra_matrix) { chroma_matrix = luma_matrix = s->avctx->intra_matrix; } if (s->avctx->chroma_intra_matrix) chroma_matrix = s->avctx->chroma_intra_matrix; for(i=1;i<64;i++){ int j= s->dsp.idct_permutation[i]; s->chroma_intra_matrix[j] = av_clip_uint8((chroma_matrix[i] * s->qscale) >> 3); s-> intra_matrix[j] = av_clip_uint8(( luma_matrix[i] * s->qscale) >> 3); } s->y_dc_scale_table= s->c_dc_scale_table= ff_mpeg2_dc_scale_table[s->intra_dc_precision]; s->chroma_intra_matrix[0] = s->intra_matrix[0] = ff_mpeg2_dc_scale_table[s->intra_dc_precision][8]; ff_convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16, s->intra_matrix, s->intra_quant_bias, 8, 8, 1); ff_convert_matrix(&s->dsp, s->q_chroma_intra_matrix, s->q_chroma_intra_matrix16, s->chroma_intra_matrix, s->intra_quant_bias, 8, 8, 1); s->qscale= 8; } if(s->codec_id == AV_CODEC_ID_AMV){ static const uint8_t y[32]={13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13}; static const uint8_t c[32]={14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14}; for(i=1;i<64;i++){ int j= s->dsp.idct_permutation[ff_zigzag_direct[i]]; s->intra_matrix[j] = sp5x_quant_table[5*2+0][i]; s->chroma_intra_matrix[j] = sp5x_quant_table[5*2+1][i]; } s->y_dc_scale_table= y; s->c_dc_scale_table= c; s->intra_matrix[0] = 13; s->chroma_intra_matrix[0] = 14; ff_convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16, s->intra_matrix, s->intra_quant_bias, 8, 8, 1); ff_convert_matrix(&s->dsp, s->q_chroma_intra_matrix, s->q_chroma_intra_matrix16, s->chroma_intra_matrix, s->intra_quant_bias, 8, 8, 1); s->qscale= 8; } s->current_picture_ptr->f.key_frame = s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; s->current_picture_ptr->f.pict_type = s->current_picture.f.pict_type = s->pict_type; if (s->current_picture.f.key_frame) s->picture_in_gop_number=0; s->mb_x = s->mb_y = 0; s->last_bits= put_bits_count(&s->pb); switch(s->out_format) { case FMT_MJPEG: if (CONFIG_MJPEG_ENCODER) ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable, s->intra_matrix, s->chroma_intra_matrix); break; case FMT_H261: if (CONFIG_H261_ENCODER) ff_h261_encode_picture_header(s, picture_number); break; case FMT_H263: if (CONFIG_WMV2_ENCODER && s->codec_id == AV_CODEC_ID_WMV2) ff_wmv2_encode_picture_header(s, picture_number); else if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version) ff_msmpeg4_encode_picture_header(s, picture_number); else if (CONFIG_MPEG4_ENCODER && s->h263_pred) ff_mpeg4_encode_picture_header(s, picture_number); else if (CONFIG_RV10_ENCODER && s->codec_id == AV_CODEC_ID_RV10) ff_rv10_encode_picture_header(s, picture_number); else if (CONFIG_RV20_ENCODER && s->codec_id == AV_CODEC_ID_RV20) ff_rv20_encode_picture_header(s, picture_number); else if (CONFIG_FLV_ENCODER && s->codec_id == AV_CODEC_ID_FLV1) ff_flv_encode_picture_header(s, picture_number); else if (CONFIG_H263_ENCODER) ff_h263_encode_picture_header(s, picture_number); break; case FMT_MPEG1: if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) ff_mpeg1_encode_picture_header(s, picture_number); break; default: av_assert0(0); } bits= put_bits_count(&s->pb); s->header_bits= bits - s->last_bits; for(i=1; i<context_count; i++){ update_duplicate_context_after_me(s->thread_context[i], s); } s->avctx->execute(s->avctx, encode_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); for(i=1; i<context_count; i++){ merge_context_after_encode(s, s->thread_context[i]); } emms_c(); return 0; }
1threat
Docker: in memory file system : <p>I have a docker container which does alot of read/write to disk. I would like to test out what happens when my entire docker filesystem is in memory. I have seen some answers here that say it will not be a real performance improvement, but this is for testing. </p> <p>The ideal solution I would like to test is sharing the common parts of each image and copy to your memory space when needed. </p> <p>Each container files which are created during runtime should be in memory as well and separated. it shouldn't be more than 5GB fs in idle time and up to 7GB in processing time. </p> <p>Simple solutions would duplicate all shared files (even those part of the OS you never use) for each container. </p>
0debug
php error shows MySQL server has gone away error : When I try to upload large audio (40 MB File) on the server and insert that values into the database then the file should successfully be uploaded on the server but data does not insert into the database it shows "MySQL server has gone away" can anyone tell me the solution of this error.
0debug
Is there F# Interactive for Linux on .NET Core, without using Mono? : <p>I'm able to build and run F# projects with .NET Core, but unable to use or see F# Interactive with it. Is it on the roadmap somewhere?</p> <p>I'm using Linux Mint 18.3</p>
0debug
How to tell the version number of RxJS : <p>How to tell the version of the installed RxJS from the code? For example:</p> <pre><code>var Rx = require('rxjs/Rx'); console.log(Rx.rev); // undefined console.log(Rx.version); // undefined </code></pre> <p>Second question: How to tell if it's rxjs5 ?</p>
0debug
How to read in existing data into Quill JS : <p>I am having real trouble understanding how to work with quill...</p> <p>Saving the data is not a problem as that pretty straight forward :)</p> <p>I am a little stuck on two points</p> <ol> <li>How to edit the saved data in quill</li> <li>How to parse the saved data to create a static page</li> </ol> <p>can anyone offer any advice how to load the delta </p> <pre><code>{"ops":[{"insert":"this is a test bit of text\n"}]} </code></pre> <p>back into the quill editor and how to parse the output to create a page?</p> <p>Thanks in advance for any replies!</p>
0debug
tensorflow error:You must feed a value for placeholder tensor 'Placeholder' with dtype bool : i run the code for second respondents and catch an error. [error pic here][1] [1]: https://i.stack.imgur.com/s7KeE.jpg
0debug
size_t iov_from_buf(struct iovec *iov, unsigned int iov_cnt, size_t iov_off, const void *buf, size_t size) { size_t iovec_off, buf_off; unsigned int i; iovec_off = 0; buf_off = 0; for (i = 0; i < iov_cnt && size; i++) { if (iov_off < (iovec_off + iov[i].iov_len)) { size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off, size); memcpy(iov[i].iov_base + (iov_off - iovec_off), buf + buf_off, len); buf_off += len; iov_off += len; size -= len; } iovec_off += iov[i].iov_len; } return buf_off; }
1threat
sequelize "findbyid" is not a function but apparently "findAll" is : <p>I am getting a very strange problem with sequelize, When I try to call the function findAll it works fine (same for create and destroy), but when I try to call function "findById", it throws "findById is not a function" (same for "FindOne").</p> <pre><code>//works fine var gammes = models.gamme.findAll().then(function(gammes) { res.render('admin/gammes/gestion_gamme',{ layout: 'admin/layouts/structure' , gammes : gammes, js: "gammes" }); }); // throws models.gamme.findById is not a function models.gamme.findById(req.params.id).then(function(gamme) { gamme.update({ nom: req.body.nom }).then(function () { res.redirect("/gammes"); }) }); </code></pre> <p>Gamme.js model</p> <pre><code>module.exports = function (sequelize, DataTypes) { "use strict"; var gamme = sequelize.define('gamme', { id_gamme: { type: DataTypes.INTEGER.UNSIGNED, autoIncrement: true, primaryKey: true }, nom: { type: DataTypes.STRING, allowNull: false } }, { classMethods: {}, timestamps: false }); return gamme; }; </code></pre>
0debug
Read only mode in keras : <p>I have cloned human pose estimation keras model from this link <a href="https://github.com/michalfaber/keras_Realtime_Multi-Person_Pose_Estimation" rel="noreferrer">human pose estimation keras</a> </p> <p>When I try to load the model on google colab, I get the following error</p> <p>code</p> <pre><code>from keras.models import load_model model = load_model('model.h5') </code></pre> <p>error</p> <pre><code>ValueError Traceback (most recent call last) &lt;ipython-input-29-bdcc7d8d338b&gt; in &lt;module&gt;() 1 from keras.models import load_model ----&gt; 2 model = load_model('model.h5') /usr/local/lib/python3.6/dist-packages/keras/engine/saving.py in load_model(filepath, custom_objects, compile) 417 f = h5dict(filepath, 'r') 418 try: --&gt; 419 model = _deserialize_model(f, custom_objects, compile) 420 finally: 421 if opened_new_file: /usr/local/lib/python3.6/dist-packages/keras/engine/saving.py in _deserialize_model(f, custom_objects, compile) 219 return obj 220 --&gt; 221 model_config = f['model_config'] 222 if model_config is None: 223 raise ValueError('No model found in config.') /usr/local/lib/python3.6/dist-packages/keras/utils/io_utils.py in __getitem__(self, attr) 300 else: 301 if self.read_only: --&gt; 302 raise ValueError('Cannot create group in read only mode.') 303 val = H5Dict(self.data.create_group(attr)) 304 return val ValueError: Cannot create group in read only mode. </code></pre> <p>Can someone please help me understand this read-only mode? How do I load this model?</p>
0debug
How to install Docker on 32bit machine having Ubuntu 12.04? : <p>I have followed the <a href="https://docs.docker.com/engine/installation/linux/ubuntulinux/" rel="noreferrer">docker installation doc</a> for installing it on my machine which is a 32 bit machine running Ubuntu 12.04</p> <p>The step</p> <pre><code>$ sudo apt-get install docker-engine </code></pre> <p>fails saying</p> <pre><code>E: Unable to locate package docker-engine </code></pre> <p>It should have been installed, right?</p> <p>Also I came to know that, Docker currently only supports 64bit platforms. </p> <pre><code>$ wget -qO- https://get.docker.io/ | sh Error: you are not using a 64bit platform. Docker currently only supports 64bit platforms. </code></pre> <p>Is there a way to I install it and make it work on 32bit machine?</p>
0debug
How to darken the entire page except the specific elements : <p>Do you know how it looks like a <a href="https://www.bing.com/" rel="nofollow noreferrer">bing</a> page, when the SearchTextBox.focus() darkens the rest of the page?</p>
0debug
How to add duplicates in intersection of two sets in python : <p>Let suppose I have two sets </p> <pre><code>a = {1,2,3,4} b = {2,2,5,7,3,3} </code></pre> <p>So when I take a intersection of these two sets , I also want duplicates in my result </p> <pre><code>c = a.intersection(b) print (c) {2,2,3,3} </code></pre>
0debug
What is the difference between these two variations of collection initialiser expressions? : <p>I've been using C# for a while, but recently noticed that the behaviour of one of my unit tests changed depending on which variation of collection initialiser expression I used:</p> <ul> <li><code>var object = new Class { SomeCollection = new List&lt;int&gt; { 1, 2, 3 } };</code></li> <li><code>var object = new Class { SomeCollection = { 1, 2, 3 } };</code></li> </ul> <p>Up until this point I assumed that the second form was just syntactic sugar and was semantically equivalent to the first form. However, switching between these two forms resulted in my failing unit test passing.</p> <p>The example code below demonstrates this:</p> <pre class="lang-cs prettyprint-override"><code>void Main() { var foo1 = new Foo { Items = new List&lt;int&gt; { 1, 2, 3} }; var foo2 = new Foo { Items = { 1, 2, 3 } }; foo1.Dump(); foo2.Dump(); } class Foo { public List&lt;int&gt; Items { get; set; } } </code></pre> <p>When I run this, the first assignment works fine but the second results in a <code>NullReferenceException</code>.</p> <p>My gut feeling is that behind the scenes the compiler is treating these two expressions as this:</p> <pre class="lang-cs prettyprint-override"><code>var foo1 = new Foo(); foo1.Items = new List&lt;int&gt; { 1, 2, 3 }; var foo2 = new Foo(); foo2.Items.Add(1); foo2.Items.Add(2); foo2.Items.Add(3); </code></pre> <p>Is that assumption accurate?</p>
0debug
Ruby shuffle two arrays non-randomly : I have two different arrays with arrays in them: Vowels = [['a', 'a'], ['a', 'e'], ['a', 'i']...] Consonants = [['b', 'b', 'b'], ['b', 'b', 'c'], ['b', 'b', 'd']...] I want to be able to mix them together into every possible combination, without losing or adding content, with a function > allmixes(Vowels, Consonants) => [['a', 'a', 'b', 'b', 'b'], ['a', 'b', 'b', 'b', 'a']...] By mix, I mean that I need the two arrays two have a sort of combination without duplicates, or a shuffle that follows a pattern letting me call a certain result by index.
0debug
Error: Could not find or load main class - Whenever i make a new java file : im currently working on a group project, we are using Eclipse to make a java program and using e-git (eclipse extension) to work together. For some reason today, whenever im trying to make an new java file in the package it will give me the error Error: Could not find or load main class projectPackage.filename, i have no idea what is causing the error as it was fine yesterday.
0debug
angular2-cli gives @multi styles error : <p>I started using angular2-cli recently and created a new project. I wanted to use bootstrap in my project hence I installed bootstrap and then wanted to import the bootstrap css file like it is shown in the the angular2-cli guide here. <a href="https://github.com/angular/angular-cli#global-library-installation" rel="noreferrer">https://github.com/angular/angular-cli#global-library-installation</a> After running ng serve I get the following error.</p> <blockquote> <p>ERROR in multi styles Module not found: Error: Can't resolve '/home/krishna/angular2_migrate/webui/node_modules/bootstrap/dist/css/bootstrap.min.css' in '/home/krishna/angular2_migrate/webui/node_modules/angular-cli/models' @ multi styles</p> </blockquote> <p>What am I doing wrong ?</p> <p>Information about angular2-cli version</p> <pre><code>krishna@Krishna:~/angular2_migrate/webui$ ng version Could not start watchman; falling back to NodeWatcher for file system events. Visit http://ember-cli.com/user-guide/#watchman for more info. angular-cli: 1.0.0-beta.17 node: 4.4.3 os: linux x64 </code></pre>
0debug
Where is the Messages Window in Android Studio 3.1 : <p>After upgrading Android Studio from 3.0 to 3.1, the Messages window seems to have disappeared, even though some build outputs (e.g. proguard) continue to refer to it. Where is it?</p>
0debug
why is the result showing segmentation fault? : <p>The program ask the user to enter the two values, after storing the values in the pointers, it print segmentation fault and terminate.why?</p> <pre><code>// c program to add two numbers using pointers #include &lt;stdio.h&gt; int main() { int *ptr1, *ptr2, sum; printf ("Enter the two numbers:\n"); scanf ("%d %d", ptr1, ptr2); sum = *ptr1 + *ptr2; printf("The result is %d", sum); return 0; </code></pre>
0debug
Angular testing techniques Jasmine vs karma vs protractor in Angular 2? : <p>I am new in angular testing. Can anyone tell me about the difference between these above 3 techniques?</p>
0debug
im trying to echo an php code with mysqli inside an html eho : im trying to echo my php while loop inside a html echo basically echo inside echo. can someone help me? is that possible? here is my entire code: <?php session_start(); require 'config.php'; if (@$_SESSION['username']) { $query = "SELECT * FROM `crew_info`"; $query_run = mysqli_query($conn,$query); echo '<!DOCTYPE html> <html> <head> <title>All Crew</title> </head> <body> <table> <tr> <th>First Name: </th> <th>Middle Name: </th> <th>Last Name: </th> <th>Age: </th> <th>Birth Date: </th> <th>Birth Place: </th> <th>Gender: </th> <th>Martial Status: </th> <th>Nationality: </th> <th>Email Address: </th> <th>Address 1: </th> <th>Address 2: </th> <th>Course: </th> <th>School Graduated: </th> <th>Remarks: </th> <th>Date Added: </th> <th>Status: </th> </tr> <tr> while($record = mysqli_fetch_assoc($query_run)) { echo "<tr>"; echo "<th>".$record['first_name']."</th>"; echo "<th>".$record['middle_name']."</th>"; echo "<th>".$record['last_name']."</th>"; echo "<th>".$record['age']."</th>"; echo "<th>".$record['birth_date']."</th>"; echo "<th>".$record['birth_place']."</th>"; echo "<th>".$record['gender']."</th>"; echo "<th>".$record['martial_status']."</th>"; echo "<th>".$record['nationality']."</th>"; echo "<th>".$record['email_address']."</th>"; echo "<th>".$record['address_1']."</th>"; echo "<th>".$record['address_2']."</th>"; echo "<th>".$record['course']."</th>"; echo "<th>".$record['school_graduated']."</th>"; echo "<th>".$record['remarks']."</th>"; echo "<th>".$record['date_added']."</th>"; echo "<th>".$record['crew_status']."</th>"; echo "</tr><br>"; </tr> </table> </body> </html>'; } } else { header('Location: /practice1/index.php'); } ?> this is what my codes look like. i hope someone can help me
0debug
static void update_cursor_data_virgl(VirtIOGPU *g, struct virtio_gpu_scanout *s, uint32_t resource_id) { uint32_t width, height; uint32_t pixels, *data; data = virgl_renderer_get_cursor_data(resource_id, &width, &height); if (!data) { return; } if (width != s->current_cursor->width || height != s->current_cursor->height) { return; } pixels = s->current_cursor->width * s->current_cursor->height; memcpy(s->current_cursor->data, data, pixels * sizeof(uint32_t)); }
1threat
Default constructor does not initialize the instance members of the class? : <p>I encountered a question that asks "Which of the following are true about the "default" constructor?"</p> <p>and an option "It initializes the instance members of the class." was incorrect choice.</p> <p>Now my understanding was that if we have a code such as</p> <pre><code> Class Test { String name; } </code></pre> <p>then the compiler creates default constructor that looks like</p> <pre><code> Class Test { String name; Test(){ super(); name = null; } } </code></pre> <p>Isn't the default constructor initializing the instance member name=null ?</p>
0debug
How to prevent submission of form : <p>I have a form with ajax calls:</p> <pre><code>&lt;form method="post" action="?slt=Sbmt" onsubmit="return validateForm()" id="reportform" enctype="multipart/form-data"&gt; &lt;div id="evaluation1"&gt; &lt;h2&gt;Rate Technical Skills&lt;/h2&gt; &lt;table class="quartz-table" id="techskills_table"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Driver&lt;/th&gt; &lt;th&gt;Sub-Driver&lt;/th&gt; &lt;th class="sorter-false"&gt;Skill&lt;/th&gt; &lt;th class="sorter-false"&gt;Marks&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;?php foreach( $subdriver as $sbdriver =&gt; $sbd ) { $skillsResult = getTechSkills($yes, $role, $sbd); $countTech = 0; while($row = mysqli_fetch_array($skillsResult)) { $id = $row['id']; $driver = $row['driver']; $subdriver = $row['subdriver']; $dep = $row['department']; $skill = $row['skills']; $vrgood = $row['4']; $good = $row['3']; $middle = $row['2']; $low = $row['1']; ?&gt; &lt;tbody&gt; &lt;tr class="full_qst"&gt; &lt;td&gt;&lt;?php echo $driver; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $subdriver; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $skill; ?&gt;&lt;/td&gt; &lt;td&gt; &lt;img alt="" src="imagesAssessment/check.png" class="check"&gt; &lt;div class="mrk"&gt; &lt;label class="choice" for="q1_a" &gt;&lt;input class="q" name="q1_a[]" type="checkbox" value="&lt;?php echo $low ?&gt;"/&gt;1&lt;/label&gt; &lt;label class="choice" for="q1_b" &gt;&lt;input class="q" name="q1_a[]" type="checkbox" value="&lt;?php echo $middle ?&gt;"/&gt;2&lt;/label&gt; &lt;label class="choice" for="q1_c" &gt;&lt;input class="q" name="q1_a[]" type="checkbox" value="&lt;?php echo $good ?&gt;"/&gt;3&lt;/label&gt; &lt;label class="choice" for="q1_d" &gt;&lt;input class="q" name="q1_a[]" type="checkbox" value="&lt;?php echo $vrgood ?&gt;"/&gt;4&lt;/label&gt; &lt;/div&gt; &lt;input id="q" name="q[]" type="hidden" value="&lt;?php echo $id; ?&gt;" /&gt; &lt;input name="dep[]" type="hidden" value="&lt;?php echo $dep; ?&gt;" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;?php $countTech++; } } ?&gt; &lt;/table&gt; &lt;button type='button' class='ev_quest2' data-id3="&lt;?php echo $yes.'|'.$role.'|'.$quarter.'|'.$username.'|'.$staffid; ?&gt;"&gt;Performance Skills&lt;/button&gt; &lt;/div&gt; &lt;div id="evaluation3"&gt;&lt;/div&gt; &lt;br/&gt;&lt;br/&gt;&lt;br/&gt; &lt;/form&gt; </code></pre> <p>I call ajax to display in evaluation3 . Here is code to display data:</p> <pre><code>$(document).on('click', '.ev_quest3', function(){ var row_number2 = "&lt;?php echo $countPerf; ?&gt;"; var checked_number2 = $("#evaluation2 :checkbox:checked").length; if(row_number2 == checked_number2){ var evaluation3 = $(this).data("id3"); $.ajax({ url: "comAssessment/scoreboard_evaluation_closed.php", method: "POST", data: {evaluation3: evaluation3}, dataType:"text", success: function (data) { $('.quest3').hide(); $("#evaluation3").hide().html(data).show("slide", { direction: "up" }, 1500); } }); }else{ alert('Please Rate all Performance Skills first!'); } }); </code></pre> <p>So I check sum of checked checkboxes and sum of checkboxes from the database. If its not equal then system wont upload data. In the end I want to check if all checkboxes of id evaluation3 are checked. If yes then submit the form if not just give alert and stay on the page. </p> <p>And here is scoreboard_evaluation_closed.php:</p> <pre><code>&lt;table id="closedquest_table" class="quartz-table"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th class="sorter-false"&gt;Skill&lt;/th&gt; &lt;th class="sorter-false"&gt;Marks&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;?php while($row = mysqli_fetch_array($closedResult)) { $id = $row['id']; $dep = $row['department']; $skill = $row['question']; $vrgood = $row['4']; $good = $row['3']; $middle = $row['2']; $low = $row['1']; ?&gt; &lt;tbody&gt; &lt;tr class="full_qst"&gt; &lt;td&gt;&lt;?php echo $skill; ?&gt;&lt;/td&gt; &lt;td&gt; &lt;img alt="" src="imagesAssessment/check.png" class="check"&gt; &lt;div class="mrk"&gt; &lt;label class="choice" for="q1_a" &gt;&lt;input class="q" name="q1_a[]" type="checkbox" value="&lt;?php echo $low ?&gt;"/&gt;1&lt;/label&gt; &lt;label class="choice" for="q1_a" &gt;&lt;input class="q" name="q1_a[]" type="checkbox" value="&lt;?php echo $middle ?&gt;"/&gt;2&lt;/label&gt; &lt;label class="choice" for="q1_a" &gt;&lt;input class="q" name="q1_a[]" type="checkbox" value="&lt;?php echo $good ?&gt;"/&gt;3&lt;/label&gt; &lt;label class="choice" for="q1_a" &gt;&lt;input class="q" name="q1_a[]" type="checkbox" value="&lt;?php echo $vrgood ?&gt;"/&gt;4&lt;/label&gt; &lt;/div&gt; &lt;input id="q" name="q[]" type="hidden" value="&lt;?php echo $id; ?&gt;" /&gt; &lt;input name="dep[]" type="hidden" value="&lt;?php echo $dep; ?&gt;" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;?php $countClosed++; } ?&gt; &lt;/table&gt; </code></pre> <p>And function to prevent submission if not all checkboxes are checked:</p> <pre><code>$(function () { $('form').on('submit', function (e) { var row_number3 = "&lt;?php echo $countClosed; ?&gt;"; var checked_number3 = $("#evaluation3 :checkbox:checked").length; if(row_number3 != checked_number3){ e.preventDefault(); alert(/*'Please Rate all Closed Questions'*/ row_number3+' a / b '+checked_number3); } }); }); </code></pre> <p>So the problem is it gets me alert message but it also submit the form after giving first alert message. How can I prevent form from submission if not all checkboxes are checked?</p>
0debug
static void virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) { SCSIDevice *d = virtio_scsi_device_find(s, req->req.tmf->lun); SCSIRequest *r, *next; BusChild *kid; int target; req->resp.tmf->response = VIRTIO_SCSI_S_OK; tswap32s(&req->req.tmf->subtype); switch (req->req.tmf->subtype) { case VIRTIO_SCSI_T_TMF_ABORT_TASK: case VIRTIO_SCSI_T_TMF_QUERY_TASK: if (!d) { goto fail; } if (d->lun != virtio_scsi_get_lun(req->req.tmf->lun)) { goto incorrect_lun; } QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) { VirtIOSCSIReq *cmd_req = r->hba_private; if (cmd_req && cmd_req->req.cmd->tag == req->req.tmf->tag) { break; } } if (r) { assert(r->hba_private); if (req->req.tmf->subtype == VIRTIO_SCSI_T_TMF_QUERY_TASK) { req->resp.tmf->response = VIRTIO_SCSI_S_FUNCTION_SUCCEEDED; } else { scsi_req_cancel(r); } } break; case VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET: if (!d) { goto fail; } if (d->lun != virtio_scsi_get_lun(req->req.tmf->lun)) { goto incorrect_lun; } s->resetting++; qdev_reset_all(&d->qdev); s->resetting--; break; case VIRTIO_SCSI_T_TMF_ABORT_TASK_SET: case VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET: case VIRTIO_SCSI_T_TMF_QUERY_TASK_SET: if (!d) { goto fail; } if (d->lun != virtio_scsi_get_lun(req->req.tmf->lun)) { goto incorrect_lun; } QTAILQ_FOREACH_SAFE(r, &d->requests, next, next) { if (r->hba_private) { if (req->req.tmf->subtype == VIRTIO_SCSI_T_TMF_QUERY_TASK_SET) { req->resp.tmf->response = VIRTIO_SCSI_S_FUNCTION_SUCCEEDED; break; } else { scsi_req_cancel(r); } } } break; case VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET: target = req->req.tmf->lun[1]; s->resetting++; QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { d = DO_UPCAST(SCSIDevice, qdev, kid->child); if (d->channel == 0 && d->id == target) { qdev_reset_all(&d->qdev); } } s->resetting--; break; case VIRTIO_SCSI_T_TMF_CLEAR_ACA: default: req->resp.tmf->response = VIRTIO_SCSI_S_FUNCTION_REJECTED; break; } return; incorrect_lun: req->resp.tmf->response = VIRTIO_SCSI_S_INCORRECT_LUN; return; fail: req->resp.tmf->response = VIRTIO_SCSI_S_BAD_TARGET; }
1threat
Form with POST, how to get variable into Form : <p>I wanna make a form where the variables are gotten by the URL My_url com/email.html?name=Myname </p> <p>For example the name is introduced by default as "MyName" <a href="https://i.stack.imgur.com/SgBai.png" rel="nofollow noreferrer">IMAGE</a></p> <p>How would could I do this? The HTML code. <a href="https://codepaste.net/sqq43i" rel="nofollow noreferrer">https://codepaste.net/sqq43i</a></p> <p>The PHP code.</p> <pre><code>$field_name = $_POST['name']; $field_email = $_POST['email']; $field_message = $_POST['text']; $mail_to = 'MyMail'; $subject = 'Message from a site visitor '.$field_name; $body_message = 'From: '.$field_name."\n"; $body_message .= 'E-mail: '.$field_email."\n"; $body_message .= 'Message: '.$field_message; $headers = 'From: '.$field_email."\r\n"; $headers .= 'Reply-To: '.$field_email."\r\n"; $mail_status = mail($mail_to, $subject, $body_message, $headers); </code></pre>
0debug
def find_peak_util(arr, low, high, n): mid = low + (high - low)/2 mid = int(mid) if ((mid == 0 or arr[mid - 1] <= arr[mid]) and (mid == n - 1 or arr[mid + 1] <= arr[mid])): return mid elif (mid > 0 and arr[mid - 1] > arr[mid]): return find_peak_util(arr, low, (mid - 1), n) else: return find_peak_util(arr, (mid + 1), high, n) def find_peak(arr, n): return find_peak_util(arr, 0, n - 1, n)
0debug
How to restrict the jenkins pipeline docker agent in specific slave? : <p>I have several jenkins slaves configured and only label with <code>dockerserver</code> has docker env, then how can I restrict the jenkins pipeline docker agent in this slave?</p> <p>Below <code>Jenkinsfile</code> doesn't work, the <code>agent</code> inside <code>stage</code> will overwrite the defined slave <code>dockerserver</code></p> <pre> pipeline { agent { label 'dockerserver' } stages { stage('Back-end') { agent { docker { image 'maven:3-alpine' } } steps { sh 'mvn --version' } } stage('Front-end') { agent { docker { image 'node:7-alpine' } } steps { sh 'node --version' } } } } </pre> <p>It may pick other slave which doesn't have docker supported</p> <p>Any suggestion?</p>
0debug
Roundup using math : <p>I have a amount 100001, i want to round it up to nearest 10000. my expected output after roundup would be 110000.</p> <p>How to do that using c#??</p>
0debug
Android Studio with JSON URL does not give any result : <p>I have a situation whats getting annoying because i can't get a result. Im trying to use a localhost JSON GET call. When i use this URL in my browser i get a JSON RESULT (not xml) <a href="http://localhost:8080/Boxbackend/webresources/entities.movingboxes" rel="nofollow">http://localhost:8080/Boxbackend/webresources/entities.movingboxes</a></p> <pre><code>[ { "boxId": 1, "boxName": "Stuff_1" }, { "boxId": 2, "boxName": "Stuff_2" }, { "boxId": 3, "boxName": "Stuff_3" } ] </code></pre> <p>I used this netbeans tutorial to create a RESTful Web Service</p> <p><a href="https://netbeans.org/kb/docs/websvc/rest.html" rel="nofollow">https://netbeans.org/kb/docs/websvc/rest.html</a></p> <p>I used this example for android studio</p> <p><a href="https://www.learn2crack.com/2013/10/android-asynctask-json-parsing-example.html" rel="nofollow">https://www.learn2crack.com/2013/10/android-asynctask-json-parsing-example.html</a></p> <p>when the url is passing:</p> <pre><code>JSONObject json = jParser.getJSONFromUrl(url); </code></pre> <p>json gets result null and and exception is fired sometimes the exception : android.os.NetworkOnMainThreadException</p> <p>instead of localhost i also uses sometimes 10.0.2.2</p> <p>im getting a little frustrated.. </p> <p>perhaps somebody can help</p> <p>extra info:</p> <p>the Mainactivity onCreate has a button</p> <pre><code>Button box_list_button=(Button)findViewById(R.id.box_list_button); box_list_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { i = new Intent(getApplicationContext(), boxlist.class); startActivity(i); } }); </code></pre> <p>the boxlist.class is like</p> <pre><code> public class boxlist extends Activity { ArrayList mobileArray; String [] mobileResult = {"there is no data"}; private static String url = "http://localhost:8080/Boxbackend/webresources/entities.movingboxes"; JSONArray mbox = null; private static final String TAG_BNAME = "boxName"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.movingbox_layout); new JSONParse().execute(); } private class JSONParse extends AsyncTask&lt;String, String, JSONObject&gt; { private ProgressDialog pDialog; @Override protected void onPreExecute() { super.onPreExecute(); // uid = (TextView)findViewById(R.id.uid); // name1 = (TextView)findViewById(R.id.name); // email1 = (TextView)findViewById(R.id.email); pDialog = new ProgressDialog(boxlist.this); pDialog.setMessage("Getting Data ..."); pDialog.setIndeterminate(false); pDialog.setCancelable(true); pDialog.show(); } @Override protected JSONObject doInBackground(String... args) { JSONParser jParser = new JSONParser(); // Getting JSON from URL JSONObject json = jParser.getJSONFromUrl(url); return json; } ....... </code></pre>
0debug
Python Regex Search For HTML Tag with UUID : I'm trying to match a single html whole tag with an id attribute which is a UUID. I tested it with an external resource to make sure the regex is correct with the same input string. The UUID is extracted dynamically so the string replacement is necessary. The output I get when printing is the whole input string which would suggest the regex is incorrect. What's going on here? The output I would would expect is for the last line to print: <tr class="ref_row" id="b9060ff1-015d-4089-a193-8fef57e7c2ef"> This is the code I tried: content = '<tbody><tr class="ref_row" id="b9060ff1-015d-4089-a193-8fef57e7c2ef"><td><b>01/08/2016 14:41:00</b></td>' ref = 'b9060ff1-015d-4089-a193-8fef57e7c2ef' regex = '<[^>]+?id=\"%s\"[^<]*?>' % ref regex_comp = re.compile(regex) element_to_link = regex_comp.search(content) print element_to_link.string I also tried: element_to_link = re.search(regex, content) Which yielded the same result. Please don't suggest that I use Beautiful Soup, this should be possible to do with regular expressions. Thank you for taking the time to read my question
0debug
static int stdio_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int size) { QEMUFileStdio *s = opaque; return fwrite(buf, 1, size, s->stdio_file); }
1threat