problem
stringlengths
26
131k
labels
class label
2 classes
static ram_addr_t get_current_ram_size(void) { GSList *list = NULL, *item; ram_addr_t size = ram_size; pc_dimm_build_list(qdev_get_machine(), &list); for (item = list; item; item = g_slist_next(item)) { Object *obj = OBJECT(item->data); size += object_property_get_int(obj, PC_DIMM_SIZE_PROP, &error_abort); } g_slist_free(list); return size; }
1threat
Count unique strings by column in pandas DataFrame : <p>I need to find how many times one of my four unique strings occurs in each column of my dataframe.</p> <p>does anyone know a formula that would work for this?</p>
0debug
How do you do a post request with xml? : <p>I'm trying to reproduce an post request but the examples of sending a post request include parameters and the example I'm trying to reporduce doesn't show parameters, just xml</p>
0debug
static void virtio_serial_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOSerial *vser = VIRTIO_SERIAL(dev); uint32_t i, max_supported_ports; if (!vser->serial.max_virtserial_ports) { error_setg(errp, "Maximum number of serial ports not specified"); return; } max_supported_ports = VIRTIO_QUEUE_MAX / 2 - 1; if (vser->serial.max_virtserial_ports > max_supported_ports) { error_setg(errp, "maximum ports supported: %u", max_supported_ports); return; } virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE, offsetof(struct virtio_console_config, emerg_wr)); qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS, dev, vdev->bus_name); qbus_set_hotplug_handler(BUS(&vser->bus), DEVICE(vser), errp); vser->bus.vser = vser; QTAILQ_INIT(&vser->ports); vser->bus.max_nr_ports = vser->serial.max_virtserial_ports; vser->ivqs = g_malloc(vser->serial.max_virtserial_ports * sizeof(VirtQueue *)); vser->ovqs = g_malloc(vser->serial.max_virtserial_ports * sizeof(VirtQueue *)); vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input); vser->ovqs[0] = virtio_add_queue(vdev, 128, handle_output); vser->c_ivq = virtio_add_queue(vdev, 32, control_in); vser->c_ovq = virtio_add_queue(vdev, 32, control_out); for (i = 1; i < vser->bus.max_nr_ports; i++) { vser->ivqs[i] = virtio_add_queue(vdev, 128, handle_input); vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output); } vser->ports_map = g_malloc0(((vser->serial.max_virtserial_ports + 31) / 32) * sizeof(vser->ports_map[0])); mark_port_added(vser, 0); vser->post_load = NULL; QLIST_INSERT_HEAD(&vserdevices.devices, vser, next); }
1threat
static void s390_cpu_realizefn(DeviceState *dev, Error **errp) { S390CPU *cpu = S390_CPU(dev); S390CPUClass *scc = S390_CPU_GET_CLASS(dev); cpu_reset(CPU(cpu)); scc->parent_realize(dev, errp); }
1threat
static void add_wav(int16_t *dest, int n, int skip_first, int *m, const int16_t *s1, const int8_t *s2, const int8_t *s3) { int i; int v[3]; v[0] = 0; for (i=!skip_first; i<3; i++) v[i] = (gain_val_tab[n][i] * m[i]) >> gain_exp_tab[n]; dest[i] = (s1[i]*v[0] + s2[i]*v[1] + s3[i]*v[2]) >> 12;
1threat
static void filter(AVFilterContext *ctx, AVFilterBufferRef *dstpic, int parity, int tff) { YADIFContext *yadif = ctx->priv; int y, i; for (i = 0; i < yadif->csp->nb_components; i++) { int w = dstpic->video->w; int h = dstpic->video->h; int refs = yadif->cur->linesize[i]; int df = (yadif->csp->comp[i].depth_minus1 + 8) / 8; if (i == 1 || i == 2) { w >>= yadif->csp->log2_chroma_w; h >>= yadif->csp->log2_chroma_h; } for (y = 0; y < h; y++) { if ((y ^ parity) & 1) { uint8_t *prev = &yadif->prev->data[i][y*refs]; uint8_t *cur = &yadif->cur ->data[i][y*refs]; uint8_t *next = &yadif->next->data[i][y*refs]; uint8_t *dst = &dstpic->data[i][y*dstpic->linesize[i]]; int mode = y==1 || y+2==h ? 2 : yadif->mode; yadif->filter_line(dst, prev, cur, next, w, y+1<h ? refs : -refs, y ? -refs : refs, parity ^ tff, mode); } else { memcpy(&dstpic->data[i][y*dstpic->linesize[i]], &yadif->cur->data[i][y*refs], w*df); } } } emms_c(); }
1threat
How can i make my own command to my first console application in VB.NET? : <p>I'm doing my first VB.NET console application. I have some experience making VB.NET "non-console" applications.</p> <p>My guestion is, how can i make my own commands to my console application. For example if user types to console "Hello World" and then the application would answer back to the user. I dont want it to be like "Press any key to continue..." nothing like that. I just want to make my own commands. </p> <p>I've already tried to find some help from YouTube or Google but i couldn't find anything that would help even little. So i'm asking from you guys.</p> <p>I also would like an answer soon as possible.</p>
0debug
What is the time complexity of Python's os.path.exists()? : <p>I have a ton of folders nested inside one another.<br> What is time complexity of Python's os.path.exists() ?<br> Does it change if used with different OS ?</p>
0debug
static size_t qemu_rdma_fill(RDMAContext *rdma, uint8_t *buf, int size, int idx) { size_t len = 0; if (rdma->wr_data[idx].control_len) { DDDPRINTF("RDMA %" PRId64 " of %d bytes already in buffer\n", rdma->wr_data[idx].control_len, size); len = MIN(size, rdma->wr_data[idx].control_len); memcpy(buf, rdma->wr_data[idx].control_curr, len); rdma->wr_data[idx].control_curr += len; rdma->wr_data[idx].control_len -= len; } return len; }
1threat
void bdrv_get_backing_filename(BlockDriverState *bs, char *filename, int filename_size) { pstrcpy(filename, filename_size, bs->backing_file); }
1threat
Can anyone help me with my currency shop? : <p>I'm a little bit new to python but i know like the basics like variables and strings, i recently create a discord bot with a currency and a shop. The shop doesn't work, its meant to let me buy a ticket for the item listed (it isn't meant to store anything).Could you please help me find out where i went wrong and help me make it better or show me where i went wrong where i can find me my answer. Here is what i got for the shop (note i'm using python 3.6.4):</p> <pre><code>@client.command(pass_context = True) async def buy(ctx, item): items = { "Apex Legends":[3,20], "Minecraft":[5,30], "Halo":[5,20], "Fortnite":[8,10], } while True: print("Apex Legends = 3BP / Minecraft = 5BP / Halo = 5BP / Fortnite = 8BP") print("Account Balance bp",stash) choice = input("What would you like to buy?: ").strip().title() if choice in items: if items[choice][1]&gt;0: if stash&gt;=items[choice][0]: items[choice][1]=items[choice][1]-1 stash= stash-items[choice][0] print("Thank you..!") print("") else: print("Sorry you don\'t enough money...") print("") else: print("sorry sold out") print("") else: print("Sorry we don\'t have that item...") print("") </code></pre> <p>If you want to see my full code on the bot its on here: <a href="https://hastebin.com/tojadefajo.py" rel="nofollow noreferrer">https://hastebin.com/tojadefajo.py</a></p>
0debug
static void mm_decode_intra(MmContext * s, int half_horiz, int half_vert, const uint8_t *buf, int buf_size) { int i, x, y; i=0; x=0; y=0; while(i<buf_size) { int run_length, color; if (buf[i] & 0x80) { run_length = 1; color = buf[i]; i++; }else{ run_length = (buf[i] & 0x7f) + 2; color = buf[i+1]; i+=2; } if (half_horiz) run_length *=2; if (color) { memset(s->frame.data[0] + y*s->frame.linesize[0] + x, color, run_length); if (half_vert) memset(s->frame.data[0] + (y+1)*s->frame.linesize[0] + x, color, run_length); } x+= run_length; if (x >= s->avctx->width) { x=0; y += 1 + half_vert; } } }
1threat
Swift 3 - Receiving optional value when value be a string : <p>So I have this code that takes the date of when a time was posted and converts it to something like "5h" or "1d" ago. However, it is displaying in my application as something like this - Optional(1)h. </p> <p>Here is the code: </p> <pre><code>func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "admincell", for: indexPath) as! AdminHomeCell let post = activities[indexPath.row] print(post["path"]) //let image = images[indexPath.row] //let imaged = post["path"] as! String //let image = URL(string: imaged) let username = post["username"] as? String let title = post["title"] as? String let date = post["date"] as! String let description = post["text"] as? String let location = post["location"] as? String let dateFormater = DateFormatter() dateFormater.dateFormat = "yyyy-MM-dd-HH:mm:ss" let newDate = dateFormater.date(from: date)! let from = newDate let now = Date() let components : NSCalendar.Unit = [.second, .minute, .hour, .day, .weekOfMonth] let difference = (Calendar.current as NSCalendar).components(components, from: from, to: now, options: []) if difference.second! &lt;= 0 { cell.postDate.text! = "now" } if difference.second! &gt; 0 &amp;&amp; difference.minute! == 0 { cell.postDate.text! = "\(difference.second)s." // 12s. } if difference.minute! &gt; 0 &amp;&amp; difference.hour! == 0 { cell.postDate.text! = "\(difference.minute)m." } if difference.hour! &gt; 0 &amp;&amp; difference.day! == 0 { cell.postDate.text! = "\(difference.hour)h." } if difference.day! &gt; 0 &amp;&amp; difference.weekOfMonth! == 0 { cell.postDate.text! = "\(difference.day)d." } if difference.weekOfMonth! &gt; 0 { cell.postDate.text! = "\(difference.weekOfMonth)w." } /* let session = URLSession(configuration: .default) let downloadPicTask = session.dataTask(with: image!) { (data, response, error) in if let e = error { print("Error downloading image: \(e)") } else { if let res = response as? HTTPURLResponse { if let image = data { let pic = UIImage(data: image) cell.postImage.image = pic } else{ print("couldn't get image: image is nil") } } else { print("Couldn't get response code") } } } */ cell.postTitle.text = title cell.postUser.text = username cell.postDescription.text = description cell.postLocation.text = location cell.postDate.text = date cell.postDescription.lineBreakMode = .byWordWrapping // or NSLineBreakMode.ByWordWrapping cell.postDescription.numberOfLines = 0 //downloadPicTask.resume() return cell } </code></pre> <p>If there is anything I should change to make it simply display "1h", please let me know! Thanks!</p>
0debug
Python String Compare : Simple == of strings not working. Using a typeform webhook, provides a json list of questions and answers to a user form. Question and answers are keyed on ID. I know beforehand what questions and answer ID's are, I now want to loop over the answers. For each Question ID, I loop through the answers to get the matching ID, and then I can pluck out the answer. Unfortunately, the equality operator is not working although the stings look the same? Not pretty, but here is the code (only a small form): for answer in user_answers: print("answer: " + answer['field']['id']) print("name id: " + form_fields["name"]) print("bio id: " + form_fields["bio"]) print("interests id: " + form_fields["interests"]) if answer == form_fields["name"]: print("A") elif answer == form_fields["bio"]: print("B") elif answer == form_fields["interests"]: print("C") else: print("D") Output: answer: aoQDJzkrAVGA name id: aoQDJzkrAVGA bio id: aOsexSfYNQ8B interests id: l6QZGmgHPXEQ D answer: aOsexSfYNQ8B name id: aoQDJzkrAVGA bio id: aOsexSfYNQ8B interests id: l6QZGmgHPXEQ D answer: l6QZGmgHPXEQ name id: aoQDJzkrAVGA bio id: aOsexSfYNQ8B interests id: l6QZGmgHPXEQ D We can see that the first pass answer and name ID match - should pring out A, but instead jumps out at the default clause and prints D. Priority is to understand why this is not working, but also happy if a more efficient method is available to cope with longer forms?
0debug
static void memory_region_dispatch_write(MemoryRegion *mr, hwaddr addr, uint64_t data, unsigned size) { if (!memory_region_access_valid(mr, addr, size, true)) { return; } adjust_endianness(mr, &data, size); if (!mr->ops->write) { mr->ops->old_mmio.write[bitops_ffsl(size)](mr->opaque, addr, data); return; } access_with_adjusted_size(addr, &data, size, mr->ops->impl.min_access_size, mr->ops->impl.max_access_size, memory_region_write_accessor, mr); }
1threat
int css_do_rsch(SubchDev *sch) { SCSW *s = &sch->curr_status.scsw; PMCW *p = &sch->curr_status.pmcw; int ret; if (~(p->flags) & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA)) { ret = -ENODEV; goto out; } if (s->ctrl & SCSW_STCTL_STATUS_PEND) { ret = -EINPROGRESS; goto out; } if (((s->ctrl & SCSW_CTRL_MASK_FCTL) != SCSW_FCTL_START_FUNC) || (s->ctrl & SCSW_ACTL_RESUME_PEND) || (!(s->ctrl & SCSW_ACTL_SUSP))) { ret = -EINVAL; goto out; } if (channel_subsys.chnmon_active) { css_update_chnmon(sch); } s->ctrl |= SCSW_ACTL_RESUME_PEND; do_subchannel_work(sch); ret = 0; out: return ret; }
1threat
I cant figure out my error :/ : Okay so, this is probably one of those mistakes that is so simple that its mindblowing. Im not sure what the problem is but the program is meant to receive a number, 1 digit at a time, use that digit as an index for the array to check if its true, if so then break out of the loop and if not, set it to true and continue scanning the other digits til it reaches the last. Its only supposed to tell if a digit was repeated or not at this point. I have this code so far but i cant seem to get it working. Can anyone help me? i noticed while doing my own troubleshooting by testing the value of the variables after execution that sometimes the other digits aren't even read, only the first entered and i dont know why Heres the code: #include <stdio.h> #define true 1 #define false 0 typedef int bool; int main(void) { // Variables to contain the seen digits bool seendig[10] = { false }; long entered; int container; printf("This Program Is Designed To Determine If Any Digits Has Been Repeated!\nPlease Enter a Number: "); scanf_s("%1d", &entered); while (entered > 0) { container = entered; if (seendig[container]) { break; } seendig[container] = true; entered /= 10; } if (entered > 0) // then digit is repeated printf("\nThe Digit Was Repeated\n\n"); else { printf("The Digit Was Not Repeated\n\n"); } system("pause"); return 0; }
0debug
static void RENAME(yuv2rgb565_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) { 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" YSCALEYUV2RGB1(%%REGBP, %5) "pxor %%mm7, %%mm7 \n\t" #ifdef DITHER1XBPP "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t" "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif WRITERGB16(%%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) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5) "pxor %%mm7, %%mm7 \n\t" #ifdef DITHER1XBPP "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t" "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif WRITERGB16(%%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) ); } }
1threat
static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx, Plane *plane, const uint8_t *data, int32_t data_size, int32_t strip_width) { Cell curr_cell; int num_vectors; num_vectors = bytestream_get_le32(&data); ctx->mc_vectors = num_vectors ? data : 0; init_get_bits(&ctx->gb, &data[num_vectors * 2], data_size << 3); ctx->skip_bits = 0; ctx->need_resync = 0; ctx->last_byte = data + data_size - 1; curr_cell.xpos = curr_cell.ypos = 0; curr_cell.width = plane->width >> 2; curr_cell.height = plane->height >> 2; curr_cell.tree = 0; curr_cell.mv_ptr = 0; return parse_bintree(ctx, avctx, plane, INTRA_NULL, &curr_cell, CELL_STACK_MAX, strip_width); }
1threat
Can't find Python executable "/path/to/executable/python2.7", you can set the PYTHON env variable : <blockquote> <p>bufferutil@1.2.1 install /home/sudthenerd/polymer-starter-kit-1.2.1/node_modules/bufferutil > <strong>node-gyp rebuild gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "/path/to/executable/python2.7", you can set the PYTHON env variable</strong>. gyp ERR! stack at failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:401:14) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:330:11 gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:78:16) gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:82:29) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:93:16 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15) gyp ERR! System Linux 3.13.0-74-generic gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /home/sudthenerd/polymer-starter-kit-1.2.1/node_modules/bufferutil gyp ERR! node -v v5.3.0 gyp ERR! node-gyp -v v3.2.1 gyp ERR! not ok npm WARN install:bufferutil@1.2.1 bufferutil@1.2.1 install: <code>node-gyp rebuild</code> npm WARN install:bufferutil@1.2.1 Exit status 1 > utf-8-validate@1.2.1 install /home/sudthenerd/polymer-starter-kit-1.2.1/node_modules/utf-8-validate > node-gyp rebuild gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "/path/to/executable/python2.7", you can set the PYTHON env variable. gyp ERR! stack at failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:401:14) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:330:11 gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:78:16) gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:82:29) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:93:16 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15) gyp ERR! System Linux 3.13.0-74-generic gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /home/sudthenerd/polymer-starter-kit-1.2.1/node_modules/utf-8-validate gyp ERR! node -v v5.3.0 gyp ERR! node-gyp -v v3.2.1 gyp ERR! not ok npm WARN install:utf-8-validate@1.2.1 utf-8-validate@1.2.1 install: <code>node-gyp rebuild</code> npm WARN install:utf-8-validate@1.2.1 Exit status 1</p> </blockquote>
0debug
static int gif_image_write_header(ByteIOContext *pb, int width, int height, uint32_t *palette) { int i; unsigned int v; put_tag(pb, "GIF"); put_tag(pb, "89a"); put_le16(pb, width); put_le16(pb, height); put_byte(pb, 0xf7); put_byte(pb, 0x1f); put_byte(pb, 0); if (!palette) { put_buffer(pb, (unsigned char *)gif_clut, 216*3); for(i=0;i<((256-216)*3);i++) put_byte(pb, 0); } else { for(i=0;i<256;i++) { v = palette[i]; put_byte(pb, (v >> 16) & 0xff); put_byte(pb, (v >> 8) & 0xff); put_byte(pb, (v) & 0xff); } } #ifdef GIF_ADD_APP_HEADER put_byte(pb, 0x21); put_byte(pb, 0xff); put_byte(pb, 0x0b); put_tag(pb, "NETSCAPE2.0"); put_byte(pb, 0x03); put_byte(pb, 0x01); put_byte(pb, 0x00); put_byte(pb, 0x00); #endif return 0; }
1threat
static CharDriverState *qemu_chr_open_file_out(QemuOpts *opts) { int fd_out; TFR(fd_out = open(qemu_opt_get(opts, "path"), O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666)); if (fd_out < 0) return NULL; return qemu_chr_open_fd(-1, fd_out); }
1threat
Validating Domain For AWS ACM in GoDaddy : <p>I have requested an SSL certificate from AWS and I opted for DNS validation. Now they are asking me to add a CNAME record to validate. They have provided me the following to be used:</p> <pre><code>Name: xxx.mydomain.com. [Host field on GoDaddy] Value: xxx.acm-validations.aws. [Points to field on GoDaddy] Type: CNAME </code></pre> <p>Now whenever I provide this using GoDaddy DNS interface, it throws an error saying for 'Points to' field:</p> <blockquote> <p>Enter either @ or a valid host name such as: "subdomain.domain.tld"</p> </blockquote> <p>Did anyone encounter this issue on GoDaddy DNS entries?</p>
0debug
Texture Array getting the last index only ( C# UNITY) : <p>I'm creating an array of Texture so I'm doing it like this</p> <pre><code>[SerializeField] GameObject[] uitex = new GameObject[4]; void GetTextureFromServer() { string dealer_image = ""; var tex = new Texture2D(20, 20); for (int i = 0; i &lt; tzPlayInfo.Instance.bc_gametablelist.Count; i++) { dealer_image += tzPlayInfo.Instance.bc_gametablelist[i].dlrimage; dealer_image += ","; } string[] NewLinks = dealer_image.Split(','); for(int j = 0; j &lt; NewLinks.Length - 1; j++) { Debug.Log("HERE ARE THE LINKS : " + NewLinks[j]); new BestHTTP.HTTPRequest(new System.Uri("***********.amazonaws.com/resources" + "/dealer/pic/" + NewLinks[j]), (BestHTTP.HTTPRequest req, BestHTTP.HTTPResponse res) =&gt; { tex.LoadImage(res.Data); }).Send(); } for (int i = 0; i &lt; uitex.Length; i++) { uitex[i].GetComponent&lt;UITexture&gt;().mainTexture = tex; } } </code></pre> <p>What i tried so far is this</p> <pre><code>uitex[j].GetComponent&lt;UITexture&gt;().mainTexture = tex; </code></pre> <p>But it gives me an array is out of range and i don't know why.</p> <p>The problem with this code is that it always gets the last index i have so all 4 gameobject has the same all textures and that's not what i want. Could someone please help me with my problem . Thank you.</p>
0debug
c# - Incorrect syntax near the keyword 'Table' : I'm creating a login window in c# with SQL server following this guys tutorial https://www.youtube.com/watch?v=NX8-LhgFnUU I did everything like he did but I get an error in my code when I debug the app and type username and password and click login. It brings me to code which is this code / pictures: https://i.imgur.com/UF1BUl8.png https://i.imgur.com/mYTOZBw.png Code: private void button1_Click(object sender, EventArgs e) { SqlConnection sqlcon = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=E:\eAlati - 1366x768\FastFoodDemo\DB\logindb.mdf;Integrated Security=True;Connect Timeout=30"); string query = "Select * from Table Where username = '" + txtUsername.Text.Trim() + "'and password = '" + txtPassword.Text.Trim() + "'"; SqlDataAdapter sda = new SqlDataAdapter(query, sqlcon); DataTable dtbl = new DataTable(); sda.Fill(dtbl); if(dtbl.Rows.Count == 1) { ucitavanje objUcitavanje = new ucitavanje(); this.Hide(); objUcitavanje.Show(); } else { MessageBox.Show("Vaše korisničko ime ili lozinka nisu točni! Pokušajte ponovno"); } } thanks for understanding :)
0debug
xcode 'boost/config/user.hpp' file not found : <p>I'm using Xcode 9, everything was fine. but after I upgrade my React-native version to 0.46, and upgrade my React to 16.0.0 alpha12. and re-run my project, Xcode gives me an error <code>'boost/config/user.hpp' file not found</code>, I use <code>brew install boost</code> to install boost. but it doest work. It seems like something wrong with react-native, because I can use Xcode to create a new iOS project and works fine, but when I use 'react-native init newProject', It gives me the same error. </p>
0debug
How do I compile a GitHub project? : <p>I've tried for few hours.. and failed. i can't seem to get it to work. ( in NetBeans)</p> <p>I've added libraries that creator pointed out, source and nbproject - I get errors.</p> <p>Can someone tell me what to do step by step? Thank you in advance.</p> <p>LINK TO GITHUB: <a href="https://github.com/lucidexploration/JonBot-NG" rel="nofollow">https://github.com/lucidexploration/JonBot-NG</a></p> <p>( i've tried adding it - I downloaded the zip from github then I created new project in netbeams (selected as just Java) then I went to "files" tab and dragged and dropped down src folder from zip i downloaded from GitHub then nbproject and the rest. I've got an JAVADOC error. )</p>
0debug
Create a Stored Procedure in Firebird from Delphi code : How to Create a Stored Procedure in Firebird from Delphi XE3 code i.e. want to add stored procedure given below through delphi code. I am using TSQLQuery ->ExecSQL() but it is giving error at line 9 column 10. CREATE PROCEDURE GET_BRANCH_ID ( EMPID Integer) returns ( EMPBRANCHID Integer) AS declare variable EmpBrch Integer; Begin select EMP_BRANCH_ID from EMPLOYEE where EMPLOYEE_ID= :EMPID into :EmpBrch; EMPBRANCHID = :EmpBrch; SUSPEND; End Delphi code I am using is: with SQLQueryExc do begin close; SQL.clear; SQL.Add(SPString.Text); ExecSQL(); End Any help will be appreciated. Thanks.
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
static void mmio_interface_realize(DeviceState *dev, Error **errp) { MMIOInterface *s = MMIO_INTERFACE(dev); DPRINTF("realize from 0x%" PRIX64 " to 0x%" PRIX64 " map host pointer" " %p\n", s->start, s->end, s->host_ptr); if (!s->host_ptr) { error_setg(errp, "host_ptr property must be set"); } if (!s->subregion) { error_setg(errp, "subregion property must be set"); } memory_region_init_ram_ptr(&s->ram_mem, OBJECT(s), "ram", s->end - s->start + 1, s->host_ptr); memory_region_set_readonly(&s->ram_mem, s->ro); memory_region_add_subregion(s->subregion, s->start, &s->ram_mem); }
1threat
static void libopus_write_header(AVCodecContext *avctx, int stream_count, int coupled_stream_count, const uint8_t *channel_mapping) { uint8_t *p = avctx->extradata; int channels = avctx->channels; bytestream_put_buffer(&p, "OpusHead", 8); bytestream_put_byte(&p, 1); bytestream_put_byte(&p, channels); bytestream_put_le16(&p, avctx->delay); bytestream_put_le32(&p, avctx->sample_rate); bytestream_put_le16(&p, 0); if (channels > 2) { bytestream_put_byte(&p, channels <= 8 ? 1 : 255); bytestream_put_byte(&p, stream_count); bytestream_put_byte(&p, coupled_stream_count); bytestream_put_buffer(&p, channel_mapping, channels); } else { bytestream_put_byte(&p, 0); } }
1threat
int ff_split_xiph_headers(uint8_t *extradata, int extradata_size, int first_header_size, uint8_t *header_start[3], int header_len[3]) { int i, j; if (AV_RB16(extradata) == first_header_size) { for (i=0; i<3; i++) { header_len[i] = AV_RB16(extradata); extradata += 2; header_start[i] = extradata; extradata += header_len[i]; } } else if (extradata[0] == 2) { for (i=0,j=1; i<2; i++,j++) { header_len[i] = 0; for (; j<extradata_size && extradata[j]==0xff; j++) { header_len[i] += 0xff; } if (j >= extradata_size) return -1; header_len[i] += extradata[j]; } header_len[2] = extradata_size - header_len[0] - header_len[1] - j; extradata += j; header_start[0] = extradata; header_start[1] = header_start[0] + header_len[0]; header_start[2] = header_start[1] + header_len[1]; } else { return -1; } return 0; }
1threat
static void isa_ipmi_bmc_check(Object *obj, const char *name, Object *val, Error **errp) { IPMIBmc *bmc = IPMI_BMC(val); if (bmc->intf) error_setg(errp, "BMC object is already in use"); }
1threat
How do i make for my program to run again after it asked the user to press 1 to continue? : i have a program where a user has to select a element of their choice from the linear search array. my program should display the question and the given array again when a user enters 1 to continue. im not sure where the while loop have to be and what code should be in the while loop, because if the user enters 1 to continue my program does not continue it just ends Here my code: import java.util.Scanner; public class SearchArray { public static int Search(int[] data, int key) { for (int i = 0; i < data.length; i++) { if (data[i] == key) { return i; }//end of if statement }//end of for loop return -1; }//end of search method public static void main(String[] args) { Scanner in = new Scanner(System.in); int [] data= {74,56,45,14,78,100}; for(int element: data) { System.out.print(element + " , "); } System.out.println("Enter the key of your choice: "); int key = in.nextInt(); int index = Search(data, key); int option = 1; System.out.println("Enter 1 to continue: "); while(option ==1) { option=in.nextInt(); } if(index!=-1) { System.out.println("Key: " + key + " Found at index: " + Search(data, key)); }//end of if statement else { System.out.println("Key: " + key + " Is not found "); }//end of else statement }//end of main method }//end of main class
0debug
How to join several arrays in PHP? : <p>I have this arrays: Array ( [0] => 1 ) Array ( [0] => 1) Array ( [0] => 1 )</p> <p>I want join to one array and result equal : Array ( [0] => 1 , [1] => 1 , [2] => 1 )</p>
0debug
static void RENAME(extract_even)(const uint8_t *src, uint8_t *dst, x86_reg count) { dst += count; src += 2*count; count= - count; #if COMPILE_TEMPLATE_MMX if(count <= -16) { count += 15; __asm__ volatile( "pcmpeqw %%mm7, %%mm7 \n\t" "psrlw $8, %%mm7 \n\t" "1: \n\t" "movq -30(%1, %0, 2), %%mm0 \n\t" "movq -22(%1, %0, 2), %%mm1 \n\t" "movq -14(%1, %0, 2), %%mm2 \n\t" "movq -6(%1, %0, 2), %%mm3 \n\t" "pand %%mm7, %%mm0 \n\t" "pand %%mm7, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "pand %%mm7, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm0,-15(%2, %0) \n\t" MOVNTQ" %%mm2,- 7(%2, %0) \n\t" "add $16, %0 \n\t" " js 1b \n\t" : "+r"(count) : "r"(src), "r"(dst) ); count -= 15; } #endif while(count<0) { dst[count]= src[2*count]; count++; } }
1threat
static void pciej_write(void *opaque, uint32_t addr, uint32_t val) { BusState *bus = opaque; DeviceState *qdev, *next; PCIDevice *dev; int slot = ffs(val) - 1; QLIST_FOREACH_SAFE(qdev, &bus->children, sibling, next) { dev = DO_UPCAST(PCIDevice, qdev, qdev); if (PCI_SLOT(dev->devfn) == slot) { qdev_free(qdev); } } PIIX4_DPRINTF("pciej write %x <== %d\n", addr, val); }
1threat
static inline void h264_idct8_1d(int16_t *block) { __asm__ volatile( "movq 112(%0), %%mm7 \n\t" "movq 80(%0), %%mm0 \n\t" "movq 48(%0), %%mm3 \n\t" "movq 16(%0), %%mm5 \n\t" "movq %%mm0, %%mm4 \n\t" "movq %%mm5, %%mm1 \n\t" "psraw $1, %%mm4 \n\t" "psraw $1, %%mm1 \n\t" "paddw %%mm0, %%mm4 \n\t" "paddw %%mm5, %%mm1 \n\t" "paddw %%mm7, %%mm4 \n\t" "paddw %%mm0, %%mm1 \n\t" "psubw %%mm5, %%mm4 \n\t" "paddw %%mm3, %%mm1 \n\t" "psubw %%mm3, %%mm5 \n\t" "psubw %%mm3, %%mm0 \n\t" "paddw %%mm7, %%mm5 \n\t" "psubw %%mm7, %%mm0 \n\t" "psraw $1, %%mm3 \n\t" "psraw $1, %%mm7 \n\t" "psubw %%mm3, %%mm5 \n\t" "psubw %%mm7, %%mm0 \n\t" "movq %%mm4, %%mm3 \n\t" "movq %%mm1, %%mm7 \n\t" "psraw $2, %%mm1 \n\t" "psraw $2, %%mm3 \n\t" "paddw %%mm5, %%mm3 \n\t" "psraw $2, %%mm5 \n\t" "paddw %%mm0, %%mm1 \n\t" "psraw $2, %%mm0 \n\t" "psubw %%mm4, %%mm5 \n\t" "psubw %%mm0, %%mm7 \n\t" "movq 32(%0), %%mm2 \n\t" "movq 96(%0), %%mm6 \n\t" "movq %%mm2, %%mm4 \n\t" "movq %%mm6, %%mm0 \n\t" "psraw $1, %%mm4 \n\t" "psraw $1, %%mm6 \n\t" "psubw %%mm0, %%mm4 \n\t" "paddw %%mm2, %%mm6 \n\t" "movq (%0), %%mm2 \n\t" "movq 64(%0), %%mm0 \n\t" SUMSUB_BA( %%mm0, %%mm2 ) SUMSUB_BA( %%mm6, %%mm0 ) SUMSUB_BA( %%mm4, %%mm2 ) SUMSUB_BA( %%mm7, %%mm6 ) SUMSUB_BA( %%mm5, %%mm4 ) SUMSUB_BA( %%mm3, %%mm2 ) SUMSUB_BA( %%mm1, %%mm0 ) :: "r"(block) ); }
1threat
how to create connection between MySQL table to query in c# : i write the query for insert data to MySQL table "Persons": SqlConnection con = new SqlConnection(); try { String insert = "INSERT INTO Persons (id,Name,Surname,Address,Phone) VALUES ('" + txtId.Text + "','" + txtName.Text + "','" + txtSurname.Text + "','" + txtAddress.Text + "','" + txtPhone.Text + "')"; con.Open(); SqlCommand cmd = new SqlCommand(insert,con); cmd.ExecuteNonQuery(); con.Close(); } catch { MessageBox.Show("Id is not valid"); } But its not work. I have one connection for all database, but its not work for specific table. how i can to create connection between specific table to query in c#?
0debug
static int decode_type2(GetByteContext *gb, PutByteContext *pb) { unsigned repeat = 0, first = 1, opcode; int i, len, pos; while (bytestream2_get_bytes_left(gb) > 0) { GetByteContext gbc; while (bytestream2_get_bytes_left(gb) > 0) { if (first) { first = 0; if (bytestream2_peek_byte(gb) > 17) { len = bytestream2_get_byte(gb) - 17; if (len < 4) { do { bytestream2_put_byte(pb, bytestream2_get_byte(gb)); --len; } while (len); opcode = bytestream2_peek_byte(gb); continue; } else { do { bytestream2_put_byte(pb, bytestream2_get_byte(gb)); --len; } while (len); opcode = bytestream2_peek_byte(gb); if (opcode < 0x10) { bytestream2_skip(gb, 1); pos = - (opcode >> 2) - 4 * bytestream2_get_byte(gb) - 2049; bytestream2_init(&gbc, pb->buffer_start, pb->buffer_end - pb->buffer_start); bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos, SEEK_SET); bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); len = opcode & 3; if (!len) { repeat = 1; } else { do { bytestream2_put_byte(pb, bytestream2_get_byte(gb)); --len; } while (len); opcode = bytestream2_peek_byte(gb); } continue; } } repeat = 0; } repeat = 1; } if (repeat) { repeat = 0; opcode = bytestream2_peek_byte(gb); if (opcode < 0x10) { bytestream2_skip(gb, 1); if (!opcode) { if (!bytestream2_peek_byte(gb)) { do { bytestream2_skip(gb, 1); opcode += 255; } while (!bytestream2_peek_byte(gb) && bytestream2_get_bytes_left(gb) > 0); } opcode += bytestream2_get_byte(gb) + 15; } bytestream2_put_le32(pb, bytestream2_get_le32(gb)); for (i = opcode - 1; i > 0; --i) bytestream2_put_byte(pb, bytestream2_get_byte(gb)); opcode = bytestream2_peek_byte(gb); if (opcode < 0x10) { bytestream2_skip(gb, 1); pos = - (opcode >> 2) - 4 * bytestream2_get_byte(gb) - 2049; bytestream2_init(&gbc, pb->buffer_start, pb->buffer_end - pb->buffer_start); bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos, SEEK_SET); bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); len = opcode & 3; if (!len) { repeat = 1; } else { do { bytestream2_put_byte(pb, bytestream2_get_byte(gb)); --len; } while (len); opcode = bytestream2_peek_byte(gb); } continue; } } } if (opcode >= 0x40) { bytestream2_skip(gb, 1); pos = - ((opcode >> 2) & 7) - 1 - 8 * bytestream2_get_byte(gb); len = (opcode >> 5) - 1; bytestream2_init(&gbc, pb->buffer_start, pb->buffer_end - pb->buffer_start); bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos, SEEK_SET); bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); do { bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); --len; } while (len); len = opcode & 3; if (!len) { repeat = 1; } else { do { bytestream2_put_byte(pb, bytestream2_get_byte(gb)); --len; } while (len); opcode = bytestream2_peek_byte(gb); } continue; } else if (opcode < 0x20) { break; } len = opcode & 0x1F; bytestream2_skip(gb, 1); if (!len) { if (!bytestream2_peek_byte(gb)) { do { bytestream2_skip(gb, 1); len += 255; } while (!bytestream2_peek_byte(gb) && bytestream2_get_bytes_left(gb) > 0); } len += bytestream2_get_byte(gb) + 31; } i = bytestream2_get_le16(gb); pos = - (i >> 2) - 1; bytestream2_init(&gbc, pb->buffer_start, pb->buffer_end - pb->buffer_start); bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos, SEEK_SET); if (len < 6 || bytestream2_tell_p(pb) - bytestream2_tell(&gbc) < 4) { bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); do { bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); --len; } while (len); } else { bytestream2_put_le32(pb, bytestream2_get_le32(&gbc)); for (len = len - 2; len; --len) bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); } len = i & 3; if (!len) { repeat = 1; } else { do { bytestream2_put_byte(pb, bytestream2_get_byte(gb)); --len; } while (len); opcode = bytestream2_peek_byte(gb); } } bytestream2_skip(gb, 1); if (opcode < 0x10) { pos = -(opcode >> 2) - 1 - 4 * bytestream2_get_byte(gb); bytestream2_init(&gbc, pb->buffer_start, pb->buffer_end - pb->buffer_start); bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos, SEEK_SET); bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); len = opcode & 3; if (!len) { repeat = 1; } else { do { bytestream2_put_byte(pb, bytestream2_get_byte(gb)); --len; } while (len); opcode = bytestream2_peek_byte(gb); } continue; } len = opcode & 7; if (!len) { if (!bytestream2_peek_byte(gb)) { do { bytestream2_skip(gb, 1); len += 255; } while (!bytestream2_peek_byte(gb) && bytestream2_get_bytes_left(gb) > 0); } len += bytestream2_get_byte(gb) + 7; } i = bytestream2_get_le16(gb); pos = bytestream2_tell_p(pb) - 2048 * (opcode & 8); pos = pos - (i >> 2); if (pos == bytestream2_tell_p(pb)) break; pos = pos - 0x4000; bytestream2_init(&gbc, pb->buffer_start, pb->buffer_end - pb->buffer_start); bytestream2_seek(&gbc, pos, SEEK_SET); if (len < 6 || bytestream2_tell_p(pb) - bytestream2_tell(&gbc) < 4) { bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); do { bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); --len; } while (len); } else { bytestream2_put_le32(pb, bytestream2_get_le32(&gbc)); for (len = len - 2; len; --len) bytestream2_put_byte(pb, bytestream2_get_byte(&gbc)); } len = i & 3; if (!len) { repeat = 1; } else { do { bytestream2_put_byte(pb, bytestream2_get_byte(gb)); --len; } while (len); opcode = bytestream2_peek_byte(gb); } } return 0; }
1threat
HOW CAN I DISPLAY AN ERROR MESSAGE - JAVA : I am a beginner, and I have to write a code that calculates the area and circumference from the radius the user gives me. that part was easy, but the teacher also wanted me to only accept valid integers and have the user re-enter a value when his input is incorrect ... so i was able to have it display the error message for every case except when they enter an negative integer: import java.util.Scanner; public class GetCircle { public static void main(String []args) { Scanner input = new Scanner(System.in); int radius; do { System.out.print("Please enter size of radius (Must be integer): "); while (!input.hasNextInt()) { System.out.print("That is not a valid number, please try again :"); input.next(); } radius = input.nextInt(); } while (radius < 0); System.out.println("The radius is: " + radius); } } and so this is what I get as a result: Please enter size of radius (Must be integer): aaa That is not a valid number, please try again :4.5555 That is not a valid number, please try again :-5 Please enter size of radius (Must be integer): -5 Please enter size of radius (Must be integer): -8.777 That is not a valid number, please try again :-4 Please enter size of radius (Must be integer): ** so whenever its a negative integer it doesn't display the error message... how can i fix this please?
0debug
the right way to sort a linked list in java : i have this linked List class Node { Node next; int num; public Node(int val) { num = val; next = null; } } public class LinkedList { Node head; public LinkedList(int val) { head = new Node(val); } public void append(int val) { Node tmpNode = head; while (tmpNode.next != null) { tmpNode = tmpNode.next; } tmpNode.next = new Node(val); } public void print() { Node tmpNode = head; while (tmpNode != null) { System.out.print(tmpNode.num + " -> "); tmpNode = tmpNode.next; } System.out.print("null"); } public static void main(String[] args) { LinkedList myList = new LinkedList(8); myList.append(7); myList.append(16); myList.print(); } } ` and i want to know how should I sort this linked list ... all i know that the sorting code based on this insert code ... i tried to change it but some how the numbers start to Disapper public void insert(int val) { Node currentNode = head; Node nextNode = head.next; if (currentNode.num > val) { Node tmpNode = head; head = new Node(val); head.next = tmpNode; return; } if (nextNode != null && nextNode.num > val) { currentNode.next = new Node(val); currentNode.next.next = nextNode; return; } while (nextNode != null && nextNode.num < val) { currentNode = nextNode; nextNode = nextNode.next; } currentNode.next = new Node(val); currentNode.next.next = nextNode; }
0debug
How do I add do regular expression for add '\' before $ after "//" : Input: //bla bla $Log$ Output //bla bla \$Log\$
0debug
static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { MP3Context *mp3 = s->priv_data; AVIndexEntry *ie; AVStream *st = s->streams[0]; int64_t ret = av_index_search_timestamp(st, timestamp, flags); uint32_t header = 0; if (!mp3->xing_toc) { st->skip_samples = timestamp <= 0 ? mp3->start_pad + 528 + 1 : 0; return -1; } if (ret < 0) return ret; ie = &st->index_entries[ret]; ret = avio_seek(s->pb, ie->pos, SEEK_SET); if (ret < 0) return ret; while (!s->pb->eof_reached) { header = (header << 8) + avio_r8(s->pb); if (ff_mpa_check_header(header) >= 0) { ff_update_cur_dts(s, st, ie->timestamp); ret = avio_seek(s->pb, -4, SEEK_CUR); st->skip_samples = ie->timestamp <= 0 ? mp3->start_pad + 528 + 1 : 0; return (ret >= 0) ? 0 : ret; } } return AVERROR_EOF; }
1threat
Python: How to find a list of all keys that contain equal values : I want to find a list (of lists) of all keys in a dictionary that contain values equal to other elements. For example: ``` dict_with_dups = { "a": 1, "b": 1, "c": 1, "d": 2, "e": 3, "f": 3, "g": 4, } keys_with_same = locate_same_keys(dict_with_dups) for key_list in keys_with_same: print(f"{key_list}") ``` The above should print this: ``` ['a', 'b', 'c'] ['e', 'f'] ``` How do I most efficiently write the function `locate_same_keys`?
0debug
static void virtio_console_init_pci(PCIDevice *pci_dev) { VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); VirtIODevice *vdev; vdev = virtio_console_init(&pci_dev->qdev); virtio_init_pci(proxy, vdev, PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_CONSOLE, PCI_CLASS_DISPLAY_OTHER, 0x00); }
1threat
static int vpc_create(const char *filename, QEMUOptionParameter *options) { uint8_t buf[1024]; struct vhd_footer* footer = (struct vhd_footer*) buf; struct vhd_dyndisk_header* dyndisk_header = (struct vhd_dyndisk_header*) buf; int fd, i; uint16_t cyls; uint8_t heads; uint8_t secs_per_cyl; size_t block_size, num_bat_entries; int64_t total_sectors = 0; while (options && options->name) { if (!strcmp(options->name, "size")) { total_sectors = options->value.n / 512; } options++; } fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) return -EIO; if (calculate_geometry(total_sectors, &cyls, &heads, &secs_per_cyl)) return -EFBIG; total_sectors = (int64_t) cyls * heads * secs_per_cyl; memset(buf, 0, 1024); memcpy(footer->creator, "conectix", 8); memcpy(footer->creator_app, "qemu", 4); memcpy(footer->creator_os, "Wi2k", 4); footer->features = be32_to_cpu(0x02); footer->version = be32_to_cpu(0x00010000); footer->data_offset = be64_to_cpu(HEADER_SIZE); footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE); footer->major = be16_to_cpu(0x0005); footer->minor =be16_to_cpu(0x0003); footer->orig_size = be64_to_cpu(total_sectors * 512); footer->size = be64_to_cpu(total_sectors * 512); footer->cyls = be16_to_cpu(cyls); footer->heads = heads; footer->secs_per_cyl = secs_per_cyl; footer->type = be32_to_cpu(VHD_DYNAMIC); footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE)); block_size = 0x200000; num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512); if (write(fd, buf, HEADER_SIZE) != HEADER_SIZE) return -EIO; if (lseek(fd, 1536 + ((num_bat_entries * 4 + 511) & ~511), SEEK_SET) < 0) return -EIO; if (write(fd, buf, HEADER_SIZE) != HEADER_SIZE) return -EIO; if (lseek(fd, 3 * 512, SEEK_SET) < 0) return -EIO; memset(buf, 0xFF, 512); for (i = 0; i < (num_bat_entries * 4 + 511) / 512; i++) if (write(fd, buf, 512) != 512) return -EIO; memset(buf, 0, 1024); memcpy(dyndisk_header->magic, "cxsparse", 8); dyndisk_header->data_offset = be64_to_cpu(0xFFFFFFFF); dyndisk_header->table_offset = be64_to_cpu(3 * 512); dyndisk_header->version = be32_to_cpu(0x00010000); dyndisk_header->block_size = be32_to_cpu(block_size); dyndisk_header->max_table_entries = be32_to_cpu(num_bat_entries); dyndisk_header->checksum = be32_to_cpu(vpc_checksum(buf, 1024)); if (lseek(fd, 512, SEEK_SET) < 0) return -EIO; if (write(fd, buf, 1024) != 1024) return -EIO; close(fd); return 0; }
1threat
A system to convert html page to a prettier one as a web service : <p>As the title is too vague to understand, let me explain.</p> <p>This is a webpage of petal laws in Japan.<br> <a href="http://law.e-gov.go.jp/htmldata/M40/M40HO045.html" rel="nofollow">http://law.e-gov.go.jp/htmldata/M40/M40HO045.html</a></p> <p>This look gray, drab and not interesting, right? So I'd like to set up a web service to do a little job to convert this to "better" looking one. More colors, more indentations and even a feature that a user hovers the cursor over a word and sees a pop up saying the definition of the word. But the issue is, I don't know much about technology to achieve this goal.</p> <ol> <li>Is there a technology to achieve this.</li> <li>If any, what is it called?</li> </ol> <p>Any help would be appreciated. Thanks.</p>
0debug
How to check if a range in a list is the same in python? : I want to check if a certain range in a list is the same. For example: In a list I have X,Y,X,X,X,Y,Y, i want to see if the third, fourth and fifth are the same. I have tried the following: list = ['X', 'Y', 'X', 'X', 'X', 'Y'] for i in list, range(2,4): if not i == 'X': print("Test") It does work but prints Test twice. Test Test I just don't want to write a bunch of this: if ... and .... and ..... and ... or .... and ...
0debug
How to extract string between double quotes in java? : <p>I'm reading a response from a source which is an journal or an essay and I have the html response as a string like:</p> <p>According to some, dreams express "profound aspects of personality" (Foulkes 184), though "others disagree" but truth is.</p> <p>My goal is just to extract all of the quotes out of the given string and save each of them into a list. And add space in original string in place of quotes. </p>
0debug
Stack Implementations in C : <p>I’m stuck trying to figure out what, exactly, are the definitions of the following stack implementations and the advantages and disadvantages associated with each.</p> <pre><code>1.Array-based implementation 2.Linked implementation 3.Blocked implementation </code></pre> <p>Any help would be much appreciated.</p>
0debug
Typescript: Spread types may only be created from object types : <pre><code>function foo&lt;T extends object&gt;(t: T): T { return { ...t // Error: [ts] Spread types may only be created from object types. } } </code></pre> <p>I am aware that there are issues on github, but I can't figure out what is fixed and what is not and they have 2695 open issues. So I am posting here. I am using latest Typescript 2.9.2. </p> <p>Should the above code not work? And how can I fix it if possible?</p>
0debug
Prevent scrolling using CSS on React rendered components : <p>So I render a component via React within my <code>html</code> like so:</p> <pre><code> &lt;html&gt; &lt;body&gt; &lt;div id=app&gt;${appHtml}&lt;/div&gt; &lt;script src="/bundle.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Within my app I have a burger button, that <code>onClick</code> goes full screen.</p> <p>However, the body is scrollable. I'd normally add a class to the <code>body</code> tag and make it <code>overflow: hidden</code> to prevent this. However, my react component is rendered within the <code>body</code> tag so I have no control over toggling classes based on a click within a react component.</p> <p>Has anyone got any ideas/advice on how i'd achieve what i'm looking for.</p> <p>Thanks!</p>
0debug
how to count only specific row's column value in R : i have to count total_buy/total sell of only column "A to D"...... it should not contain column "E to H" [enter image description here][1] [1]: https://i.stack.imgur.com/fK27r.png
0debug
I am working with an app which,I have another team member : <p>I am developing an ios, app,it is in swift language.I have another team member.The app has many pages which we decided to program seprately.How can I integrate both of our pages in our app?Kindly help.</p>
0debug
alert('Hello ' + user_input);
1threat
AngularJS select : > <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <body> <div ng-app="myApp" ng-app="myFruitsApp" ng-controller="myCtrl"> <p>Select a car:</p> <select ng-model="selectedCar" ng-options="x.model for x in cars"> </select> <select ng-model="selectedFruit" ng-options="y.type for y in fruits"> </select> <h1>You selected: {{selectedCar.model}}</h1> <h1>fruits:: {{selectedFruit.type}}</h1> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.cars = [ {model : "Ford Mustang"}, {model : "Fiat 500"}, {model : "Volvo XC90"} ]; }); </script> <script> var app2 = angular.module('myFruitsApp',[]); app2.controller('myCtrla', function($scope){ $scope.fruits = [ {type: "apple"}, {type: "oranges"}, {type: "pear"} ]; }); </script> </body> <!-- end snippet --> > Hello. I am trying to more than one select in one div. But first select getting own list and can show up but second and other cannot. I couldnt manage that. I added script link.
0debug
static void qmp_output_free(Visitor *v) { QmpOutputVisitor *qov = to_qov(v); QStackEntry *e; while (!QSLIST_EMPTY(&qov->stack)) { e = QSLIST_FIRST(&qov->stack); QSLIST_REMOVE_HEAD(&qov->stack, node); g_free(e); } qobject_decref(qov->root); g_free(qov); }
1threat
In React Router, how do you pass route parameters when using browser history push? : <p>Using the newer version of React Router, how do you pass parameters to the route you are transitioning to if you are transitioning using the browserHistory.push()? I am open to using some other way to transitioning if browserHistory does not allow this. I see that in my top most child component in React Router there is this.props.routeParams but I can't seem to get this populated with values I want from the previous route when transitioning.</p>
0debug
how to fix Thread 1: EXC_BAD_ACCESS (code=1, address=0x58) xcode : I am trying to play some sound files with buttons but pressing the button throws me this error Thread 1: EXC_BAD_ACCESS (code=1, address=0x58) on line audioPlayer.play() I have looked for possible solutions and I can't find anything related to that error, the function of my code runs well until the print, this is my complete code. import UIKit import AVFoundation class ViewController: UIViewController { var track: String? = nil var audioPlayer = AVAudioPlayer() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } @IBAction func heavyButton(_ sender: Any) { track = "H" print("heavy machine gun \(track!)") reproducirAudio(audio: track!) audioPlayer.play() } func reproducirAudio(audio: String) { do { print("entro a la funcion de reproducir") audioPlayer = try AVAudioPlayer(contentsOf: URL.init(fileURLWithPath: Bundle.main.path(forResource: audio, ofType: "mp3")!)) audioPlayer.prepareToPlay() } catch { print(error) } }
0debug
int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, uint8_t* buf, int buf_size, int64_t pos) { int size, i; uint8_t *ppcm[4] = {0}; if (buf_size < DV_PROFILE_BYTES || !(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) || buf_size < c->sys->frame_size) { return -1; } size = dv_extract_audio_info(c, buf); for (i = 0; i < c->ach; i++) { c->audio_pkt[i].pos = pos; c->audio_pkt[i].size = size; c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate; ppcm[i] = c->audio_buf[i]; } dv_extract_audio(buf, ppcm, c->sys); if (c->sys->height == 720) { if (buf[1] & 0x0C) { c->audio_pkt[2].size = c->audio_pkt[3].size = 0; } else { c->audio_pkt[0].size = c->audio_pkt[1].size = 0; c->abytes += size; } } else { c->abytes += size; } size = dv_extract_video_info(c, buf); av_init_packet(pkt); pkt->data = buf; pkt->pos = pos; pkt->size = size; pkt->flags |= AV_PKT_FLAG_KEY; pkt->stream_index = c->vst->id; pkt->pts = c->frames; c->frames++; return size; }
1threat
How to reference a class object? javascript : Assume the following class: class Player{ constructor(id,name){ this.id=id; this.name=name; } } If I would like to instantiate the class I would go about `var player = new Player(1,'Mike')` and then I could access the values with dot notation such as `player.name`. I'm trying to use an iteration to generate several players and add them into an array and part of the code is: let player =[]; player.push( playerName = new Player(id,playerName); If insert a var infront of playerName i.e. `player.push( playerName = new Player(id,playerName);` it throws an error. Currently the only way to access the name would be `player[0].name` which is not convenient. How else could I make the code so as to create an Object variable as in the example above?
0debug
Angular2: unable to navigate to url using location.go(url) : <p>I am trying to navigate to a specific url using location.go service from typescript function. It changes the url in the browser but the component of the url is not reflected in the screen. It stays on the login (actual) screen - say for eg:</p> <pre><code>constructor(location: Location, public _userdetails: userdetails){ this.location = location; } login(){ if (this.username &amp;&amp; this.password){ this._userdetails.username = this.username; this.location.go('/home'); } else{ console.log('Cannot be blank'); } } </code></pre> <p>Is there a compile method or a refresh method I am missing?</p>
0debug
joining strings in a table according to values in another column : <p>I got a table like this:</p> <pre><code>id words 1 I like school. 2 I hate school. 3 I like cakes. 1 I like cats. </code></pre> <p>Here's what I want to do, joining the strings in each row according to id. </p> <pre><code>id words 1 I like school. I like cats. 2 I hate school. 3 I like cakes. </code></pre> <p>Is there a package to do that in R?</p>
0debug
Angular.js(SPA) loading times : I have a website that is built with Angular.js. I’m having issues with a slow loading time (obviously) especially from users in countries that have slow internet connections. Even for some users the page is not loaded at all. How can I improve initial loading times?
0debug
static int dnxhd_decode_row(AVCodecContext *avctx, void *data, int rownb, int threadnb) { const DNXHDContext *ctx = avctx->priv_data; uint32_t offset = ctx->mb_scan_index[rownb]; RowContext *row = ctx->rows + threadnb; int x; row->last_dc[0] = row->last_dc[1] = row->last_dc[2] = 1 << (ctx->bit_depth + 2); init_get_bits(&row->gb, ctx->buf + offset, (ctx->buf_size - offset) << 3); for (x = 0; x < ctx->mb_width; x++) { dnxhd_decode_macroblock(ctx, row, data, x, rownb); } return 0; }
1threat
Closing PHP tags after exit or die functions : <p>Should I close PHP tags after <code>die</code> or <code>exit</code> functions or it is not necessary?</p>
0debug
How to recreate native iOS UI label with border in SWIFT? : As a beginner in SWIFT dev, I have a challenge replicating basic UI elements in Xcode. I am not aware how to replicate elements from [this picture][1]. The action that needs to happen is: when clicking on "On site", new View Controller is opened. I have assumed that "On Site" is a UIButton sitting on UIView White Rectangle with Grey Border on Top and Bottom. Is there a different/better way of doing this? [1]: https://i.stack.imgur.com/EkrZx.png
0debug
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum PixelFormat pix_fmt, int width, int height) { const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; if (desc->flags & PIX_FMT_HWACCEL) return; if (desc->flags & PIX_FMT_PAL) { av_image_copy_plane(dst_data[0], dst_linesizes[0], src_data[0], src_linesizes[0], width, height); memcpy(dst_data[1], src_data[1], 4*256); } else { int i, planes_nb = 0; for (i = 0; i < desc->nb_components; i++) planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1); for (i = 0; i < planes_nb; i++) { int h = height; int bwidth = av_image_get_linesize(pix_fmt, width, i); if (i == 1 || i == 2) { h= -((-height)>>desc->log2_chroma_h); } av_image_copy_plane(dst_data[i], dst_linesizes[i], src_data[i], src_linesizes[i], bwidth, h); } } }
1threat
static void test_machine(const void *data) { const testdef_t *test = data; char *args; char tmpname[] = "/tmp/qtest-boot-serial-XXXXXX"; int fd; fd = mkstemp(tmpname); g_assert(fd != -1); args = g_strdup_printf("-M %s,accel=tcg -chardev file,id=serial0,path=%s" " -serial chardev:serial0 %s", test->machine, tmpname, test->extra); qtest_start(args); unlink(tmpname); check_guest_output(test, fd); qtest_quit(global_qtest); g_free(args); close(fd); }
1threat
chrome webdriver for selenium results in 4 errors : [![enter image description here][1]][1] I'm doing exactly what the website says but it results in 4 errors... [1]: https://i.stack.imgur.com/0thoj.jpg
0debug
alert('Hello ' + user_input);
1threat
static int vdadec_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { VDADecoderContext *ctx = avctx->priv_data; AVFrame *pic = data; int ret; ret = ff_h264_decoder.decode(avctx, data, got_frame, avpkt); if (*got_frame) { AVBufferRef *buffer = pic->buf[0]; VDABufferContext *context = av_buffer_get_opaque(buffer); CVPixelBufferRef cv_buffer = (CVPixelBufferRef)pic->data[3]; CVPixelBufferLockBaseAddress(cv_buffer, 0); context->cv_buffer = cv_buffer; pic->format = ctx->pix_fmt; if (CVPixelBufferIsPlanar(cv_buffer)) { int i, count = CVPixelBufferGetPlaneCount(cv_buffer); av_assert0(count < 4); for (i = 0; i < count; i++) { pic->data[i] = CVPixelBufferGetBaseAddressOfPlane(cv_buffer, i); pic->linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(cv_buffer, i); } } else { pic->data[0] = CVPixelBufferGetBaseAddress(cv_buffer); pic->linesize[0] = CVPixelBufferGetBytesPerRow(cv_buffer); } } avctx->pix_fmt = ctx->pix_fmt; return ret; }
1threat
RefPicList *ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *ref, int x0, int y0) { if (x0 < 0 || y0 < 0) { return s->ref->refPicList; } else { int x_cb = x0 >> s->sps->log2_ctb_size; int y_cb = y0 >> s->sps->log2_ctb_size; int pic_width_cb = (s->sps->width + (1 << s->sps->log2_ctb_size) - 1) >> s->sps->log2_ctb_size; int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[y_cb * pic_width_cb + x_cb]; return (RefPicList *)ref->rpl_tab[ctb_addr_ts]; } }
1threat
No podspec found for `React-fishhook` : <p>When I upgrade react-native version 0.60.4 to 0.60.5, I find this error message after I try to <code>pod install</code> my iOS project. And I can not find any file under <code>node_models/react-native/Libraries/React-fishhook</code>, how should install it?</p>
0debug
static int dds_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { DDSContext *ctx = avctx->priv_data; GetByteContext *gbc = &ctx->gbc; AVFrame *frame = data; int mipmap; int ret; ff_texturedsp_init(&ctx->texdsp); bytestream2_init(gbc, avpkt->data, avpkt->size); if (bytestream2_get_bytes_left(gbc) < 128) { av_log(avctx, AV_LOG_ERROR, "Frame is too small (%d).\n", bytestream2_get_bytes_left(gbc)); return AVERROR_INVALIDDATA; } if (bytestream2_get_le32(gbc) != MKTAG('D', 'D', 'S', ' ') || bytestream2_get_le32(gbc) != 124) { av_log(avctx, AV_LOG_ERROR, "Invalid DDS header.\n"); return AVERROR_INVALIDDATA; } bytestream2_skip(gbc, 4); avctx->height = bytestream2_get_le32(gbc); avctx->width = bytestream2_get_le32(gbc); ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid image size %dx%d.\n", avctx->width, avctx->height); return ret; } avctx->coded_width = FFALIGN(avctx->width, TEXTURE_BLOCK_W); avctx->coded_height = FFALIGN(avctx->height, TEXTURE_BLOCK_H); bytestream2_skip(gbc, 4); bytestream2_skip(gbc, 4); mipmap = bytestream2_get_le32(gbc); if (mipmap != 0) av_log(avctx, AV_LOG_VERBOSE, "Found %d mipmaps (ignored).\n", mipmap); ret = parse_pixel_format(avctx); if (ret < 0) return ret; ret = ff_get_buffer(avctx, frame, 0); if (ret < 0) return ret; if (ctx->compressed) { int size = (avctx->coded_height / TEXTURE_BLOCK_H) * (avctx->coded_width / TEXTURE_BLOCK_W) * ctx->tex_ratio; ctx->slice_count = av_clip(avctx->thread_count, 1, avctx->coded_height / TEXTURE_BLOCK_H); if (bytestream2_get_bytes_left(gbc) < size) { av_log(avctx, AV_LOG_ERROR, "Compressed Buffer is too small (%d < %d).\n", bytestream2_get_bytes_left(gbc), size); return AVERROR_INVALIDDATA; } ctx->tex_data = gbc->buffer; avctx->execute2(avctx, decompress_texture_thread, frame, NULL, ctx->slice_count); } else if (!ctx->paletted && ctx->bpp == 4 && avctx->pix_fmt == AV_PIX_FMT_PAL8) { uint8_t *dst = frame->data[0]; int x, y, i; bytestream2_get_buffer(gbc, frame->data[1], 16 * 4); for (i = 0; i < 16; i++) { AV_WN32(frame->data[1] + i*4, (frame->data[1][2+i*4]<<0)+ (frame->data[1][1+i*4]<<8)+ (frame->data[1][0+i*4]<<16)+ (frame->data[1][3+i*4]<<24) ); } frame->palette_has_changed = 1; if (bytestream2_get_bytes_left(gbc) < frame->height * frame->width / 2) { av_log(avctx, AV_LOG_ERROR, "Buffer is too small (%d < %d).\n", bytestream2_get_bytes_left(gbc), frame->height * frame->width / 2); return AVERROR_INVALIDDATA; } for (y = 0; y < frame->height; y++) { for (x = 0; x < frame->width; x += 2) { uint8_t val = bytestream2_get_byte(gbc); dst[x ] = val & 0xF; dst[x + 1] = val >> 4; } dst += frame->linesize[0]; } } else { int linesize = av_image_get_linesize(avctx->pix_fmt, frame->width, 0); if (ctx->paletted) { int i; bytestream2_get_buffer(gbc, frame->data[1], 256 * 4); for (i = 0; i < 256; i++) AV_WN32(frame->data[1] + i*4, (frame->data[1][2+i*4]<<0)+ (frame->data[1][1+i*4]<<8)+ (frame->data[1][0+i*4]<<16)+ (frame->data[1][3+i*4]<<24) ); frame->palette_has_changed = 1; } if (bytestream2_get_bytes_left(gbc) < frame->height * linesize) { av_log(avctx, AV_LOG_ERROR, "Buffer is too small (%d < %d).\n", bytestream2_get_bytes_left(gbc), frame->height * linesize); return AVERROR_INVALIDDATA; } av_image_copy_plane(frame->data[0], frame->linesize[0], gbc->buffer, linesize, linesize, frame->height); } if (ctx->postproc != DDS_NONE) run_postproc(avctx, frame); frame->pict_type = AV_PICTURE_TYPE_I; frame->key_frame = 1; *got_frame = 1; return avpkt->size; }
1threat
Is it possible to have conditional property in ARM template : <p>I understand there is option to have conditional output for property values, but is it possible to have conditional property itself. For example I have template which creates <code>Microsoft.Compute/VirtualMachine</code> and it's the same template for both Windows and Linux. But for windows I need to specify property which do not exist for Linux (<code>"licenseType": "Windows_Server")</code>. Presense of this property will fail deployment with error <code>The property 'LicenseType' cannot be used together with property 'linuxConfiguration'</code></p> <p>I'm trying to figure out if it's possible to have this property included only for Windows images while keeping template the same?</p>
0debug
static void bochs_refresh_limits(BlockDriverState *bs, Error **errp) { bs->request_alignment = BDRV_SECTOR_SIZE; }
1threat
static int add_string_metadata(int count, const char *name, TiffContext *s) { char *value; if (bytestream2_get_bytes_left(&s->gb) < count) return AVERROR_INVALIDDATA; value = av_malloc(count + 1); if (!value) return AVERROR(ENOMEM); bytestream2_get_bufferu(&s->gb, value, count); value[count] = 0; av_dict_set(&s->picture.metadata, name, value, AV_DICT_DONT_STRDUP_VAL); return 0; }
1threat
Converting INT8...INT64, UINT8...UINT64 ,float, double, into WCHAR* : <p>I am using C/C++, are there any windows functions ,or any very fast ways to convert from any of types in Title to const WCHAR* ?</p> <p>So I have big case where I check my data what type it is, after it goes into some branch where I need to convert that data to WCHAR*.</p> <p>So for exmaple if i have 21, i want it to be L"21". 32.322 => L"32.322" etc.</p> <p>I could do it manually but I would prefer it if there is some faster way! These conversions seem that happen a lot on some lower level.</p> <p>Thanks!</p>
0debug
PHP SQL Select fast 10 rows from 60.000 rows : How can I force with PHP a SQL query, to skip reading 60.000 rows! I need to select just 10 first rows and it takes lifetime! $FirstRowsQuery = "SELECT * FROM `tbl_premium_articles` ORDER BY `id_p` DESC LIMIT 10"; Is there any way to bring it query in one second?
0debug
jquery doesn't find particular element in ng-repeat : <p>Starting with the following html code</p> <pre><code>&lt;div ng-repeat="item in list"&gt; &lt;input type="text" class="texter"&gt; &lt;/div&gt; </code></pre> <p>I use jquery to listen on keypress on any input listed.</p> <pre><code>$('.texter').keypress(function(e){ console.log(this); } </code></pre> <p>but nothing happens. Even with</p> <pre><code>$('input').keypress(function(e){ console.log(this); } </code></pre> <p>Basically, I want to get the element where keypress event is fired.</p> <p>Is there a way to get it with jquery?</p> <p>Note that I already searched for an answer before asking but none seems to do what I'm expecting.</p>
0debug
static void gem_transmit(CadenceGEMState *s) { unsigned desc[2]; hwaddr packet_desc_addr; uint8_t tx_packet[2048]; uint8_t *p; unsigned total_bytes; if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_TXENA)) { return; DB_PRINT("\n"); p = tx_packet; total_bytes = 0; packet_desc_addr = s->tx_desc_addr; DB_PRINT("read descriptor 0x%" HWADDR_PRIx "\n", packet_desc_addr); cpu_physical_memory_read(packet_desc_addr, (uint8_t *)desc, sizeof(desc)); while (tx_desc_get_used(desc) == 0) { if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_TXENA)) { return; print_gem_tx_desc(desc); if ((tx_desc_get_buffer(desc) == 0) || (tx_desc_get_length(desc) == 0)) { DB_PRINT("Invalid TX descriptor @ 0x%x\n", (unsigned)packet_desc_addr); cpu_physical_memory_read(tx_desc_get_buffer(desc), p, tx_desc_get_length(desc)); p += tx_desc_get_length(desc); total_bytes += tx_desc_get_length(desc); if (tx_desc_get_last(desc)) { unsigned desc_first[2]; cpu_physical_memory_read(s->tx_desc_addr, (uint8_t *)desc_first, sizeof(desc_first)); tx_desc_set_used(desc_first); cpu_physical_memory_write(s->tx_desc_addr, (uint8_t *)desc_first, sizeof(desc_first)); if (tx_desc_get_wrap(desc)) { s->tx_desc_addr = s->regs[GEM_TXQBASE]; } else { s->tx_desc_addr = packet_desc_addr + 8; DB_PRINT("TX descriptor next: 0x%08x\n", s->tx_desc_addr); s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_TXCMPL; s->regs[GEM_ISR] |= GEM_INT_TXCMPL & ~(s->regs[GEM_IMR]); gem_update_int_status(s); if (s->regs[GEM_DMACFG] & GEM_DMACFG_TXCSUM_OFFL) { net_checksum_calculate(tx_packet, total_bytes); gem_transmit_updatestats(s, tx_packet, total_bytes); if (s->phy_loop || (s->regs[GEM_NWCTRL] & GEM_NWCTRL_LOCALLOOP)) { gem_receive(qemu_get_queue(s->nic), tx_packet, total_bytes); } else { qemu_send_packet(qemu_get_queue(s->nic), tx_packet, total_bytes); p = tx_packet; total_bytes = 0; if (tx_desc_get_wrap(desc)) { packet_desc_addr = s->regs[GEM_TXQBASE]; } else { packet_desc_addr += 8; DB_PRINT("read descriptor 0x%" HWADDR_PRIx "\n", packet_desc_addr); cpu_physical_memory_read(packet_desc_addr, (uint8_t *)desc, sizeof(desc)); if (tx_desc_get_used(desc)) { s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_USED; s->regs[GEM_ISR] |= GEM_INT_TXUSED & ~(s->regs[GEM_IMR]); gem_update_int_status(s);
1threat
Prevent duplicate entry into vector? C++ : <p>I have a program that prompts a user to enter a value. Each value that the user enters gets placed into a vector 'other' which is there only for validation. If a duplicate value has been entered, the user will get a prompt until they enter a unique value. </p> <p>The main problem I am facing is that for some reason when running the code and printing out the results of the vector, there appears to be a duplicate entry. Could anyone please tell me why that is? </p> <p>See below for my code:</p> <pre><code>// prompt to continue cout &lt;&lt; "Would you like to continue? [Y]es, [N]o: "; cin &gt;&gt; toContinue; while (toContinue == 'Y') { bool isDuplicate = 0; // prompt for product no. cout &lt;&lt; "Please enter product number: "; cin &gt;&gt; productB; // Validation check for duplicate entries for (size_t i = 0; i &lt; other.size(); i++) { if (productB == other[i]) isDuplicate = 1; while (isDuplicate == 1) { cout &lt;&lt; "You have already entered this product number!" &lt;&lt; endl; cout &lt;&lt; "Please enter correct product number: "; cin &gt;&gt; productB; if (productB != other[i]) other.push_back(productB); isDuplicate = 0; } } // prompt to continue cout &lt;&lt; "Would you like to continue? [Y]es, [N]o: "; cin &gt;&gt; toContinue; } </code></pre>
0debug
static void tap_set_sndbuf(TAPState *s, int sndbuf, Monitor *mon) { #ifdef TUNSETSNDBUF if (ioctl(s->fd, TUNSETSNDBUF, &sndbuf) == -1) { config_error(mon, "TUNSETSNDBUF ioctl failed: %s\n", strerror(errno)); } #else config_error(mon, "No '-net tap,sndbuf=<nbytes>' support available\n"); #endif }
1threat
my navigation bar when I include it appears above : <p>my navigation bar when I include it appears above.</p> <p><a href="https://i.stack.imgur.com/4CoAU.png" rel="nofollow noreferrer">my navigation bar in separate file</a></p> <p><a href="https://i.stack.imgur.com/4giKH.png" rel="nofollow noreferrer">my navigation bar where I want to include</a></p>
0debug
y_pred = regressor.predict(6.5) not working : """ whenever I am going to predict, I saw an error. I am stuck with the line "y_pred = regressor.predict(6.5)" in the code. I am getting the error: "ValueError: Expected 2D array, got scalar array instead: array=6.5. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample." """ Any help would be appreciated. Thank you. spyder # SVR # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Position_Salaries.csv') X = dataset.iloc[:, 1:2].values y = dataset.iloc[:, 2].values # Feature Scaling from sklearn.preprocessing import StandardScaler sc_X = StandardScaler() sc_y = StandardScaler() X = sc_X.fit_transform(X) y = sc_y.fit_transform(y) # Fitting SVR to the dataset from sklearn.svm import SVR regressor = SVR(kernel = 'rbf') regressor.fit(X, y) # Predicting a new result y_pred = regressor.predict(6.5) """ y_pred = regressor.predict(6.5) Traceback (most recent call last): File "<ipython-input-10-5865c008a8c9>", line 1, in <module> y_pred = regressor.predict(6.5) File "C:\Users\achiever\Anaconda3\lib\site-packages\sklearn\svm\base.py", line 322, in predict X = self._validate_for_predict(X) File "C:\Users\achiever\Anaconda3\lib\site-packages\sklearn\svm\base.py", line 454, in _validate_for_predict accept_large_sparse=False) File "C:\Users\achiever\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 514, in check_array "if it contains a single sample.".format(array)) ValueError: Expected 2D array, got scalar array instead: array=6.5. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample."""
0debug
SQL Server Data cleaning : <p>please I want your help I will start working on data mining project using sql server for database. I have big database and before I start working on my project for sure I need to do data cleaning on my database, so please I want your suggestions what I need to do, like removing duplicate, and removing spaces from some columns ? what else and what I need to do to be sure that my data are ready to start working on it with data mining process like clustering and decisions tree ...... </p> <ul> <li>Also please if you have any useful videos for Data mining in general using SQL Server Management studio - sql server cleaning data</li> </ul> <p>Thanks a lot in Advance...</p>
0debug
How to write ResponseEntity to HttpServletResponse? : <p>How to write ResponseEntity to HttpServletResponse (as it makes @ResponseBody)?</p> <p>For example I have authentication success handler:</p> <pre><code>@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { Map responseMap = new HashMap(); responseMap.put("user", "my_user_name"); ResponseEntity responseEntity = new ResponseEntity(response, HttpStatus.OK); } </code></pre> <p>If use MappingJackson2HttpMessageConverter I have error: "Could not write content: not in non blocking mode."</p> <p>Code:</p> <pre><code>HttpOutputMessage outputMessage = new ServletServerHttpResponse(response); messageConverter.write(responseEntity, null, outputMessage); </code></pre> <p>What are the best practices of implementation handlers with HttpServletResponse?</p>
0debug
Convert array in string format to an array : <p>I have the following string : </p> <pre><code>"[[0, 0, 0], [1, 1, 1], [2, 2, 2]]" </code></pre> <p>What is the easiest way in Java to convert this to a pure multidimensional float array? Somthing like this for example:</p> <pre><code>String stringArray = "[[0, 0, 0], [1, 1, 1], [2, 2, 2]]"; float[][] floatArray = stringArray.parseSomeHow() //here I don't know the best way to convert </code></pre> <p>Sure I could write an algorithm that would read for example each char or so. But maybe there is a simpler and faster way that java already provides.</p>
0debug
Cannot open socket when incoming call in Android : I try to send data to server when incoming call through mobile data (4G). I get one of these errors: java.net.UnknownHostException: Host is unresolved: xyz.xy or java.net.SocketTimeoutException: failed to connect to /xxx.xxx.xxx.xxx (port yyyyyy) after 15000ms When is WIFI on, data is sending during incoming call. Here is part of code: Socket socket = new Socket(); DataOutputStream dos; DataInputStream dis; try { socket.connect(new InetSocketAddress(SERVER_IP, SERVER_PORT), CONNECTION_TIMEOUT); socket.setTcpNoDelay(true); socket.setSoTimeout(READ_TIMEOUT); dos = new DataOutputStream(socket.getOutputStream()); dis = new DataInputStream(socket.getInputStream()); int count = text.getBytes("UTF-8").length; ByteBuffer data = ByteBuffer.allocate(count); data.put(text.getBytes("UTF-8")); dos.write(data.array(), 0, data.array().length); Is a problem send data through mobile data (4G) when incomming call? Or I am missing any settings?
0debug
static int vc1_decode_p_mb_intfi(VC1Context *v) { MpegEncContext *s = &v->s; GetBitContext *gb = &s->gb; int i; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; int cbp = 0; int mqdiff, mquant; int ttmb = v->ttfrm; int mb_has_coeffs = 1; int dmv_x, dmv_y; int val; int first_block = 1; int dst_idx, off; int pred_flag = 0; int block_cbp = 0, pat, block_tt = 0; int idx_mbmode = 0; mquant = v->pq; idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_IF_MBMODE_VLC_BITS, 2); if (idx_mbmode <= 1) { v->is_intra[s->mb_x] = 0x3f; s->mb_intra = 1; s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0; s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0; s->current_picture.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA; GET_MQUANT(); s->current_picture.qscale_table[mb_pos] = mquant; s->y_dc_scale = s->y_dc_scale_table[mquant]; s->c_dc_scale = s->c_dc_scale_table[mquant]; v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); mb_has_coeffs = idx_mbmode & 1; if (mb_has_coeffs) cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2); dst_idx = 0; for (i = 0; i < 6; i++) { v->a_avail = v->c_avail = 0; v->mb_type[0][s->block_index[i]] = 1; s->dc_val[0][s->block_index[i]] = 0; dst_idx += i >> 2; val = ((cbp >> (5 - i)) & 1); if (i == 2 || i == 3 || !s->first_slice_line) v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; if (i == 1 || i == 3 || s->mb_x) v->c_avail = v->mb_type[0][s->block_index[i] - 1]; vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i & 4) ? v->codingset2 : v->codingset); if ((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); s->idsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize); } } else { s->mb_intra = v->is_intra[s->mb_x] = 0; s->current_picture.mb_type[mb_pos + v->mb_off] = MB_TYPE_16x16; for (i = 0; i < 6; i++) v->mb_type[0][s->block_index[i]] = 0; if (idx_mbmode <= 5) { dmv_x = dmv_y = pred_flag = 0; if (idx_mbmode & 1) { get_mvdata_interlaced(v, &dmv_x, &dmv_y, &pred_flag); } ff_vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], pred_flag, 0); ff_vc1_mc_1mv(v, 0); mb_has_coeffs = !(idx_mbmode & 2); } else { v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1); for (i = 0; i < 6; i++) { if (i < 4) { dmv_x = dmv_y = pred_flag = 0; val = ((v->fourmvbp >> (3 - i)) & 1); if (val) { get_mvdata_interlaced(v, &dmv_x, &dmv_y, &pred_flag); } ff_vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0], pred_flag, 0); ff_vc1_mc_4mv_luma(v, i, 0, 0); } else if (i == 4) ff_vc1_mc_4mv_chroma(v, 0); } mb_has_coeffs = idx_mbmode & 1; } if (mb_has_coeffs) cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); if (cbp) { GET_MQUANT(); } s->current_picture.qscale_table[mb_pos] = mquant; if (!v->ttmbf && cbp) { ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); } dst_idx = 0; for (i = 0; i < 6; i++) { s->dc_val[0][s->block_index[i]] = 0; dst_idx += i >> 2; val = ((cbp >> (5 - i)) & 1); off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize; if (val) { pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize, (i & 4) && (s->flags & CODEC_FLAG_GRAY), &block_tt); block_cbp |= pat << (i << 2); if (!v->ttmbf && ttmb < 8) ttmb = -1; first_block = 0; } } } if (s->mb_x == s->mb_width - 1) memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0]) * s->mb_stride); return 0; }
1threat
static void exit_program(void) { int i, j; for (i = 0; i < nb_filtergraphs; i++) { avfilter_graph_free(&filtergraphs[i]->graph); for (j = 0; j < filtergraphs[i]->nb_inputs; j++) { av_freep(&filtergraphs[i]->inputs[j]->name); av_freep(&filtergraphs[i]->inputs[j]); } av_freep(&filtergraphs[i]->inputs); for (j = 0; j < filtergraphs[i]->nb_outputs; j++) { av_freep(&filtergraphs[i]->outputs[j]->name); av_freep(&filtergraphs[i]->outputs[j]); } av_freep(&filtergraphs[i]->outputs); av_freep(&filtergraphs[i]->graph_desc); av_freep(&filtergraphs[i]); } av_freep(&filtergraphs); for (i = 0; i < nb_output_files; i++) { AVFormatContext *s = output_files[i]->ctx; if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb) avio_close(s->pb); avformat_free_context(s); av_dict_free(&output_files[i]->opts); av_freep(&output_files[i]); } for (i = 0; i < nb_output_streams; i++) { AVBitStreamFilterContext *bsfc = output_streams[i]->bitstream_filters; while (bsfc) { AVBitStreamFilterContext *next = bsfc->next; av_bitstream_filter_close(bsfc); bsfc = next; } output_streams[i]->bitstream_filters = NULL; avcodec_free_frame(&output_streams[i]->filtered_frame); av_freep(&output_streams[i]->forced_keyframes); av_freep(&output_streams[i]->avfilter); av_freep(&output_streams[i]->logfile_prefix); av_freep(&output_streams[i]); } for (i = 0; i < nb_input_files; i++) { avformat_close_input(&input_files[i]->ctx); av_freep(&input_files[i]); } for (i = 0; i < nb_input_streams; i++) { av_frame_free(&input_streams[i]->decoded_frame); av_frame_free(&input_streams[i]->filter_frame); av_dict_free(&input_streams[i]->opts); av_freep(&input_streams[i]->filters); av_freep(&input_streams[i]); } if (vstats_file) fclose(vstats_file); av_free(vstats_filename); av_freep(&input_streams); av_freep(&input_files); av_freep(&output_streams); av_freep(&output_files); uninit_opts(); avformat_network_deinit(); if (received_sigterm) { av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n", (int) received_sigterm); exit (255); } }
1threat
static MachineClass *machine_parse(const char *name) { MachineClass *mc = NULL; GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false); if (name) { mc = find_machine(name); } if (mc) { return mc; } if (name && !is_help_option(name)) { error_report("Unsupported machine type"); error_printf("Use -machine help to list supported machines!\n"); } else { printf("Supported machines are:\n"); machines = g_slist_sort(machines, machine_class_cmp); for (el = machines; el; el = el->next) { MachineClass *mc = el->data; if (mc->alias) { printf("%-20s %s (alias of %s)\n", mc->alias, mc->desc, mc->name); } printf("%-20s %s%s\n", mc->name, mc->desc, mc->is_default ? " (default)" : ""); } } exit(!name || !is_help_option(name)); }
1threat
static int xen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, uint16_t *val, uint16_t dev_value, uint16_t valid_mask) { XenPTRegInfo *reg = cfg_entry->reg; uint16_t writable_mask = 0; uint16_t throughable_mask = get_throughable_mask(s, reg, valid_mask); writable_mask = ~reg->ro_mask & valid_mask; cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask); if (*val & PCI_COMMAND_INTX_DISABLE) { throughable_mask |= PCI_COMMAND_INTX_DISABLE; } else { if (s->machine_irq) { throughable_mask |= PCI_COMMAND_INTX_DISABLE; } } *val = XEN_PT_MERGE_VALUE(*val, dev_value, throughable_mask); return 0; }
1threat
document.write('<script src="evil.js"></script>');
1threat
static void test_in_coroutine(void) { Coroutine *coroutine; g_assert(!qemu_in_coroutine()); coroutine = qemu_coroutine_create(verify_in_coroutine); qemu_coroutine_enter(coroutine, NULL); }
1threat
How to make a if-else Angular template with only ng-container? : <p>I would like to make an if-else statement in my angular template. I started with that :</p> <pre><code>&lt;ng-container *ngIf="contributeur.deb; else newDeb" &gt; [... HERE IS A RESULT 1] &lt;/ng-container&gt; &lt;ng-template #newDeb&gt; [... HERE IS A RESULT 2] &lt;/ng-template&gt; </code></pre> <p>And I tried to only use ng-container : </p> <pre><code>&lt;ng-container *ngIf="contributeur.deb; else newDeb" &gt; [... HERE IS A RESULT 1] &lt;/ng-container&gt; &lt;ng-container #newDeb&gt; [... HERE IS A RESULT 2] &lt;/ng-container &gt; </code></pre> <p>Unfortunately, this does not work. I have this error :</p> <pre><code>ERROR TypeError: templateRef.createEmbeddedView is not a function at ViewContainerRef_.createEmbeddedView (eval at &lt;anonymous&gt; (vendor.bundle.js:11), &lt;anonymous&gt;:10200:52) at NgIf._updateView (eval at &lt;anonymous&gt; (vendor.bundle.js:96), &lt;anonymous&gt;:2013:45) at NgIf.set [as ngIfElse] (eval at &lt;anonymous&gt; (vendor.bundle.js:96), &lt;anonymous&gt;:1988:18) at updateProp (eval at &lt;anonymous&gt; (vendor.bundle.js:11), &lt;anonymous&gt;:11172:37) at checkAndUpdateDirectiveInline (eval at &lt;anonymous&gt; (vendor.bundle.js:11), &lt;anonymous&gt;:10873:19) at checkAndUpdateNodeInline (eval at &lt;anonymous&gt; (vendor.bundle.js:11), &lt;anonymous&gt;:12290:17) at checkAndUpdateNode (eval at &lt;anonymous&gt; (vendor.bundle.js:11), &lt;anonymous&gt;:12258:16) at debugCheckAndUpdateNode (eval at &lt;anonymous&gt; (vendor.bundle.js:11), &lt;anonymous&gt;:12887:59) at debugCheckDirectivesFn (eval at &lt;anonymous&gt; (vendor.bundle.js:11), &lt;anonymous&gt;:12828:13) at Object.eval [as updateDirectives] (ActionsButtons.html:5) </code></pre> <p>Can anyone explain me what is going wrong in this code ?</p>
0debug
void do_subfzeo (void) { T1 = T0; T0 = ~T0 + xer_ca; if (likely(!((~T1 ^ (-1)) & ((~T1) ^ T0) & (1 << 31)))) { xer_ov = 0; } else { xer_ov = 1; xer_so = 1; } if (likely(T0 >= ~T1)) { xer_ca = 0; } else { xer_ca = 1; } }
1threat