problem
stringlengths
26
131k
labels
class label
2 classes
static int proxy_closedir(FsContext *ctx, V9fsFidOpenState *fs) { return closedir(fs->dir); }
1threat
changing letters in text in R : I have a text. It includes letters like ş ç ü ö ı. I need to changed them with s c u o i. I wrote following code: `string <- "ş ç ı ğ ü ö f s x q" chartr("ş ç ı ğ ü ö", "s c i g u o", string)` My text file name is `text`. How can apply the code above to my text, since I have still these letters?
0debug
static void *bochs_bios_init(void) { void *fw_cfg; uint8_t *smbios_table; size_t smbios_len; uint64_t *numa_fw_cfg; int i, j; fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0); fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES, (uint8_t *)acpi_tables, acpi_tables_len); fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override()); smbios_table = smbios_get_table(&smbios_len); if (smbios_table) fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, smbios_table, smbios_len); fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE, (uint8_t *)&e820_table, sizeof(e820_table)); fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, (uint8_t *)&hpet_cfg, sizeof(struct hpet_fw_config)); numa_fw_cfg = g_new0(uint64_t, 1 + max_cpus + nb_numa_nodes); numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes); for (i = 0; i < max_cpus; i++) { for (j = 0; j < nb_numa_nodes; j++) { if (test_bit(i, node_cpumask[j])) { numa_fw_cfg[i + 1] = cpu_to_le64(j); break; } } } for (i = 0; i < nb_numa_nodes; i++) { numa_fw_cfg[max_cpus + 1 + i] = cpu_to_le64(node_mem[i]); } fw_cfg_add_bytes(fw_cfg, FW_CFG_NUMA, (uint8_t *)numa_fw_cfg, (1 + max_cpus + nb_numa_nodes) * sizeof(*numa_fw_cfg)); return fw_cfg; }
1threat
Same layout Look different in to device which have same screen size : I have 2 phone amsung s6 edge+ & Samsung note 4, Both have same same screen size 5.7 inch & same screen resolution 1440X2560 & both layout have xxxhdpi density. still same layout look different on both device. even top status bar & action bar is also look different on both device which is system genereated. any one can suggest some solution to have same UI on each and every android device. [Screen shot of same layout in both devices][1] [1]: http://i.stack.imgur.com/AzMve.jpg
0debug
static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id) { VirtIOBlock *s = opaque; if (version_id != 2) return -EINVAL; virtio_load(&s->vdev, f); while (qemu_get_sbyte(f)) { VirtIOBlockReq *req = virtio_blk_alloc_request(s); qemu_get_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem)); req->next = s->rq; s->rq = req->next; } return 0; }
1threat
Elixir - How do I split a string into a list by every 3 characters : <p>if I have the string <code>"UGGUGUUAUUAAUGGUUU"</code> how to I turn it into a list split up by every 3 characters into <code>["UGG", "UGU", "UAU", "UAA", "UGG", "UUU"]</code>?</p>
0debug
Speed up expensive IEnumerable<T> operation : <p>I am working on a C# library that recursively enumerates the subfolders of a remote share over the network. This is an expensive operation, and there may be thousands of folders to be traversed. The method that carries out this work for the client returns an <code>IEnumerable&lt;string&gt;</code>, and uses lazy evaluation (as is often the case with <code>IEnumerable&lt;T&gt;</code>, so the call itself returns very quickly, but then, when the client executes a <code>foreach</code> loop or a <code>Take()</code> call on the return value, things get pretty slow.</p> <p>I am looking for approaches to speed this up. Some ideas include:</p> <ol> <li>Avoid lazy enumeration by making my library retrieve all items and store them in a <code>List&lt;string&gt;</code>, for example, before it is returned to the client. This would make the method call much slower, but iteration much faster.</li> <li>Drop the functionality to enumerate all the subfolders, and require that the client specifies some kind of filter that limits the number of items to traverse.</li> <li>Use an altogether different method to enumerate folders which avoids <code>IEnumerable&lt;T&gt;</code>.</li> </ol> <p>I have run out of ideas. What approach would you suggest to make this work, and fast? Thank you.</p>
0debug
Get only Objects which get match from other Array of object : <p>I am having a two array of objects,</p> <pre><code>let list = [ { "currency": "Albania Lek", "abbreviation": "ALL", }, { "currency": "Afghanistan Afghani", "abbreviation": "AFN", }, { "currency": "Argentina Peso", "abbreviation": "ARS", }]; let c = [ { "value": "AFN" }, { "value": "ARS" }] let asd = list.filter(l=&gt;{ return l.abbreviation === c.forEach(x=&gt;x.sCurrencyName) }) </code></pre> <p>i want to return only those object from <code>list</code> which has value in Array of object <code>c</code></p>
0debug
PEM routines:PEM_read_bio:bad end line : <p>I'm trying to parse the developer certificate in embedded.mobileprovision file. Firstly I use</p> <p><code>security cms -D -i embedded.mobileprovision</code> </p> <p>to get the base64 developer certificate string. </p> <p>Then I split the string every 64 characters and stored in a file named dev.cer. </p> <p>Finally add <code>-----BEGIN CERTIFICATE-----</code> at the first line and <code>-----END CERTIFICATE-----</code> at the end of file. </p> <p>On my mac computer, I right click the dev.cer file and the developer informations are all there. However, When I use <code>openssl x509 -in dev.cer -text -noout</code>, error comes out:</p> <pre><code>unable to load certificate 69721:error:0906D066:PEM routines:PEM_read_bio:bad end line:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-64.50.6/src/crypto/pem/pem_lib.c:747: </code></pre> <p>The dev.cer file is following:</p> <pre><code>-----BEGIN CERTIFICATE----- MIIFljCCBH6gAwIBAgIIIP7GMO9cWzYwDQYJKoZIhvcNAQELBQAwgZYxCzAJBgNV BAYTAlVTMRMwEQYDVQQKDApBcHBsZSBJbmMuMSwwKgYDVQQLDCNBcHBsZSBXb3Js ZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczFEMEIGA1UEAww7QXBwbGUgV29ybGR3 aWRlIERldmVsb3BlciBSZWxhdGlvbnMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkw HhcNMTcwNDI5MDMzMDA4WhcNMTgwNDI5MDMzMDA4WjCBiTEaMBgGCgmSJomT8ixk AQEMCk1ENFA0UTg1WlExMzAxBgNVBAMMKmlQaG9uZSBEZXZlbG9wZXI6IGFtbW1p IGFtbW1pIChXM1BSS1JDVDRRKTETMBEGA1UECwwKVktRNTZVQ0c4ODEUMBIGA1UE CgwLYW1tbWkgYW1tbWkxCzAJBgNVBAYTAlVTMIIBIjANBgkqhkiG9w0BAQEFAAOC AQ8AMIIBCgKCAQEAwudboPuPnImOssBCw9vISRnnivreVwOuDAu77u47zIU8uTag bzktX6pF54YToSLQHeOaNNQfZ7idccU2DKVBr3etz/++ca4HNadeUaEm2VWW4kEq 3iKIo1wZZhJJR6bQl4q797U0+f7eEXLKD4fjfidEF+ceAxAsX5YIuokq3K/B+XW3 tKk7D4nCaaCyJ9/+aJkFKT/oOxWRD0NYi5vXpni/3Plj5Qu3kDGrTUQaGCXXjRrA E3mOVS4M2W5sFoOUpBxcfK7ajs+HUZNp0Gvb04OeD4O0lLTxcNu6omhG3MzOo81F T+bkdxLM7XkIbNlIjYhyxGRynpgAKmiR9B/oeQIDAQABo4IB8TCCAe0wPwYIKwYB BQUHAQEEMzAxMC8GCCsGAQUFBzABhiNodHRwOi8vb2NzcC5hcHBsZS5jb20vb2Nz cDAzLXd3ZHIwMTAdBgNVHQ4EFgQUF8T1dPnBmZfKfG0+lHtczMuGy9owDAYDVR0T AQH/BAIwADAfBgNVHSMEGDAWgBSIJxcJqbYYYIvs67r2R1nFUlSjtzCCAR0GA1Ud IASCARQwggEQMIIBDAYJKoZIhvdjZAUBMIH+MIHDBggrBgEFBQcCAjCBtgyBs1Jl bGlhbmNlIG9uIHRoaXMgY2VydGlmaWNhdGUgYnkgYW55IHBhcnR5IGFzc3VtZXMg YWNjZXB0YW5jZSBvZiB0aGUgdGhlbiBhcHBsaWNhYmxlIHN0YW5kYXJkIHRlcm1z IGFuZCBjb25kaXRpb25zIG9mIHVzZSwgY2VydGlmaWNhdGUgcG9saWN5IGFuZCBj ZXJ0aWZpY2F0aW9uIHByYWN0aWNlIHN0YXRlbWVudHMuMDYGCCsGAQUFBwIBFipo dHRwOi8vd3d3LmFwcGxlLmNvbS9jZXJ0aWZpY2F0ZWF1dGhvcml0eS8wDgYDVR0P AQH/BAQDAgeAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMDMBMGCiqGSIb3Y2QGAQIB Af8EAgUAMA0GCSqGSIb3DQEBCwUAA4IBAQA1//RUQ+hnCxfzSKO13qtuSb4IUrY5 bjkRKIAUlxN5aYVN5NIzCGxmahlDA/Rjw8MLVA8dWbT0QMSqx5IXC+Ov3JNZlkL0 5+RBuZEtZL7IZp0L3ZrCFtuizaunH9fZWbyFyfLACIYqZqP40N1+wIx1l4Es65Zu WSeDeQMutda8DpmtCJhrnod9B1vfvDc3FUSmbJbvkLFh2UCgqtE9moLYI8qFMzqe CQUJdPGdE+2WNv0wM8/cFIG/audSvEADKg1DgO+j6oP+urUe1gLsyzyv10J7/XA4 nmDuP1UNG7O7ADbdEOxhRiB96ZNwgcw9Q0wv9H9jMa+NNti6SxLud2+B -----END CERTIFICATE---- </code></pre> <p>By the way, I used online certificate decoder to decode dev.cer, it works well. Here is the url:</p> <pre><code>https://www.sslshopper.com/certificate-decoder.html </code></pre> <p>This site recommended to use openssl, but it failed.</p>
0debug
Why is grid span not being excepted for "blank1" in IE 11 : css grid issue: Third grid item "blank1" should row span and cover both row 1 and row 2 of column 3. But it is not working in IE 11. It is only covering the first row. Here is a link to the file online. Look at in in firefox and it will show what it is suppose to look like. IE 11 need fixing. https://www.survival-manual.com/test/test-ie.php .wrapper { display: -ms-grid; display: grid; -ms-grid-columns: 300px 300px 300px; grid-template-columns: 300px 300px 300px; -ms-grid-rows: 200px 200px 200px 200px; grid-template-rows: 200px 200px 200px 200px; background-color: #fff; } .wrapper > *:nth-child(1) { -ms-grid-row: 1; -ms-grid-column: 1; } .wrapper > *:nth-child(2) { -ms-grid-row: 1; -ms-grid-column: 2; } .wrapper > *:nth-child(3) { -ms-grid-row: 1; -ms-grid-column: 3; } .wrapper > *:nth-child(4) { -ms-grid-row: 2; -ms-grid-column: 1; } .wrapper > *:nth-child(5) { -ms-grid-row: 2; -ms-grid-column: 2; } .wrapper > *:nth-child(6) { -ms-grid-row: 2; -ms-grid-column: 3; } .wrapper > *:nth-child(7) { -ms-grid-row: 3; -ms-grid-column: 1; } .wrapper > *:nth-child(8) { -ms-grid-row: 3; -ms-grid-column: 2; } .wrapper > *:nth-child(9) { -ms-grid-row: 3; -ms-grid-column: 3; } .wrapper > *:nth-child(10) { -ms-grid-row: 4; -ms-grid-column: 1; } .wrapper > *:nth-child(11) { -ms-grid-row: 4; -ms-grid-column: 2; } .wrapper > *:nth-child(12) { -ms-grid-row: 4; -ms-grid-column: 3; } .box { background-color: #444; color: #fff; border-radius: 5px; padding: 20px; font-size: 150%; } .print { -ms-grid-column: 1; grid-column-start: 1; -ms-grid-column-span: 1; grid-column-end: 2; -ms-grid-row: 1; grid-row-start: 1; -ms-grid-row-span: 1; grid-row-end: 2; background-color:white; } .ad { -ms-grid-column: 2; grid-column-start: 2; -ms-grid-column-span: 1; grid-column-end: 3; -ms-grid-row: 1; grid-row-start: 1; -ms-grid-row-span: 1; grid-row-end: 2; background-color:234; } .blank1 { -ms-grid-column: 3; grid-column-start: 3; -ms-grid-column-span: 1; grid-column-end: 4; -ms-grid-row: 1; grid-row-start: 1; -ms-grid-row-span: 2; grid-row-end: 3; background-color:678; } .search { -ms-grid-column: 1; grid-column-start: 1; -ms-grid-column-span: 1; grid-column-end: 2; -ms-grid-row: 2; grid-row-start: 2; -ms-grid-row-span: 1; grid-row-end: 3; background-color:white; } .logo { -ms-grid-column: 2; grid-column-start: 2; -ms-grid-column-span: 1; grid-column-end: 3; -ms-grid-row: 2; grid-row-start: 2; -ms-grid-row-span: 1; grid-row-end: 3; background-color:678; } .menu { -ms-grid-column: 1; grid-column-start: 1; -ms-grid-column-span: 1; grid-column-end: 2; -ms-grid-row: 3; grid-row-start: 3; -ms-grid-row-span: 1; grid-row-end: 4; background-color:789; } .content { -ms-grid-column: 2; grid-column-start: 2; -ms-grid-column-span: 1; grid-column-end: 3; -ms-grid-row: 3; grid-row-start: 3; -ms-grid-row-span: 1; grid-row-end: 4; background-color:567; } .rightside { -ms-grid-column: 3; grid-column-start: 3; -ms-grid-column-span: 1; grid-column-end: 4; -ms-grid-row: 3; grid-row-start: 3; -ms-grid-row-span: 2; grid-row-end: 5; background-color:orange; } .blank2 { -ms-grid-column: 1; grid-column-start: 1; -ms-grid-column-span: 1; grid-column-end: 2; -ms-grid-row: 4; grid-row-start: 4; -ms-grid-row-span: 1; grid-row-end: 5; background-color:red; } .footer { -ms-grid-column: 2; grid-column-start: 2; -ms-grid-column-span: 1; grid-column-end: 3; -ms-grid-row: 4; grid-row-start: 4; -ms-grid-row-span: 1; grid-row-end: 5; background-color:289; } </style>
0debug
int attribute_align_arg sws_scale(struct SwsContext *c, const uint8_t * const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[]) { int i, ret; const uint8_t *src2[4] = { srcSlice[0], srcSlice[1], srcSlice[2], srcSlice[3] }; uint8_t *dst2[4] = { dst[0], dst[1], dst[2], dst[3] }; uint8_t *rgb0_tmp = NULL; if (srcSliceH == 0) return 0; if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) { av_log(c, AV_LOG_ERROR, "bad src image pointers\n"); return 0; } if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) { av_log(c, AV_LOG_ERROR, "bad dst image pointers\n"); return 0; } if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n"); return 0; } if (c->sliceDir == 0) { if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1; } if (usePal(c->srcFormat)) { for (i = 0; i < 256; i++) { int p, r, g, b, y, u, v, a = 0xff; if (c->srcFormat == AV_PIX_FMT_PAL8) { p = ((const uint32_t *)(srcSlice[1]))[i]; a = (p >> 24) & 0xFF; r = (p >> 16) & 0xFF; g = (p >> 8) & 0xFF; b = p & 0xFF; } else if (c->srcFormat == AV_PIX_FMT_RGB8) { r = ( i >> 5 ) * 36; g = ((i >> 2) & 7) * 36; b = ( i & 3) * 85; } else if (c->srcFormat == AV_PIX_FMT_BGR8) { b = ( i >> 6 ) * 85; g = ((i >> 3) & 7) * 36; r = ( i & 7) * 36; } else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) { r = ( i >> 3 ) * 255; g = ((i >> 1) & 3) * 85; b = ( i & 1) * 255; } else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) { r = g = b = i; } else { av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE); b = ( i >> 3 ) * 255; g = ((i >> 1) & 3) * 85; r = ( i & 1) * 255; } #define RGB2YUV_SHIFT 15 #define BY ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define BV (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define BU ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define GY ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define GV (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define GU (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define RY ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define RV ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define RU (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) y = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); c->pal_yuv[i]= y + (u<<8) + (v<<16) + (a<<24); switch (c->dstFormat) { case AV_PIX_FMT_BGR32: #if !HAVE_BIGENDIAN case AV_PIX_FMT_RGB24: #endif c->pal_rgb[i]= r + (g<<8) + (b<<16) + (a<<24); break; case AV_PIX_FMT_BGR32_1: #if HAVE_BIGENDIAN case AV_PIX_FMT_BGR24: #endif c->pal_rgb[i]= a + (r<<8) + (g<<16) + (b<<24); break; case AV_PIX_FMT_RGB32_1: #if HAVE_BIGENDIAN case AV_PIX_FMT_RGB24: #endif c->pal_rgb[i]= a + (b<<8) + (g<<16) + (r<<24); break; case AV_PIX_FMT_RGB32: #if !HAVE_BIGENDIAN case AV_PIX_FMT_BGR24: #endif default: c->pal_rgb[i]= b + (g<<8) + (r<<16) + (a<<24); } } } if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) { uint8_t *base; int x,y; rgb0_tmp = av_malloc(FFABS(srcStride[0]) * srcSliceH + 32); base = srcStride[0] < 0 ? rgb0_tmp - srcStride[0] * (srcSliceH-1) : rgb0_tmp; for (y=0; y<srcSliceH; y++){ memcpy(base + srcStride[0]*y, src2[0] + srcStride[0]*y, 4*c->srcW); for (x=c->src0Alpha-1; x<4*c->srcW; x+=4) { base[ srcStride[0]*y + x] = 0xFF; } } src2[0] = base; } if (c->sliceDir == 1) { int srcStride2[4] = { srcStride[0], srcStride[1], srcStride[2], srcStride[3] }; int dstStride2[4] = { dstStride[0], dstStride[1], dstStride[2], dstStride[3] }; reset_ptr(src2, c->srcFormat); reset_ptr((void*)dst2, c->dstFormat); if (srcSliceY + srcSliceH == c->srcH) c->sliceDir = 0; ret = c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst2, dstStride2); } else { int srcStride2[4] = { -srcStride[0], -srcStride[1], -srcStride[2], -srcStride[3] }; int dstStride2[4] = { -dstStride[0], -dstStride[1], -dstStride[2], -dstStride[3] }; src2[0] += (srcSliceH - 1) * srcStride[0]; if (!usePal(c->srcFormat)) src2[1] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[1]; src2[2] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[2]; src2[3] += (srcSliceH - 1) * srcStride[3]; dst2[0] += ( c->dstH - 1) * dstStride[0]; dst2[1] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[1]; dst2[2] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[2]; dst2[3] += ( c->dstH - 1) * dstStride[3]; reset_ptr(src2, c->srcFormat); reset_ptr((void*)dst2, c->dstFormat); if (!srcSliceY) c->sliceDir = 0; ret = c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH, srcSliceH, dst2, dstStride2); } av_free(rgb0_tmp); return ret; }
1threat
static int mjpegb_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { MJpegDecodeContext *s = avctx->priv_data; uint8_t *buf_end, *buf_ptr; AVFrame *picture = data; GetBitContext hgb; uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs; uint32_t field_size, sod_offs; buf_ptr = buf; buf_end = buf + buf_size; read_header: s->restart_interval = 0; s->restart_count = 0; s->mjpb_skiptosod = 0; init_get_bits(&hgb, buf_ptr, (buf_end - buf_ptr)*8); skip_bits(&hgb, 32); if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g')) { av_log(avctx, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n"); return 0; } field_size = get_bits_long(&hgb, 32); av_log(avctx, AV_LOG_DEBUG, "field size: 0x%x\n", field_size); skip_bits(&hgb, 32); second_field_offs = get_bits_long(&hgb, 32); av_log(avctx, AV_LOG_DEBUG, "second field offs: 0x%x\n", second_field_offs); if (second_field_offs) s->interlaced = 1; dqt_offs = get_bits_long(&hgb, 32); av_log(avctx, AV_LOG_DEBUG, "dqt offs: 0x%x\n", dqt_offs); if (dqt_offs) { init_get_bits(&s->gb, buf+dqt_offs, (buf_end - (buf+dqt_offs))*8); s->start_code = DQT; mjpeg_decode_dqt(s); } dht_offs = get_bits_long(&hgb, 32); av_log(avctx, AV_LOG_DEBUG, "dht offs: 0x%x\n", dht_offs); if (dht_offs) { init_get_bits(&s->gb, buf+dht_offs, (buf_end - (buf+dht_offs))*8); s->start_code = DHT; mjpeg_decode_dht(s); } sof_offs = get_bits_long(&hgb, 32); av_log(avctx, AV_LOG_DEBUG, "sof offs: 0x%x\n", sof_offs); if (sof_offs) { init_get_bits(&s->gb, buf+sof_offs, (buf_end - (buf+sof_offs))*8); s->start_code = SOF0; if (mjpeg_decode_sof(s) < 0) return -1; } sos_offs = get_bits_long(&hgb, 32); av_log(avctx, AV_LOG_DEBUG, "sos offs: 0x%x\n", sos_offs); sod_offs = get_bits_long(&hgb, 32); av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs); if (sos_offs) { init_get_bits(&s->gb, buf+sos_offs, field_size*8); s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16)); s->start_code = SOS; mjpeg_decode_sos(s); } if (s->interlaced) { s->bottom_field ^= 1; if (s->bottom_field && second_field_offs) { buf_ptr = buf + second_field_offs; second_field_offs = 0; goto read_header; } } *picture= s->picture; *data_size = sizeof(AVFrame); if(!s->lossless){ picture->quality= FFMAX(FFMAX(s->qscale[0], s->qscale[1]), s->qscale[2]); picture->qstride= 0; picture->qscale_table= s->qscale_table; memset(picture->qscale_table, picture->quality, (s->width+15)/16); if(avctx->debug & FF_DEBUG_QP) av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality); picture->quality*= FF_QP2LAMBDA; } return buf_ptr - buf; }
1threat
Why does Google say I need chrome to use my Yubico security key? : <p>Not sure if this is the right place to ask, but here goes. When I'm trying to sign into google, and it asks for my security key, it says that it can only be used in Chrome. This is a problem because my school only has internet explorer on the computers (bad, I know) and this makes it more annoying to sign in. Is there a workaround, and does anyone know why this is?</p> <p>(p.s. I have tried to find some info about this but nothing explains why it needs chrome, especially since when I trigger the key in microsoft word all it does it print some text)</p>
0debug
Getting metadata in EF Core: table and column mappings : <p>Looking to get metadata in EF Core, to work with the mappings of objects &amp; properties to database tables &amp; columns.</p> <p>These mappings are defined in the DBContext.cs OnModelCreating() method, mapping tables with .ToTable(), and columns via .Property.HasColumnName().</p> <p>But I don't see this metadata under the Entity Types returned by...</p> <pre><code>IEnumerable&lt;IEntityType&gt; entityTypes = [dbContext].Model.GetEntityTypes(); </code></pre> <p>Is this metadata available anywhere in EF Core?</p>
0debug
static void rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, int read_all) { RMContext *rm = s->priv_data; ByteIOContext *pb = &s->pb; char buf[256]; uint32_t version; int i; version = get_be32(pb); if (((version >> 16) & 0xff) == 3) { int64_t startpos = url_ftell(pb); for(i = 0; i < 14; i++) get_byte(pb); get_str8(pb, s->title, sizeof(s->title)); get_str8(pb, s->author, sizeof(s->author)); get_str8(pb, s->copyright, sizeof(s->copyright)); get_str8(pb, s->comment, sizeof(s->comment)); if ((startpos + (version & 0xffff)) >= url_ftell(pb) + 2) { get_byte(pb); get_str8(pb, buf, sizeof(buf)); if ((startpos + (version & 0xffff)) > url_ftell(pb)) url_fskip(pb, (version & 0xffff) + startpos - url_ftell(pb)); st->codec->sample_rate = 8000; st->codec->channels = 1; st->codec->codec_type = CODEC_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_RA_144; } else { int flavor, sub_packet_h, coded_framesize, sub_packet_size; get_be32(pb); get_be32(pb); get_be16(pb); get_be32(pb); flavor= get_be16(pb); rm->coded_framesize = coded_framesize = get_be32(pb); get_be32(pb); get_be32(pb); get_be32(pb); rm->sub_packet_h = sub_packet_h = get_be16(pb); st->codec->block_align= get_be16(pb); rm->sub_packet_size = sub_packet_size = get_be16(pb); get_be16(pb); if (((version >> 16) & 0xff) == 5) { get_be16(pb); get_be16(pb); get_be16(pb); } st->codec->sample_rate = get_be16(pb); get_be32(pb); st->codec->channels = get_be16(pb); if (((version >> 16) & 0xff) == 5) { get_be32(pb); buf[0] = get_byte(pb); buf[1] = get_byte(pb); buf[2] = get_byte(pb); buf[3] = get_byte(pb); buf[4] = 0; } else { get_str8(pb, buf, sizeof(buf)); get_str8(pb, buf, sizeof(buf)); st->codec->codec_type = CODEC_TYPE_AUDIO; if (!strcmp(buf, "dnet")) { st->codec->codec_id = CODEC_ID_AC3; } else if (!strcmp(buf, "28_8")) { st->codec->codec_id = CODEC_ID_RA_288; st->codec->extradata_size= 0; rm->audio_framesize = st->codec->block_align; st->codec->block_align = coded_framesize; rm->audiobuf = av_malloc(rm->audio_framesize * sub_packet_h); } else if (!strcmp(buf, "cook")) { int codecdata_length, i; get_be16(pb); get_byte(pb); if (((version >> 16) & 0xff) == 5) get_byte(pb); codecdata_length = get_be32(pb); if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){ av_log(s, AV_LOG_ERROR, "codecdata_length too large\n"); st->codec->codec_id = CODEC_ID_COOK; st->codec->extradata_size= codecdata_length; st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); for(i = 0; i < codecdata_length; i++) ((uint8_t*)st->codec->extradata)[i] = get_byte(pb); rm->audio_framesize = st->codec->block_align; st->codec->block_align = rm->sub_packet_size; rm->audiobuf = av_malloc(rm->audio_framesize * sub_packet_h); } else { st->codec->codec_id = CODEC_ID_NONE; pstrcpy(st->codec->codec_name, sizeof(st->codec->codec_name), buf); if (read_all) { get_byte(pb); get_byte(pb); get_byte(pb); get_str8(pb, s->title, sizeof(s->title)); get_str8(pb, s->author, sizeof(s->author)); get_str8(pb, s->copyright, sizeof(s->copyright)); get_str8(pb, s->comment, sizeof(s->comment));
1threat
Creating an empty nested list in python : <p>i'm trying to create an empty nested list in python. I have searched for information regarding nested list and most are usually nested lists that already has values in it. </p> <p>The reason I needed a nested list is because I have a set of items: Apple, Pears and Oranges. However, Each item has another list that consists of: ID, price, quantity. </p> <p>So what I'm planning is to: 1. Put all items into index 0,1,2 respectively. So, apple = [0], pears =[1], oranges =[2] 2. Create another nested list to put ID,price and quantity. So using apple as an example, I would do: apple[0][0].append(ID), apple[0][1].append(price), apple[0][2].append(quantity)</p> <p>Is it possible for nested list to work these way? Or is there any other way to create an empty nested list? By the way, the apple, pears and orange all have their own python code file, so I have to import the pears and orange python file into the apple python file. I would appreciate any help given. Thank You.</p> <p>Codes from apple.py:</p> <pre><code>fruits = [],[] fruits[0],[0].append("ID") fruits[0],[1].append("price") fruits[0],[2].append("quantity") </code></pre> <p>Codes from pears.py:</p> <pre><code>fruits = [],[] fruits[1],[0].append("ID") fruits[1],[1].append("price") fruits[1],[2].append("quantity") </code></pre>
0debug
How to parse JSON from the Invoke-WebRequest in PowerShell? : <p>When sending the GET request to the server, which uses self-signed certificate:</p> <pre><code>add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { return true; } } "@ [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy $RESPONSE=Invoke-WebRequest -Uri https://yadayada:8080/bla -Method GET echo $RESPONSE </code></pre> <p>I'm getting following Response:</p> <pre><code>StatusCode : 200 StatusDescription : OK Content : {123, 10, 108, 111...} RawContent : HTTP/1.1 200 OK Content-Length: 21 Date: Sat, 11 Jun 2016 10:11:03 GMT { flag:false } Headers : {[Content-Length, 21], [Date, Sat, 11 Jun 2016 10:11:03 GMT]} RawContentLength : 21 </code></pre> <p>Content contains some wired numbers, so I went after RawContent, how would I parse the JSON inside, ignoring headers? or is there a clean way to get Content from those numbers?</p>
0debug
How can i use scanf and if with strings (Very basic) : I just had my first class in c programing at college and i did this: #include <stdio.h> int main() { char answer='x'; printf("Should the crocodile eat the man? y/n "); scanf("%s",&answer); printf("%s",& answer); if(answer == 'y') {printf("the man is dead");} if(answer == 'n') {printf("the man still alive ");} } How can i do the same with strings instead of single charactes? i have tried many things but nothing works.
0debug
Getting unexpected behaviour with firefox web console, equality for undefined not working fine : <p>When trying to write following javascript code snippet in mozilla web console then getting following unexpected behaviour.Please refer below image.When I declared a variable x then the undefined check evaluated to true.But when I defined it as "var a" then I get a seemingly wrong answer.I have checked it for chrome it is working fine.Can please someone explain this obscure behaviour?</p> <p><a href="https://i.stack.imgur.com/S56rn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S56rn.png" alt="enter image description here"></a></p>
0debug
how to get image from directory and save the image into db using wpf? : i want get image from directory and insert into the database of SQL server,retrieve image from database of SQL server.
0debug
Connection reset by peer while running Apache Spark Job : <p>We have two HDP cluster's setup let's call them A and B. </p> <p><strong>CLUSTER A NODES</strong> : </p> <ul> <li>It contains a total of 20 commodity machines.</li> <li>There are 20 data nodes.</li> <li>As namenode HA is configured, there is one active and one standby namenode.</li> </ul> <p><strong>CLUSTER B NODES</strong> : </p> <ul> <li>It contains a total of 5 commodity machines.</li> <li>There are 5 datanodes.</li> <li>There is no HA configured and this cluster has one primary and one secondary namenode.</li> </ul> <p>We have three major components in our application that perform an ETL (Extract, Transform and Load) operation on incoming files. I will refer to these components as E,T and L respectively.</p> <p><strong>COMPONENT E CHARACTERISTICS</strong> : </p> <ul> <li>This component is an Apache Spark Job and it runs solely on Cluster B. </li> <li>It's job is to pick up files from a NAS storage and put them into HDFS in cluster B.</li> </ul> <p><strong>COMPONENT T CHARACTERISTICS</strong> : </p> <ul> <li>This component is also an Apache Spark Job and it runs on Cluster B.</li> <li>It's job is to pick up the files in HDFS written by component E, transform them and then write the transformed files to HDFS in cluster A.</li> </ul> <p><strong>COMPONENT L CHARACTERISTICS</strong> :</p> <ul> <li>This component is also an Apache Spark job and it runs solely on Cluster A.</li> <li>It's job is to pick up files written by Component T and load the data to Hive tables present in Cluster A.</li> </ul> <p>Component L is the gem among all of the three components and we have not faced any glitches in it. There were minor unexplained glitches in component E, but component T is the most troublesome one.</p> <p>Component E and T both make use of DFS client to communicate to the namenode.</p> <p>Following is an excerpt of the exception that we have observed intermittently while running component T : </p> <pre><code>clusterA.namenode.com/10.141.160.141:8020. Trying to fail over immediately. java.io.IOException: Failed on local exception: java.io.IOException: Connection reset by peer; Host Details : local host is: "clusterB.datanode.com"; destination host is: "clusterA.namenode.com":8020; at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:782) at org.apache.hadoop.ipc.Client.call(Client.java:1459) at org.apache.hadoop.ipc.Client.call(Client.java:1392) at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:229) at com.sun.proxy.$Proxy15.complete(Unknown Source) at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.complete(ClientNamenodeProtocolTranslatorPB.java:464) at sun.reflect.GeneratedMethodAccessor1240.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:258) at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:104) at com.sun.proxy.$Proxy16.complete(Unknown Source) at org.apache.hadoop.hdfs.DFSOutputStream.completeFile(DFSOutputStream.java:2361) at org.apache.hadoop.hdfs.DFSOutputStream.closeImpl(DFSOutputStream.java:2338) at org.apache.hadoop.hdfs.DFSOutputStream.close(DFSOutputStream.java:2303) at org.apache.hadoop.fs.FSDataOutputStream$PositionCache.close(FSDataOutputStream.java:72) at org.apache.hadoop.fs.FSDataOutputStream.close(FSDataOutputStream.java:106) at org.apache.hadoop.io.compress.CompressorStream.close(CompressorStream.java:109) at sun.nio.cs.StreamEncoder.implClose(StreamEncoder.java:320) at sun.nio.cs.StreamEncoder.close(StreamEncoder.java:149) at java.io.OutputStreamWriter.close(OutputStreamWriter.java:233) at com.abc.xyz.io.CounterWriter.close(CounterWriter.java:34) at com.abc.xyz.common.io.PathDataSink.close(PathDataSink.java:47) at com.abc.xyz.diamond.parse.map.node.AbstractOutputNode.finalise(AbstractOutputNode.java:142) at com.abc.xyz.diamond.parse.map.application.spark.node.SparkOutputNode.finalise(SparkOutputNode.java:239) at com.abc.xyz.diamond.parse.map.DiamondMapper.onParseComplete(DiamondMapper.java:1072) at com.abc.xyz.diamond.parse.decode.decoder.DiamondDecoder.parse(DiamondDecoder.java:956) at com.abc.xyz.parsing.functions.ProcessorWrapper.process(ProcessorWrapper.java:96) at com.abc.xyz.parser.FlumeEvent2AvroBytes.call(FlumeEvent2AvroBytes.java:131) at com.abc.xyz.parser.FlumeEvent2AvroBytes.call(FlumeEvent2AvroBytes.java:45) at org.apache.spark.api.java.JavaRDDLike$$anonfun$fn$1$1.apply(JavaRDDLike.scala:129) at org.apache.spark.api.java.JavaRDDLike$$anonfun$fn$1$1.apply(JavaRDDLike.scala:129) at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371) at scala.collection.Iterator$$anon$14.hasNext(Iterator.scala:388) at scala.collection.convert.Wrappers$IteratorWrapper.hasNext(Wrappers.scala:29) at com.abc.xyz.zzz.ParseFrameHolder$ToKafkaStream.call(ParseFrameHolder.java:123) at com.abc.xyz.zzz.ParseFrameHolder$ToKafkaStream.call(ParseFrameHolder.java:82) at org.apache.spark.api.java.JavaRDDLike$$anonfun$foreachPartition$1.apply(JavaRDDLike.scala:225) at org.apache.spark.api.java.JavaRDDLike$$anonfun$foreachPartition$1.apply(JavaRDDLike.scala:225) at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$35.apply(RDD.scala:927) at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$35.apply(RDD.scala:927) at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1882) at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1882) at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66) at org.apache.spark.scheduler.Task.run(Task.scala:89) at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:227) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.IOException: Connection reset by peer at sun.nio.ch.FileDispatcherImpl.read0(Native Method) at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) at sun.nio.ch.IOUtil.read(IOUtil.java:197) at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) at org.apache.hadoop.net.SocketInputStream$Reader.performIO(SocketInputStream.java:57) at org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:142) at org.apache.hadoop.net.SocketInputStream.read(SocketInputStream.java:161) at org.apache.hadoop.net.SocketInputStream.read(SocketInputStream.java:131) at java.io.FilterInputStream.read(FilterInputStream.java:133) at java.io.FilterInputStream.read(FilterInputStream.java:133) at org.apache.hadoop.ipc.Client$Connection$PingInputStream.read(Client.java:554) at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) at java.io.BufferedInputStream.read(BufferedInputStream.java:265) at java.io.DataInputStream.readInt(DataInputStream.java:387) at org.apache.hadoop.ipc.Client$Connection.receiveRpcResponse(Client.java:1116) at org.apache.hadoop.ipc.Client$Connection.run(Client.java:1011) </code></pre> <p>As mentioned, we face this exception very intermittently and when it does occur our application gets stuck causing us to restart it.</p> <p><strong>SOLUTIONS THAT WE TRIED :</strong></p> <ul> <li><p>Our first suspect was that we are overloading the active namenode in cluster A since component T does open a lot of DFS client in parallel and performs file operations on different files ( no issue of contention on same files ). In our effort to tackle this problem, we looked at two key parameters for the namenode <strong>dfs.namenode.handler.count</strong> and <strong>ipc.server.listen.queue.size</strong> and bumped the latter from 128 (default) to 1024.</p></li> <li><p>Unfortunately, the issue still persisted in component T. We started taking a different approach on the problem. We focused solely on finding the reason for the occurrence of Connection Reset By Peer. According to a lot of articles and stack exchange discussions, the problem is described as follows, <em>the <strong>RST</strong> flag has been set by the peer which results in an immediate termination of the connection</em>. In our case we identified that the peer was the namenode of cluster A. </p></li> <li><p>Keeping the RST flag in mind, I delved deep into understanding the internals of TCP communication only w.r.t. the reason of RST flag. </p></li> <li>Every socket in Linux distributions ( not BSD ) has two queue's associated with it namely, the accept and the backlog queue. </li> <li>During the TCP handshake process, all requests are kept in the backlog queue until ACK packets are received from the node that started to establish the connection. Once received, the request is transferred to the accept queue and the application that opened the socket can start receiving packets from the remote client.</li> <li>The size of the backlog queue is controlled by two kernel level parameters namely <strong>net.ipv4.tcp_max_syn_backlog</strong> and <strong>net.core.somaxconn</strong> whereas the application ( namenode in our case ) can request the kernel for queue size that it desires limited by an upper bound ( we believe the accept queue size is the queue size defined by <strong>ipc.server.listen.queue.size</strong> ).</li> <li>Also, another interesting thing to note here is that if the size of <strong>net.ipv4.tcp_max_syn_backlog</strong> is greater than <strong>net.core.somaxconn</strong>, then the value of the former is truncated to that of the latter. This claim is based upon Linux documentation and can be found at <a href="https://linux.die.net/man/2/listen" rel="noreferrer">https://linux.die.net/man/2/listen</a>.</li> <li><p>Coming back to the point, when the backlog fills up completely TCP behaves in two manners and this behaviour can also be controlled by a kernel parameter called <strong>net.ipv4.tcp_abort_on_overflow</strong>. This is by default set to 0 and causes kernel to drop any new SYN packets when the backlog is full, which in turn lets the sender resend SYN packets. When set to 1, the kernel will mark the RST flag in a packet and send it to the sender thus abruptly terminating the connection. </p></li> <li><p>We checked the value of the above mentioned kernel parameters and found out that <strong>net.core.somaxconn</strong> is set to 1024, <strong>net.ipv4.tcp_abort_on_overflow</strong> is set to 0 and <strong>net.ipv4.tcp_max_syn_backlog</strong> is set to 4096 across all the machines in both the clusters. </p></li> <li><p>The only suspect that we have left now are the switches that connect Cluster A to Cluster B because none of the machines in any of the cluster will ever set the RST flag as the parameter <strong>net.ipv4.tcp_abort_on_overflow</strong> is set to 0. </p></li> </ul> <p><strong>MY QUESTIONS</strong></p> <ul> <li>It is evident from HDFS documentation that DFS Client uses RPC to communicate with the namenode for performing file operations. Does every RPC call involves the establishment of a TCP connection to namenode?</li> <li>Does the parameter <strong>ipc.server.listen.queue.size</strong> define the length of accept queue of the socket at which namenode accepts RPC requests?</li> <li>Can the namenode implicitly close connections to DFS client when under heavy load thus making the kernel to send a packet with RST flag being set, even if the kernel parameter <strong>net.ipv4.tcp_abort_on_overflow</strong> is set to 0?</li> <li>Are L2 or L3 switches ( used for connecting the machines in our two clusters ) capable of setting the RST flag because they are not able to handle bursty traffics? </li> </ul> <p>Our next approach to this problem is to identify which machine or switch ( there is no router involved ) is setting the RST flag by analyzing the packets using tcpdump or wireshark. We will also bump the size of all the queues mentioned above to 4096 in order to effectively handle bursty traffic.</p> <p>The namenode logs show no sign of any exceptions except that the Namenode Connection Load as seen in Ambari peeked at certain points in time and not necessarily when the Connection Reset By Peer exception occured. </p> <p>To conclude, I wanted to know whether or not we are headed on the right track to solve this problem or are we just going hit a dead end?</p> <p><strong>P.S.</strong> I apologize for the content's length in my question. I wanted to present the entire context to the readers before asking for any help or suggestions. Thank you for your patience. </p>
0debug
Format date with "/" to "-" with javascript : <p>I have this Javascript function that takes X number of days and returns a date in the past</p> <pre><code> var GetDateInThePastFromDays = function (days) { var today = new Date(); _date = new Date(today.getFullYear(), today.getMonth(), today.getDate() - days); return _date.toLocaleDateString(); } </code></pre> <p>That works absolutely fine, but it returns the date as <code>06/01/2016</code> but I want it returned as <code>06-01-2016</code> but I can't seem to find out how to do it correctly.</p>
0debug
Visual studio code cmd error: Cannot be loaded because running scripts is disabled on this system : <p>Inside of visual studio code, I'm trying to execute a script.bat from the command line, but I'm getting the following error:</p> <blockquote> <p>File C:\Theses_Repo\train-cnn\environment\Scripts\activate.ps1 cannot be loaded because running scripts is disabled on this system.</p> </blockquote> <p>After reading <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6" rel="noreferrer">this</a> I tried to run the visual studio code in administrator mode, thinking that the problem was a matter of privileges. But the error is throwing anyway.</p>
0debug
def even_or_odd(N): l = len(N) if (N[l-1] =='0'or N[l-1] =='2'or N[l-1] =='4'or N[l-1] =='6'or N[l-1] =='8'or N[l-1] =='A'or N[l-1] =='C'or N[l-1] =='E'): return ("Even") else: return ("Odd")
0debug
Event isn't firing on click : <p>I have appended the following HTML to a Div called <code>videoList</code> but when I click the link it isn't firing the ajax call but it's going to the url defined in <code>href</code>. I have tried javascript void in href but still it's not firing the ajax on click. No error is present in console!</p> <pre><code> var newHtml = '&lt;div class="group-seemore"&gt;'; newHtml += '&lt;a class="ajax-cate-mobile" data-slug="' + res.category.slug + '" data-start="5" href="/blog/category/'+ res.category.slug +'" title=""&gt;'; newHtml += 'See more'; newHtml += '&lt;/a&gt;'; newHtml += '&lt;/div&gt;'; $('#videoList').append(newHtml); </code></pre> <p>Ajax:</p> <pre><code>$('.ajax-cate-mobile').click(function(e){ console.log('hi'); e.preventDefault(); var $this = $(this); var start = $this.parents('.blog-groups').find('.ajax-cate-mobile').data('start'); params.start = start; var newStart = start + 10; $this.parents('.blog-groups').find('.ajax-cate-mobile').data('start', newStart); $(this).style="border-bottom:1px solid #197B81"; var _loader = '&lt;div class="ajax-loader"&gt;&lt;img src="/images/ajax-loader.gif"&gt;&lt;/div&gt;'; //$('#videoList').empty().html(_loader); var cate_slug = $(this).attr('data-slug'); params.cate_slug = cate_slug; ajaxLoadVideoInMobile(params, $this); $('.submenu').fadeOut(); $('.ajax-loader').fadeOut(); }); </code></pre>
0debug
Pass parameters to Airflow Experimental REST api when creating dag run : <p>Looks like Airflow has an experimental REST api that allow users to create dag runs with https POST request. This is awesome. </p> <p>Is there a way to pass parameters via HTTP to the create dag run? Judging from the official docs, found <a href="https://airflow.apache.org/api.html" rel="noreferrer">here</a>, it would seem the answer is "no" but I'm hoping I'm wrong. </p>
0debug
Change the format of the returned data when selecting records. Flask : <p>In my flask application, in routes.py I get entries with specific fields of the <code>Location</code> model:</p> <pre><code>... location = db.session.query(Location.id, Location.name,Location.code, Location.id_parent).all() newLocat = list( location) print(str(newLocat)) ... </code></pre> <p>The format of the returned data is as follows:</p> <pre><code>[(1, 'Test1', 101, 0), (2, 'Test2', 202, 1)] </code></pre> <p>How to make the returned data format look like this?</p> <pre><code>[{'id': '1', 'name': 'Test1','code':101, 'id_parent': '0'}, {'id': '2', 'name': 'Test2','code':202, 'id_parent': '1'}] </code></pre>
0debug
Can't we do node creation using pointer to object in C++? : I was solving this problem on Linked List on hacker rank : https://www.hackerrank.com/challenges/insert-a-node-at-the-head-of-a-linked-list/ And got correct answer for the given code . Most of the code was prewritten ; I only had to complete the function insertNodeAtHead function (enclosed between the three stars) : #include <bits/stdc++.h> using namespace std; class SinglyLinkedListNode { public: int data; SinglyLinkedListNode *next; SinglyLinkedListNode(int node_data) { this->data = node_data; this->next = nullptr; } }; class SinglyLinkedList { public: SinglyLinkedListNode *head; SinglyLinkedListNode *tail; SinglyLinkedList() { this->head = nullptr; this->tail = nullptr; } }; void print_singly_linked_list(SinglyLinkedListNode* node, string sep, ofstream& fout) { while (node) { fout << node->data; node = node->next; if (node) { fout << sep; } } } void free_singly_linked_list(SinglyLinkedListNode* node) { while (node) { SinglyLinkedListNode* temp = node; node = node->next; free(temp); } } // Complete the insertNodeAtHead function below. /* * For your reference: * * SinglyLinkedListNode { * int data; * SinglyLinkedListNode* next; * }; * */ ***SinglyLinkedListNode* insertNodeAtHead(SinglyLinkedListNode* llist, int data) { SinglyLinkedListNode *nnode; nnode = new SinglyLinkedListNode(data); if(llist !=NULL) nnode->next=llist; return llist=nnode; }*** int main() { ofstream fout(getenv("OUTPUT_PATH")); SinglyLinkedList* llist = new SinglyLinkedList(); int llist_count; cin >> llist_count; cin.ignore(numeric_limits<streamsize>::max(), '\n'); for (int i = 0; i < llist_count; i++) { int llist_item; cin >> llist_item; cin.ignore(numeric_limits<streamsize>::max(), '\n'); SinglyLinkedListNode* llist_head = insertNodeAtHead(llist->head, llist_item); llist->head = llist_head; } print_singly_linked_list(llist->head, "\n", fout); fout << "\n"; free_singly_linked_list(llist->head); fout.close(); return 0; } I had to complete the insertNodeAtHead() function only . Rest all was already there. But when I tried to do it without using pointer nnode object( my identifier) of SinglyLinkedListNode class type(their predefined class) I get compilation error: #include <bits/stdc++.h> using namespace std; class SinglyLinkedListNode { public: int data; SinglyLinkedListNode * next; SinglyLinkedListNode(int node_data) { this - > data = node_data; this - > next = nullptr; } }; class SinglyLinkedList { public: SinglyLinkedListNode * head; SinglyLinkedListNode * tail; SinglyLinkedList() { this - > head = nullptr; this - > tail = nullptr; } }; void print_singly_linked_list(SinglyLinkedListNode * node, string sep, ofstream & fout) { while (node) { fout << node - > data; node = node - > next; if (node) { fout << sep; } } } void free_singly_linked_list(SinglyLinkedListNode * node) { while (node) { SinglyLinkedListNode * temp = node; node = node - > next; free(temp); } } // Complete the insertNodeAtHead function below. /* * For your reference: * * SinglyLinkedListNode { * int data; * SinglyLinkedListNode* next; * }; * */ ***SinglyLinkedListNode * insertNodeAtHead(SinglyLinkedListNode * llist, int data) { SinglyLinkedListNode nnode; nnode = new SinglyLinkedListNode(data); if (llist != NULL) nnode.next = llist; return llist = & nnode; }*** int main() { ofstream fout(getenv("OUTPUT_PATH")); SinglyLinkedList * llist = new SinglyLinkedList(); int llist_count; cin >> llist_count; cin.ignore(numeric_limits < streamsize > ::max(), '\n'); for (int i = 0; i < llist_count; i++) { int llist_item; cin >> llist_item; cin.ignore(numeric_limits < streamsize > ::max(), '\n'); SinglyLinkedListNode * llist_head = insertNodeAtHead(llist - > head, llist_item); llist - > head = llist_head; } print_singly_linked_list(llist - > head, "\n", fout); fout << "\n"; free_singly_linked_list(llist - > head); fout.close(); return 0; } **ERROR AFTER COMPILATION:** solution.cc: In function ‘SinglyLinkedListNode* insertNodeAtHead(SinglyLinkedListNode*, int)’: solution.cc:63:24: error: no matching function for call to ‘SinglyLinkedListNode::SinglyLinkedListNode()’ SinglyLinkedListNode nnode; ^~~~~ solution.cc:10:9: note: candidate: ‘SinglyLinkedListNode::SinglyLinkedListNode(int)’ SinglyLinkedListNode(int node_data) { ^~~~~~~~~~~~~~~~~~~~ solution.cc:10:9: note: candidate expects 1 argument, 0 provided solution.cc:5:7: note: candidate: ‘constexpr SinglyLinkedListNode::SinglyLinkedListNode(const SinglyLinkedListNode&)’ class SinglyLinkedListNode { ^~~~~~~~~~~~~~~~~~~~ solution.cc:5:7: note: candidate expects 1 argument, 0 provided solution.cc:5:7: note: candidate: ‘constexpr SinglyLinkedListNode::SinglyLinkedListNode(SinglyLinkedListNode&&)’ solution.cc:5:7: note: candidate expects 1 argument, 0 provided solution.cc:64:40: error: ambiguous overload for ‘operator=’ (operand types are ‘SinglyLinkedListNode’ and ‘SinglyLinkedListNode*’) nnode = new SinglyLinkedListNode(data); ^ solution.cc:5:7: note: candidate: ‘SinglyLinkedListNode& SinglyLinkedListNode::operator=(const SinglyLinkedListNode&)’ <near match> class SinglyLinkedListNode { ^~~~~~~~~~~~~~~~~~~~ solution.cc:5:7: note: conversion of argument 1 would be ill-formed: solution.cc:64:11: error: invalid user-defined conversion from ‘SinglyLinkedListNode*’ to ‘const SinglyLinkedListNode&’ [-fpermissive] nnode = new SinglyLinkedListNode(data); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ solution.cc:10:9: note: candidate is: ‘SinglyLinkedListNode::SinglyLinkedListNode(int)’ <near match> SinglyLinkedListNode(int node_data) { ^~~~~~~~~~~~~~~~~~~~ solution.cc:10:9: note: conversion of argument 1 would be ill-formed: solution.cc:64:11: error: invalid conversion from ‘SinglyLinkedListNode*’ to ‘int’ [-fpermissive] nnode = new SinglyLinkedListNode(data); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ solution.cc:64:11: error: invalid conversion from ‘SinglyLinkedListNode*’ to ‘int’ [-fpermissive] solution.cc:10:34: note: initializing argument 1 of ‘SinglyLinkedListNode::SinglyLinkedListNode(int)’ SinglyLinkedListNode(int node_data) { ~~~~^~~~~~~~~ solution.cc:5:7: note: candidate: ‘SinglyLinkedListNode& SinglyLinkedListNode::operator=(SinglyLinkedListNode&&)’ <near match> class SinglyLinkedListNode { ^~~~~~~~~~~~~~~~~~~~ solution.cc:5:7: note: conversion of argument 1 would be ill-formed: solution.cc:64:11: error: invalid user-defined conversion from ‘SinglyLinkedListNode*’ to ‘SinglyLinkedListNode&&’ [-fpermissive] nnode = new SinglyLinkedListNode(data); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ solution.cc:10:9: note: candidate is: ‘SinglyLinkedListNode::SinglyLinkedListNode(int)’ <near match> SinglyLinkedListNode(int node_data) { ^~~~~~~~~~~~~~~~~~~~ solution.cc:10:9: note: conversion of argument 1 would be ill-formed: solution.cc:64:11: error: invalid conversion from ‘SinglyLinkedListNode*’ to ‘int’ [-fpermissive] nnode = new SinglyLinkedListNode(data); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ solution.cc:64:11: error: invalid conversion from ‘SinglyLinkedListNode*’ to ‘int’ [-fpermissive] solution.cc:10:34: note: initializing argument 1 of ‘SinglyLinkedListNode::SinglyLinkedListNode(int)’ SinglyLinkedListNode(int node_data) { ~~~~^~~~~~~~~ solution.cc:64:40: error: conversion to non-const reference type ‘class SinglyLinkedListNode&&’ from rvalue of type ‘SinglyLinkedListNode’ [-fpermissive] nnode = new SinglyLinkedListNode(data); Exit Status 255 ***I firmly believed that it should have worked but it didn't happen so. Since the logic was same , the only difference was I used pointer to create the object.*** Since I am new to C++ I am unable to figure out why is this happening. Please give an insight.
0debug
static void super2xsai(AVFilterContext *ctx, uint8_t *src, int src_linesize, uint8_t *dst, int dst_linesize, int width, int height) { Super2xSaIContext *sai = ctx->priv; unsigned int x, y; uint32_t color[4][4]; unsigned char *src_line[4]; const int bpp = sai->bpp; const uint32_t hi_pixel_mask = sai->hi_pixel_mask; const uint32_t lo_pixel_mask = sai->lo_pixel_mask; const uint32_t q_hi_pixel_mask = sai->q_hi_pixel_mask; const uint32_t q_lo_pixel_mask = sai->q_lo_pixel_mask; src_line[0] = src; src_line[1] = src; src_line[2] = src + src_linesize*FFMIN(1, height-1); src_line[3] = src + src_linesize*FFMIN(2, height-1); #define READ_COLOR4(dst, src_line, off) dst = *((const uint32_t *)src_line + off) #define READ_COLOR3(dst, src_line, off) dst = AV_RL24 (src_line + 3*off) #define READ_COLOR2(dst, src_line, off) dst = *((const uint16_t *)src_line + off) switch (bpp) { case 4: READ_COLOR4(color[0][0], src_line[0], 0); color[0][1] = color[0][0]; READ_COLOR4(color[0][2], src_line[0], 1); READ_COLOR4(color[0][3], src_line[0], 2); READ_COLOR4(color[1][0], src_line[1], 0); color[1][1] = color[1][0]; READ_COLOR4(color[1][2], src_line[1], 1); READ_COLOR4(color[1][3], src_line[1], 2); READ_COLOR4(color[2][0], src_line[2], 0); color[2][1] = color[2][0]; READ_COLOR4(color[2][2], src_line[2], 1); READ_COLOR4(color[2][3], src_line[2], 2); READ_COLOR4(color[3][0], src_line[3], 0); color[3][1] = color[3][0]; READ_COLOR4(color[3][2], src_line[3], 1); READ_COLOR4(color[3][3], src_line[3], 2); break; case 3: READ_COLOR3(color[0][0], src_line[0], 0); color[0][1] = color[0][0]; READ_COLOR3(color[0][2], src_line[0], 1); READ_COLOR3(color[0][3], src_line[0], 2); READ_COLOR3(color[1][0], src_line[1], 0); color[1][1] = color[1][0]; READ_COLOR3(color[1][2], src_line[1], 1); READ_COLOR3(color[1][3], src_line[1], 2); READ_COLOR3(color[2][0], src_line[2], 0); color[2][1] = color[2][0]; READ_COLOR3(color[2][2], src_line[2], 1); READ_COLOR3(color[2][3], src_line[2], 2); READ_COLOR3(color[3][0], src_line[3], 0); color[3][1] = color[3][0]; READ_COLOR3(color[3][2], src_line[3], 1); READ_COLOR3(color[3][3], src_line[3], 2); break; default: READ_COLOR2(color[0][0], src_line[0], 0); color[0][1] = color[0][0]; READ_COLOR2(color[0][2], src_line[0], 1); READ_COLOR2(color[0][3], src_line[0], 2); READ_COLOR2(color[1][0], src_line[1], 0); color[1][1] = color[1][0]; READ_COLOR2(color[1][2], src_line[1], 1); READ_COLOR2(color[1][3], src_line[1], 2); READ_COLOR2(color[2][0], src_line[2], 0); color[2][1] = color[2][0]; READ_COLOR2(color[2][2], src_line[2], 1); READ_COLOR2(color[2][3], src_line[2], 2); READ_COLOR2(color[3][0], src_line[3], 0); color[3][1] = color[3][0]; READ_COLOR2(color[3][2], src_line[3], 1); READ_COLOR2(color[3][3], src_line[3], 2); } for (y = 0; y < height; y++) { uint8_t *dst_line[2]; dst_line[0] = dst + dst_linesize*2*y; dst_line[1] = dst + dst_linesize*(2*y+1); for (x = 0; x < width; x++) { uint32_t product1a, product1b, product2a, product2b; if (color[2][1] == color[1][2] && color[1][1] != color[2][2]) { product2b = color[2][1]; product1b = product2b; } else if (color[1][1] == color[2][2] && color[2][1] != color[1][2]) { product2b = color[1][1]; product1b = product2b; } else if (color[1][1] == color[2][2] && color[2][1] == color[1][2]) { int r = 0; r += GET_RESULT(color[1][2], color[1][1], color[1][0], color[3][1]); r += GET_RESULT(color[1][2], color[1][1], color[2][0], color[0][1]); r += GET_RESULT(color[1][2], color[1][1], color[3][2], color[2][3]); r += GET_RESULT(color[1][2], color[1][1], color[0][2], color[1][3]); if (r > 0) product1b = color[1][2]; else if (r < 0) product1b = color[1][1]; else product1b = INTERPOLATE(color[1][1], color[1][2]); product2b = product1b; } else { if (color[1][2] == color[2][2] && color[2][2] == color[3][1] && color[2][1] != color[3][2] && color[2][2] != color[3][0]) product2b = Q_INTERPOLATE(color[2][2], color[2][2], color[2][2], color[2][1]); else if (color[1][1] == color[2][1] && color[2][1] == color[3][2] && color[3][1] != color[2][2] && color[2][1] != color[3][3]) product2b = Q_INTERPOLATE(color[2][1], color[2][1], color[2][1], color[2][2]); else product2b = INTERPOLATE(color[2][1], color[2][2]); if (color[1][2] == color[2][2] && color[1][2] == color[0][1] && color[1][1] != color[0][2] && color[1][2] != color[0][0]) product1b = Q_INTERPOLATE(color[1][2], color[1][2], color[1][2], color[1][1]); else if (color[1][1] == color[2][1] && color[1][1] == color[0][2] && color[0][1] != color[1][2] && color[1][1] != color[0][3]) product1b = Q_INTERPOLATE(color[1][2], color[1][1], color[1][1], color[1][1]); else product1b = INTERPOLATE(color[1][1], color[1][2]); } if (color[1][1] == color[2][2] && color[2][1] != color[1][2] && color[1][0] == color[1][1] && color[1][1] != color[3][2]) product2a = INTERPOLATE(color[2][1], color[1][1]); else if (color[1][1] == color[2][0] && color[1][2] == color[1][1] && color[1][0] != color[2][1] && color[1][1] != color[3][0]) product2a = INTERPOLATE(color[2][1], color[1][1]); else product2a = color[2][1]; if (color[2][1] == color[1][2] && color[1][1] != color[2][2] && color[2][0] == color[2][1] && color[2][1] != color[0][2]) product1a = INTERPOLATE(color[2][1], color[1][1]); else if (color[1][0] == color[2][1] && color[2][2] == color[2][1] && color[2][0] != color[1][1] && color[2][1] != color[0][0]) product1a = INTERPOLATE(color[2][1], color[1][1]); else product1a = color[1][1]; switch (bpp) { case 4: AV_WN32A(dst_line[0] + x * 8, product1a); AV_WN32A(dst_line[0] + x * 8 + 4, product1b); AV_WN32A(dst_line[1] + x * 8, product2a); AV_WN32A(dst_line[1] + x * 8 + 4, product2b); break; case 3: AV_WL24(dst_line[0] + x * 6, product1a); AV_WL24(dst_line[0] + x * 6 + 3, product1b); AV_WL24(dst_line[1] + x * 6, product2a); AV_WL24(dst_line[1] + x * 6 + 3, product2b); break; default: AV_WN32A(dst_line[0] + x * 4, product1a | (product1b << 16)); AV_WN32A(dst_line[1] + x * 4, product2a | (product2b << 16)); } color[0][0] = color[0][1]; color[0][1] = color[0][2]; color[0][2] = color[0][3]; color[1][0] = color[1][1]; color[1][1] = color[1][2]; color[1][2] = color[1][3]; color[2][0] = color[2][1]; color[2][1] = color[2][2]; color[2][2] = color[2][3]; color[3][0] = color[3][1]; color[3][1] = color[3][2]; color[3][2] = color[3][3]; if (x < width - 3) { x += 3; switch (bpp) { case 4: READ_COLOR4(color[0][3], src_line[0], x); READ_COLOR4(color[1][3], src_line[1], x); READ_COLOR4(color[2][3], src_line[2], x); READ_COLOR4(color[3][3], src_line[3], x); break; case 3: READ_COLOR3(color[0][3], src_line[0], x); READ_COLOR3(color[1][3], src_line[1], x); READ_COLOR3(color[2][3], src_line[2], x); READ_COLOR3(color[3][3], src_line[3], x); break; default: READ_COLOR2(color[0][3], src_line[0], x); READ_COLOR2(color[1][3], src_line[1], x); READ_COLOR2(color[2][3], src_line[2], x); READ_COLOR2(color[3][3], src_line[3], x); } x -= 3; } } src_line[0] = src_line[1]; src_line[1] = src_line[2]; src_line[2] = src_line[3]; src_line[3] = src_line[2]; if (y < height - 3) src_line[3] += src_linesize; switch (bpp) { case 4: READ_COLOR4(color[0][0], src_line[0], 0); color[0][1] = color[0][0]; READ_COLOR4(color[0][2], src_line[0], 1); READ_COLOR4(color[0][3], src_line[0], 2); READ_COLOR4(color[1][0], src_line[1], 0); color[1][1] = color[1][0]; READ_COLOR4(color[1][2], src_line[1], 1); READ_COLOR4(color[1][3], src_line[1], 2); READ_COLOR4(color[2][0], src_line[2], 0); color[2][1] = color[2][0]; READ_COLOR4(color[2][2], src_line[2], 1); READ_COLOR4(color[2][3], src_line[2], 2); READ_COLOR4(color[3][0], src_line[3], 0); color[3][1] = color[3][0]; READ_COLOR4(color[3][2], src_line[3], 1); READ_COLOR4(color[3][3], src_line[3], 2); break; case 3: READ_COLOR3(color[0][0], src_line[0], 0); color[0][1] = color[0][0]; READ_COLOR3(color[0][2], src_line[0], 1); READ_COLOR3(color[0][3], src_line[0], 2); READ_COLOR3(color[1][0], src_line[1], 0); color[1][1] = color[1][0]; READ_COLOR3(color[1][2], src_line[1], 1); READ_COLOR3(color[1][3], src_line[1], 2); READ_COLOR3(color[2][0], src_line[2], 0); color[2][1] = color[2][0]; READ_COLOR3(color[2][2], src_line[2], 1); READ_COLOR3(color[2][3], src_line[2], 2); READ_COLOR3(color[3][0], src_line[3], 0); color[3][1] = color[3][0]; READ_COLOR3(color[3][2], src_line[3], 1); READ_COLOR3(color[3][3], src_line[3], 2); break; default: READ_COLOR2(color[0][0], src_line[0], 0); color[0][1] = color[0][0]; READ_COLOR2(color[0][2], src_line[0], 1); READ_COLOR2(color[0][3], src_line[0], 2); READ_COLOR2(color[1][0], src_line[1], 0); color[1][1] = color[1][0]; READ_COLOR2(color[1][2], src_line[1], 1); READ_COLOR2(color[1][3], src_line[1], 2); READ_COLOR2(color[2][0], src_line[2], 0); color[2][1] = color[2][0]; READ_COLOR2(color[2][2], src_line[2], 1); READ_COLOR2(color[2][3], src_line[2], 2); READ_COLOR2(color[3][0], src_line[3], 0); color[3][1] = color[3][0]; READ_COLOR2(color[3][2], src_line[3], 1); READ_COLOR2(color[3][3], src_line[3], 2); } } }
1threat
Unable to perform php in command line : <p>I am new to php scripting and been following a tutorial video. I'm getting an error on trying to output an array from php via command line, this is the code named as array1.php:</p> <pre><code>&lt;? # Canada, USA, Mexico $arr1 = array("Toronto", "Ottawa", "Montreal", "Quebec"); $arr2 = array("Boston", "New York", "Santa Barbara", "San Francisco"); $arr3 = array("Mexico City", "Cozumel", "Cancun", "Aculpoco"); # array 4 is an associative array $arr4 = array("Canada" =&gt; $arr1, "USA" =&gt; $arr2, "Mexico" =&gt; $arr3); print_r($arr4); ?&gt; </code></pre> <p>The tutorial video says I'll just need to follow the instructions/code and perform "php array1.php" but getting this:</p> <pre><code>$ php array1.php &lt;? # Canada, USA, Mexico $arr1 = array("Toronto", "Ottawa", "Montreal", "Quebec"); $arr2 = array("Boston", "New York", "Santa Barbara", "San Francisco"); $arr3 = array("Mexico City", "Cozumel", "Cancun", "Aculpoco"); # array 4 is an associative array $arr4 = array("Canada" =&gt; $arr1, "USA" =&gt; $arr2, "Mexico" =&gt; $arr3); print_r($arr4); ?&gt; </code></pre>
0debug
void HELPER(set_cp15)(CPUARMState *env, uint32_t insn, uint32_t val) { int op1; int op2; int crm; op1 = (insn >> 21) & 7; op2 = (insn >> 5) & 7; crm = insn & 0xf; switch ((insn >> 16) & 0xf) { case 0: if (arm_feature(env, ARM_FEATURE_XSCALE)) break; if (arm_feature(env, ARM_FEATURE_OMAPCP)) break; if (arm_feature(env, ARM_FEATURE_V7) && op1 == 2 && crm == 0 && op2 == 0) { env->cp15.c0_cssel = val & 0xf; break; } goto bad_reg; case 1: if (arm_feature(env, ARM_FEATURE_V7) && op1 == 0 && crm == 1 && op2 == 0) { env->cp15.c1_scr = val; break; } if (arm_feature(env, ARM_FEATURE_OMAPCP)) op2 = 0; switch (op2) { case 0: if (!arm_feature(env, ARM_FEATURE_XSCALE) || crm == 0) env->cp15.c1_sys = val; tlb_flush(env, 1); break; case 1: if (arm_feature(env, ARM_FEATURE_XSCALE)) { env->cp15.c1_xscaleauxcr = val; break; } break; case 2: if (arm_feature(env, ARM_FEATURE_XSCALE)) goto bad_reg; if (env->cp15.c1_coproc != val) { env->cp15.c1_coproc = val; tb_flush(env); } break; default: goto bad_reg; } break; case 4: goto bad_reg; case 6: if (arm_feature(env, ARM_FEATURE_MPU)) { if (crm >= 8) goto bad_reg; env->cp15.c6_region[crm] = val; } else { if (arm_feature(env, ARM_FEATURE_OMAPCP)) op2 = 0; switch (op2) { case 0: env->cp15.c6_data = val; break; case 1: case 2: env->cp15.c6_insn = val; break; default: goto bad_reg; } } break; case 7: env->cp15.c15_i_max = 0x000; env->cp15.c15_i_min = 0xff0; if (op1 != 0) { goto bad_reg; } break; case 9: if (arm_feature(env, ARM_FEATURE_OMAPCP)) break; if (arm_feature(env, ARM_FEATURE_STRONGARM)) break; switch (crm) { case 0: switch (op1) { case 0: switch (op2) { case 0: env->cp15.c9_data = val; break; case 1: env->cp15.c9_insn = val; break; default: goto bad_reg; } break; case 1: break; default: goto bad_reg; } break; case 1: goto bad_reg; default: goto bad_reg; } break; case 12: goto bad_reg; } return; bad_reg: cpu_abort(env, "Unimplemented cp15 register write (c%d, c%d, {%d, %d})\n", (insn >> 16) & 0xf, crm, op1, op2); }
1threat
How did a vector became a matrix? : So i found this code on the internet but as i'm not that familiar with C++ i found difficult to understand this: how does a vector suddenly becomes a matrix? thanks! :) int main(){ int n; string v[MAX]; cin >> n; for(int i=0;i<n;i++) cin >> v[i]; for(int i=0;i<n-1;i++){ int y1,y2; y1=v[i].size(); y2=v[i+1].size(); for(int j=0; j<y1 && j<y2 ;j++) if(v[i][j]!=v[i+1][j]){ // here <- int x1,x2; x1=(int) v[i][j]-'A'; x2=(int) v[i+1][j] - 'A'; m[x1][0]=true; m[x2][0]=true; m[x1][x2+1]=true; break; } }
0debug
merge sort infinite recursion : I'm learning Ruby and algorithms at the current moment an would like some guidance in solving this issue that has arise. I haven't started the merge process yet. So far I've only focused on dividing the array over and over again until only 1 number is left in the array. Below is my code showing how I implemented this so far. My problem is the loop will not break and I'm unsure why. I'm hoping someone can point me in the right direction as to what I'm missing. I'm also open to resources to help me solve this problem better. def mergesort(list) mid = list.length / 2 left = list[0, mid] right = list[mid, list.size] until left.size <= 1 || right.size <= 1 do test(mergesort(left), mergesort(right)) end print left print right def test(left, right) sorted = [] left.length / 2 right.length / 2 # print sorted end end
0debug
How can I update ASP.NET Core app over an existing/running site without stopping the web server? : <p>We have an ASP.NET Core site running on our test server that we would like to auto-deploy by XCopy to our IIS web server as we do our current apps, where I already have the site running. I've added a publish profile that packages the site to a "publish-local" directory within the solution. Whenever I try to copy over the existing site, all DLLs are being used by another process, presumably Kestrel, so I am forced to deploy to a sibling directory and re-map IIS to look at the sibling. How does one update a running ASP.NET Core site without having to manually intervene and stop either the Kestrel or IIS web servers?</p>
0debug
java return statement not returning : Why does the code below return -1 instead of arr.length-1? If the find function is looking for 24 it should return 5, but returns -1. It should only return -1 if n is not found in arr. Thanks for your help. public class linearArraySearch { public static void main(String[] args) { int[] numbers = new int[]{ 12, 42, 56, 7, 99, 24, 6, 1, 5 }; System.out.println( find(numbers, 24) ); } public static int find( int[] arr, int n ){ if( arr[arr.length-1] == n ){ return arr.length-1; }else if( arr.length > 1 && arr[arr.length-1] != n ){ int[] temp = new int[arr.length-1]; for( int i = 0; i < temp.length; i++ ){ temp[i] = arr[i]; } find( temp, n ); } return -1; } }
0debug
static void init_vlcs(FourXContext *f){ static int done = 0; int i; if (!done) { done = 1; for(i=0; i<4; i++){ init_vlc(&block_type_vlc[i], BLOCK_TYPE_VLC_BITS, 7, &block_type_tab[i][0][1], 2, 1, &block_type_tab[i][0][0], 2, 1); } } }
1threat
what method does the computer use to add unsigned integers : int main(){ unsigned int num1; unsigned int num2; unsigned int sum = num1 + num2; cout << hex << sum; } If i have two unsigned integers say num1 and num2. And then I tell the computer to unsigned int sum = num1 + num2; What method does the computer use to add them, would it be two's complement. Would the sum variable be printed in two's complement.
0debug
How do I create react-router v4 breadcrumbs? : <p>How do I create react-router v4 breadcrumbs? I tried asking this question on the react-router V4 website via an issue ticket. They just said to see the <a href="https://reacttraining.com/react-router/examples/recursive-paths" rel="noreferrer">recursive paths</a> example. I really want to create it in <a href="http://react.semantic-ui.com" rel="noreferrer">semantic-ui-react</a></p>
0debug
<%= %> cannot be connected with equals() : <%= %> cannot be connected with equals(). I am making JSP & Servlet app. Now I wrote in JSP file like <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-css --> <table> <tbody> <tr> <td><%= item.getName() %></td> </tr> <tr> <td> <% if(request.getAttribute("code").equals.new(<%= item.getCode() %>)){ %> <input type="submit" value="Click" onclick="JavaScript:Submit(<%= item.getCode() %>,<%= item.getCount() %>);" <% if(request.getAttribute("count") != null){ if(request.getAttribute("count").equals("0")){ %> disabled <% } } %> <!-- end snippet --> But,<% if(request.getAttribute("code").equals.new(<%= item.getCode() %>)) has too much errors,so this grammer is wrong. But I do not know how to fix.I wanna know how to connected with equals() & <%= %>.
0debug
START_TEST(qobject_to_qdict_test) { fail_unless(qobject_to_qdict(QOBJECT(tests_dict)) == tests_dict); }
1threat
static int mp3_read_probe(AVProbeData *p) { int max_frames, first_frames; int fsize, frames, sample_rate; uint32_t header; uint8_t *buf, *buf2, *end; AVCodecContext avctx; if(id3v2_match(p->buf)) return AVPROBE_SCORE_MAX/2+1; max_frames = 0; buf = p->buf; end = buf + FFMIN(4096, p->buf_size - sizeof(uint32_t)); for(; buf < end; buf++) { buf2 = buf; for(frames = 0; buf2 < end; frames++) { header = AV_RB32(buf2); fsize = ff_mpa_decode_header(&avctx, header, &sample_rate); if(fsize < 0) break; buf2 += fsize; } max_frames = FFMAX(max_frames, frames); if(buf == p->buf) first_frames= frames; } if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1; else if(max_frames>=3) return AVPROBE_SCORE_MAX/4; else if(max_frames>=1) return 1; else return 0; }
1threat
Python converting data frame to comma separated rows : <p>I have a pandas dataframe, call it df with 2 columns:</p> <pre><code> user_id result --------- --------- 12 0 233 1 189 0 </code></pre> <p>And so forth. Is there an easy way to write this data frame out to a text file (with column headers removed) that just has comma-separated rows, i.e.,</p> <pre><code>12, 0 233, 1 189, 0 </code></pre> <p>Thanks.</p>
0debug
int qemu_savevm_state(QEMUFile *f) { int saved_vm_running; int ret; saved_vm_running = vm_running; vm_stop(0); ret = qemu_savevm_state_begin(f); if (ret < 0) goto out; do { ret = qemu_savevm_state_iterate(f); if (ret < 0) goto out; } while (ret == 0); ret = qemu_savevm_state_complete(f); out: if (saved_vm_running) vm_start(); return ret; }
1threat
Error running: Project has no JDK configured in IntelliJ IDEA Ultimate : <p>When I try to execute program ergo, it gives me an error. </p> <p><strong>Error running: Project has no JDK configured</strong></p> <p>Can anybody help me? I'm newbie in IntelliJ IDEA.</p>
0debug
static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt) { ASFContext *asf = s->priv_data; ASFStream *asf_st = 0; for (;;) { int ret; if(pb->eof_reached) return AVERROR_EOF; if (asf->packet_size_left < FRAME_HEADER_SIZE || asf->packet_segments < 1) { int ret = asf->packet_size_left + asf->packet_padsize; assert(ret>=0); avio_skip(pb, ret); asf->packet_pos= avio_tell(pb); if (asf->data_object_size != (uint64_t)-1 && (asf->packet_pos - asf->data_object_offset >= asf->data_object_size)) return AVERROR_EOF; return 1; } if (asf->packet_time_start == 0) { if(asf_read_frame_header(s, pb) < 0){ asf->packet_segments= 0; continue; } if (asf->stream_index < 0 || s->streams[asf->stream_index]->discard >= AVDISCARD_ALL || (!asf->packet_key_frame && s->streams[asf->stream_index]->discard >= AVDISCARD_NONKEY) ) { asf->packet_time_start = 0; avio_skip(pb, asf->packet_frag_size); asf->packet_size_left -= asf->packet_frag_size; if(asf->stream_index < 0) av_log(s, AV_LOG_ERROR, "ff asf skip %d (unknown stream)\n", asf->packet_frag_size); continue; } asf->asf_st = s->streams[asf->stream_index]->priv_data; } asf_st = asf->asf_st; if (asf->packet_replic_size == 1) { asf->packet_frag_timestamp = asf->packet_time_start; asf->packet_time_start += asf->packet_time_delta; asf->packet_obj_size = asf->packet_frag_size = avio_r8(pb); asf->packet_size_left--; asf->packet_multi_size--; if (asf->packet_multi_size < asf->packet_obj_size) { asf->packet_time_start = 0; avio_skip(pb, asf->packet_multi_size); asf->packet_size_left -= asf->packet_multi_size; continue; } asf->packet_multi_size -= asf->packet_obj_size; } if( asf_st->frag_offset + asf->packet_frag_size <= asf_st->pkt.size && asf_st->frag_offset + asf->packet_frag_size > asf->packet_obj_size){ av_log(s, AV_LOG_INFO, "ignoring invalid packet_obj_size (%d %d %d %d)\n", asf_st->frag_offset, asf->packet_frag_size, asf->packet_obj_size, asf_st->pkt.size); asf->packet_obj_size= asf_st->pkt.size; } if ( asf_st->pkt.size != asf->packet_obj_size || asf_st->frag_offset + asf->packet_frag_size > asf_st->pkt.size) { if(asf_st->pkt.data){ av_log(s, AV_LOG_INFO, "freeing incomplete packet size %d, new %d\n", asf_st->pkt.size, asf->packet_obj_size); asf_st->frag_offset = 0; av_free_packet(&asf_st->pkt); } av_new_packet(&asf_st->pkt, asf->packet_obj_size); asf_st->seq = asf->packet_seq; asf_st->pkt.dts = asf->packet_frag_timestamp - asf->hdr.preroll; asf_st->pkt.stream_index = asf->stream_index; asf_st->pkt.pos = asf_st->packet_pos= asf->packet_pos; if (asf_st->pkt.data && asf_st->palette_changed) { uint8_t *pal; pal = av_packet_new_side_data(&asf_st->pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); if (!pal) { av_log(s, AV_LOG_ERROR, "Cannot append palette to packet\n"); } else { memcpy(pal, asf_st->palette, AVPALETTE_SIZE); asf_st->palette_changed = 0; } } if (s->streams[asf->stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO) asf->packet_key_frame = 1; if (asf->packet_key_frame) asf_st->pkt.flags |= AV_PKT_FLAG_KEY; } asf->packet_size_left -= asf->packet_frag_size; if (asf->packet_size_left < 0) continue; if( asf->packet_frag_offset >= asf_st->pkt.size || asf->packet_frag_size > asf_st->pkt.size - asf->packet_frag_offset){ av_log(s, AV_LOG_ERROR, "packet fragment position invalid %u,%u not in %u\n", asf->packet_frag_offset, asf->packet_frag_size, asf_st->pkt.size); continue; } ret = avio_read(pb, asf_st->pkt.data + asf->packet_frag_offset, asf->packet_frag_size); if (ret != asf->packet_frag_size) { if (ret < 0 || asf->packet_frag_offset + ret == 0) return ret < 0 ? ret : AVERROR_EOF; if (asf_st->ds_span > 1) { memset(asf_st->pkt.data + asf->packet_frag_offset + ret, 0, asf->packet_frag_size - ret); ret = asf->packet_frag_size; } else av_shrink_packet(&asf_st->pkt, asf->packet_frag_offset + ret); } if (s->key && s->keylen == 20) ff_asfcrypt_dec(s->key, asf_st->pkt.data + asf->packet_frag_offset, ret); asf_st->frag_offset += ret; if (asf_st->frag_offset == asf_st->pkt.size) { if( s->streams[asf->stream_index]->codec->codec_id == CODEC_ID_MPEG2VIDEO && asf_st->pkt.size > 100){ int i; for(i=0; i<asf_st->pkt.size && !asf_st->pkt.data[i]; i++); if(i == asf_st->pkt.size){ av_log(s, AV_LOG_DEBUG, "discarding ms fart\n"); asf_st->frag_offset = 0; av_free_packet(&asf_st->pkt); continue; } } if (asf_st->ds_span > 1) { if(asf_st->pkt.size != asf_st->ds_packet_size * asf_st->ds_span){ av_log(s, AV_LOG_ERROR, "pkt.size != ds_packet_size * ds_span (%d %d %d)\n", asf_st->pkt.size, asf_st->ds_packet_size, asf_st->ds_span); }else{ uint8_t *newdata = av_malloc(asf_st->pkt.size + FF_INPUT_BUFFER_PADDING_SIZE); if (newdata) { int offset = 0; memset(newdata + asf_st->pkt.size, 0, FF_INPUT_BUFFER_PADDING_SIZE); while (offset < asf_st->pkt.size) { int off = offset / asf_st->ds_chunk_size; int row = off / asf_st->ds_span; int col = off % asf_st->ds_span; int idx = row + col * asf_st->ds_packet_size / asf_st->ds_chunk_size; assert(offset + asf_st->ds_chunk_size <= asf_st->pkt.size); assert(idx+1 <= asf_st->pkt.size / asf_st->ds_chunk_size); memcpy(newdata + offset, asf_st->pkt.data + idx * asf_st->ds_chunk_size, asf_st->ds_chunk_size); offset += asf_st->ds_chunk_size; } av_free(asf_st->pkt.data); asf_st->pkt.data = newdata; } } } asf_st->frag_offset = 0; *pkt= asf_st->pkt; asf_st->pkt.size = 0; asf_st->pkt.data = 0; break; } } return 0; }
1threat
Google map is not displaying in my android program : I'm new to the android program now I am working on maps so it's my first sample program in android maps tutorial.I get key from google console and I gave permissions in manifest file so this is <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> The output of this code is [enter image description here][1] [1]: https://i.stack.imgur.com/Npzp0.jpg I searched so many websites and I found nothing for my error
0debug
pairwise adding element in a list : I have two list of tuples [1,3000],[2,5000],[3,7000],[4,10000] [1,2000],[2,3000],[3,4000],[4,5000]] the sum is 10000. Here we have [2,5000],[4,5000] and [3,7000],[2,3000] so the output should be **[2,4]** and **[3,2]** [[1,2000],[2,4000],[3,6000]] [[1,2000]] the sum is 7000. Here since I dont have a combination that sum up to 7000 I consider all the possible combinations 4000(2000+2000),6000(4000+2000) and 8000(6000+2000) and consider the next lowest number from the desired sum which is 6000 . For 6000 my output should be [2,4000] and [1,2000] which is **[2,1]** Here is my code import itertools def optimalUtilization(maximumOperatingTravelDistance, forwardShippingRouteList, returnShippingRouteList): result=[] t1=[] t2=[] for miles in forwardShippingRouteList: t1.append(miles[1]) for miles in returnShippingRouteList: t2.append(miles[1]) result.append(t1) result.append(t2) total_sum=set() for element in list(itertools.product(*result)): if sum(element)<=maximumOperatingTravelDistance: total_sum.add(sum(element)) total_sum=sorted(total_sum,reverse=True) return optimalUtilizationhelper(total_sum[0], forwardShippingRouteList, returnShippingRouteList) def optimalUtilizationhelper(maximumOperatingTravelDistance, forwardShippingRouteList, returnShippingRouteList): dist_dict={} for carid,miles in forwardShippingRouteList: dist_dict.update({miles:carid}) result=[] for carid,miles in returnShippingRouteList: if (maximumOperatingTravelDistance-miles) in dist_dict: result.append(list((dist_dict[maximumOperatingTravelDistance-miles],carid))) return result Is there a better pythonic way to do this ?
0debug
fatal error: 'Python.h' file not found while installing opencv : <p>I am trying to get opencv 3.1 installed for Python on my Mac OS X 10.10.5 I'm following the steps as outlined here - <a href="http://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/">http://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/</a></p> <p>When I actually try installing opencv after all the setup, I get the following error: </p> <pre><code>.../opencv/modules/python/src2/cv2.cpp:6:10: fatal error: 'Python.h' file not found #include &lt;Python.h&gt; ^ </code></pre> <p>I looked around StackOverflow and found that most people facing this issue are using Anaconda, which is not my case. It would be great if someone could point me in the right direction to get this fixed. </p> <p>Thanks,</p>
0debug
Remove the "This is the format of your plot grid:" in a plotly subplot in a Jupyter Notebook : <p>When using Plotly in a Jupyter Notebook plotting an offline iplot figure with subplots, before the figure I get the output:</p> <pre><code>This is the format of your plot grid: [ (1,1) x1,y1 ] [ (1,2) x2,y2 ] [ (1,3) x3,y3 ] [ (1,4) x4,y4 ] [ (2,1) x5,y5 ] [ (2,2) x6,y6 ] [ (2,3) x7,y7 ] [ (2,4) x8,y8 ] [ (3,1) x9,y9 ] [ (3,2) x10,y10 ] [ (3,3) x11,y11 ] [ (3,4) x12,y12 ] [ (4,1) x13,y13 ] [ (4,2) x14,y14 ] [ (4,3) x15,y15 ] [ (4,4) x16,y16 ] </code></pre> <p>How do I remove this from the output?</p> <p>Example code:</p> <pre><code>import plotly as pl import plotly.graph_objs as go import numpy as np fig = pl.tools.make_subplots(cols=4, rows=4) for col in range(1, 5): for row in range(1, 5): x = np.random.rand(500) trace = go.Histogram(x=x, histnorm='density') fig.append_trace(trace, row, col) pl.offline.iplot(fig) </code></pre>
0debug
Apply CSS to all but last element? : <p>I've got the following html:</p> <pre><code>&lt;ul class="menu"&gt; &lt;li&gt;&lt;a&gt;list item 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;list item 2&lt;/a&gt;&lt;/li&gt; ... &lt;li&gt;&lt;a&gt;list item 5&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I want to apply a border to all the <code>&lt;a&gt;</code> elements except the last one. </p> <p>I've been trying this:</p> <pre><code>.menu a { border-right: 1px dotted #ccc; } .menu a:last-of-type { border-right: none; } </code></pre> <p>but I end up with a border on none of the elements, I guess because the <code>&lt;a&gt;</code> in each case is the last of type. </p> <p>How can I do this? I'd prefer to use only CSS if possible, and I'd like IE9 compatibility if possible. </p>
0debug
static void qemu_announce_self_once(void *opaque) { int i, len; VLANState *vlan; VLANClientState *vc; uint8_t buf[256]; static int count = SELF_ANNOUNCE_ROUNDS; QEMUTimer *timer = *(QEMUTimer **)opaque; for (i = 0; i < MAX_NICS; i++) { if (!nd_table[i].used) continue; len = announce_self_create(buf, nd_table[i].macaddr); vlan = nd_table[i].vlan; QTAILQ_FOREACH(vc, &vlan->clients, next) { vc->receive(vc, buf, len); } } if (count--) { qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 100); } else { qemu_del_timer(timer); qemu_free_timer(timer); } }
1threat
M48t59State *m48t59_init(qemu_irq IRQ, target_phys_addr_t mem_base, uint32_t io_base, uint16_t size, int model) { DeviceState *dev; SysBusDevice *s; M48t59SysBusState *d; M48t59State *state; dev = qdev_create(NULL, "m48t59"); qdev_prop_set_uint32(dev, "model", model); qdev_prop_set_uint32(dev, "size", size); qdev_prop_set_uint32(dev, "io_base", io_base); qdev_init_nofail(dev); s = sysbus_from_qdev(dev); d = FROM_SYSBUS(M48t59SysBusState, s); state = &d->state; sysbus_connect_irq(s, 0, IRQ); if (io_base != 0) { register_ioport_read(io_base, 0x04, 1, NVRAM_readb, state); register_ioport_write(io_base, 0x04, 1, NVRAM_writeb, state); } if (mem_base != 0) { sysbus_mmio_map(s, 0, mem_base); } return state; }
1threat
static gboolean nbd_accept(QIOChannel *ioc, GIOCondition cond, gpointer opaque) { QIOChannelSocket *cioc; cioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), NULL); if (!cioc) { return TRUE; } if (state >= TERMINATE) { object_unref(OBJECT(cioc)); return TRUE; } nb_fds++; nbd_update_server_watch(); nbd_client_new(newproto ? NULL : exp, cioc, NULL, NULL, nbd_client_closed); object_unref(OBJECT(cioc)); return TRUE; }
1threat
void ff_put_h264_qpel8_mc02_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_vt_8w_msa(src - (stride * 2), stride, dst, stride, 8); }
1threat
static void assert_codec_experimental(AVCodecContext *c, int encoder) { const char *codec_string = encoder ? "encoder" : "decoder"; AVCodec *codec; if (c->codec->capabilities & CODEC_CAP_EXPERIMENTAL && c->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { av_log(NULL, AV_LOG_ERROR, "%s '%s' is experimental and might produce bad " "results.\nAdd '-strict experimental' if you want to use it.\n", codec_string, c->codec->name); codec = encoder ? avcodec_find_encoder(codec->id) : avcodec_find_decoder(codec->id); if (!(codec->capabilities & CODEC_CAP_EXPERIMENTAL)) av_log(NULL, AV_LOG_ERROR, "Or use the non experimental %s '%s'.\n", codec_string, codec->name); ffmpeg_exit(1); } }
1threat
static int ftp_passive_mode(FTPContext *s) { char *res = NULL, *start, *end; int i; const char *command = "PASV\r\n"; const int pasv_codes[] = {227, 501, 0}; if (ftp_send_command(s, command, pasv_codes, &res) != 227 || !res) goto fail; start = NULL; for (i = 0; i < strlen(res); ++i) { if (res[i] == '(') { start = res + i + 1; } else if (res[i] == ')') { end = res + i; break; } } if (!start || !end) goto fail; *end = '\0'; if (!av_strtok(start, ",", &end)) goto fail; if (!av_strtok(end, ",", &end)) goto fail; if (!av_strtok(end, ",", &end)) goto fail; if (!av_strtok(end, ",", &end)) goto fail; start = av_strtok(end, ",", &end); if (!start) goto fail; s->server_data_port = atoi(start) * 256; start = av_strtok(end, ",", &end); if (!start) goto fail; s->server_data_port += atoi(start); av_dlog(s, "Server data port: %d\n", s->server_data_port); av_free(res); return 0; fail: av_free(res); s->server_data_port = -1; return AVERROR(EIO); }
1threat
With C# a dynamic table in asp.net MVC : I want to have a dynamic table in MVC. I copied some code from the internet but it doesn't work. I haven't an error but I get no values on my site. My goal is just a little website with a dynamic table. View: @model IEnumerable<ProjectName.Models.TestModel> @using (Html.BeginForm()) { <table width="960px"> <tr> @{ int crow = 1; foreach (var item in Model) { <td style="border: 1px solid black;" width="600px"> <ul style="list-style: none;"> <li> @Html.TextBox("txt") </li> </ul> </td> if (crow % 3 == 0) { <tr> <td style="width: 285px; height: 50px"></td> </tr> } crow++; } } </tr> </table> } Model: public string numbers { get; set; } Controller: List<testModel> model = new List<testModel>(); int[] numbersdata = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0, 15, 14, 11, 13, 19, 18, 16, 17, 12, 10 }; var lowNums = from n in numbersdata where n > 5 select n; foreach (var x in lowNums) { model.Add(new testModel() { numbers = x.ToString() }); } return View(model);
0debug
static int cinepak_decode_vectors (CinepakContext *s, cvid_strip *strip, int chunk_id, int size, const uint8_t *data) { const uint8_t *eod = (data + size); uint32_t flag, mask; uint8_t *cb0, *cb1, *cb2, *cb3; unsigned int x, y; char *ip0, *ip1, *ip2, *ip3; flag = 0; mask = 0; for (y=strip->y1; y < strip->y2; y+=4) { ip0 = ip1 = ip2 = ip3 = s->frame->data[0] + (s->palette_video?strip->x1:strip->x1*3) + (y * s->frame->linesize[0]); if(s->avctx->height - y > 1) { ip1 = ip0 + s->frame->linesize[0]; if(s->avctx->height - y > 2) { ip2 = ip1 + s->frame->linesize[0]; if(s->avctx->height - y > 3) { ip3 = ip2 + s->frame->linesize[0]; } } } for (x=strip->x1; x < strip->x2; x+=4) { if ((chunk_id & 0x01) && !(mask >>= 1)) { if ((data + 4) > eod) return AVERROR_INVALIDDATA; flag = AV_RB32 (data); data += 4; mask = 0x80000000; } if (!(chunk_id & 0x01) || (flag & mask)) { if (!(chunk_id & 0x02) && !(mask >>= 1)) { if ((data + 4) > eod) return AVERROR_INVALIDDATA; flag = AV_RB32 (data); data += 4; mask = 0x80000000; } if ((chunk_id & 0x02) || (~flag & mask)) { uint8_t *p; if (data >= eod) return AVERROR_INVALIDDATA; p = strip->v1_codebook[*data++]; if (s->palette_video) { ip3[0] = ip3[1] = ip2[0] = ip2[1] = p[6]; ip3[2] = ip3[3] = ip2[2] = ip2[3] = p[9]; ip1[0] = ip1[1] = ip0[0] = ip0[1] = p[0]; ip1[2] = ip1[3] = ip0[2] = ip0[3] = p[3]; } else { p += 6; memcpy(ip3 + 0, p, 3); memcpy(ip3 + 3, p, 3); memcpy(ip2 + 0, p, 3); memcpy(ip2 + 3, p, 3); p += 3; memcpy(ip3 + 6, p, 3); memcpy(ip3 + 9, p, 3); memcpy(ip2 + 6, p, 3); memcpy(ip2 + 9, p, 3); p -= 9; memcpy(ip1 + 0, p, 3); memcpy(ip1 + 3, p, 3); memcpy(ip0 + 0, p, 3); memcpy(ip0 + 3, p, 3); p += 3; memcpy(ip1 + 6, p, 3); memcpy(ip1 + 9, p, 3); memcpy(ip0 + 6, p, 3); memcpy(ip0 + 9, p, 3); } } else if (flag & mask) { if ((data + 4) > eod) return AVERROR_INVALIDDATA; cb0 = strip->v4_codebook[*data++]; cb1 = strip->v4_codebook[*data++]; cb2 = strip->v4_codebook[*data++]; cb3 = strip->v4_codebook[*data++]; if (s->palette_video) { uint8_t *p; p = ip3; *p++ = cb2[6]; *p++ = cb2[9]; *p++ = cb3[6]; *p = cb3[9]; p = ip2; *p++ = cb2[0]; *p++ = cb2[3]; *p++ = cb3[0]; *p = cb3[3]; p = ip1; *p++ = cb0[6]; *p++ = cb0[9]; *p++ = cb1[6]; *p = cb1[9]; p = ip0; *p++ = cb0[0]; *p++ = cb0[3]; *p++ = cb1[0]; *p = cb1[3]; } else { memcpy(ip3 + 0, cb2 + 6, 6); memcpy(ip3 + 6, cb3 + 6, 6); memcpy(ip2 + 0, cb2 + 0, 6); memcpy(ip2 + 6, cb3 + 0, 6); memcpy(ip1 + 0, cb0 + 6, 6); memcpy(ip1 + 6, cb1 + 6, 6); memcpy(ip0 + 0, cb0 + 0, 6); memcpy(ip0 + 6, cb1 + 0, 6); } } } if (s->palette_video) { ip0 += 4; ip1 += 4; ip2 += 4; ip3 += 4; } else { ip0 += 12; ip1 += 12; ip2 += 12; ip3 += 12; } } } return 0; }
1threat
long do_rt_sigreturn(CPUARMState *env) { struct target_rt_sigframe *frame = NULL; abi_ulong frame_addr = env->xregs[31]; trace_user_do_rt_sigreturn(env, frame_addr); if (frame_addr & 15) { goto badframe; } if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { goto badframe; } if (target_restore_sigframe(env, frame)) { goto badframe; } if (do_sigaltstack(frame_addr + offsetof(struct target_rt_sigframe, uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT) { goto badframe; } unlock_user_struct(frame, frame_addr, 0); return env->xregs[0]; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); return 0; }
1threat
how to change navigationitem title color : <p>I think all day to change the navigation Bar title color, but it doesn't work. this is my code:</p> <pre><code>var user: User? { didSet { navigationItem.title = user?.name observeMessages() } } </code></pre> <p>I use didSet to show the title on the navigation title. </p>
0debug
BlockStatsList *qmp_query_blockstats(bool has_query_nodes, bool query_nodes, Error **errp) { BlockStatsList *head = NULL, **p_next = &head; BlockBackend *blk = NULL; BlockDriverState *bs = NULL; query_nodes = has_query_nodes && query_nodes; while (next_query_bds(&blk, &bs, query_nodes)) { BlockStatsList *info = g_malloc0(sizeof(*info)); AioContext *ctx = blk ? blk_get_aio_context(blk) : bdrv_get_aio_context(bs); aio_context_acquire(ctx); info->value = bdrv_query_stats(blk, bs, !query_nodes); aio_context_release(ctx); *p_next = info; p_next = &info->next; } return head; }
1threat
SQL INSERT INTO Syntax error. Basic Database : <p>I'm attempting to insert a new row into a table and I am getting a syntax error. I successfully inserted rows into different tables in the same database withe the same format with no issues. The scrip is as follows</p> <pre><code>INSERT INTO Ordertbl(OrdNo, OrdDate, CustNo, EmpNo, OrdName, OrdStreet, OrdCity, OrdState, OrdZip) VALUES ('O1234567', '2030-1-25', '49908905', '55138445', 'John Smith', 'Milwaukee', 'WI', '53122-4523') </code></pre>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
Bash Script to read a file and add the contents : I have no idea of bash scripting, but I need to write one to do the following: I have the following contents in the file, and I want to filter Executor Deserialize Time and add all the values to get the final result. How can I do that? Thanks in advance! {"Event":"SparkListenerTaskEnd","Stage ID":0,"Stage Attempt ID":0,"Task Type":"ShuffleMapTask","Task End Reason":{"Reason":"Success"},"Task Info":{"Task ID":29,"Index":29,"Attempt":0,"Launch Time":1453927221831,"Executor ID":"1","Host":"172.17.0.226","Locality":"ANY","Speculative":false,"Getting Result Time":0,"Finish Time":1453927230401,"Failed":false,"Accumulables":[]},"Task Metrics":{"Host Name":"172.17.0.226","Executor Deserialize Time":9,"Executor Run Time":8550,"Result Size":2258,"JVM GC Time":18,"Result Serialization Time":0,"Memory Bytes Spilled":0,"Disk Bytes Spilled":0,"Shuffle Write Metrics":{"Shuffle Bytes Written":0,"Shuffle Write Time":4425,"Shuffle Records Written":0},"Input Metrics":{"Data Read Method":"Hadoop","Bytes Read":134283264,"Records Read":100890}}} {"Event":"SparkListenerTaskEnd","Stage ID":0,"Stage Attempt ID":0,"Task Type":"ShuffleMapTask","Task End Reason":{"Reason":"Success"},"Task Info":{"Task ID":30,"Index":30,"Attempt":0,"Launch Time":1453927222232,"Executor ID":"1","Host":"172.17.0.226","Locality":"ANY","Speculative":false,"Getting Result Time":0,"Finish Time":1453927230493,"Failed":false,"Accumulables":[]},"Task Metrics":{"Host Name":"172.17.0.226","Executor Deserialize Time":7,"Executor Run Time":8244,"Result Size":2258,"JVM GC Time":16,"Result Serialization Time":0,"Memory Bytes Spilled":0,"Disk Bytes Spilled":0,"Shuffle Write Metrics":{"Shuffle Bytes Written":0,"Shuffle Write Time":4190,"Shuffle Records Written":0},"Input Metrics":{"Data Read Method":"Hadoop","Bytes Read":134283264,"Records Read":100886}}} {"Event":"SparkListenerTaskEnd","Stage ID":0,"Stage Attempt ID":0,"Task Type":"ShuffleMapTask","Task End Reason":{"Reason":"Success"},"Task Info":{"Task ID":31,"Index":31,"Attempt":0,"Launch Time":1453927222796,"Executor ID":"1","Host":"172.17.0.226","Locality":"ANY","Speculative":false,"Getting Result Time":0,"Finish Time":1453927230638,"Failed":false,"Accumulables":[]},"Task Metrics":{"Host Name":"172.17.0.226","Executor Deserialize Time":5,"Executor Run Time":7826,"Result Size":2258,"JVM GC Time":18,"Result Serialization Time":0,"Memory Bytes Spilled":0,"Disk Bytes Spilled":0,"Shuffle Write Metrics":{"Shuffle Bytes Written":0,"Shuffle Write Time":3958,"Shuffle Records Written":0},"Input Metrics":{"Data Read Method":"Hadoop","Bytes Read":134283264,"Records Read":101004}}}
0debug
matplotlib bar chart: space out bars : <p>How do I increase the space between each bar with matplotlib barcharts, as they keep cramming them self to the centre.<a href="https://i.stack.imgur.com/oYxW1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oYxW1.png" alt="enter image description here"></a> (this is what it currently looks)</p> <pre><code>import matplotlib.pyplot as plt import matplotlib.dates as mdates def ww(self):#wrongwords text file with open("wrongWords.txt") as file: array1 = [] array2 = [] for element in file: array1.append(element) x=array1[0] s = x.replace(')(', '),(') #removes the quote marks from csv file print(s) my_list = ast.literal_eval(s) print(my_list) my_dict = {} for item in my_list: my_dict[item[2]] = my_dict.get(item[2], 0) + 1 plt.bar(range(len(my_dict)), my_dict.values(), align='center') plt.xticks(range(len(my_dict)), my_dict.keys()) plt.show() </code></pre>
0debug
void *etraxfs_eth_init(NICInfo *nd, target_phys_addr_t base, int phyaddr) { struct etraxfs_dma_client *dma = NULL; struct fs_eth *eth = NULL; qemu_check_nic_model(nd, "fseth"); dma = qemu_mallocz(sizeof *dma * 2); eth = qemu_mallocz(sizeof *eth); dma[0].client.push = eth_tx_push; dma[0].client.opaque = eth; dma[1].client.opaque = eth; dma[1].client.pull = NULL; eth->dma_out = dma; eth->dma_in = dma + 1; eth->phyaddr = phyaddr & 0x1f; tdk_init(&eth->phy); mdio_attach(&eth->mdio_bus, &eth->phy, eth->phyaddr); eth->ethregs = cpu_register_io_memory(eth_read, eth_write, eth); cpu_register_physical_memory (base, 0x5c, eth->ethregs); eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, eth_can_receive, eth_receive, NULL, eth_cleanup, eth); eth->vc->opaque = eth; eth->vc->link_status_changed = eth_set_link; return dma; }
1threat
Using python 3.x, how to find the sum of this series using loops. x - x^2/fact(2) + x^3/fact(3) ... -x^6/fact(6) : I tried various ways, even used nested 'for' loops, but I can't seem to figure out the code, any help?
0debug
static void init_excp_602 (CPUPPCState *env) { #if !defined(CONFIG_USER_ONLY) env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; env->excp_vectors[POWERPC_EXCP_FPA] = 0x00000E00; env->excp_vectors[POWERPC_EXCP_IFTLB] = 0x00001000; env->excp_vectors[POWERPC_EXCP_DLTLB] = 0x00001100; env->excp_vectors[POWERPC_EXCP_DSTLB] = 0x00001200; env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; env->excp_vectors[POWERPC_EXCP_WDT] = 0x00001500; env->excp_vectors[POWERPC_EXCP_EMUL] = 0x00001600; env->excp_prefix = 0xFFF00000; env->hreset_vector = 0xFFFFFFFCUL; #endif }
1threat
static int teletext_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt) { TeletextContext *ctx = avctx->priv_data; AVSubtitle *sub = data; const uint8_t *buf = pkt->data; int left = pkt->size; uint8_t pesheader[45] = {0x00, 0x00, 0x01, 0xbd, 0x00, 0x00, 0x85, 0x80, 0x24, 0x21, 0x00, 0x01, 0x00, 0x01}; int pesheader_size = sizeof(pesheader); const uint8_t *pesheader_buf = pesheader; int ret = 0; if (!ctx->vbi) { if (!(ctx->vbi = vbi_decoder_new())) return AVERROR(ENOMEM); if (!vbi_event_handler_add(ctx->vbi, VBI_EVENT_TTX_PAGE, handler, ctx)) { vbi_decoder_delete(ctx->vbi); ctx->vbi = NULL; return AVERROR(ENOMEM); } } if (!ctx->dx && (!(ctx->dx = vbi_dvb_pes_demux_new ( NULL, NULL)))) return AVERROR(ENOMEM); if (avctx->pkt_timebase.den && pkt->pts != AV_NOPTS_VALUE) ctx->pts = av_rescale_q(pkt->pts, avctx->pkt_timebase, AV_TIME_BASE_Q); if (left) { if ((pesheader_size + left) < 184 || (pesheader_size + left) > 65504 || (pesheader_size + left) % 184 != 0) return AVERROR_INVALIDDATA; memset(pesheader + 14, 0xff, pesheader_size - 14); AV_WB16(pesheader + 4, left + pesheader_size - 6); vbi_dvb_demux_cor(ctx->dx, ctx->sliced, 64, NULL, &pesheader_buf, &pesheader_size); ctx->handler_ret = pkt->size; while (left > 0) { int64_t pts = 0; unsigned int lines = vbi_dvb_demux_cor(ctx->dx, ctx->sliced, 64, &pts, &buf, &left); av_dlog(avctx, "ctx=%p buf_size=%d left=%u lines=%u pts=%f pkt_pts=%f\n", ctx, pkt->size, left, lines, (double)pts/90000.0, (double)pkt->pts/90000.0); if (lines > 0) { #ifdef DEBUGx int i; for(i=0; i<lines; ++i) av_log(avctx, AV_LOG_DEBUG, "lines=%d id=%x\n", i, ctx->sliced[i].id); #endif vbi_decode(ctx->vbi, ctx->sliced, lines, (double)pts/90000.0); ctx->lines_processed += lines; } } ctx->pts = AV_NOPTS_VALUE; ret = ctx->handler_ret; } if (ret < 0) return ret; if (ctx->nb_pages) { int i; sub->format = ctx->format_id; sub->start_display_time = 0; sub->end_display_time = ctx->sub_duration; sub->num_rects = 0; sub->pts = ctx->pages->pts; if (ctx->pages->sub_rect->type != SUBTITLE_NONE) { sub->rects = av_malloc(sizeof(*sub->rects) * 1); if (sub->rects) { sub->num_rects = 1; sub->rects[0] = ctx->pages->sub_rect; } else { ret = AVERROR(ENOMEM); } } else { av_log(avctx, AV_LOG_DEBUG, "sending empty sub\n"); sub->rects = NULL; } if (!sub->rects) subtitle_rect_free(&ctx->pages->sub_rect); for (i = 0; i < ctx->nb_pages - 1; i++) ctx->pages[i] = ctx->pages[i + 1]; ctx->nb_pages--; if (ret >= 0) *data_size = 1; } else *data_size = 0; return ret; }
1threat
Android Button: get value? I do not mean the text : I have an android button with a text. When the button is clicked, I want to access the database for which I need an integer associated with the button. I do not mean the text of the button which is visible to the user (i.e. not the string "Save data"). I mean something like the value of the button, which could be an integer (e.g. 17). I am reading [this](https://developer.android.com/reference/android/widget/TextView) since button extends textview. I've scanned the XML attributes but I cannot find anything, does a button in android not have a value that I can fetch in my activity method which is linked to the button? I was thinking about something like casting the View that I get in my activity method to a `(Button)` and then call something like `int my_database_int = button.getValue()` but I do not find anything in the link above and I find it hard to believe that there is no such functionality?
0debug
static void i440fx_pcihost_get_pci_hole64_start(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { PCIHostState *h = PCI_HOST_BRIDGE(obj); Range w64; pci_bus_get_w64_range(h->bus, &w64); visit_type_uint64(v, name, &w64.begin, errp); }
1threat
Operator '==' cannot be applied to operands of type 'bool' and 'string' in mvc c# : <p>I am new in MVC C#. I am getting this error, I have checked and found similar which is not going to my error.</p> <p>The error is - <i>"Operator '==' cannot be applied to operands of type 'bool' and 'string'"</i></p> <p>The Code is -</p> <pre><code>List&lt;RptItem&gt; _r2 = _r1.Where(xx =&gt; xx.Value == ("rcat")) .Select(xx=&gt;(KeyValuePair&lt;string, string&gt;?)xx) .FirstOrDefault(); </code></pre> <p>Could someone help me, what I need to do.</p> <p>Thanks</p>
0debug
static void qemu_kvm_eat_signals(CPUState *env) { struct timespec ts = { 0, 0 }; siginfo_t siginfo; sigset_t waitset; sigset_t chkset; int r; sigemptyset(&waitset); sigaddset(&waitset, SIG_IPI); sigaddset(&waitset, SIGBUS); do { r = sigtimedwait(&waitset, &siginfo, &ts); if (r == -1 && !(errno == EAGAIN || errno == EINTR)) { perror("sigtimedwait"); exit(1); } switch (r) { case SIGBUS: if (kvm_on_sigbus_vcpu(env, siginfo.si_code, siginfo.si_addr)) { sigbus_reraise(); } break; default: break; } r = sigpending(&chkset); if (r == -1) { perror("sigpending"); exit(1); } } while (sigismember(&chkset, SIG_IPI) || sigismember(&chkset, SIGBUS)); #ifndef CONFIG_IOTHREAD if (sigismember(&chkset, SIGIO) || sigismember(&chkset, SIGALRM)) { qemu_notify_event(); } #endif }
1threat
static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) { VP56RangeCoder *c = &s->c; int header_size, hscale, vscale, i, j, k, l, m, ret; int width = s->avctx->width; int height = s->avctx->height; s->keyframe = !(buf[0] & 1); s->profile = (buf[0]>>1) & 7; s->invisible = !(buf[0] & 0x10); header_size = AV_RL24(buf) >> 5; buf += 3; buf_size -= 3; if (s->profile > 3) av_log(s->avctx, AV_LOG_WARNING, "Unknown profile %d\n", s->profile); if (!s->profile) memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, sizeof(s->put_pixels_tab)); else memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_bilinear_pixels_tab, sizeof(s->put_pixels_tab)); if (header_size > buf_size - 7*s->keyframe) { av_log(s->avctx, AV_LOG_ERROR, "Header size larger than data provided\n"); return AVERROR_INVALIDDATA; } if (s->keyframe) { if (AV_RL24(buf) != 0x2a019d) { av_log(s->avctx, AV_LOG_ERROR, "Invalid start code 0x%x\n", AV_RL24(buf)); return AVERROR_INVALIDDATA; } width = AV_RL16(buf+3) & 0x3fff; height = AV_RL16(buf+5) & 0x3fff; hscale = buf[4] >> 6; vscale = buf[6] >> 6; buf += 7; buf_size -= 7; if (hscale || vscale) av_log_missing_feature(s->avctx, "Upscaling", 1); s->update_golden = s->update_altref = VP56_FRAME_CURRENT; for (i = 0; i < 4; i++) for (j = 0; j < 16; j++) memcpy(s->prob->token[i][j], vp8_token_default_probs[i][vp8_coeff_band[j]], sizeof(s->prob->token[i][j])); memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter, sizeof(s->prob->pred16x16)); memcpy(s->prob->pred8x8c , vp8_pred8x8c_prob_inter , sizeof(s->prob->pred8x8c)); memcpy(s->prob->mvc , vp8_mv_default_prob , sizeof(s->prob->mvc)); memset(&s->segmentation, 0, sizeof(s->segmentation)); } if (!s->macroblocks_base || width != s->avctx->width || height != s->avctx->height) { if ((ret = update_dimensions(s, width, height)) < 0) return ret; } ff_vp56_init_range_decoder(c, buf, header_size); buf += header_size; buf_size -= header_size; if (s->keyframe) { if (vp8_rac_get(c)) av_log(s->avctx, AV_LOG_WARNING, "Unspecified colorspace\n"); vp8_rac_get(c); } if ((s->segmentation.enabled = vp8_rac_get(c))) parse_segment_info(s); else s->segmentation.update_map = 0; s->filter.simple = vp8_rac_get(c); s->filter.level = vp8_rac_get_uint(c, 6); s->filter.sharpness = vp8_rac_get_uint(c, 3); if ((s->lf_delta.enabled = vp8_rac_get(c))) if (vp8_rac_get(c)) update_lf_deltas(s); if (setup_partitions(s, buf, buf_size)) { av_log(s->avctx, AV_LOG_ERROR, "Invalid partitions\n"); return AVERROR_INVALIDDATA; } get_quants(s); if (!s->keyframe) { update_refs(s); s->sign_bias[VP56_FRAME_GOLDEN] = vp8_rac_get(c); s->sign_bias[VP56_FRAME_GOLDEN2 ] = vp8_rac_get(c); } if (!(s->update_probabilities = vp8_rac_get(c))) s->prob[1] = s->prob[0]; s->update_last = s->keyframe || vp8_rac_get(c); for (i = 0; i < 4; i++) for (j = 0; j < 8; j++) for (k = 0; k < 3; k++) for (l = 0; l < NUM_DCT_TOKENS-1; l++) if (vp56_rac_get_prob_branchy(c, vp8_token_update_probs[i][j][k][l])) { int prob = vp8_rac_get_uint(c, 8); for (m = 0; vp8_coeff_band_indexes[j][m] >= 0; m++) s->prob->token[i][vp8_coeff_band_indexes[j][m]][k][l] = prob; } if ((s->mbskip_enabled = vp8_rac_get(c))) s->prob->mbskip = vp8_rac_get_uint(c, 8); if (!s->keyframe) { s->prob->intra = vp8_rac_get_uint(c, 8); s->prob->last = vp8_rac_get_uint(c, 8); s->prob->golden = vp8_rac_get_uint(c, 8); if (vp8_rac_get(c)) for (i = 0; i < 4; i++) s->prob->pred16x16[i] = vp8_rac_get_uint(c, 8); if (vp8_rac_get(c)) for (i = 0; i < 3; i++) s->prob->pred8x8c[i] = vp8_rac_get_uint(c, 8); for (i = 0; i < 2; i++) for (j = 0; j < 19; j++) if (vp56_rac_get_prob_branchy(c, vp8_mv_update_prob[i][j])) s->prob->mvc[i][j] = vp8_rac_get_nn(c); } return 0; }
1threat
minimac2_read(void *opaque, target_phys_addr_t addr, unsigned size) { MilkymistMinimac2State *s = opaque; uint32_t r = 0; addr >>= 2; switch (addr) { case R_SETUP: case R_MDIO: case R_STATE0: case R_COUNT0: case R_STATE1: case R_COUNT1: case R_TXCOUNT: r = s->regs[addr]; break; default: error_report("milkymist_minimac2: read access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } trace_milkymist_minimac2_memory_read(addr << 2, r); return r; }
1threat
static void mov_text_text_cb(void *priv, const char *text, int len) { MovTextContext *s = priv; av_strlcpy(s->ptr, text, FFMIN(s->end - s->ptr, len + 1)); s->ptr += len; }
1threat
void yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4]) { vector signed short CY, CRV, CBU, CGU, CGV, OY, Y0; int64_t crv __attribute__ ((aligned(16))) = inv_table[0]; int64_t cbu __attribute__ ((aligned(16))) = inv_table[1]; int64_t cgu __attribute__ ((aligned(16))) = inv_table[2]; int64_t cgv __attribute__ ((aligned(16))) = inv_table[3]; int64_t cy = (1<<16)-1; int64_t oy = 0; short tmp __attribute__ ((aligned(16))); if ((c->flags & SWS_CPU_CAPS_ALTIVEC) == 0) return; cy = (cy *c->contrast )>>17; crv= (crv*c->contrast * c->saturation)>>32; cbu= (cbu*c->contrast * c->saturation)>>32; cgu= (cgu*c->contrast * c->saturation)>>32; cgv= (cgv*c->contrast * c->saturation)>>32; oy -= 256*c->brightness; tmp = cy; CY = vec_lde (0, &tmp); CY = vec_splat (CY, 0); tmp = oy; OY = vec_lde (0, &tmp); OY = vec_splat (OY, 0); tmp = crv>>3; CRV = vec_lde (0, &tmp); CRV = vec_splat (CRV, 0); tmp = cbu>>3; CBU = vec_lde (0, &tmp); CBU = vec_splat (CBU, 0); tmp = -(cgu>>1); CGU = vec_lde (0, &tmp); CGU = vec_splat (CGU, 0); tmp = -(cgv>>1); CGV = vec_lde (0, &tmp); CGV = vec_splat (CGV, 0); c->CSHIFT = (vector unsigned short)(2); c->CY = CY; c->OY = OY; c->CRV = CRV; c->CBU = CBU; c->CGU = CGU; c->CGV = CGV; #if 0 printf ("cy: %hvx\n", CY); printf ("oy: %hvx\n", OY); printf ("crv: %hvx\n", CRV); printf ("cbu: %hvx\n", CBU); printf ("cgv: %hvx\n", CGV); printf ("cgu: %hvx\n", CGU); #endif return; }
1threat
How to avoid overlapping OnClicks? : I'm using a Relative Layout where I've placed a Button over an Image View as shown [here][1]. <br /> The problem is I've used `OnClick` on both button and Image View that refers to different methods i.e., button when clicked calls a method, Image when clicked calls a different method. When I click on the button the App force quits i.e., has a Runtime Exception. **activity_main.xml**: <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="click" android:onClick="sampleClick" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="125dp" android:id="@+id/button" /> <ImageView android:id="@+id/imageView" android:layout_width="wrap_content" android:layout_height="wrap_content" app:srcCompat="@drawable/oreo" android:onClick="imageClick" android:layout_alignParentTop="true" android:layout_alignParentStart="true" /> **MainActivity.java**: public void sampleClick(View view){ Toast.makeText(MainActivity.this,"Button Click",Toast.LENGTH_LONG).show(); } public void imageClick(View view){ Toast.makeText(MainActivity.this,"Image Click",Toast.LENGTH_LONG).show(); } Help me solve the Error. [1]: https://i.stack.imgur.com/Tv0TW.png
0debug
JavaFX or Swing in a new project : <p>Well, i have 180 days to construct a new project, where i should use the TOP tecnologies (Java 8, Hibernate 5 and more ..)</p> <p>I have a big doubt before start it: What GUI Framework should i use ?</p> <p>If i should use Swing (as i always did) or start this project with JavaFX ( i don't have any knowledge about it). </p> <p>So, i'm thinking about some things:</p> <p>1) If i start with JavaFX, the difference will be very big to customer ? 2) If i start with JavaFX, in 180 days i will have enought time to study about this tecnology ? Is very complex or different from Swing?</p>
0debug
i wnt disply that javascript via url plese help me : i want disply this but its not worcking help me document.write('<a href="/site"><img src="" alt="image"/></a> var answer = confirm ("Please click on OK to continue loading my page, or CANCEL to be directed to the Yahoo site.") if (answer) window.location="https://www.google.co.in";');
0debug
Finding the limit of a sequence in python, jupyter notebook : <p>I’ve got a sequence a(n)=(5-77sin(n)+8n^2)/(1-4n^2) and I’m trying to find a candidate for the limit of this sequence. How do I do this? I’ve tried using a code below but that didn’t work so any ideas?<a href="https://i.stack.imgur.com/zUd3V.jpg" rel="nofollow noreferrer">enter image description here</a></p>
0debug
what does the following Line of code do in javascript $('div[class^="remainingQtyErrMsg"]').hide(); : <p>what does the following Line of code do in <strong>javascript/JQuery</strong>?</p> <pre><code>$('div[class^="remainingQtyErrMsg"]').hide(); </code></pre>
0debug
static av_cold int vtenc_close(AVCodecContext *avctx) { VTEncContext *vtctx = avctx->priv_data; if(!vtctx->session) return 0; VTCompressionSessionInvalidate(vtctx->session); pthread_cond_destroy(&vtctx->cv_sample_sent); pthread_mutex_destroy(&vtctx->lock); CFRelease(vtctx->session); vtctx->session = NULL; return 0; }
1threat
C++ Simulate key press and mantain it pressed on Windows : I Have this C++ Function that receives Virtual Key and Press/Release the key: void SendKey (WORD wVk, bool press) { keybd_event(wVk, 0, press? 0 : KEYEVENTF_KEYUP, 0); } But it does just press the key 1 time, not constantly as i expected. Im constructing a joypad simulation, so, i need to configure KeyDown and KeyUp respectively, this is a little C++ process that reads by cmd the key and the type (Down, Press or Release): #define WINVER 0x0500 #include <windows.h> #include <iostream> using namespace std; void SendKey (WORD wVk, bool press) { keybd_event(wVk, 0, press? 0 : KEYEVENTF_KEYUP, 0); } void PressKey (WORD wVk) { SendKey(wVk, true); Sleep(30); SendKey(wVk, false); } int main() { int key; char type; while(true) { cin >> key; cin >> type; if(key == 0) break; if(type == 'd') SendKey((WORD) key, true); if(type == 'r') SendKey((WORD) key, false); if(type == 'p') PressKey((WORD) key); } return 0; } Thanks a lot, if anyone have built something like this, plz tell me.
0debug
static int pci_ne2000_init(PCIDevice *pci_dev) { PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev); NE2000State *s; uint8_t *pci_conf; pci_conf = d->dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_REALTEK); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_REALTEK_8029); pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET); pci_conf[PCI_INTERRUPT_PIN] = 1; pci_register_bar(&d->dev, 0, 0x100, PCI_BASE_ADDRESS_SPACE_IO, ne2000_map); s = &d->ne2000; s->irq = d->dev.irq[0]; qemu_macaddr_default_if_unset(&s->c.macaddr); ne2000_reset(s); s->nic = qemu_new_nic(&net_ne2000_info, &s->c, pci_dev->qdev.info->name, pci_dev->qdev.id, s); qemu_format_nic_info_str(&s->nic->nc, s->c.macaddr.a); if (!pci_dev->qdev.hotplugged) { static int loaded = 0; if (!loaded) { rom_add_option("pxe-ne2k_pci.rom", -1); loaded = 1; } } add_boot_device_path(s->c.bootindex, &pci_dev->qdev, "/ethernet-phy@0"); return 0; }
1threat
HTML form posting default values : <p>I have a HTML form in which for some fields the user will enter the values and for some some fields i want to pass some default values, is there a way to do it?</p>
0debug
static void xen_set_memory(struct MemoryListener *listener, MemoryRegionSection *section, bool add) { XenIOState *state = container_of(listener, XenIOState, memory_listener); hwaddr start_addr = section->offset_within_address_space; ram_addr_t size = int128_get64(section->size); bool log_dirty = memory_region_is_logging(section->mr); hvmmem_type_t mem_type; if (!memory_region_is_ram(section->mr)) { return; } if (!(section->mr != &ram_memory && ( (log_dirty && add) || (!log_dirty && !add)))) { return; } trace_xen_client_set_memory(start_addr, size, log_dirty); start_addr &= TARGET_PAGE_MASK; size = TARGET_PAGE_ALIGN(size); if (add) { if (!memory_region_is_rom(section->mr)) { xen_add_to_physmap(state, start_addr, size, section->mr, section->offset_within_region); } else { mem_type = HVMMEM_ram_ro; if (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type, start_addr >> TARGET_PAGE_BITS, size >> TARGET_PAGE_BITS)) { DPRINTF("xc_hvm_set_mem_type error, addr: "TARGET_FMT_plx"\n", start_addr); } } } else { if (xen_remove_from_physmap(state, start_addr, size) < 0) { DPRINTF("physmapping does not exist at "TARGET_FMT_plx"\n", start_addr); } } }
1threat
How can i generate unique number as format XXXX-XXXX-XXXX using c# : <p>I want to generate number as format above and I try to use <code>UUID()</code> and <code>GUID()</code> but it is not what I want(difference format and it is hexadecimal not number)</p> <p>anyone have any idea or logic to do it?</p>
0debug
Make condition in one line? : <p>Usually I made the <code>if/else</code> condition like this:</p> <pre><code>if(empty($data['key'])) { $err = "empty . $key "; } </code></pre> <p>but I saw that there is the <a href="https://davidwalsh.name/php-shorthand-if-else-ternary-operators" rel="nofollow">ternary operator.</a></p> <p>I really don't understand how this works.. Someone could show me an example? How can I convert this condition in the ternary logic?</p>
0debug
Convert swift2 code to swift3 : Here is the code I would like compatible with swift3: { let size = text.boundingRectWithSize(CGSizeMake(view.frame.width - 26, 2000), options: NSStringDrawingOptions.UsesFontLeading.union(.UsesLineFragmentOrigin), context: nil).size }
0debug
Acess phone camera with a button (HTML) : I'm developing a application that needs to acess the phone camera. I'm currently using the Ratchet Framework but that's not really relevant here. I have a button that needs to open the camera onCLick. I know that to acess the camera we need this: <input type="file" accept="image/*" onchange="updatePhoto(event);"></input> And my button is like this: <button class="btn btn-positive btn-block"> Choose photo </button> I tried putting the input to acess the camera inside the button but it doesn't make the ugly "Choose photo" disapear making it look silly. I just need to replace the standard "Choose photo" that appears when we put only the first input and replace it with the button to look better.
0debug
static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind, const char *name, size_t size, Error **errp) { QmpInputVisitor *qiv = to_qiv(v); const QObject *qobj = qmp_input_get_object(qiv, name); if (!qobj || qobject_type(qobj) != QTYPE_QDICT) { error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "QDict"); return; } qmp_input_push(qiv, qobj, errp); if (error_is_set(errp)) { return; } if (obj) { *obj = g_malloc0(size); } }
1threat
static void cmv_decode_intra(CmvContext * s, const uint8_t *buf, const uint8_t *buf_end){ unsigned char *dst = s->frame.data[0]; int i; for (i=0; i < s->avctx->height && buf+s->avctx->width<=buf_end; i++) { memcpy(dst, buf, s->avctx->width); dst += s->frame.linesize[0]; buf += s->avctx->width; } }
1threat
Removing the Hardcoded MYSQL connection string : [this it the connection string that is hardcoded][ ost <<" DRIVER=SQL Server Native Client 11.0; SERVER=Avchar-D\\ENTERPRISE2014;Database="<< czDataSourceName << ";Uid=da; Pwd=P@ssw0rd10;Integrated Security=SSPI;Persist Security Info=False";
0debug
How to reverse a string in javascript without using any inbuild funcition ,meanwhile it can change the original string : function reverse1(str){ var a = ""; for(var i = 0; i <= str.length/2; i++){ a = str[i]; str[i] = str[str.length-i-1]; str[str.length-i-1] = a; } return str; } var str = "abcdef"; reverse1(str); I want to reverse a string without using any inbuild function ,and i want it to change the original string itself but it doesn't work well. the language is javascript.
0debug
Split on newline, but not newline-space in JS : <p>I am trying to split my string into an array on every new line, but not if a newline begins with a space. </p> <pre><code>ORGANIZER;organizer@example.com //YES ATTENDEE; user@example.com, another@exa //YES mple.com, peter@example.com //NO DESCRIPTION;LANGUAGE=en-US //YES </code></pre>
0debug
static int check_strtox_error(const char *nptr, char *ep, const char **endptr, int libc_errno) { if (libc_errno == 0 && ep == nptr) { libc_errno = EINVAL; } if (!endptr && *ep) { return -EINVAL; } if (endptr) { *endptr = ep; } return -libc_errno; }
1threat
R: find closest match of two data frames : I hope you can help me with this question: I have a data.frame with x and y coordinates and now I want to find the closest matching values on a different data.frame with x and y coordinates. It is important that x&y is considered as one as they are a pair. I hope you understand my question and can help me!
0debug
switch two <a> tag elements on the nav in the DOM wth event listeners : <p>Right now i am working on trying to swap the order of tags on a menu so that they still maintain there event listeners and change order on the front end. For example, </p> <pre><code> &lt;a id = "A" href = ""&gt;&lt;/a&gt; &lt;a id = "B" href = ""&gt;&lt;/a&gt; &lt;a id = "C" href = ""&gt;&lt;/a&gt; &lt;a id = "D" href = ""&gt;&lt;/a&gt; </code></pre> <p>Swap A, B, C, D to any position and at the same time switch them on the front end to represent the same order. Ive tried many different functions like append(), next(), however none work in a way that consistent. </p>
0debug
Flutter: Minimum height on horizontal list view : <p>I'm trying to create a horizontal scrolling list of items in Flutter, and I want that list to only take up the necessary height based on its children. By design “<code>ListView</code> tries to expand to fit the space available in its cross-direction” (from the <a href="https://flutter.io/layout" rel="noreferrer">Flutter docs</a>), which I also notice in that it takes up the whole height of the viewport, but is there a way to make it not do this? Ideally something similar to this (which obviously doesn't work):</p> <pre class="lang-dart prettyprint-override"><code>new ListView( scrollDirection: Axis.horizontal, crossAxisSize: CrossAxisSize.min, children: &lt;Widget&gt;[ new ListItem(), new ListItem(), // ... ], ); </code></pre> <hr> <p>I realize that one way to do this is by wrapping the <code>ListView</code> in a <code>Container</code> with a fixed height. However, I don't necessarily know the height of the items:</p> <pre class="lang-dart prettyprint-override"><code>new Container( height: 97.0, child: new ListView( scrollDirection: Axis.horizontal, children: &lt;Widget&gt;[ new ListItem(), new ListItem(), // ... ], ), ); </code></pre> <hr> <p>I was able to hack together a “solution” by nesting a <code>Row</code> in a <code>SingleChildScrollView</code> in a <code>Column</code> with a <code>mainAxisSize: MainAxisSize.min</code>. However, this doesn't feel like a solution, to me:</p> <pre class="lang-dart prettyprint-override"><code>new Column( mainAxisSize: MainAxisSize.min, children: &lt;Widget&gt;[ new SingleChildScrollView( scrollDirection: Axis.horizontal, child: new Row( children: &lt;Widget&gt;[ new ListItem(), new ListItem(), // ... ], ), ), ], ); </code></pre>
0debug