problem
stringlengths
26
131k
labels
class label
2 classes
DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) { const char *value; BlockBackend *blk; DriveInfo *dinfo = NULL; QDict *bs_opts; QemuOpts *legacy_opts; DriveMediaType media = MEDIA_DISK; BlockInterfaceType type; int cyls, heads, secs, translation; int max_devs, bus_id, unit_id, index; const char *devaddr; const char *werror, *rerror; bool read_only = false; bool copy_on_read; const char *serial; const char *filename; Error *local_err = NULL; int i; const char *deprecated[] = { "serial", "trans", "secs", "heads", "cyls", "addr" }; static const struct { const char *from; const char *to; } opt_renames[] = { { "iops", "throttling.iops-total" }, { "iops_rd", "throttling.iops-read" }, { "iops_wr", "throttling.iops-write" }, { "bps", "throttling.bps-total" }, { "bps_rd", "throttling.bps-read" }, { "bps_wr", "throttling.bps-write" }, { "iops_max", "throttling.iops-total-max" }, { "iops_rd_max", "throttling.iops-read-max" }, { "iops_wr_max", "throttling.iops-write-max" }, { "bps_max", "throttling.bps-total-max" }, { "bps_rd_max", "throttling.bps-read-max" }, { "bps_wr_max", "throttling.bps-write-max" }, { "iops_size", "throttling.iops-size" }, { "group", "throttling.group" }, { "readonly", BDRV_OPT_READ_ONLY }, }; for (i = 0; i < ARRAY_SIZE(opt_renames); i++) { qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to, &local_err); if (local_err) { error_report_err(local_err); return NULL; } } value = qemu_opt_get(all_opts, "cache"); if (value) { int flags = 0; bool writethrough; if (bdrv_parse_cache_mode(value, &flags, &writethrough) != 0) { error_report("invalid cache option"); return NULL; } if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_WB)) { qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_WB, !writethrough, &error_abort); } if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_DIRECT)) { qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_DIRECT, !!(flags & BDRV_O_NOCACHE), &error_abort); } if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_NO_FLUSH)) { qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_NO_FLUSH, !!(flags & BDRV_O_NO_FLUSH), &error_abort); } qemu_opt_unset(all_opts, "cache"); } bs_opts = qdict_new(); qemu_opts_to_qdict(all_opts, bs_opts); legacy_opts = qemu_opts_create(&qemu_legacy_drive_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err); if (local_err) { error_report_err(local_err); goto fail; } if (qemu_opt_get(legacy_opts, "boot") != NULL) { fprintf(stderr, "qemu-kvm: boot=on|off is deprecated and will be " "ignored. Future versions will reject this parameter. Please " "update your scripts.\n"); } if (!qtest_enabled()) { for (i = 0; i < ARRAY_SIZE(deprecated); i++) { if (qemu_opt_get(legacy_opts, deprecated[i]) != NULL) { error_report("'%s' is deprecated, please use the corresponding " "option of '-device' instead", deprecated[i]); } } } value = qemu_opt_get(legacy_opts, "media"); if (value) { if (!strcmp(value, "disk")) { media = MEDIA_DISK; } else if (!strcmp(value, "cdrom")) { media = MEDIA_CDROM; read_only = true; } else { error_report("'%s' invalid media", value); goto fail; } } read_only |= qemu_opt_get_bool(legacy_opts, BDRV_OPT_READ_ONLY, false); copy_on_read = qemu_opt_get_bool(legacy_opts, "copy-on-read", false); if (read_only && copy_on_read) { error_report("warning: disabling copy-on-read on read-only drive"); copy_on_read = false; } qdict_put_str(bs_opts, BDRV_OPT_READ_ONLY, read_only ? "on" : "off"); qdict_put_str(bs_opts, "copy-on-read", copy_on_read ? "on" : "off"); value = qemu_opt_get(legacy_opts, "if"); if (value) { for (type = 0; type < IF_COUNT && strcmp(value, if_name[type]); type++) { } if (type == IF_COUNT) { error_report("unsupported bus type '%s'", value); goto fail; } } else { type = block_default_type; } cyls = qemu_opt_get_number(legacy_opts, "cyls", 0); heads = qemu_opt_get_number(legacy_opts, "heads", 0); secs = qemu_opt_get_number(legacy_opts, "secs", 0); if (cyls || heads || secs) { if (cyls < 1) { error_report("invalid physical cyls number"); goto fail; } if (heads < 1) { error_report("invalid physical heads number"); goto fail; } if (secs < 1) { error_report("invalid physical secs number"); goto fail; } } translation = BIOS_ATA_TRANSLATION_AUTO; value = qemu_opt_get(legacy_opts, "trans"); if (value != NULL) { if (!cyls) { error_report("'%s' trans must be used with cyls, heads and secs", value); goto fail; } if (!strcmp(value, "none")) { translation = BIOS_ATA_TRANSLATION_NONE; } else if (!strcmp(value, "lba")) { translation = BIOS_ATA_TRANSLATION_LBA; } else if (!strcmp(value, "large")) { translation = BIOS_ATA_TRANSLATION_LARGE; } else if (!strcmp(value, "rechs")) { translation = BIOS_ATA_TRANSLATION_RECHS; } else if (!strcmp(value, "auto")) { translation = BIOS_ATA_TRANSLATION_AUTO; } else { error_report("'%s' invalid translation type", value); goto fail; } } if (media == MEDIA_CDROM) { if (cyls || secs || heads) { error_report("CHS can't be set with media=cdrom"); goto fail; } } bus_id = qemu_opt_get_number(legacy_opts, "bus", 0); unit_id = qemu_opt_get_number(legacy_opts, "unit", -1); index = qemu_opt_get_number(legacy_opts, "index", -1); max_devs = if_max_devs[type]; if (index != -1) { if (bus_id != 0 || unit_id != -1) { error_report("index cannot be used with bus and unit"); goto fail; } bus_id = drive_index_to_bus_id(type, index); unit_id = drive_index_to_unit_id(type, index); } if (unit_id == -1) { unit_id = 0; while (drive_get(type, bus_id, unit_id) != NULL) { unit_id++; if (max_devs && unit_id >= max_devs) { unit_id -= max_devs; bus_id++; } } } if (max_devs && unit_id >= max_devs) { error_report("unit %d too big (max is %d)", unit_id, max_devs - 1); goto fail; } if (drive_get(type, bus_id, unit_id) != NULL) { error_report("drive with bus=%d, unit=%d (index=%d) exists", bus_id, unit_id, index); goto fail; } serial = qemu_opt_get(legacy_opts, "serial"); if (qemu_opts_id(all_opts) == NULL) { char *new_id; const char *mediastr = ""; if (type == IF_IDE || type == IF_SCSI) { mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; } if (max_devs) { new_id = g_strdup_printf("%s%i%s%i", if_name[type], bus_id, mediastr, unit_id); } else { new_id = g_strdup_printf("%s%s%i", if_name[type], mediastr, unit_id); } qdict_put_str(bs_opts, "id", new_id); g_free(new_id); } devaddr = qemu_opt_get(legacy_opts, "addr"); if (devaddr && type != IF_VIRTIO) { error_report("addr is not supported by this bus type"); goto fail; } if (type == IF_VIRTIO) { QemuOpts *devopts; devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, &error_abort); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(devopts, "driver", "virtio-blk-ccw", &error_abort); } else { qemu_opt_set(devopts, "driver", "virtio-blk-pci", &error_abort); } qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"), &error_abort); if (devaddr) { qemu_opt_set(devopts, "addr", devaddr, &error_abort); } } filename = qemu_opt_get(legacy_opts, "file"); werror = qemu_opt_get(legacy_opts, "werror"); if (werror != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("werror is not supported by this bus type"); goto fail; } qdict_put_str(bs_opts, "werror", werror); } rerror = qemu_opt_get(legacy_opts, "rerror"); if (rerror != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); goto fail; } qdict_put_str(bs_opts, "rerror", rerror); } blk = blockdev_init(filename, bs_opts, &local_err); bs_opts = NULL; if (!blk) { if (local_err) { error_report_err(local_err); } goto fail; } else { assert(!local_err); } dinfo = g_malloc0(sizeof(*dinfo)); dinfo->opts = all_opts; dinfo->cyls = cyls; dinfo->heads = heads; dinfo->secs = secs; dinfo->trans = translation; dinfo->type = type; dinfo->bus = bus_id; dinfo->unit = unit_id; dinfo->devaddr = devaddr; dinfo->serial = g_strdup(serial); blk_set_legacy_dinfo(blk, dinfo); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: dinfo->media_cd = media == MEDIA_CDROM; break; default: break; } fail: qemu_opts_del(legacy_opts); QDECREF(bs_opts); return dinfo; }
1threat
the zone does not have enough resources available to fulfill the request/ the resource is not ready : <p>I failed to start my instance (through the web browser), it gave me the error: </p> <blockquote> <p>"The zone 'projects/XXXXX/zones/europe-west4-b' does not have enough resources available to fulfill the request. Try a different zone, or try again later."</p> </blockquote> <p>I thought it might be the quota problem at first, after checking my quota, it showed all good. Actually, I listed the available zones, europe-west4-b was available, but I still gave a shot to move the zone. Then I tried <code>"gcloud compute instances move XXXX --zone europe-west4-b --destination-zone europe-west4-c"</code>, however, it still failed, popped up the error: </p> <blockquote> <p>"ERROR: (gcloud.compute.instances.move) Instance cannot be moved while in state: TERMINATED"</p> </blockquote> <p>Okay, terminated... then I tried to restart it by <code>"gcloud compute instances reset XXX"</code>, the error showed in the way:</p> <blockquote> <p>ERROR: (gcloud.compute.instances.reset) Could not fetch resource: - The resource 'projects/XXXXX/zones/europe-west4-b/instances/XXX' is not ready</p> </blockquote> <p>I searched the error, some people solved this problem by deleting the disk. While I don't want to wipe the memory, how could I solve this problem?</p> <p>BTW, I only have one instance, with one persistent disk attached.</p>
0debug
Chart.js creating a line graph using dates : <p>I can't seem to get Chart.js to work with dates. I have tried quite a few different methods:</p> <pre><code>let examChart = document.getElementById("examChart").getContext("2d"); let examLineChart = new Chart(examChart, { type: "line", data: [ { t: new Date("2015-3-15 13:3"), y: 12 }, { t: new Date("2015-3-25 13:2"), y: 21 }, { t: new Date("2015-4-25 14:12"), y: 32 } ], options: { label: "placeholder" } }); </code></pre> <p>And:</p> <pre><code>let examChart = document.getElementById("examChart").getContext("2d"); let examLineChart = new Chart(examChart, { type: "line", data: [ { t: "2015-3-15 13:3", y: 12 }, { t: "2015-3-25 13:2", y: 21 }, { t: "2015-4-25 14:12", y: 32 } ], options: { label: "placeholder" } }); </code></pre> <p>And:</p> <pre><code>let examChart = document.getElementById("examChart").getContext("2d"); let examLineChart = new Chart(examChart, { type: "line", data: [ { t: "Sun Mar 15 2015 12:03:45 GMT+0000 (GMT Standard Time)", y: 12 }, { t: "Wed Mar 25 2015 12:02:15 GMT+0000 (GMT Standard Time)", y: 21 }, { t: "Sat Apr 25 2015 13:12:30 GMT+0100 (GMT Daylight Time)", y: 32 } ], options: { label: "placeholder" } }); </code></pre> <p>To cover just a few of my attempts, I just can't seem to get how to set dates properly even after reading the documentation (<a href="http://www.chartjs.org/docs/latest/axes/cartesian/time.html" rel="noreferrer">http://www.chartjs.org/docs/latest/axes/cartesian/time.html</a>) (they don't actually give an example)</p> <p>The HTML being used:</p> <pre><code>&lt;div class="container"&gt; &lt;canvas id="examChart"&gt;&lt;/canvas&gt; &lt;/div&gt; </code></pre> <p>I just have no idea, although I imagine this is a rather simple problem, any help would be greatly appreciated.</p>
0debug
How does one scrape all the products from a random website? : <p>I tried to get all the products from <a href="https://www.richelieu.com/" rel="noreferrer">this website</a> but somehow I don't think I chose the best method because some of them are missing and I can't figure out why. It's not the first time when I get stuck when it comes to this.</p> <p>The way I'm doing it now is like this:</p> <ul> <li>go to the <a href="https://www.richelieu.com/us/en/index" rel="noreferrer">index page</a> of the website</li> <li>get all the categories from there (A-Z 0-9)</li> <li>access each of the above category and recursively go through all the subcategories from there until I reach the products page</li> <li>when I reach the products page, check if the product has more SKUs. If it has, get the links. Otherwise, that's the only SKU.</li> </ul> <p>Now, the below code works but it just doesn't get all the products and I don't see any reasons for why it'd skip some. Maybe the way I approached everything is wrong. </p> <pre><code>from lxml import html from random import randint from string import ascii_uppercase from time import sleep from requests import Session INDEX_PAGE = 'https://www.richelieu.com/us/en/index' session_ = Session() def retry(link): wait = randint(0, 10) try: return session_.get(link).text except Exception as e: print('Retrying product page in {} seconds because: {}'.format(wait, e)) sleep(wait) return retry(link) def get_category_sections(): au = list(ascii_uppercase) au.remove('Q') au.remove('Y') au.append('0-9') return au def get_categories(): html_ = retry(INDEX_PAGE) page = html.fromstring(html_) sections = get_category_sections() for section in sections: for link in page.xpath("//div[@id='index-{}']//li/a/@href".format(section)): yield '{}?imgMode=m&amp;sort=&amp;nbPerPage=200'.format(link) def dig_up_products(url): html_ = retry(url) page = html.fromstring(html_) for link in page.xpath( '//h2[contains(., "CATEGORIES")]/following-sibling::*[@id="carouselSegment2b"]//li//a/@href' ): yield from dig_up_products(link) for link in page.xpath('//ul[@id="prodResult"]/li//div[@class="imgWrapper"]/a/@href'): yield link for link in page.xpath('//*[@id="ts_resultList"]/div/nav/ul/li[last()]/a/@href'): if link != '#': yield from dig_up_products(link) def check_if_more_products(tree): more_prods = [ all_prod for all_prod in tree.xpath("//div[@id='pm2_prodTableForm']//tbody/tr/td[1]//a/@href") ] if not more_prods: return False return more_prods def main(): for category_link in get_categories(): for product_link in dig_up_products(category_link): product_page = retry(product_link) product_tree = html.fromstring(product_page) more_products = check_if_more_products(product_tree) if not more_products: print(product_link) else: for sku_product_link in more_products: print(sku_product_link) if __name__ == '__main__': main() </code></pre> <hr> <p>Now, the question might be too generic but I wonder if there's a rule of thumb to follow when someone wants to get all the data (products, in this case) from a website. Could someone please walk me through the whole process of discovering what's the best way to approach a scenario like this?</p>
0debug
Trying to debug error arrayindexoutofbounds exception:4. (looked at other solutions no luck) : I'm trying to achieve this kind of output **Enter size of list 1: 5** **Enter items in list 1: 1 5 16 91 248** **Enter size of list 2: 4** **Enter items in list 2: 2 4 5 27** **list1 is 1 5 16 91 248** **list2 is 2 4 5 27** **The merged list is 1 2 4 5 5 16 27 91 248** What i'm getting is **Enter size of list 1: 5** **Enter items in list 1: 1 5 16 91 248** **Enter size of list 2: 4** **Enter items in list 2: 2 4 5 27** **list1 is 1 5 16 91 248** **list2 is 2 4 5 27 Exception in thread"main" java.lang.ArrayIndexOutofBoundsException: 4 at MergeTest.main(Mergetest.java:41)** I finished writing the code and now i'm lost because i'm getting an **Array indexoutOfBounds Exceptoin:4** and i already looked at other solutions people did and i'm still not getting it. Somebody told me it may be this part of the code but i'm still completely lost. (a[firstIndex] <= b[secondIndex]) { c[thirdIndex] = a[firstIndex]; firstIndex++; } else { c[thirdIndex] = b[secondIndex]; secondIndex++; } thirdIndex++; }" Here is what i have so far. import java.util.Scanner; public class MergeTest{ public static void main(String[] args){ int firstLength, secondLength; Scanner keyboard = new Scanner(System.in); System.out.print("Enter the size of list 1: "); firstLength = keyboard.nextInt(); int a[] = new int[firstLength]; System.out.println("Enter the items of list 1: "); for (int i = 0; i < firstLength; i++) { a[i] = keyboard.nextInt(); } System.out.print("Enter the size of list 2: "); secondLength = keyboard.nextInt(); int b[] = new int[secondLength]; System.out.println("Enter the items of list 2: "); for (int i = 0; i < secondLength; i++) { b[i] = keyboard.nextInt(); } System.out.print("list1 is "); for (int i = 0; i < firstLength; i++) { System.out.print(a[i]); System.out.print(" "); } System.out.println(); System.out.print("list2 is "); for (int i = 0; i < firstLength; i++) { System.out.print(b[i]); System.out.print(" "); } System.out.println(); int thirdLength = firstLength + secondLength; int c[] = new int[thirdLength]; int firstIndex = 0; int secondIndex = 0; int thirdIndex = 0; while (firstIndex < firstLength && secondIndex < secondLength) { if (a[firstIndex] <= b[secondIndex]) { c[thirdIndex] = a[firstIndex]; firstIndex++; } else { c[thirdIndex] = b[secondIndex]; secondIndex++; } thirdIndex++; } System.out.print("Here is the output:"); for (int z = 0; z < thirdLength; z++) { System.out.print(c[z]); } } } Any feedback is appreciated.
0debug
Whats the benefit of passing a CancellationToken as a parameter to Task.Run? : <p>Obviously I realize it enables me to cancel the task, but this code achieves the same effect without having to pass the token into Task.Run</p> <p>What is the practical difference? Thanks.</p> <pre><code>Dim cts As New CancellationTokenSource Dim ct As CancellationToken = cts.Token Task.Run(Sub() For i = 1 To 1000 Debug.WriteLine(i) ct.ThrowIfCancellationRequested() Threading.Thread.Sleep(10) Next End Sub) cts.CancelAfter(500) </code></pre> <p>VS</p> <pre><code>Dim cts As New CancellationTokenSource Dim ct As CancellationToken = cts.Token Task.Run(Sub() For i = 1 To 1000 Debug.WriteLine(i) ct.ThrowIfCancellationRequested() Threading.Thread.Sleep(10) Next End Sub, ct) cts.CancelAfter(500) </code></pre>
0debug
Proper way of testing ASP.NET Core IMemoryCache : <p>I'm writing a simple test case that tests that my controller calls the cache before calling my service. I'm using xUnit and Moq for the task.</p> <p>I'm facing an issue because <code>GetOrCreateAsync&lt;T&gt;</code> is an extension method, and those can't be mocked by the framework. I relied on internal details to figure out I can mock <code>TryGetValue</code> instead and get away with my test (see <a href="https://github.com/aspnet/Caching/blob/c432e5827e4505c05ac7ad8ef1e3bc6bf784520b/src/Microsoft.Extensions.Caching.Abstractions/MemoryCacheExtensions.cs#L116" rel="noreferrer">https://github.com/aspnet/Caching/blob/c432e5827e4505c05ac7ad8ef1e3bc6bf784520b/src/Microsoft.Extensions.Caching.Abstractions/MemoryCacheExtensions.cs#L116</a>)</p> <pre><code>[Theory, AutoDataMoq] public async Task GivenPopulatedCacheDoesntCallService( Mock&lt;IMemoryCache&gt; cache, SearchRequestViewModel input, MyViewModel expected) { object expectedOut = expected; cache .Setup(s =&gt; s.TryGetValue(input.Serialized(), out expectedOut)) .Returns(true); var sut = new MyController(cache.Object, Mock.Of&lt;ISearchService&gt;()); var actual = await sut.Search(input); Assert.Same(expected, actual); } </code></pre> <p>I can't sleep with the fact that I'm peeking into the MemoryCache implementation details and it can change at any point.</p> <p>For reference, this is the SUT code:</p> <pre><code>public async Task&lt;MyViewModel&gt; Search(SearchRequestViewModel request) { return await cache.GetOrCreateAsync(request.Serialized(), (e) =&gt; search.FindAsync(request)); } </code></pre> <p>Would you recommend testing any differently?</p>
0debug
Access nth child of ViewChildren Querylist (Angular) : <p>I'm trying to access the nth child of a viewchildren querylist.</p> <p>Below is my TS:</p> <pre><code>@ViewChildren(PopoverDirective) popovers: QueryList&lt;PopoverDirective&gt;; console.log(this.popovers) </code></pre> <p>The console.log shows changes, first, last, length and _results.</p> <p>How can I access the nth child (i.e., 3rd, instead of first)?</p> <p>When I try to do this with _results (i.e., this.popovers._results[2]), I get an error.</p> <p>Thank you.</p>
0debug
C# With Ram Optimize : <p>you can optimize the RAM usage of an application with the following code with AutoIt. How is this in C#, How do I set up?</p> <pre><code>Func _ReduceMemory($iPid) Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $iPid) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) Return $ai_Return[0] EndFunc </code></pre>
0debug
align text with inputbox and div : div which i use as border i wanted it to be in vertically center it looks like div going upwards [![div going upward][1]][1] <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <label> Application </label> <input type="text" style="width:10%; bottom:20px;"> <div style="width:1px; height:20px; background-color:grey;display: inline-block"></div> <label> Iteration </label> <input type="text" style="width:10%"> <!-- end snippet --> [1]: http://i.stack.imgur.com/sSh4Q.png
0debug
Is it possible to see a log or history of previous iTerm2 sessions? : <p>Is there a log of recent terminal sessions at all? Or anyway I can see what was written to console before I last quit?</p>
0debug
Test string format : <p>How can I test whether a string is in the format beginning with "R", followed by up to 8 numbers?</p>
0debug
int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len) { uint32_t *hc = (uint32_t*)buf; struct kvm_ppc_pvinfo pvinfo; if (!kvmppc_get_pvinfo(env, &pvinfo)) { memcpy(buf, pvinfo.hcall, buf_len); return 0; } hc[0] = cpu_to_be32(0x08000048); hc[1] = cpu_to_be32(0x3860ffff); hc[2] = cpu_to_be32(0x48000008); hc[3] = cpu_to_be32(bswap32(0x3860ffff)); return 0; }
1threat
static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue, BlockDriverState *bs, QDict *options, int flags, const BdrvChildRole *role, QDict *parent_options, int parent_flags) { assert(bs != NULL); BlockReopenQueueEntry *bs_entry; BdrvChild *child; QDict *old_options, *explicit_options; if (bs_queue == NULL) { bs_queue = g_new0(BlockReopenQueue, 1); QSIMPLEQ_INIT(bs_queue); } if (!options) { options = qdict_new(); } if (!parent_options) { update_options_from_flags(options, flags); } old_options = qdict_clone_shallow(bs->explicit_options); bdrv_join_options(bs, options, old_options); QDECREF(old_options); explicit_options = qdict_clone_shallow(options); if (parent_options) { assert(!flags); role->inherit_options(&flags, options, parent_flags, parent_options); } old_options = qdict_clone_shallow(bs->options); bdrv_join_options(bs, options, old_options); QDECREF(old_options); flags &= ~BDRV_O_PROTOCOL; QLIST_FOREACH(child, &bs->children, next) { QDict *new_child_options; char *child_key_dot; if (child->bs->inherits_from != bs) { continue; } child_key_dot = g_strdup_printf("%s.", child->name); qdict_extract_subqdict(options, &new_child_options, child_key_dot); g_free(child_key_dot); bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, 0, child->role, options, flags); } bs_entry = g_new0(BlockReopenQueueEntry, 1); QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry); bs_entry->state.bs = bs; bs_entry->state.options = options; bs_entry->state.explicit_options = explicit_options; bs_entry->state.flags = flags; return bs_queue; }
1threat
Do you use pure or impure functions in your React components? : <p>So i've been getting a little bit more into functional programming and immutability.</p> <p>What I often do when writing a react component is a helper function that returns something based on props/state.</p> <p>Currently I write both Pure and Impure functions even though most of them could be pure.</p> <p>Examples for both cases:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>//pure function const posts = this.props.posts; const postId = this.props.selectedPostId; const pureFunc = (postId, posts) =&gt; (posts.find(post =&gt; post.id === postId); //impure function const impureFunc = () =&gt; ( this.props.posts.find( post =&gt; post.id === this.props.selectedPostId ) )</code></pre> </div> </div> </p> <p>Please, let's refrain from commenting on the overall structure and validity of the code.</p> <p>The main point of comparison is to pass arguments and operate on those OR pass something from <code>this</code> context which is not like a global state, but it does feel a lot less like functional programming.</p> <p>What do you prefer and think?</p>
0debug
Kotlin Regex named groups support : <p>Does Kotlin have support for named regex groups?</p> <p>Named regex group looks like this: <code>(?&lt;name&gt;...)</code></p>
0debug
static void ib700_pc_init(PCIBus *unused) { register_savevm("ib700_wdt", -1, 0, ib700_save, ib700_load, NULL); register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, NULL); register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, NULL); }
1threat
int mpeg4_decode_picture_header(MpegEncContext * s) { int time_incr, startcode, state, v; redo: align_get_bits(&s->gb); state = 0xff; for(;;) { v = get_bits(&s->gb, 8); if (state == 0x000001) { state = ((state << 8) | v) & 0xffffff; startcode = state; break; } state = ((state << 8) | v) & 0xffffff; if( get_bits_count(&s->gb) > s->gb.size*8-32){ printf("no VOP startcode found\n"); return -1; } } if (startcode == 0x120) { int width, height, vo_ver_id; skip_bits(&s->gb, 1); skip_bits(&s->gb, 8); if (get_bits1(&s->gb) != 0) { vo_ver_id = get_bits(&s->gb, 4); skip_bits(&s->gb, 3); } else { vo_ver_id = 1; } s->aspect_ratio_info= get_bits(&s->gb, 4); if(s->aspect_ratio_info == EXTENDET_PAR){ skip_bits(&s->gb, 8); skip_bits(&s->gb, 8); } if(get_bits1(&s->gb)){ printf("vol control parameter not supported\n"); return -1; } s->shape = get_bits(&s->gb, 2); if(s->shape != RECT_SHAPE) printf("only rectangular vol supported\n"); if(s->shape == GRAY_SHAPE && vo_ver_id != 1){ printf("Gray shape not supported\n"); skip_bits(&s->gb, 4); } skip_bits1(&s->gb); s->time_increment_resolution = get_bits(&s->gb, 16); s->time_increment_bits = av_log2(s->time_increment_resolution - 1) + 1; if (s->time_increment_bits < 1) s->time_increment_bits = 1; skip_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, s->time_increment_bits); } if (s->shape != BIN_ONLY_SHAPE) { if (s->shape == RECT_SHAPE) { skip_bits1(&s->gb); width = get_bits(&s->gb, 13); skip_bits1(&s->gb); height = get_bits(&s->gb, 13); skip_bits1(&s->gb); if(width && height){ s->width = width; s->height = height; } } if(get_bits1(&s->gb)) printf("interlaced not supported\n"); if(!get_bits1(&s->gb)) printf("OBMC not supported\n"); if (vo_ver_id == 1) { s->vol_sprite_usage = get_bits1(&s->gb); } else { s->vol_sprite_usage = get_bits(&s->gb, 2); } if(s->vol_sprite_usage==STATIC_SPRITE) printf("Static Sprites not supported\n"); if(s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE){ if(s->vol_sprite_usage==STATIC_SPRITE){ s->sprite_width = get_bits(&s->gb, 13); skip_bits1(&s->gb); s->sprite_height= get_bits(&s->gb, 13); skip_bits1(&s->gb); s->sprite_left = get_bits(&s->gb, 13); skip_bits1(&s->gb); s->sprite_top = get_bits(&s->gb, 13); skip_bits1(&s->gb); } s->num_sprite_warping_points= get_bits(&s->gb, 6); s->sprite_warping_accuracy = get_bits(&s->gb, 2); s->sprite_brightness_change= get_bits1(&s->gb); if(s->vol_sprite_usage==STATIC_SPRITE) s->low_latency_sprite= get_bits1(&s->gb); } if (get_bits1(&s->gb) == 1) { s->quant_precision = get_bits(&s->gb, 4); if(get_bits(&s->gb, 4)!=8) printf("N-bit not supported\n"); } else { s->quant_precision = 5; } if(get_bits1(&s->gb)) printf("Quant-Type not supported\n"); if(vo_ver_id != 1) s->quarter_sample= get_bits1(&s->gb); else s->quarter_sample=0; if(!get_bits1(&s->gb)) printf("Complexity estimation not supported\n"); #if 0 if(get_bits1(&s->gb)) printf("resync disable\n"); #else skip_bits1(&s->gb); #endif s->data_partioning= get_bits1(&s->gb); if(s->data_partioning){ printf("data partitioning not supported\n"); skip_bits1(&s->gb); } if(vo_ver_id != 1) { s->new_pred= get_bits1(&s->gb); if(s->new_pred){ printf("new pred not supported\n"); skip_bits(&s->gb, 2); skip_bits1(&s->gb); } s->reduced_res_vop= get_bits1(&s->gb); if(s->reduced_res_vop) printf("reduced resolution VOP not supported\n"); } else{ s->new_pred=0; s->reduced_res_vop= 0; } s->scalability= get_bits1(&s->gb); if (s->scalability) { printf("bad scalability!!!\n"); return -1; } } goto redo; } else if (startcode == 0x1b2) { char buf[256]; int i; int e; int ver, build; buf[0]= show_bits(&s->gb, 8); for(i=1; i<256; i++){ buf[i]= show_bits(&s->gb, 16)&0xFF; if(buf[i]==0) break; skip_bits(&s->gb, 8); } buf[255]=0; e=sscanf(buf, "DivX%dBuild%d", &ver, &build); if(e==2){ s->divx_version= ver; s->divx_build= build; if(s->picture_number==0){ printf("This file was encoded with DivX%d Build%d\n", ver, build); if(ver==500 && build==413){ printf("WARNING: this version of DivX is not MPEG4 compatible, trying to workaround these bugs...\n"); }else{ printf("hmm, i havnt seen that version of divx yet, lets assume they fixed these bugs ...\n" "using mpeg4 decoder, if it fails contact the developers (of ffmpeg)\n"); } } } goto redo; } else if (startcode != 0x1b6) { goto redo; } s->pict_type = get_bits(&s->gb, 2) + 1; time_incr=0; while (get_bits1(&s->gb) != 0) time_incr++; check_marker(&s->gb, "before time_increment"); s->time_increment= get_bits(&s->gb, s->time_increment_bits); if(s->pict_type!=B_TYPE){ s->time_base+= time_incr; s->last_non_b_time[1]= s->last_non_b_time[0]; s->last_non_b_time[0]= s->time_base*s->time_increment_resolution + s->time_increment; }else{ s->time= (s->last_non_b_time[1]/s->time_increment_resolution + time_incr)*s->time_increment_resolution; s->time+= s->time_increment; } if(check_marker(&s->gb, "before vop_coded")==0 && s->picture_number==0){ printf("hmm, seems the headers arnt complete, trying to guess time_increment_bits\n"); for(s->time_increment_bits++ ;s->time_increment_bits<16; s->time_increment_bits++){ if(get_bits1(&s->gb)) break; } printf("my guess is %d bits ;)\n",s->time_increment_bits); } if (get_bits1(&s->gb) != 1) goto redo; if (s->shape != BIN_ONLY_SHAPE && ( s->pict_type == P_TYPE || (s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE))) { s->no_rounding = get_bits1(&s->gb); } else { s->no_rounding = 0; } reduced res stuff if (s->shape != RECT_SHAPE) { if (s->vol_sprite_usage != 1 || s->pict_type != I_TYPE) { int width, height, hor_spat_ref, ver_spat_ref; width = get_bits(&s->gb, 13); skip_bits1(&s->gb); height = get_bits(&s->gb, 13); skip_bits1(&s->gb); hor_spat_ref = get_bits(&s->gb, 13); skip_bits1(&s->gb); ver_spat_ref = get_bits(&s->gb, 13); } skip_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } } complexity estimation stuff if (s->shape != BIN_ONLY_SHAPE) { skip_bits(&s->gb, 3); interlaced specific bits } if(s->pict_type == S_TYPE && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){ if(s->num_sprite_warping_points){ mpeg4_decode_sprite_trajectory(s); } if(s->sprite_brightness_change) printf("sprite_brightness_change not supported\n"); if(s->vol_sprite_usage==STATIC_SPRITE) printf("static sprite not supported\n"); } if (s->shape != BIN_ONLY_SHAPE) { s->qscale = get_bits(&s->gb, 5); if(s->qscale==0){ printf("Error, header damaged or not MPEG4 header (qscale=0)\n"); return -1; } if (s->pict_type != I_TYPE) { s->f_code = get_bits(&s->gb, 3); if(s->f_code==0){ printf("Error, header damaged or not MPEG4 header (f_code=0)\n"); return -1; } } if (s->pict_type == B_TYPE) { s->b_code = get_bits(&s->gb, 3); } if(!s->scalability){ if (s->shape!=RECT_SHAPE && s->pict_type!=I_TYPE) { skip_bits1(&s->gb); } } } s->picture_number++; return 0; }
1threat
using Rstudio, how to import xlsx file larger than 100MB? : <p>How to work with excel file larger than 100 MB, I already imported but it doesn't running the shiny app?</p>
0debug
static void v9fs_statfs(void *opaque) { int32_t fid; ssize_t retval = 0; size_t offset = 7; V9fsFidState *fidp; struct statfs stbuf; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; pdu_unmarshal(pdu, offset, "d", &fid); fidp = get_fid(pdu, fid); if (fidp == NULL) { retval = -ENOENT; goto out_nofid; } retval = v9fs_co_statfs(pdu, &fidp->path, &stbuf); if (retval < 0) { goto out; } retval = offset; retval += v9fs_fill_statfs(s, pdu, &stbuf); out: put_fid(pdu, fidp); out_nofid: complete_pdu(s, pdu, retval); return; }
1threat
Storing injector instance for use in components : <p>Before RC5 I was using appref injector as a service locator like this:</p> <p>Startup.ts</p> <pre><code>bootstrap(...) .then((appRef: any) =&gt; { ServiceLocator.injector = appRef.injector; }); </code></pre> <p>ServiceLocator.ts</p> <pre><code>export class ServiceLocator { static injector: Injector; } </code></pre> <p>components:</p> <pre><code>let myServiceInstance = &lt;MyService&gt;ServiceLocator.injector.get(MyService) </code></pre> <p>Now doing the same in bootstrapModule().then() doesn't work because components seems to start to execute before the promise. </p> <p>Is there a way to store the injector instance before components load?</p> <p>I don't want to use constructor injection because I'm using the injector in a base component which derived by many components and I rather not inject the injector to all of them.</p>
0debug
How to check the object type on runtime in TypeScript? : <p>I'm trying to find a way to pass an object to function in and check it type in a runtime. This is a pseudo code:</p> <pre><code>func(obj:any){ if(typeof obj === "A"){ // do something } else if(typeof obj === "B"{ //do something else } } a:A; b:B; func(a); </code></pre> <p>But typeof is always return "object" and I could not find a way to get the real type of "a" or "b". The instanceof did not work either and return the same. Any idea how to do it in a TypeScript?</p> <p>Thank you for your help!!!</p>
0debug
static void cpu_ppc_decr_cb(void *opaque) { PowerPCCPU *cpu = opaque; _cpu_ppc_store_decr(cpu, 0x00000000, 0xFFFFFFFF, 1); }
1threat
static void uhci_process_frame(UHCIState *s) { uint32_t frame_addr, link, old_td_ctrl, val, int_mask; uint32_t curr_qh, td_count = 0; int cnt, ret; UHCI_TD td; UHCI_QH qh; QhDb qhdb; frame_addr = s->fl_base_addr + ((s->frnum & 0x3ff) << 2); pci_dma_read(&s->dev, frame_addr, &link, 4); le32_to_cpus(&link); int_mask = 0; curr_qh = 0; qhdb_reset(&qhdb); for (cnt = FRAME_MAX_LOOPS; is_valid(link) && cnt; cnt--) { if (s->frame_bytes >= s->frame_bandwidth) { trace_usb_uhci_frame_stop_bandwidth(); break; } if (is_qh(link)) { trace_usb_uhci_qh_load(link & ~0xf); if (qhdb_insert(&qhdb, link)) { if (td_count == 0) { trace_usb_uhci_frame_loop_stop_idle(); break; } else { trace_usb_uhci_frame_loop_continue(); td_count = 0; qhdb_reset(&qhdb); qhdb_insert(&qhdb, link); } } pci_dma_read(&s->dev, link & ~0xf, &qh, sizeof(qh)); le32_to_cpus(&qh.link); le32_to_cpus(&qh.el_link); if (!is_valid(qh.el_link)) { curr_qh = 0; link = qh.link; } else { curr_qh = link; link = qh.el_link; } continue; } uhci_read_td(s, &td, link); trace_usb_uhci_td_load(curr_qh & ~0xf, link & ~0xf, td.ctrl, td.token); old_td_ctrl = td.ctrl; ret = uhci_handle_td(s, NULL, &td, link, &int_mask); if (old_td_ctrl != td.ctrl) { val = cpu_to_le32(td.ctrl); pci_dma_write(&s->dev, (link & ~0xf) + 4, &val, sizeof(val)); } switch (ret) { case TD_RESULT_STOP_FRAME: goto out; case TD_RESULT_NEXT_QH: case TD_RESULT_ASYNC_CONT: trace_usb_uhci_td_nextqh(curr_qh & ~0xf, link & ~0xf); link = curr_qh ? qh.link : td.link; continue; case TD_RESULT_ASYNC_START: trace_usb_uhci_td_async(curr_qh & ~0xf, link & ~0xf); link = curr_qh ? qh.link : td.link; continue; case TD_RESULT_COMPLETE: trace_usb_uhci_td_complete(curr_qh & ~0xf, link & ~0xf); link = td.link; td_count++; s->frame_bytes += (td.ctrl & 0x7ff) + 1; if (curr_qh) { qh.el_link = link; val = cpu_to_le32(qh.el_link); pci_dma_write(&s->dev, (curr_qh & ~0xf) + 4, &val, sizeof(val)); if (!depth_first(link)) { curr_qh = 0; link = qh.link; } } break; default: assert(!"unknown return code"); } } out: s->pending_int_mask |= int_mask; }
1threat
Spring File Upload - 'Required request part is not present' : <p>I am trying to send POST request to my controller but cannot pass any parameter in any type unless I decide to use JSON. My goal is to pass a String and a file to my controller but I keep getting <code>Required request part 'xxx' is not present</code> error.</p> <pre><code>@RestController public class ConfigurationController { @PostMapping(value = "/config") public ResponseEntity&lt;?&gt; saveEnvironmentConfig(@RequestParam("file") MultipartFile uploadfile){ return ResponseEntity.ok().body(null); } } </code></pre> <p>I cannot have file here. Similarly if I try:</p> <pre><code>@RestController public class ConfigurationController { @PostMapping(value = "/config") public ResponseEntity&lt;?&gt; saveEnvironmentConfig(@RequestParam("name") String name){ return ResponseEntity.ok().body(null); } } </code></pre> <p>same thing I cannot get name here. </p> <p>I am sending request via Postman as given in following screenshot:</p> <p><a href="https://i.stack.imgur.com/gorVP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gorVP.png" alt="Postman Request"></a></p> <p><a href="https://i.stack.imgur.com/DYp6L.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DYp6L.png" alt="Postman Request 2"></a></p> <p>The only header tag is for Authorization. I do not have any Content-Type header, I tried to add <code>multipart/form-data</code> but did not help.</p> <p>Only way I could pass String parameter is by adding to URL. So following <code>http://localhost:8080/SearchBox/admin/config?name=test</code> works but this is not what I want. I want String and File parameters in Body part. </p> <p>I also tested via CURL:</p> <pre><code>curl -X POST -H "Authorization:Bearer myToken" -H "Content-Type:Multipart/form-data" http://localhost:8080/SearchBox/admin/config --data 'pwd=pwd' curl -X POST -H "Authorization:Bearer myToken"http://localhost:8080/SearchBox/admin/config --data 'pwd=pwd' curl -H "Authorization:Bearer myToken" -F file=@"/g123.conf" http://localhost:8080/SearchBox/admin/config </code></pre> <p><strong>Note:</strong> I checked similar posts already but did not help <a href="https://stackoverflow.com/questions/43936372/upload-file-springboot-required-request-part-file-is-not-present">This</a>, <a href="https://stackoverflow.com/questions/40488585/postman-required-request-part-file-is-not-present">This</a>, <a href="https://stackoverflow.com/questions/27101931/required-multipartfile-parameter-file-is-not-present-in-spring-mvc">This</a></p>
0debug
How to assign a variable to the output of a return statement in Python : <p>I have a function with a return statement that returns a list. I would like to store this list in a variable so I can use it in another following function. How would i do this?</p>
0debug
cron expression for every 30 seconds in quartz scheduler? : <p>I am using Quartz Scheduler to run my jobs. I want to run my job every thirty seconds. What will be my cron expression for that?</p> <p>For every one minute, I am using below cron expression:</p> <pre><code>&lt;cron-expression&gt;0 0/1 * 1/1 * ? *&lt;/cron-expression&gt; </code></pre> <p>What it will be for every thirty seconds?</p>
0debug
static int ffmmal_read_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame) { MMALDecodeContext *ctx = avctx->priv_data; MMAL_BUFFER_HEADER_T *buffer = NULL; MMAL_STATUS_T status = 0; int ret = 0; if (ctx->eos_received) goto done; while (1) { if (ctx->frames_output || ctx->packets_sent > MAX_DELAYED_FRAMES || (ctx->packets_sent && ctx->eos_sent)) { buffer = mmal_queue_timedwait(ctx->queue_decoded_frames, 100); if (!buffer) { av_log(avctx, AV_LOG_ERROR, "Did not get output frame from MMAL.\n"); ret = AVERROR_UNKNOWN; goto done; } } else { buffer = mmal_queue_get(ctx->queue_decoded_frames); if (!buffer) goto done; } ctx->eos_received |= !!(buffer->flags & MMAL_BUFFER_HEADER_FLAG_EOS); if (ctx->eos_received) goto done; if (buffer->cmd == MMAL_EVENT_FORMAT_CHANGED) { MMAL_COMPONENT_T *decoder = ctx->decoder; MMAL_EVENT_FORMAT_CHANGED_T *ev = mmal_event_format_changed_get(buffer); MMAL_BUFFER_HEADER_T *stale_buffer; av_log(avctx, AV_LOG_INFO, "Changing output format.\n"); if ((status = mmal_port_disable(decoder->output[0]))) goto done; while ((stale_buffer = mmal_queue_get(ctx->queue_decoded_frames))) mmal_buffer_header_release(stale_buffer); mmal_format_copy(decoder->output[0]->format, ev->format); if ((ret = ffmal_update_format(avctx)) < 0) goto done; if ((status = mmal_port_enable(decoder->output[0], output_callback))) goto done; if ((ret = ffmmal_fill_output_port(avctx)) < 0) goto done; if ((ret = ffmmal_fill_input_port(avctx)) < 0) goto done; mmal_buffer_header_release(buffer); continue; } else if (buffer->cmd) { char s[20]; av_get_codec_tag_string(s, sizeof(s), buffer->cmd); av_log(avctx, AV_LOG_WARNING, "Unknown MMAL event %s on output port\n", s); goto done; } else if (buffer->length == 0) { mmal_buffer_header_release(buffer); continue; } ctx->frames_output++; if ((ret = ffmal_copy_frame(avctx, frame, buffer)) < 0) goto done; *got_frame = 1; break; } done: if (buffer) mmal_buffer_header_release(buffer); if (status && ret >= 0) ret = AVERROR_UNKNOWN; return ret; }
1threat
RMI blocks until remote method return even when new thread is executing inside : <p>Scenario: I have a server that distributes summation problem to registered calculators. </p> <p>The problem is that when server starts calculators remotely, he executes them inorder (wait for each one to return) although the calculation inside calculator should be done in a separate thread (thus it should return immediately).</p> <p>Moreover, when I try to get type of current executing thread inside the calculator by parsing it to my thread type, I get error... and if I executed <em>wait</em> inside that thread, server thread stops instead. </p> <p>Here is my code:</p> <p>method inside server that solves a problem (this method is also called remotely by a client but I don't think this is related to what is happening)</p> <pre><code>@Override public void solveProblem(Agent a, IClient client) throws RemoteException { Runnable thread = new Runnable(){ @Override public void run() { //some variable initialization... for(int i=0;i&lt;calcs.size();i++) { try { calcs.get(i).delegate(a, chosen); System.out.println("delegate to "+i+" done"); } catch (RemoteException e) { e.printStackTrace(); } } } }; } </code></pre> <p>calculator: delegate method initialises new thread and start calculation</p> <pre><code>@Override public void delegate(Agent a, ICalculator original) throws RemoteException { receivedCount=0; thread = new CalculationThread(a, original); thread.run(); } </code></pre> <p>CalculationThread is an inner class within CalculatorImpl Class</p> <pre><code>class CalculationThread extends Thread{ private Agent a; private ICalculator original; public String name = "Calculation Thread"; public CalculationThread(Agent a, ICalculator original) { this.a=a; this.original=original; } @Override public String toString() { return "Original Calculation Thread"; } @Override public void run() { //start calculation System.out.println("----start new query----"); double result = 0; for(double n=a.lowerBound;n&lt;=a.upperBound;n++) { result += Math.pow(-1, n)/(2*n+1); } result = result*4; System.out.println("Finished with result("+a.lowerBound+","+a.upperBound+"):"+result); } } </code></pre> <p>Any body can explain what's the problem here?</p>
0debug
MemTxResult memory_region_dispatch_write(MemoryRegion *mr, hwaddr addr, uint64_t data, unsigned size, MemTxAttrs attrs) { if (!memory_region_access_valid(mr, addr, size, true)) { unassigned_mem_write(mr, addr, data, size); return MEMTX_DECODE_ERROR; adjust_endianness(mr, &data, size); if (mr->ops->write) { return access_with_adjusted_size(addr, &data, size, mr->ops->impl.min_access_size, mr->ops->impl.max_access_size, memory_region_write_accessor, mr, attrs); } else if (mr->ops->write_with_attrs) { return access_with_adjusted_size(addr, &data, size, mr->ops->impl.min_access_size, mr->ops->impl.max_access_size, memory_region_write_with_attrs_accessor, mr, attrs); } else { return access_with_adjusted_size(addr, &data, size, 1, 4, memory_region_oldmmio_write_accessor, mr, attrs);
1threat
PHP/MySQLi Contact Form Not Working with $_POST : <p>So my form seems to work when i put test values in the php file like so:</p> <pre><code>$name = 'name'; $email = 'test@gmail.com'; $telephone = '123456789'; $message = 'test message'; </code></pre> <p>However when i replace the test values with the php _POST like so:</p> <pre><code> $name = $_POST['name'] </code></pre> <p>everything seems to break and im not sure why.</p> <p>Got a very simple contact-us form setup in a file contact.html:</p> <pre><code>&lt;div class="container-fluid"&gt; &lt;div class="row"&gt; &lt;div class="col-xs-12 col-sm-9 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-8 col-lg-offset-2"&gt; &lt;div class="form-header"&gt; &lt;h8&gt;CONTACT US FORM&lt;/h8&gt; &lt;/div&gt; &lt;form method="post" action="php/contact.php"&gt; &lt;div class="row"&gt; &lt;div class="form-group col-xs-4 col-sm-4 col-md-4 col-lg-4"&gt; &lt;label&gt;Name:&lt;/label&gt; &lt;input type="text" name="name" class="form-control" onchange="capitalise()"&gt; &lt;/div&gt; &lt;div class="form-group col-xs-4 col-sm-4 col-md-4 col-lg-4"&gt; &lt;label&gt;Email Address:&lt;/label&gt; &lt;input type="email" class="form-control" name="email"&gt; &lt;/div&gt; &lt;div class="form-group col-xs-4 col-sm-4 col-md-4 col-lg-4"&gt; &lt;label&gt;Phone Number:&lt;/label&gt; &lt;input type="tel" class="form-control" name="tel"&gt; &lt;/div&gt; &lt;div class="clearfix"&gt;&lt;/div&gt; &lt;div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12"&gt; &lt;label&gt;Message:&lt;/label&gt; &lt;textarea class="form-control" rows="6"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12"&gt; &lt;input type="hidden" name="msg" value="contact"&gt; &lt;button type="submit" class="btn btn-default"&gt;Submit&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Here is the PHP contact form using prepared statements.</p> <pre><code>&lt;?php $servername = "*******"; $username = "********"; $password = "********"; $dbname = "*********"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn-&gt;connect_error){ die("Connection failed: " . $conn-&gt;connect_error); } $stmt = $conn -&gt; prepare("INSERT INTO contact (name, email, telephone, message) VALUES (?, ?, ?, ?)"); $stmt-&gt;bind_param("ssss", $name, $email, $telephone, $message); $name = $_POST['name']; $email = $_POST['email']; $telephone = $_POST['tel']; $message = $_POST['msg']; $stmt-&gt;execute(); echo "New records created successfully"; $stmt-&gt;close(); $conn-&gt;close(); ?&gt; </code></pre>
0debug
How to debug a Java maven spring-boot app in vs code? : <p>I was able to debug a simple Java hello world. The first step was to "compile" with <code>javac -g</code>. I looked up how I would acomplish the same with maven and found <a href="http://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/run-debug.html" rel="noreferrer">http://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/run-debug.html</a>, but those instructions are for running the application and wait for a debugger to connect.</p> <p>I also tried to use <code>target/classes</code> for <code>classpath</code> in <code>launch.json</code>. The debugger complains that it cannot find a file in the root directory <code>/</code>, but it runs. Althought the debugger is running, the application is not responding to HTTP requests.</p> <p>Is there a <code>mvn</code> command to compile the application with <code>javac -g</code> and produce a <code>.class</code> the debugger is able to run successfully?</p>
0debug
static VmdkExtent *vmdk_add_extent(BlockDriverState *bs, BlockDriverState *file, bool flat, int64_t sectors, int64_t l1_offset, int64_t l1_backup_offset, uint32_t l1_size, int l2_size, unsigned int cluster_sectors) { VmdkExtent *extent; BDRVVmdkState *s = bs->opaque; s->extents = g_realloc(s->extents, (s->num_extents + 1) * sizeof(VmdkExtent)); extent = &s->extents[s->num_extents]; s->num_extents++; memset(extent, 0, sizeof(VmdkExtent)); extent->file = file; extent->flat = flat; extent->sectors = sectors; extent->l1_table_offset = l1_offset; extent->l1_backup_table_offset = l1_backup_offset; extent->l1_size = l1_size; extent->l1_entry_sectors = l2_size * cluster_sectors; extent->l2_size = l2_size; extent->cluster_sectors = cluster_sectors; if (s->num_extents > 1) { extent->end_sector = (*(extent - 1)).end_sector + extent->sectors; } else { extent->end_sector = extent->sectors; } bs->total_sectors = extent->end_sector; return extent; }
1threat
static void qemu_laio_enqueue_completed(struct qemu_laio_state *s, struct qemu_laiocb* laiocb) { if (laiocb->async_context_id == get_async_context_id()) { qemu_laio_process_completion(s, laiocb); } else { QLIST_INSERT_HEAD(&s->completed_reqs, laiocb, node); } }
1threat
Loop to generate and execute commands doesn't work in python : I have following code for my pyspark script. I am trying to generate a query and run it every time with different values of i. The query should select nested json elements and calculate the size (i.e. number of occurrences). I am calculating this to help me with unit testing the final table which i am creating separately with "explode" functionality. for i in range(1,10) : onerowDF = spark.sql("SELECT items['responses'][i]['id'] as items_response_id, items['responses'][i]['name'] as responses_name FROM responses")") onerowDf.select(size("items_response_id"), size("responses_name")).show() I am getting error when I run this: >AnalysisException: u"cannot resolve '`i`' given input columns: [hasMore, items, total]; line 1 pos 74;\n'Project [items#1.id AS items_id#149, items#1.responseTime AS items.responseTime#154, items#1.responses['i][id] AS items_response_id#150, items#1.responses['i][name] AS responses_name#151, items#1.responses['i][type] AS responses_type#152, items#1.responses['i][answers] AS responses_answers#153]\n+- SubqueryAlias responses\n +- Relation[hasMore#0,items#1,total#2L] json\n" I have knowingly removed some elements from the code above to make it simpler which is why the error lists more element than my code here. So why can't I replace the value of i in each query and run the 2 statements and get results?
0debug
How can I write an if statement with multiple conditions using && and ||? : <p>I am making a tic tac toe board game and I need the user to enter any position between 1 to 9 then type in X or O. Some conditions I need include is that I want to restrict the user to enter any number greater than 9 and do not enter any character either than 'X' or 'O'. The problem I encounter is that it doesn't follow the conditional statement. Any help would be appreciated.</p> <pre><code>void CreateBoard(int m, int n, char board[][n]) { int i, j, position; char one; char two; char temp; char xORo; int count = 0; int end; do { printf("Enter the number of the cell you want to insert X or O or enter -1 to exit: \n"); scanf("%d", &amp;position); printf("Type X or O: \n"); scanf(" %c", &amp;xORo); if(position &lt; 0){ break; } if((position &gt; 9) &amp;&amp; xORo != ('X') &amp;&amp; ('O')) { continue; } else if((position &gt; 0 || position &lt; 9) &amp;&amp; xORo == ('X') &amp;&amp; ('O')) { switch(position) { case 1: temp = xORo; xORo = board[0][0]; board[0][0] = temp; break; case 2: temp = xORo; xORo = board[0][1]; board[0][1] = temp; break; case 3: temp = xORo; xORo = board[0][2]; board[0][2] = temp; break; case 4: temp = xORo; xORo = board[1][0]; board[1][0] = temp; break; case 5: temp = xORo; xORo = board[1][1]; board[1][1] = temp; break; case 6: temp = xORo; xORo = board[1][2]; board[1][2] = temp; break; case 7: temp = xORo; xORo = board[2][0]; board[2][0] = temp; break; case 8: temp = xORo; xORo = board[2][1]; board[2][1] = temp; break; case 9: temp = xORo; xORo = board[2][2]; board[2][2] = temp; break; } PrintBoard(3, 3, board); } }while(position != -1); } </code></pre>
0debug
static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf) { AVFilterContext *ctx = inlink->dst; ASyncContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; int nb_channels = av_get_channel_layout_nb_channels(buf->audio->channel_layout); int64_t pts = (buf->pts == AV_NOPTS_VALUE) ? buf->pts : av_rescale_q(buf->pts, inlink->time_base, outlink->time_base); int out_size; int64_t delta; if (s->pts == AV_NOPTS_VALUE) { if (pts != AV_NOPTS_VALUE) { s->pts = pts - get_delay(s); } write_to_fifo(s, buf); return; } if (pts == AV_NOPTS_VALUE) { write_to_fifo(s, buf); return; } delta = pts - s->pts - get_delay(s); out_size = avresample_available(s->avr); if (labs(delta) > s->min_delta) { av_log(ctx, AV_LOG_VERBOSE, "Discontinuity - %"PRId64" samples.\n", delta); out_size += delta; } else if (s->resample) { int comp = av_clip(delta, -s->max_comp, s->max_comp); av_log(ctx, AV_LOG_VERBOSE, "Compensating %d samples per second.\n", comp); avresample_set_compensation(s->avr, delta, inlink->sample_rate); } if (out_size > 0) { AVFilterBufferRef *buf_out = ff_get_audio_buffer(outlink, AV_PERM_WRITE, out_size); if (!buf_out) return; avresample_read(s->avr, (void**)buf_out->extended_data, out_size); buf_out->pts = s->pts; if (delta > 0) { av_samples_set_silence(buf_out->extended_data, out_size - delta, delta, nb_channels, buf->format); } ff_filter_samples(outlink, buf_out); } else { av_log(ctx, AV_LOG_WARNING, "Non-monotonous timestamps, dropping " "whole buffer.\n"); } avresample_read(s->avr, NULL, avresample_available(s->avr)); s->pts = pts - avresample_get_delay(s->avr); avresample_convert(s->avr, NULL, 0, 0, (void**)buf->extended_data, buf->linesize[0], buf->audio->nb_samples); avfilter_unref_buffer(buf); }
1threat
static inline void RENAME(rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size) { const uint8_t *s = src; const uint8_t *end; const uint8_t *mm_end; uint16_t *d = (uint16_t *)dst; end = s + src_size; __asm__ volatile(PREFETCH" %0"::"m"(*src):"memory"); __asm__ volatile( "movq %0, %%mm7 \n\t" "movq %1, %%mm6 \n\t" ::"m"(red_15mask),"m"(green_15mask)); mm_end = end - 15; while (s < mm_end) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movd %1, %%mm0 \n\t" "movd 4%1, %%mm3 \n\t" "punpckldq 8%1, %%mm0 \n\t" "punpckldq 12%1, %%mm3 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm3, %%mm4 \n\t" "movq %%mm3, %%mm5 \n\t" "psllq $7, %%mm0 \n\t" "psllq $7, %%mm3 \n\t" "pand %%mm7, %%mm0 \n\t" "pand %%mm7, %%mm3 \n\t" "psrlq $6, %%mm1 \n\t" "psrlq $6, %%mm4 \n\t" "pand %%mm6, %%mm1 \n\t" "pand %%mm6, %%mm4 \n\t" "psrlq $19, %%mm2 \n\t" "psrlq $19, %%mm5 \n\t" "pand %2, %%mm2 \n\t" "pand %2, %%mm5 \n\t" "por %%mm1, %%mm0 \n\t" "por %%mm4, %%mm3 \n\t" "por %%mm2, %%mm0 \n\t" "por %%mm5, %%mm3 \n\t" "psllq $16, %%mm3 \n\t" "por %%mm3, %%mm0 \n\t" MOVNTQ" %%mm0, %0 \n\t" :"=m"(*d):"m"(*s),"m"(blue_15mask):"memory"); d += 4; s += 16; } __asm__ volatile(SFENCE:::"memory"); __asm__ volatile(EMMS:::"memory"); while (s < end) { register int rgb = *(const uint32_t*)s; s += 4; *d++ = ((rgb&0xF8)<<7) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>19); } }
1threat
Which part of the C++ standard allow to declare variable in parenthesis? : <p>Consider the following code:</p> <pre><code>int main() { int(s); } </code></pre> <p>I am surprised by the fact that it creates valid variable <code>s</code>. Can anyone explain what's happening here?</p>
0debug
Understanding num_classes for xgboost in R : <p>I'm having a lot of trouble figuring out how to correctly set the num_classes for xgboost. </p> <p>I've got an example using the Iris data</p> <pre><code>df &lt;- iris y &lt;- df$Species num.class = length(levels(y)) levels(y) = 1:num.class head(y) df &lt;- df[,1:4] y &lt;- as.matrix(y) df &lt;- as.matrix(df) param &lt;- list("objective" = "multi:softprob", "num_class" = 3, "eval_metric" = "mlogloss", "nthread" = 8, "max_depth" = 16, "eta" = 0.3, "gamma" = 0, "subsample" = 1, "colsample_bytree" = 1, "min_child_weight" = 12) model &lt;- xgboost(param=param, data=df, label=y, nrounds=20) </code></pre> <p>This returns an error</p> <pre><code>Error in xgb.iter.update(bst$handle, dtrain, i - 1, obj) : SoftmaxMultiClassObj: label must be in [0, num_class), num_class=3 but found 3 in label </code></pre> <p>If I change the num_class to 2 I get the same error. If I increase the num_class to 4 then the model runs, but I get 600 predicted probabilities back, which makes sense for 4 classes. </p> <p>I'm not sure if I'm making an error or whether I'm failing to understand how xgboost works. Any help would be appreciated. </p>
0debug
Best LAMP environment for Mac : <p>I am use to using WAMP on a windows machine but I want to install something similar on a MAC. I have noticed that there are quite a few. What is the best LAMP environment to use for MAC if used to WAMP? I nearly went MAMP but can't have multiple virtual hosts unless I pay for the Pro version. Any other recommendations?</p> <p>Ideally I need phpMyAdmin and Mysql database.</p>
0debug
Google Cloud Platform: how to monitor memory usage of VM instances : <p>I have recently performed a migration to Google Cloud Platform, and I really like it.</p> <p>However I can't find a way to monitor the memory usage of the VM intances. As you can see on the attachment, the console provides utilization info about CPU, disk and network, but not about memory.</p> <p>Without knowing how much memory is being used, how is it possible to understand if there is a need of extra memory?</p> <p><a href="https://i.stack.imgur.com/n3iCd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/n3iCd.png" alt="enter image description here"></a></p>
0debug
My code is compiling out of order : <p>I'm using g++ on a Mac to compile a homework assignment. Any help is appreciated (also this isn't even the homework part of the homework, just the setup for the problem he asked us to complete). In my main.cpp I have </p> <pre><code>Queue test_list; test_list.add(4); test_list.add(1); test_list.add(3); test_list.add(2); test_list.remove(); cout &lt;&lt; "boop!" &lt;&lt; endl; </code></pre> <p>I am compiling and linking together several files: g++ main.cpp queue.cpp -o Queue However my output is: </p> <pre><code>4 End of test1 boop! 1 End of test1 3 End of test1 2 End of test1 </code></pre> <p>I don't really understand why the code is compiling out of order- shouldn't the boop be at the end? I also don't understand how the code in my textbook (which is where I got the add and remove functions)works. I don't see how the remove function is repeating since it has no loop. Here they are for reference: </p> <pre><code>void Queue::add(int item) { if(empty()) { front = new QueueNode; front-&gt;data = item; front-&gt;link = NULL; back = front; } else { QueueNodePtr temp_ptr; temp_ptr = new QueueNode; temp_ptr-&gt;data = item; temp_ptr-&gt;link = NULL; back-&gt;link = temp_ptr; back = temp_ptr; } } int Queue::remove() { if (empty()) { cout &lt;&lt; "Error: Removing an item from an empty queue.\n"; exit(1); } int result = front-&gt;data; QueueNodePtr discard; cout &lt;&lt; result &lt;&lt; endl; discard = front; front = front-&gt;link; if (front == NULL)// if you are removing the last node back = NULL; delete discard; cout &lt;&lt; "End of test1" &lt;&lt; endl; return result; } </code></pre>
0debug
How to show an bootsrap modal popup using inside php code : i want to display this modal popup after php condition check. <div id="myModal65" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title">Subscribe our Newsletter</h4> </div> <div class="modal-body"> <p>Subscribe to our mailing list to get the latest updates straight in your inbox.</p> <form> <div class="form-group"> <input type="text" class="form-control" placeholder="Name"> </div> <div class="form-group"> <input type="email" class="form-control" placeholder="Email Address"> </div> <button type="submit" class="btn btn-primary">Subscribe</button> </form> </div> </div> </div> </div> in this php code used for display the popup.but it cannot display. <?php if($intwschdle==1) { echo "<script type='text/javascript'>$('#myModal65').modal('show');</script>"; } ?>
0debug
static void frame_end(MpegEncContext *s) { if (s->unrestricted_mv && s->current_picture.reference && !s->intra_only) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt); int hshift = desc->log2_chroma_w; int vshift = desc->log2_chroma_h; s->mpvencdsp.draw_edges(s->current_picture.f->data[0], s->current_picture.f->linesize[0], s->h_edge_pos, s->v_edge_pos, EDGE_WIDTH, EDGE_WIDTH, EDGE_TOP | EDGE_BOTTOM); s->mpvencdsp.draw_edges(s->current_picture.f->data[1], s->current_picture.f->linesize[1], s->h_edge_pos >> hshift, s->v_edge_pos >> vshift, EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift, EDGE_TOP | EDGE_BOTTOM); s->mpvencdsp.draw_edges(s->current_picture.f->data[2], s->current_picture.f->linesize[2], s->h_edge_pos >> hshift, s->v_edge_pos >> vshift, EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift, EDGE_TOP | EDGE_BOTTOM); } emms_c(); s->last_pict_type = s->pict_type; s->last_lambda_for [s->pict_type] = s->current_picture_ptr->f->quality; if (s->pict_type!= AV_PICTURE_TYPE_B) s->last_non_b_pict_type = s->pict_type; #if FF_API_CODED_FRAME FF_DISABLE_DEPRECATION_WARNINGS av_frame_copy_props(s->avctx->coded_frame, s->current_picture.f); FF_ENABLE_DEPRECATION_WARNINGS #endif #if FF_API_ERROR_FRAME FF_DISABLE_DEPRECATION_WARNINGS memcpy(s->current_picture.f->error, s->current_picture.encoding_error, sizeof(s->current_picture.encoding_error)); FF_ENABLE_DEPRECATION_WARNINGS #endif }
1threat
Can anyone explain me the working of this C code? : <p>I don't know how this code is working? </p> <pre><code>#include&lt;stdio.h&gt; int main() { char *s = "PRO coder"; int n = 7; printf("%.*s", n, s); return 0; } </code></pre> <p>The result I am getting is "PRO cod"</p>
0debug
Create XML with XmlDocument C# : <p>I need to create an XML with this structure :</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:res="http://resource.webservice.correios.com.br/"&gt; &lt;soapenv:Header/&gt; &lt;soapenv:Body&gt; &lt;res:buscaEventos&gt; &lt;usuario&gt;ECT&lt;/usuario&gt; &lt;senha&gt;SRO&lt;/senha&gt; &lt;tipo&gt;L&lt;/tipo&gt; &lt;resultado&gt;T&lt;/resultado&gt; &lt;lingua&gt;101&lt;/lingua&gt; &lt;objetos&gt;JS331400752BR&lt;/objetos&gt; &lt;/res:buscaEventos&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre> <p>However it is wrong out this way:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:res="http://resource.webservice.correios.com.br/"&gt; &lt;soapenv:Header /&gt; &lt;soapenv:Body&gt; &lt;res:buscaEventos xmlns:res="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;usuario&gt;ETC&lt;/usuario&gt; &lt;senha&gt;SRO&lt;/senha&gt; &lt;tipo&gt;L&lt;/tipo&gt; &lt;resultado&gt;T&lt;/resultado&gt; &lt;lingua&gt;101&lt;/lingua&gt; &lt;objetos&gt;JS331400752BR&lt;/objetos&gt; &lt;/res:buscaEventos&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre> <p><strong>The difference is in buscaEventos</strong></p> <p>I created in the following way <code>XmlNode eventosNode = xmlDoc.CreateElement ( "res " , " buscaEventos " " http://schemas.xmlsoap.org/soap/envelope/ " ) ;</code> How do I remove the xmlns : res only that node ?</p>
0debug
void ff_put_h264_qpel16_mc01_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_vt_qrt_16w_msa(src - (stride * 2), stride, dst, stride, 16, 0); }
1threat
"export 'ɵɵinject' was not found in '@angular/core' : <p>I am getting this error when i tried to use MatToolBar in my angular app. In browser I get <code>Uncaught TypeError: Object(...) is not a function</code> and also get warnings in the console: </p> <pre><code>WARNING in ./node_modules/@angular/cdk/esm5/text-field.es5.js 146:151-159 "export 'ɵɵinject' was not found in '@angular/core' WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2324:206-214 "export 'ɵɵinject' was not found in '@angular/core' </code></pre> <p>How can I resolve this? On github it is a closed issue.</p>
0debug
Returning from a function once an async operation is done : <p>I am trying to make use an existing class which returns the data in the form of callback. The call is like this-</p> <pre><code>class Validator{ validate(){ DataProvider.getInstance(new DataListener(){ @Override void onDataReady(String data){ //Do something with data } }); } return //data when the above call is finished } </code></pre> <p>I want a clean way to return the data which should be returned when the async call is completed. Putting a while loop and checking for data is an obvious but un-clean way. Can I achieve this using RxJava?</p> <p>Note: It's ok for the validate function to wait if the call takes time</p>
0debug
How to Make Jquery Validation fire conditionally in this case? : <p>I am using <strong>jquery Validator Framework</strong> for validating form which consists of input type <strong>text</strong> and <strong>file</strong> elements .</p> <p>Initially when the page is loaded in <strong>edit</strong> mode (the Form will have all values filled in)</p> <p>So at that time when clicked on <strong>Submit</strong> button , the Jquery validation for the input type file should be skipped (as it has already a value) and it must be fired only incase user removes the picture and tries to <strong>submit</strong> the form .</p> <p>This is my jscode</p> <pre><code>jQuery(document).ready(function() { $("#description").text('Iniital Value'); var defimg = 'https://www.gstatic.com/webp/gallery3/1.png'; $("#previewpicimg").attr('src', defimg); $('#pacinsertform').validate( { rules: { previewpic: { required: true }, description: { required: true } }, messages: { previewpic: { required: "Upload Image required", }, description: { required: "description required", } }, highlight: function(element) { $(element).parent().addClass('error') }, unhighlight: function(element) { $(element).parent().removeClass('error') }, submitHandler: function(event, validator) { if ($("#pacinsertform").valid()) { ajaxInsertPac(); return false; } } }); }); $("#previewpic").change(function() { $("#previewpic").blur().focus(); }); function ajaxInsertPac() { alert('ajax call heer'); return false; } $(document).on("click", ".removepic", function(event) { $("#previewpic").attr('name', 'previewpic'); }); $(document).on("click", ".resetform", function(event) { $("#description").val(''); $(".removepic").trigger("click"); $("#pacinsertform").validate().resetForm(); }); </code></pre> <p><a href="http://jsfiddle.net/Luf0ks9b/61/" rel="nofollow">http://jsfiddle.net/Luf0ks9b/61/</a></p>
0debug
int ff_twinvq_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TwinVQContext *tctx = avctx->priv_data; const TwinVQModeTab *mtab = tctx->mtab; float **out = NULL; int ret; if (tctx->discarded_packets >= 2) { frame->nb_samples = mtab->size; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } out = (float **)frame->extended_data; } if ((ret = tctx->read_bitstream(avctx, tctx, buf, buf_size)) < 0) return ret; read_and_decode_spectrum(tctx, tctx->spectrum, tctx->bits.ftype); imdct_output(tctx, tctx->bits.ftype, tctx->bits.window_type, out); FFSWAP(float *, tctx->curr_frame, tctx->prev_frame); if (tctx->discarded_packets < 2) { tctx->discarded_packets++; *got_frame_ptr = 0; return buf_size; } *got_frame_ptr = 1; return buf_size; }
1threat
Does a running JVM detect a change to the computer's timezone? : <p>I can't find any specific docs to answer this question. </p> <p>I wrote some simple test code to work out what actually happens on Java 1.8 on OS X 10.12:</p> <pre><code>public static void main(String[] _args) throws InterruptedException { while (true) { int calendarTimezoneOffset = Calendar.getInstance().get(Calendar.ZONE_OFFSET); System.out.println("calendarTimezoneOffset = " + calendarTimezoneOffset); ZoneOffset offset = ZonedDateTime.now().getOffset(); System.out.println("offset = " + offset); Thread.sleep(1000); } } </code></pre> <p>Both the old way (Calendar) and the new way (Java 8's Date and Time library) do not detect any change I make to the OS's timezone while the JVM is running. I need to stop and start the code to get the changed timezone.</p> <p>Is this by design? Is this reliable behaviour across JVM implementations and operating systems?</p>
0debug
How to tell SwiftUI views to bind to more than one nested ObservableObject : <p>I have two classes nested in another class, which is an observable object in a SwiftUI view. Even though properties in the nested classes are declared as @Published, their values (when they change) do not update in the main view.</p> <p>A similar question has been asked here, and I could use it to get it to work for one of the two subclasses, but not both.</p> <p><a href="https://stackoverflow.com/questions/58406287/how-to-tell-swiftui-views-to-bind-to-nested-observableobjects">How to tell SwiftUI views to bind to nested ObservableObjects</a></p> <p>This is the model:</p> <pre><code>class Submodel1: ObservableObject { @Published var count = 0 } class Submodel2: ObservableObject { @Published var count = 0 } class Model: ObservableObject { @Published var submodel1: Submodel1 = Submodel1() @Published var submodel2: Submodel2 = Submodel2() } </code></pre> <p>And this is the main view:</p> <pre><code>struct ContentView: View { @ObservedObject var model: Model = Model() var body: some View { VStack { Text("Count: \(model.submodel1.count)") .onTapGesture { self.model.submodel1.count += 1 } Text("Count: \(model.submodel2.count)") .onTapGesture { self.model.submodel2.count += 1 } } } } </code></pre> <p>Adding this to the model class (see previous Stackoverflow question) works for updating on submodel1 changes, but not both:</p> <pre><code> var anyCancellable: AnyCancellable? = nil init() { anyCancellable = submodel1.objectWillChange.sink { (_) in self.objectWillChange.send() } } </code></pre> <p>What I'm looking for is some way to pass on changes of both the submodel1 and submodel2 to my view.</p>
0debug
VSCode's debugging mode always stop at first line : <p>I am using vscode for python development. I sometimes use debug running mode, and vscode always stop at first line even if there are no breakpoints. I attached a screenshot of this phenomenon. It's a little annoying and I want to skip this. Are there any ways to skip this?</p> <p><strong>My Env</strong></p> <ul> <li>Code Runner 0.6.5</li> <li>MagicPython 1.0.3</li> <li>Python 0.5.5</li> <li>Python for VSCode</li> </ul> <p><a href="https://i.stack.imgur.com/8MwaB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8MwaB.png" alt="enter image description here"></a></p>
0debug
static void test_io_channel_setup_async(SocketAddress *listen_addr, SocketAddress *connect_addr, QIOChannel **src, QIOChannel **dst) { QIOChannelSocket *lioc; struct TestIOChannelData data; data.loop = g_main_loop_new(g_main_context_default(), TRUE); lioc = qio_channel_socket_new(); qio_channel_socket_listen_async( lioc, listen_addr, test_io_channel_complete, &data, NULL); g_main_loop_run(data.loop); g_main_context_iteration(g_main_context_default(), FALSE); g_assert(!data.err); if (listen_addr->type == SOCKET_ADDRESS_KIND_INET) { SocketAddress *laddr = qio_channel_socket_get_local_address( lioc, &error_abort); g_free(connect_addr->u.inet.data->port); connect_addr->u.inet.data->port = g_strdup(laddr->u.inet.data->port); qapi_free_SocketAddress(laddr); } *src = QIO_CHANNEL(qio_channel_socket_new()); qio_channel_socket_connect_async( QIO_CHANNEL_SOCKET(*src), connect_addr, test_io_channel_complete, &data, NULL); g_main_loop_run(data.loop); g_main_context_iteration(g_main_context_default(), FALSE); g_assert(!data.err); qio_channel_wait(QIO_CHANNEL(lioc), G_IO_IN); *dst = QIO_CHANNEL(qio_channel_socket_accept(lioc, &error_abort)); g_assert(*dst); qio_channel_set_delay(*src, false); test_io_channel_set_socket_bufs(*src, *dst); object_unref(OBJECT(lioc)); g_main_loop_unref(data.loop); }
1threat
int check_params(const char * const *params, const char *str) { int name_buf_size = 1; const char *p; char *name_buf; int i, len; int ret = 0; for (i = 0; params[i] != NULL; i++) { len = strlen(params[i]) + 1; if (len > name_buf_size) { name_buf_size = len; } } name_buf = qemu_malloc(name_buf_size); p = str; while (*p != '\0') { p = get_opt_name(name_buf, name_buf_size, p, '='); if (*p != '=') { ret = -1; break; } p++; for(i = 0; params[i] != NULL; i++) if (!strcmp(params[i], name_buf)) break; if (params[i] == NULL) { ret = -1; break; } p = get_opt_value(NULL, 0, p); if (*p != ',') break; p++; } qemu_free(name_buf); return ret; }
1threat
Why is my Model object always null on my Razor Page in dotnet core 2.x Razor Page app? : <p>I'm creating a Partial View as a part of my Index.cshtml. I am following the basics outlined in the Microsoft article => <a href="https://docs.microsoft.com/en-us/aspnet/core/mvc/views/partial?view=aspnetcore-2.1" rel="noreferrer">https://docs.microsoft.com/en-us/aspnet/core/mvc/views/partial?view=aspnetcore-2.1</a></p> <p>The summary of it is that I'm : Adding a span to my Index.cshtml file which is actually loaded with the HTML from a Razor Page. The relevant HTML in Index.cshtml looks like the following:</p> <pre><code>&lt;span id="basicView"&gt; @{ Model.UserName = "IndexUser"; await Html.RenderPartialAsync("BasicPartial", Model); } &lt;/span&gt; </code></pre> <p>I have added public property to my IndexModel named UserName in the RazorPage and it looks like the following:</p> <pre><code>namespace FirstCore.Pages { public class IndexModel : PageModel { public string UserName; public void OnGet() { } } } </code></pre> <p>It is kept very simple for this example. So, in the HTML in the Index.cshtml you can see that I set the value of that public property to "IndexUser" and then I pass the name of the Razor Page ("BasicPartial" - View) and the Model object to the BasicaPartial Razor Page.</p> <p>The BasicPartial page is very simple -- was generated from the Visual Studio 2017 template - Add...Razor Page... The entire things looks like:</p> <pre><code>@page @model IndexModel @* For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 *@ &lt;div&gt;This is the text and the user name is @(Model.UserName).&lt;/div&gt; </code></pre> <p>Actually, the only important part is the and the place where I'm reading the property value of UserName out of the passed in Model. You can see I've also defined the @model as an IndexModel at the top.</p> <p><strong>The Main Problem - Model is ALWAYS Null</strong></p> <p>When I run this very simple example. The application tells me that the Model object is null.</p> <p><a href="https://i.stack.imgur.com/MPEcm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MPEcm.png" alt="Model is null"></a></p> <p>You may believe that it is the UserName that is null, but if I put a very simple directive at the top like </p> <pre><code>&lt;div&gt;@Model&lt;/div&gt; </code></pre> <p>Then it tells me that Model is null, even though I know I'm passing it in.</p> <p>Do you know why it is null?</p>
0debug
why does my var not change after 'var ++' : all I want is my var 'huidige' to go up on every interval. plz help what am I missing? var huidige = 1; var foto = 'url(img/foto' + huidige + '.jpg)'; setInterval(function(){ huidige ++; if (huidige == 4) {huidige = 1;} $('.background_img').css('backgroundImage', foto ); }, 300);
0debug
static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset, sPAPRPHBState *sphb) { ResourceProps rp; bool is_bridge = false; int pci_status, err; char *buf = NULL; uint32_t drc_index = spapr_phb_get_pci_drc_index(sphb, dev); uint32_t ccode = pci_default_read_config(dev, PCI_CLASS_PROG, 3); uint32_t max_msi, max_msix; if (pci_default_read_config(dev, PCI_HEADER_TYPE, 1) == PCI_HEADER_TYPE_BRIDGE) { is_bridge = true; } _FDT(fdt_setprop_cell(fdt, offset, "vendor-id", pci_default_read_config(dev, PCI_VENDOR_ID, 2))); _FDT(fdt_setprop_cell(fdt, offset, "device-id", pci_default_read_config(dev, PCI_DEVICE_ID, 2))); _FDT(fdt_setprop_cell(fdt, offset, "revision-id", pci_default_read_config(dev, PCI_REVISION_ID, 1))); _FDT(fdt_setprop_cell(fdt, offset, "class-code", ccode)); if (pci_default_read_config(dev, PCI_INTERRUPT_PIN, 1)) { _FDT(fdt_setprop_cell(fdt, offset, "interrupts", pci_default_read_config(dev, PCI_INTERRUPT_PIN, 1))); } if (!is_bridge) { _FDT(fdt_setprop_cell(fdt, offset, "min-grant", pci_default_read_config(dev, PCI_MIN_GNT, 1))); _FDT(fdt_setprop_cell(fdt, offset, "max-latency", pci_default_read_config(dev, PCI_MAX_LAT, 1))); } if (pci_default_read_config(dev, PCI_SUBSYSTEM_ID, 2)) { _FDT(fdt_setprop_cell(fdt, offset, "subsystem-id", pci_default_read_config(dev, PCI_SUBSYSTEM_ID, 2))); } if (pci_default_read_config(dev, PCI_SUBSYSTEM_VENDOR_ID, 2)) { _FDT(fdt_setprop_cell(fdt, offset, "subsystem-vendor-id", pci_default_read_config(dev, PCI_SUBSYSTEM_VENDOR_ID, 2))); } _FDT(fdt_setprop_cell(fdt, offset, "cache-line-size", pci_default_read_config(dev, PCI_CACHE_LINE_SIZE, 1))); pci_status = pci_default_read_config(dev, PCI_STATUS, 2); _FDT(fdt_setprop_cell(fdt, offset, "devsel-speed", PCI_STATUS_DEVSEL_MASK & pci_status)); if (pci_status & PCI_STATUS_FAST_BACK) { _FDT(fdt_setprop(fdt, offset, "fast-back-to-back", NULL, 0)); } if (pci_status & PCI_STATUS_66MHZ) { _FDT(fdt_setprop(fdt, offset, "66mhz-capable", NULL, 0)); } if (pci_status & PCI_STATUS_UDF) { _FDT(fdt_setprop(fdt, offset, "udf-supported", NULL, 0)); } _FDT(fdt_setprop_string(fdt, offset, "name", pci_find_device_name((ccode >> 16) & 0xff, (ccode >> 8) & 0xff, ccode & 0xff))); buf = spapr_phb_get_loc_code(sphb, dev); if (!buf) { error_report("Failed setting the ibm,loc-code"); return -1; } err = fdt_setprop_string(fdt, offset, "ibm,loc-code", buf); g_free(buf); if (err < 0) { return err; } if (drc_index) { _FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)); } _FDT(fdt_setprop_cell(fdt, offset, "#address-cells", RESOURCE_CELLS_ADDRESS)); _FDT(fdt_setprop_cell(fdt, offset, "#size-cells", RESOURCE_CELLS_SIZE)); max_msi = msi_nr_vectors_allocated(dev); if (max_msi) { _FDT(fdt_setprop_cell(fdt, offset, "ibm,req#msi", max_msi)); } max_msix = dev->msix_entries_nr; if (max_msix) { _FDT(fdt_setprop_cell(fdt, offset, "ibm,req#msi-x", max_msix)); } populate_resource_props(dev, &rp); _FDT(fdt_setprop(fdt, offset, "reg", (uint8_t *)rp.reg, rp.reg_len)); _FDT(fdt_setprop(fdt, offset, "assigned-addresses", (uint8_t *)rp.assigned, rp.assigned_len)); if (pci_is_express(dev)) { _FDT(fdt_setprop_cell(fdt, offset, "ibm,pci-config-space-type", 0x1)); } return 0; }
1threat
static int parse_psfile(AVFilterContext *ctx, const char *fname) { CurvesContext *curves = ctx->priv; uint8_t *buf; size_t size; int i, ret, av_unused(version), nb_curves; AVBPrint ptstr; static const int comp_ids[] = {3, 0, 1, 2}; av_bprint_init(&ptstr, 0, AV_BPRINT_SIZE_AUTOMATIC); ret = av_file_map(fname, &buf, &size, 0, NULL); if (ret < 0) return ret; #define READ16(dst) do { \ if (size < 2) \ return AVERROR_INVALIDDATA; \ dst = AV_RB16(buf); \ buf += 2; \ size -= 2; \ } while (0) READ16(version); READ16(nb_curves); for (i = 0; i < FFMIN(nb_curves, FF_ARRAY_ELEMS(comp_ids)); i++) { int nb_points, n; av_bprint_clear(&ptstr); READ16(nb_points); for (n = 0; n < nb_points; n++) { int y, x; READ16(y); READ16(x); av_bprintf(&ptstr, "%f/%f ", x / 255., y / 255.); } if (*ptstr.str) { char **pts = &curves->comp_points_str[comp_ids[i]]; if (!*pts) { *pts = av_strdup(ptstr.str); av_log(ctx, AV_LOG_DEBUG, "curves %d (intid=%d) [%d points]: [%s]\n", i, comp_ids[i], nb_points, *pts); if (!*pts) { ret = AVERROR(ENOMEM); goto end; } } } } end: av_bprint_finalize(&ptstr, NULL); av_file_unmap(buf, size); return ret; }
1threat
static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr, int is_vp7) { VP8Context *s = avctx->priv_data; VP8ThreadData *prev_td, *next_td, *td = &s->thread_data[threadnr]; int mb_y = td->thread_mb_pos >> 16; int mb_x, mb_xy = mb_y * s->mb_width; int num_jobs = s->num_jobs; VP8Frame *curframe = s->curframe, *prev_frame = s->prev_frame; VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions - 1)]; VP8Macroblock *mb; uint8_t *dst[3] = { curframe->tf.f->data[0] + 16 * mb_y * s->linesize, curframe->tf.f->data[1] + 8 * mb_y * s->uvlinesize, curframe->tf.f->data[2] + 8 * mb_y * s->uvlinesize }; if (mb_y == 0) prev_td = td; else prev_td = &s->thread_data[(jobnr + num_jobs - 1) % num_jobs]; if (mb_y == s->mb_height - 1) next_td = td; else next_td = &s->thread_data[(jobnr + 1) % num_jobs]; if (s->mb_layout == 1) mb = s->macroblocks_base + ((s->mb_width + 1) * (mb_y + 1) + 1); else { if (prev_frame && s->segmentation.enabled && !s->segmentation.update_map) ff_thread_await_progress(&prev_frame->tf, mb_y, 0); mb = s->macroblocks + (s->mb_height - mb_y - 1) * 2; memset(mb - 1, 0, sizeof(*mb)); AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED * 0x01010101); } if (!is_vp7 || mb_y == 0) memset(td->left_nnz, 0, sizeof(td->left_nnz)); s->mv_min.x = -MARGIN; s->mv_max.x = ((s->mb_width - 1) << 6) + MARGIN; for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) { if (prev_td != td) { if (threadnr != 0) { check_thread_pos(td, prev_td, mb_x + (is_vp7 ? 2 : 1), mb_y - (is_vp7 ? 2 : 1)); } else { check_thread_pos(td, prev_td, mb_x + (is_vp7 ? 2 : 1) + s->mb_width + 3, mb_y - (is_vp7 ? 2 : 1)); } } s->vdsp.prefetch(dst[0] + (mb_x & 3) * 4 * s->linesize + 64, s->linesize, 4); s->vdsp.prefetch(dst[1] + (mb_x & 7) * s->uvlinesize + 64, dst[2] - dst[1], 2); if (!s->mb_layout) decode_mb_mode(s, mb, mb_x, mb_y, curframe->seg_map->data + mb_xy, prev_frame && prev_frame->seg_map ? prev_frame->seg_map->data + mb_xy : NULL, 0, is_vp7); prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_PREVIOUS); if (!mb->skip) decode_mb_coeffs(s, td, c, mb, s->top_nnz[mb_x], td->left_nnz, is_vp7); if (mb->mode <= MODE_I4x4) intra_predict(s, td, dst, mb, mb_x, mb_y, is_vp7); else inter_predict(s, td, dst, mb, mb_x, mb_y); prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN); if (!mb->skip) { idct_mb(s, td, dst, mb); } else { AV_ZERO64(td->left_nnz); AV_WN64(s->top_nnz[mb_x], 0); if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) { td->left_nnz[8] = 0; s->top_nnz[mb_x][8] = 0; } } if (s->deblock_filter) filter_level_for_mb(s, mb, &td->filter_strength[mb_x], is_vp7); if (s->deblock_filter && num_jobs != 1 && threadnr == num_jobs - 1) { if (s->filter.simple) backup_mb_border(s->top_border[mb_x + 1], dst[0], NULL, NULL, s->linesize, 0, 1); else backup_mb_border(s->top_border[mb_x + 1], dst[0], dst[1], dst[2], s->linesize, s->uvlinesize, 0); } prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN2); dst[0] += 16; dst[1] += 8; dst[2] += 8; s->mv_min.x -= 64; s->mv_max.x -= 64; if (mb_x == s->mb_width + 1) { update_pos(td, mb_y, s->mb_width + 3); } else { update_pos(td, mb_y, mb_x); } } return 0; }
1threat
int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf, int bytes, uint8_t *_dst, int coeffs) { int i, b, c_idx = 0; int32_t *dst = (int32_t *)_dst; DiracGolombLUT *future[4], *l = &lut_ctx[2*LUT_SIZE + buf[0]]; INIT_RESIDUE(res); for (b = 1; b <= bytes; b++) { future[0] = &lut_ctx[buf[b]]; future[1] = future[0] + 1*LUT_SIZE; future[2] = future[0] + 2*LUT_SIZE; future[3] = future[0] + 3*LUT_SIZE; if ((c_idx + 1) > coeffs) return c_idx; if (res_bits && l->sign) { int32_t coeff = 1; APPEND_RESIDUE(res, l->preamble); for (i = 0; i < (res_bits >> 1) - 1; i++) { coeff <<= 1; coeff |= (res >> (RSIZE_BITS - 2*i - 2)) & 1; } dst[c_idx++] = l->sign * (coeff - 1); SET_RESIDUE(res, 0, 0); } memcpy(&dst[c_idx], l->ready, LUT_BITS*sizeof(int32_t)); c_idx += l->ready_num; APPEND_RESIDUE(res, l->leftover); l = future[l->need_s ? 3 : !res_bits ? 2 : res_bits & 1]; } return c_idx; }
1threat
VirtIOS390Device *s390_virtio_bus_find_vring(VirtIOS390Bus *bus, ram_addr_t mem, int *vq_num) { BusChild *kid; int i; QTAILQ_FOREACH(kid, &bus->bus.children, sibling) { VirtIOS390Device *dev = (VirtIOS390Device *)kid->child; for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) { if (!virtio_queue_get_addr(dev->vdev, i)) break; if (virtio_queue_get_addr(dev->vdev, i) == mem) { if (vq_num) { *vq_num = i; } return dev; } } } return NULL; }
1threat
static int nbd_co_readv_1(NbdClientSession *client, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int offset) { struct nbd_request request = { .type = NBD_CMD_READ }; struct nbd_reply reply; ssize_t ret; request.from = sector_num * 512; request.len = nb_sectors * 512; nbd_coroutine_start(client, &request); ret = nbd_co_send_request(client, &request, NULL, 0); if (ret < 0) { reply.error = -ret; } else { nbd_co_receive_reply(client, &request, &reply, qiov, offset); } nbd_coroutine_end(client, &request); return -reply.error; }
1threat
why am I getting "An exception occurred: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException" : i have already started the mysql server [enter image description here][1] [1]: https://i.stack.imgur.com/Iptpk.png but on executing the statement sqlcon = DriverManager.getConnection(SQLConnection.getUrl(), SQLConnection.getUser(), SQLConnection.getPassword()); where SQLConnection.getUrl() = "jdbc:mysql://localhost:3306/dataValdb" SQLConnection.getUser() = "root" SQLConnection.getPassword() = "mypassword" i get An exception occurred: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException
0debug
static av_cold int vp8_decode_free(AVCodecContext *avctx) { vp8_decode_flush_impl(avctx, 0, 1); release_queued_segmaps(avctx->priv_data, 1); return 0; }
1threat
Counting the amount of times a number shows up as the first digit in a data set : <p>I have a dataset as a .txt file like this:</p> <pre><code>17900 66100 11300 94600 10600 28700 37800 </code></pre> <p>I want to extract the first digit from every number in my dataset and then count how many times that number appears as the first digit in my dataset. How would I solve that in python code?</p>
0debug
how to extract a substring from a string in Python with regex? : <p>I have a string </p> <p><code>&lt;b&gt;Status : Active&lt;br&gt;Code : C1654&lt;br&gt;&lt;br&gt;Shop &lt;a class="top"&lt;b&gt;Shop A&lt;/b&gt;&lt;/a&gt;&lt;/b&gt;</code> </p> <p>And I want get <code>Active</code> , <code>C1654</code> and <code>Shop A</code>.</p> <p>How to do the same thing in Python?</p>
0debug
static CharDriverState *chr_baum_init(const char *id, ChardevBackend *backend, ChardevReturn *ret, Error **errp) { BaumDriverState *baum; CharDriverState *chr; brlapi_handle_t *handle; #if defined(CONFIG_SDL) #if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0) SDL_SysWMinfo info; #endif #endif int tty; baum = g_malloc0(sizeof(BaumDriverState)); baum->chr = chr = qemu_chr_alloc(); chr->opaque = baum; chr->chr_write = baum_write; chr->chr_accept_input = baum_accept_input; chr->chr_close = baum_close; handle = g_malloc0(brlapi_getHandleSize()); baum->brlapi = handle; baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL); if (baum->brlapi_fd == -1) { error_setg(errp, "brlapi__openConnection: %s", brlapi_strerror(brlapi_error_location())); goto fail_handle; } baum->cellCount_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, baum_cellCount_timer_cb, baum); if (brlapi__getDisplaySize(handle, &baum->x, &baum->y) == -1) { error_setg(errp, "brlapi__getDisplaySize: %s", brlapi_strerror(brlapi_error_location())); goto fail; } #if defined(CONFIG_SDL) #if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0) memset(&info, 0, sizeof(info)); SDL_VERSION(&info.version); if (SDL_GetWMInfo(&info)) tty = info.info.x11.wmwindow; else #endif #endif tty = BRLAPI_TTY_DEFAULT; if (brlapi__enterTtyMode(handle, tty, NULL) == -1) { error_setg(errp, "brlapi__enterTtyMode: %s", brlapi_strerror(brlapi_error_location())); goto fail; } qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum); return chr; fail: timer_free(baum->cellCount_timer); brlapi__closeConnection(handle); fail_handle: g_free(handle); g_free(chr); g_free(baum); return NULL; }
1threat
Why doesn't F# Compile Currying into Separate Functions? : <p>So I'm trying to learn F# and as I learn new things I like to look at the IL to see what's happening under the covers. I recently read about Currying, an obvious fundamental of the language. </p> <p>According to <a href="https://fsharpforfunandprofit.com/posts/currying/">F# for fun and Profit</a> when you create the below function:</p> <pre><code>let addItems x y = x + y </code></pre> <p>What is really happening is there are two single argument functions being created.</p> <pre><code>let addItems x = let subFunction y = x + y subFunction </code></pre> <p>and when you invoke the function with addItems 5 6 the order of operations are as follows</p> <ol> <li><p>addItems is called with argument 5</p></li> <li><p>addItems returns subFunction</p></li> <li>subFunction is called with argument 6</li> <li>subFunction has argument 5 in scope so it adds and returns the sum of 5 and 6</li> </ol> <p>All of this sounds fine on the surface. However, when you look at the IL for this it tells a different story. </p> <pre><code>.method public static int32 testCurry(int32 x, int32 y) cil managed { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) // Code size 5 (0x5) .maxstack 8 IL_0000: nop IL_0001: ldarg.0 IL_0002: ldarg.1 IL_0003: add IL_0004: ret } // end of method Sandbox::testCurry </code></pre> <p>We can clearly see in the IL that a single static function that takes two arguments and returns an Int32 is created. </p> <p>So my question is, why the discrepancy? This isn't the first time I've seen IL that doesn't jive with the documentation either... </p>
0debug
Check multiple buttons with same id with javascript : I'm trying to build a website where people can make a reservation, I'm using a database to collect the times and php to display it. It displays all times within 5 days, including the ones that aren't available. They are displayed as buttons, all sharing the same id. I got stuck at the last step, disabling the buttons with unavailable times. Since the only difference between these buttons is their background color (grey for unavailable and green for available) I figured I'd use a javascript function in which it checks the background colors of the boxes in a condition and then the grey ones get disabled and the green ones give a form. However: it'll only check the color of the first button and all buttons give the same result as that one. My page will always display 50 buttons, so I thought I could just use a while loop with an auto-decrement at the end, however I can't seem to find out how to check the next button, it will now only check the same button again and again. Here's a part of the php-code to show the buttons with the right color (I've take some irrelevant parts out): while($row = $results->fetch_assoc()){ $color = "##8fd6a5"; if (!empty($row['unavailable'])){ $color = "##9b9393"; } $time= new DateTime($row['time']); if ($time->format('H') == '08'){ echo '<button id="myBtn" onload="disablebuttons()" class="buttonstyle" style="background-color: '.$color.'">'.$time>format('m/d H:i').'</button>'; } This works entirely, but since all buttons have id="myBtn" when disablebuttons() executes, it only looks at the first button, following this code: function disablebuttons() { var amountButton = 50; while (a > 0){ var buttondisable = document.getElementById("myBtn"); if (buttondisable.style.backgroundColor == "rgb(155, 147, 147)"){ document.getElementById("myBtn").disabled = true; a--;} } } I've tried to delete the variable at the end of the while loop and place the "var buttondisable = document.getElementById("myBtn");" inside the loop, however this did not work. Can somebody help please?
0debug
static av_cold int xan_decode_init(AVCodecContext *avctx) { XanContext *s = avctx->priv_data; s->avctx = avctx; s->frame_size = 0; if ((avctx->codec->id == CODEC_ID_XAN_WC3) && (s->avctx->palctrl == NULL)) { av_log(avctx, AV_LOG_ERROR, "palette expected\n"); return AVERROR(EINVAL); } avctx->pix_fmt = PIX_FMT_PAL8; s->buffer1_size = avctx->width * avctx->height; s->buffer1 = av_malloc(s->buffer1_size); if (!s->buffer1) return AVERROR(ENOMEM); s->buffer2_size = avctx->width * avctx->height; s->buffer2 = av_malloc(s->buffer2_size + 130); if (!s->buffer2) { av_freep(&s->buffer1); return AVERROR(ENOMEM); } return 0; }
1threat
Having trouble passing reference : <p>Within my code I keep getting an error sayong that the "n" in the main function is undeclared even though I declare it in "double mols"</p> <pre><code>#include &lt;iostream&gt; using namespace std; const double idealGas = 8.3144598; double mols(double mass, double molarMass); double pressure(double v, double n, double t); int main() { cout &lt;&lt; "the mols are " &lt;&lt; mols(5.0,20.0) &lt;&lt; "\n" &lt;&lt; "the pressure is" &lt;&lt; pressure(3.0,n,293) &lt;&lt; endl; return 0; } double mols(double mass, double molarMass){ double n = mass/molarMass; return n; } double pressure(double v, double n, double t){ double p = (n*idealGas*t)/v; return p; } </code></pre>
0debug
static void build_fs_mount_list_from_mtab(FsMountList *mounts, Error **errp) { struct mntent *ment; FsMount *mount; char const *mtab = "/proc/self/mounts"; FILE *fp; unsigned int devmajor, devminor; fp = setmntent(mtab, "r"); if (!fp) { error_setg(errp, "failed to open mtab file: '%s'", mtab); return; } while ((ment = getmntent(fp))) { if ((ment->mnt_fsname[0] != '/') || (strcmp(ment->mnt_type, "smbfs") == 0) || (strcmp(ment->mnt_type, "cifs") == 0)) { continue; } if (dev_major_minor(ment->mnt_fsname, &devmajor, &devminor) == -2) { continue; } mount = g_malloc0(sizeof(FsMount)); mount->dirname = g_strdup(ment->mnt_dir); mount->devtype = g_strdup(ment->mnt_type); mount->devmajor = devmajor; mount->devminor = devminor; QTAILQ_INSERT_TAIL(mounts, mount, next); } endmntent(fp); }
1threat
static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, int imgh) { int x, y, Y, U, V, A; uint8_t *lum, *cb, *cr; int dstx, dsty, dstw, dsth; const AVPicture *src = &rect->pict; dstw = av_clip(rect->w, 0, imgw); dsth = av_clip(rect->h, 0, imgh); dstx = av_clip(rect->x, 0, imgw - dstw); dsty = av_clip(rect->y, 0, imgh - dsth); lum = dst->data[0] + dstx + dsty * dst->linesize[0]; cb = dst->data[1] + dstx/2 + (dsty >> 1) * dst->linesize[1]; cr = dst->data[2] + dstx/2 + (dsty >> 1) * dst->linesize[2]; for (y = 0; y<dsth; y++) { for (x = 0; x<dstw; x++) { Y = src->data[0][x + y*src->linesize[0]]; A = src->data[3][x + y*src->linesize[3]]; lum[0] = ALPHA_BLEND(A, lum[0], Y, 0); lum++; } lum += dst->linesize[0] - dstw; } for (y = 0; y<dsth/2; y++) { for (x = 0; x<dstw/2; x++) { U = src->data[1][x + y*src->linesize[1]]; V = src->data[2][x + y*src->linesize[2]]; A = src->data[3][2*x + 2*y *src->linesize[3]] + src->data[3][2*x + 1 + 2*y *src->linesize[3]] + src->data[3][2*x + 1 + (2*y+1)*src->linesize[3]] + src->data[3][2*x + (2*y+1)*src->linesize[3]]; cb[0] = ALPHA_BLEND(A>>2, cb[0], U, 0); cr[0] = ALPHA_BLEND(A>>2, cr[0], V, 0); cb++; cr++; } cb += dst->linesize[1] - dstw/2; cr += dst->linesize[2] - dstw/2; } }
1threat
Highcharts not diplaying percentage : <p>I want to display only percentage in corresponding bit of pie. The charts appears a line between the percentage and the pie.</p>
0debug
taking out common data using sql : i want to compare two column and take out the common rows which are present in table1 and table 2 from two different tables. table 1 table 2 result mobnum A mobnum B 988123456 988123456 988124567201718 988123457 988124567 988123456201718 944123456 988623456201718
0debug
static void e500plat_init(QEMUMachineInitArgs *args) { ram_addr_t ram_size = args->ram_size; const char *boot_device = args->boot_device; const char *cpu_model = args->cpu_model; const char *kernel_filename = args->kernel_filename; const char *kernel_cmdline = args->kernel_cmdline; const char *initrd_filename = args->initrd_filename; PPCE500Params params = { .ram_size = ram_size, .boot_device = boot_device, .kernel_filename = kernel_filename, .kernel_cmdline = kernel_cmdline, .initrd_filename = initrd_filename, .cpu_model = cpu_model, .pci_first_slot = 0x11, .pci_nr_slots = 2, .fixup_devtree = e500plat_fixup_devtree, }; ppce500_init(&params); }
1threat
Template programming beginner problems : <p>I have some basic template programming errors.</p> <p>I have this code in <code>main.cpp</code>:</p> <pre><code>#include &lt;string&gt; #include &lt;iostream&gt; #include "arrapp.h" #include &lt;algorithm&gt; #include &lt;vector&gt; const int max = 1000; int main() { int your_mark = 1; /* 2-es*/ int s[] = {3, 2}; array_appender&lt;int&gt; ia ( s, sizeof( s ) / sizeof( s[ 0 ] ) ); for( int i = 0; i &lt; max - 1; ++i ) { ia.append( s, sizeof( s ) / sizeof( s[ 0 ] ) ); } std::string hw[] = { "Hello", "World" }; std::string langs[] = { "C++", "Ada", "Brainfuck" }; std::string x[] = { "Goodbye", "Cruel", "World" }; array_appender&lt;std::string&gt; sa ( hw, sizeof( hw ) / sizeof( hw[ 0 ] ) ); sa.append( langs, sizeof( langs ) / sizeof( langs[ 0 ] ) ); sa.append( x, sizeof( x ) / sizeof( x[ 0 ] ) ); const array_appender&lt;std::string&gt; ha( hw, sizeof( hw ) / sizeof( hw[ 0 ] ) ); if ( max * 2 == ia.size() &amp;&amp; 3 == ia.at( max ) &amp;&amp; 2 == ia.at( 3 ) &amp;&amp; &amp;( s[ 0 ] ) == &amp;(ia.at( max / 2 ) ) &amp;&amp; 2 == ha.size() &amp;&amp; 8 == sa.size() &amp;&amp; "C++" == sa.at( 2 ) &amp;&amp; 7 == sa.at( 5 ).length() &amp;&amp; &amp;( ha.at( 0 ) ) == hw ) { your_mark = ia.at( max + 1 ); } std::cout &lt;&lt; "Your mark is " &lt;&lt; your_mark; std::endl( std::cout ); } </code></pre> <p>And I have to solve this, by writing <code>"arrapp.h"</code>. So I created this:</p> <pre><code>#ifndef arrapp_H #include &lt;algorithm&gt; #include &lt;list&gt; #include &lt;vector&gt; #include &lt;array&gt; template &lt;typename T&gt; T const&amp; array_appender (std::vector &lt;T const&amp;&gt; v, T const&amp; size) { std::vector&lt;T*&gt; vec [size]= {}; for( int idx = 0; idx &lt; size; ++idx) { std::cout &lt;&lt; "value of v: " &lt;&lt; v[idx] &lt;&lt; std::endl; vec.add(v[idx]); } return vec; } #endif // arrapp_H </code></pre> <p>But If I use this i got the error <code>main.cpp|14|error: expected ';' before 'ia'|</code>. So this isn't working. How can I create these template things, to work? Am I misunderstood, here <code>array_appender</code> don't have work as I think, as I wrote?</p>
0debug
static bool gscb_needed(void *opaque) { return kvm_s390_get_gs(); }
1threat
window.location.href = 'http://attack.com?user=' + user_input;
1threat
Calculate time difference in seconds between 2 dates PHP : <p>I have to 2 dates values in PHP, </p> <pre><code>start_date_time = "2018-03-15T20:39:06Z" end_date_time = "2018-03-17T12:42:08Z" duration = ? // in seconds </code></pre> <p>I actually want to get total time in seconds. Please help</p>
0debug
static void rtas_ibm_os_term(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { target_ulong ret = 0; qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort); rtas_st(rets, 0, ret); }
1threat
Can't call a function in viewDidLoad : <p>I created this function in my controller</p> <pre><code>func addMarker(place:EClass) { guard let coordinates = place.location else { return } self.destination = coordinates // clear current marker marker.map = nil marker.position = coordinates marker.title = place.name marker.map = mapView mapView.selectedMarker = marker } } </code></pre> <p>and now i'm trying to call it in my viewDidLoad because i want to add some markers in my mapView</p> <pre><code>override func viewDidLoad() { super.viewDidLoad() print(categories as Any) guard let currentUser = Auth.auth().currentUser else { return } tableView.dataSource = self tableView.delegate = self dateFormatter.timeZone = TimeZone.current dateFormatter.dateFormat = "hh:mm" print(dateFormatter.string(from: NSDate() as Date)) mapView.isMyLocationEnabled = true locationManager?.startUpdatingLocation() //HERE let srt = sortedArray for category in categories! { addMarker(place: srt) } } </code></pre> <p>but i'm getting the error "Use of unresolved identifier 'addMarker'" , why? How can i fix it?</p>
0debug
How to show different value of input element with ng-model? : <p>In the controller if have a variable that tracks the index (starting at 0) of the page for a pagination table:</p> <pre><code>var page { pageNumber: 0; } </code></pre> <p>Question: how can I show this <code>pageNumber</code> variable in the html, but always incremented by +1? (as the index=0 page is obviously the 1st page and should thus be shown as <code>Page 1</code>)</p> <pre><code>&lt;input type="text" ng-model="page.pageNumber"&gt; </code></pre> <p>Also, when the model gets updated, the value in the input should automatically change (again: also incremented by +1).</p>
0debug
static void put_buffer(GDBState *s, const uint8_t *buf, int len) { #ifdef CONFIG_USER_ONLY int ret; while (len > 0) { ret = send(s->fd, buf, len, 0); if (ret < 0) { if (errno != EINTR && errno != EAGAIN) return; } else { buf += ret; len -= ret; } } #else qemu_chr_fe_write(s->chr, buf, len); #endif }
1threat
how to sum results from an argument,that come in array form : i have this fortran 95 do-loop code which return answers in array form, please how do i find the SUM of the answers (fv) without writing them out,because they're iterative and subject to change. thanks !.......vapor fraction.............. do i=1,6 FV=Z(I)*(K(i)-1)/(VOLD*(K(i)-1)+1) write(*,99001)FV END DO
0debug
Redirecting domains to local addresses : <p>Clients are connecting to private servers using OpenVPN, currently using raw IPs (<code>172.X.X.X</code>) but I would like to point more user-friendly subdomains (<code>something.ourdomain.com</code>) to those private IPs</p> <p>Key is to</p> <ul> <li><strong>Not make our private topology public</strong>, so binding subdomains to a public DNS is not an option</li> <li><strong>Be able to push new settings to all clients efficiently</strong>, so modifying local hosts-files whenever a private IP updates could potentially be cumbersome</li> <li><strong>Not tie the routing to a specific local hardware</strong>, so doing the routing on say e.g. our office router is not really an option</li> </ul> <p>Any suggestions how to achieve this considering the above points? Set-up a private DNS? Do the routing in OpenVPN?</p>
0debug
findChessboardCorners IS GIVING GARBAGE VALUE IN CORNERS : Here is my code #include <opencv/cv.h> #include <opencv/highgui.h> #include<opencv2/opencv.hpp> #include<iostream> //#include<vector> using namespace cv; using namespace std; int main() { VideoCapture cap = VideoCapture(0); int successes = 0; int numBoards = 0; int numCornersHor = 6; int numCornersVer = 4; int numSquares = (numCornersHor - 1) * (numCornersVer - 1); Size board_sz = Size(numCornersHor, numCornersVer); vector<Point2f> corners; for (;;) { Mat img; cap >> img; Mat gray; cvtColor(img, gray, CV_RGB2GRAY); if (img.empty()) break; // end of video stream imshow("this is you, smile! :)", gray); if (waitKey(1) == 27) break; // stop capturing by pressing ESC bool found = findChessboardCorners(gray, board_sz, corners, CALIB_CB_ADAPTIVE_THRESH); if (found == 1) { cout << corners.size()<<"\n"; cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1), TermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 30, 0.1)); drawChessboardCorners(gray, board_sz, corners, found); } } cap.release(); waitKey(); return 0; } What code is doing is, if "chessBoard" is found during capturing frames from webcam, it will print the corner size (I did it because I was not getting the output of the tutorial code and I wanted to find where the bug is!) Here is the image of my output:[1] [1]: http://i.stack.imgur.com/S1ewO.png
0debug
How to connect mysqli Databse in php : Her Is MyCode `$conn=mysqli_connect("localhost","root",""); $db=mysqli_select_db("root");` Now It Showing Me Some Error
0debug
Adding an element beneath the root based on condition : I'm reading an xml file using SAX, then I'm comparing the children of the xml file to validation rules that I got from my database in (validateByRules) Now based on the validation, I'm adding to each chilld, a subchild: <DESC><DESC/> . Now What I want is that after iterating all the children of the document, if at least one validation is wrong, in any of the children. Then an element is added beneath the root of name: <error>. For that I created a counter in VALIDATEbYrULES. Bur from there I'm not positively sure on how to continue. Any help? public void execute() throws Exception { try{ Document xmlDoc = convertXmlFileToDocument("c:\\TEST.xml"); String xmlType = xmlDoc.getRootElement().getAttributeValue("type"); HashMap<String, HashMap<String, String>> hashValidationRules = getRulesByType(xmlType); List<Element> childElem = xmlDoc.getRootElement().getChildren(); Element updatedElem = null; updatedElem = validateByRules(hashValidationRules, childElem.get(j)); xmlDoc.getRootElement().getChildren().remove(j); xmlDoc.getRootElement().getChildren().add(j, updatedElem); } } private Element validateByRules(HashMap<String, HashMap<String, String>> hashValidationRules, Element element) { HashMap<String, String> rules = null; String desc = ""; String value = ""; int counter = 0; String fileName = null; for ( String key : hashValidationRules.keySet() ) { rules = hashValidationRules.get(key); if(rules.get("mandatory").equals("true") && (element.getChild(key)==null || element.getChild(key).getValue().equals(""))){ counter ++; desc = "Mandatory Element ("+key+") does not exist"; } value = element.getChild(key).getValue(); if(value.length()> Integer.parseInt(rules.get("size"))){ counter ++; desc = "Field "+key+" exceeded max size ("+rules.get("size")+")"; } } element.addContent(new Element("DESC").setText(desc)); System.out.println(counter); return element; } private Document convertXmlFileToDocument(String path){ SAXBuilder sb=new SAXBuilder(); File xmlFile = new File(path); Document doc = null; try { doc = sb.build(xmlFile); } catch (Exception e) { e.printStackTrace(); } return doc; }
0debug
How to make my enum inherit from a class? : Before: enum EMagicAbility{ Fireball, IceBolt, BlackMagic }; enum EPhysicalAbility{ SwordLance, FearlessBlow, RagnarokRage }; enum ERangedAbility{ Snipe, RainOfArrows, CrossbowShot }; enum EBiologicalAbility{bla,bla,bla}; enum Eblabla{}; enum Eevenmore{}; ... There are many more abilities ... ... //Each EMagicAbility can only have either zero or one Ability value. Dictionary<EMagicAbility,Ability> myMagicAbilityDictionary; //Each EPhysicalAbility can only have either zero or one Ability value. Dictionary<EPhysicalAbility,Ability> myPhysicalAbilityDictionary; //Each EPhysicalAbility can only have either zero or one Ability value. Dictionary<ERangedAbility,Ability> myRangedAbilityDictionary; //Each EBiologicalAbility can only have either zero or one Ability value. Dictionary<EBiologicalAbility,Ability> myBiologicalAbilityDictionary; //Each Eblabla can only have either zero or one Ability value. Dictionary<Eblabla,Ability> myBlablaAbilityDictionary; //Each Eevenmore can only have either zero or one Ability value. Dictionary<Eblabla,Ability> myBlablaAbilityDictionary; ... keeps going on... ... After: enum class EAbility{} enum EMagicAbility:EAbility{ Fireball, IceBolt, BlackMagic }; enum EPhysicalAbility:EAbility{ SwordLance, FearlessBlow, RagnarokRage }; enum ERangedAbility:EAbility{ Snipe, RainOfArrows, CrossbowShot }; enum EBiologicalAbility:EAbility{bla,bla,bla}; enum Eblabla:EAbility{}; enum Eevenmore:EAbility{}; ... There are many more abilities ... ... //Each any enum derived from Eability can only have either zero or one Ability value. Dictionary<EAbility,Ability> myAbilityDictionary; //I don't have to create another dictionary when I create a new category of Abilities! Yay! This is probably a super similar to this question: http://stackoverflow.com/questions/35191235/what-variable-type-should-i-use-to-store-types-of-a-non-sealed-class-or-interfac/35191505#35191505 In which I would use this instead: //I can remove all enumerations have such a clean, one-line code <3<3 Dictionary<typeof(Ability),Ability> myAbilityDictionary; EDIT: After doing some more research, I found out that this may be a viable option for me: http://stackoverflow.com/questions/518442/enum-subset-or-subgroup-in-c-sharp The problem with this is that I will have a behemoth amount of lines of code, which I rather find a more sane way to solve this. Also, an up vote would be really, really helpful since I can't access some features in stackoverflow, thank you.
0debug
single sign on on ubuntu computer withou using any server : >I want to try signle sign on on ubuntu > computers without using any server.. how to implement this on local > computer is it possible or not ?
0debug
Fabricjs How to scale object but keep the border (stroke) width fixed : <p>I'm developing a diagram tool based on fabricjs. Our tool has our own collection of shape, which is svg based. My problem is when I scale the object, the border (stroke) scale as well. My question is: How can I scale the object but keep the stroke width fixed. Please check the attachments.<br> <a href="https://i.stack.imgur.com/3UVMc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3UVMc.png" alt="small version"></a></p> <p><a href="https://i.stack.imgur.com/QCMLM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QCMLM.png" alt="scaled version"></a></p> <p>Thank you very much! </p>
0debug
Swift 4 - MisplacedView, Frame will be different at runtime : I'm not able to get this warning fixed. When I start the App everything is looking good... I tried to Update frames and everything I found on the Internet.. The Warning came up the first time, after I restarted Xcode.. This is a how my CollectionViewController looks like in the StoryBoard: [![error][1]][1] [1]: https://i.stack.imgur.com/cbpv3.png Someone knows how to resolve this?
0debug
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep) { int ret, count = 0; while (*opts) { if ((ret = parse_key_value_pair(ctx, &opts, key_val_sep, pairs_sep)) < 0) return ret; count++; if (*opts) opts++; } return count; }
1threat
static inline void RENAME(BEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused) { #if COMPILE_TEMPLATE_MMX __asm__ volatile( "movq "MANGLE(bm01010101)", %%mm4 \n\t" "mov %0, %%"REG_a" \n\t" "1: \n\t" "movq (%1, %%"REG_a",2), %%mm0 \n\t" "movq 8(%1, %%"REG_a",2), %%mm1 \n\t" "movq (%2, %%"REG_a",2), %%mm2 \n\t" "movq 8(%2, %%"REG_a",2), %%mm3 \n\t" "pand %%mm4, %%mm0 \n\t" "pand %%mm4, %%mm1 \n\t" "pand %%mm4, %%mm2 \n\t" "pand %%mm4, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" "movq %%mm0, (%3, %%"REG_a") \n\t" "movq %%mm2, (%4, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "g" ((x86_reg)-width), "r" (src1+width*2), "r" (src2+width*2), "r" (dstU+width), "r" (dstV+width) : "%"REG_a ); #else int i; for (i=0; i<width; i++) { dstU[i]= src1[2*i]; dstV[i]= src2[2*i]; } #endif }
1threat
static int monitor_fdset_dup_fd_find_remove(int dup_fd, bool remove) { MonFdset *mon_fdset; MonFdsetFd *mon_fdset_fd_dup; QLIST_FOREACH(mon_fdset, &mon_fdsets, next) { QLIST_FOREACH(mon_fdset_fd_dup, &mon_fdset->dup_fds, next) { if (mon_fdset_fd_dup->fd == dup_fd) { if (remove) { QLIST_REMOVE(mon_fdset_fd_dup, next); if (QLIST_EMPTY(&mon_fdset->dup_fds)) { monitor_fdset_cleanup(mon_fdset); } } return mon_fdset->id; } } } return -1; }
1threat
Cursor overwrite mode in vscode? : <p>I can't seem to find any way to put the cursor into 'overwrite' mode - as in when you press the insert key and newly typed characters overwrite the existing characters inline. I haven't found any reference anywhere online to the omission or inclusion of such a feature in vscode, but it seems to be a fairly commonly used feature. Does this exist?</p>
0debug