problem
stringlengths
26
131k
labels
class label
2 classes
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, enum AVSampleFormat sample_fmt, int size, int64_t channel_layout, int planar) { AVFilterBufferRef *ret = NULL; if (link->dstpad->get_audio_buffer) ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); if (!ret) ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar); if (ret) ret->type = AVMEDIA_TYPE_AUDIO; return ret; }
1threat
static int usb_hub_handle_data(USBDevice *dev, USBPacket *p) { USBHubState *s = (USBHubState *)dev; int ret; switch(p->pid) { case USB_TOKEN_IN: if (p->devep == 1) { USBHubPort *port; unsigned int status; int i, n; n = (NUM_PORTS + 1 + 7) / 8; if (p->len == 1) { n = 1; } else if (n > p->len) { return USB_RET_BABBLE; } status = 0; for(i = 0; i < NUM_PORTS; i++) { port = &s->ports[i]; if (port->wPortChange) status |= (1 << (i + 1)); } if (status != 0) { for(i = 0; i < n; i++) { p->data[i] = status >> (8 * i); } ret = n; } else { ret = USB_RET_NAK; } } else { goto fail; } break; case USB_TOKEN_OUT: default: fail: ret = USB_RET_STALL; break; } return ret; }
1threat
Explain after *r=*q : <p>Not able to understand int *r=*q; and (*r)++;(Here,r is a pointer pointing to an integer on LHS after = sign,how to form the analogy?)</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { int a=100; int *p=&amp;a; int **q=&amp;p; int b=(**q)++; int *r=*q; ++(*r); cout&lt;&lt;a&lt;&lt;" "&lt;&lt;b&lt;&lt;endl; getchar(); } </code></pre>
0debug
c++ How to a exit a function that calls itself? : void function () { if (condition) { do something }else if (other condition) { go back to main() } function(); } In here, this function will always call itself, no mater what I replace 'go back to main()' with. return; exit; break; Code above does not work. Can anyone help?
0debug
How to instantiate an object in TypeScript by specifying each property and its value? : <p>Here's a snippet in which I instantiate a new <code>content</code> object in my service:</p> <pre><code>const newContent = new Content( result.obj.name result.obj.user.firstName, result.obj._id, result.obj.user._id, ); </code></pre> <p>The problem is that this way of object instantiation relies on the order of properties in my <code>content</code> model. I was wondering if there's a way to do it by mapping every property to the value I want to set it to, for example:</p> <pre><code> const newContent = new Content( name: result.obj.name, user: result.obj.user. content_id: result.obj._id, user_id: result.obj.user._id, ); </code></pre>
0debug
static void quiesce_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); SCLPEventClass *k = SCLP_EVENT_CLASS(klass); dc->reset = quiesce_reset; dc->vmsd = &vmstate_sclpquiesce; set_bit(DEVICE_CATEGORY_MISC, dc->categories); k->init = quiesce_init; k->get_send_mask = send_mask; k->get_receive_mask = receive_mask; k->can_handle_event = can_handle_event; k->read_event_data = read_event_data; k->write_event_data = NULL; }
1threat
What is the being called here: return _() : <p>I have come across this code in MoreLinq, in file <code>Batch.cs</code> (<a href="https://github.com/morelinq/MoreLINQ/blob/master/MoreLinq/Batch.cs#L96" rel="noreferrer">link</a>):</p> <pre><code>return _(); IEnumerable&lt;TResult&gt; _() </code></pre> <p>I read up on discards, but nevertheless I cannot make sense of the above code. When I hover above the first <code>_</code> it says: "Variables captured: resultSelector, collection".</p> <ul> <li>What do the two <code>_()</code> represent?</li> <li>Since we are doing a <code>return _();</code>, how can the subsequent code <code>IEnumerable&lt;TResult&gt; _()</code> still be executed?</li> </ul>
0debug
static void rtas_nvram_fetch(PowerPCCPU *cpu, sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { sPAPRNVRAM *nvram = spapr->nvram; hwaddr offset, buffer, len; int alen; void *membuf; if ((nargs != 3) || (nret != 2)) { rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } if (!nvram) { rtas_st(rets, 0, RTAS_OUT_HW_ERROR); rtas_st(rets, 1, 0); return; } offset = rtas_ld(args, 0); buffer = rtas_ld(args, 1); len = rtas_ld(args, 2); if (((offset + len) < offset) || ((offset + len) > nvram->size)) { rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); rtas_st(rets, 1, 0); return; } membuf = cpu_physical_memory_map(buffer, &len, 1); if (nvram->drive) { alen = bdrv_pread(nvram->drive, offset, membuf, len); } else { assert(nvram->buf); memcpy(membuf, nvram->buf + offset, len); alen = len; } cpu_physical_memory_unmap(membuf, len, 1, len); rtas_st(rets, 0, (alen < len) ? RTAS_OUT_HW_ERROR : RTAS_OUT_SUCCESS); rtas_st(rets, 1, (alen < 0) ? 0 : alen); }
1threat
static int rscc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { RsccContext *ctx = avctx->priv_data; GetByteContext *gbc = &ctx->gbc; GetByteContext tiles_gbc; AVFrame *frame = data; const uint8_t *pixels, *raw; uint8_t *inflated_tiles = NULL; int tiles_nb, packed_size, pixel_size = 0; int i, ret = 0; bytestream2_init(gbc, avpkt->data, avpkt->size); if (bytestream2_get_bytes_left(gbc) < 12) { av_log(avctx, AV_LOG_ERROR, "Packet too small (%d)\n", avpkt->size); return AVERROR_INVALIDDATA; tiles_nb = bytestream2_get_le16(gbc); av_fast_malloc(&ctx->tiles, &ctx->tiles_size, tiles_nb * sizeof(*ctx->tiles)); if (!ctx->tiles) { ret = AVERROR(ENOMEM); av_log(avctx, AV_LOG_DEBUG, "Frame with %d tiles.\n", tiles_nb); if (tiles_nb > 5) { uLongf packed_tiles_size; if (tiles_nb < 32) packed_tiles_size = bytestream2_get_byte(gbc); else packed_tiles_size = bytestream2_get_le16(gbc); ff_dlog(avctx, "packed tiles of size %lu.\n", packed_tiles_size); if (packed_tiles_size != tiles_nb * TILE_SIZE) { uLongf length = tiles_nb * TILE_SIZE; inflated_tiles = av_malloc(length); if (!inflated_tiles) { ret = AVERROR(ENOMEM); ret = uncompress(inflated_tiles, &length, gbc->buffer, packed_tiles_size); if (ret) { av_log(avctx, AV_LOG_ERROR, "Tile deflate error %d.\n", ret); ret = AVERROR_UNKNOWN; bytestream2_skip(gbc, packed_tiles_size); bytestream2_init(&tiles_gbc, inflated_tiles, length); gbc = &tiles_gbc; for (i = 0; i < tiles_nb; i++) { ctx->tiles[i].x = bytestream2_get_le16(gbc); ctx->tiles[i].w = bytestream2_get_le16(gbc); ctx->tiles[i].y = bytestream2_get_le16(gbc); ctx->tiles[i].h = bytestream2_get_le16(gbc); pixel_size += ctx->tiles[i].w * ctx->tiles[i].h * ctx->component_size; ff_dlog(avctx, "tile %d orig(%d,%d) %dx%d.\n", i, ctx->tiles[i].x, ctx->tiles[i].y, ctx->tiles[i].w, ctx->tiles[i].h); if (ctx->tiles[i].w == 0 || ctx->tiles[i].h == 0) { av_log(avctx, AV_LOG_ERROR, "invalid tile %d at (%d.%d) with size %dx%d.\n", i, ctx->tiles[i].x, ctx->tiles[i].y, ctx->tiles[i].w, ctx->tiles[i].h); } else if (ctx->tiles[i].x + ctx->tiles[i].w > avctx->width || ctx->tiles[i].y + ctx->tiles[i].h > avctx->height) { av_log(avctx, AV_LOG_ERROR, "out of bounds tile %d at (%d.%d) with size %dx%d.\n", i, ctx->tiles[i].x, ctx->tiles[i].y, ctx->tiles[i].w, ctx->tiles[i].h); gbc = &ctx->gbc; if (pixel_size < 0x100) packed_size = bytestream2_get_byte(gbc); else if (pixel_size < 0x10000) packed_size = bytestream2_get_le16(gbc); else if (pixel_size < 0x1000000) packed_size = bytestream2_get_le24(gbc); else packed_size = bytestream2_get_le32(gbc); ff_dlog(avctx, "pixel_size %d packed_size %d.\n", pixel_size, packed_size); if (packed_size < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid tile size %d\n", packed_size); if (pixel_size == packed_size) { if (bytestream2_get_bytes_left(gbc) < pixel_size) { av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", pixel_size); pixels = gbc->buffer; } else { uLongf len = ctx->inflated_size; if (bytestream2_get_bytes_left(gbc) < packed_size) { av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", packed_size); ret = uncompress(ctx->inflated_buf, &len, gbc->buffer, packed_size); if (ret) { av_log(avctx, AV_LOG_ERROR, "Pixel deflate error %d.\n", ret); ret = AVERROR_UNKNOWN; pixels = ctx->inflated_buf; ret = ff_reget_buffer(avctx, ctx->reference); if (ret < 0) raw = pixels; for (i = 0; i < tiles_nb; i++) { uint8_t *dst = ctx->reference->data[0] + ctx->reference->linesize[0] * (avctx->height - ctx->tiles[i].y - 1) + ctx->tiles[i].x * ctx->component_size; av_image_copy_plane(dst, -1 * ctx->reference->linesize[0], raw, ctx->tiles[i].w * ctx->component_size, ctx->tiles[i].w * ctx->component_size, ctx->tiles[i].h); raw += ctx->tiles[i].w * ctx->component_size * ctx->tiles[i].h; ret = av_frame_ref(frame, ctx->reference); if (ret < 0) if (pixel_size == ctx->inflated_size) { frame->pict_type = AV_PICTURE_TYPE_I; frame->key_frame = 1; } else { frame->pict_type = AV_PICTURE_TYPE_P; if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { int size; const uint8_t *palette = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); if (palette && size == AVPALETTE_SIZE) { frame->palette_has_changed = 1; memcpy(ctx->palette, palette, AVPALETTE_SIZE); } else if (palette) { av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); memcpy (frame->data[1], ctx->palette, AVPALETTE_SIZE); *got_frame = 1; ret = avpkt->size; end: av_free(inflated_tiles); return ret;
1threat
QT: how to safely store data such that it is not possible to rewrite the data from outside the application? : I am still learning QT, and this thing come to my mind: If I design a software and I want some data to be saved and protected. But all the ways I know about saving data from QT Creator applications are writing into files which can be easily altered and deleted. Is there any way that I can safely store some application data and no one else can access it without breaking the applcation? This might be a stupid question, but I am actually looking forward to some idea. Thanks a lot.
0debug
[C#][Windows Forms] How to stop passing value from one form to other in formclosing event? : So, I got 2 forms (form1,form2),**form1** is the main form. I got one textbox and one radiobutton and a simple button in form2, and 1 onlyreadable-textbox with label on the side, and simple button in **form1**. The form1 button opens the form2 window. In form2, I can write numbers in textbox, and then select the valute on radio button(Euro) and when I click on the passvalue button the numbers and valute are passed to the form 1 textbox(numbers) and label(valute). That works fine, but when I open the form2 window and don't write anything in textbox, also don't check the radiobutt, and click on the red X for closing the form 2, the form will close and the values in form 1(where there was added values before) disappears. For example: I add a value of 2000 euros to form 1 textbox&label, and then when I open one more time the form2, and leave the texbox clear and radiobutt unchecked, close the form2 with the X, the form1 values of 2000 euros will disappear. Here's the source code of the passing values and buttons: FORM2 private string pss; public string Passvalue { get { return pss; } set { pss = value; } } private string pss2; public string Passvalue2 { get { return pss2; } set { pss2 = value; } } public void Btn1_Click(object sender, EventArgs e)//The passvalue button { string eur="EUR"; Passvalue = ukupnaCifraTB.Text;//textbox form2=the number sender ukupnaCifraTB.Text = String.Empty; if (radioButton1.Checked) { radioButton1.Text = eur; Passvalue2 = radioButton2.Text; } this.Close(); } Here's form1: private string backvalue; public string BackedValue { get { return backvalue; } set { backvalue = value; } } private string backedText; public string BackedText { get { return backedText; } set { backedText = value; } } public void Btn1_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.ShowDialog(); trenutnoStanjeTB.Text = f2.Passvalue;//trenutnostanjeTB=textbox(form1)=gets number from form2 DinEuLab1.Text = f2.Passvalue2;//dineulab1=label form1=gets the eur text DinEuLab2.Text = f2.Passvalue2; } What I need to change/add to resolve my problem? **I want that when I once pass the values, and then open the form2 and close it, to not send the empty values to form1.**
0debug
How to get a tensorflow op by name? : <p>You can get a tensor by name with <code>tf.get_default_graph().get_tensor_by_name("tensor_name:0")</code></p> <p>But can you get an operation, such as <code>Optimizer.minimize</code>, or an <code>enqueue</code> operation on a queue?</p> <p>In my first model I returned all tensors and ops I would need from a <code>build_model</code> function. But the list of tensors got ugly. In later models I tossed all tensors and ops in a dictionary for easier access. This time around I thought I'd just look up tensors by name as I needed them, but I don't know how to do that with ops.</p> <p>Or is there a better way to do this? I find various tensors and ops are needed all over the place. Training, inference code, test cases, hence the desire for a nice standard way of accessing the various parts of the graph without passing variables all over the place.</p>
0debug
static int find_debugfs(char *debugfs) { char type[100]; FILE *fp; fp = fopen("/proc/mounts", "r"); if (fp == NULL) { return 0; } while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n", debugfs, type) == 2) { if (strcmp(type, "debugfs") == 0) { break; } } fclose(fp); if (strcmp(type, "debugfs") != 0) { return 0; } return 1; }
1threat
php html dynamicly add to end of list items : i have some data on server side on database like person info. i like to at the first view, show e.g 3 person info on list like placement. OK i can do this by write query for read from database and write "for" in php and write html code and echo to fill 3 list item. OK now i need add link like "more persons" below this tree output and when user clicked this link php shows other persons info at the end of previous 3 person info without refresh page or redirecting. how can do that? thanks and sorry for English grammar mistakes
0debug
static uint64_t bmdma_read(void *opaque, target_phys_addr_t addr, unsigned size) { BMDMAState *bm = opaque; PCIIDEState *pci_dev = bm->pci_dev; uint32_t val; if (size != 1) { return ((uint64_t)1 << (size * 8)) - 1; } switch(addr & 3) { case 0: val = bm->cmd; break; case 1: val = pci_dev->dev.config[MRDMODE]; break; case 2: val = bm->status; break; case 3: if (bm == &pci_dev->bmdma[0]) { val = pci_dev->dev.config[UDIDETCR0]; } else { val = pci_dev->dev.config[UDIDETCR1]; } break; default: val = 0xff; break; } #ifdef DEBUG_IDE printf("bmdma: readb 0x%02x : 0x%02x\n", addr, val); #endif return val; }
1threat
Mockito - separately verifying multiple invocations on the same method : <pre><code>import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.verify; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; public class MockitoTest { public static class TestMock { public void doIt(String s) { } } public static void main(String[] args) { TestMock mock = Mockito.mock(TestMock.class); mock.doIt("1"); mock.doIt("2"); ArgumentCaptor&lt;String&gt; argument = ArgumentCaptor.forClass(String.class); verify(mock, atLeastOnce()).doIt(argument.capture()); System.out.println(argument.getValue()); verify(mock, atLeastOnce()).doIt(argument.capture()); System.out.println(argument.getValue()); } } </code></pre> <p>I expected this to print <code>1 2</code> but it instead prints <code>2 2</code>. It seems the '1' invocation is lost. Is there a way that I can verify that verifications happened with <code>1</code> and then <code>2</code>?</p>
0debug
void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs, int cba_idx, int cb1_idx, int cb2_idx, int gval, int gain) { int16_t *block; int m[3]; if (cba_idx) { cba_idx += BLOCKSIZE/2 - 1; ff_copy_and_dup(ractx->buffer_a, ractx->adapt_cb, cba_idx); m[0] = (ff_irms(&ractx->adsp, ractx->buffer_a) * gval) >> 12; } else { m[0] = 0; } m[1] = (ff_cb1_base[cb1_idx] * gval) >> 8; m[2] = (ff_cb2_base[cb2_idx] * gval) >> 8; memmove(ractx->adapt_cb, ractx->adapt_cb + BLOCKSIZE, (BUFFERSIZE - BLOCKSIZE) * sizeof(*ractx->adapt_cb)); block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE; add_wav(block, gain, cba_idx, m, cba_idx? ractx->buffer_a: NULL, ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]); memcpy(ractx->curr_sblock, ractx->curr_sblock + BLOCKSIZE, LPC_ORDER*sizeof(*ractx->curr_sblock)); if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + LPC_ORDER, lpc_coefs, block, BLOCKSIZE, LPC_ORDER, 1, 0, 0xfff)) memset(ractx->curr_sblock, 0, (LPC_ORDER+BLOCKSIZE)*sizeof(*ractx->curr_sblock)); }
1threat
static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen, char *tag, ID3v2ExtraMeta **extra_meta) { int enc, pic_type; char mimetype[64]; const CodecMime *mime = ff_id3v2_mime_tags; enum AVCodecID id = AV_CODEC_ID_NONE; ID3v2ExtraMetaAPIC *apic = NULL; ID3v2ExtraMeta *new_extra = NULL; int64_t end = avio_tell(pb) + taglen; if (taglen <= 4) goto fail; new_extra = av_mallocz(sizeof(*new_extra)); apic = av_mallocz(sizeof(*apic)); if (!new_extra || !apic) goto fail; enc = avio_r8(pb); taglen--; taglen -= avio_get_str(pb, taglen, mimetype, sizeof(mimetype)); while (mime->id != AV_CODEC_ID_NONE) { if (!av_strncasecmp(mime->str, mimetype, sizeof(mimetype))) { id = mime->id; break; } mime++; } if (id == AV_CODEC_ID_NONE) { av_log(s, AV_LOG_WARNING, "Unknown attached picture mimetype: %s, skipping.\n", mimetype); goto fail; } apic->id = id; pic_type = avio_r8(pb); taglen--; if (pic_type < 0 || pic_type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types)) { av_log(s, AV_LOG_WARNING, "Unknown attached picture type %d.\n", pic_type); pic_type = 0; } apic->type = ff_id3v2_picture_types[pic_type]; if (decode_str(s, pb, enc, &apic->description, &taglen) < 0) { av_log(s, AV_LOG_ERROR, "Error decoding attached picture description.\n"); goto fail; } apic->buf = av_buffer_alloc(taglen); if (!apic->buf || !taglen || avio_read(pb, apic->buf->data, taglen) != taglen) goto fail; new_extra->tag = "APIC"; new_extra->data = apic; new_extra->next = *extra_meta; *extra_meta = new_extra; return; fail: if (apic) free_apic(apic); av_freep(&new_extra); avio_seek(pb, end, SEEK_SET); }
1threat
iscsi_aio_write16_cb(struct iscsi_context *iscsi, int status, void *command_data, void *opaque) { IscsiAIOCB *acb = opaque; trace_iscsi_aio_write16_cb(iscsi, status, acb, acb->canceled); g_free(acb->buf); acb->buf = NULL; if (acb->canceled != 0) { return; } acb->status = 0; if (status < 0) { error_report("Failed to write16 data to iSCSI lun. %s", iscsi_get_error(iscsi)); acb->status = -EIO; } iscsi_schedule_bh(acb); }
1threat
static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track) { int i; avio_wb32(pb, 24); ffio_wfourcc(pb, "ACLR"); ffio_wfourcc(pb, "ACLR"); ffio_wfourcc(pb, "0001"); if (track->enc->color_range == AVCOL_RANGE_MPEG || track->enc->color_range == AVCOL_RANGE_UNSPECIFIED) { avio_wb32(pb, 1); } else { avio_wb32(pb, 2); } avio_wb32(pb, 0); avio_wb32(pb, 24); ffio_wfourcc(pb, "APRG"); ffio_wfourcc(pb, "APRG"); ffio_wfourcc(pb, "0001"); avio_wb32(pb, 1); avio_wb32(pb, 0); avio_wb32(pb, 120); ffio_wfourcc(pb, "ARES"); ffio_wfourcc(pb, "ARES"); ffio_wfourcc(pb, "0001"); avio_wb32(pb, AV_RB32(track->vos_data + 0x28)); avio_wb32(pb, track->enc->width); if (track->vos_data[5] & 2) { avio_wb32(pb, track->enc->height / 2); avio_wb32(pb, 2); avio_wb32(pb, 0); avio_wb32(pb, 4); } else { avio_wb32(pb, track->enc->height); avio_wb32(pb, 1); avio_wb32(pb, 0); if (track->enc->height == 1080) avio_wb32(pb, 5); else avio_wb32(pb, 6); } for (i = 0; i < 10; i++) avio_wb64(pb, 0); avio_wb32(pb, 0); return 0; }
1threat
how can I use console.log for number division : <p>I try multiple times, but it keeps saying error. Please help</p> <p>Prompt the user for a number. Use console.log to display either</p> <p>This number is divisible by 3 </p> <p>or </p> <p>This number isn't divisible by 3 </p> <p>whichever is correct. </p>
0debug
How to remove edge between two vertices? : <p>I want to remove edge between two vertices, so my code in java tinkerpop3 as below</p> <pre><code>private void removeEdgeOfTwoVertices(Vertex fromV, Vertex toV,String edgeLabel,GraphTraversalSource g){ if(g.V(toV).inE(edgeLabel).bothV().hasId(fromV.id()).hasNext()){ List&lt;Edge&gt; edgeList = g.V(toV).inE(edgeLabel).toList(); for (Edge edge:edgeList){ if(edge.outVertex().id().equals(fromV.id())) { TitanGraph().tx(); edge.remove(); TitanGraph().tx().commit(); return;//Remove edge ok, now return. } } } } </code></pre> <p>Is there a simpler way to remove edge between two vertices by a direct query to that edge and remove it? Thank for your help.</p>
0debug
Cant retrieve user data form Firebase using query : I have the following firebase structure: Users" : { "angelbreath" : { "PvP_Wins" : 0, "PvP_scores" : 0, "avatar" : "https://i.imgur.com/qp9gnKE.png", "gender" : "Male", "userName" : "angelbreath", "user_class" : "Bard", "user_id" : "sC8JGw6SvMUGH4Id1HwcSf6Sl5n1" }, I m trying to get the data of current auth user with no luck because of null exception. After many tries i have end up with this code: private void showData() { DatabaseReference Users = database.getReference("Users"); final Query userQuery = Users.orderByChild("user_id"); final FirebaseUser user = firebaseAuth.getCurrentUser(); userQuery.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { for(DataSnapshot post : dataSnapshot.getChildren() ){ if(post.child("user_id").getValue().equals(user.getUid())){ Log.d("Output", "Found"); Log.d("Output", post.getKey().toString()); userClass.setText(post.child("user_class").getValue().toString()); userGender.setText(post.child("gender").getValue().toString()); }else{ Log.d("Output", "Failure"); } Log.d("Output", post.child("user_id").toString()); } } @Override public void onCancelled(DatabaseError databaseError) { } }); As i can understand because i m new to firebase, i have the right reference and i query the right way. I cant figure out why i get the exception. Just in case i have the following check too : //Checking whether a user as already Logged In if(firebaseAuth.getCurrentUser()==null){ finish(); //Starting the User Login Activity if the user is not Logged in startActivity(new Intent(this,MainActivity.class)); } So i think i have the current user and his id, so i querry Users with the user id. What is wrong? I ll appriciate any help!
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
How to do a function in Python? : im very new at coding and im learning python. im doing an simple program just to test my skills and im having some difficulties with getting a few info and turn it in a function to let the code cleanner. The error that im getting is this one: http://prntscr.com/im5pt7 Here is what i want to put inside a function: name = input(str("\nFull Name: ")) position = input(str("Position at the company: ")) print("\nConfirm Staff Data:\n") name_confirm = "Name: %s"%(name) position_confirm = "Position: %s"%(position) print(name_confirm) print(position_confirm) confirmAns = input("Is the information right? (Y/N)") if confirmAns == "y" or confirmAns == "Y": message = "\nSearching for %s"%(name) print(message) hoursWorked = int(input("Insert hours worked: ")) if hoursWorked <= 0: print("Please insert a valid number") elif hoursWorked > 0: print("\nCalculete Paycheck") hourRate = int(input("Insert the rate of each hour worked: ")) bonus = input("If a bonus was given insert it here: ") fine = input("If a fine was given insert it here: ") print('\n') payment = hoursWorked*hourRate-int(fine)+int(bonus) paymentMsg = "Your Payment is: $%d"%(payment) print(paymentMsg) elif confirmAns == "n" or confirmAns == "N": ctypes.windll.user32.MessageBoxW(0, "The software will close to avoid slowness.", "Warning", 1) else: print("Please answer with Y or N") I've tried [**THAT**][1] but it did not worked. Here is all the code (working but with out the function so i need to copy and paste code): https://pastebin.com/PA9mxMkk [1]: https://pastebin.com/i7yxfMtL
0debug
void clear_blocks_dcbz32_ppc(DCTELEM *blocks) { POWERPC_TBL_DECLARE(powerpc_clear_blocks_dcbz32, 1); register int misal = ((unsigned long)blocks & 0x00000010); register int i = 0; POWERPC_TBL_START_COUNT(powerpc_clear_blocks_dcbz32, 1); #if 1 if (misal) { ((unsigned long*)blocks)[0] = 0L; ((unsigned long*)blocks)[1] = 0L; ((unsigned long*)blocks)[2] = 0L; ((unsigned long*)blocks)[3] = 0L; i += 16; } for ( ; i < sizeof(DCTELEM)*6*64 ; i += 32) { asm volatile("dcbz %0,%1" : : "b" (blocks), "r" (i) : "memory"); } if (misal) { ((unsigned long*)blocks)[188] = 0L; ((unsigned long*)blocks)[189] = 0L; ((unsigned long*)blocks)[190] = 0L; ((unsigned long*)blocks)[191] = 0L; i += 16; } #else memset(blocks, 0, sizeof(DCTELEM)*6*64); #endif POWERPC_TBL_STOP_COUNT(powerpc_clear_blocks_dcbz32, 1); }
1threat
void mips_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, int flags) { MIPSCPU *cpu = MIPS_CPU(cs); CPUMIPSState *env = &cpu->env; int i; cpu_fprintf(f, "pc=0x" TARGET_FMT_lx " HI=0x" TARGET_FMT_lx " LO=0x" TARGET_FMT_lx " ds %04x " TARGET_FMT_lx " " TARGET_FMT_ld "\n", env->active_tc.PC, env->active_tc.HI[0], env->active_tc.LO[0], env->hflags, env->btarget, env->bcond); for (i = 0; i < 32; i++) { if ((i & 3) == 0) cpu_fprintf(f, "GPR%02d:", i); cpu_fprintf(f, " %s " TARGET_FMT_lx, regnames[i], env->active_tc.gpr[i]); if ((i & 3) == 3) cpu_fprintf(f, "\n"); } cpu_fprintf(f, "CP0 Status 0x%08x Cause 0x%08x EPC 0x" TARGET_FMT_lx "\n", env->CP0_Status, env->CP0_Cause, env->CP0_EPC); cpu_fprintf(f, " Config0 0x%08x Config1 0x%08x LLAddr 0x%016" PRIx64 "\n", env->CP0_Config0, env->CP0_Config1, env->lladdr); cpu_fprintf(f, " Config2 0x%08x Config3 0x%08x\n", env->CP0_Config2, env->CP0_Config3); cpu_fprintf(f, " Config4 0x%08x Config5 0x%08x\n", env->CP0_Config4, env->CP0_Config5); if (env->hflags & MIPS_HFLAG_FPU) fpu_dump_state(env, f, cpu_fprintf, flags); #if defined(TARGET_MIPS64) && defined(MIPS_DEBUG_SIGN_EXTENSIONS) cpu_mips_check_sign_extensions(env, f, cpu_fprintf, flags); #endif }
1threat
static void apb_config_writel (void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { APBState *s = opaque; APB_DPRINTF("%s: addr " TARGET_FMT_lx " val %" PRIx64 "\n", __func__, addr, val); switch (addr & 0xffff) { case 0x30 ... 0x4f: break; case 0x200 ... 0x20b: s->iommu[(addr & 0xf) >> 2] = val; break; case 0x20c ... 0x3ff: break; case 0xc00 ... 0xc3f: if (addr & 4) { s->pci_irq_map[(addr & 0x3f) >> 3] &= PBM_PCI_IMR_MASK; s->pci_irq_map[(addr & 0x3f) >> 3] |= val & ~PBM_PCI_IMR_MASK; } break; case 0x1000 ... 0x1080: if (addr & 4) { s->obio_irq_map[(addr & 0xff) >> 3] &= PBM_PCI_IMR_MASK; s->obio_irq_map[(addr & 0xff) >> 3] |= val & ~PBM_PCI_IMR_MASK; } break; case 0x1400 ... 0x143f: if (addr & 4) { pci_apb_set_irq(s, (addr & 0x3f) >> 3, 0); } break; case 0x1800 ... 0x1860: if (addr & 4) { pci_apb_set_irq(s, 0x20 | ((addr & 0xff) >> 3), 0); } break; case 0x2000 ... 0x202f: s->pci_control[(addr & 0x3f) >> 2] = val; break; case 0xf020 ... 0xf027: if (addr & 4) { val &= RESET_MASK; s->reset_control &= ~(val & RESET_WCMASK); s->reset_control |= val & RESET_WMASK; if (val & SOFT_POR) { s->nr_resets = 0; qemu_system_reset_request(); } else if (val & SOFT_XIR) { qemu_system_reset_request(); } } break; case 0x5000 ... 0x51cf: case 0xa400 ... 0xa67f: case 0xa800 ... 0xa80f: case 0xf000 ... 0xf01f: default: break; } }
1threat
PHP WITH MS SQL SERVER DOWNLOADING AND CONNECTING : I have a project written in php.Also,another application is written in C(sharp) with Ms Sql as the database engine. I want to fetch some data from the Ms Sql database and use it in php. I have tried many solution provided on stackover and other site, but none seems to work.Below are what I have done, maybe there is a place where i am missing something: 1. I Downloaded drivers(Ms Drivers for php) and loads it into the C:\wamp\bin\php\php5.5.12\ext directories.files are php_pdo_sqlsrv_55_nts.dll php_pdo_sqlsrv_55_ts.dll php_sqlsrv_55_nts.dll php_sqlsrv_55_ts.dll 2. Modify the php.ini by including the following in the extension area: extension=php_pdo_sqlsrv_55_nts.dll extension=php_pdo_sqlsrv_55_ts.dll extension=php_sqlsrv_55_nts.dll extension=php_sqlsrv_55_ts.dll Infact, one of the site says I should rename by removing the "_55_xx", so that it looks like php_sqlsrv.dll.yet it is still not working. 3. Restart the Apache server and discovered that the included files not activated or seen when you click on the wamp monitor,navigate to the php and view the extension directory. I have search and search,seems to be given up, but thought it better to communicate with others who can be of assistance. I currently use wamp and php version is php5.5.12. Please, I need a solution on how to get working drivers to connect my php with Ms Sql server and get data from the server seamlessly.
0debug
java arrayoutofbound exception after compiling : <pre><code>package binarywa; import java.util.*; public class binaryadd { public static void main(String args[]) { Scanner scan=new Scanner(System.in); String g=scan.next(); String s[]=g.split(""); int i,x=0; for(i=s.length;i&gt;0;i--) { x+=Integer.parseInt(s[i])*Math.pow(2,i); } } } </code></pre> <p>Im trying to convert binary into decimal</p> <p>but after compiling this im getting an arrayoutofbound exception</p> <p>eg: 541656(its the input) Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6 at binarywa.binaryadd.main(binaryadd.java:16)</p>
0debug
Please provide guidance in understanding recursion : <pre><code>public static int countX(String str) { if (str.length() == 0) { return 0; } if (str.charAt(0) == 'x') { return 1 + countX(str.substring(1)); } else { return countX(str.substring(1)); } } </code></pre> <p>Given an input String of "xxx", the method above shall return 3. I understand the flow of the method, the line <em>"return 1 + countX(str.substring(1));"</em> adds one if an 'x' is found. What I don't understand is how does that return value carry over to the next iteration/recursion? I don't see the value of the increment stored anywhere.</p>
0debug
static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn) { int op; int q; int rd, rn, rm; int size; int shift; int pass; int count; int pairwise; int u; int n; uint32_t imm, mask; TCGv tmp, tmp2, tmp3, tmp4, tmp5; TCGv_i64 tmp64; if (!s->vfp_enabled) return 1; q = (insn & (1 << 6)) != 0; u = (insn >> 24) & 1; VFP_DREG_D(rd, insn); VFP_DREG_N(rn, insn); VFP_DREG_M(rm, insn); size = (insn >> 20) & 3; if ((insn & (1 << 23)) == 0) { op = ((insn >> 7) & 0x1e) | ((insn >> 4) & 1); if (size == 3 && (op == 1 || op == 5 || op == 8 || op == 9 || op == 10 || op == 11 || op == 16)) { for (pass = 0; pass < (q ? 2 : 1); pass++) { neon_load_reg64(cpu_V0, rn + pass); neon_load_reg64(cpu_V1, rm + pass); switch (op) { case 1: if (u) { gen_helper_neon_add_saturate_u64(CPU_V001); } else { gen_helper_neon_add_saturate_s64(CPU_V001); } break; case 5: if (u) { gen_helper_neon_sub_saturate_u64(CPU_V001); } else { gen_helper_neon_sub_saturate_s64(CPU_V001); } break; case 8: if (u) { gen_helper_neon_shl_u64(cpu_V0, cpu_V1, cpu_V0); } else { gen_helper_neon_shl_s64(cpu_V0, cpu_V1, cpu_V0); } break; case 9: if (u) { gen_helper_neon_qshl_u64(cpu_V0, cpu_env, cpu_V1, cpu_V0); } else { gen_helper_neon_qshl_s64(cpu_V0, cpu_env, cpu_V1, cpu_V0); } break; case 10: if (u) { gen_helper_neon_rshl_u64(cpu_V0, cpu_V1, cpu_V0); } else { gen_helper_neon_rshl_s64(cpu_V0, cpu_V1, cpu_V0); } break; case 11: if (u) { gen_helper_neon_qrshl_u64(cpu_V0, cpu_env, cpu_V1, cpu_V0); } else { gen_helper_neon_qrshl_s64(cpu_V0, cpu_env, cpu_V1, cpu_V0); } break; case 16: if (u) { tcg_gen_sub_i64(CPU_V001); } else { tcg_gen_add_i64(CPU_V001); } break; default: abort(); } neon_store_reg64(cpu_V0, rd + pass); } return 0; } switch (op) { case 8: case 9: case 10: case 11: { int rtmp; rtmp = rn; rn = rm; rm = rtmp; pairwise = 0; } break; case 20: case 21: case 23: pairwise = 1; break; case 26: pairwise = (u && size < 2); break; case 30: pairwise = u; break; default: pairwise = 0; break; } for (pass = 0; pass < (q ? 4 : 2); pass++) { if (pairwise) { if (q) n = (pass & 1) * 2; else n = 0; if (pass < q + 1) { tmp = neon_load_reg(rn, n); tmp2 = neon_load_reg(rn, n + 1); } else { tmp = neon_load_reg(rm, n); tmp2 = neon_load_reg(rm, n + 1); } } else { tmp = neon_load_reg(rn, pass); tmp2 = neon_load_reg(rm, pass); } switch (op) { case 0: GEN_NEON_INTEGER_OP(hadd); break; case 1: GEN_NEON_INTEGER_OP_ENV(qadd); break; case 2: GEN_NEON_INTEGER_OP(rhadd); break; case 3: switch ((u << 2) | size) { case 0: tcg_gen_and_i32(tmp, tmp, tmp2); break; case 1: tcg_gen_andc_i32(tmp, tmp, tmp2); break; case 2: tcg_gen_or_i32(tmp, tmp, tmp2); break; case 3: tcg_gen_orc_i32(tmp, tmp, tmp2); break; case 4: tcg_gen_xor_i32(tmp, tmp, tmp2); break; case 5: tmp3 = neon_load_reg(rd, pass); gen_neon_bsl(tmp, tmp, tmp2, tmp3); dead_tmp(tmp3); break; case 6: tmp3 = neon_load_reg(rd, pass); gen_neon_bsl(tmp, tmp, tmp3, tmp2); dead_tmp(tmp3); break; case 7: tmp3 = neon_load_reg(rd, pass); gen_neon_bsl(tmp, tmp3, tmp, tmp2); dead_tmp(tmp3); break; } break; case 4: GEN_NEON_INTEGER_OP(hsub); break; case 5: GEN_NEON_INTEGER_OP_ENV(qsub); break; case 6: GEN_NEON_INTEGER_OP(cgt); break; case 7: GEN_NEON_INTEGER_OP(cge); break; case 8: GEN_NEON_INTEGER_OP(shl); break; case 9: GEN_NEON_INTEGER_OP_ENV(qshl); break; case 10: GEN_NEON_INTEGER_OP(rshl); break; case 11: GEN_NEON_INTEGER_OP_ENV(qrshl); break; case 12: GEN_NEON_INTEGER_OP(max); break; case 13: GEN_NEON_INTEGER_OP(min); break; case 14: GEN_NEON_INTEGER_OP(abd); break; case 15: GEN_NEON_INTEGER_OP(abd); dead_tmp(tmp2); tmp2 = neon_load_reg(rd, pass); gen_neon_add(size, tmp, tmp2); break; case 16: if (!u) { if (gen_neon_add(size, tmp, tmp2)) return 1; } else { switch (size) { case 0: gen_helper_neon_sub_u8(tmp, tmp, tmp2); break; case 1: gen_helper_neon_sub_u16(tmp, tmp, tmp2); break; case 2: tcg_gen_sub_i32(tmp, tmp, tmp2); break; default: return 1; } } break; case 17: if (!u) { switch (size) { case 0: gen_helper_neon_tst_u8(tmp, tmp, tmp2); break; case 1: gen_helper_neon_tst_u16(tmp, tmp, tmp2); break; case 2: gen_helper_neon_tst_u32(tmp, tmp, tmp2); break; default: return 1; } } else { switch (size) { case 0: gen_helper_neon_ceq_u8(tmp, tmp, tmp2); break; case 1: gen_helper_neon_ceq_u16(tmp, tmp, tmp2); break; case 2: gen_helper_neon_ceq_u32(tmp, tmp, tmp2); break; default: return 1; } } break; case 18: switch (size) { case 0: gen_helper_neon_mul_u8(tmp, tmp, tmp2); break; case 1: gen_helper_neon_mul_u16(tmp, tmp, tmp2); break; case 2: tcg_gen_mul_i32(tmp, tmp, tmp2); break; default: return 1; } dead_tmp(tmp2); tmp2 = neon_load_reg(rd, pass); if (u) { gen_neon_rsb(size, tmp, tmp2); } else { gen_neon_add(size, tmp, tmp2); } break; case 19: if (u) { gen_helper_neon_mul_p8(tmp, tmp, tmp2); } else { switch (size) { case 0: gen_helper_neon_mul_u8(tmp, tmp, tmp2); break; case 1: gen_helper_neon_mul_u16(tmp, tmp, tmp2); break; case 2: tcg_gen_mul_i32(tmp, tmp, tmp2); break; default: return 1; } } break; case 20: GEN_NEON_INTEGER_OP(pmax); break; case 21: GEN_NEON_INTEGER_OP(pmin); break; case 22: if (!u) { switch (size) { case 1: gen_helper_neon_qdmulh_s16(tmp, cpu_env, tmp, tmp2); break; case 2: gen_helper_neon_qdmulh_s32(tmp, cpu_env, tmp, tmp2); break; default: return 1; } } else { switch (size) { case 1: gen_helper_neon_qrdmulh_s16(tmp, cpu_env, tmp, tmp2); break; case 2: gen_helper_neon_qrdmulh_s32(tmp, cpu_env, tmp, tmp2); break; default: return 1; } } break; case 23: if (u) return 1; switch (size) { case 0: gen_helper_neon_padd_u8(tmp, tmp, tmp2); break; case 1: gen_helper_neon_padd_u16(tmp, tmp, tmp2); break; case 2: tcg_gen_add_i32(tmp, tmp, tmp2); break; default: return 1; } break; case 26: switch ((u << 2) | size) { case 0: gen_helper_neon_add_f32(tmp, tmp, tmp2); break; case 2: gen_helper_neon_sub_f32(tmp, tmp, tmp2); break; case 4: gen_helper_neon_add_f32(tmp, tmp, tmp2); break; case 6: gen_helper_neon_abd_f32(tmp, tmp, tmp2); break; default: return 1; } break; case 27: gen_helper_neon_mul_f32(tmp, tmp, tmp2); if (!u) { dead_tmp(tmp2); tmp2 = neon_load_reg(rd, pass); if (size == 0) { gen_helper_neon_add_f32(tmp, tmp, tmp2); } else { gen_helper_neon_sub_f32(tmp, tmp2, tmp); } } break; case 28: if (!u) { gen_helper_neon_ceq_f32(tmp, tmp, tmp2); } else { if (size == 0) gen_helper_neon_cge_f32(tmp, tmp, tmp2); else gen_helper_neon_cgt_f32(tmp, tmp, tmp2); } break; case 29: if (!u) return 1; if (size == 0) gen_helper_neon_acge_f32(tmp, tmp, tmp2); else gen_helper_neon_acgt_f32(tmp, tmp, tmp2); break; case 30: if (size == 0) gen_helper_neon_max_f32(tmp, tmp, tmp2); else gen_helper_neon_min_f32(tmp, tmp, tmp2); break; case 31: if (size == 0) gen_helper_recps_f32(tmp, tmp, tmp2, cpu_env); else gen_helper_rsqrts_f32(tmp, tmp, tmp2, cpu_env); break; default: abort(); } dead_tmp(tmp2); if (pairwise && rd == rm) { neon_store_scratch(pass, tmp); } else { neon_store_reg(rd, pass, tmp); } } if (pairwise && rd == rm) { for (pass = 0; pass < (q ? 4 : 2); pass++) { tmp = neon_load_scratch(pass); neon_store_reg(rd, pass, tmp); } } } else if (insn & (1 << 4)) { if ((insn & 0x00380080) != 0) { op = (insn >> 8) & 0xf; if (insn & (1 << 7)) { size = 3; } else { size = 2; while ((insn & (1 << (size + 19))) == 0) size--; } shift = (insn >> 16) & ((1 << (3 + size)) - 1); if (op < 8) { if (op <= 4) shift = shift - (1 << (size + 3)); if (size == 3) { count = q + 1; } else { count = q ? 4: 2; } switch (size) { case 0: imm = (uint8_t) shift; imm |= imm << 8; imm |= imm << 16; break; case 1: imm = (uint16_t) shift; imm |= imm << 16; break; case 2: case 3: imm = shift; break; default: abort(); } for (pass = 0; pass < count; pass++) { if (size == 3) { neon_load_reg64(cpu_V0, rm + pass); tcg_gen_movi_i64(cpu_V1, imm); switch (op) { case 0: case 1: if (u) gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1); else gen_helper_neon_shl_s64(cpu_V0, cpu_V0, cpu_V1); break; case 2: case 3: if (u) gen_helper_neon_rshl_u64(cpu_V0, cpu_V0, cpu_V1); else gen_helper_neon_rshl_s64(cpu_V0, cpu_V0, cpu_V1); break; case 4: if (!u) return 1; gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1); break; case 5: gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1); break; case 6: if (u) { gen_helper_neon_qshlu_s64(cpu_V0, cpu_env, cpu_V0, cpu_V1); } else { return 1; } break; case 7: if (u) { gen_helper_neon_qshl_u64(cpu_V0, cpu_env, cpu_V0, cpu_V1); } else { gen_helper_neon_qshl_s64(cpu_V0, cpu_env, cpu_V0, cpu_V1); } break; } if (op == 1 || op == 3) { neon_load_reg64(cpu_V1, rd + pass); tcg_gen_add_i64(cpu_V0, cpu_V0, cpu_V1); } else if (op == 4 || (op == 5 && u)) { cpu_abort(env, "VS[LR]I.64 not implemented"); } neon_store_reg64(cpu_V0, rd + pass); } else { tmp = neon_load_reg(rm, pass); tmp2 = new_tmp(); tcg_gen_movi_i32(tmp2, imm); switch (op) { case 0: case 1: GEN_NEON_INTEGER_OP(shl); break; case 2: case 3: GEN_NEON_INTEGER_OP(rshl); break; case 4: if (!u) return 1; GEN_NEON_INTEGER_OP(shl); break; case 5: switch (size) { case 0: gen_helper_neon_shl_u8(tmp, tmp, tmp2); break; case 1: gen_helper_neon_shl_u16(tmp, tmp, tmp2); break; case 2: gen_helper_neon_shl_u32(tmp, tmp, tmp2); break; default: return 1; } break; case 6: if (!u) { return 1; } switch (size) { case 0: gen_helper_neon_qshlu_s8(tmp, cpu_env, tmp, tmp2); break; case 1: gen_helper_neon_qshlu_s16(tmp, cpu_env, tmp, tmp2); break; case 2: gen_helper_neon_qshlu_s32(tmp, cpu_env, tmp, tmp2); break; default: return 1; } break; case 7: GEN_NEON_INTEGER_OP_ENV(qshl); break; } dead_tmp(tmp2); if (op == 1 || op == 3) { tmp2 = neon_load_reg(rd, pass); gen_neon_add(size, tmp, tmp2); dead_tmp(tmp2); } else if (op == 4 || (op == 5 && u)) { switch (size) { case 0: if (op == 4) mask = 0xff >> -shift; else mask = (uint8_t)(0xff << shift); mask |= mask << 8; mask |= mask << 16; break; case 1: if (op == 4) mask = 0xffff >> -shift; else mask = (uint16_t)(0xffff << shift); mask |= mask << 16; break; case 2: if (shift < -31 || shift > 31) { mask = 0; } else { if (op == 4) mask = 0xffffffffu >> -shift; else mask = 0xffffffffu << shift; } break; default: abort(); } tmp2 = neon_load_reg(rd, pass); tcg_gen_andi_i32(tmp, tmp, mask); tcg_gen_andi_i32(tmp2, tmp2, ~mask); tcg_gen_or_i32(tmp, tmp, tmp2); dead_tmp(tmp2); } neon_store_reg(rd, pass, tmp); } } } else if (op < 10) { shift = shift - (1 << (size + 3)); size++; switch (size) { case 1: imm = (uint16_t)shift; imm |= imm << 16; tmp2 = tcg_const_i32(imm); TCGV_UNUSED_I64(tmp64); break; case 2: imm = (uint32_t)shift; tmp2 = tcg_const_i32(imm); TCGV_UNUSED_I64(tmp64); break; case 3: tmp64 = tcg_const_i64(shift); TCGV_UNUSED(tmp2); break; default: abort(); } for (pass = 0; pass < 2; pass++) { if (size == 3) { neon_load_reg64(cpu_V0, rm + pass); if (q) { if (u) gen_helper_neon_rshl_u64(cpu_V0, cpu_V0, tmp64); else gen_helper_neon_rshl_s64(cpu_V0, cpu_V0, tmp64); } else { if (u) gen_helper_neon_shl_u64(cpu_V0, cpu_V0, tmp64); else gen_helper_neon_shl_s64(cpu_V0, cpu_V0, tmp64); } } else { tmp = neon_load_reg(rm + pass, 0); gen_neon_shift_narrow(size, tmp, tmp2, q, u); tmp3 = neon_load_reg(rm + pass, 1); gen_neon_shift_narrow(size, tmp3, tmp2, q, u); tcg_gen_concat_i32_i64(cpu_V0, tmp, tmp3); dead_tmp(tmp); dead_tmp(tmp3); } tmp = new_tmp(); if (op == 8 && !u) { gen_neon_narrow(size - 1, tmp, cpu_V0); } else { if (op == 8) gen_neon_narrow_sats(size - 1, tmp, cpu_V0); else gen_neon_narrow_satu(size - 1, tmp, cpu_V0); } neon_store_reg(rd, pass, tmp); } if (size == 3) { tcg_temp_free_i64(tmp64); } else { tcg_temp_free_i32(tmp2); } } else if (op == 10) { if (q || size == 3) return 1; tmp = neon_load_reg(rm, 0); tmp2 = neon_load_reg(rm, 1); for (pass = 0; pass < 2; pass++) { if (pass == 1) tmp = tmp2; gen_neon_widen(cpu_V0, tmp, size, u); if (shift != 0) { tcg_gen_shli_i64(cpu_V0, cpu_V0, shift); if (size < 2 || !u) { uint64_t imm64; if (size == 0) { imm = (0xffu >> (8 - shift)); imm |= imm << 16; } else { imm = 0xffff >> (16 - shift); } imm64 = imm | (((uint64_t)imm) << 32); tcg_gen_andi_i64(cpu_V0, cpu_V0, imm64); } } neon_store_reg64(cpu_V0, rd + pass); } } else if (op >= 14) { shift = 32 - shift; for (pass = 0; pass < (q ? 4 : 2); pass++) { tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, pass)); if (!(op & 1)) { if (u) gen_vfp_ulto(0, shift); else gen_vfp_slto(0, shift); } else { if (u) gen_vfp_toul(0, shift); else gen_vfp_tosl(0, shift); } tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, pass)); } } else { return 1; } } else { int invert; op = (insn >> 8) & 0xf; imm = (u << 7) | ((insn >> 12) & 0x70) | (insn & 0xf); invert = (insn & (1 << 5)) != 0; switch (op) { case 0: case 1: break; case 2: case 3: imm <<= 8; break; case 4: case 5: imm <<= 16; break; case 6: case 7: imm <<= 24; break; case 8: case 9: imm |= imm << 16; break; case 10: case 11: imm = (imm << 8) | (imm << 24); break; case 12: imm = (imm << 8) | 0xff; break; case 13: imm = (imm << 16) | 0xffff; break; case 14: imm |= (imm << 8) | (imm << 16) | (imm << 24); if (invert) imm = ~imm; break; case 15: imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); break; } if (invert) imm = ~imm; for (pass = 0; pass < (q ? 4 : 2); pass++) { if (op & 1 && op < 12) { tmp = neon_load_reg(rd, pass); if (invert) { tcg_gen_andi_i32(tmp, tmp, imm); } else { tcg_gen_ori_i32(tmp, tmp, imm); } } else { tmp = new_tmp(); if (op == 14 && invert) { uint32_t val; val = 0; for (n = 0; n < 4; n++) { if (imm & (1 << (n + (pass & 1) * 4))) val |= 0xff << (n * 8); } tcg_gen_movi_i32(tmp, val); } else { tcg_gen_movi_i32(tmp, imm); } } neon_store_reg(rd, pass, tmp); } } } else { if (size != 3) { op = (insn >> 8) & 0xf; if ((insn & (1 << 6)) == 0) { int src1_wide; int src2_wide; int prewiden; static const int neon_3reg_wide[16][3] = { {1, 0, 0}, {1, 1, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 1}, {0, 0, 0}, {0, 1, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} }; prewiden = neon_3reg_wide[op][0]; src1_wide = neon_3reg_wide[op][1]; src2_wide = neon_3reg_wide[op][2]; if (size == 0 && (op == 9 || op == 11 || op == 13)) return 1; if (rd == rm && !src2_wide) { tmp = neon_load_reg(rm, 1); neon_store_scratch(2, tmp); } else if (rd == rn && !src1_wide) { tmp = neon_load_reg(rn, 1); neon_store_scratch(2, tmp); } TCGV_UNUSED(tmp3); for (pass = 0; pass < 2; pass++) { if (src1_wide) { neon_load_reg64(cpu_V0, rn + pass); TCGV_UNUSED(tmp); } else { if (pass == 1 && rd == rn) { tmp = neon_load_scratch(2); } else { tmp = neon_load_reg(rn, pass); } if (prewiden) { gen_neon_widen(cpu_V0, tmp, size, u); } } if (src2_wide) { neon_load_reg64(cpu_V1, rm + pass); TCGV_UNUSED(tmp2); } else { if (pass == 1 && rd == rm) { tmp2 = neon_load_scratch(2); } else { tmp2 = neon_load_reg(rm, pass); } if (prewiden) { gen_neon_widen(cpu_V1, tmp2, size, u); } } switch (op) { case 0: case 1: case 4: gen_neon_addl(size); break; case 2: case 3: case 6: gen_neon_subl(size); break; case 5: case 7: switch ((size << 1) | u) { case 0: gen_helper_neon_abdl_s16(cpu_V0, tmp, tmp2); break; case 1: gen_helper_neon_abdl_u16(cpu_V0, tmp, tmp2); break; case 2: gen_helper_neon_abdl_s32(cpu_V0, tmp, tmp2); break; case 3: gen_helper_neon_abdl_u32(cpu_V0, tmp, tmp2); break; case 4: gen_helper_neon_abdl_s64(cpu_V0, tmp, tmp2); break; case 5: gen_helper_neon_abdl_u64(cpu_V0, tmp, tmp2); break; default: abort(); } dead_tmp(tmp2); dead_tmp(tmp); break; case 8: case 9: case 10: case 11: case 12: case 13: gen_neon_mull(cpu_V0, tmp, tmp2, size, u); break; case 14: cpu_abort(env, "Polynomial VMULL not implemented"); default: return 1; } if (op == 5 || op == 13 || (op >= 8 && op <= 11)) { if (op == 10 || op == 11) { gen_neon_negl(cpu_V0, size); } if (op != 13) { neon_load_reg64(cpu_V1, rd + pass); } switch (op) { case 5: case 8: case 10: gen_neon_addl(size); break; case 9: case 11: gen_neon_addl_saturate(cpu_V0, cpu_V0, size); gen_neon_addl_saturate(cpu_V0, cpu_V1, size); break; case 13: gen_neon_addl_saturate(cpu_V0, cpu_V0, size); break; default: abort(); } neon_store_reg64(cpu_V0, rd + pass); } else if (op == 4 || op == 6) { tmp = new_tmp(); if (!u) { switch (size) { case 0: gen_helper_neon_narrow_high_u8(tmp, cpu_V0); break; case 1: gen_helper_neon_narrow_high_u16(tmp, cpu_V0); break; case 2: tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); tcg_gen_trunc_i64_i32(tmp, cpu_V0); break; default: abort(); } } else { switch (size) { case 0: gen_helper_neon_narrow_round_high_u8(tmp, cpu_V0); break; case 1: gen_helper_neon_narrow_round_high_u16(tmp, cpu_V0); break; case 2: tcg_gen_addi_i64(cpu_V0, cpu_V0, 1u << 31); tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); tcg_gen_trunc_i64_i32(tmp, cpu_V0); break; default: abort(); } } if (pass == 0) { tmp3 = tmp; } else { neon_store_reg(rd, 0, tmp3); neon_store_reg(rd, 1, tmp); } } else { neon_store_reg64(cpu_V0, rd + pass); } } } else { switch (op) { case 0: case 1: case 4: case 5: case 8: case 9: case 12: case 13: tmp = neon_get_scalar(size, rm); neon_store_scratch(0, tmp); for (pass = 0; pass < (u ? 4 : 2); pass++) { tmp = neon_load_scratch(0); tmp2 = neon_load_reg(rn, pass); if (op == 12) { if (size == 1) { gen_helper_neon_qdmulh_s16(tmp, cpu_env, tmp, tmp2); } else { gen_helper_neon_qdmulh_s32(tmp, cpu_env, tmp, tmp2); } } else if (op == 13) { if (size == 1) { gen_helper_neon_qrdmulh_s16(tmp, cpu_env, tmp, tmp2); } else { gen_helper_neon_qrdmulh_s32(tmp, cpu_env, tmp, tmp2); } } else if (op & 1) { gen_helper_neon_mul_f32(tmp, tmp, tmp2); } else { switch (size) { case 0: gen_helper_neon_mul_u8(tmp, tmp, tmp2); break; case 1: gen_helper_neon_mul_u16(tmp, tmp, tmp2); break; case 2: tcg_gen_mul_i32(tmp, tmp, tmp2); break; default: return 1; } } dead_tmp(tmp2); if (op < 8) { tmp2 = neon_load_reg(rd, pass); switch (op) { case 0: gen_neon_add(size, tmp, tmp2); break; case 1: gen_helper_neon_add_f32(tmp, tmp, tmp2); break; case 4: gen_neon_rsb(size, tmp, tmp2); break; case 5: gen_helper_neon_sub_f32(tmp, tmp2, tmp); break; default: abort(); } dead_tmp(tmp2); } neon_store_reg(rd, pass, tmp); } break; case 2: case 3: case 6: case 7: case 10: case 11: if (size == 0 && (op == 3 || op == 7 || op == 11)) return 1; tmp2 = neon_get_scalar(size, rm); tmp4 = new_tmp(); tcg_gen_mov_i32(tmp4, tmp2); tmp3 = neon_load_reg(rn, 1); for (pass = 0; pass < 2; pass++) { if (pass == 0) { tmp = neon_load_reg(rn, 0); } else { tmp = tmp3; tmp2 = tmp4; } gen_neon_mull(cpu_V0, tmp, tmp2, size, u); if (op == 6 || op == 7) { gen_neon_negl(cpu_V0, size); } if (op != 11) { neon_load_reg64(cpu_V1, rd + pass); } switch (op) { case 2: case 6: gen_neon_addl(size); break; case 3: case 7: gen_neon_addl_saturate(cpu_V0, cpu_V0, size); gen_neon_addl_saturate(cpu_V0, cpu_V1, size); break; case 10: break; case 11: gen_neon_addl_saturate(cpu_V0, cpu_V0, size); break; default: abort(); } neon_store_reg64(cpu_V0, rd + pass); } break; default: return 1; } } } else { if (!u) { imm = (insn >> 8) & 0xf; if (imm > 7 && !q) return 1; if (imm == 0) { neon_load_reg64(cpu_V0, rn); if (q) { neon_load_reg64(cpu_V1, rn + 1); } } else if (imm == 8) { neon_load_reg64(cpu_V0, rn + 1); if (q) { neon_load_reg64(cpu_V1, rm); } } else if (q) { tmp64 = tcg_temp_new_i64(); if (imm < 8) { neon_load_reg64(cpu_V0, rn); neon_load_reg64(tmp64, rn + 1); } else { neon_load_reg64(cpu_V0, rn + 1); neon_load_reg64(tmp64, rm); } tcg_gen_shri_i64(cpu_V0, cpu_V0, (imm & 7) * 8); tcg_gen_shli_i64(cpu_V1, tmp64, 64 - ((imm & 7) * 8)); tcg_gen_or_i64(cpu_V0, cpu_V0, cpu_V1); if (imm < 8) { neon_load_reg64(cpu_V1, rm); } else { neon_load_reg64(cpu_V1, rm + 1); imm -= 8; } tcg_gen_shli_i64(cpu_V1, cpu_V1, 64 - (imm * 8)); tcg_gen_shri_i64(tmp64, tmp64, imm * 8); tcg_gen_or_i64(cpu_V1, cpu_V1, tmp64); tcg_temp_free_i64(tmp64); } else { neon_load_reg64(cpu_V0, rn); tcg_gen_shri_i64(cpu_V0, cpu_V0, imm * 8); neon_load_reg64(cpu_V1, rm); tcg_gen_shli_i64(cpu_V1, cpu_V1, 64 - (imm * 8)); tcg_gen_or_i64(cpu_V0, cpu_V0, cpu_V1); } neon_store_reg64(cpu_V0, rd); if (q) { neon_store_reg64(cpu_V1, rd + 1); } } else if ((insn & (1 << 11)) == 0) { op = ((insn >> 12) & 0x30) | ((insn >> 7) & 0xf); size = (insn >> 18) & 3; switch (op) { case 0: if (size == 3) return 1; for (pass = 0; pass < (q ? 2 : 1); pass++) { tmp = neon_load_reg(rm, pass * 2); tmp2 = neon_load_reg(rm, pass * 2 + 1); switch (size) { case 0: tcg_gen_bswap32_i32(tmp, tmp); break; case 1: gen_swap_half(tmp); break; case 2: break; default: abort(); } neon_store_reg(rd, pass * 2 + 1, tmp); if (size == 2) { neon_store_reg(rd, pass * 2, tmp2); } else { switch (size) { case 0: tcg_gen_bswap32_i32(tmp2, tmp2); break; case 1: gen_swap_half(tmp2); break; default: abort(); } neon_store_reg(rd, pass * 2, tmp2); } } break; case 4: case 5: case 12: case 13: if (size == 3) return 1; for (pass = 0; pass < q + 1; pass++) { tmp = neon_load_reg(rm, pass * 2); gen_neon_widen(cpu_V0, tmp, size, op & 1); tmp = neon_load_reg(rm, pass * 2 + 1); gen_neon_widen(cpu_V1, tmp, size, op & 1); switch (size) { case 0: gen_helper_neon_paddl_u16(CPU_V001); break; case 1: gen_helper_neon_paddl_u32(CPU_V001); break; case 2: tcg_gen_add_i64(CPU_V001); break; default: abort(); } if (op >= 12) { neon_load_reg64(cpu_V1, rd + pass); gen_neon_addl(size); } neon_store_reg64(cpu_V0, rd + pass); } break; case 33: if (size == 2) { for (n = 0; n < (q ? 4 : 2); n += 2) { tmp = neon_load_reg(rm, n); tmp2 = neon_load_reg(rd, n + 1); neon_store_reg(rm, n, tmp2); neon_store_reg(rd, n + 1, tmp); } } else { goto elementwise; } break; case 34: if (size == 3) return 1; gen_neon_unzip(rd, q, 0, size); gen_neon_unzip(rm, q, 4, size); if (q) { static int unzip_order_q[8] = {0, 2, 4, 6, 1, 3, 5, 7}; for (n = 0; n < 8; n++) { int reg = (n < 4) ? rd : rm; tmp = neon_load_scratch(unzip_order_q[n]); neon_store_reg(reg, n % 4, tmp); } } else { static int unzip_order[4] = {0, 4, 1, 5}; for (n = 0; n < 4; n++) { int reg = (n < 2) ? rd : rm; tmp = neon_load_scratch(unzip_order[n]); neon_store_reg(reg, n % 2, tmp); } } break; case 35: if (size == 3) return 1; count = (q ? 4 : 2); for (n = 0; n < count; n++) { tmp = neon_load_reg(rd, n); tmp2 = neon_load_reg(rd, n); switch (size) { case 0: gen_neon_zip_u8(tmp, tmp2); break; case 1: gen_neon_zip_u16(tmp, tmp2); break; case 2: ; break; default: abort(); } neon_store_scratch(n * 2, tmp); neon_store_scratch(n * 2 + 1, tmp2); } for (n = 0; n < count * 2; n++) { int reg = (n < count) ? rd : rm; tmp = neon_load_scratch(n); neon_store_reg(reg, n % count, tmp); } break; case 36: case 37: if (size == 3) return 1; TCGV_UNUSED(tmp2); for (pass = 0; pass < 2; pass++) { neon_load_reg64(cpu_V0, rm + pass); tmp = new_tmp(); if (op == 36 && q == 0) { gen_neon_narrow(size, tmp, cpu_V0); } else if (q) { gen_neon_narrow_satu(size, tmp, cpu_V0); } else { gen_neon_narrow_sats(size, tmp, cpu_V0); } if (pass == 0) { tmp2 = tmp; } else { neon_store_reg(rd, 0, tmp2); neon_store_reg(rd, 1, tmp); } } break; case 38: if (q || size == 3) return 1; tmp = neon_load_reg(rm, 0); tmp2 = neon_load_reg(rm, 1); for (pass = 0; pass < 2; pass++) { if (pass == 1) tmp = tmp2; gen_neon_widen(cpu_V0, tmp, size, 1); tcg_gen_shli_i64(cpu_V0, cpu_V0, 8 << size); neon_store_reg64(cpu_V0, rd + pass); } break; case 44: if (!arm_feature(env, ARM_FEATURE_VFP_FP16)) return 1; tmp = new_tmp(); tmp2 = new_tmp(); tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 0)); gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env); tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 1)); gen_helper_vfp_fcvt_f32_to_f16(tmp2, cpu_F0s, cpu_env); tcg_gen_shli_i32(tmp2, tmp2, 16); tcg_gen_or_i32(tmp2, tmp2, tmp); tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 2)); gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env); tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 3)); neon_store_reg(rd, 0, tmp2); tmp2 = new_tmp(); gen_helper_vfp_fcvt_f32_to_f16(tmp2, cpu_F0s, cpu_env); tcg_gen_shli_i32(tmp2, tmp2, 16); tcg_gen_or_i32(tmp2, tmp2, tmp); neon_store_reg(rd, 1, tmp2); dead_tmp(tmp); break; case 46: if (!arm_feature(env, ARM_FEATURE_VFP_FP16)) return 1; tmp3 = new_tmp(); tmp = neon_load_reg(rm, 0); tmp2 = neon_load_reg(rm, 1); tcg_gen_ext16u_i32(tmp3, tmp); gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env); tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 0)); tcg_gen_shri_i32(tmp3, tmp, 16); gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env); tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 1)); dead_tmp(tmp); tcg_gen_ext16u_i32(tmp3, tmp2); gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env); tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 2)); tcg_gen_shri_i32(tmp3, tmp2, 16); gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env); tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 3)); dead_tmp(tmp2); dead_tmp(tmp3); break; default: elementwise: for (pass = 0; pass < (q ? 4 : 2); pass++) { if (op == 30 || op == 31 || op >= 58) { tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, pass)); TCGV_UNUSED(tmp); } else { tmp = neon_load_reg(rm, pass); } switch (op) { case 1: switch (size) { case 0: tcg_gen_bswap32_i32(tmp, tmp); break; case 1: gen_swap_half(tmp); break; default: return 1; } break; case 2: if (size != 0) return 1; gen_rev16(tmp); break; case 8: switch (size) { case 0: gen_helper_neon_cls_s8(tmp, tmp); break; case 1: gen_helper_neon_cls_s16(tmp, tmp); break; case 2: gen_helper_neon_cls_s32(tmp, tmp); break; default: return 1; } break; case 9: switch (size) { case 0: gen_helper_neon_clz_u8(tmp, tmp); break; case 1: gen_helper_neon_clz_u16(tmp, tmp); break; case 2: gen_helper_clz(tmp, tmp); break; default: return 1; } break; case 10: if (size != 0) return 1; gen_helper_neon_cnt_u8(tmp, tmp); break; case 11: if (size != 0) return 1; tcg_gen_not_i32(tmp, tmp); break; case 14: switch (size) { case 0: gen_helper_neon_qabs_s8(tmp, cpu_env, tmp); break; case 1: gen_helper_neon_qabs_s16(tmp, cpu_env, tmp); break; case 2: gen_helper_neon_qabs_s32(tmp, cpu_env, tmp); break; default: return 1; } break; case 15: switch (size) { case 0: gen_helper_neon_qneg_s8(tmp, cpu_env, tmp); break; case 1: gen_helper_neon_qneg_s16(tmp, cpu_env, tmp); break; case 2: gen_helper_neon_qneg_s32(tmp, cpu_env, tmp); break; default: return 1; } break; case 16: case 19: tmp2 = tcg_const_i32(0); switch(size) { case 0: gen_helper_neon_cgt_s8(tmp, tmp, tmp2); break; case 1: gen_helper_neon_cgt_s16(tmp, tmp, tmp2); break; case 2: gen_helper_neon_cgt_s32(tmp, tmp, tmp2); break; default: return 1; } tcg_temp_free(tmp2); if (op == 19) tcg_gen_not_i32(tmp, tmp); break; case 17: case 20: tmp2 = tcg_const_i32(0); switch(size) { case 0: gen_helper_neon_cge_s8(tmp, tmp, tmp2); break; case 1: gen_helper_neon_cge_s16(tmp, tmp, tmp2); break; case 2: gen_helper_neon_cge_s32(tmp, tmp, tmp2); break; default: return 1; } tcg_temp_free(tmp2); if (op == 20) tcg_gen_not_i32(tmp, tmp); break; case 18: tmp2 = tcg_const_i32(0); switch(size) { case 0: gen_helper_neon_ceq_u8(tmp, tmp, tmp2); break; case 1: gen_helper_neon_ceq_u16(tmp, tmp, tmp2); break; case 2: gen_helper_neon_ceq_u32(tmp, tmp, tmp2); break; default: return 1; } tcg_temp_free(tmp2); break; case 22: switch(size) { case 0: gen_helper_neon_abs_s8(tmp, tmp); break; case 1: gen_helper_neon_abs_s16(tmp, tmp); break; case 2: tcg_gen_abs_i32(tmp, tmp); break; default: return 1; } break; case 23: if (size == 3) return 1; tmp2 = tcg_const_i32(0); gen_neon_rsb(size, tmp, tmp2); tcg_temp_free(tmp2); break; case 24: case 27: tmp2 = tcg_const_i32(0); gen_helper_neon_cgt_f32(tmp, tmp, tmp2); tcg_temp_free(tmp2); if (op == 27) tcg_gen_not_i32(tmp, tmp); break; case 25: case 28: tmp2 = tcg_const_i32(0); gen_helper_neon_cge_f32(tmp, tmp, tmp2); tcg_temp_free(tmp2); if (op == 28) tcg_gen_not_i32(tmp, tmp); break; case 26: tmp2 = tcg_const_i32(0); gen_helper_neon_ceq_f32(tmp, tmp, tmp2); tcg_temp_free(tmp2); break; case 30: gen_vfp_abs(0); break; case 31: gen_vfp_neg(0); break; case 32: tmp2 = neon_load_reg(rd, pass); neon_store_reg(rm, pass, tmp2); break; case 33: tmp2 = neon_load_reg(rd, pass); switch (size) { case 0: gen_neon_trn_u8(tmp, tmp2); break; case 1: gen_neon_trn_u16(tmp, tmp2); break; case 2: abort(); default: return 1; } neon_store_reg(rm, pass, tmp2); break; case 56: gen_helper_recpe_u32(tmp, tmp, cpu_env); break; case 57: gen_helper_rsqrte_u32(tmp, tmp, cpu_env); break; case 58: gen_helper_recpe_f32(cpu_F0s, cpu_F0s, cpu_env); break; case 59: gen_helper_rsqrte_f32(cpu_F0s, cpu_F0s, cpu_env); break; case 60: gen_vfp_sito(0); break; case 61: gen_vfp_uito(0); break; case 62: gen_vfp_tosiz(0); break; case 63: gen_vfp_touiz(0); break; default: return 1; } if (op == 30 || op == 31 || op >= 58) { tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, pass)); } else { neon_store_reg(rd, pass, tmp); } } break; } } else if ((insn & (1 << 10)) == 0) { n = ((insn >> 5) & 0x18) + 8; if (insn & (1 << 6)) { tmp = neon_load_reg(rd, 0); } else { tmp = new_tmp(); tcg_gen_movi_i32(tmp, 0); } tmp2 = neon_load_reg(rm, 0); tmp4 = tcg_const_i32(rn); tmp5 = tcg_const_i32(n); gen_helper_neon_tbl(tmp2, tmp2, tmp, tmp4, tmp5); dead_tmp(tmp); if (insn & (1 << 6)) { tmp = neon_load_reg(rd, 1); } else { tmp = new_tmp(); tcg_gen_movi_i32(tmp, 0); } tmp3 = neon_load_reg(rm, 1); gen_helper_neon_tbl(tmp3, tmp3, tmp, tmp4, tmp5); tcg_temp_free_i32(tmp5); tcg_temp_free_i32(tmp4); neon_store_reg(rd, 0, tmp2); neon_store_reg(rd, 1, tmp3); dead_tmp(tmp); } else if ((insn & 0x380) == 0) { if (insn & (1 << 19)) { tmp = neon_load_reg(rm, 1); } else { tmp = neon_load_reg(rm, 0); } if (insn & (1 << 16)) { gen_neon_dup_u8(tmp, ((insn >> 17) & 3) * 8); } else if (insn & (1 << 17)) { if ((insn >> 18) & 1) gen_neon_dup_high16(tmp); else gen_neon_dup_low16(tmp); } for (pass = 0; pass < (q ? 4 : 2); pass++) { tmp2 = new_tmp(); tcg_gen_mov_i32(tmp2, tmp); neon_store_reg(rd, pass, tmp2); } dead_tmp(tmp); } else { return 1; } } } return 0; }
1threat
i want to make calculator and i don't know to calculate string 2*2+6/3+6 : i don't know to split the string and calculate the result. Is there any algorithm or some easy way to get result.I have already searched for it.But it only tells infix expressions.
0debug
static gboolean cadence_uart_xmit(GIOChannel *chan, GIOCondition cond, void *opaque) { CadenceUARTState *s = opaque; int ret; if (!s->chr) { s->tx_count = 0; return FALSE; } if (!s->tx_count) { return FALSE; } ret = qemu_chr_fe_write(s->chr, s->tx_fifo, s->tx_count); s->tx_count -= ret; memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_count); if (s->tx_count) { int r = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP, cadence_uart_xmit, s); assert(r); } uart_update_status(s); return FALSE; }
1threat
int ff_h2645_extract_rbsp(const uint8_t *src, int length, H2645NAL *nal, int small_padding) { int i, si, di; uint8_t *dst; int64_t padding = small_padding ? AV_INPUT_BUFFER_PADDING_SIZE : MAX_MBPAIR_SIZE; nal->skipped_bytes = 0; #define STARTCODE_TEST \ if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \ if (src[i + 2] != 3 && src[i + 2] != 0) { \ \ length = i; \ } \ break; \ } #if HAVE_FAST_UNALIGNED #define FIND_FIRST_ZERO \ if (i > 0 && !src[i]) \ i--; \ while (src[i]) \ i++ #if HAVE_FAST_64BIT for (i = 0; i + 1 < length; i += 9) { if (!((~AV_RN64A(src + i) & (AV_RN64A(src + i) - 0x0100010001000101ULL)) & 0x8000800080008080ULL)) continue; FIND_FIRST_ZERO; STARTCODE_TEST; i -= 7; } #else for (i = 0; i + 1 < length; i += 5) { if (!((~AV_RN32A(src + i) & (AV_RN32A(src + i) - 0x01000101U)) & 0x80008080U)) continue; FIND_FIRST_ZERO; STARTCODE_TEST; i -= 3; } #endif #else for (i = 0; i + 1 < length; i += 2) { if (src[i]) continue; if (i > 0 && src[i - 1] == 0) i--; STARTCODE_TEST; } #endif if (i >= length - 1 && small_padding) { nal->data = nal->raw_data = src; nal->size = nal->raw_size = length; return length; } av_fast_malloc(&nal->rbsp_buffer, &nal->rbsp_buffer_size, length + padding); if (!nal->rbsp_buffer) return AVERROR(ENOMEM); dst = nal->rbsp_buffer; memcpy(dst, src, i); si = di = i; while (si + 2 < length) { if (src[si + 2] > 3) { dst[di++] = src[si++]; dst[di++] = src[si++]; } else if (src[si] == 0 && src[si + 1] == 0 && src[si + 2] != 0) { if (src[si + 2] == 3) { dst[di++] = 0; dst[di++] = 0; si += 3; if (nal->skipped_bytes_pos) { nal->skipped_bytes++; if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { nal->skipped_bytes_pos_size *= 2; av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes); av_reallocp_array(&nal->skipped_bytes_pos, nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos)); if (!nal->skipped_bytes_pos) { nal->skipped_bytes_pos_size = 0; return AVERROR(ENOMEM); } } if (nal->skipped_bytes_pos) nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1; } continue; } else goto nsc; } dst[di++] = src[si++]; } while (si < length) dst[di++] = src[si++]; nsc: memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE); nal->data = dst; nal->size = di; nal->raw_data = src; nal->raw_size = si; return si; }
1threat
def count_Hexadecimal(L,R) : count = 0; for i in range(L,R + 1) : if (i >= 10 and i <= 15) : count += 1; elif (i > 15) : k = i; while (k != 0) : if (k % 16 >= 10) : count += 1; k = k // 16; return count;
0debug
Yellow Pages Scraper in Python stopped working : <p>I am trying to scrape data from Yellow Pages. I have used this scraper successfully several times, but it has recently stopped working. I noticed a recent change on the Yellow Pages website where they have added a Sponsored Links table that contains three results. Since this change, the only thing my scraper picks up is the advertisement below this Sponsored Links table. It does not retrieve any of the results. </p> <p>Where am I going wrong on this? </p> <p>I have included my code below. As an example, it shows a search for 7 Eleven locations in Wisconsin. </p> <pre><code>import requests from bs4 import BeautifulSoup import csv my_url = "https://www.yellowpages.com/search?search_terms=7-eleven&amp;geo_location_terms=WI&amp;page={}" for link in [my_url.format(page) for page in range(1,20)]: res = requests.get(link) soup = BeautifulSoup(res.text, "lxml") placeHolder = [] for item in soup.select(".info"): try: name = item.select("[itemprop='name']")[0].text except Exception: name = "" try: streetAddress = item.select("[itemprop='streetAddress']")[0].text except Exception: streetAddress = "" try: addressLocality = item.select("[itemprop='addressLocality']")[0].text except Exception: addressLocality = "" try: addressRegion = item.select("[itemprop='addressRegion']")[0].text except Exception: addressRegion = "" try: postalCode = item.select("[itemprop='postalCode']")[0].text except Exception: postalCode = "" try: phone = item.select("[itemprop='telephone']")[0].text except Exception: phone = "" with open('yp-7-eleven-wi.csv', 'a') as csv_file: writer = csv.writer(csv_file) writer.writerow([name, streetAddress, addressLocality, addressRegion, postalCode, phone]) </code></pre>
0debug
how to have 2 relative layouts devided by half in activity? : i want to devide my screen in half vertically, and do a diffrent color in each half, i was trying to use this sulotion mentioned in here> http://stackoverflow.com/questions/19983335/android-2-relative-layout-divided-in-half-screen but it doesn't work for me. this is my layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:layout_width="match_parent" android:layout_height="match_parent" android:baselineAligned="false" android:orientation="horizontal" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context=".activities.alignmentActivities.Add_New_Project_Activity" tools:showIn="@layout/app_bar_add__new__project_"> <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content" android:background="#f00000" android:layout_weight="1"> </RelativeLayout> <RelativeLayout android:layout_width="0dp" android:background="#00b0f0" android:layout_height="wrap_content" android:layout_weight="1"> </RelativeLayout> </LinearLayout> how can i achieve the desired effect of 2 layouts each takes half the screen vertical \ what am i doing wrong then the example mentioned in the link ?
0debug
Does Visual Studio 2017 fully support C99? : <p>Recent versions of Visual Studio have seen improving support for C99. Does the latest version, VS2017, now support all of C99?</p> <p>If not, what features of C99 are still missing?</p>
0debug
Spring Security Sessions without cookies : <p>I'm trying to manage sessions in Spring Security without leveraging cookies. The reasoning is - our application is displayed within an iframe from another domain, we need to manage sessions in our application, <a href="https://medium.com/@bluepnume/safaris-new-tracking-rules-and-enabling-cross-domain-data-storage-85241eea7483" rel="noreferrer">and Safari restricts cross-domain cookie creation</a>. (context : domainA.com displays domainB.com in an iframe. domainB.com is setting a JSESSIONID cookie to leverage on domainB.com, but since the user's browser is showing domainA.com - Safari restricts domainB.com from creating the cookie). </p> <p>The only way I can think to achieve this (against OWASP security recommendations) - is to include the JSESSIONID in the URL as a GET parameter. I don't WANT to do this, but I can't think of an alternative. </p> <p>So this question is both about : </p> <ul> <li>Are there better alternatives to tackling this problem?</li> <li>If not - how can I achieve this with Spring Security</li> </ul> <p>Reviewing Spring's Documentation around this, using <a href="https://docs.spring.io/autorepo/docs/spring-security/4.0.1.RELEASE/apidocs/org/springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.html#enableSessionUrlRewriting(boolean)" rel="noreferrer">enableSessionUrlRewriting</a> should allow for this </p> <p>So I've done this :</p> <pre><code>@Override protected void configure(HttpSecurity http) throws Exception { http .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.ALWAYS) .enableSessionUrlRewriting(true) </code></pre> <p>This didn't add the JSESSIONID to the URL, but it should be allowed now. I then leveraged some code found <a href="https://stackoverflow.com/questions/31791587/spring-boot-remove-jsessionid-from-url">in this question</a> to set the "tracking mode" to URL</p> <pre><code>@SpringBootApplication public class MyApplication extends SpringBootServletInitializer { @Override public void onStartup(ServletContext servletContext) throws ServletException { super.onStartup(servletContext); servletContext .setSessionTrackingModes( Collections.singleton(SessionTrackingMode.URL) ); </code></pre> <p>Even after this - the application still adds the JSESSIONID as a cookie and not in the URL. </p> <p>Can someone help point me in the right direction here?</p>
0debug
Subplot for seaborn boxplot : <p>I have a dataframe like this</p> <pre><code>import seaborn as sns import pandas as pd %pylab inline df = pd.DataFrame({'a' :['one','one','two','two','one','two','one','one','one','two'], 'b': [1,2,1,2,1,2,1,2,1,1], 'c': [1,2,3,4,6,1,2,3,4,6]}) </code></pre> <p>A single boxplot is OK</p> <pre><code>sns.boxplot( y="b", x= "a", data=df, orient='v' ) </code></pre> <p>But i want to build a subplot for all variables. I do</p> <pre><code>names = ['b', 'c'] plt.subplots(1,2) sub = [] for name in names: ax = sns.boxplot( y=name, x= "a", data=df, orient='v' ) sub.append(ax) </code></pre> <p>and i get </p> <p><a href="https://i.stack.imgur.com/tEqqC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tEqqC.png" alt="enter image description here"></a></p> <p>how to fix it? thanx for your help</p>
0debug
int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset, int64_t size) { BDRVQcowState *s = bs->opaque; int chk = s->overlap_check & ~ign; int i, j; if (!size) { return 0; } if (chk & QCOW2_OL_MAIN_HEADER) { if (offset < s->cluster_size) { return QCOW2_OL_MAIN_HEADER; } } size = align_offset(offset_into_cluster(s, offset) + size, s->cluster_size); offset = start_of_cluster(s, offset); if ((chk & QCOW2_OL_ACTIVE_L1) && s->l1_size) { if (overlaps_with(s->l1_table_offset, s->l1_size * sizeof(uint64_t))) { return QCOW2_OL_ACTIVE_L1; } } if ((chk & QCOW2_OL_REFCOUNT_TABLE) && s->refcount_table_size) { if (overlaps_with(s->refcount_table_offset, s->refcount_table_size * sizeof(uint64_t))) { return QCOW2_OL_REFCOUNT_TABLE; } } if ((chk & QCOW2_OL_SNAPSHOT_TABLE) && s->snapshots_size) { if (overlaps_with(s->snapshots_offset, s->snapshots_size)) { return QCOW2_OL_SNAPSHOT_TABLE; } } if ((chk & QCOW2_OL_INACTIVE_L1) && s->snapshots) { for (i = 0; i < s->nb_snapshots; i++) { if (s->snapshots[i].l1_size && overlaps_with(s->snapshots[i].l1_table_offset, s->snapshots[i].l1_size * sizeof(uint64_t))) { return QCOW2_OL_INACTIVE_L1; } } } if ((chk & QCOW2_OL_ACTIVE_L2) && s->l1_table) { for (i = 0; i < s->l1_size; i++) { if ((s->l1_table[i] & L1E_OFFSET_MASK) && overlaps_with(s->l1_table[i] & L1E_OFFSET_MASK, s->cluster_size)) { return QCOW2_OL_ACTIVE_L2; } } } if ((chk & QCOW2_OL_REFCOUNT_BLOCK) && s->refcount_table) { for (i = 0; i < s->refcount_table_size; i++) { if ((s->refcount_table[i] & REFT_OFFSET_MASK) && overlaps_with(s->refcount_table[i] & REFT_OFFSET_MASK, s->cluster_size)) { return QCOW2_OL_REFCOUNT_BLOCK; } } } if ((chk & QCOW2_OL_INACTIVE_L2) && s->snapshots) { for (i = 0; i < s->nb_snapshots; i++) { uint64_t l1_ofs = s->snapshots[i].l1_table_offset; uint32_t l1_sz = s->snapshots[i].l1_size; uint64_t l1_sz2 = l1_sz * sizeof(uint64_t); uint64_t *l1 = g_malloc(l1_sz2); int ret; ret = bdrv_pread(bs->file, l1_ofs, l1, l1_sz2); if (ret < 0) { g_free(l1); return ret; } for (j = 0; j < l1_sz; j++) { uint64_t l2_ofs = be64_to_cpu(l1[j]) & L1E_OFFSET_MASK; if (l2_ofs && overlaps_with(l2_ofs, s->cluster_size)) { g_free(l1); return QCOW2_OL_INACTIVE_L2; } } g_free(l1); } } return 0; }
1threat
Array.select in ruby : I'm trying to get result array if the `data` array has matching with respect to `compare_data` array. So below is the code, however the return array has complete values from original array i.e `data`. Reference Data: data = [ { "id": 100, "name": "Rob", "age": "22", "job": "Tester" }, { "id": 101, "name": "Matt", "age": "28", "job": "Engineer" } ] Comparing Data: compare_data = [{"age": "21"},{"age": "29"},{"age": "22"} ] Code Block: new_array = data.select do |each_item| compare_data.map do |child| child[:age].include?(each_item[:age]) end end puts new_array #{:id=>100, :name=>"Rob", :age=>"22", :job=>"Tester"}{:id=>101, :name=>"Matt", :age=>"28", :job=>"Engineer"}
0debug
Tensorflow vs OpenCV : <p>I'm new into the AI world, I've start doing some stuff using Python &amp; OpenCV for face detection and so on. I know that with the implementation of some algorithms I can develop AI system using Python &amp; OpenCV. So my question is : What is the position of Tensorflow here? Can I say Tensorflow is an alternative to OpenCV? as I can say Python is an alternative programming language to Java (for example).</p>
0debug
from collections import OrderedDict def remove_duplicate(string): result = ' '.join(OrderedDict((w,w) for w in string.split()).keys()) return result
0debug
Allowing table column to change color when clicking checkboxes - HTML/angularJS : I have a table and I am attempting to make it so that when one or more checkboxes in the table are clicked, the entire checkbox column changes color. For better understanding, I want it to look like this before being clicked (which I already have now): [Before][1] And this is what I want it to look after one or more boxes are clicked: [After][2] Here is the HTML I have for the grid: <table id="table-users" class="table table-condensed"> <thead> <tr> <th>#</th> <th> User ID <a href="#" class="filter-link" ng-click="sortType = 'name'; sortReverse = !sortReverse" > <span class="glyphicon glyphicon-sort-by-alphabet"></span> <span ng-show="sortType == 'name' && !sortReverse"></span> <span ng-show="sortType == 'name' && sortReverse"></span></a> </th> <th> Notification Email <a href="#" class="filter-link" ng-click="sortType = 'email'; sortReverse = !sortReverse" > <span class="glyphicon glyphicon-sort-by-alphabet"></span> <span ng-show="sortType == 'email' && !sortReverse"></span> <span ng-show="sortType == 'email' && sortReverse"></span></a> </th> <th> Role <a href="#" class="filter-link" ng-click="sortType = 'type'; sortReverse = !sortReverse" > <span class="glyphicon glyphicon-sort-by-alphabet"></span> <span ng-show="sortType == 'type' && !sortReverse"></span> <span ng-show="sortType == 'type' && sortReverse"></span></a> </th> <th> Last Activity <a href="#" class="filter-link" ng-click="sortType = 'lastActivity'; sortReverse = !sortReverse" > <span class="glyphicon glyphicon-sort-by-alphabet"></span> <span ng-show="sortType == 'lastActivity' && !sortReverse"></span> <span ng-show="sortType == 'lastActivity' && sortReverse"></span></a> </th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr ng-repeat="user in users | orderBy:sortType:sortReverse | filter:searching"> <td>{{ $index+1 }}</td> <td>{{ user.name }}</td> <td>{{ user.email }}</td> <td> <!--<span class="circle-user" ng-class="{'circle-admin': user.type === 'Admin'}"><span class="glyphicon glyphicon-user"></span></span>--> {{ user.type }} </td> <td>{{getLastDate(user.lastActivity) | date:'short'}}</td> <td><input type="checkbox"></td> <td> <span ng-hide="user.name === authInfo.user"> <a href="#" ng-click="showUserAddDialog(user)">Edit</a> </span> </td> <td> <span ng-hide="user.name === authInfo.user"> <a href="#" ng-click="showDeleteUser(user.id,user.name)">Delete</a> </span> </td> <td> <span ng-hide="user.name === authInfo.user"> <a href="#" ng-click="showResetPassword(user.name)">Reset</a> </span> </td> </tr> </tbody> </table> Not sure where to go from here to make this change. [1]: http://i.stack.imgur.com/ZYk60.png [2]: http://i.stack.imgur.com/AymdV.png
0debug
Javascript slice method, start at a certain word.s : <p>how do I make it so that my slice function starts at a certain word instead of just an integer. Is this possible?</p>
0debug
static int cbs_read_se_golomb(CodedBitstreamContext *ctx, BitstreamContext *bc, const char *name, int32_t *write_to, int32_t range_min, int32_t range_max) { int32_t value; int position; if (ctx->trace_enable) { char bits[65]; uint32_t v; unsigned int k; int i, j; position = bitstream_tell(bc); for (i = 0; i < 32; i++) { k = bitstream_read_bit(bc); bits[i] = k ? '1' : '0'; if (k) break; } if (i >= 32) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid se-golomb " "code found while reading %s: " "more than 31 zeroes.\n", name); return AVERROR_INVALIDDATA; } v = 1; for (j = 0; j < i; j++) { k = bitstream_read_bit(bc); bits[i + j + 1] = k ? '1' : '0'; v = v << 1 | k; } bits[i + j + 1] = 0; if (v & 1) value = -(int32_t)(v / 2); else value = v / 2; ff_cbs_trace_syntax_element(ctx, position, name, bits, value); } else { value = get_se_golomb_long(bc); } if (value < range_min || value > range_max) { av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: " "%"PRId32", but must be in [%"PRId32",%"PRId32"].\n", name, value, range_min, range_max); return AVERROR_INVALIDDATA; } *write_to = value; return 0; }
1threat
C#. Count Consecutive 1 bits in ulong : <p>Basically i want to count the number of consecutive 1 bits (1 bit groups) in a ulong. for example: ulong x = 0x1BD11BDAA9FC1A22UL; In binary it becomes: 1101111010001000110111101101010101001111111000001101000100010. I need output as No of consecutive 1 bits = 16.</p>
0debug
What is the use case and advantage of Anonymous class in java? : <p>What i know about Anonymous class is when you have any class or interface , and only someof your code need to implement or override some class or interface Anonymously ,it increases the readability of program . But i am Little bit confused suppose in future you need to implement same interface for different class , so in that case you have to refactor you previous class , so is there any other advanrage of Anonymous class ?(Is it improves performance ?)</p>
0debug
OutOfBoundsException error when creating an ArrayList : <p>I am trying to make a deck of cards. So far I have this:</p> <pre><code>import java.util.*; public class Card { public static void main(String[] args) { ArrayList&lt;String&gt; rank = new ArrayList&lt;String&gt;(Arrays.asList("Ace", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King")); ArrayList&lt;String&gt; suite = new ArrayList&lt;String&gt;(Arrays.asList("Spades", "Hearts", "Clubs", "Diamonds")); ArrayList&lt;String&gt; deck = new ArrayList&lt;String&gt;(); String card; for (int i = 0; i &lt; rank.size(); i++) { for (int p = 0; i &lt; suite.size(); p++) { card = rank.get(i) + " of " + suite.get(p); deck.add(card); } } System.out.println(deck); } } </code></pre> <p>I am getting an IndexOutOfBoundsException error on this line:</p> <pre><code>card = rank.get(i) + " of " + suite.get(p); </code></pre>
0debug
How to convet dict with object as value to dataframe? : I have a Dict with object as value and I want to create from it a DF (ignore the Nans) list_of_actors[key] = value key -> string value -> Actor() ``` class Actor: def __init__(self,title,link): self.link = link self.title = title self.count = 1 self.yearOfBirth ="NaN" self.countryOfBirth ="NaN" self.numberOfAwards = "0" ``` ``` columns = ['Name', 'Year of birth', 'Country of birth', 'Awards'] ``` Name = self.title Year of birth = self.yearOfBirth Country of birth = self.countryOfBirth Awards = self.numberOfAwards
0debug
static int mpeg_decode_slice(MpegEncContext *s, int mb_y, const uint8_t **buf, int buf_size) { AVCodecContext *avctx = s->avctx; const int lowres = s->avctx->lowres; const int field_pic = s->picture_structure != PICT_FRAME; int ret; s->resync_mb_x = s->resync_mb_y = -1; av_assert0(mb_y < s->mb_height); init_get_bits(&s->gb, *buf, buf_size * 8); if (s->codec_id != AV_CODEC_ID_MPEG1VIDEO && s->mb_height > 2800/16) skip_bits(&s->gb, 3); ff_mpeg1_clean_buffers(s); s->interlaced_dct = 0; s->qscale = get_qscale(s); if (s->qscale == 0) { av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n"); return AVERROR_INVALIDDATA; } if (skip_1stop_8data_bits(&s->gb) < 0) return AVERROR_INVALIDDATA; s->mb_x = 0; if (mb_y == 0 && s->codec_tag == AV_RL32("SLIF")) { skip_bits1(&s->gb); } else { while (get_bits_left(&s->gb) > 0) { int code = get_vlc2(&s->gb, ff_mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (code < 0) { av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n"); return AVERROR_INVALIDDATA; } if (code >= 33) { if (code == 33) s->mb_x += 33; } else { s->mb_x += code; break; } } } if (s->mb_x >= (unsigned) s->mb_width) { av_log(s->avctx, AV_LOG_ERROR, "initial skip overflow\n"); return AVERROR_INVALIDDATA; } if (avctx->hwaccel && avctx->hwaccel->decode_slice) { const uint8_t *buf_end, *buf_start = *buf - 4; int start_code = -1; buf_end = avpriv_find_start_code(buf_start + 2, *buf + buf_size, &start_code); if (buf_end < *buf + buf_size) buf_end -= 4; s->mb_y = mb_y; if (avctx->hwaccel->decode_slice(avctx, buf_start, buf_end - buf_start) < 0) return DECODE_SLICE_ERROR; *buf = buf_end; return DECODE_SLICE_OK; } s->resync_mb_x = s->mb_x; s->resync_mb_y = s->mb_y = mb_y; s->mb_skip_run = 0; ff_init_block_index(s); if (s->mb_y == 0 && s->mb_x == 0 && (s->first_field || s->picture_structure == PICT_FRAME)) { if (s->avctx->debug & FF_DEBUG_PICT_INFO) { av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", s->qscale, s->mpeg_f_code[0][0], s->mpeg_f_code[0][1], s->mpeg_f_code[1][0], s->mpeg_f_code[1][1], s->pict_type == AV_PICTURE_TYPE_I ? "I" : (s->pict_type == AV_PICTURE_TYPE_P ? "P" : (s->pict_type == AV_PICTURE_TYPE_B ? "B" : "S")), s->progressive_sequence ? "ps" : "", s->progressive_frame ? "pf" : "", s->alternate_scan ? "alt" : "", s->top_field_first ? "top" : "", s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" : ""); } } for (;;) { if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks) ff_xvmc_init_block(s); if ((ret = mpeg_decode_mb(s, s->block)) < 0) return ret; if (s->current_picture.motion_val[0] && !s->encoding) { const int wrap = s->b8_stride; int xy = s->mb_x * 2 + s->mb_y * 2 * wrap; int b8_xy = 4 * (s->mb_x + s->mb_y * s->mb_stride); int motion_x, motion_y, dir, i; for (i = 0; i < 2; i++) { for (dir = 0; dir < 2; dir++) { if (s->mb_intra || (dir == 1 && s->pict_type != AV_PICTURE_TYPE_B)) { motion_x = motion_y = 0; } else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && field_pic)) { motion_x = s->mv[dir][0][0]; motion_y = s->mv[dir][0][1]; } else { motion_x = s->mv[dir][i][0]; motion_y = s->mv[dir][i][1]; } s->current_picture.motion_val[dir][xy][0] = motion_x; s->current_picture.motion_val[dir][xy][1] = motion_y; s->current_picture.motion_val[dir][xy + 1][0] = motion_x; s->current_picture.motion_val[dir][xy + 1][1] = motion_y; s->current_picture.ref_index [dir][b8_xy] = s->current_picture.ref_index [dir][b8_xy + 1] = s->field_select[dir][i]; av_assert2(s->field_select[dir][i] == 0 || s->field_select[dir][i] == 1); } xy += wrap; b8_xy += 2; } } s->dest[0] += 16 >> lowres; s->dest[1] +=(16 >> lowres) >> s->chroma_x_shift; s->dest[2] +=(16 >> lowres) >> s->chroma_x_shift; ff_mpv_decode_mb(s, s->block); if (++s->mb_x >= s->mb_width) { const int mb_size = 16 >> s->avctx->lowres; ff_mpeg_draw_horiz_band(s, mb_size * (s->mb_y >> field_pic), mb_size); ff_mpv_report_decode_progress(s); s->mb_x = 0; s->mb_y += 1 << field_pic; if (s->mb_y >= s->mb_height) { int left = get_bits_left(&s->gb); int is_d10 = s->chroma_format == 2 && s->pict_type == AV_PICTURE_TYPE_I && avctx->profile == 0 && avctx->level == 5 && s->intra_dc_precision == 2 && s->q_scale_type == 1 && s->alternate_scan == 0 && s->progressive_frame == 0 ; if (left >= 32 && !is_d10) { GetBitContext gb = s->gb; align_get_bits(&gb); if (show_bits(&gb, 24) == 0x060E2B) { av_log(avctx, AV_LOG_DEBUG, "Invalid MXF data found in video stream\n"); is_d10 = 1; } } if (left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23)) && !is_d10) || ((avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_AGGRESSIVE)) && left > 8)) { av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X\n", left, show_bits(&s->gb, FFMIN(left, 23))); return AVERROR_INVALIDDATA; } else goto eos; } if (s->mb_y >= ((s->height + 15) >> 4) && !s->progressive_sequence && get_bits_left(&s->gb) <= 8 && get_bits_left(&s->gb) >= 0 && s->mb_skip_run == -1 && show_bits(&s->gb, 8) == 0) goto eos; ff_init_block_index(s); } if (s->mb_skip_run == -1) { s->mb_skip_run = 0; for (;;) { int code = get_vlc2(&s->gb, ff_mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (code < 0) { av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n"); return AVERROR_INVALIDDATA; } if (code >= 33) { if (code == 33) { s->mb_skip_run += 33; } else if (code == 35) { if (s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0) { av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n"); return AVERROR_INVALIDDATA; } goto eos; } } else { s->mb_skip_run += code; break; } } if (s->mb_skip_run) { int i; if (s->pict_type == AV_PICTURE_TYPE_I) { av_log(s->avctx, AV_LOG_ERROR, "skipped MB in I frame at %d %d\n", s->mb_x, s->mb_y); return AVERROR_INVALIDDATA; } s->mb_intra = 0; for (i = 0; i < 12; i++) s->block_last_index[i] = -1; if (s->picture_structure == PICT_FRAME) s->mv_type = MV_TYPE_16X16; else s->mv_type = MV_TYPE_FIELD; if (s->pict_type == AV_PICTURE_TYPE_P) { s->mv_dir = MV_DIR_FORWARD; s->mv[0][0][0] = s->mv[0][0][1] = 0; s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0; s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0; s->field_select[0][0] = (s->picture_structure - 1) & 1; } else { s->mv[0][0][0] = s->last_mv[0][0][0]; s->mv[0][0][1] = s->last_mv[0][0][1]; s->mv[1][0][0] = s->last_mv[1][0][0]; s->mv[1][0][1] = s->last_mv[1][0][1]; } } } } eos: if (get_bits_left(&s->gb) < 0) { av_log(s, AV_LOG_ERROR, "overread %d\n", -get_bits_left(&s->gb)); return AVERROR_INVALIDDATA; } *buf += (get_bits_count(&s->gb) - 1) / 8; ff_dlog(s, "Slice start:%d %d end:%d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y); return 0; }
1threat
sql count new id that did not exsits before for each month : I have the follow set of data [enter image description here][1] [1]: https://i.stack.imgur.com/VikQ8.png how can i write the sql to gives the result on right side? that is the counting of unique id that did appeared previously for each month.
0debug
Mac elipse has an error when I write a Java code : My photo is in this link: [Everytime I write a Java code on mac, it says it can't run the codes. (My current java version is 1.8.0_111 whereas eclipse's jre version is 1.8.0_66. I'm not sure if it matters.) Previously, Eclipse worked pretty well, but it suddenly doesn't work. ][1] [1]: https://i.stack.imgur.com/BRGNG.png
0debug
Why is it not a good idea to introduce an instance variable for the area? And how do you fix it, thanks : public class Square { private int sideLength; private int area; // Not a good idea public Square(int length) { sideLength = length; } public int getArea() { area = sideLength * sideLength; return area; } } Why is it not a good idea to introduce an instance variable for the area? And how do you fix it, thanks
0debug
Why does Angular run controller function twice for each model change? : <p>I have Angular application made of following tiers:</p> <ul> <li><code>service()</code> used for computations and data-munging</li> <li><code>factory()</code> used as common data storage for multiple controllers</li> <li>few <code>controllers()</code></li> </ul> <p>My controller exposes function from factory that, in turn, calls function from service. In HTML, I run controller function and display output to user: <code>{{ controller.function() }}</code>.</p> <p>I have noticed that when page is loaded, and on every subsequent model change, <code>controller.function()</code> is run <strong>twice</strong>. Why does it happen? How can I avoid unnecessary invocation?</p> <p>See <a href="https://plnkr.co/edit/O4NbJRAzTjAknuA8O57w?p=preview" rel="nofollow noreferrer">working example</a> - open your browser JS console, click <code>Run</code> and observe that <code>console.log()</code> line is executed two times.</p> <hr> <h2>JavaScript</h2> <pre><code>angular.module('myApp',[]) .service('Worker', [function() { this.i = 0; this.sample = function(data) { console.log(this.i.toString() + " " + Math.random().toString()); return JSON.stringify(data); }; }]) .factory('DataStorage', ['Worker', function(worker) { var self = this; self.data = [{}, {}]; self.getData = function() { return self.data; } self.sample = function() { return worker.sample(self.data); }; return { getData: self.getData, sample: self.sample }; }]) .controller('MainController', ['DataStorage', function(DataStorage) { var self = this; self.data = DataStorage.getData(); self.sample = DataStorage.sample; }]) .controller('DataSource', [function() { var self = this; self.data = ["one", "two", "three", "four", "five", "six"]; }]) </code></pre> <hr> <h2>HTML</h2> <pre><code>&lt;!DOCTYPE html&gt; &lt;html ng-app="myApp"&gt; &lt;head&gt; &lt;script data-require="angularjs@1.5.8" data-semver="1.5.8" src="https://opensource.keycdn.com/angularjs/1.5.8/angular.min.js"&gt;&lt;/script&gt; &lt;script src="script.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body ng-controller="MainController as main"&gt; &lt;div ng-controller="DataSource as datasource"&gt; &lt;div ng-repeat="select in main.data"&gt; &lt;select ng-model="select.choice" ng-options="value for value in datasource.data"&gt; &lt;option value=""&gt;-- Your choice --&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;pre&gt; {{ main.sample() }} &lt;/pre&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <hr> <p>Why does this function run multiple times for every single model change and how can I ensure that it runs only once?</p> <p>I have tried assigning factory function output to controller variable (and use <code>{{ controller.function }}</code> in HTML - note lack of parentheses), but then function is run only once ever. It should run on new data when model is changed.</p> <p>Similar problems reported on StackOverflow all refer to ng-route module, which I am not using.</p>
0debug
Keep TextInputLayout always focused or keep label always expanded : <p>I was wondering if it's possible to always keep the label expanded regardless of whether or not there is text in the <code>EditText</code>. I looked around in the source and it is a using a <code>ValueAnimator</code> and a <code>counter</code> inside a <code>TextWatcher</code> to animate or not animate changes. Maybe I can set a custom <code>TextWatcher</code> with a custom <code>ValueAnimator</code> on the <code>EditText</code> inside the <code>TextInputLayout</code>? </p>
0debug
subprocess: unexpected keyword argument capture_output : <p>When executing <code>subprocess.run()</code> as given in the <a href="https://docs.python.org/3/library/subprocess.html#subprocess.run" rel="noreferrer">Python docs</a>, I get a TypeError:</p> <pre><code>&gt;&gt;&gt; import subprocess &gt;&gt;&gt; subprocess.run(["ls", "-l", "/dev/null"], capture_output=True) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/usr/lib/python3.6/subprocess.py", line 403, in run with Popen(*popenargs, **kwargs) as process: TypeError: __init__() got an unexpected keyword argument 'capture_output' </code></pre> <p>I am running Python 3.6.6:</p> <pre><code>$ python3 --version Python 3.6.6 </code></pre>
0debug
static void reconstruct_stereo_16(int32_t *buffer[MAX_CHANNELS], int16_t *buffer_out, int numchannels, int numsamples, uint8_t interlacing_shift, uint8_t interlacing_leftweight) { int i; if (numsamples <= 0) return; if (interlacing_leftweight) { for (i = 0; i < numsamples; i++) { int32_t a, b; a = buffer[0][i]; b = buffer[1][i]; a -= (b * interlacing_leftweight) >> interlacing_shift; b += a; buffer_out[i*numchannels] = b; buffer_out[i*numchannels + 1] = a; } return; } for (i = 0; i < numsamples; i++) { int16_t left, right; left = buffer[0][i]; right = buffer[1][i]; buffer_out[i*numchannels] = left; buffer_out[i*numchannels + 1] = right; } }
1threat
static void nbd_teardown_connection(BlockDriverState *bs) { NBDClientSession *client = nbd_get_client_session(bs); if (!client->ioc) { return; } qio_channel_shutdown(client->ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); nbd_recv_coroutines_enter_all(bs); nbd_client_detach_aio_context(bs); object_unref(OBJECT(client->sioc)); client->sioc = NULL; object_unref(OBJECT(client->ioc)); client->ioc = NULL; }
1threat
How can I update a second Activity via a Thread? : I want to update a second activity via a Thread. I know the solution for the Main Activity is: postonuithread(); or a handler with the mainlooper. But how to manage this with a second activity?
0debug
Does Python support Default Keyord and Default Variable Length Arguments? : I know that Python supports variable arguments `*args` and keyword arguments `**kwargs` but is there a way to have a default for these fields ? <br> ```*args = (1,'v')) , **kwargs = {'a':20}```. I am not saying that I have a use case for this but it seems there is also no reason to disallow this. I do understand that it is trivial to get around this by checking for empty `args`
0debug
remove spaces in every where in the string python : <p>I have below string</p> <pre><code> a = " Get a Pen" </code></pre> <p>Code:</p> <pre><code> if a.lower().strip() == "get a pen" print "removed white spaces" </code></pre> <h1>need help to achieve remove all spaces in the string</h1> <pre><code> if a.lower.().strip() =="getapen" # which is the easiest way remove all spaces print "remove all spaces in the string" </code></pre>
0debug
static void quantize_mantissas(AC3EncodeContext *s) { int blk, ch; for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { AC3Block *block = &s->blocks[blk]; s->mant1_cnt = s->mant2_cnt = s->mant4_cnt = 0; s->qmant1_ptr = s->qmant2_ptr = s->qmant4_ptr = NULL; for (ch = 0; ch < s->channels; ch++) { quantize_mantissas_blk_ch(s, block->fixed_coef[ch], block->exp_shift[ch], block->exp[ch], block->bap[ch], block->qmant[ch], s->nb_coefs[ch]); } } }
1threat
The complier I used is gcc5.1 but it seems that he did't support c++11 : #include <iostream> #include <string> int main() { std::string s1 = "hello"; std::cout << s1 << std::endl; for (auto c : s1) std::cout << c << std::endl; return 0; } I think the code is right,but it had lots of error message(please ignore the name of the code): D:\>gcc hello.cpp -o hello hello.cpp: In function 'int main()': hello.cpp:8:12: error: 'c' does not name a type for (auto c : s1) ^ hello.cpp:11:2: error: expected ';' before 'return' return 0; ^ hello.cpp:11:2: error: expected primary-expression before 'return' hello.cpp:11:2: error: expected ';' before 'return' hello.cpp:11:2: error: expected primary-expression before 'return' hello.cpp:11:2: error: expected ')' before 'return' the book that i use to learn c++ is ***c++ primer***,and i have learned c language before,but i still is freshmen.
0debug
Dictionary assigning : <pre><code>listim=[['1' ,'2'], ['3' , '4'], ['1', '5'], ['4', '1']] </code></pre> <p>I am trying to make dictionary using listim for each number,</p> <p>I want to have d={'1': 2 , 4, 5 ,'2':1, '3': 4, (...and so on)}</p> <p>my code is(I can't find the mistake but probably about dictionaries):</p> <pre><code>a=1 dic={} while a&lt;6: for number in listim: if number[0]==a: if number[1] not in dic[a]: dic[a].append(number[1]) elif number[1]==a: if number[0] not in dic[a]: dic[a].append(number[0]) a+=1 </code></pre> <p>I couldn't find enough information on web,(I know I can). I hope I was clear enough. Thank you</p>
0debug
static uint64_t alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, int n_start, int n_end, int *num) { BDRVQcowState *s = bs->opaque; int l2_index, ret; uint64_t l2_offset, *l2_table, cluster_offset; int nb_available, nb_clusters, i = 0; uint64_t start_sect; ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index); if (ret == 0) return 0; nb_clusters = size_to_clusters(s, n_end << 9); if (nb_clusters > s->l2_size - l2_index) nb_clusters = s->l2_size - l2_index; cluster_offset = be64_to_cpu(l2_table[l2_index]); if (cluster_offset & QCOW_OFLAG_COPIED) { nb_clusters = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], 0); nb_available = nb_clusters << (s->cluster_bits - 9); if (nb_available > n_end) nb_available = n_end; cluster_offset &= ~QCOW_OFLAG_COPIED; goto out; } if (cluster_offset & QCOW_OFLAG_COMPRESSED) nb_clusters = 1; while (i < nb_clusters) { int j; i += count_contiguous_free_clusters(nb_clusters - i, &l2_table[l2_index + i]); cluster_offset = be64_to_cpu(l2_table[l2_index + i]); if ((cluster_offset & QCOW_OFLAG_COPIED) || (cluster_offset & QCOW_OFLAG_COMPRESSED)) break; j = count_contiguous_clusters(nb_clusters - i, s->cluster_size, &l2_table[l2_index + i], 0); if (j) free_any_clusters(bs, cluster_offset, j); i += j; if(be64_to_cpu(l2_table[l2_index + i])) break; } nb_clusters = i; cluster_offset = alloc_clusters(bs, nb_clusters * s->cluster_size); nb_available = nb_clusters << (s->cluster_bits - 9); if (nb_available > n_end) nb_available = n_end; start_sect = (offset & ~(s->cluster_size - 1)) >> 9; if (n_start) { ret = copy_sectors(bs, start_sect, cluster_offset, 0, n_start); if (ret < 0) return 0; } if (nb_available & (s->cluster_sectors - 1)) { uint64_t end = nb_available & ~(uint64_t)(s->cluster_sectors - 1); ret = copy_sectors(bs, start_sect + end, cluster_offset + (end << 9), nb_available - end, s->cluster_sectors); if (ret < 0) return 0; } for (i = 0; i < nb_clusters; i++) l2_table[l2_index + i] = cpu_to_be64((cluster_offset + (i << s->cluster_bits)) | QCOW_OFLAG_COPIED); if (bdrv_pwrite(s->hd, l2_offset + l2_index * sizeof(uint64_t), l2_table + l2_index, nb_clusters * sizeof(uint64_t)) != nb_clusters * sizeof(uint64_t)) return 0; out: *num = nb_available - n_start; return cluster_offset; }
1threat
static inline void RENAME(yuv2yuyv422_1)(SwsContext *c, const uint16_t *buf0, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, enum PixelFormat dstFormat, int flags, int y) { x86_reg uv_off = c->uv_off << 1; const uint16_t *buf1= buf0; if (uvalpha < 2048) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2PACKED1(%%REGBP, %5, %6) WRITEYUY2(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2PACKED1b(%%REGBP, %5, %6) WRITEYUY2(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); } }
1threat
Letencrypt renewal fails: Could not bind to IPv4 or IPv6.. Skipping : <p>The full error message I'm getting is:</p> <pre><code>Attempting to renew cert from /etc/letsencrypt/renewal/somedomain.com.conf produced an unexpected error: Problem binding to port 443: Could not bind to IPv4 or IPv6.. Skipping. </code></pre> <p>This is running on an AWS ubuntu 14.04 instance. All ports are open outgoing and 443 is open incoming.</p> <p>Anyone have any ideas?</p>
0debug
def string_to_tuple(str1): result = tuple(x for x in str1 if not x.isspace()) return result
0debug
static inline int host_to_target_errno(int err) { if(host_to_target_errno_table[err]) return host_to_target_errno_table[err]; return err; }
1threat
int swr_resample(AVResampleContext *c, short *dst, const short *src, int *consumed, int src_size, int dst_size, int update_ctx){ int dst_index, i; int index= c->index; int frac= c->frac; int dst_incr_frac= c->dst_incr % c->src_incr; int dst_incr= c->dst_incr / c->src_incr; int compensation_distance= c->compensation_distance; if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){ int64_t index2= ((int64_t)index)<<32; int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr; dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr); for(dst_index=0; dst_index < dst_size; dst_index++){ dst[dst_index] = src[index2>>32]; index2 += incr; } frac += dst_index * dst_incr_frac; index += dst_index * dst_incr; index += frac / c->src_incr; frac %= c->src_incr; }else{ for(dst_index=0; dst_index < dst_size; dst_index++){ FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); int sample_index= index >> c->phase_shift; FELEM2 val=0; if(sample_index < 0){ for(i=0; i<c->filter_length; i++) val += src[FFABS(sample_index + i) % src_size] * filter[i]; }else if(sample_index + c->filter_length > src_size){ break; }else if(c->linear){ FELEM2 v2=0; for(i=0; i<c->filter_length; i++){ val += src[sample_index + i] * (FELEM2)filter[i]; v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length]; } val+=(v2-val)*(FELEML)frac / c->src_incr; }else{ for(i=0; i<c->filter_length; i++){ val += src[sample_index + i] * (FELEM2)filter[i]; } } #ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE dst[dst_index] = av_clip_int16(lrintf(val)); #else val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT; dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val; #endif frac += dst_incr_frac; index += dst_incr; if(frac >= c->src_incr){ frac -= c->src_incr; index++; } if(dst_index + 1 == compensation_distance){ compensation_distance= 0; dst_incr_frac= c->ideal_dst_incr % c->src_incr; dst_incr= c->ideal_dst_incr / c->src_incr; } } } *consumed= FFMAX(index, 0) >> c->phase_shift; if(index>=0) index &= c->phase_mask; if(compensation_distance){ compensation_distance -= dst_index; assert(compensation_distance > 0); } if(update_ctx){ c->frac= frac; c->index= index; c->dst_incr= dst_incr_frac + c->src_incr*dst_incr; c->compensation_distance= compensation_distance; } #if 0 if(update_ctx && !c->compensation_distance){ #undef rand av_resample_compensate(c, rand() % (8000*2) - 8000, 8000*2); av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", c->dst_incr, c->ideal_dst_incr, c->compensation_distance); } #endif return dst_index; }
1threat
How would I submit my form data in a proper way by mailing in a simple HTML website? : <p>I'm tried to get this type of mail from my HTML website.</p> <p><strong>Name:</strong> XYZ</p> <p><strong>Email:</strong> xyz@gmail.com</p> <p><strong>Message:</strong> msg</p> <p>Can anybody help me to get this type of mail when somebody fills my HTML form, Remember I don't want to use any programming language like PHP. If anyone has javascript code for it then please share it.</p>
0debug
Make my page work for certain place : <p>I am under developing a game website i would like to know how to make <strong>only certain point of my website to work</strong>? and the rest should be disabled!</p>
0debug
Select rows containing certain values from pandas dataframe : <p>I have a pandas dataframe whose entries are all strings:</p> <pre><code> A B C 1 apple banana pear 2 pear pear apple 3 banana pear pear 4 apple apple pear </code></pre> <p>etc. I want to select all the rows that contain a certain string, say, 'banana'. I don't know which column it will appear in each time. Of course, I can write a for loop and iterate over all rows. But is there an easier or faster way to do this?</p>
0debug
how to value pass option to input ng-model : <div ng-app ng-controller="MyCtrl"> <select ng-model="referral.organization" ng-options="b for b in organizations"></select> </div> <script type='text/javascript'> function MyCtrl($scope) { $scope.organizations = ['Moo Milk','Silver Dairy']; $scope.referral = { organization: $scope.organizations[0] }; } </script> <input name="job_description" onkeypress="return event.keyCode != 13;" ng-model="req_data.job_description" value="{{referral}}" placeholder="Quantity" type="text" /> This is my code just i want to pass option value into input ng-model please help
0debug
static void pflash_cfi01_realize(DeviceState *dev, Error **errp) { pflash_t *pfl = CFI_PFLASH01(dev); uint64_t total_len; int ret; uint64_t blocks_per_device, device_len; int num_devices; Error *local_err = NULL; total_len = pfl->sector_len * pfl->nb_blocs; num_devices = pfl->device_width ? (pfl->bank_width / pfl->device_width) : 1; blocks_per_device = pfl->nb_blocs / num_devices; device_len = pfl->sector_len * blocks_per_device; #if 0 if (total_len != (8 * 1024 * 1024) && total_len != (16 * 1024 * 1024) && total_len != (32 * 1024 * 1024) && total_len != (64 * 1024 * 1024)) return NULL; #endif memory_region_init_rom_device( &pfl->mem, OBJECT(dev), &pflash_cfi01_ops, pfl, pfl->name, total_len, &local_err); if (local_err) { error_propagate(errp, local_err); vmstate_register_ram(&pfl->mem, DEVICE(pfl)); pfl->storage = memory_region_get_ram_ptr(&pfl->mem); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem); if (pfl->blk) { ret = blk_pread(pfl->blk, 0, pfl->storage, total_len); if (ret < 0) { vmstate_unregister_ram(&pfl->mem, DEVICE(pfl)); error_setg(errp, "failed to read the initial flash content"); if (pfl->blk) { pfl->ro = blk_is_read_only(pfl->blk); } else { pfl->ro = 0; if (!pfl->max_device_width) { pfl->max_device_width = pfl->device_width; pfl->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pflash_timer, pfl); pfl->wcycle = 0; pfl->cmd = 0; pfl->status = 0; pfl->cfi_len = 0x52; pfl->cfi_table[0x10] = 'Q'; pfl->cfi_table[0x11] = 'R'; pfl->cfi_table[0x12] = 'Y'; pfl->cfi_table[0x13] = 0x01; pfl->cfi_table[0x14] = 0x00; pfl->cfi_table[0x15] = 0x31; pfl->cfi_table[0x16] = 0x00; pfl->cfi_table[0x17] = 0x00; pfl->cfi_table[0x18] = 0x00; pfl->cfi_table[0x19] = 0x00; pfl->cfi_table[0x1A] = 0x00; pfl->cfi_table[0x1B] = 0x45; pfl->cfi_table[0x1C] = 0x55; pfl->cfi_table[0x1D] = 0x00; pfl->cfi_table[0x1E] = 0x00; pfl->cfi_table[0x1F] = 0x07; pfl->cfi_table[0x20] = 0x07; pfl->cfi_table[0x21] = 0x0a; pfl->cfi_table[0x22] = 0x00; pfl->cfi_table[0x23] = 0x04; pfl->cfi_table[0x24] = 0x04; pfl->cfi_table[0x25] = 0x04; pfl->cfi_table[0x26] = 0x00; pfl->cfi_table[0x27] = ctz32(device_len); pfl->cfi_table[0x28] = 0x02; pfl->cfi_table[0x29] = 0x00; if (pfl->bank_width == 1) { pfl->cfi_table[0x2A] = 0x08; } else { pfl->cfi_table[0x2A] = 0x0B; pfl->writeblock_size = 1 << pfl->cfi_table[0x2A]; pfl->cfi_table[0x2B] = 0x00; pfl->cfi_table[0x2C] = 0x01; pfl->cfi_table[0x2D] = blocks_per_device - 1; pfl->cfi_table[0x2E] = (blocks_per_device - 1) >> 8; pfl->cfi_table[0x2F] = pfl->sector_len >> 8; pfl->cfi_table[0x30] = pfl->sector_len >> 16; pfl->cfi_table[0x31] = 'P'; pfl->cfi_table[0x32] = 'R'; pfl->cfi_table[0x33] = 'I'; pfl->cfi_table[0x34] = '1'; pfl->cfi_table[0x35] = '0'; pfl->cfi_table[0x36] = 0x00; pfl->cfi_table[0x37] = 0x00; pfl->cfi_table[0x38] = 0x00; pfl->cfi_table[0x39] = 0x00; pfl->cfi_table[0x3a] = 0x00; pfl->cfi_table[0x3b] = 0x00; pfl->cfi_table[0x3c] = 0x00; pfl->cfi_table[0x3f] = 0x01;
1threat
Remove some x labels with Seaborn : <p>In the screenshot below, all my x-labels are overlapping each other.</p> <pre><code>g = sns.factorplot(x='Age', y='PassengerId', hue='Survived', col='Sex', kind='strip', data=train); </code></pre> <p>I know that I can remove all the labels by calling <code>g.set(xticks=[])</code>, but is there a way to just show some of the Age labels, like 0, 20, 40, 60, 80?</p> <p><a href="https://i.stack.imgur.com/UUdH4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UUdH4.png" alt="enter image description here"></a></p>
0debug
BlockAIOCB *dma_bdrv_read(BlockDriverState *bs, QEMUSGList *sg, uint64_t sector, void (*cb)(void *opaque, int ret), void *opaque) { return dma_bdrv_io(bs, sg, sector, bdrv_aio_readv, cb, opaque, DMA_DIRECTION_FROM_DEVICE); }
1threat
Scala : How to union multiple csv files in to single csv file : I am writing the below code to convert the union of multiple CSV files and writing the combined data into new file. But I am facing an error please do the needful. val filesData=List("file1", "file2") val dataframes = filesData.map(spark.read.option("header", true).csv(_)) val combined = dataframes.reduce(_ union _) val data = combined.rdd val head :Array[String]= data.first() val memberDataRDD = data.filter(_(0) != head(0)) type mismatch; found : org.apache.spark.sql.Row required: Array[String]
0debug
How to get FULL length GPS coordinates in Android? : I just found out that my GPS is returning latitude and longitude in not full length. It's returning latitude (example): 00.0000000 (9 chars), instead of: 00.00000000000000 (16 chars), so when I use my Geocoder it's returns different names of places. How can I receive a full-length coordinates?
0debug
int bdrv_file_open(BlockDriverState **pbs, const char *filename, const char *reference, QDict *options, int flags, Error **errp) { BlockDriverState *bs = NULL; BlockDriver *drv; const char *drvname; bool allow_protocol_prefix = false; Error *local_err = NULL; int ret; if (options == NULL) { options = qdict_new(); } if (reference) { if (filename || qdict_size(options)) { error_setg(errp, "Cannot reference an existing block device with " "additional options or a new filename"); return -EINVAL; } QDECREF(options); bs = bdrv_find(reference); if (!bs) { error_setg(errp, "Cannot find block device '%s'", reference); return -ENODEV; } bdrv_ref(bs); *pbs = bs; return 0; } bs = bdrv_new(""); bs->options = options; options = qdict_clone_shallow(options); if (!filename) { filename = qdict_get_try_str(options, "filename"); } else if (filename && !qdict_haskey(options, "filename")) { qdict_put(options, "filename", qstring_from_str(filename)); allow_protocol_prefix = true; } else { error_setg(errp, "Can't specify 'file' and 'filename' options at the " "same time"); ret = -EINVAL; goto fail; } drvname = qdict_get_try_str(options, "driver"); if (drvname) { drv = bdrv_find_format(drvname); if (!drv) { error_setg(errp, "Unknown driver '%s'", drvname); } qdict_del(options, "driver"); } else if (filename) { drv = bdrv_find_protocol(filename, allow_protocol_prefix); if (!drv) { error_setg(errp, "Unknown protocol"); } } else { error_setg(errp, "Must specify either driver or file"); drv = NULL; } if (!drv) { ret = -ENOENT; goto fail; } if (drv->bdrv_parse_filename && filename) { drv->bdrv_parse_filename(filename, options, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } qdict_del(options, "filename"); } else if (drv->bdrv_needs_filename && !filename) { error_setg(errp, "The '%s' block driver requires a file name", drv->format_name); ret = -EINVAL; goto fail; } if (!drv->bdrv_file_open) { ret = bdrv_open(bs, filename, options, flags, drv, &local_err); options = NULL; } else { ret = bdrv_open_common(bs, NULL, options, flags, drv, &local_err); } if (ret < 0) { error_propagate(errp, local_err); goto fail; } if (options && (qdict_size(options) != 0)) { const QDictEntry *entry = qdict_first(options); error_setg(errp, "Block protocol '%s' doesn't support the option '%s'", drv->format_name, entry->key); ret = -EINVAL; goto fail; } QDECREF(options); bs->growable = 1; *pbs = bs; return 0; fail: QDECREF(options); if (!bs->drv) { QDECREF(bs->options); } bdrv_unref(bs); return ret; }
1threat
How to generate TypeScript UML class diagrams? : <p>I'm using Visual Studio 2015 to create Web Apps and I just start using <code>TypeScript</code>. </p> <p>As my project gets bigger, I'm wondering if there's a way to get UML diagram of <code>TypeScript</code> code using Visual Studio, extensions or any other free tool. </p>
0debug
Missing return statement error even with return statement at the end of method : <p>I have this method to search for files and store them into a list and return it. The problem is that I get an "This method must return a result of type List" even I have a return statement of type List at the end of it.</p> <pre><code>public List&lt;String&gt; cautaFisiere(String root) { List&lt;String&gt; list = new ArrayList&lt;String&gt;(); File[] file = new File(root).listFiles(); if (file == null) { return ; } for (File x : file) { if (x.getName().toLowerCase().contains(fileName.toLowerCase())) { System.out.println(x.getName() + " " + x.getPath()); } String path = x.getPath(); if (x.isDirectory()) { cautaFisiere(path); } } return list; } </code></pre> <p>the error is on the 5th line in my code</p>
0debug
static void megasas_scsi_realize(PCIDevice *dev, Error **errp) { DeviceState *d = DEVICE(dev); MegasasState *s = MEGASAS(dev); MegasasBaseClass *b = MEGASAS_DEVICE_GET_CLASS(s); uint8_t *pci_conf; int i, bar_type; Error *err = NULL; int ret; pci_conf = dev->config; pci_conf[PCI_LATENCY_TIMER] = 0; pci_conf[PCI_INTERRUPT_PIN] = 0x01; if (s->msi != ON_OFF_AUTO_OFF) { ret = msi_init(dev, 0x50, 1, true, false, &err); assert(!ret || ret == -ENOTSUP); if (ret && s->msi == ON_OFF_AUTO_ON) { error_append_hint(&err, "You have to use msi=auto (default) or " "msi=off with this machine type.\n"); error_propagate(errp, err); return; } else if (ret) { s->msi = ON_OFF_AUTO_OFF; error_free(err); } } memory_region_init_io(&s->mmio_io, OBJECT(s), &megasas_mmio_ops, s, "megasas-mmio", 0x4000); memory_region_init_io(&s->port_io, OBJECT(s), &megasas_port_ops, s, "megasas-io", 256); memory_region_init_io(&s->queue_io, OBJECT(s), &megasas_queue_ops, s, "megasas-queue", 0x40000); if (megasas_use_msix(s) && msix_init(dev, 15, &s->mmio_io, b->mmio_bar, 0x2000, &s->mmio_io, b->mmio_bar, 0x3800, 0x68)) { s->msix = ON_OFF_AUTO_OFF; } if (pci_is_express(dev)) { pcie_endpoint_cap_init(dev, 0xa0); } bar_type = PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64; pci_register_bar(dev, b->ioport_bar, PCI_BASE_ADDRESS_SPACE_IO, &s->port_io); pci_register_bar(dev, b->mmio_bar, bar_type, &s->mmio_io); pci_register_bar(dev, 3, bar_type, &s->queue_io); if (megasas_use_msix(s)) { msix_vector_use(dev, 0); } s->fw_state = MFI_FWSTATE_READY; if (!s->sas_addr) { s->sas_addr = ((NAA_LOCALLY_ASSIGNED_ID << 24) | IEEE_COMPANY_LOCALLY_ASSIGNED) << 36; s->sas_addr |= (pci_bus_num(dev->bus) << 16); s->sas_addr |= (PCI_SLOT(dev->devfn) << 8); s->sas_addr |= PCI_FUNC(dev->devfn); } if (!s->hba_serial) { s->hba_serial = g_strdup(MEGASAS_HBA_SERIAL); } if (s->fw_sge >= MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE) { s->fw_sge = MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE; } else if (s->fw_sge >= 128 - MFI_PASS_FRAME_SIZE) { s->fw_sge = 128 - MFI_PASS_FRAME_SIZE; } else { s->fw_sge = 64 - MFI_PASS_FRAME_SIZE; } if (s->fw_cmds > MEGASAS_MAX_FRAMES) { s->fw_cmds = MEGASAS_MAX_FRAMES; } trace_megasas_init(s->fw_sge, s->fw_cmds, megasas_is_jbod(s) ? "jbod" : "raid"); if (megasas_is_jbod(s)) { s->fw_luns = MFI_MAX_SYS_PDS; } else { s->fw_luns = MFI_MAX_LD; } s->producer_pa = 0; s->consumer_pa = 0; for (i = 0; i < s->fw_cmds; i++) { s->frames[i].index = i; s->frames[i].context = -1; s->frames[i].pa = 0; s->frames[i].state = s; } scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev), &megasas_scsi_info, NULL); if (!d->hotplugged) { scsi_bus_legacy_handle_cmdline(&s->bus, errp); } }
1threat
Analytics API & PHP - Get reports in different format : <p>The following code returns an object of <code>Google_Service_AnalyticsReporting_GetReportsResponse</code></p> <pre><code>$body = new Google_Service_AnalyticsReporting_GetReportsRequest(); $body-&gt;setReportRequests($aRequests); return $this-&gt;oAnalytics-&gt;reports-&gt;batchGet($body); </code></pre> <p>I'm wondering if I can get Reports in a different format, example: <code>Array(Dimension,value)</code></p>
0debug
Turning off "Language Service Disabled" error message in VS2017 : <p>We are getting the following "Error" message in our MVC web application in Visual studio 2017 Enterprise.</p> <blockquote> <p>The language service is disabled for project 'C:\Work\Blackhawk Platform\Platform-DEV-Branch\BlackhawkViewer\BlackhawkViewer.csproj' because it included a large number of .js files. Consider excluding files using the 'exclude' section of a 'tsconfig.json' file.</p> </blockquote> <p>I have tried turning off the Language service in the options but this does not turn the message off:</p> <p><a href="https://i.stack.imgur.com/Gkiik.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Gkiik.png" alt="enter image description here"></a></p> <p>This is a rather large web application. Is there a way to turn this message off without disabling any files in the tsconfig.json file as it suggests?</p>
0debug
Xcode does not generate dSYM file : <p>In my iOS Project, I have set the <code>Generate Debug Symbols</code> to be <code>Yes</code>, but the .dYSM file is not created in DerivedData folder. I am running this application on my iPhone. Because I need it to map it to do the time profiler, because time profiler shows all the symbols in hex address. That has to be symbolicated to identify the time taking tasks.</p> <p>Thanks in advance.</p>
0debug
static void gen_load(DisasContext *dc, TCGv dst, TCGv addr, unsigned int size, int sign) { int mem_index = cpu_mmu_index(dc->env); if (dc->delayed_branch == 1) cris_store_direct_jmp(dc); if (size == 1) { if (sign) tcg_gen_qemu_ld8s(dst, addr, mem_index); else tcg_gen_qemu_ld8u(dst, addr, mem_index); } else if (size == 2) { if (sign) tcg_gen_qemu_ld16s(dst, addr, mem_index); else tcg_gen_qemu_ld16u(dst, addr, mem_index); } else if (size == 4) { tcg_gen_qemu_ld32u(dst, addr, mem_index); } else if (size == 8) { tcg_gen_qemu_ld64(dst, addr, mem_index); } }
1threat
How to open multiple terminals in docker? : <p>I need to launch two distinct processes on a docker container which requires two terminals.What is the best way to achieve this?</p>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
`std::complex<T>[n]` and `T[n*2]` type aliasing : <p>Since C++11 <code>std::complex&lt;T&gt;[n]</code> is guaranteed to be aliasable as <code>T[n*2]</code>, with well defined values. Which is exactly what one would expect for any mainstream architecture. Is this guarantee achievable with standard C++ for my own types, say <code>struct vec3 { float x, y, z; }</code> or is it only possible with special support from the compiler?</p>
0debug
error: incompatible types: void cannot be converted to double : <pre><code>import java.util.*; // This program will estimate the cost to paint a room in your house public class PaintJobEstimator { // square feet per one gallon of paint. public static final double AREA_PER_GALLON = 112.0; // hours of labor needed to paint AREA_PER_GALLON square feet. public static final double HOURS_PER_UNIT_AREA = 8.0; // charge to customer for one hour of labor. public static final double LABOR_COST_PER_HOUR = 35.0; // main declares a Scanner that is passed to // the input methods. main also controls the // order of calculations. public static void main( String[] args ) { Scanner keyboard = new Scanner( System.in ); // How many square feet do we need to paint? double sqft = getInput( keyboard, "Enter the number of square feet: " ); // How much does a gallon of paint cost? double gallonCost = getInput( keyboard, "Enter the price of a gallon of paint: " ); //////////////////////////////////////// // Calculate the cost of this paint job. //////////////////////////////////////// // First, how many gallons of paint do we need? int numGallons = calculateGallons( sqft ); // How long will the job take? double hoursLabor = calculateHours( sqft ); // How much will the paint cost? double paintCost = calculatePaintCost( numGallons, gallonCost ); // How much will the labor cost? double laborCost = calculateLaborCost( hoursLabor ); // What's the total bill? double totalCost = calculateTotalCost( paintCost, laborCost ); // Print the results. generateReport( sqft, gallonCost, numGallons, hoursLabor, paintCost, laborCost, totalCost); } public static double getInput( Scanner input, String prompt ) { System.out.print( prompt ); while ( !input.hasNextDouble() ) { input.nextLine(); // get rid of bad input. System.out.print( prompt ); } double inValue = input.nextDouble(); input.nextLine(); // clear the input line. return inValue; } // Your methods go here: // calculateGallons public static int calculateGallons( double sqft ) { // TO DO return correct value return (int)Math.ceil(sqft / AREA_PER_GALLON); } // calculateHours public static double calculateHours( double sqft ) { // TO DO return correct value return sqft / 14; } // TO DO: calculatePaintCost public static double calculatePaintCost (int numGallons, double gallonCost){ return numGallons * gallonCost; } // TO DO: calculateLaborCost (Hours * Labor/hr) public static double calculateLaborCost( double hoursLabor ){ return hoursLabor * LABOR_COST_PER_HOUR; } // TO DO: calculateTotalCost public static double calculateTotalCost( double paintCost, double laborCost ){ return paintCost + laborCost; } // To Do: generateReport public static double generateReport(double sqft, double gallonCost, int numGallons, double hoursLabor, double paintCost, double laborCost, double totalCost) { return System.out.print("To paint" + sqft + "square feet, with"); System.out.print("paint that costs" + gallonCost + "per gallon,"); System.out.print("you will need" + numGallons + "gallons of paint"); System.out.print("and" + hoursLabor + "hours of labor."); System.out.print("The cost of the paint is: " + paintCost ); System.out.print("The cost of the labor is: "+ laborCost); System.out.print("The total cost of the job is: " + totalCost); System.out.println(); } } </code></pre> <p>I am having with the generateReport method, i don't know how to return it properly. i keep getting the error</p> <pre><code>PaintJobEstimator.java:99: error: incompatible types: void cannot be converted to double return System.out.print("To paint" + sqft + "square feet, with"); ^ </code></pre> <p>what am i doing wrong. or am i just completely missing the point. I am new at this and really need help, i don't want to get the answer but if someone can point me in the right direction that would be great</p>
0debug
static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1, intptr_t arg2) { uint8_t *old_code_ptr = s->code_ptr; if (type == TCG_TYPE_I32) { tcg_out_op_t(s, INDEX_op_ld_i32); tcg_out_r(s, ret); tcg_out_r(s, arg1); tcg_out32(s, arg2); } else { assert(type == TCG_TYPE_I64); #if TCG_TARGET_REG_BITS == 64 tcg_out_op_t(s, INDEX_op_ld_i64); tcg_out_r(s, ret); tcg_out_r(s, arg1); assert(arg2 == (int32_t)arg2); tcg_out32(s, arg2); #else TODO(); #endif } old_code_ptr[1] = s->code_ptr - old_code_ptr; }
1threat
_net_rx_pkt_calc_l4_csum(struct NetRxPkt *pkt) { uint32_t cntr; uint16_t csum; uint16_t csl; uint32_t cso; trace_net_rx_pkt_l4_csum_calc_entry(); if (pkt->isip4) { if (pkt->isudp) { csl = be16_to_cpu(pkt->l4hdr_info.hdr.udp.uh_ulen); trace_net_rx_pkt_l4_csum_calc_ip4_udp(); } else { csl = be16_to_cpu(pkt->ip4hdr_info.ip4_hdr.ip_len) - IP_HDR_GET_LEN(&pkt->ip4hdr_info.ip4_hdr); trace_net_rx_pkt_l4_csum_calc_ip4_tcp(); } cntr = eth_calc_ip4_pseudo_hdr_csum(&pkt->ip4hdr_info.ip4_hdr, csl, &cso); trace_net_rx_pkt_l4_csum_calc_ph_csum(cntr, csl); } else { if (pkt->isudp) { csl = be16_to_cpu(pkt->l4hdr_info.hdr.udp.uh_ulen); trace_net_rx_pkt_l4_csum_calc_ip6_udp(); } else { struct ip6_header *ip6hdr = &pkt->ip6hdr_info.ip6_hdr; size_t full_ip6hdr_len = pkt->l4hdr_off - pkt->l3hdr_off; size_t ip6opts_len = full_ip6hdr_len - sizeof(struct ip6_header); csl = be16_to_cpu(ip6hdr->ip6_ctlun.ip6_un1.ip6_un1_plen) - ip6opts_len; trace_net_rx_pkt_l4_csum_calc_ip6_tcp(); } cntr = eth_calc_ip6_pseudo_hdr_csum(&pkt->ip6hdr_info.ip6_hdr, csl, pkt->ip6hdr_info.l4proto, &cso); trace_net_rx_pkt_l4_csum_calc_ph_csum(cntr, csl); } cntr += net_checksum_add_iov(pkt->vec, pkt->vec_len, pkt->l4hdr_off, csl, cso); csum = net_checksum_finish(cntr); trace_net_rx_pkt_l4_csum_calc_csum(pkt->l4hdr_off, csl, cntr, csum); return csum; }
1threat
Hide legend from seaborn pairplot : <p>I would like to hide the Seaborn pairplot legend. The official docs don't mention a keyword legend. Everything I tried using <code>plt.legend</code> didn't work. Please suggest the best way forward. Thanks!</p> <pre><code>import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline test = pd.DataFrame({ 'id': ['1','2','1','2','2','6','7','7','6','6'], 'x': [123,22,356,412,54,634,72,812,129,110], 'y':[120,12,35,41,45,63,17,91,112,151]}) sns.pairplot(x_vars='x', y_vars="y", data=test, hue = 'id', height = 3) </code></pre>
0debug
ajax can not recieve JSON from php : I have issues with recieving a JSON Objekt from PHP. I can alert it and get a ( I think correct) JSON Object with `dataType: 'text'`, but not use it like `data.message` --> it is "undefined". With `dataType: 'json'`,`'jsonp'` or the ajax call `$.getJSON` it does not work (It does not fire this request). AJAX $('#login').click(function () { var name = $('#username').val(); var pass = $('#password').val(); $.ajax({ url: "http://localhost/weltenbummler/Weltenbummler1/Weltenbummler1/app/login.php?username=" + name + "&password=" + pass, success: function (d) { alert(d); //works alert(d.message); // undefined }, dataType: "text", contentType: "application/json; charset=utf-8" }); }); Alerted JSONs `{"status":"f","message":"Benutzername und Passwort stimmen nicht ueberein"}` or `{"status":"t","message":"Erfolgreich eingeloggt!","data":{"id":"1","mail":"abc","password":"123"}}` I tested the recieved String on jsonlint.com and it should be valid. I tried to `JSON.parse(data)` , `$.parseJSON(data)` what does not work. `JSON.stringify(data)` is returning the JSON with slashes (I do not know why). Postman can read it aswell in html, text, xml or JSON... In php I tried to change the header to `header("Content-type: application/json; charset=utf-8");` or to force the response as JSON. connect.php file: <?php $host = "127.0.0.1"; $user= "root"; $pw=""; $db = "weltenbummler"; //Create connection $con = new mysqli($host,$user,$pw,$db); //Check connection if($con->connect_error){ die("Connection failed: " .$con->connect_error); }?> login.php file: <?php header("Content-type: application/json; charset=utf-8"); require 'connect.php'; $username = $_GET['username']; $password = $_GET['password']; $response = array(); if(empty($username)){ $response = array( "status " => " f", "message " => " Gebe einen Benutzernamen ein!" ); die(json_encode($response)); } if(empty($password)){ $response = array( "status" => "f", "message"=> "Gebe ein Passwort ein!" ); die(json_encode($response)); } $sqlstatement= ("SELECT id,mail,password FROM user WHERE mail = '$username' AND password = '$password'"); $result = mysqli_fetch_assoc($con->query($sqlstatement)); if (!$result) { $response = array( "status" => "f", "message" => "Benutzername und Passwort stimmen nicht ueberein" ); } else { $response = array( "status" => "t", "message" => "Erfolgreich eingeloggt!", "data" => $result ); } echo json_encode($response); $con->close();?> I do not know what else I can do. Thank you for your help in advice!
0debug
AWS Pass in variable into buildspec.yml from CodePipeline : <p>I have an AWS CodePipeline that invokes CodeBuild in the Build Stage.</p> <p>The question is how do I pass in an environment variable from CodePipeline that can be read in the CodeBuild's buildspec.yml?</p> <p>I know I can set environment variables in CodeBuild, but I want to use the same CodeBuild project for dev, qa, and prod environments. I don't see how I can pass an environment variable from CodePipeline that makes it all the way to the buildspec.yml</p> <p>Example buildspec.yml</p> <pre><code>version: 0.1 phases: build: commands: - npm install - npm build -- --env ${CURRENT_ENVIRONMENT} </code></pre> <p>Where CURRENT_ENVIRONMENT would be the variable I set in the CodePipeline Stage action.</p>
0debug
"TypeError: count() takes 0 positional arguments but 1 was given", what is wrong with the code : <p>I'm trying to find no. of even and odd numbers from the list.</p> <pre><code>list = [] for i in range(5): lst = int(input("Enter the numbers: ")) list.append(lst) print(list) even = 0 odd = 0 def count(): for i in list: if list[i] % 2 == 0: even+=1 else: odd+=1 return even, odd even,odd = count(list) print('Even : {} and Odd : {}'.format(even,odd)) </code></pre> <p>I'm getting an error:TypeError: count() takes 0 positional arguments but 1 was given. What does it mean?</p>
0debug