problem
stringlengths
26
131k
labels
class label
2 classes
static int bt_hid_out(struct bt_hid_device_s *s) { USBPacket p; if (s->data_type == BT_DATA_OUTPUT) { p.pid = USB_TOKEN_OUT; p.devep = 1; p.data = s->dataout.buffer; p.len = s->dataout.len; s->dataout.len = s->usbdev->info->handle_data(s->usbdev, &p); return s->dataout.len; } if (s->data_type == BT_DATA_FEATURE) { p.devep = 0; } return -1; }
1threat
Conditional operators precedence in C : Do conditional operators have precedence in C (like && being executed after || or vice-versa) or do they execute from left to right? I usually use parentheses to make sure they execute correctly, but someone asked me about this and I was not sure. For example is $a || b && c == 2$ interpreted as $(((a || b) && c) == 2)$ or $(a ||( b && (c == 2)))$
0debug
How do I open developer tools on IOS simulator : <p>I am wanting to open <strong>developer tools</strong> on an IOS simulator</p> <p>I have taken the following steps, on a 2016 Macbook running <strong>macOS Sierra 10.12.1</strong> and don't know how to get any further:</p> <ul> <li>I have XCode installed</li> <li>I create a new playground </li> <li>Right click on the Xcode dock icon and click Open Developer Tool > Simulator</li> <li>I now have an IOS simulator running whichever device I need, in my case iPhone 6 running IOS 10.0</li> </ul> <p>Now I am wondering what steps do I take to debug, and inspect elements on a webpage as I would in Safari or Chrome developer tools?</p>
0debug
c++ loop its not end the program wont end : can u tell whats the mistake t runs ok but program wont end i a m new to programming please i need help i have posted the code any one v=can check and help me please and am using dev c++ for this and i dont know why its doing like this uuuuurgghhhhhh #include <iostream> using namespace std; main(){ char num; again: int usr; float area; cout <<"\nEnter 1 to calculate area of rectangle\n"; cout <<"Enter 2 to calculate area of trapezoid\n"; cout <<"\nEnter your choice: "; cin >> usr; if(usr==1) { double width, length; cout <<"Enter the width of rectangle: "; cin >> width; cout <<"Enter the length of rectangle: "; cin >> length; area=length*width; cout <<"The area of rectangle is: "<< area; } if (usr==2) { double base1, base2, height; cout <<"Enter the base 1 of trapezoid: "; cin >> base1; cout <<"Enter the base 2 of trapezoid: "; cin >> base2; cout <<"Enter the height of trapezoid: "; cin >> height; area= (((base1 + base2) /2)*height); cout <<"The area of trapezoid is: "<< area; } cout <<"\n\ndo you want to do another calculation?"; cin >> num;{ goto again; } if (num=='y') { goto again; } if(num=='n'){ exit (0);} }
0debug
Javascipt: How can I change the class of a div by clicking another div? : I want to make a div appear when clicking on another div. I was thinking of doing this by using JavaScript to change the class of a div when another div is clicked on. This is the HTML of the div I want to appear: <div id ="menutext1" class - "hidden"> </div> This is the HTML of the control div (the one to click on to make the above div appear): <div id ="menu1"> </div> This is the CSS: .hidden { display: none; } .unhidden { display: block; } I've looked everywhere and nothing seems to work for me! I don't have much experience with JavaScript or JQuery but can understand it. Thanks in advance :))
0debug
static int64_t load_kernel(void) { int64_t entry, kernel_high; long kernel_size, initrd_size, params_size; ram_addr_t initrd_offset; uint32_t *params_buf; int big_endian; #ifdef TARGET_WORDS_BIGENDIAN big_endian = 1; #else big_endian = 0; #endif kernel_size = load_elf(loaderparams.kernel_filename, cpu_mips_kseg0_to_phys, NULL, (uint64_t *)&entry, NULL, (uint64_t *)&kernel_high, big_endian, ELF_MACHINE, 1); if (kernel_size >= 0) { if ((entry & ~0x7fffffffULL) == 0x80000000) entry = (int32_t)entry; } else { fprintf(stderr, "qemu: could not load kernel '%s'\n", loaderparams.kernel_filename); exit(1); } initrd_size = 0; initrd_offset = 0; if (loaderparams.initrd_filename) { initrd_size = get_image_size (loaderparams.initrd_filename); if (initrd_size > 0) { initrd_offset = (kernel_high + ~INITRD_PAGE_MASK) & INITRD_PAGE_MASK; if (initrd_offset + initrd_size > ram_size) { fprintf(stderr, "qemu: memory too small for initial ram disk '%s'\n", loaderparams.initrd_filename); exit(1); } initrd_size = load_image_targphys(loaderparams.initrd_filename, initrd_offset, ram_size - initrd_offset); } if (initrd_size == (target_ulong) -1) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", loaderparams.initrd_filename); exit(1); } } params_size = 264; params_buf = g_malloc(params_size); params_buf[0] = tswap32(ram_size); params_buf[1] = tswap32(0x12345678); if (initrd_size > 0) { snprintf((char *)params_buf + 8, 256, "rd_start=0x%" PRIx64 " rd_size=%li %s", cpu_mips_phys_to_kseg0(NULL, initrd_offset), initrd_size, loaderparams.kernel_cmdline); } else { snprintf((char *)params_buf + 8, 256, "%s", loaderparams.kernel_cmdline); } rom_add_blob_fixed("params", params_buf, params_size, (16 << 20) - 264); return entry; }
1threat
what i am further to do..I got a Prime Numbers to be print ,non prime numbers are am not able to print. : Input:20 Output:0 is not a Prime 1 is not a prime 2 is a prime 3 is a prime 4 is not a prime 5 is a prime 20 is not a prime(upto number 20) public class Prime { public static void main(String[] args) { int number=20; int p; for(int i=2;i<number;i++) { p=0; for(int j=2;j<i;j++) { if(i%j==0) { p=1; } } if(p==0) { System.out.println(i+" "+"Is Prime"); } } } } In the above program I printed the prime numbers,How to print both prime and non prime numbers in it?Thanks in advance! check it from 0 is not a Prime, 1 is not a prime, 2 is a prime, 3 is a prime, 4 is not a prime, 5 is a prime, 7 is a prime, 8 is not a prime ,continues upto n given
0debug
Can someone please help me with this program? : Write a program that reads four integers and prints "two pairs" if the input consists of two matching pairs (in some order) and "not two pairs" So far I have written: public static void main(String[] args){ Scanner in = new Scanner(System.in); int n; int number1; int number2; int number3; int number4; System.out.println("Enter up to four numbers: "); n = s.nextInt();
0debug
qsort not working c program : <p>I am trying to sort an array of names via qsort.</p> <p>This is my code</p> <pre><code>#include&lt;stdio.h&gt; #include&lt;string.h&gt; #include&lt;stdlib.h&gt; int myCompare (const void * a, const void * b ) { return *(char*)a - *(char*)b; } int main(void) { int i; char fileArr[] = {"inputbv", "inputa","inputzef",}; int stringLen = sizeof(fileArr) / sizeof(char *); qsort(fileArr, stringLen, sizeof(char *), myCompare); for (i=0; i&lt;stringLen; ++i) printf("%d: %s\n", i, fileArr[i]); } </code></pre> <p>This code doesn't print anything at the end. It just ends so it seems like it deletes the entries in the char array</p>
0debug
how to arrange values according to alphabets in php : hi m working on jobportal project, and wants to arrange values alphabatically according to their starting aplhabet section, according to image. <span>a</span> <?php $sql = "select * from companies"; $result = mysqli_query($con, $sql); while($data = mysqli_fetch_array($result)) { $company = $data['company_name']; ?> <div class="list-col"> <a href="#"><?php echo $company; ?>(0)</a> </div> <?php } ?> </div> </li> <li class="loop-entry"> <div class="col"> <span>b</span> <div class="list-col"> <a href="#">Company Name (0)</a> <a href="#">Company Name (0)</a> <a href="#">Company Name (0)</a> <a href="#">Company Name (0) </a> <a href="#">Company Name (0)</a> </div> </div> </li> [i wants to arrange according to this image][1] [1]: https://i.stack.imgur.com/6VaCK.png
0debug
bool virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *req) { VirtIOSCSICommon *vs = &s->parent_obj; SCSIDevice *d; int rc; rc = virtio_scsi_parse_req(req, sizeof(VirtIOSCSICmdReq) + vs->cdb_size, sizeof(VirtIOSCSICmdResp) + vs->sense_size); if (rc < 0) { if (rc == -ENOTSUP) { virtio_scsi_fail_cmd_req(req); } else { virtio_scsi_bad_req(); } return false; } d = virtio_scsi_device_find(s, req->req.cmd.lun); if (!d) { req->resp.cmd.response = VIRTIO_SCSI_S_BAD_TARGET; virtio_scsi_complete_cmd_req(req); return false; } if (s->dataplane_started) { assert(blk_get_aio_context(d->conf.blk) == s->ctx); } req->sreq = scsi_req_new(d, req->req.cmd.tag, virtio_scsi_get_lun(req->req.cmd.lun), req->req.cmd.cdb, req); if (req->sreq->cmd.mode != SCSI_XFER_NONE && (req->sreq->cmd.mode != req->mode || req->sreq->cmd.xfer > req->qsgl.size)) { req->resp.cmd.response = VIRTIO_SCSI_S_OVERRUN; virtio_scsi_complete_cmd_req(req); return false; } scsi_req_ref(req->sreq); blk_io_plug(d->conf.blk); return true; }
1threat
Unable to resolve module `./../../react-transform-hmr/lib/index.js` : <p>error: bundling failed: Error: Unable to resolve module <code>./../../react-transform-hmr/lib/index.js</code> from <code>/ReactNative/UsermanagementNav/src/App.js</code>: The module <code>./../../react-transform-hmr/lib/index.js</code> could not be found from <code>/ReactNative/UsermanagementNav/src/App.js</code>.</p> <p>I have tried to install react-native-transform-hmr using </p> <blockquote> <p>npm i react-native-transform-hmr</p> </blockquote> <p>but it does not solve my issue. i am using react-native 0.57.2 and react 16.5.0</p>
0debug
static void v9fs_wstat_post_rename(V9fsState *s, V9fsWstatState *vs, int err) { if (err < 0) { goto out; } if (vs->v9stat.name.size != 0) { v9fs_string_free(&vs->nname); } if (vs->v9stat.length != -1) { if (v9fs_do_truncate(s, &vs->fidp->path, vs->v9stat.length) < 0) { err = -errno; } } v9fs_wstat_post_truncate(s, vs, err); return; out: v9fs_stat_free(&vs->v9stat); complete_pdu(s, vs->pdu, err); qemu_free(vs); }
1threat
When not to use mobile-web-app-capable : <p>I've <a href="http://www.html5rocks.com/en/mobile/fullscreen/#toc-launch" rel="noreferrer">read</a> on how adding</p> <pre class="lang-html prettyprint-override"><code>&lt;meta name="apple-mobile-web-app-capable" content="yes"&gt; &lt;meta name="mobile-web-app-capable" content="yes"&gt; </code></pre> <p>to your HTML will allow users to add that page to their home screen and use it as an App. So I'm wondering whether it would make sense to add these meta tags to pretty much all the HTML I generate. After all, the user doesn't <em>have</em> to install them as apps, but if they choose to do so, why should I prevent that?</p> <p>I'm mostly thinking about unauthenticated content here which is static from a HTML server perspective, although it may well be interctive thanks to client-side JavaScript. To give you an idea, think about single-page tutorials, perhaps with some interactive code demo in it. Something like that.</p> <ul> <li>Am I making any promises by adding these tags?</li> <li>In what situations should I avoid adding them?</li> </ul>
0debug
How to change the line color in seaborn lmplot : <p>We can get a plot as bellow</p> <pre><code>import numpy as np, pandas as pd; np.random.seed(0) import seaborn as sns; sns.set(style="white", color_codes=True) tips = sns.load_dataset("tips") g = sns.lmplot(x="total_bill", y="tip", data=tips) sns.plt.show() </code></pre> <p><a href="https://i.stack.imgur.com/5kLUv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5kLUv.png" alt="enter image description here"></a></p> <p>But when we have a lot of data points the regression line is not visible anymore. How can I change the line's color? I couldn't find anymore command</p>
0debug
Logging array indices, not values (JavaScript) - why? : <p>Here's my script:</p> <pre><code>var alphabet = ["A", "B", "C", "D", "3", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]; var str = []; for (i=0; i&lt;alphabet.length; i++) { str.push(i); console.log(str.join("")); } </code></pre> <p>It's printing out the indices of str (0, 01, 012...) rather than the values (A, AB, ABC...). What is going on here? </p>
0debug
Error while Installing restart patches when launching android app with Android Studio 2.0 : <p>Currently I'm using Android Studio 2.0 and installing my APK into my Samsung device (S6). However, when rebuilding my code and running it again I receive the following error:</p> <pre><code>Error installing cold swap patches: com.android.tools.fd.client.InstantRunPushFailedException: Error creating folder with: run-as com.appcustomer mkdir -p /data/data/com.appcustomer/files/instant-run/inbox Error while Installing restart patches </code></pre> <p>Does anyone have any idea what this issue is?</p>
0debug
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { PicContext *s = avctx->priv_data; AVFrame *frame = data; uint32_t *palette; int bits_per_plane, bpp, etype, esize, npal, pos_after_pal; int i, x, y, plane, tmp, ret, val; bytestream2_init(&s->g, avpkt->data, avpkt->size); if (bytestream2_get_bytes_left(&s->g) < 11) return AVERROR_INVALIDDATA; if (bytestream2_get_le16u(&s->g) != 0x1234) return AVERROR_INVALIDDATA; s->width = bytestream2_get_le16u(&s->g); s->height = bytestream2_get_le16u(&s->g); bytestream2_skip(&s->g, 4); tmp = bytestream2_get_byteu(&s->g); bits_per_plane = tmp & 0xF; s->nb_planes = (tmp >> 4) + 1; bpp = bits_per_plane * s->nb_planes; if (bits_per_plane > 8 || bpp < 1 || bpp > 32) { avpriv_request_sample(avctx, "Unsupported bit depth"); return AVERROR_PATCHWELCOME; } if (bytestream2_peek_byte(&s->g) == 0xFF || bpp == 1 || bpp == 4 || bpp == 8) { bytestream2_skip(&s->g, 2); etype = bytestream2_get_le16(&s->g); esize = bytestream2_get_le16(&s->g); if (bytestream2_get_bytes_left(&s->g) < esize) return AVERROR_INVALIDDATA; } else { etype = -1; esize = 0; } avctx->pix_fmt = AV_PIX_FMT_PAL8; if (s->width != avctx->width && s->height != avctx->height) { if (av_image_check_size(s->width, s->height, 0, avctx) < 0) return -1; avcodec_set_dimensions(avctx, s->width, s->height); } if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; memset(frame->data[0], 0, s->height * frame->linesize[0]); frame->pict_type = AV_PICTURE_TYPE_I; frame->palette_has_changed = 1; pos_after_pal = bytestream2_tell(&s->g) + esize; palette = (uint32_t*)frame->data[1]; if (etype == 1 && esize > 1 && bytestream2_peek_byte(&s->g) < 6) { int idx = bytestream2_get_byte(&s->g); npal = 4; for (i = 0; i < npal; i++) palette[i] = ff_cga_palette[ cga_mode45_index[idx][i] ]; } else if (etype == 2) { npal = FFMIN(esize, 16); for (i = 0; i < npal; i++) { int pal_idx = bytestream2_get_byte(&s->g); palette[i] = ff_cga_palette[FFMIN(pal_idx, 15)]; } } else if (etype == 3) { npal = FFMIN(esize, 16); for (i = 0; i < npal; i++) { int pal_idx = bytestream2_get_byte(&s->g); palette[i] = ff_ega_palette[FFMIN(pal_idx, 63)]; } } else if (etype == 4 || etype == 5) { npal = FFMIN(esize / 3, 256); for (i = 0; i < npal; i++) { palette[i] = bytestream2_get_be24(&s->g) << 2; palette[i] |= 0xFFU << 24 | palette[i] >> 6 & 0x30303; } } else { if (bpp == 1) { npal = 2; palette[0] = 0xFF000000; palette[1] = 0xFFFFFFFF; } else if (bpp == 2) { npal = 4; for (i = 0; i < npal; i++) palette[i] = ff_cga_palette[ cga_mode45_index[0][i] ]; } else { npal = 16; memcpy(palette, ff_cga_palette, npal * 4); } } memset(palette + npal, 0, AVPALETTE_SIZE - npal * 4); bytestream2_seek(&s->g, pos_after_pal, SEEK_SET); val = 0; y = s->height - 1; if (bytestream2_get_le16(&s->g)) { x = 0; plane = 0; while (y >= 0 && bytestream2_get_bytes_left(&s->g) >= 6) { int stop_size, marker, t1, t2; t1 = bytestream2_get_bytes_left(&s->g); t2 = bytestream2_get_le16(&s->g); stop_size = t1 - FFMIN(t1, t2); bytestream2_skip(&s->g, 2); marker = bytestream2_get_byte(&s->g); while (plane < s->nb_planes && y >= 0 && bytestream2_get_bytes_left(&s->g) > stop_size) { int run = 1; val = bytestream2_get_byte(&s->g); if (val == marker) { run = bytestream2_get_byte(&s->g); if (run == 0) run = bytestream2_get_le16(&s->g); val = bytestream2_get_byte(&s->g); } if (!bytestream2_get_bytes_left(&s->g)) break; if (bits_per_plane == 8) { picmemset_8bpp(s, frame, val, run, &x, &y); if (y < 0) goto finish; } else { picmemset(s, frame, val, run, &x, &y, &plane, bits_per_plane); } } } if (x < avctx->width && y >= 0) { int run = (y + 1) * avctx->width - x; if (bits_per_plane == 8) picmemset_8bpp(s, frame, val, run, &x, &y); else picmemset(s, frame, val, run / (8 / bits_per_plane), &x, &y, &plane, bits_per_plane); } } else { while (y >= 0 && bytestream2_get_bytes_left(&s->g) > 0) { memcpy(frame->data[0] + y * frame->linesize[0], s->g.buffer, FFMIN(avctx->width, bytestream2_get_bytes_left(&s->g))); bytestream2_skip(&s->g, avctx->width); y--; } } finish: *got_frame = 1; return avpkt->size; }
1threat
Convert Matrix to upper triangular without using numpy : My code had conveted the matrix to Upper Triangular Matrix but I need to eliminate the space after the last element in a row. My code is n= int(input()) matrix=[] for i in range(n): matrix.append(list(map(int,input().rstrip().split()))) for i in range(n): for j in range(n): if(i<j): print("0",end=" ") else: print(matrix[i][j],end=" ") if(i!=n-1): print() Outut: Expected Output Actual Output 2 0 0\n 2 0 0 \n 5 6 0\n 5 6 0 \n 7 6 5 7 6 5
0debug
static void exponents_from_scale_factors(MPADecodeContext *s, GranuleDef *g, int16_t *exponents) { const uint8_t *bstab, *pretab; int len, i, j, k, l, v0, shift, gain, gains[3]; int16_t *exp_ptr; exp_ptr = exponents; gain = g->global_gain - 210; shift = g->scalefac_scale + 1; bstab = band_size_long[s->sample_rate_index]; pretab = mpa_pretab[g->preflag]; for(i=0;i<g->long_end;i++) { v0 = gain - ((g->scale_factors[i] + pretab[i]) << shift); len = bstab[i]; for(j=len;j>0;j--) *exp_ptr++ = v0; } if (g->short_start < 13) { bstab = band_size_short[s->sample_rate_index]; gains[0] = gain - (g->subblock_gain[0] << 3); gains[1] = gain - (g->subblock_gain[1] << 3); gains[2] = gain - (g->subblock_gain[2] << 3); k = g->long_end; for(i=g->short_start;i<13;i++) { len = bstab[i]; for(l=0;l<3;l++) { v0 = gains[l] - (g->scale_factors[k++] << shift); for(j=len;j>0;j--) *exp_ptr++ = v0; } } } }
1threat
how to develop a wordpress plugin to fetch the posts from the parameters given at home page and parse it as json, like JSON API Plugin : I am trying to develop a small wordpress plugin to fetch the posts, pages from the website and parse it as json to further use in mobile apps. Right now i am achiving the goal via this method: 1) Created a file webservice.php on my current active theme eg. twentythirteen. So the location of the file is http://www.example.com/wp-content/themes/twentythirteen/webservice.php 2) I am posting the parameters on that url to get a json response like this http://www.example.com/wp-content/themes/twentythirteen/webservice.php?type=page&limit=10 The thing is i want to post parameters on the home page like this http://www.example.com?type=page&limit=10 i dont know how to do it i have seen 'JSON API' Plugin which is doing the same thing but not able to find on its code how its fething the request from home page and parse JSON on the same page. Can any one help me with this
0debug
How to add a URL to download a file in java : <p>I want to add a URL into my java program: <a href="http://www.markit.com/news/InterestRates_JPY_20160426.zip" rel="nofollow">http://www.markit.com/news/InterestRates_JPY_20160426.zip</a>; so basically when you open this link a zip file is downloaded. How do I do that?</p> <p>And then, I want to unzip the downloaded file in the java program as well.</p> <p>How do I do these in java?</p>
0debug
Invalid name when running stata do file : I am getting "Invalid name" when running the following code foreach i in 2008 2009 2010 2011{ disp `"Working in Year `i'"' tostring `i', local(yearStr) disp `"yearStr"' graph bar E if Year=="'i'", c(1) name ('i',replace) histogram E if Year=="`i'", c(1) name (`yearStr',replace) } What I am trying to do is plot a graph bar between years and "E" by choosing the years 2008 2009 2010 2011 from a dataset that I have already input. But whenever I try to run the code, the same error is found. Error : Working on year 2008 2008 invalid name r(198); Many Thanks
0debug
Stream Video using Twilio from IP Camera RTSP : <p>All of Twilio's examples for their Programmable Video service that I've been able to find either demonstrate screen sharing or webcam media streams. Can someone point me to an example that streams video from an RTSP stream provided by an IP Camera?</p> <p>I've been able to find examples of and experiment with this behavior using Kurento, so I figured Twilio-Video might expose the same. See <a href="https://github.com/lulop-k/kurento-rtsp2webrtc" rel="noreferrer">https://github.com/lulop-k/kurento-rtsp2webrtc</a></p>
0debug
Is C# a regular language? : <p>I'm writing some static analysis tools and have been trying to avoid doing full-on compilation style string parsing, and that brought me to this question.</p> <p>Is C# a regular language?</p> <p>Why or why not?</p>
0debug
static void pit_reset(void *opaque) { PITState *pit = opaque; PITChannelState *s; int i; for(i = 0;i < 3; i++) { s = &pit->channels[i]; s->mode = 3; s->gate = (i != 2); pit_load_count(s, 0); } }
1threat
%matplotlib notebook showing a blank histogram : <p>In my Jupyter notebook I am now using <code>%matplotlib notebook</code> instead of <code>%matplotlib inline</code>, it's awesome that I can now interact with my plots on Jupyter. However, when I try to make an histogram I get a blank plot:</p> <p><a href="https://i.stack.imgur.com/s6Jgd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/s6Jgd.png" alt="%matplotlib notebook"></a></p> <p>If I use <code>%matplotlib inline</code> everything works fine: <a href="https://i.stack.imgur.com/sJQGn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sJQGn.png" alt="%matplotlib inline"></a></p> <p>What's going on?</p>
0debug
static av_cold int prores_encode_close(AVCodecContext *avctx) { ProresContext* ctx = avctx->priv_data; av_freep(&avctx->coded_frame); av_free(ctx->fill_y); av_free(ctx->fill_u); av_free(ctx->fill_v); return 0; }
1threat
CVS how to split and find number of 0's in column : I have 14 columns (A-N) in a CVS file I am looking to to find how many patients(303 in total) have 0 signs for heart disease this would be in column 14(N) anything above 0 would be counted as ill patients and those with 0 are healthy. From what I have in my code so far is this ( i know I am more than likely doing this wrong so please correct me if I made a mistake) import csv import math with open("train.csv", "r") as f: #HP is healthy patient IP is ill patients for c in f.read()14: chars.append(c) num_chars = len(chars) num_IP = 0; num_HP = 0; for c in chars: if c = >0 num_IP += 1 if c = <=0 num_HP += 1
0debug
static void validate_bootdevices(char *devices) { const char *p; int bitmap = 0; for (p = devices; *p != '\0'; p++) { if (*p < 'a' || *p > 'p') { fprintf(stderr, "Invalid boot device '%c'\n", *p); exit(1); } if (bitmap & (1 << (*p - 'a'))) { fprintf(stderr, "Boot device '%c' was given twice\n", *p); exit(1); } bitmap |= 1 << (*p - 'a'); } }
1threat
ComboBox Items via Scene Builder? : <pre><code> &lt;ComboBox fx:id="schaltung" layoutX="347.0" layoutY="50.0" prefHeight="63.0" prefWidth="213.0"&gt; &lt;items&gt; &lt;FXCollections fx:factory="observableArrayList"&gt; &lt;String fx:id="reihe" fx:value="Reihenschaltung" /&gt; &lt;String fx:id="parallel" fx:value="Parallelschaltung" /&gt; &lt;/FXCollections&gt; &lt;/items&gt; &lt;/ComboBox&gt; </code></pre> <p>I added this to my FXML file because I couldnt figure out where I could add Items to my ComboBox in the SceneBuilder. Is it possible to add items via the SceneBuilder, or do I have to do it manually?</p>
0debug
Convert Rdd to Data Frame - i am getting output in the data frame table with " " like "2012-10-10" but i should get output without " " in the table : My input file contains below input "date","time","size","r_version","r_arch","r_os" "2012-10-01","00:30:13",35165,"2.15.1","i686","linux-gnu" "2012-10-01","00:30:15",212967,"2.15.1","i686","linux-gnu" "2012-10-01","02:30:16",167199,"2.15.1","x86_64","linux-gnu" my present output is like [present output][1] my required output is [required output][3] [1]: https://i.stack.imgur.com/DMfXP.png [2]: https://i.stack.imgur.com/jBzXl.png [3]: https://i.stack.imgur.com/vVJpU.png
0debug
found syntax error near ')' SQL server : when I run this query don't know why this show error "Incorrect syntax near ')'." Thank you for help select Sum(DateDiff(s,Toc1.OutTime, (Select Top 1 Intime From tblTokenLogs Where TokenId = Toc1.TokenId And LogId != Toc1.LogId And LogId > Toc1.LogId))) as Sec From tblTokenLogs As Toc1 Where Toc1.TokenId = 1 And Toc1.OutTime != '') as SecTotal
0debug
Cross platform iOS, Android, Linux C++ test framework : <p>In 2017, what options for cross platform C++ unit testing do I have? Testing for both iOS and Android has been totally cumbersome and required lots of custom work in the past.</p> <p>Google recently improved C++ support for Android and Google's GTest looked promising at first glance. But it has no official iOS support and integration was cumbersome and error prone. </p> <p>Then there is Boost.test and catch. I have mo experience with either, but suppose they do not integrate well with XCode or Android Studio. </p> <p>What other options do I have?</p>
0debug
static int bdrv_qed_do_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQEDState *s = bs->opaque; QEDHeader le_header; int64_t file_size; int ret; s->bs = bs; qemu_co_queue_init(&s->allocating_write_reqs); ret = bdrv_pread(bs->file, 0, &le_header, sizeof(le_header)); if (ret < 0) { return ret; } qed_header_le_to_cpu(&le_header, &s->header); if (s->header.magic != QED_MAGIC) { error_setg(errp, "Image not in QED format"); return -EINVAL; } if (s->header.features & ~QED_FEATURE_MASK) { error_setg(errp, "Unsupported QED features: %" PRIx64, s->header.features & ~QED_FEATURE_MASK); return -ENOTSUP; } if (!qed_is_cluster_size_valid(s->header.cluster_size)) { return -EINVAL; } file_size = bdrv_getlength(bs->file->bs); if (file_size < 0) { return file_size; } s->file_size = qed_start_of_cluster(s, file_size); if (!qed_is_table_size_valid(s->header.table_size)) { return -EINVAL; } if (!qed_is_image_size_valid(s->header.image_size, s->header.cluster_size, s->header.table_size)) { return -EINVAL; } if (!qed_check_table_offset(s, s->header.l1_table_offset)) { return -EINVAL; } s->table_nelems = (s->header.cluster_size * s->header.table_size) / sizeof(uint64_t); s->l2_shift = ctz32(s->header.cluster_size); s->l2_mask = s->table_nelems - 1; s->l1_shift = s->l2_shift + ctz32(s->table_nelems); if (s->header.header_size > UINT32_MAX / s->header.cluster_size) { return -EINVAL; } if ((s->header.features & QED_F_BACKING_FILE)) { if ((uint64_t)s->header.backing_filename_offset + s->header.backing_filename_size > s->header.cluster_size * s->header.header_size) { return -EINVAL; } ret = qed_read_string(bs->file, s->header.backing_filename_offset, s->header.backing_filename_size, bs->backing_file, sizeof(bs->backing_file)); if (ret < 0) { return ret; } if (s->header.features & QED_F_BACKING_FORMAT_NO_PROBE) { pstrcpy(bs->backing_format, sizeof(bs->backing_format), "raw"); } } if ((s->header.autoclear_features & ~QED_AUTOCLEAR_FEATURE_MASK) != 0 && !bdrv_is_read_only(bs->file->bs) && !(flags & BDRV_O_INACTIVE)) { s->header.autoclear_features &= QED_AUTOCLEAR_FEATURE_MASK; ret = qed_write_header_sync(s); if (ret) { return ret; } bdrv_flush(bs->file->bs); } s->l1_table = qed_alloc_table(s); qed_init_l2_cache(&s->l2_cache); ret = qed_read_l1_table_sync(s); if (ret) { goto out; } if (!(flags & BDRV_O_CHECK) && (s->header.features & QED_F_NEED_CHECK)) { if (!bdrv_is_read_only(bs->file->bs) && !(flags & BDRV_O_INACTIVE)) { BdrvCheckResult result = {0}; ret = qed_check(s, &result, true); if (ret) { goto out; } } } bdrv_qed_attach_aio_context(bs, bdrv_get_aio_context(bs)); out: if (ret) { qed_free_l2_cache(&s->l2_cache); qemu_vfree(s->l1_table); } return ret; }
1threat
static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque) { Range *range = opaque; PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); uint16_t cmd = pci_get_word(dev->config + PCI_COMMAND); int i; if (!(cmd & PCI_COMMAND_MEMORY)) { return; } if (pc->is_bridge) { pcibus_t base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_MEM_PREFETCH); pcibus_t limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_MEM_PREFETCH); base = MAX(base, 0x1ULL << 32); if (limit >= base) { Range pref_range; pref_range.begin = base; pref_range.end = limit + 1; range_extend(range, &pref_range); } } for (i = 0; i < PCI_NUM_REGIONS; ++i) { PCIIORegion *r = &dev->io_regions[i]; Range region_range; if (!r->size || (r->type & PCI_BASE_ADDRESS_SPACE_IO) || !(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64)) { continue; } region_range.begin = pci_bar_address(dev, i, r->type, r->size); region_range.end = region_range.begin + r->size; if (region_range.begin == PCI_BAR_UNMAPPED) { continue; } region_range.begin = MAX(region_range.begin, 0x1ULL << 32); if (region_range.end - 1 >= region_range.begin) { range_extend(range, &region_range); } } }
1threat
What CIDR address do not overlaps with 10.0.0.0/16? : <p>I ahve created aws VPC and try to create additional CIDR. I have always got overlaps error whever values I tried <code>/8</code>, <code>/0</code>, <code>/16</code>, <code>/32</code>:</p> <p><a href="https://i.stack.imgur.com/UU9aV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UU9aV.png" alt="enter image description here"></a></p> <p>What are correct values?</p>
0debug
Error in windows forms : <p>First of all, sorry for my bad english,</p> <p>My teacher gave me some homeworks to do, he told me to make a program with 'windows forms' to order fruits from home, but i have these two errors in the code. These two errors are coming from the rows with three slashes. I hope somebody can help me with this. Thank you.</p> <pre><code> this.tex_shbanane.Location = new System.Drawing.Point(316, 242); this.tex_shbanane.Name = "tex_shbanane"; this.tex_shbanane.ReadOnly = true; this.tex_shbanane.Size = new System.Drawing.Size(70, 20); this.tex_shbanane.TabIndex = 22; /// this.tex_shbanane.TextChanged += new System.EventHandler(this.tex_shbanane_TextChanged); // // tex_shgjithsej // this.tex_shgjithsej.Location = new System.Drawing.Point(316, 268); this.tex_shgjithsej.Name = "tex_shgjithsej"; this.tex_shgjithsej.ReadOnly = true; this.tex_shgjithsej.Size = new System.Drawing.Size(70, 20); this.tex_shgjithsej.TabIndex = 23; this.tex_shgjithsej.TextChanged += new System.EventHandler(this.tex_shgjithsej_TextChanged); // // tex_shtaksa // this.tex_shtaksa.Location = new System.Drawing.Point(316, 294); this.tex_shtaksa.Name = "tex_shtaksa"; this.tex_shtaksa.ReadOnly = true; this.tex_shtaksa.Size = new System.Drawing.Size(70, 20); this.tex_shtaksa.TabIndex = 24; this.tex_shtaksa.TextChanged += new System.EventHandler(this.tex_shtaksa_TextChanged); // // tex_shtransporti // this.tex_shtransporti.Location = new System.Drawing.Point(316, 318); this.tex_shtransporti.Name = "tex_shtransporti"; this.tex_shtransporti.ReadOnly = true; this.tex_shtransporti.Size = new System.Drawing.Size(70, 20); this.tex_shtransporti.TabIndex = 25; /// this.tex_shtransporti.TextChanged += new System.EventHandler(this.tex_shtransporti_TextChanged); </code></pre>
0debug
static void build_guest_fsinfo_for_virtual_device(char const *syspath, GuestFilesystemInfo *fs, Error **errp) { DIR *dir; char *dirpath; struct dirent entry, *result; dirpath = g_strdup_printf("%s/slaves", syspath); dir = opendir(dirpath); if (!dir) { error_setg_errno(errp, errno, "opendir(\"%s\")", dirpath); g_free(dirpath); return; } g_free(dirpath); for (;;) { if (readdir_r(dir, &entry, &result) != 0) { error_setg_errno(errp, errno, "readdir_r(\"%s\")", dirpath); break; } if (!result) { break; } if (entry.d_type == DT_LNK) { g_debug(" slave device '%s'", entry.d_name); dirpath = g_strdup_printf("%s/slaves/%s", syspath, entry.d_name); build_guest_fsinfo_for_device(dirpath, fs, errp); g_free(dirpath); if (*errp) { break; } } } closedir(dir); }
1threat
Pictures and images for using in app designing : <p>anyone knows a good website for getting pictures, images, characters,etc for an app I'm developing? I have tried looking for websites but couldnt find anything. maybe there isnt. but im pretty much a begginer and would love to know if there is one. </p>
0debug
When using create-react-app why does the development server keep disconnecting? : <p>It happens arbritarily, like once every 3 or 4 refreshes, the server just disocnnects with this message in the console:</p> <pre><code>The development server has disconnected. Refresh the page if necessary. </code></pre> <p>I looked at one of the other <a href="https://stackoverflow.com/questions/43274925/development-server-of-create-react-app-does-not-auto-refresh">SO threads</a> and my problem seems different because that's about the webpack watcher not connecting to begin with, in my case it works but disconnects very often. I haven't even ejected the app so not sure why this can be. Anyone else had this problem and found a solution?</p>
0debug
how to fill a full line in vertical layout android app programming : this is my first app so sorry i know its not that good. My english neither. I got a Problem with my xml design: I want 2 Buttons and 2 TextViews in one line and to fill the whole line. At the moment it looks like that: [enter image description here][1] but it gets even worse: [enter image description here][2] my code: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="-" /> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/textView11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/button11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="+" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="-" /> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/textView12" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/button12" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="+" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="-" /> <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/textView13" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/button13" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="+" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="-" /> <TextView android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/textView14" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/button14" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="+" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="-" /> <TextView android:id="@+id/textView5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/textView15" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/button15" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="+" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="-" /> <TextView android:id="@+id/textView6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/textView16" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/button16" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="+" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="-" /> <TextView android:id="@+id/textView7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/textView17" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/button17" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="+" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button8" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="-" /> <TextView android:id="@+id/textView8" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/textView18" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/button18" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="+" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button9" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="-" /> <TextView android:id="@+id/textView9" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/textView19" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/button19" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="+" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button10" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="-" /> <TextView android:id="@+id/textView10" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <TextView android:id="@+id/textView20" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/button20" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="+" /> </LinearLayout> </LinearLayout> I hope you can help me [1]: https://i.stack.imgur.com/o7DDx.jpg [2]: https://i.stack.imgur.com/0lxd4.jpg
0debug
background-image not displaying on body : my css is not working i need it to be fixed does not display and don't know why it has done this i'm new so coding html and css and want the image to go full screen. I have tried everything and still not working. body { background-image: "/folder/photo.gif"; } Hope someone can help me out and find the answer.
0debug
Convert code from C++ to C : Does anyone know how to convert this line from C++ to C programming language? i wrote this code in C++ and i want to convert it in C. bool compare(string a, string b) { return a+b > b+a; }
0debug
static int balloon_parse(const char *arg) { QemuOpts *opts; if (strcmp(arg, "none") == 0) { return 0; } if (!strncmp(arg, "virtio", 6)) { if (arg[6] == ',') { opts = qemu_opts_parse(qemu_find_opts("device"), arg+7, 0); if (!opts) return -1; } else { opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0); } qemu_opt_set(opts, "driver", "virtio-balloon"); return 0; } return -1; }
1threat
static int coroutine_fn backup_run_incremental(BackupBlockJob *job) { bool error_is_read; int ret = 0; int clusters_per_iter; uint32_t granularity; int64_t sector; int64_t cluster; int64_t end; int64_t last_cluster = -1; int64_t sectors_per_cluster = cluster_size_sectors(job); BdrvDirtyBitmapIter *dbi; granularity = bdrv_dirty_bitmap_granularity(job->sync_bitmap); clusters_per_iter = MAX((granularity / job->cluster_size), 1); dbi = bdrv_dirty_iter_new(job->sync_bitmap, 0); while ((sector = bdrv_dirty_iter_next(dbi)) != -1) { cluster = sector / sectors_per_cluster; if (cluster != last_cluster + 1) { job->common.offset += ((cluster - last_cluster - 1) * job->cluster_size); } for (end = cluster + clusters_per_iter; cluster < end; cluster++) { do { if (yield_and_check(job)) { goto out; } ret = backup_do_cow(job, cluster * job->cluster_size, job->cluster_size, &error_is_read, false); if ((ret < 0) && backup_error_action(job, error_is_read, -ret) == BLOCK_ERROR_ACTION_REPORT) { goto out; } } while (ret < 0); } if (granularity < job->cluster_size) { bdrv_set_dirty_iter(dbi, cluster * sectors_per_cluster); } last_cluster = cluster - 1; } end = DIV_ROUND_UP(job->common.len, job->cluster_size); if (last_cluster + 1 < end) { job->common.offset += ((end - last_cluster - 1) * job->cluster_size); } out: bdrv_dirty_iter_free(dbi); return ret; }
1threat
why my code giving error in in jupyter notebook where as it is running correct on online ide ? : # Program for Armstrong Number<br> import math<br> print("this program is for armstrong number\n")<br /> m=0<br> p=0<br> n=int(input("Enter any number: \n"))<br> y=n<br> while y!=0:<br> y=y/10<br> p+=1<br> y=n<br> while n!=0:<br> x=n%10<br> m+=math.pow(x,p)<br> n=n/10<br> if y==m:<br> print("The given number is an armstrong number\n")<br> else:<br> print("The given number is not an armstrong number\n")<br>
0debug
How to disable gathering facts for subplays not included within given tag : <p>Several of my playbooks have sub-plays structure like this:</p> <pre><code>- hosts: sites user: root tags: - configuration tasks: (...) - hosts: sites user: root tags: - db tasks: (...) - hosts: sites user: "{{ site_vars.user }}" tags: - app tasks: (...) </code></pre> <p>In Ansible 1.x both admins and developers were able to use such playbook. Admins could run it with all the tags (root and user access), while developers had access only to the last tag with tasks at user access level. When developers run this playbook with the <em>app</em> tag, gathering facts was skipped for the first two tags. Now however, in Ansible 2.1, it is not being skipped, which causes failure for users without root access. </p> <p>Is there a mechanism or an easy modification to fix this behaviour? Is there a new approach which should be applied for such cases now?</p>
0debug
Why I am getting the below error? I interchanged the class names and there was no error. : [enter image description here][1] [1]: http://i.stack.imgur.com/IbCWi.png I am executing this in java 8. I tried interchanging the class name. While i did that, I also shuffled the main method. I was getting no errors. It is the only scenario where i am getting an error. I am not getting why. Please help.
0debug
EF query to Oracle throwing "ORA-12704: character set mismatch" : <p>I'm trying to combine a few columns in EF from Oracle then do a <code>.Contains()</code> over the columns like this:</p> <pre><code>public IEnumerable&lt;User&gt; SearchUsers(string search) { search = search.ToLower(); return _securityUow.Users .Where(u =&gt; (u.FirstName.ToLower() + " " + u.LastName.ToLower() + " (" + u.NetId.ToLower() + ")").Contains(search)) .OrderBy(u =&gt; u.LastName) .ThenBy(u =&gt; u.FirstName) .AsEnumerable(); } </code></pre> <p>However, I'm getting this exception:</p> <pre><code>{ "Message": "An error has occurred.", "ExceptionMessage": "An error occurred while executing the command definition. See the inner exception for details.", "ExceptionType": "System.Data.Entity.Core.EntityCommandExecutionException", "StackTrace": " at SoftwareRegistration.WebUI.Controllers.Api.V1.UserContactController.Lookup(String search) in C:\LocalRepository\OnlineSupport\SoftwareRegistration\trunk\release\SoftwareRegistration\SoftwareRegistration.WebUI\Controllers\Api\V1\UserContactController.cs:line 40\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.&lt;&gt;c__DisplayClass10.&lt;GetExecutor&gt;b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.&lt;InvokeActionAsyncCore&gt;d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ActionFilterResult.&lt;ExecuteAsync&gt;d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.&lt;SendAsync&gt;d__1.MoveNext()", "InnerException": { "Message": "An error has occurred.", "ExceptionMessage": "ORA-12704: character set mismatch", "ExceptionType": "Oracle.ManagedDataAccess.Client.OracleException", "StackTrace": " at OracleInternal.ServiceObjects.OracleCommandImpl.VerifyExecution(OracleConnectionImpl connectionImpl, Int32&amp; cursorId, Boolean bThrowArrayBindRelatedErrors, OracleException&amp; exceptionForArrayBindDML, Boolean&amp; hasMoreRowsInDB, Boolean bFirstIterationDone)\r\n at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteReader(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, OracleDataReaderImpl&amp; rdrImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[] scnForExecution, Int64[]&amp; scnFromExecution, OracleParameterCollection&amp; bindByPositionParamColl, Boolean&amp; bBindParamPresent, Int64&amp; internalInitialLOBFS, OracleException&amp; exceptionForArrayBindDML, Boolean isDescribeOnly, Boolean isFromEF)\r\n at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)\r\n at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.&lt;Reader&gt;b__c(DbCommand t, DbCommandInterceptionContext`1 c)\r\n at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)\r\n at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)\r\n at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)" } } </code></pre> <p>The columns I'm querying are all of type VARCHAR2(128) in Oracle.</p> <p>I'm also using this exact same code in another project and it works. The only difference is that for the project that works I'm using <code>Oracle.DataAccess</code> and for the one that doesn't work, I'm using <code>Oracle.ManagedDataAccess</code> (I am unable to use <code>Oracle.DataAccess</code> for this project). So I believe there is a bug/problem in the managed driver.</p> <p>I'm open to solutions or workarounds.</p>
0debug
How to create a dataframe from a built in vector in Rstudio : I tried to create a dataframe from the built in data (its a vector) called percip. Here is the code below: data("precip") > str(precip) Named num [1:70] 67 54.7 7 48.5 14 17.2 20.7 13 43.4 40.2 ... - attr(*, "names")= chr [1:70] "Mobile" "Juneau" "Phoenix" "Little Rock" ... > head(precip) Mobile Juneau Phoenix Little Rock Los Angeles Sacramento 67.0 54.7 7.0 48.5 14.0 17.2 How do I create a dataframe where I have the name of the city in one column and the numbers in another column?
0debug
How to print ASCII art in python 3? : I want to print some ASCII art using python 3 on my terminal. I've tried triple quotes but got all sorts of Syntax Errors. Found something like [this][1] that looks fine, but i don't know python 2 and translating it was non-trivial. How do I do this? Thanks a lot. [1]: http://code.activestate.com/recipes/306863-printing-a-bannertitle-line/
0debug
Cookie is not set on localhost in chrome or firefox : <p>I am working with a Jersey server which returns a cookie in the following way:</p> <pre><code>return Response.ok() .cookie( new NewCookie( "userAccessToken", userTokenDTO.getToken(), "/", "", "what is this", 3600, false ) ).build(); </code></pre> <p>When I call the method which returns the cookie, I get the following result in chrome: <a href="https://i.stack.imgur.com/UuCq2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UuCq2.png" alt="Request and response headers"></a></p> <p>I can even see that chrome has recognized my cookie: <a href="https://i.stack.imgur.com/4gHxt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4gHxt.png" alt="Cookie recognized"></a></p> <p>But for some reason it isn't set in the cookie tab:</p> <p><a href="https://i.stack.imgur.com/9Tx4K.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9Tx4K.png" alt="No cookie shown"></a></p> <p>I have tried setting the domain both to false, null, "", creating an entry in the hosts file renaming 127.0.0.1.</p> <pre><code>return Response.ok() .cookie( new NewCookie( "userAccessToken", userTokenDTO.getToken(), "/", "127.0.0.1", "what is this", 3600, false) ).build(); </code></pre> <p>Works in IE 11, but still not Chrome nor Firefox...</p> <p>I have tried multiple time to insert another host name for 127.0.0.1. In this example it is text.myexample.com. It still doesn't work in any other browser than IE11. </p> <pre><code>return Response.ok() .cookie( new NewCookie( "userAccessToken", userTokenDTO.getToken(), "/", "test.myexample.com", "what", 7200, false) ).build(); </code></pre> <p>I tried to do the following in the console of Google Chrome:</p> <pre><code>document.cookie = "userAccessToken=72bebbe0-44fd-45ce-a6e1-accb72201eff;Version=1;Comment=what;Domain=test.myexample.com;Path=/;Max-Age=7200" </code></pre> <p>Which is the cookie in the header returned by the server in Chrome. That works fine. I have literally no clue what is going on here.</p>
0debug
Need to change program filtering of files getting from FTP : <p>I've a C# program that received FTP records. The files we receive are all .csv so I check for that below:</p> <pre><code>private static bool IsAllowedExtension(string fileExtension) { return fileExtension.ToLower() == ".csv"; } </code></pre> <p>then we process only this sort of file:</p> <pre><code> foreach (RemoteFileInfo fileInfo in directory.Files) { var fileExtension = Path.GetExtension(fileInfo.Name); if (string.IsNullOrEmpty(fileExtension) || !IsAllowedExtension(fileExtension)) continue; if (!Directory.Exists(LocalPath)) Directory.CreateDirectory(LocalPath); var localFile = string.Format("{0}\\{1}",LocalPath.TrimEnd('\\') , fileInfo.Name); if (fileInfo.Name != ".." &amp;&amp; !File.Exists(localFile)) </code></pre> <p>However, now there has been some .csv in the group receiving we dont want. So i want to add or change this to that the file we want all start as this:</p> <p>"CheckoutReportID=" this would give us only the ones needed.</p>
0debug
Get current OS language - Python : <p>I want to take the current OS language in Python. For example if english are chosen, I want to get a code (or something like that) and when I change with shift+alt to other language, I want to take the newly changed language code.</p> <p>Is this possible?</p>
0debug
Why does this bool expression with 'or' return True? : <p>I am still working with bool logic.</p> <p>I have this snippet and I don't understand why the result comes out True.</p> <pre><code>flag = False print(flag) flag = flag or True print(flag) </code></pre> <p>you get:</p> <pre><code>&gt;&gt;False &gt;&gt;True </code></pre> <p>Why is this happening? I am not sure how this works.</p> <p>Is or supposed to give you any instance where the expression is True? </p> <p>I get why this happens:</p> <pre><code>check = (7 &gt; 60) or (7 &lt; 10) print(check) </code></pre> <p>7 is less than 10, so the check expression is True</p> <p>Thanks for the explanation. Just trying to work out bools in my head.</p>
0debug
What does (1UL << 22) mean in MySQL Source Code Documentation : <p>I am updating an existing library in Java I have to connect to MySQL 8 but the source code documentation has a #DEFINE I don't understand. I'm looking specifically at the client capability flags at <a href="https://dev.mysql.com/doc/dev/mysql-server/latest/group__group__cs__capabilities__flags.html" rel="nofollow noreferrer">https://dev.mysql.com/doc/dev/mysql-server/latest/group__group__cs__capabilities__flags.html</a>. </p> <p>Some of the capability flags show the decimal value so I can convert them to unix for easier bitmasking but there's some flags like <code>CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS</code> which has the value of <code>(1UL &lt;&lt; 22)</code>. I have no idea what <code>(1UL &lt;&lt; 22)</code> means to be able convert that to something I can use in java. </p>
0debug
Disable AccountChooser for Firebase Auth : <p>I'm trying the new FirebaseUI for Web (<a href="https://github.com/firebase/FirebaseUI-Web" rel="noreferrer">https://github.com/firebase/FirebaseUI-Web</a>). But when I tried to login with Email, it redirects me to an AccountChooser website.</p> <p>Is there anyway that I can turn off that AccountChooser?</p> <p>Thanks</p>
0debug
MongoDB: Bulk insert (Bulk.insert) vs insert multiple (insert([...])) : <p>Is there any difference between a <a href="https://docs.mongodb.org/manual/core/bulk-write-operations/" rel="noreferrer">bulk insert</a> vs <a href="https://docs.mongodb.org/manual/reference/method/db.collection.insert/" rel="noreferrer">inserting multiple documents</a>? </p> <pre><code>var bulk = db.items.initializeUnorderedBulkOp(); bulk.insert( { item: "abc123", defaultQty: 100, status: "A", points: 100 } ); bulk.insert( { item: "ijk123", defaultQty: 200, status: "A", points: 200 } ); bulk.insert( { item: "mop123", defaultQty: 0, status: "P", points: 0 } ); bulk.execute(); </code></pre> <p>VS</p> <pre><code>db.collection.insert( &lt;document or array of documents&gt; ) </code></pre> <p>Is there one thats faster? </p>
0debug
Java - How to determine if there's a run of characters in an array? : Say we have an array: array = [1, 0, 0, 0, 1, 0, 1, 1, 1]; And we want to find a "run" of duplicate numbers where there are at least three in a row. In this case, it would be the set of 0, 0, 0, and 1, 1, 1. How can I determine which indices contain the "runs" of three or more? I hope this makes sense.
0debug
static void test_hmac_speed(const void *opaque) { size_t chunk_size = (size_t)opaque; QCryptoHmac *hmac = NULL; uint8_t *in = NULL, *out = NULL; size_t out_len = 0; double total = 0.0; struct iovec iov; Error *err = NULL; int ret; if (!qcrypto_hmac_supports(QCRYPTO_HASH_ALG_SHA256)) { return; } in = g_new0(uint8_t, chunk_size); memset(in, g_test_rand_int(), chunk_size); iov.iov_base = (char *)in; iov.iov_len = chunk_size; g_test_timer_start(); do { hmac = qcrypto_hmac_new(QCRYPTO_HASH_ALG_SHA256, (const uint8_t *)KEY, strlen(KEY), &err); g_assert(err == NULL); g_assert(hmac != NULL); ret = qcrypto_hmac_bytesv(hmac, &iov, 1, &out, &out_len, &err); g_assert(ret == 0); g_assert(err == NULL); qcrypto_hmac_free(hmac); total += chunk_size; } while (g_test_timer_elapsed() < 5.0); total /= 1024 * 1024; g_print("hmac(sha256): "); g_print("Testing chunk_size %ld bytes ", chunk_size); g_print("done: %.2f MB in %.2f secs: ", total, g_test_timer_last()); g_print("%.2f MB/sec\n", total / g_test_timer_last()); g_free(out); g_free(in); }
1threat
Get first and last elements in array, ES6 way : <p><code>let array = [1,2,3,4,5,6,7,8,9,0]</code></p> <p>Documentation is something like this</p> <p><code>[first, ...rest] = array</code> will output 1 and the rest of array</p> <p>Now is there a way to take only the first and the last element <code>1 &amp; 0</code> with <code>Destructuring</code> </p> <p>ex: <code>[first, ...middle, last] = array</code></p> <p>I know how to take the first and last elements the other way but I was wondering if it is possible with es6</p>
0debug
XCode 10 does not show file in Navigation Pane : When I click on a folder in the Navigation pane, and open it in Finder, the file is there, but it's not shown in Xcode and build fails complaining the file doesn't exist.
0debug
MYSQL Tables Conflict Need Help Joining tables : MYSQL PROBLEM! HELP PLEASE.. <h3>I HAVE TWO TABLES CALLED kingdom & player</h3> <pre> kingdom table: +---------------------------------------- | ID | kingdom | timestamp | +---------------------------------------- | 1 | Kingdom 47 | time | | 2 | Kingdom 48 | time | ----------------------------------------+ player table: +---------------------------------------+ | ID | name | kingdom | +---------------------------------------+ | 7 | some name | 1 | | 8 | some name | 1 | | 9 | some name | 1 | +---------------------------------------+ <h2><h2> Help Needed MYSQL</h2> <h3><strong>I would like to join them and get out some thing like the one below:</strong></h3> <b><mark>I WANT THE OUTPUT LIKE THIS: +-----------------------------------------+ | ID | name | kingdom | +-----------------------------------------+ | 7 | some name | Kingdom 47 | | 8 | some name | Kingdom 47 | | 9 | some name | Kingdom 47 | +-----------------------------------------+</mark></b> </pre>
0debug
Delphi: Very simple random : I have this code ... letsdoit(something,'abcd'); letsdoit(something,'asdfasdf'); letsdoit(something,'gagaga'); ... I want it to be, if possible, just one simple line with the logic like: > Question 1: (letsdoit(something,'abcd'))OR(letsdoit(something,'asdfasdf'))OR(letsdoit(something,'gagaga')); so it has 33% chance to choose either of the three. Or if I do > Question 2: (letsdoit(something,'abcd'))OR(letsdoit(something,'asdfasdf')) it has 50% chance to choose the left or 50% chance for the right thing. **So in short,** my questions: *Question 1: randomize between the three and only do one thing. Question 2: randomize between two things and only do one.*
0debug
check_host_key_hash(BDRVSSHState *s, const char *hash, int hash_type, size_t fingerprint_len) { const char *fingerprint; fingerprint = libssh2_hostkey_hash(s->session, hash_type); if (!fingerprint) { session_error_report(s, "failed to read remote host key"); return -EINVAL; } if(compare_fingerprint((unsigned char *) fingerprint, fingerprint_len, hash) != 0) { error_report("remote host key does not match host_key_check '%s'", hash); return -EPERM; } return 0; }
1threat
How to sort certain range of elements only of a String array in java? : <p>For example I have an array of 5 elements and i want to sort only elements 1-3??</p> <p>array={"abc","rst","pqr","qwerty","lmn"}</p> <p>my array should be array={"abc","pqr","qwerty","rst","lmn"} How do i proceed?</p>
0debug
static int tcp_read(URLContext *h, uint8_t *buf, int size) { TCPContext *s = h->priv_data; int size1, len, fd_max; fd_set rfds; struct timeval tv; size1 = size; while (size > 0) { if (url_interrupt_cb()) return -EINTR; fd_max = s->fd; FD_ZERO(&rfds); FD_SET(s->fd, &rfds); tv.tv_sec = 0; tv.tv_usec = 100 * 1000; select(fd_max + 1, &rfds, NULL, NULL, &tv); #ifdef __BEOS__ len = recv(s->fd, buf, size, 0); #else len = read(s->fd, buf, size); #endif if (len < 0) { if (errno != EINTR && errno != EAGAIN) #ifdef __BEOS__ return errno; #else return -errno; #endif else continue; } else if (len == 0) { break; } size -= len; buf += len; } return size1 - size; }
1threat
Comparing Two Hashmaps in Java : <p>What's the recommended approach for comparing hashmaps in Java for equality so that I can determine if they have identical keys and values?</p> <pre><code>Map&lt;String,List&lt;String&gt;&gt; data1 = new HashMap&lt;&gt;(); data1.put("file1", Arrays.asList("one","two","three")); Map&lt;String,List&lt;String&gt;&gt; data2 = new HashMap&lt;&gt;(); data2.put("file1", Arrays.asList("one","two","three")); </code></pre>
0debug
Using classes in static main method : <p>So I'm writing a mini-board game program in Java.</p> <p>The program is going to read in standard input and construct a game as directed in the input.</p> <p>To help stay organized and progress my oo java skills, I am using a Cell class to act as a cell in a nxn game.</p> <p>For the board game, I need to have it all in one file, and it must run from static void main.</p> <p>Here's what my Cell class looks like</p> <pre><code>public class Cell{ public int x; public int y; . . . } </code></pre> <p>I want to read the input, and assign values to each cell and then add the cells to a list such as ArrayList allCells. However, I can not the use it in a static context.</p> <p>I understand that static is a single instance, so I'm confused how I would go about doing this. Is there anyway I can use a class-based system to solve this problem. Each cell is it's own individual object, so making it stat wouldn't work.</p> <p>Any sort-of explanation or alternative would be amazing! Hope I was clear enough in my description.</p>
0debug
copy web page content in a file via linux terminal : I want to copy some texts from a web page to a file in Linux. I know "wget" can be used to download files but my favourite data is not stored in files and when I want to have them, I have to use copy and paste manually which is very difficult for thousands of web pages. For example, I need to have the data in the link below: http://weather.uwyo.edu/cgi-bin/sounding?region=naconf&TYPE=TEXT%3ALIST&YEAR=2017&MONTH=09&FROM=0112&TO=0112&STNM=72672 and similar link with varying YEAR, MONTH, FROM, TO, STNM values. Is there any command/script to copy and paste automatically ? Thanks
0debug
static int vp8_lossless_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, uint8_t *data_start, unsigned int data_size, int is_alpha_chunk) { WebPContext *s = avctx->priv_data; int w, h, ret, i; if (!is_alpha_chunk) { s->lossless = 1; avctx->pix_fmt = AV_PIX_FMT_ARGB; } ret = init_get_bits8(&s->gb, data_start, data_size); if (ret < 0) return ret; if (!is_alpha_chunk) { if (get_bits(&s->gb, 8) != 0x2F) { av_log(avctx, AV_LOG_ERROR, "Invalid WebP Lossless signature\n"); return AVERROR_INVALIDDATA; } w = get_bits(&s->gb, 14) + 1; h = get_bits(&s->gb, 14) + 1; if (s->width && s->width != w) { av_log(avctx, AV_LOG_WARNING, "Width mismatch. %d != %d\n", s->width, w); } s->width = w; if (s->height && s->height != h) { av_log(avctx, AV_LOG_WARNING, "Height mismatch. %d != %d\n", s->width, w); } s->height = h; ret = ff_set_dimensions(avctx, s->width, s->height); if (ret < 0) return ret; s->has_alpha = get_bits1(&s->gb); if (get_bits(&s->gb, 3) != 0x0) { av_log(avctx, AV_LOG_ERROR, "Invalid WebP Lossless version\n"); return AVERROR_INVALIDDATA; } } else { if (!s->width || !s->height) return AVERROR_BUG; w = s->width; h = s->height; } s->nb_transforms = 0; s->reduced_width = 0; while (get_bits1(&s->gb)) { enum TransformType transform = get_bits(&s->gb, 2); s->transforms[s->nb_transforms++] = transform; switch (transform) { case PREDICTOR_TRANSFORM: ret = parse_transform_predictor(s); break; case COLOR_TRANSFORM: ret = parse_transform_color(s); break; case COLOR_INDEXING_TRANSFORM: ret = parse_transform_color_indexing(s); break; } if (ret < 0) goto free_and_return; } s->image[IMAGE_ROLE_ARGB].frame = p; if (is_alpha_chunk) s->image[IMAGE_ROLE_ARGB].is_alpha_primary = 1; ret = decode_entropy_coded_image(s, IMAGE_ROLE_ARGB, w, h); if (ret < 0) goto free_and_return; for (i = s->nb_transforms - 1; i >= 0; i--) { switch (s->transforms[i]) { case PREDICTOR_TRANSFORM: ret = apply_predictor_transform(s); break; case COLOR_TRANSFORM: ret = apply_color_transform(s); break; case SUBTRACT_GREEN: ret = apply_subtract_green_transform(s); break; case COLOR_INDEXING_TRANSFORM: ret = apply_color_indexing_transform(s); break; } if (ret < 0) goto free_and_return; } *got_frame = 1; p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; ret = data_size; free_and_return: for (i = 0; i < IMAGE_ROLE_NB; i++) image_ctx_free(&s->image[i]); return ret; }
1threat
static inline void cow_set_bits(uint8_t *bitmap, int start, int64_t nb_sectors) { int64_t bitnum = start, last = start + nb_sectors; while (bitnum < last) { if ((bitnum & 7) == 0 && bitnum + 8 <= last) { bitmap[bitnum / 8] = 0xFF; bitnum += 8; continue; } bitmap[bitnum/8] |= (1 << (bitnum % 8)); bitnum++; } }
1threat
static void i6300esb_restart_timer(I6300State *d, int stage) { int64_t timeout; if (!d->enabled) return; d->stage = stage; if (d->stage <= 1) timeout = d->timer1_preload; else timeout = d->timer2_preload; if (d->clock_scale == CLOCK_SCALE_1KHZ) timeout <<= 15; else timeout <<= 5; timeout = get_ticks_per_sec() * timeout / 33000000; i6300esb_debug("stage %d, timeout %" PRIi64 "\n", d->stage, timeout); timer_mod(d->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + timeout); }
1threat
What is the exact difference between abstraction and encapsulation in C++ : <p>C++: Difference between abstraction and encapsulation in c++</p> <p>I have seen some answers on this topic but I want to know the difference by an example which relates to the theoretical concept of these topics. </p>
0debug
FIND 3RD HISGHEST COST FROM : [This is catalog table [] [1]: https://i.stack.imgur.com/F4AML.png**so i have to find 3rd highest cost from this table .** i wrote this SELECT TOP 1 COST FROM CATALOG WHERE COST IN (SELECT DISTINCT TOP 3 COST FROM CATALOG ORDER BY COST DESC) ORDER BY COST ASC; I GOT THIS ERROR' FROM KEYWORD NOT FOUND WHERE EXPECTED' PLEASE TELL ME WHAT IS THE ACTUAL QUERY .
0debug
How do i Maintain Session in C# MVC Partial Views which will access in different Controllers : <p>I am Trying to Design a web App using MVC .. i am trying to access user Login information throughout the application until the user Logout from the application. </p> <p>please anyone help me... it's most helpful for me if we add session in list variable and pass throughout the application </p>
0debug
Pulling double inverted commas from the database : <p>I need some assistance. I have a table and I am loading info to it from the database, everything loads how it is in the database but as soon as I want to edit a row with a value that has a double inverted comma in it for eg: 40" Samsung. What it will do when I want to edit it it will show the 40 but everything after the 40 wont appear.</p> <p>How my edit works, I have checkbox in on column of the table linked to its row so when I tick the check box and I select edit all the information on that row(s) will be present on their respected textboxes and I edit the info and click save. If I add any character it will save exactly as I typed into the database but if on of the columns contains a double inverted comma it shows everything before the inverted comma, example: 40" Samsung will show the 40 but everything after the zero won't show.</p> <p>Please help</p>
0debug
How NAT traversal works in case of peer to peer protocols like bittorrent. : <p>I know about NAT traversal and about STUN, TURN and ICE and its use. I want to know whether these are implemented in peer to peer file sharing application like bittorrent. Whether trackers facilitate peers behind NATs to communicate with each other by helping in creating direct connection using STUN or relay through TURN. In the case of Distributed Hash Table(DHT) how one peer would communicate with other peer behind NAT ?</p>
0debug
void kvm_cpu_synchronize_state(CPUState *env) { if (!env->kvm_vcpu_dirty) run_on_cpu(env, do_kvm_cpu_synchronize_state, env); }
1threat
void spapr_tce_free(sPAPRTCETable *tcet) { QLIST_REMOVE(tcet, list); if (!kvm_enabled() || (kvmppc_remove_spapr_tce(tcet->table, tcet->fd, tcet->window_size) != 0)) { g_free(tcet->table); } g_free(tcet); }
1threat
static coroutine_fn int qcow2_co_flush_to_os(BlockDriverState *bs) { BDRVQcow2State *s = bs->opaque; int ret; qemu_co_mutex_lock(&s->lock); ret = qcow2_cache_flush(bs, s->l2_table_cache); if (ret < 0) { qemu_co_mutex_unlock(&s->lock); return ret; } if (qcow2_need_accurate_refcounts(s)) { ret = qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { qemu_co_mutex_unlock(&s->lock); return ret; } } qemu_co_mutex_unlock(&s->lock); return 0; }
1threat
How to pass a string value from a class to another on the same viewcontroller (Swift) : I have created a viewcontroller which consists of two classes. These are displayed below: import UIKit class ViewController: UIViewController { var colour:String? override func viewDidLoad() { super.viewDidLoad() } } class TestView: UIView { } my question is how can I pass the colour variable to the TestView class.
0debug
static uint16_t md_common_read(PCMCIACardState *card, uint32_t at) { MicroDriveState *s = MICRODRIVE(card); IDEState *ifs; uint16_t ret; at -= s->io_base; switch (s->opt & OPT_MODE) { case OPT_MODE_MMAP: if ((at & ~0x3ff) == 0x400) { at = 0; } break; case OPT_MODE_IOMAP16: at &= 0xf; break; case OPT_MODE_IOMAP1: if ((at & ~0xf) == 0x3f0) { at -= 0x3e8; } else if ((at & ~0xf) == 0x1f0) { at -= 0x1f0; } break; case OPT_MODE_IOMAP2: if ((at & ~0xf) == 0x370) { at -= 0x368; } else if ((at & ~0xf) == 0x170) { at -= 0x170; } } switch (at) { case 0x0: case 0x8: return ide_data_readw(&s->bus, 0); if (s->cycle) { ret = s->io >> 8; } else { s->io = ide_data_readw(&s->bus, 0); ret = s->io & 0xff; } s->cycle = !s->cycle; return ret; case 0x9: return s->io >> 8; case 0xd: return ide_ioport_read(&s->bus, 0x1); case 0xe: ifs = idebus_active_if(&s->bus); if (ifs->bs) { return ifs->status; } else { return 0; } case 0xf: ifs = idebus_active_if(&s->bus); return 0xc2 | ((~ifs->select << 2) & 0x3c); default: return ide_ioport_read(&s->bus, at); } return 0; }
1threat
Javascript shorthand which calls functions : <p>I want a shorthand that runs a function if true and runs a separate function if false. Something like:</p> <pre><code>(condition)? function1:function2; </code></pre>
0debug
static void alpha_cpu_realizefn(DeviceState *dev, Error **errp) { AlphaCPUClass *acc = ALPHA_CPU_GET_CLASS(dev); acc->parent_realize(dev, errp); }
1threat
Text selection is not giving the exact position : I have a text which is like -> **Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.** Now, I want to highlight some part of this text . So, I need to know the start and end offsets of the string. Let's say it to make a This text I want to highlight so, I need to have the offset of this text. So, for this I am using following logic var startoffset = $scope.original_doc_content.indexOf("it to make a "); var endoffset = startoffset + string.length; So, Now what is happening here is if `it to make a` is present 2 times in a given text then if I want to highlight or want to take the second one and if it present before the 2nd one then it gives me the 1st ones offset and not the second one which I require. So,How can I resolve this ?
0debug
What does =+ mean in c++ : <p>I've been studying operator overloading and i cant understand this, whenever i use <code>s1=+s2</code> answer is <code>s1=1 s2=1</code> and when i use <code>s2=+s1</code> i get <code>s1=2 s2=2</code> please explain</p> <pre><code>#include&lt;iostream&gt; using namespace std; class score { private: int val; public: score() { val=0; } score operator+() { score temp; val=val+1; temp.val=val; return temp; } void show() { cout&lt;&lt;val&lt;&lt;endl; } }; main() { score s1,s2; s1.show(); s2.show(); +s1; s1=+s2; s1.show(); s2.show(); } </code></pre>
0debug
Generic programming via effects : <p>In the Idris <a href="https://github.com/idris-lang/Idris-dev/blob/master/libs/effects/Effects.idr" rel="noreferrer">Effects</a> library effects are represented as</p> <pre><code>||| This type is parameterised by: ||| + The return type of the computation. ||| + The input resource. ||| + The computation to run on the resource given the return value. Effect : Type Effect = (x : Type) -&gt; Type -&gt; (x -&gt; Type) -&gt; Type </code></pre> <p>If we allow resources to be values and swap the first two arguments, we get (the rest of the code is in Agda)</p> <pre><code>Effect : Set -&gt; Set Effect R = R -&gt; (A : Set) -&gt; (A -&gt; R) -&gt; Set </code></pre> <p>Having some basic type-context-membership machinery</p> <pre><code>data Type : Set where nat : Type _⇒_ : Type -&gt; Type -&gt; Type data Con : Set where ε : Con _▻_ : Con -&gt; Type -&gt; Con data _∈_ σ : Con -&gt; Set where vz : ∀ {Γ} -&gt; σ ∈ Γ ▻ σ vs_ : ∀ {Γ τ} -&gt; σ ∈ Γ -&gt; σ ∈ Γ ▻ τ </code></pre> <p>we can encode lambda terms constructors as follows:</p> <pre><code>app-arg : Bool -&gt; Type -&gt; Type -&gt; Type app-arg b σ τ = if b then σ ⇒ τ else σ data TermE : Effect (Con × Type) where Var : ∀ {Γ σ } -&gt; σ ∈ Γ -&gt; TermE (Γ , σ ) ⊥ λ() Lam : ∀ {Γ σ τ} -&gt; TermE (Γ , σ ⇒ τ ) ⊤ (λ _ -&gt; Γ ▻ σ , τ ) App : ∀ {Γ σ τ} -&gt; TermE (Γ , τ ) Bool (λ b -&gt; Γ , app-arg b σ τ) </code></pre> <p>In <code>TermE i r i′</code> <code>i</code> is an output index (e.g. lambda abstractions (<code>Lam</code>) construct function types (<code>σ ⇒ τ</code>) (for ease of description I'll ignore that indices also contain contexts besides types)), <code>r</code> represents a number of inductive positions (<code>Var</code> doesn't (<code>⊥</code>) receive any <code>TermE</code>, <code>Lam</code> receives one (<code>⊤</code>), <code>App</code> receives two (<code>Bool</code>) — a function and its argument) and <code>i′</code> computes an index at each inductive position (e.g. the index at the first inductive position of <code>App</code> is <code>σ ⇒ τ</code> and the index at the second is <code>σ</code>, i.e. we can apply a function to a value only if the type of the first argument of the function equals the type of the value).</p> <p>To construct a real lambda term we must tie the knot using something like a <a href="https://github.com/agda/agda-stdlib/blob/master/src/Data/W.agda" rel="noreferrer"><code>W</code></a> data type. Here is the definition:</p> <pre><code>data Wer {R} (Ψ : Effect R) : Effect R where call : ∀ {r A r′ B r′′} -&gt; Ψ r A r′ -&gt; (∀ x -&gt; Wer Ψ (r′ x) B r′′) -&gt; Wer Ψ r B r′′ </code></pre> <p>It's the indexed variant of the Oleg Kiselyov's <a href="http://okmij.org/ftp/Haskell/extensible/more.pdf" rel="noreferrer"><code>Freer</code></a> monad (effects stuff again), but without <code>return</code>. Using this we can recover the usual constructors:</p> <pre><code>_&lt;∨&gt;_ : ∀ {B : Bool -&gt; Set} -&gt; B true -&gt; B false -&gt; ∀ b -&gt; B b (x &lt;∨&gt; y) true = x (x &lt;∨&gt; y) false = y _⊢_ : Con -&gt; Type -&gt; Set Γ ⊢ σ = Wer TermE (Γ , σ) ⊥ λ() var : ∀ {Γ σ} -&gt; σ ∈ Γ -&gt; Γ ⊢ σ var v = call (Var v) λ() ƛ_ : ∀ {Γ σ τ} -&gt; Γ ▻ σ ⊢ τ -&gt; Γ ⊢ σ ⇒ τ ƛ b = call Lam (const b) _·_ : ∀ {Γ σ τ} -&gt; Γ ⊢ σ ⇒ τ -&gt; Γ ⊢ σ -&gt; Γ ⊢ τ f · x = call App (f &lt;∨&gt; x) </code></pre> <p>The whole encoding is very similar to the <a href="https://github.com/effectfully/DataData/blob/master/Container/Indexed.agda#L75" rel="noreferrer">corresponding encoding</a> in terms of <a href="http://strictlypositive.org/indexed-containers.pdf" rel="noreferrer">indexed containers</a>: <code>Effect</code> corresponds to <code>IContainer</code> and <code>Wer</code> corresponds to <code>ITree</code> (the type of Petersson-Synek Trees). However the above encoding looks simpler to me, because you don't need to think about things you have to put into shapes to be able to recover indices at inductive positions. Instead, you have everything in one place and the encoding process is really straightforward.</p> <p>So what am I doing here? Is there some real relation to the indexed containers approach (besides the fact that this encoding has the same <a href="http://mazzo.li/epilogue/index.html%3Fp=324.html" rel="noreferrer">extensionality problems</a>)? Can we do something useful this way? One natural thought is to built an effectful lambda calculus as we can freely mix lambda terms with effects, since a lambda term is itself just an effect, but it's an external effect and we either need other effects to be external as well (which means that we can't say something like <code>tell (var vz)</code>, because <code>var vz</code> is not a value — it's a computation) or we need to somehow internalize this effect and the whole effects machinery (which means I don't know what).</p> <p><a href="https://github.com/effectfully/random-stuff/blob/master/Wer.agda" rel="noreferrer">The code used</a>.</p>
0debug
static int coroutine_fn bdrv_driver_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BlockDriver *drv = bs->drv; int64_t sector_num = offset >> BDRV_SECTOR_BITS; unsigned int nb_sectors = bytes >> BDRV_SECTOR_BITS; assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); assert((bytes >> BDRV_SECTOR_BITS) <= BDRV_REQUEST_MAX_SECTORS); return drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov); }
1threat
What kind of information is stored in a .cpp file extension? : <p>I researched this question on Google and Stak Overflow but couldn't find an answer to it. </p> <p>I am trying to find out what all information is stored in a .cpp file extension. Meaning, is it just code that has been compiled (meaning compiled code)? Does have an object file in it? Does it include an object in it? What exactly does it consist of?</p>
0debug
Wordpress functions.php has a parse error : <p>Hi I ran into a prob while setting up the functions.php file for Wordpress. My localhost server is showing this error: Parse error: syntax error, unexpected 'if' (T_IF) in /Applications/MAMP/htdocs/wdnomads-wp/wp-content/themes/womendigitalnomads/functions.php on line 3</p> <p>I've tried googling and pasting Wordpress' own code, but the error still exists. Not sure what I'm doing wrong.</p> <pre><code>&lt;? php if ( ! isset( $content_width ) ) { $content_width = 660; } </code></pre>
0debug
How to get an image of each letter from image with text : <p>F.E. we have a scanned text document. For now, I have wrote a program which can get an image of a letter and recognize it. The thing which I don't understand now is how can I get from the whole scanned document the image representation of each text symbol? Is it possible?</p> <p><a href="https://i.stack.imgur.com/Qt4jF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qt4jF.png" alt="enter image description here"></a></p>
0debug
How i can create generator string with ONLY ONE special character? : <p>i want to create generator string with one special character. Just only one. Can u help me ?.</p> <p>I tried searched the generator on the internet but i saw only generatorspecial characters with a lot of special characters i need "ONLY ONE SPECIAL CHARACTER".</p> <p>PHP 7</p>
0debug
static uint16_t nvme_del_cq(NvmeCtrl *n, NvmeCmd *cmd) { NvmeDeleteQ *c = (NvmeDeleteQ *)cmd; NvmeCQueue *cq; uint16_t qid = le16_to_cpu(c->qid); if (!qid || nvme_check_cqid(n, qid)) { return NVME_INVALID_CQID | NVME_DNR; } cq = n->cq[qid]; if (!QTAILQ_EMPTY(&cq->sq_list)) { return NVME_INVALID_QUEUE_DEL; } nvme_free_cq(cq, n); return NVME_SUCCESS; }
1threat
Is Visual Studio 2017 new .csproj relevant to non .net core projects : <p>I'm a bit confused. I have the new version of Visual Studio 2017. And have converted my class projects (.net full 4.5) to the new .csproj project format. Then I tried to run live tests on those projects, but VS now informs me that live testing is not supported on .net core projects jet.</p> <p>So:</p> <ol> <li>Are those projects now .Net Core projects?</li> <li>If Yes, can I use the new .csproj project file for the old good .Net Full 4.x</li> <li>I am planning to deploy my application as WebApi services to a windows server only, and I'm planning to use NHibernate ORM, so movig to .net Core is excluded, are there any benefit of using this new .csproj format for my case?</li> <li>Can I use the new .csproj format and keep using non .Net Core compatible libraries like NHibernate?</li> </ol> <p>Thanks</p>
0debug
static coroutine_fn int qcow2_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors, BdrvRequestFlags flags) { int ret; BDRVQcow2State *s = bs->opaque; int head = sector_num % s->cluster_sectors; int tail = (sector_num + nb_sectors) % s->cluster_sectors; trace_qcow2_write_zeroes_start_req(qemu_coroutine_self(), sector_num, nb_sectors); if (head != 0 || tail != 0) { int64_t cl_start = sector_num - head; assert(cl_start + s->cluster_sectors >= sector_num + nb_sectors); sector_num = cl_start; nb_sectors = s->cluster_sectors; if (!is_zero_cluster(bs, sector_num)) { return -ENOTSUP; } qemu_co_mutex_lock(&s->lock); if (!is_zero_cluster_top_locked(bs, sector_num)) { qemu_co_mutex_unlock(&s->lock); return -ENOTSUP; } } else { qemu_co_mutex_lock(&s->lock); } trace_qcow2_write_zeroes(qemu_coroutine_self(), sector_num, nb_sectors); ret = qcow2_zero_clusters(bs, sector_num << BDRV_SECTOR_BITS, nb_sectors); qemu_co_mutex_unlock(&s->lock); return ret; }
1threat
iterating through multiple equations : <p>I have a problem simplified into the following:</p> <p>Xn+1 = Xn + Yn</p> <p>Yn+1= Yn + Zn</p> <p>Zn+1= Zn+ Xn</p> <p>I know the values of X0,Y0,Z0 to be equal to 1. I want to tell python to find the values of X1,Y1,Z1 and then X2,Y2,Z2,...etc. Can anyone help me with that? I think I have to use a nested loop but I am not sure exactly how to go about it. Thanks!</p>
0debug
Wrong answer although the whole program logic seems to be working : <p>This is my solution to the problem <a href="http://codeforces.com/contest/129/problem/A" rel="nofollow noreferrer">Codeforces-D2A-129 Cookies</a>. The program outputs a wrong answer at testcase 11, which is: </p> <p>82 </p> <p>43 44 96 33 23 42 33 66 53 87 8 90 43 91 40 88 51 18 48 62 59 10 22 20 54 6 13 63 2 56 31 52 98 42 54 32 26 77 9 24 33 91 16 30 39 34 78 82 73 90 12 15 67 76 30 18 44 86 84 98 65 54 100 79 28 34 40 56 11 43 72 35 86 59 89 40 30 33 7 19 44 15</p> <p>My program: </p> <pre><code>#include &lt;cstdio&gt; #include &lt;algorithm&gt; // for count() and sort() #include &lt;vector&gt; using namespace std; // function prototype void erase_duplicates(vector&lt;int&gt; &amp;, int, int); int main() { int num; // number of bags of cookies int total = 0; // total number of cookies int ways = 0; // number of ways Olga can take a bag of cookies int duplicates = 0; // number of duplicates of an element scanf("%i", &amp;num); // getting number of bags of cookies vector&lt;int&gt; cookies(num); // number of cookies in the ith bag // getting number of cookies in each bag for(int i = 0; i &lt; num; i++) scanf("%i", &amp;cookies[i]); for(int j = 0; j &lt; num; j++) // calculating total number of cookies total += cookies[j]; // sorting the input sort(cookies.begin(), cookies.end()); for(int k = 0; k &lt; cookies.size(); k++) { if((total - cookies[k]) % 2 == 0) { // adding number of duplicates of the current element to the number of ways duplicates = count(cookies.begin(), cookies.end(), cookies[k]); ways += duplicates; // erasing the duplicates of that element erase_duplicates(cookies, cookies[k], k); } } //printing the possible number of ways printf("%i", ways); return 0; } // This function erases the duplicates of the element passed as the second argument. // Parameters are: vector of integers, element, index of the element. void erase_duplicates(vector&lt;int&gt; &amp;cookies, int value, int k){ for(int i = k; i &lt; cookies.size(); i++){ if(cookies[i] == value) // if it is a duplicate, remove it. cookies.erase(cookies.begin() + i); } } </code></pre> <p>What's wrong with my code?</p>
0debug
static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr, uint64_t *data, unsigned size, MemTxAttrs attrs) { NVICState *s = (NVICState *)opaque; uint32_t offset = addr; unsigned i, startvec, end; uint32_t val; if (attrs.user && !nvic_user_access_ok(s, addr)) { return MEMTX_ERROR; } switch (offset) { case 0x100 ... 0x13f: offset += 0x80; case 0x180 ... 0x1bf: val = 0; startvec = offset - 0x180 + NVIC_FIRST_IRQ; for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) { if (s->vectors[startvec + i].enabled) { val |= (1 << i); } } break; case 0x200 ... 0x23f: offset += 0x80; case 0x280 ... 0x2bf: val = 0; startvec = offset - 0x280 + NVIC_FIRST_IRQ; for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) { if (s->vectors[startvec + i].pending) { val |= (1 << i); } } break; case 0x300 ... 0x33f: val = 0; startvec = offset - 0x300 + NVIC_FIRST_IRQ; for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) { if (s->vectors[startvec + i].active) { val |= (1 << i); } } break; case 0x400 ... 0x5ef: val = 0; startvec = offset - 0x400 + NVIC_FIRST_IRQ; for (i = 0; i < size && startvec + i < s->num_irq; i++) { val |= s->vectors[startvec + i].prio << (8 * i); } break; case 0xd18 ... 0xd23: val = 0; for (i = 0; i < size; i++) { val |= s->vectors[(offset - 0xd14) + i].prio << (i * 8); } break; case 0xfe0 ... 0xfff: if (offset & 3) { val = 0; } else { val = nvic_id[(offset - 0xfe0) >> 2]; } break; default: if (size == 4) { val = nvic_readl(s, offset); } else { qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read of size %d at offset 0x%x\n", size, offset); val = 0; } } trace_nvic_sysreg_read(addr, val, size); *data = val; return MEMTX_OK; }
1threat