problem
stringlengths
26
131k
labels
class label
2 classes
static int vfio_add_capabilities(VFIOPCIDevice *vdev) { PCIDevice *pdev = &vdev->pdev; int ret; if (!(pdev->config[PCI_STATUS] & PCI_STATUS_CAP_LIST) || !pdev->config[PCI_CAPABILITY_LIST]) { return 0; } ret = vfio_add_std_cap(vdev, pdev->config[PCI_CAPABILITY_LIST]); if (ret) { return ret; } if (!pci_is_express(pdev) || !pci_bus_is_express(pdev->bus) || !pci_get_long(pdev->config + PCI_CONFIG_SPACE_SIZE)) { return 0; } return vfio_add_ext_cap(vdev); }
1threat
How to represent Guid in typescript? : <p>let's say I have this C# class</p> <pre><code>public class Product { public Guid Id { get; set; } public string ProductName { get; set; } public Decimal Price { get; set; } public int Level { get; set; } } </code></pre> <p>The equivalent typescript would be something like:</p> <pre><code>export class Product { id: ???; productName: string; price: number; level: number; } </code></pre> <p>How to represent Guid in typescript? </p>
0debug
how to split number and simbols JAVA : I need help with the java. As I have such a character in a line 1.11 € 1.10 € 1.02 € 0.66 € 0.50 and I need to add these characters to separate variables like double i = 1.11 double a = 1.10 and so on.
0debug
static void arm_gic_realize(DeviceState *dev, Error **errp) { GICv3State *s = ARM_GICV3(dev); ARMGICv3Class *agc = ARM_GICV3_GET_CLASS(s); Error *local_err = NULL; agc->parent_realize(dev, &local_err); if (local_err) { error_propagate(errp, local_err); return; } gicv3_init_irqs_and_mmio(s, gicv3_set_irq, NULL); }
1threat
Calculate total number of levels of nesting paranthesis for each letter in input string : I have input string ``` `(a ( b c ) ( d ( e ) ) )` ``` I want to calculate total number of nested paranthesis for each character ``` for example output should be for a -> 1 b and c and d -> 2 and for e -> 3 ```
0debug
from collections import defaultdict def count_Substrings(s,n): count,sum = 0,0 mp = defaultdict(lambda : 0) mp[0] += 1 for i in range(n): sum += ord(s[i]) - ord('0') count += mp[sum - (i + 1)] mp[sum - (i + 1)] += 1 return count
0debug
c# I can not Parse JSON to string : I have problem with my code. I don't know how to fix. I just want to get all title from json. It showed error at: var obj = JObject.Parse(jsons); "Unexpected character encountered while parsing value: . Path '', line 0, position 0." public void getTitle() { ArrayList myTitle = new ArrayList(); string url = "https://www.fiverr.com/gigs/endless_page_as_json?host=subcategory&type=endless_auto&category_id=3&sub_category_id=154&limit=48&filter=auto&use_single_query=true&page=1&instart_disable_injection=true"; using (var webClient = new System.Net.WebClient()) { var jsons = webClient.DownloadString(url); if (jsons != null) { var obj = JObject.Parse(jsons); var urll = (string)obj["gigs"]["title"]; myNode1.Add(urll); } else { MessageBox.Show("nothing"); } }
0debug
static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags) { int ident, fragmented, tdt, num_pkts, pkt_len; if (!buf) { if (!data->split_buf || data->split_pos + 2 > data->split_buf_len || data->split_pkts <= 0) { av_log(ctx, AV_LOG_ERROR, "No more data to return\n"); return AVERROR_INVALIDDATA; } pkt_len = AV_RB16(data->split_buf + data->split_pos); data->split_pos += 2; if (data->split_pos + pkt_len > data->split_buf_len) { av_log(ctx, AV_LOG_ERROR, "Not enough data to return\n"); return AVERROR_INVALIDDATA; } if (av_new_packet(pkt, pkt_len)) { av_log(ctx, AV_LOG_ERROR, "Out of memory.\n"); return AVERROR(ENOMEM); } pkt->stream_index = st->index; memcpy(pkt->data, data->split_buf + data->split_pos, pkt_len); data->split_pos += pkt_len; data->split_pkts--; return data->split_pkts > 0; } if (len < 6 || len > INT_MAX/2) { av_log(ctx, AV_LOG_ERROR, "Invalid %d byte packet\n", len); return AVERROR_INVALIDDATA; } ident = AV_RB24(buf); fragmented = buf[3] >> 6; tdt = (buf[3] >> 4) & 3; num_pkts = buf[3] & 0xf; pkt_len = AV_RB16(buf + 4); if (pkt_len > len - 6) { av_log(ctx, AV_LOG_ERROR, "Invalid packet length %d in %d byte packet\n", pkt_len, len); return AVERROR_INVALIDDATA; } if (ident != data->ident) { av_log(ctx, AV_LOG_ERROR, "Unimplemented Xiph SDP configuration change detected\n"); return AVERROR_PATCHWELCOME; } if (tdt) { av_log(ctx, AV_LOG_ERROR, "Unimplemented RTP Xiph packet settings (%d,%d,%d)\n", fragmented, tdt, num_pkts); return AVERROR_PATCHWELCOME; } buf += 6; len -= 6; if (fragmented == 0) { if (av_new_packet(pkt, pkt_len)) { av_log(ctx, AV_LOG_ERROR, "Out of memory.\n"); return AVERROR(ENOMEM); } pkt->stream_index = st->index; memcpy(pkt->data, buf, pkt_len); buf += pkt_len; len -= pkt_len; num_pkts--; if (num_pkts > 0) { if (len > data->split_buf_size || !data->split_buf) { av_freep(&data->split_buf); data->split_buf_size = 2 * len; data->split_buf = av_malloc(data->split_buf_size); if (!data->split_buf) { av_log(ctx, AV_LOG_ERROR, "Out of memory.\n"); av_free_packet(pkt); return AVERROR(ENOMEM); } } memcpy(data->split_buf, buf, len); data->split_buf_len = len; data->split_pos = 0; data->split_pkts = num_pkts; return 1; } return 0; } else if (fragmented == 1) { int res; ffio_free_dyn_buf(&data->fragment); if((res = avio_open_dyn_buf(&data->fragment)) < 0) return res; avio_write(data->fragment, buf, pkt_len); data->timestamp = *timestamp; } else { av_assert1(fragmented < 4); if (data->timestamp != *timestamp) { ffio_free_dyn_buf(&data->fragment); av_log(ctx, AV_LOG_ERROR, "RTP timestamps don't match!\n"); return AVERROR_INVALIDDATA; } if (!data->fragment) { av_log(ctx, AV_LOG_WARNING, "Received packet without a start fragment; dropping.\n"); return AVERROR(EAGAIN); } avio_write(data->fragment, buf, pkt_len); if (fragmented == 3) { int ret = ff_rtp_finalize_packet(pkt, &data->fragment, st->index); if (ret < 0) { av_log(ctx, AV_LOG_ERROR, "Error occurred when getting fragment buffer."); return ret; } return 0; } } return AVERROR(EAGAIN); }
1threat
int kvm_arch_put_registers(CPUState *cpu, int level) { X86CPU *x86_cpu = X86_CPU(cpu); int ret; assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu)); if (level >= KVM_PUT_RESET_STATE) { ret = kvm_put_msr_feature_control(x86_cpu); if (ret < 0) { return ret; } } if (level == KVM_PUT_FULL_STATE) { kvm_arch_set_tsc_khz(cpu); } ret = kvm_getput_regs(x86_cpu, 1); if (ret < 0) { return ret; } ret = kvm_put_xsave(x86_cpu); if (ret < 0) { return ret; } ret = kvm_put_xcrs(x86_cpu); if (ret < 0) { return ret; } ret = kvm_put_sregs(x86_cpu); if (ret < 0) { return ret; } ret = kvm_inject_mce_oldstyle(x86_cpu); if (ret < 0) { return ret; } ret = kvm_put_msrs(x86_cpu, level); if (ret < 0) { return ret; } if (level >= KVM_PUT_RESET_STATE) { ret = kvm_put_mp_state(x86_cpu); if (ret < 0) { return ret; } } ret = kvm_put_tscdeadline_msr(x86_cpu); if (ret < 0) { return ret; } ret = kvm_put_vcpu_events(x86_cpu, level); if (ret < 0) { return ret; } ret = kvm_put_debugregs(x86_cpu); if (ret < 0) { return ret; } ret = kvm_guest_debug_workarounds(x86_cpu); if (ret < 0) { return ret; } return 0; }
1threat
static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, FsCred *credp) { char *path; int err = -1; int serrno = 0; V9fsString fullname; char *buffer; v9fs_string_init(&fullname); v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); path = fullname.data; if (fs_ctx->export_flags & V9FS_SM_MAPPED) { buffer = rpath(fs_ctx, path); err = mknod(buffer, SM_LOCAL_MODE_BITS|S_IFREG, 0); if (err == -1) { g_free(buffer); goto out; } err = local_set_xattr(buffer, credp); if (err == -1) { serrno = errno; goto err_end; } } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { buffer = rpath(fs_ctx, path); err = mknod(buffer, SM_LOCAL_MODE_BITS|S_IFREG, 0); if (err == -1) { g_free(buffer); goto out; } err = local_set_mapped_file_attr(fs_ctx, path, credp); if (err == -1) { serrno = errno; goto err_end; } } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || (fs_ctx->export_flags & V9FS_SM_NONE)) { buffer = rpath(fs_ctx, path); err = mknod(buffer, credp->fc_mode, credp->fc_rdev); if (err == -1) { g_free(buffer); goto out; } err = local_post_create_passthrough(fs_ctx, path, credp); if (err == -1) { serrno = errno; goto err_end; } } goto out; err_end: remove(buffer); errno = serrno; g_free(buffer); out: v9fs_string_free(&fullname); return err; }
1threat
CSS selector for all elements starting with a prefix : <p>I have several polymer elements.</p> <pre><code>&lt;ps-el-one/&gt; &lt;ps-el-two/&gt; &lt;ps-el-three/&gt; &lt;ps-el-four/&gt; </code></pre> <p>I want to be able to query all of the elements which begin with "ps-" with either a CSS selector or javaScript.</p> <p>I whipped up the following solution, but I am wondering if there is anything more efficient?</p> <pre><code>var allElementsOnPage = document.querySelectorAll('*'); var res = []; for (var index in allElementsOnPage) { var el = allElementsOnPage[index]; if (el &amp;&amp; el.tagName &amp;&amp; el.tagName.substr(0, 3) == 'PS-') { res.push(el); } } </code></pre> <p>This solution seems very inefficient.</p>
0debug
Jquery ajax not loading in same page : I'm trying to load my stripe payment success message when the form is submitted but for some reason the page always refreshes and then I get the display message. I don't want the page refresh though. This is a javascript I'm working with (a mix of jquery and vanilla js) <script type="text/javascript"> // this identifies your website in the createToken call below Stripe.setPublishableKey('stripe_key_here'); function stripeResponseHandler(status, response) { if (response.error) { // re-enable the submit button $('.submit-button').removeAttr("disabled"); // show hidden div document.getElementById('a_x200').style.display = 'block'; // show the errors on the form $(".payment-errors").html(response.error.message); } else { var form$ = $("#payment-form"); // token contains id, last4, and card type var token = response['id']; var posted = document.getElementById("post-price").value // insert the token into the form so it gets submitted to the server form$.append("<input type='hidden' name='stripeToken' value='" + token + "' />"); form$.append("<input type='hidden' name='posted' value='" + posted + "' />"); // and submit $("#payment-form").get(0).submit(function(e) { e.preventDefault(); var url = "pricing.php"; $.ajax({ type: "POST", url: url, data: $("#payment-form").serialize(), success: function(data) { alert(data); } }); }); } } </script>
0debug
Calculate time difference in word VBA : I would like to calculate the time difference between 2 cells and the result showing in the 3rd cell. For instance, cell D2 showing 2pm and D1 showing 1pm and the difference in cell B2 Sub DetermineDuration() Dim doc As Document Dim rng As Range Dim dtDuration As Date dtDuration = DateDiff("h:mm:ss", D2, D1) Range("B2").dtDuration End Sub
0debug
Immutability and collections : <p>Hello I've got a questation, is this bad approach to immutability? And if it is, why? I mean for me if you adding or removing items to or from collection, you are not changing the state of the object, it still has one and the same collection. It doesn't really matter how many and if collection has items when you itterating it. When you ask for it, you will get allways different reference which you can not modify. If this is bad practice where are pros in using immutable collections?</p> <p>Thank you!</p> <pre><code>using System; using System.Collections.Generic; class Test { private readonly List&lt;object&gt; items; public object[] Items { get { return this.items.ToArray(); } } public Test(params object[] items) { this.items = new List&lt;object&gt;(); this.items.AddRange(items); } public void AddItem(object item) { this.items.Add(item); } } </code></pre>
0debug
Why is it saying that the = in bold is an invalid syntax? : <pre><code>print('Select operation') print('Choose from:') print('+') print('-') print('*') print('/') choice=input('Enter choice (+,-,*,/):') num1=int(input('Enter first number:')) num2=int(input('Enter second number:')) if choice== '+': print(num1,'+',num1,'=', (num1+num2)) while restart **=** input('Do you want to restart the calculator y/n'): if restart == 'y':t print('restart') else restart == 'n': print('Thanks for using my program') break elif choice== '-': print(num1,'-',num2,'=', (num1-num2)) elif choice== '*': print(num1,'*',num2,'=', (num1*num2)) elif choice== '/': print(num1,'/',num2,'=',(num1/num2)) else: print('Invalid input') </code></pre> <p>What is wrong with the = in bold? I don't understand what is wrong with it? Someone please answer my question.</p> <p>Thank you, Charlotte</p>
0debug
static void block_job_ref(BlockJob *job) { ++job->refcnt; }
1threat
static int mp_user_removexattr(FsContext *ctx, const char *path, const char *name) { char buffer[PATH_MAX]; if (strncmp(name, "user.virtfs.", 12) == 0) { errno = EACCES; return -1; } return lremovexattr(rpath(ctx, path, buffer), name); }
1threat
Fetching the server IP from URL : <p>Suppose I go on to some website from my chrome browser. Is it possible in any programing language like PHP, js to fetch the server IP of a webpage from its URL. (for eg: like we do using NSlookup). Is it possible to write a script to get the server IP of a webpage using its URL.</p>
0debug
qio_channel_command_new_spawn(const char *const argv[], int flags, Error **errp) { pid_t pid = -1; int stdinfd[2] = { -1, -1 }; int stdoutfd[2] = { -1, -1 }; int devnull = -1; bool stdinnull = false, stdoutnull = false; QIOChannelCommand *ioc; flags = flags & O_ACCMODE; if (flags == O_RDONLY) { stdinnull = true; } if (flags == O_WRONLY) { stdoutnull = true; } if (stdinnull || stdoutnull) { devnull = open("/dev/null", O_RDWR); if (!devnull) { error_setg_errno(errp, errno, "Unable to open /dev/null"); goto error; } } if ((!stdinnull && pipe(stdinfd) < 0) || (!stdoutnull && pipe(stdoutfd) < 0)) { error_setg_errno(errp, errno, "Unable to open pipe"); goto error; } pid = qemu_fork(errp); if (pid < 0) { goto error; } if (pid == 0) { dup2(stdinnull ? devnull : stdinfd[0], STDIN_FILENO); dup2(stdoutnull ? devnull : stdoutfd[1], STDOUT_FILENO); if (!stdinnull) { close(stdinfd[0]); close(stdinfd[1]); } if (!stdoutnull) { close(stdoutfd[0]); close(stdoutfd[1]); } execv(argv[0], (char * const *)argv); _exit(1); } if (!stdinnull) { close(stdinfd[0]); } if (!stdoutnull) { close(stdoutfd[1]); } ioc = qio_channel_command_new_pid(stdinnull ? devnull : stdinfd[1], stdoutnull ? devnull : stdoutfd[0], pid); trace_qio_channel_command_new_spawn(ioc, argv[0], flags); return ioc; error: if (stdinfd[0] != -1) { close(stdinfd[0]); } if (stdinfd[1] != -1) { close(stdinfd[1]); } if (stdoutfd[0] != -1) { close(stdoutfd[0]); } if (stdoutfd[1] != -1) { close(stdoutfd[1]); } return NULL; }
1threat
How to put script in a separate file? : <p>I have this code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;p id="demo"&gt;&lt;/p&gt; &lt;script&gt; var txt = '{"name":"John", "city":"New York"}' var obj = JSON.parse(txt); document.getElementById("demo").innerHTML = obj.name; &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>How to put the script in another file named "myscript.js" and connect to html page? I want to do that because i want to link the script to multiple html pages and sometimes i need to change var txt = '{"name":"John", "city":"New York"}'</p> <p>Thank you!</p>
0debug
where did NUnit Gui Runner go? version 3.0.1 : <p>I just upgraded to version 3.0.1 from nunit 2.6.4. It used to have a NUnit Gui Runner, located here:</p> <p><a href="https://i.stack.imgur.com/PNHqE.png"><img src="https://i.stack.imgur.com/PNHqE.png" alt="enter image description here"></a></p> <p>After installing 3.0.1 (which I downloaded windows version <a href="http://www.nunit.org/index.php?p=download">from here</a>)</p> <p>I now no longer see the nunit.exe in the installation folder, for example the directory structure is different and appears to be missing many files that were part of the previous installation:</p> <p><a href="https://i.stack.imgur.com/zN6c4.png"><img src="https://i.stack.imgur.com/zN6c4.png" alt="enter image description here"></a></p>
0debug
What's the right way to clear a bytes.Buffer in golang? : <p>I'm trying to clear a <code>bytes.Buffer</code>, but there's no such function in the document</p> <p>Maybe I should just renew the buffer? What's the right way to do it?</p> <pre><code>buffer = bytes.NewBufferString("") buffer.Grow (30000) </code></pre>
0debug
Variance Inflation Factor in Python : <p>I'm trying to calculate the variance inflation factor (VIF) for each column in a simple dataset in python: </p> <pre><code>a b c d 1 2 4 4 1 2 6 3 2 3 7 4 3 2 8 5 4 1 9 4 </code></pre> <p>I have already done this in R using the vif function from the <a href="https://cran.r-project.org/web/packages/usdm/usdm.pdf" rel="noreferrer">usdm library</a> which gives the following results:</p> <pre><code>a &lt;- c(1, 1, 2, 3, 4) b &lt;- c(2, 2, 3, 2, 1) c &lt;- c(4, 6, 7, 8, 9) d &lt;- c(4, 3, 4, 5, 4) df &lt;- data.frame(a, b, c, d) vif_df &lt;- vif(df) print(vif_df) Variables VIF a 22.95 b 3.00 c 12.95 d 3.00 </code></pre> <p>However, when I do the same in python using the <a href="http://statsmodels.sourceforge.net/devel/generated/statsmodels.stats.outliers_influence.variance_inflation_factor.html" rel="noreferrer">statsmodel vif function</a>, my results are:</p> <pre><code>a = [1, 1, 2, 3, 4] b = [2, 2, 3, 2, 1] c = [4, 6, 7, 8, 9] d = [4, 3, 4, 5, 4] ck = np.column_stack([a, b, c, d]) vif = [variance_inflation_factor(ck, i) for i in range(ck.shape[1])] print(vif) Variables VIF a 47.136986301369774 b 28.931506849315081 c 80.31506849315096 d 40.438356164383549 </code></pre> <p>The results are vastly different, even though the inputs are the same. In general, results from the statsmodel VIF function seem to be wrong, but I'm not sure if this is because of the way I am calling it or if it is an issue with the function itself. </p> <p>I was hoping someone could help me figure out whether I was incorrectly calling the statsmodel function or explain the discrepancies in the results. If it's an issue with the function then are there any VIF alternatives in python?</p>
0debug
how to create string and sum from A,B,C in javascript : how to make output from A,B,C and calculate all result, where AAAA = 1 AAAA AAAB AAAC AABA etc
0debug
static int ide_write_dma_cb(IDEState *s, target_phys_addr_t phys_addr, int transfer_size1) { int len, transfer_size, n; int64_t sector_num; transfer_size = transfer_size1; for(;;) { len = s->io_buffer_size - s->io_buffer_index; if (len == 0) { n = s->io_buffer_size >> 9; sector_num = ide_get_sector(s); bdrv_write(s->bs, sector_num, s->io_buffer, s->io_buffer_size >> 9); sector_num += n; ide_set_sector(s, sector_num); s->nsector -= n; n = s->nsector; if (n == 0) { s->status = READY_STAT | SEEK_STAT; ide_set_irq(s); return 0; } if (n > MAX_MULT_SECTORS) n = MAX_MULT_SECTORS; s->io_buffer_index = 0; s->io_buffer_size = n * 512; len = s->io_buffer_size; } if (transfer_size <= 0) break; if (len > transfer_size) len = transfer_size; cpu_physical_memory_read(phys_addr, s->io_buffer + s->io_buffer_index, len); s->io_buffer_index += len; transfer_size -= len; phys_addr += len; } return transfer_size1 - transfer_size; }
1threat
sPAPRTCETable *spapr_tce_find_by_liobn(uint32_t liobn) { sPAPRTCETable *tcet; if (liobn & 0xFFFFFFFF00000000ULL) { hcall_dprintf("Request for out-of-bounds LIOBN 0x" TARGET_FMT_lx "\n", liobn); return NULL; } QLIST_FOREACH(tcet, &spapr_tce_tables, list) { if (tcet->liobn == liobn) { return tcet; } } return NULL; }
1threat
How to convert node.js code to regular browser javascript? : <p>I don't know how to get a javascript file to work for web-browser functionalit, when it's coded as node.js.</p> <p>The code in question is from a github <a href="https://github.com/svk31/graphenejs-lib" rel="noreferrer">graphenejs-lib</a>. I want to convert this node.js code into js:</p> <pre><code>import {Apis} from "graphenejs-ws"; var {ChainStore} = require("graphenejs-lib"); Apis.instance("wss://bitshares.openledger.info/ws", true).init_promise.then((res) =&gt; { console.log("connected to:", res[0].network); ChainStore.init().then(() =&gt; { ChainStore.subscribe(updateState); }); }); let dynamicGlobal = null; function updateState(object) { dynamicGlobal = ChainStore.getObject("2.1.0"); console.log("ChainStore object update\n", dynamicGlobal ? dynamicGlobal.toJS() : dynamicGlobal); } </code></pre> <p>There is another github from the same developer, <a href="https://github.com/svk31/steemjs-lib" rel="noreferrer">steemjs-lib</a>, that shows both the node.js use, and the browser use in the README default page.</p> <p>I don't know how to make graphenejs-lib into browser javascript, like the steemjs-lib has been made into a regular javascript working version. I contact the dev, but have yet to receive a response.</p> <p>I figured other people actually know how to do what the dev did for steemjs-lib, and get the graphenejs-lib to work in a browser.</p> <p>Can you help me out? Thank you.</p>
0debug
void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp) { int64_t value; if (!error_is_set(errp)) { if (v->type_int16) { v->type_int16(v, obj, name, errp); } else { value = *obj; v->type_int(v, &value, name, errp); if (value < INT16_MIN || value > INT16_MAX) { error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null", "int16_t"); return; } *obj = value; } } }
1threat
change the background color of a given field only in a form : <p>Is it possible to target a particular text field in a form and change it's background &amp; foreground color. Likewise different colors for different fields too.</p> <p>It needs to use css and not js and also there is to be no inline html/code present.</p> <p>Thanks all.</p>
0debug
Recycleview not scroll in nested scroolview android : I have using recycle view inside nested Scroll view but Recycle view not scroll down in nested scroll view.recycle view scroll down when keyboard open and new item add in recycle view
0debug
addStyleClass("sapUiSizeCompact"); after clicking a button in UI5 : I want to change the compact density with a button. onInit: function () { this.getView().addStyleClass("sapUiSizeCompact"); }, works well. If I will change it in a button, it does not work. onOpenDialog: function (oEvent) { var oDialog1 = new sap.ui.commons.Dialog(); oDialog1.setTitle("App View Settings"); var oText = new sap.ui.commons.TextView({ text: "Compact Content Density:" }); oDialog1.addContent(oText); var oToggleButton1 = new sap.ui.commons.ToggleButton({ text: "ON, press for OFF", tooltip: "This is a test tooltip", pressed: true, press: function () { if (oToggleButton1.getPressed()) { oToggleButton1.setText("ON, press for OFF"); this.getView().addStyleClass("sapUiSizeCompact"); } else { oToggleButton1.setText("OFF, press for ON"); this.getView().removeStyleClass("sapUiSizeCompact"); } } }); oDialog1.addContent(oToggleButton1); oDialog1.addButton(new sap.ui.commons.Button({ text: "OK", press: function () { oDialog1.close(); } })); oDialog1.open(); }, How can I point to the view from inside the function? Thanks Marcus
0debug
Convert drawings in instructions for Java Swing paintComponent : <p>Would you know a software able to convert simple drawings (done with simple instructions that can be found in paintComponent like fillRectangle, drawLine... etc) into Java instructions?</p> <p>I ask this question because I'm programming a Pacman game, and i wanted to be able to randomly generate ghosts, with random color, and shapes.</p> <p>Thank you. </p>
0debug
cannot resolve symbol 'R' in android studio 3.3.1 : I am using android 3.3.1. I am currently taking an android development bootcamp online course on udemy. After I cloned the project from github to android studio (bitcoin-ticker), after the graddle files synchronize and project is loaded, when I open the MainActivity in java, I get R in red saying cannot resolve symbol 'R'. I didn't see a r class files in the project. So, I cleaned and built the project, android studio generated automatically the r class. I still had the cannot resolve symbol 'R' error. I moved the generated r class file to the same package where MainActivity java is with no result. Here is a picture of what it looks. Does anyone know how can I get rid of the red R and get the project to compile? Thanks in advance [enter image description here][1] [1]: https://i.stack.imgur.com/BYlXs.png
0debug
static void drive_backup_prepare(BlkActionState *common, Error **errp) { DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common); BlockBackend *blk; DriveBackup *backup; Error *local_err = NULL; assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP); backup = common->action->u.drive_backup.data; blk = blk_by_name(backup->device); if (!blk) { error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", backup->device); return; } if (!blk_is_available(blk)) { error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, backup->device); return; } state->aio_context = blk_get_aio_context(blk); aio_context_acquire(state->aio_context); bdrv_drained_begin(blk_bs(blk)); state->bs = blk_bs(blk); do_drive_backup(backup->has_job_id ? backup->job_id : NULL, backup->device, backup->target, backup->has_format, backup->format, backup->sync, backup->has_mode, backup->mode, backup->has_speed, backup->speed, backup->has_bitmap, backup->bitmap, backup->has_on_source_error, backup->on_source_error, backup->has_on_target_error, backup->on_target_error, common->block_job_txn, &local_err); if (local_err) { error_propagate(errp, local_err); return; } state->job = state->bs->job; }
1threat
Can i reboot phone without root access on b4a? : How to reboot phone without root access on b4a? Only need root access with ML library? Pls help me, i m start learning in b4a. Code: Sub Globals Dim M as MLfiles End Sub Sub Activity_Create(FirstTime As Boolean) M.GetRoot M.RootCmd("reboot","",Null,Null,False) End Sub
0debug
Is there a way to share a configMap in kubernetes between namespaces? : <p>We are using one namespace for the develop environment and one for the staging environment. Inside each one of this namespaces we have several configMaps and secrets but there are a lot of share variables between the two environments so we will like to have a common file for those.</p> <p>Is there a way to have a base configMap into the default namespace and refer to it using something like:</p> <pre><code>- envFrom: - configMapRef: name: default.base-config-map </code></pre> <p>If this is not possible, is there no other way other than duplicate the variables through namespaces?</p>
0debug
static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section) { KVMState *s = kvm_state; unsigned long size, allocated_size = 0; KVMDirtyLog d; KVMSlot *mem; int ret = 0; hwaddr start_addr = section->offset_within_address_space; hwaddr end_addr = start_addr + int128_get64(section->size); d.dirty_bitmap = NULL; while (start_addr < end_addr) { mem = kvm_lookup_overlapping_slot(s, start_addr, end_addr); if (mem == NULL) { break; } size = ALIGN(((mem->memory_size) >> TARGET_PAGE_BITS), 64) / 8; if (!d.dirty_bitmap) { d.dirty_bitmap = g_malloc(size); } else if (size > allocated_size) { d.dirty_bitmap = g_realloc(d.dirty_bitmap, size); } allocated_size = size; memset(d.dirty_bitmap, 0, allocated_size); d.slot = mem->slot; if (kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d) == -1) { DPRINTF("ioctl failed %d\n", errno); ret = -1; break; } kvm_get_dirty_pages_log_range(section, d.dirty_bitmap); start_addr = mem->start_addr + mem->memory_size; } g_free(d.dirty_bitmap); return ret; }
1threat
static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) { InputStream *ist = NULL; enum AVMediaType type = avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx); int i; if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) { av_log(NULL, AV_LOG_FATAL, "Only video and audio filters supported " "currently.\n"); exit(1); } if (in->name) { AVFormatContext *s; AVStream *st = NULL; char *p; int file_idx = strtol(in->name, &p, 0); if (file_idx < 0 || file_idx >= nb_input_files) { av_log(NULL, AV_LOG_FATAL, "Invalid file index %d in filtegraph description %s.\n", file_idx, fg->graph_desc); exit(1); } s = input_files[file_idx]->ctx; for (i = 0; i < s->nb_streams; i++) { if (s->streams[i]->codecpar->codec_type != type) continue; if (check_stream_specifier(s, s->streams[i], *p == ':' ? p + 1 : p) == 1) { st = s->streams[i]; break; } } if (!st) { av_log(NULL, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s " "matches no streams.\n", p, fg->graph_desc); exit(1); } ist = input_streams[input_files[file_idx]->ist_index + st->index]; } else { for (i = 0; i < nb_input_streams; i++) { ist = input_streams[i]; if (ist->dec_ctx->codec_type == type && ist->discard) break; } if (i == nb_input_streams) { av_log(NULL, AV_LOG_FATAL, "Cannot find a matching stream for " "unlabeled input pad %d on filter %s\n", in->pad_idx, in->filter_ctx->name); exit(1); } } av_assert0(ist); ist->discard = 0; ist->decoding_needed = 1; ist->st->discard = AVDISCARD_NONE; GROW_ARRAY(fg->inputs, fg->nb_inputs); if (!(fg->inputs[fg->nb_inputs - 1] = av_mallocz(sizeof(*fg->inputs[0])))) exit(1); fg->inputs[fg->nb_inputs - 1]->ist = ist; fg->inputs[fg->nb_inputs - 1]->graph = fg; fg->inputs[fg->nb_inputs - 1]->format = -1; fg->inputs[fg->nb_inputs - 1]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*)); if (!fg->inputs[fg->nb_inputs - 1]) exit_program(1); GROW_ARRAY(ist->filters, ist->nb_filters); ist->filters[ist->nb_filters - 1] = fg->inputs[fg->nb_inputs - 1]; }
1threat
void ff_vp3_h_loop_filter_c(uint8_t *first_pixel, int stride, int *bounding_values) { unsigned char *end; int filter_value; for (end= first_pixel + 8*stride; first_pixel != end; first_pixel += stride) { filter_value = (first_pixel[-2] - first_pixel[ 1]) +3*(first_pixel[ 0] - first_pixel[-1]); filter_value = bounding_values[(filter_value + 4) >> 3]; first_pixel[-1] = av_clip_uint8(first_pixel[-1] + filter_value); first_pixel[ 0] = av_clip_uint8(first_pixel[ 0] - filter_value); } }
1threat
Xamarin.Android Architecture Components: Not getting callbacks for lifecycle events : <p>I'm trying to use the architecture components package for detecting when the application enters background or foreground state. The problem is that the callbacks are not being invoked. In the sample code below, the methods <code>onApplicationForegrounded</code> and <code>onApplicationBackgrounded</code> are not invoked:</p> <pre><code>namespace POC.Droid { [Application] public class MyApp : Application, ILifecycleObserver { static readonly string TAG = "MyApp"; public MyApp(IntPtr handle, Android.Runtime.JniHandleOwnership ownerShip) : base(handle, ownerShip) { } public override void OnCreate() { base.OnCreate(); ProcessLifecycleOwner.Get().Lifecycle.AddObserver(this); } [Lifecycle.Event.OnStop] public void onAppBackgrounded() { Log.Debug(TAG, "App entered background state."); } [Lifecycle.Event.OnStart] public void onAppForegrounded() { Log.Debug(TAG, "App entered foreground state."); } } } </code></pre> <p>My Xamarin version is 8.2.0.16 (Visual Studio Community) and Xamarin.Android.Arch.Lifecycle.Extensions version is 1.0.0. I'm using a Nougat device (7.0) for testing.</p>
0debug
static uint32_t isa_mmio_readl(void *opaque, target_phys_addr_t addr) { return cpu_inl(addr & IOPORTS_MASK); }
1threat
This code should reverse the string but i am not getting why is it not reversing the string? : class Solution: def reverseString(self, s: List[str]) -> None: if(len(s)<=1): return s[0],s[-1] = s[-1],s[0] self.reverseString(s[1:-1]) this was a question on leetcode. we have to reverse the string using recursion without using extra memory, i.e inplace. I wrote thos code but am not sure why is it not working.
0debug
How can I define macros for the C++ intellisense engine? : <p>When using the <code>"Default"</code> intellisense engine, some of the symbols in my C++ project cannot be resolved. It turns out that it's because they are in headers where they are guarded by an <code>#ifdef</code> that depends on a macro passed to gcc with the <code>-D</code> flag by the makefile. How can I tell the intellisense engine about these defines so that it is able to compile those parts of the header? </p>
0debug
[C++][SDL2]Segmentation fault before function entry, no apparent cause, can not find answer elsewhere : So, first I'll note that I am unable of finding a cause for this after an hour of debugging and googling. I have a function, that is supposed to load a few test assets and blit them onto screen using SDL2. This function throws a segfault immediately before executing any commands, with no clear cause. Keep in mind that some of the variables in this function are globals. I am very sorry for not commenting my code to make it easy to read but I will try to do so in the future. Function contents: printf("DEBUG"); int menuSelect = 0; printf("declare"); SDL_Surface* bg = SDL_LoadBMP("menubg.bmp"); printf("bg load"); SDL_Surface* menu1 = TTF_RenderText_Solid(font,"HACKING PROGRAM",whiteclr); printf("title blip"); SDL_BlitSurface(bg,NULL,screen,NULL); printf("event"); SDL_Event* event; printf("menu2"); SDL_Surface* menu2 = TTF_RenderText_Solid(font,"Hack",whiteclr); printf("rect"); SDL_Rect menu2r = CreateRect(5,30,menu2->w,menu2->h); printf("free"); SDL_FreeSurface(menu2); SDL_FreeSurface(menu1); while(SDL_WaitEvent(event)) { switch(event->type) { case SDL_MOUSEBUTTONDOWN: if(event->motion.x > menu2r.x && event->motion.x < menu2r.x+menu2r.w && event->motion.y > menu2r.y && event->motion.y < menu2r.y+menu2r.h) { SDL_FreeSurface(bg); return 0; } break; case SDL_MOUSEMOTION: if(event->motion.x > menu2r.x && event->motion.x < menu2r.x+menu2r.w && event->motion.y > menu2r.y && event->motion.y < menu2r.y+menu2r.h) { menuSelect=1; } else { menuSelect=0; } break; } if(menuSelect==1) { menu2 = TTF_RenderText_Solid(font,"Hack",selectclr); } else { menu2 = TTF_RenderText_Solid(font,"Hack",selectclr); } } return 0; Please, before downvoting try to tell me what is wrong here. The "DEBUG" is never printed, and no I will no convert these into your superior std::cout.
0debug
How to make angular div using html & css : I am using html, css, and bootstrap. I have 2 horizontal divs: <div class="container-fluid"> ...div content... </div> <div class="container-fluid"> ...div content... </div> They each have a background image, and I would like them to meet up in a triangular manner like [this site](http://www.solarcity.com)
0debug
I wnat when I open the slide menu hamburger icon disappears : I have this html code : ~ <div id="side-menu" class="side-nav" > <a href="#" onclick="openSlideMenu()" > <div id="open-slide"> <svg width="30" height="30" style="margin-left:-10px;"> <path d="M0 ,5 30 ,5" stroke="#003145" stroke-width="5"/> <path d="M0 ,14 30 ,14" stroke="#003145" stroke-width="5"/> <path d="M0 ,23 30 ,23" stroke="#003145" stroke-width="5"/> </svg> </div> </a> <a href="#" class="btn-close" onclick="closeSlideMenu()">X </a> <div class="menu-bar">Menu</div> <ul> <li> <a href="http://webdesignleren.com/">Home</a> </li> <li> <a href="http://webdesignleren.com/?page_id=7">Onderhoud</a> </li> <li> <a href="http://webdesignleren.com/?page_id=9">Banden</a> </li> <li> <a href="http://webdesignleren.com/?page_id=11">APK</a> </li> <li><a href="http://webdesignleren.com/?page_id=13">Contact</a> </li> </ul> </div> ~ and I have this javascript code: ~ <script> function openSlideMenu() { document.getElementById('side-menu') .style.width='250px'; } function closeSlideMenu() { document.getElementById('side-menu') .style.width='0'; </script> ~ now when I open the slide menu I see the hamburger icon visible . my question is how I can make this hamburger icon invisible when the slide menu opens. as you see above I have 2 id .one is side-bar and the other is open-slide. which code I have to insert above in javascript or some condiitional code to make hamburger icon invisible when the slide menu opens. can you write to me all the javascript code to achieve my goal. my url is :<http://webdesignleren.com> so you can see exactly what I mean. thanks
0debug
Styled-component vs jss vs emotion for React : <p>I'm trying to understand the best choice (as a CTO) between</p> <ul> <li>jss</li> <li>emotion</li> <li>styled-component.</li> </ul> <p>I will try not to make the question "too wide" or "off-topic", because it's a very subjective topic. I'll try to answer (here) the question myself if no-one answers the whole, and I'll ask very closed questions :</p> <ul> <li>How the three of them can "compile to" (external css, <code>&lt;style&gt;</code> tag, <code>style=</code> attributes) ?</li> <li>How the three of them can integrate smoothly with CRA (without too much tweaks and without ejecting) ?</li> <li>What about the OpenSource POV (age, community, plugins, backing) ?</li> <li>What about the performance ?</li> </ul> <p>Please I don't want this question closed, so I don't want some code-style opinions, and I want to avoid subjectives POVs.</p>
0debug
dynamic semantic errors checking : <p>I read that dynamic semantic errors cannot be detected by the C compiler as semantic analysis phase catches only static semantic errors.</p> <p>Then which component of C compiler does the checking of dynamic semantic errors?</p>
0debug
static void gen_ld (CPUMIPSState *env, DisasContext *ctx, uint32_t opc, int rt, int base, int16_t offset) { const char *opn = "ld"; TCGv t0, t1; if (rt == 0 && env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) { MIPS_DEBUG("NOP"); return; } t0 = tcg_temp_new(); gen_base_offset_addr(ctx, t0, base, offset); switch (opc) { #if defined(TARGET_MIPS64) case OPC_LWU: tcg_gen_qemu_ld32u(t0, t0, ctx->mem_idx); gen_store_gpr(t0, rt); opn = "lwu"; break; case OPC_LD: tcg_gen_qemu_ld64(t0, t0, ctx->mem_idx); gen_store_gpr(t0, rt); opn = "ld"; break; case OPC_LLD: save_cpu_state(ctx, 1); op_ld_lld(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lld"; break; case OPC_LDL: save_cpu_state(ctx, 1); t1 = tcg_temp_new(); gen_load_gpr(t1, rt); gen_helper_1e2i(ldl, t1, t1, t0, ctx->mem_idx); gen_store_gpr(t1, rt); tcg_temp_free(t1); opn = "ldl"; break; case OPC_LDR: save_cpu_state(ctx, 1); t1 = tcg_temp_new(); gen_load_gpr(t1, rt); gen_helper_1e2i(ldr, t1, t1, t0, ctx->mem_idx); gen_store_gpr(t1, rt); tcg_temp_free(t1); opn = "ldr"; break; case OPC_LDPC: t1 = tcg_const_tl(pc_relative_pc(ctx)); gen_op_addr_add(ctx, t0, t0, t1); tcg_temp_free(t1); tcg_gen_qemu_ld64(t0, t0, ctx->mem_idx); gen_store_gpr(t0, rt); opn = "ldpc"; break; #endif case OPC_LWPC: t1 = tcg_const_tl(pc_relative_pc(ctx)); gen_op_addr_add(ctx, t0, t0, t1); tcg_temp_free(t1); tcg_gen_qemu_ld32s(t0, t0, ctx->mem_idx); gen_store_gpr(t0, rt); opn = "lwpc"; break; case OPC_LW: tcg_gen_qemu_ld32s(t0, t0, ctx->mem_idx); gen_store_gpr(t0, rt); opn = "lw"; break; case OPC_LH: tcg_gen_qemu_ld16s(t0, t0, ctx->mem_idx); gen_store_gpr(t0, rt); opn = "lh"; break; case OPC_LHU: tcg_gen_qemu_ld16u(t0, t0, ctx->mem_idx); gen_store_gpr(t0, rt); opn = "lhu"; break; case OPC_LB: tcg_gen_qemu_ld8s(t0, t0, ctx->mem_idx); gen_store_gpr(t0, rt); opn = "lb"; break; case OPC_LBU: tcg_gen_qemu_ld8u(t0, t0, ctx->mem_idx); gen_store_gpr(t0, rt); opn = "lbu"; break; case OPC_LWL: save_cpu_state(ctx, 1); t1 = tcg_temp_new(); gen_load_gpr(t1, rt); gen_helper_1e2i(lwl, t1, t1, t0, ctx->mem_idx); gen_store_gpr(t1, rt); tcg_temp_free(t1); opn = "lwl"; break; case OPC_LWR: save_cpu_state(ctx, 1); t1 = tcg_temp_new(); gen_load_gpr(t1, rt); gen_helper_1e2i(lwr, t1, t1, t0, ctx->mem_idx); gen_store_gpr(t1, rt); tcg_temp_free(t1); opn = "lwr"; break; case OPC_LL: save_cpu_state(ctx, 1); op_ld_ll(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "ll"; break; } (void)opn; MIPS_DEBUG("%s %s, %d(%s)", opn, regnames[rt], offset, regnames[base]); tcg_temp_free(t0); }
1threat
static void register_multipage(AddressSpaceDispatch *d, MemoryRegionSection *section) { target_phys_addr_t start_addr = section->offset_within_address_space; ram_addr_t size = section->size; target_phys_addr_t addr; uint16_t section_index = phys_section_add(section); assert(size); addr = start_addr; phys_page_set(d, addr >> TARGET_PAGE_BITS, size >> TARGET_PAGE_BITS, section_index); }
1threat
double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max) { char *tail; const char *error; double d = av_strtod(numstr, &tail); if (*tail) error= "Expected number for %s but found: %s\n"; else if (d < min || d > max) error= "The value for %s was %s which is not within %f - %f\n"; else if(type == OPT_INT64 && (int64_t)d != d) error= "Expected int64 for %s but found %s\n"; else return d; fprintf(stderr, error, context, numstr, min, max); exit(1); }
1threat
How to print the following with php[preferred] or javaScript? : <p>So i was asked the following question in an interview. I was able to print the whole xxx thing. but it was not diagonal like the below one. I think it meant to have spaces prints through a loop. Can Someone please help me with this.</p> <p>How to print the following using php or javascript?? Php would be preferred.</p> <pre><code> xx xxxx xxxxxx xxxxxxxx xxxxxxxxxx </code></pre> <p>what i was able to get was</p> <pre><code>xx xxxx xxxxxx xxxxxxxx xxxxxxxxxx </code></pre> <p>through php for loop.</p>
0debug
static void vma_delete(struct mm_struct *mm) { struct vm_area_struct *vma; while ((vma = vma_first(mm)) != NULL) { TAILQ_REMOVE(&mm->mm_mmap, vma, vma_link); qemu_free(vma); } qemu_free(mm); }
1threat
Gradle: No tests found : <p>When I am trying to run Android tests by executing:</p> <pre><code>./gradlew connectedDebugAndroidTest </code></pre> <p>The following error occurs:</p> <pre><code>com.android.builder.testing.ConnectedDevice &gt; No tests found.[devicename] FAILED No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations). :connectedDebugAndroidTest FAILED FAILURE: Build failed with an exception. </code></pre> <p>I <strong>have not made any changes</strong> to <code>build.gradle</code> or <code>gradle-wrapper.properties</code> files.</p> <p>The issue can't be solved by updating everything to the latest version (gradle, android plugin, build tools, etc.)</p> <p>All tests were previously successful. What could cause this mystic regression? Thanks.</p>
0debug
How to join a table by a column with tilde separated values in sql server : I'm trying to match the codes/descriptions from table_2 to each company in table_1. The company_type_string column contains multiple codes separated by '~' that are supposed to match with the codes in table_2. Table 1: company company_type_string A 1A~2B~3C B 1A~2B C 1A D 1A~2B~3C~4D Table 2: code description 1A Finance 2B Law 3C Security 4D Marketing Desired Outcome: company description A Finance A Law A Security B Finance B Law C Finance D Finance D Law D Security D Marketing I've tried using split_string with no success. Is there a way to make this join without altering the DB schema?
0debug
How to obtain a position of last non-zero element : <p>I've got a binary variable representing if event happened or not:</p> <pre><code>event &lt;- c(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0) </code></pre> <p>I need to obtain a variable that would indicate the time when the last event happened. The expected output would be:</p> <pre><code>last_event &lt;- c(0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 13, 13, 13, 13) </code></pre> <p>How can I obtain that with base R, tidyverse or any other way?</p>
0debug
How to Swap Two numbers using java script function with one parameter : My Requirement is I want to display this output when I gave a(0) the output should come 5 and when I gave a(5) the output should come 0. a(0) = 5 a(5) = 0 like this Hint: Using this function function A(num){} like this Please Help me how to do this I'm new in JS
0debug
Generating and accessing stored procedures using Entity framework core : <p>I am implementing Asp.Net core Web API , entity framework core, database first approach using Visual Studio 2017. I have managed to generate the context and class files based on an existing database. I need to access stored procedures using my context. In earlier version of entity framework it was simple by selecting the stored procedure objects in the wizard and generating an edmx that contains those objects. I could then access stored procedures via the complex type objects exposed by entity framework. How do I do a similar thing in entity framework core. An example would help ?</p>
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
PYTHON TKINTER entry float 8,2 : I have the need with tkinter python, to define an entry field that only accepts a float field with 8 integers and 2 decimals, perhaps with an error message if it does not respect the format 8.2. You can help me define a format for this field. Thanks in advance . Greetings . Paul
0debug
What is `export type` in Typescript? : <p>I notice the following syntax in Typescript.</p> <pre><code>export type feline = typeof cat; </code></pre> <p>As far as I know, <code>type</code> is not a <a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" rel="noreferrer">built-in basic type</a>, nor it is an interface or class. Actually it looks more like a syntax for aliasing, which however I can't find reference to verify my guess.</p> <p>So what does the above statement mean?</p>
0debug
void ff_put_h264_qpel4_mc20_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hz_4w_msa(src - 2, stride, dst, stride, 4); }
1threat
Best resources for learning Machine Learning for beginners : <p>I am keen in learning machining learning. I know programming, just want to know some useful sites which will help in understanding the concepts of machine learning with simple examples.</p>
0debug
void event_loop(void) { SDL_Event event; double incr, pos, frac; for(;;) { SDL_WaitEvent(&event); switch(event.type) { case SDL_KEYDOWN: switch(event.key.keysym.sym) { case SDLK_ESCAPE: case SDLK_q: do_exit(); break; case SDLK_f: toggle_full_screen(); break; case SDLK_p: case SDLK_SPACE: toggle_pause(); break; case SDLK_s: step_to_next_frame(); break; case SDLK_a: if (cur_stream) stream_cycle_channel(cur_stream, CODEC_TYPE_AUDIO); break; case SDLK_v: if (cur_stream) stream_cycle_channel(cur_stream, CODEC_TYPE_VIDEO); break; case SDLK_w: toggle_audio_display(); break; case SDLK_LEFT: incr = -10.0; goto do_seek; case SDLK_RIGHT: incr = 10.0; goto do_seek; case SDLK_UP: incr = 60.0; goto do_seek; case SDLK_DOWN: incr = -60.0; do_seek: if (cur_stream) { pos = get_master_clock(cur_stream); printf("%f %f %d %d %d %d\n", (float)pos, (float)incr, cur_stream->av_sync_type == AV_SYNC_VIDEO_MASTER, cur_stream->av_sync_type == AV_SYNC_AUDIO_MASTER, cur_stream->video_st, cur_stream->audio_st); pos += incr; stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE)); } break; default: break; } break; case SDL_MOUSEBUTTONDOWN: if (cur_stream) { int ns, hh, mm, ss; int tns, thh, tmm, tss; tns = cur_stream->ic->duration/1000000LL; thh = tns/3600; tmm = (tns%3600)/60; tss = (tns%60); frac = (double)event.button.x/(double)cur_stream->width; ns = frac*tns; hh = ns/3600; mm = (ns%3600)/60; ss = (ns%60); fprintf(stderr, "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d) \n", frac*100, hh, mm, ss, thh, tmm, tss); stream_seek(cur_stream, (int64_t)(cur_stream->ic->start_time+frac*cur_stream->ic->duration)); } break; case SDL_VIDEORESIZE: if (cur_stream) { screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0, SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL); cur_stream->width = event.resize.w; cur_stream->height = event.resize.h; } break; case SDL_QUIT: case FF_QUIT_EVENT: do_exit(); break; case FF_ALLOC_EVENT: alloc_picture(event.user.data1); break; case FF_REFRESH_EVENT: video_refresh_timer(event.user.data1); break; default: break; } } }
1threat
Suspend function 'callGetApi' should be called only from a coroutine or another suspend function : <p>I am calling suspended function from onCreate(...)</p> <pre><code>override fun onCreate(savedInstanceState: Bundle?) { ... ... callGetApi() } </code></pre> <p>and the suspended function is:-</p> <pre><code>suspend fun callGetApi() {....} </code></pre> <p>But the error shows up <em>Suspend function 'callGetApi' should be called only from a coroutine or another suspend function</em></p>
0debug
static inline void assert_fp_access_checked(DisasContext *s) { #ifdef CONFIG_DEBUG_TCG if (unlikely(!s->fp_access_checked || !s->cpacr_fpen)) { fprintf(stderr, "target-arm: FP access check missing for " "instruction 0x%08x\n", s->insn); abort(); } #endif }
1threat
static void fill_float_array(AVLFG *lfg, float *a, int len) { int i; double bmg[2], stddev = 10.0, mean = 0.0; for (i = 0; i < len; i += 2) { av_bmg_get(lfg, bmg); a[i] = bmg[0] * stddev + mean; a[i + 1] = bmg[1] * stddev + mean; } }
1threat
When I put 'wet' into the code it can't find the notepad document. The notepad document is called notepad : The code is not finding the notepad document, please help SEND_REPORT_TUPLE = ('wet', 'water', 'liquid') #make a list from the input input_list = answer.split(" ") #And then the use any function with comprehension list if any(e in SEND_REPORT_TUPLE for e in input_list): file = open('Notepad', 'r') print = file
0debug
can i use span tag for making html email templates? : This is html email templates. I don't know gmail,yahoo,hotmail,outlook is span tag and br-line-break is supported or not? Please give your valuable answare. thanks [enter image description here][1] [1]: https://i.stack.imgur.com/IR4Ls.png
0debug
static void iohandler_init(void) { if (!iohandler_ctx) { iohandler_ctx = aio_context_new(&error_abort); } }
1threat
MATLAB - Working with multiple multiple elements : 'Simple' question. Say I had y=sin(x) where **x is made up of multiple elements** say x=(1:1:5). Now my question: how do I **solve for all elements** in a variable z where all I know is z=cos(y)? Using just MATLAB code, please no algebraic manipulation. Thanks!
0debug
How to overwrite angular 2 material styles? : <p>I have this select in angular material:</p> <p><a href="https://i.stack.imgur.com/cAOsA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cAOsA.png" alt="enter image description here"></a></p> <p>Its code :</p> <pre><code>&lt;md-select placeholder="Descuentos y convenios" [(ngModel)]="passenger.discount"&gt; &lt;md-option [value]="null" [disabled]="true"&gt; Descuentos &lt;/md-option&gt; &lt;md-option *ngFor="let option of discounts" [value]="option"&gt; {{ option }} &lt;/md-option&gt; &lt;md-option [value]="null" [disabled]="true"&gt; Convenios &lt;/md-option&gt; &lt;md-option *ngFor="let option of agreements" [value]="option"&gt; {{ option }} &lt;/md-option&gt; &lt;/md-select&gt; </code></pre> <p>And I would like to have this styles in it:</p> <p><a href="https://i.stack.imgur.com/gwoDh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gwoDh.png" alt="enter image description here"></a></p> <p>I tried to put some classes over md-select and md-option, but not worked. I would like to have maybe just an example of how to put the background color or the border and that would give me an idea.</p> <p>Thank you in advance </p>
0debug
Edit text should allow text if a. alphabet +number b. alphabet +special charterer c. alphabet only in Android : I am trying to generate a regular expression in Android which can satisfy following conditions: Edit text can accept: 1. Alphabet only 2. Combination of Alphabet and number 3. Combination of Alphabet and special character Should not accept: a. Only Number b. Only Special character I tried alot but still, i didn't get any meaningful link. Please try to save my day.
0debug
Base R horizontal legend - with multiple rows : <p>I wish to create a horizontal legend with multiple rows using base R (not ggplot). There is an option for multiple columns but not multiple rows in legend(). Is there a way to do this? Example to play with below where the horizontal legend it too wide for the plot.</p> <pre><code>MyCol &lt;- topo.colors(20) barplot(rep(1,20), yaxt="n", col=MyCol) x &lt;- 1:20 MyLab &lt;- paste("Zone",x) legend("bottom",MyLab,fill=MyCol,horiz=T) </code></pre>
0debug
Kotlin Map with non null values : <p>Let say that I have a Map for translating a letter of a playing card to an integer </p> <pre><code> val rank = mapOf("J" to 11, "Q" to 12, "K" to 13, "A" to 14) </code></pre> <p>When working with the map it seems that I always have to make a null safety check even though the Map and Pair are immutable:</p> <pre><code>val difference = rank["Q"]!! - rank["K"]!! </code></pre> <p>I guess this comes from that generic types have Any? supertype. Why can't this be resolved at compile time when both Map and Pair are immutable?</p>
0debug
What exactly is the timeout value in React CSS Transition Group doing? : <p>I've been reading the official docs for <a href="https://facebook.github.io/react/docs/animation.html" rel="noreferrer">React Animations (React CSS Transition Group)</a>, but I'm a little unclear as to what the timeout values are used for - especially when I'm setting transitions within my CSS. Are the values a delay, duration of the animation, or how long that class is applied before being removed? And how do they relate to the duration of transitions set in my CSS? </p> <p>For example, if I were to have a simple fade in/out when the component enters/leaves, I'd also set the opacity and transition duration within my CSS. Does the component then animated based on the timing passed in this value or the duration set within my CSS?</p> <p>Here's an example provided by the official docs:</p> <p><strong>My React Component</strong></p> <pre><code>&lt;ReactCSSTransitionGroup transitionName="example" transitionEnterTimeout={500} transitionLeaveTimeout={300} &gt; {items} &lt;/ReactCSSTransitionGroup&gt; </code></pre> <p><strong>My .css file</strong></p> <pre><code>.example-enter { opacity: 0.01; } .example-enter.example-enter-active { opacity: 1; transition: opacity 500ms ease-in; } .example-leave { opacity: 1; } .example-leave.example-leave-active { opacity: 0.01; transition: opacity 300ms ease-in; } </code></pre> <p>Thanks!</p>
0debug
how to present a frequency table from Rstudio in MS Word nicely : So, I copied this frequency table from R in MS Word: I A I B II A II B III A III A III B IV 128 73 61 59 1 166 86 463 How can I make it look nicer in a MS Word document? No Latex please, it should be written in an MS document. Thanks in advance!
0debug
static void kvm_supported_msrs(CPUState *env) { static int kvm_supported_msrs; int ret; if (kvm_supported_msrs == 0) { struct kvm_msr_list msr_list, *kvm_msr_list; kvm_supported_msrs = -1; msr_list.nmsrs = 0; ret = kvm_ioctl(env->kvm_state, KVM_GET_MSR_INDEX_LIST, &msr_list); if (ret < 0 && ret != -E2BIG) { return; } kvm_msr_list = qemu_mallocz(MAX(1024, sizeof(msr_list) + msr_list.nmsrs * sizeof(msr_list.indices[0]))); kvm_msr_list->nmsrs = msr_list.nmsrs; ret = kvm_ioctl(env->kvm_state, KVM_GET_MSR_INDEX_LIST, kvm_msr_list); if (ret >= 0) { int i; for (i = 0; i < kvm_msr_list->nmsrs; i++) { if (kvm_msr_list->indices[i] == MSR_STAR) { has_msr_star = 1; continue; } if (kvm_msr_list->indices[i] == MSR_VM_HSAVE_PA) { has_msr_hsave_pa = 1; continue; } } } free(kvm_msr_list); } return; }
1threat
What should I do in order to retain the text view values in Android? : I have two text views on my home page of the app.And I have two buttons which launches new activities. And I am taking the values of text view from the two respective activities and then using intent passing the data back to the main activity .But when I do so only the current text view value is displayed.What to do to display both at the same time?
0debug
Python - Breaking a Word into a given list of "syllables" : I'm trying to write a function in Python that will return True or False based on string matching to see if a given list of "syllables" mixed and matched can form a word. The two inputs would be the word and the list of syllables. Some examples: **Inputs**: “hello” , [”hel”, ”hol”, ”llo”, ”he”] **Output**: True , **Inputs** ”world” , [”woo”, ”wor”, ”rld”, ”or”] **Output**False
0debug
void hmp_info_memdev(Monitor *mon, const QDict *qdict) { Error *err = NULL; MemdevList *memdev_list = qmp_query_memdev(&err); MemdevList *m = memdev_list; StringOutputVisitor *ov; char *str; int i = 0; while (m) { ov = string_output_visitor_new(false); visit_type_uint16List(string_output_get_visitor(ov), NULL, &m->value->host_nodes, NULL); monitor_printf(mon, "memory backend: %d\n", i); monitor_printf(mon, " size: %" PRId64 "\n", m->value->size); monitor_printf(mon, " merge: %s\n", m->value->merge ? "true" : "false"); monitor_printf(mon, " dump: %s\n", m->value->dump ? "true" : "false"); monitor_printf(mon, " prealloc: %s\n", m->value->prealloc ? "true" : "false"); monitor_printf(mon, " policy: %s\n", HostMemPolicy_lookup[m->value->policy]); str = string_output_get_string(ov); monitor_printf(mon, " host nodes: %s\n", str); g_free(str); string_output_visitor_cleanup(ov); m = m->next; i++; } monitor_printf(mon, "\n"); qapi_free_MemdevList(memdev_list); }
1threat
C# Use textbox value in another cs file : I'd like to add a WinForm into my Console App: namespace ExchangeNativeDemo.Window { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void textBox1_TextChanged(object sender, EventArgs e) { } } } I would like to pass textbox1 value to Program.cs, like: var emailaddress = textbox1.value In program.cs: using ExchangeNativeDemo.Window; namespace ExchangeNativeDemo class Program { static void Main(string[] args) { But I got the error: "is inaccessible due to its protection level". What I missed? Thanks!
0debug
static inline int is_sector_in_chunk(BDRVDMGState* s, uint32_t chunk_num,int sector_num) { if(chunk_num>=s->n_chunks || s->sectors[chunk_num]>sector_num || s->sectors[chunk_num]+s->sectorcounts[chunk_num]<=sector_num) return 0; else return -1; }
1threat
static int vc1_init_common(VC1Context *v) { static int done = 0; int i = 0; static VLC_TYPE vlc_table[32372][2]; v->hrd_rate = v->hrd_buffer = NULL; if (!done) { INIT_VLC_STATIC(&ff_vc1_bfraction_vlc, VC1_BFRACTION_VLC_BITS, 23, ff_vc1_bfraction_bits, 1, 1, ff_vc1_bfraction_codes, 1, 1, 1 << VC1_BFRACTION_VLC_BITS); INIT_VLC_STATIC(&ff_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 4, ff_vc1_norm2_bits, 1, 1, ff_vc1_norm2_codes, 1, 1, 1 << VC1_NORM2_VLC_BITS); INIT_VLC_STATIC(&ff_vc1_norm6_vlc, VC1_NORM6_VLC_BITS, 64, ff_vc1_norm6_bits, 1, 1, ff_vc1_norm6_codes, 2, 2, 556); INIT_VLC_STATIC(&ff_vc1_imode_vlc, VC1_IMODE_VLC_BITS, 7, ff_vc1_imode_bits, 1, 1, ff_vc1_imode_codes, 1, 1, 1 << VC1_IMODE_VLC_BITS); for (i = 0; i < 3; i++) { ff_vc1_ttmb_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 0]]; ff_vc1_ttmb_vlc[i].table_allocated = vlc_offs[i * 3 + 1] - vlc_offs[i * 3 + 0]; init_vlc(&ff_vc1_ttmb_vlc[i], VC1_TTMB_VLC_BITS, 16, ff_vc1_ttmb_bits[i], 1, 1, ff_vc1_ttmb_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); ff_vc1_ttblk_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 1]]; ff_vc1_ttblk_vlc[i].table_allocated = vlc_offs[i * 3 + 2] - vlc_offs[i * 3 + 1]; init_vlc(&ff_vc1_ttblk_vlc[i], VC1_TTBLK_VLC_BITS, 8, ff_vc1_ttblk_bits[i], 1, 1, ff_vc1_ttblk_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); ff_vc1_subblkpat_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 2]]; ff_vc1_subblkpat_vlc[i].table_allocated = vlc_offs[i * 3 + 3] - vlc_offs[i * 3 + 2]; init_vlc(&ff_vc1_subblkpat_vlc[i], VC1_SUBBLKPAT_VLC_BITS, 15, ff_vc1_subblkpat_bits[i], 1, 1, ff_vc1_subblkpat_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); } for (i = 0; i < 4; i++) { ff_vc1_4mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 9]]; ff_vc1_4mv_block_pattern_vlc[i].table_allocated = vlc_offs[i * 3 + 10] - vlc_offs[i * 3 + 9]; init_vlc(&ff_vc1_4mv_block_pattern_vlc[i], VC1_4MV_BLOCK_PATTERN_VLC_BITS, 16, ff_vc1_4mv_block_pattern_bits[i], 1, 1, ff_vc1_4mv_block_pattern_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); ff_vc1_cbpcy_p_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 10]]; ff_vc1_cbpcy_p_vlc[i].table_allocated = vlc_offs[i * 3 + 11] - vlc_offs[i * 3 + 10]; init_vlc(&ff_vc1_cbpcy_p_vlc[i], VC1_CBPCY_P_VLC_BITS, 64, ff_vc1_cbpcy_p_bits[i], 1, 1, ff_vc1_cbpcy_p_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); ff_vc1_mv_diff_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 11]]; ff_vc1_mv_diff_vlc[i].table_allocated = vlc_offs[i * 3 + 12] - vlc_offs[i * 3 + 11]; init_vlc(&ff_vc1_mv_diff_vlc[i], VC1_MV_DIFF_VLC_BITS, 73, ff_vc1_mv_diff_bits[i], 1, 1, ff_vc1_mv_diff_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); } for (i = 0; i < 8; i++) { ff_vc1_ac_coeff_table[i].table = &vlc_table[vlc_offs[i * 2 + 21]]; ff_vc1_ac_coeff_table[i].table_allocated = vlc_offs[i * 2 + 22] - vlc_offs[i * 2 + 21]; init_vlc(&ff_vc1_ac_coeff_table[i], AC_VLC_BITS, vc1_ac_sizes[i], &vc1_ac_tables[i][0][1], 8, 4, &vc1_ac_tables[i][0][0], 8, 4, INIT_VLC_USE_NEW_STATIC); ff_vc1_2ref_mvdata_vlc[i].table = &vlc_table[vlc_offs[i * 2 + 22]]; ff_vc1_2ref_mvdata_vlc[i].table_allocated = vlc_offs[i * 2 + 23] - vlc_offs[i * 2 + 22]; init_vlc(&ff_vc1_2ref_mvdata_vlc[i], VC1_2REF_MVDATA_VLC_BITS, 126, ff_vc1_2ref_mvdata_bits[i], 1, 1, ff_vc1_2ref_mvdata_codes[i], 4, 4, INIT_VLC_USE_NEW_STATIC); } for (i = 0; i < 4; i++) { ff_vc1_intfr_4mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 37]]; ff_vc1_intfr_4mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 38] - vlc_offs[i * 3 + 37]; init_vlc(&ff_vc1_intfr_4mv_mbmode_vlc[i], VC1_INTFR_4MV_MBMODE_VLC_BITS, 15, ff_vc1_intfr_4mv_mbmode_bits[i], 1, 1, ff_vc1_intfr_4mv_mbmode_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); ff_vc1_intfr_non4mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 38]]; ff_vc1_intfr_non4mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 39] - vlc_offs[i * 3 + 38]; init_vlc(&ff_vc1_intfr_non4mv_mbmode_vlc[i], VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 9, ff_vc1_intfr_non4mv_mbmode_bits[i], 1, 1, ff_vc1_intfr_non4mv_mbmode_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); ff_vc1_1ref_mvdata_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 39]]; ff_vc1_1ref_mvdata_vlc[i].table_allocated = vlc_offs[i * 3 + 40] - vlc_offs[i * 3 + 39]; init_vlc(&ff_vc1_1ref_mvdata_vlc[i], VC1_1REF_MVDATA_VLC_BITS, 72, ff_vc1_1ref_mvdata_bits[i], 1, 1, ff_vc1_1ref_mvdata_codes[i], 4, 4, INIT_VLC_USE_NEW_STATIC); } for (i = 0; i < 4; i++) { ff_vc1_2mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i + 49]]; ff_vc1_2mv_block_pattern_vlc[i].table_allocated = vlc_offs[i + 50] - vlc_offs[i + 49]; init_vlc(&ff_vc1_2mv_block_pattern_vlc[i], VC1_2MV_BLOCK_PATTERN_VLC_BITS, 4, ff_vc1_2mv_block_pattern_bits[i], 1, 1, ff_vc1_2mv_block_pattern_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); } for (i = 0; i < 8; i++) { ff_vc1_icbpcy_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 53]]; ff_vc1_icbpcy_vlc[i].table_allocated = vlc_offs[i * 3 + 54] - vlc_offs[i * 3 + 53]; init_vlc(&ff_vc1_icbpcy_vlc[i], VC1_ICBPCY_VLC_BITS, 63, ff_vc1_icbpcy_p_bits[i], 1, 1, ff_vc1_icbpcy_p_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); ff_vc1_if_mmv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 54]]; ff_vc1_if_mmv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 55] - vlc_offs[i * 3 + 54]; init_vlc(&ff_vc1_if_mmv_mbmode_vlc[i], VC1_IF_MMV_MBMODE_VLC_BITS, 8, ff_vc1_if_mmv_mbmode_bits[i], 1, 1, ff_vc1_if_mmv_mbmode_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); ff_vc1_if_1mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 55]]; ff_vc1_if_1mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 56] - vlc_offs[i * 3 + 55]; init_vlc(&ff_vc1_if_1mv_mbmode_vlc[i], VC1_IF_1MV_MBMODE_VLC_BITS, 6, ff_vc1_if_1mv_mbmode_bits[i], 1, 1, ff_vc1_if_1mv_mbmode_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); } done = 1; } v->pq = -1; v->mvrange = 0; return 0; }
1threat
static uint8_t usb_linux_get_alt_setting(USBHostDevice *s, uint8_t configuration, uint8_t interface) { char device_name[64], line[1024]; int alt_setting; sprintf(device_name, "%d-%s:%d.%d", s->bus_num, s->port, (int)configuration, (int)interface); if (!usb_host_read_file(line, sizeof(line), "bAlternateSetting", device_name)) { return 0; } if (sscanf(line, "%d", &alt_setting) != 1) { return 0; } return alt_setting; }
1threat
.sqlite file no more available in documents folder - Swift 5 : <p>The sqlite file related to coredata is no more available in the documents directory.</p> <p>Found it is present inside <code>/Library/Application Support</code></p> <p>How to search for that url in proper way?</p>
0debug
C# Win Forms game. Ground Collision : I have tried searching for an answer but i have not found anything. I'm making this 2d game in c# where i want the player to be pulled down by the force which increases by gravity each time the function in called (inside a while loop). For some reason the code will not stop when the for loop is broken. private void PhysicsLoop() { NowX = Convert.ToInt32(Math.Floor(Convert.ToDecimal(Player.x / 32))); NowY = Convert.ToInt32(Math.Floor(Convert.ToDecimal(Player.y / 32))); if (Block[NowX,NowY + 2].Collides == false) { Falling = true; } if (Falling == true) { force += Gravity; for (int i = 0; i <= force; i++) { if (Block[NowX, NowY + 2].Collides == true) { Falling = false; break; } else { Player.y += 1; } } } else { } } Also, block is a 2d array of a class, player is a class which just holds an x, y ,width and height value. Thanks for helping in advance!
0debug
int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *data_size, UINT8 *buf, int buf_size) { MpegEncContext *s = avctx->priv_data; int ret,i; AVFrame *pict = data; float new_aspect; #ifdef PRINT_FRAME_TIME uint64_t time= rdtsc(); #endif #ifdef DEBUG printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); #endif s->flags= avctx->flags; *data_size = 0; if (buf_size == 0) { return 0; } if(s->flags&CODEC_FLAG_TRUNCATED){ int next; ParseContext *pc= &s->parse_context; pc->last_index= pc->index; if(s->codec_id==CODEC_ID_MPEG4){ next= mpeg4_find_frame_end(s, buf, buf_size); }else{ fprintf(stderr, "this codec doesnt support truncated bitstreams\n"); return -1; } if(next==-1){ if(buf_size + FF_INPUT_BUFFER_PADDING_SIZE + pc->index > pc->buffer_size){ pc->buffer_size= buf_size + pc->index + 10*1024; pc->buffer= realloc(pc->buffer, pc->buffer_size); } memcpy(&pc->buffer[pc->index], buf, buf_size); pc->index += buf_size; return buf_size; } if(pc->index){ if(next + FF_INPUT_BUFFER_PADDING_SIZE + pc->index > pc->buffer_size){ pc->buffer_size= next + pc->index + 10*1024; pc->buffer= realloc(pc->buffer, pc->buffer_size); } memcpy(&pc->buffer[pc->index], buf, next + FF_INPUT_BUFFER_PADDING_SIZE ); pc->index = 0; buf= pc->buffer; buf_size= pc->last_index + next; } } retry: if(s->bitstream_buffer_size && buf_size<20){ init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size); }else init_get_bits(&s->gb, buf, buf_size); s->bitstream_buffer_size=0; if (!s->context_initialized) { if (MPV_common_init(s) < 0) return -1; } if (s->msmpeg4_version==5) { ret= ff_wmv2_decode_picture_header(s); } else if (s->msmpeg4_version) { ret = msmpeg4_decode_picture_header(s); } else if (s->h263_pred) { if(s->avctx->extradata_size && s->picture_number==0){ GetBitContext gb; init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size); ret = ff_mpeg4_decode_picture_header(s, &gb); } ret = ff_mpeg4_decode_picture_header(s, &s->gb); if(s->flags& CODEC_FLAG_LOW_DELAY) s->low_delay=1; } else if (s->h263_intel) { ret = intel_h263_decode_picture_header(s); } else { ret = h263_decode_picture_header(s); } avctx->has_b_frames= !s->low_delay; if(s->workaround_bugs&FF_BUG_AUTODETECT){ if(s->padding_bug_score > -2 && !s->data_partitioning) s->workaround_bugs |= FF_BUG_NO_PADDING; else s->workaround_bugs &= ~FF_BUG_NO_PADDING; if(s->avctx->fourcc == ff_get_fourcc("XVIX")) s->workaround_bugs|= FF_BUG_XVID_ILACE; #if 0 if(s->avctx->fourcc == ff_get_fourcc("MP4S")) s->workaround_bugs|= FF_BUG_AC_VLC; if(s->avctx->fourcc == ff_get_fourcc("M4S2")) s->workaround_bugs|= FF_BUG_AC_VLC; #endif if(s->avctx->fourcc == ff_get_fourcc("UMP4")){ s->workaround_bugs|= FF_BUG_UMP4; s->workaround_bugs|= FF_BUG_AC_VLC; } if(s->divx_version){ s->workaround_bugs|= FF_BUG_QPEL_CHROMA; } if(s->avctx->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0) s->workaround_bugs|= FF_BUG_QPEL_CHROMA; if(s->avctx->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0) s->padding_bug_score= 256*256*256*64; if(s->xvid_build && s->xvid_build<=3) s->padding_bug_score= 256*256*256*64; if(s->xvid_build && s->xvid_build<=1) s->workaround_bugs|= FF_BUG_QPEL_CHROMA; #define SET_QPEL_FUNC(postfix1, postfix2) \ s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\ s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\ s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2; if(s->lavc_build && s->lavc_build<4653) s->workaround_bugs|= FF_BUG_STD_QPEL; #if 0 if(s->divx_version==500) s->workaround_bugs|= FF_BUG_NO_PADDING; if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==0 && s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0) s->workaround_bugs|= FF_BUG_NO_PADDING; if(s->lavc_build && s->lavc_build<4609) s->workaround_bugs|= FF_BUG_NO_PADDING; #endif } if(s->workaround_bugs& FF_BUG_STD_QPEL){ SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c) } #if 0 { static FILE *f=NULL; if(!f) f=fopen("rate_qp_cplx.txt", "w"); fprintf(f, "%d %d %f\n", buf_size, s->qscale, buf_size*(double)s->qscale); } #endif if(s->aspected_height) new_aspect= s->aspected_width*s->width / (float)(s->height*s->aspected_height); else new_aspect=0; if ( s->width != avctx->width || s->height != avctx->height || ABS(new_aspect - avctx->aspect_ratio) > 0.001) { MPV_common_end(s); s->context_initialized=0; } if (!s->context_initialized) { avctx->width = s->width; avctx->height = s->height; avctx->aspect_ratio= new_aspect; goto retry; } if((s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P)) s->gob_index = ff_h263_get_gob_height(s); if(ret==FRAME_SKIPED) return get_consumed_bytes(s, buf_size); if (ret < 0){ fprintf(stderr, "header damaged\n"); return -1; } s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == I_TYPE; if(s->last_picture.data[0]==NULL && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); if(avctx->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size); if(s->next_p_frame_damaged){ if(s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); else s->next_p_frame_damaged=0; } if(MPV_frame_start(s, avctx) < 0) return -1; #ifdef DEBUG printf("qscale=%d\n", s->qscale); #endif if(s->error_resilience) memset(s->error_status_table, MV_ERROR|AC_ERROR|DC_ERROR|VP_START|AC_END|DC_END|MV_END, s->mb_num*sizeof(UINT8)); s->block_wrap[0]= s->block_wrap[1]= s->block_wrap[2]= s->block_wrap[3]= s->mb_width*2 + 2; s->block_wrap[4]= s->block_wrap[5]= s->mb_width + 2; s->mb_x=0; s->mb_y=0; decode_slice(s); s->error_status_table[0]|= VP_START; while(s->mb_y<s->mb_height && s->gb.size*8 - get_bits_count(&s->gb)>16){ if(s->msmpeg4_version){ if(s->mb_x!=0 || (s->mb_y%s->slice_height)!=0) break; }else{ if(ff_h263_resync(s)<0) break; } if(s->msmpeg4_version<4 && s->h263_pred) ff_mpeg4_clean_buffers(s); decode_slice(s); s->error_status_table[s->resync_mb_x + s->resync_mb_y*s->mb_width]|= VP_START; } if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE) if(msmpeg4_decode_ext_header(s, buf_size) < 0){ s->error_status_table[s->mb_num-1]= AC_ERROR|DC_ERROR|MV_ERROR; } if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_version>=500){ int current_pos= get_bits_count(&s->gb)>>3; if( buf_size - current_pos > 5 && buf_size - current_pos < BITSTREAM_BUFFER_SIZE){ int i; int startcode_found=0; for(i=current_pos; i<buf_size-3; i++){ if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){ startcode_found=1; break; } } if(startcode_found){ memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos); s->bitstream_buffer_size= buf_size - current_pos; } } } if(s->error_resilience){ int error=0, num_end_markers=0; for(i=0; i<s->mb_num; i++){ int status= s->error_status_table[i]; #if 0 if(i%s->mb_width == 0) printf("\n"); printf("%2X ", status); #endif if(status==0) continue; if(status&(DC_ERROR|AC_ERROR|MV_ERROR)) error=1; if(status&VP_START){ if(num_end_markers) error=1; num_end_markers=3; } if(status&AC_END) num_end_markers--; if(status&DC_END) num_end_markers--; if(status&MV_END) num_end_markers--; } if(num_end_markers || error){ fprintf(stderr, "concealing errors\n"); ff_error_resilience(s); } } MPV_frame_end(s); if((avctx->debug&FF_DEBUG_VIS_MV) && s->last_picture.data[0]){ const int shift= 1 + s->quarter_sample; int mb_y; uint8_t *ptr= s->last_picture.data[0]; s->low_delay=0; for(mb_y=0; mb_y<s->mb_height; mb_y++){ int mb_x; for(mb_x=0; mb_x<s->mb_width; mb_x++){ const int mb_index= mb_x + mb_y*s->mb_width; if(s->co_located_type_table[mb_index] == MV_TYPE_8X8){ int i; for(i=0; i<4; i++){ int sx= mb_x*16 + 4 + 8*(i&1); int sy= mb_y*16 + 4 + 8*(i>>1); int xy= 1 + mb_x*2 + (i&1) + (mb_y*2 + 1 + (i>>1))*(s->mb_width*2 + 2); int mx= (s->motion_val[xy][0]>>shift) + sx; int my= (s->motion_val[xy][1]>>shift) + sy; draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); } }else{ int sx= mb_x*16 + 8; int sy= mb_y*16 + 8; int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); int mx= (s->motion_val[xy][0]>>shift) + sx; int my= (s->motion_val[xy][1]>>shift) + sy; draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); } s->mbskip_table[mb_index]=0; } } } if(s->pict_type==B_TYPE || s->low_delay){ *pict= *(AVFrame*)&s->current_picture; } else { *pict= *(AVFrame*)&s->last_picture; } if(avctx->debug&FF_DEBUG_QP){ int8_t *qtab= pict->qscale_table; int x,y; for(y=0; y<s->mb_height; y++){ for(x=0; x<s->mb_width; x++){ printf("%2d ", qtab[x + y*s->mb_width]); } printf("\n"); } printf("\n"); } avctx->frame_number = s->picture_number - 1; if(s->last_picture.data[0] || s->low_delay) *data_size = sizeof(AVFrame); #ifdef PRINT_FRAME_TIME printf("%Ld\n", rdtsc()-time); #endif return get_consumed_bytes(s, buf_size); }
1threat
PHP loop trough JSON repsonce and insert into MYSQL : for a school project i want to loop trough a json responce and insert the data into a mysql database. The json responce looks like this: ID 123456 data 0 updated_at 1234567890123 total last avg_daily_volume last_90d 12 last_30d 12 last_7d 12 last_24h 12 safe_ts last_90d 12 last_30d 12 last_7d 12 last_24h 12 min 12 hash_name "TEST" name "TEST" nameID "123456789" 1 updated_at 1234567890123 total last avg_daily_volume last_90d 12 last_30d 12 last_7d 12 last_24h 12 safe_ts last_90d 12 last_30d 12 last_7d 12 last_24h 12 safe 12 mean 12 max 12 avg 12 min 12 latest 12 hash_name "TEST" name "TEST" nameID "234567890" 3 ........ Every array should be a own row in the mysql database. I'm not sure how to do this since every array has a custom name (0, 1, 2, ...).
0debug
How 2 fragments communicate each other inside an activity : <p>Consider an activity we can call as a base activity. Two fragments are added to this base activity , call as fragmentOne and fragentTwo.How can fragmentOne can communicate with fragentTwo and vice versa .</p>
0debug
static void apply_mdct(AC3EncodeContext *s) { int blk, ch; for (ch = 0; ch < s->channels; ch++) { for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { AC3Block *block = &s->blocks[blk]; const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE]; apply_window(&s->dsp, s->windowed_samples, input_samples, s->mdct.window, AC3_WINDOW_SIZE); block->coeff_shift[ch] = normalize_samples(s); mdct512(&s->mdct, block->mdct_coef[ch], s->windowed_samples); } } }
1threat
static void outport_write(KBDState *s, uint32_t val) { DPRINTF("kbd: write outport=0x%02x\n", val); s->outport = val; if (s->a20_out) { qemu_set_irq(*s->a20_out, (val >> 1) & 1); } if (!(val & 1)) { qemu_system_reset_request(); } }
1threat
void qmp_guest_file_close(int64_t handle, Error **err) { GuestFileHandle *gfh = guest_file_handle_find(handle, err); int ret; slog("guest-file-close called, handle: %ld", handle); if (!gfh) { return; } ret = fclose(gfh->fh); if (ret == -1) { error_set(err, QERR_QGA_COMMAND_FAILED, "fclose() failed"); return; } QTAILQ_REMOVE(&guest_file_state.filehandles, gfh, next); g_free(gfh); }
1threat
static uint64_t kvm_apic_mem_read(void *opaque, target_phys_addr_t addr, unsigned size) { return ~(uint64_t)0; }
1threat
void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, AcpiCpuHotplug *gpe_cpu, uint16_t base) { CPUState *cpu; CPU_FOREACH(cpu) { acpi_set_cpu_present_bit(gpe_cpu, cpu, &error_abort); } memory_region_init_io(&gpe_cpu->io, owner, &AcpiCpuHotplug_ops, gpe_cpu, "acpi-cpu-hotplug", ACPI_GPE_PROC_LEN); memory_region_add_subregion(parent, base, &gpe_cpu->io); gpe_cpu->device = owner; }
1threat
specify sysctl values using docker-compose : <p>I am trying to set a few sysctl values.<br> Basically the following </p> <pre><code>sysctl -w \ net.ipv4.tcp_keepalive_time=300 \ net.ipv4.tcp_keepalive_intvl=60 \ net.ipv4.tcp_keepalive_probes=9 </code></pre> <p>in a docker container.<br> When log into to the container directly and execute the command, I get the following error</p> <pre><code>sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_time: No such file or directory sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_intvl: No such file or directory sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_probes: No such file or directory </code></pre> <p>Then I found out the --sysctl option in <code>docker run</code> in <a href="https://docs.docker.com/engine/reference/commandline/run/" rel="noreferrer">here</a> But I did not find the equivalent option via docker-compose. I have few services that start by default so using docker run instead of docker-compose is not an option for me.</p> <p>Anyone knows of a way to supply --sysctl options to the container via compose?</p>
0debug
static void nvme_rw_cb(void *opaque, int ret) { NvmeRequest *req = opaque; NvmeSQueue *sq = req->sq; NvmeCtrl *n = sq->ctrl; NvmeCQueue *cq = n->cq[sq->cqid]; block_acct_done(blk_get_stats(n->conf.blk), &req->acct); if (!ret) { req->status = NVME_SUCCESS; } else { req->status = NVME_INTERNAL_DEV_ERROR; } if (req->has_sg) { qemu_sglist_destroy(&req->qsg); } nvme_enqueue_req_completion(cq, req); }
1threat
bool trace_init_backends(void) { #ifdef CONFIG_TRACE_SIMPLE if (!st_init()) { fprintf(stderr, "failed to initialize simple tracing backend.\n"); return false; } #ifdef CONFIG_TRACE_FTRACE if (!ftrace_init()) { fprintf(stderr, "failed to initialize ftrace backend.\n"); return false; } return true; }
1threat
static const char *io_port_to_string(uint32_t io_port) { if (io_port >= QXL_IO_RANGE_SIZE) { return "out of range"; } static const char *io_port_to_string[QXL_IO_RANGE_SIZE + 1] = { [QXL_IO_NOTIFY_CMD] = "QXL_IO_NOTIFY_CMD", [QXL_IO_NOTIFY_CURSOR] = "QXL_IO_NOTIFY_CURSOR", [QXL_IO_UPDATE_AREA] = "QXL_IO_UPDATE_AREA", [QXL_IO_UPDATE_IRQ] = "QXL_IO_UPDATE_IRQ", [QXL_IO_NOTIFY_OOM] = "QXL_IO_NOTIFY_OOM", [QXL_IO_RESET] = "QXL_IO_RESET", [QXL_IO_SET_MODE] = "QXL_IO_SET_MODE", [QXL_IO_LOG] = "QXL_IO_LOG", [QXL_IO_MEMSLOT_ADD] = "QXL_IO_MEMSLOT_ADD", [QXL_IO_MEMSLOT_DEL] = "QXL_IO_MEMSLOT_DEL", [QXL_IO_DETACH_PRIMARY] = "QXL_IO_DETACH_PRIMARY", [QXL_IO_ATTACH_PRIMARY] = "QXL_IO_ATTACH_PRIMARY", [QXL_IO_CREATE_PRIMARY] = "QXL_IO_CREATE_PRIMARY", [QXL_IO_DESTROY_PRIMARY] = "QXL_IO_DESTROY_PRIMARY", [QXL_IO_DESTROY_SURFACE_WAIT] = "QXL_IO_DESTROY_SURFACE_WAIT", [QXL_IO_DESTROY_ALL_SURFACES] = "QXL_IO_DESTROY_ALL_SURFACES", #if SPICE_INTERFACE_QXL_MINOR >= 1 [QXL_IO_UPDATE_AREA_ASYNC] = "QXL_IO_UPDATE_AREA_ASYNC", [QXL_IO_MEMSLOT_ADD_ASYNC] = "QXL_IO_MEMSLOT_ADD_ASYNC", [QXL_IO_CREATE_PRIMARY_ASYNC] = "QXL_IO_CREATE_PRIMARY_ASYNC", [QXL_IO_DESTROY_PRIMARY_ASYNC] = "QXL_IO_DESTROY_PRIMARY_ASYNC", [QXL_IO_DESTROY_SURFACE_ASYNC] = "QXL_IO_DESTROY_SURFACE_ASYNC", [QXL_IO_DESTROY_ALL_SURFACES_ASYNC] = "QXL_IO_DESTROY_ALL_SURFACES_ASYNC", [QXL_IO_FLUSH_SURFACES_ASYNC] = "QXL_IO_FLUSH_SURFACES_ASYNC", [QXL_IO_FLUSH_RELEASE] = "QXL_IO_FLUSH_RELEASE", #endif }; return io_port_to_string[io_port]; }
1threat
PHP + MySQL/MariaDB + avoid race condition : <p>I've developed a web application using Apache, MySQL and PHP.</p> <p>This web app allows multiple users' to login to the application. Then, through the application, they have access to the Database.</p> <p>Since race conditions may apply when two or more users try to SELECT/UPDATE/DELETE the same information (in my case a row of a Table), I am searching for the best way to avoid such race conditions.</p> <p>I've tried using mysqli with setting autocommit to OFF and using SELECT .... FOR UPDATE, but this fails to work as -to my understanding- with PHP, each transaction commits automatically and each connection to the db is being auto released when the PHP -->html page is provided/loaded for the user.</p> <p>After reading some posts, there seem to be two possible solutions for my problem :</p> <ol> <li><p>Use PDO. To my understanding PDO creates connections to the DB which are not released when the html page loads. Special precautions should be taken though as locks may remain if e.g. the user quits the page and the PDO connection has not been released...</p></li> <li><p>Add a "locked" column in the corresponding table to flag locked rows. So e.g. when an UPDATE transaction may only be performed if the corresponding user has locked the row for editing. The other users shall not be allowed to modify.</p></li> </ol> <p>The main issue I may have with PDO is that I have to modify the PHP code in order to replace mysqli with PDO, where applicable.</p> <p>The issue with the scenario 2 is that I need to also modify my DB schema, add additional coding for lock/unlock and also consider the possibility of "hanging" locked rows which may result in additional columns to be added in the table (e.g. to store the time the row was locked and the lockedBy information) and code as well (e.g. to run a Javascript at User side that will be updating the locked time so that the user continuously flags the row while using it...) </p> <p>Your comments based on your experience would be highly appreciated!!!</p> <p>Thank you.</p>
0debug