problem
stringlengths
26
131k
labels
class label
2 classes
static inline PageDesc *page_find_alloc(target_ulong index) { PageDesc **lp, *p; #if TARGET_LONG_BITS > 32 if (index > ((target_ulong)L2_SIZE * L1_SIZE)) return NULL; #endif lp = &l1_map[index >> L2_BITS]; p = *lp; if (!p) { #if defined(CONFIG_USER_ONLY) unsigned long addr; size_t len = sizeof(PageDesc) * L2_SIZE; p = mmap(0, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); *lp = p; addr = h2g(p); if (addr == (target_ulong)addr) { page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + len), PAGE_RESERVED); } #else p = qemu_mallocz(sizeof(PageDesc) * L2_SIZE); *lp = p; #endif } return p + (index & (L2_SIZE - 1)); }
1threat
static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt) { MatroskaDemuxContext *matroska = s->priv_data; int ret = 0; while (!ret && matroska_deliver_packet(matroska, pkt)) { if (matroska->done) return AVERROR_EOF; ret = matroska_parse_cluster(matroska); } return ret; }
1threat
static int packed_16bpc_bswap(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]) { int i, j; int srcstr = srcStride[0] >> 1; int dststr = dstStride[0] >> 1; uint16_t *dstPtr = (uint16_t *) dst[0]; const uint16_t *srcPtr = (const uint16_t *) src[0]; for (i = 0; i < srcSliceH; i++) { for (j = 0; j < srcstr; j++) { dstPtr[j] = av_bswap16(srcPtr[j]); } srcPtr += srcstr; dstPtr += dststr; } return srcSliceH; }
1threat
How do i create asp.net code for Password Strength? : I am looking to implement a password strength feature for my textbox in my asp.net website. Currently, my aspx code looks like this : <span id="password_strength"></span> <script type="text/javascript"> function CheckPasswordStrength(password) { var password_strength = document.getElementById("password_strength"); //if textBox is empty if(password.length==0){ password_strength.innerHTML = ""; return; } //Regular Expressions var regex = new Array(); regex.push("[A-Z]"); //For Uppercase Alphabet regex.push("[a-z]"); //For Lowercase Alphabet regex.push("[0-9]"); //For Numeric Digits regex.push("[$@$!%*#?&]"); //For Special Characters var passed = 0; //Validation for each Regular Expression for (var i = 0; i < regex.length; i++) { if(new RegExp (regex[i]).test(password){ passed++; } } //Validation for Length of Password if(passed > 2 && password.length > 8){ passed++; } //Display of Status var color = ""; var passwordStrength = ""; switch(passed){ case 0: case 1: passwordStrength = "Password is Weak."; color = "Red"; break; case 2: passwordStrength = "Password is Good."; color = "darkorange"; break; case 3: case 4: passwordStrength = "Password is Strong."; color = "Green"; break; case 5: passwordStrength = "Password is Very Strong."; color = "darkgreen"; break; } password_strength.innerHTML = passwordStrength; password_strength.style.color = color; } </script> <div class="row"> <div class="col-sm-6"> <center><asp:label runat="server" text="Password :" Font-Bold="True" Font-Italic="False"></asp:label></center> <center><asp:TextBox ID="tbPassword" runat="server" onkeyup="CheckPasswordStrength(this.value)"></asp:TextBox></center> </div> </div> Had got this code online... But had tried it on my website and it does not work. Would really appreciate if somebody can help me with my code. Thank You. :)
0debug
static av_always_inline SoftFloat autocorr_calc(int64_t accu) { int nz, mant, expo, round; int i = (int)(accu >> 32); if (i == 0) { nz = 1; } else { nz = 0; while (FFABS(i) < 0x40000000) { i <<= 1; nz++; } nz = 32-nz; } round = 1 << (nz-1); mant = (int)((accu + round) >> nz); mant = (mant + 0x40)>>7; mant <<= 6; expo = nz + 15; return av_int2sf(mant, 30 - expo); }
1threat
How to remove empty element in an array : <p>I have been trying array_filter but doesn't work on my part. </p> <p><a href="https://i.stack.imgur.com/kV2nF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kV2nF.jpg" alt="enter image description here"></a></p>
0debug
static void filter_mb(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, int mb_x, int mb_y) { int filter_level, inner_limit, hev_thresh, mbedge_lim, bedge_lim; filter_level_for_mb(s, mb, &filter_level, &inner_limit, &hev_thresh); if (!filter_level) return; mbedge_lim = 2*(filter_level+2) + inner_limit; bedge_lim = 2* filter_level + inner_limit; if (mb_x) { s->vp8dsp.vp8_h_loop_filter16(dst[0], s->linesize, mbedge_lim, inner_limit, hev_thresh); s->vp8dsp.vp8_h_loop_filter8 (dst[1], s->uvlinesize, mbedge_lim, inner_limit, hev_thresh); s->vp8dsp.vp8_h_loop_filter8 (dst[2], s->uvlinesize, mbedge_lim, inner_limit, hev_thresh); } if (!mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT) { s->vp8dsp.vp8_h_loop_filter16_inner(dst[0]+ 4, s->linesize, bedge_lim, inner_limit, hev_thresh); s->vp8dsp.vp8_h_loop_filter16_inner(dst[0]+ 8, s->linesize, bedge_lim, inner_limit, hev_thresh); s->vp8dsp.vp8_h_loop_filter16_inner(dst[0]+12, s->linesize, bedge_lim, inner_limit, hev_thresh); s->vp8dsp.vp8_h_loop_filter8_inner (dst[1]+ 4, s->uvlinesize, bedge_lim, inner_limit, hev_thresh); s->vp8dsp.vp8_h_loop_filter8_inner (dst[2]+ 4, s->uvlinesize, bedge_lim, inner_limit, hev_thresh); } if (mb_y) { s->vp8dsp.vp8_v_loop_filter16(dst[0], s->linesize, mbedge_lim, inner_limit, hev_thresh); s->vp8dsp.vp8_v_loop_filter8 (dst[1], s->uvlinesize, mbedge_lim, inner_limit, hev_thresh); s->vp8dsp.vp8_v_loop_filter8 (dst[2], s->uvlinesize, mbedge_lim, inner_limit, hev_thresh); } if (!mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT) { s->vp8dsp.vp8_v_loop_filter16_inner(dst[0]+ 4*s->linesize, s->linesize, bedge_lim, inner_limit, hev_thresh); s->vp8dsp.vp8_v_loop_filter16_inner(dst[0]+ 8*s->linesize, s->linesize, bedge_lim, inner_limit, hev_thresh); s->vp8dsp.vp8_v_loop_filter16_inner(dst[0]+12*s->linesize, s->linesize, bedge_lim, inner_limit, hev_thresh); s->vp8dsp.vp8_v_loop_filter8_inner (dst[1]+ 4*s->uvlinesize, s->uvlinesize, bedge_lim, inner_limit, hev_thresh); s->vp8dsp.vp8_v_loop_filter8_inner (dst[2]+ 4*s->uvlinesize, s->uvlinesize, bedge_lim, inner_limit, hev_thresh); } }
1threat
How do I find a job as a junior rails developer? : <p>How do I find a job as a junior Ruby on Rails developer? I am eager to improve my skills and be a part of something bigger.</p>
0debug
bool migrate_auto_converge(void) { MigrationState *s; s = migrate_get_current(); return s->enabled_capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE]; }
1threat
void qemu_coroutine_enter(Coroutine *co, void *opaque) { Coroutine *self = qemu_coroutine_self(); CoroutineAction ret; trace_qemu_coroutine_enter(self, co, opaque); if (co->caller) { fprintf(stderr, "Co-routine re-entered recursively\n"); abort(); } co->caller = self; co->entry_arg = opaque; ret = qemu_coroutine_switch(self, co, COROUTINE_ENTER); qemu_co_queue_run_restart(co); switch (ret) { case COROUTINE_YIELD: return; case COROUTINE_TERMINATE: trace_qemu_coroutine_terminate(co); coroutine_delete(co); return; default: abort(); } }
1threat
Can't get claims from JWT token with ASP.NET Core : <p>I'm trying to do a really simple implementation of JWT bearer authentication with ASP.NET Core. I return a response from a controller a bit like this:</p> <pre><code> var identity = new ClaimsIdentity(); identity.AddClaim(new Claim(ClaimTypes.Name, applicationUser.UserName)); var jwt = new JwtSecurityToken( _jwtOptions.Issuer, _jwtOptions.Audience, identity.Claims, _jwtOptions.NotBefore, _jwtOptions.Expiration, _jwtOptions.SigningCredentials); var encodedJwt = new JwtSecurityTokenHandler().WriteToken(jwt); return new JObject( new JProperty("access_token", encodedJwt), new JProperty("token_type", "bearer"), new JProperty("expires_in", (int)_jwtOptions.ValidFor.TotalSeconds), new JProperty(".issued", DateTimeOffset.UtcNow.ToString()) ); </code></pre> <p>I have Jwt middleware for incoming requests:</p> <pre><code>app.UseJwtBearerAuthentication(new JwtBearerOptions { AutomaticAuthenticate = true, AutomaticChallenge = true, TokenValidationParameters = tokenValidationParameters }); </code></pre> <p>This seems to work to protect resources with the authorize attribute, but the claims never show up.</p> <pre><code> [Authorize] public async Task&lt;IActionResult&gt; Get() { var user = ClaimsPrincipal.Current.Claims; // Nothing here </code></pre>
0debug
static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int log2_cb_size, int cb_depth) { HEVCLocalContext *lc = s->HEVClc; const int cb_size = 1 << log2_cb_size; int ret; lc->ct.depth = cb_depth; if (x0 + cb_size <= s->sps->width && y0 + cb_size <= s->sps->height && log2_cb_size > s->sps->log2_min_cb_size) { SAMPLE(s->split_cu_flag, x0, y0) = ff_hevc_split_coding_unit_flag_decode(s, cb_depth, x0, y0); } else { SAMPLE(s->split_cu_flag, x0, y0) = (log2_cb_size > s->sps->log2_min_cb_size); } if (s->pps->cu_qp_delta_enabled_flag && log2_cb_size >= s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth) { lc->tu.is_cu_qp_delta_coded = 0; lc->tu.cu_qp_delta = 0; } if (SAMPLE(s->split_cu_flag, x0, y0)) { const int cb_size_split = cb_size >> 1; const int x1 = x0 + cb_size_split; const int y1 = y0 + cb_size_split; int more_data = 0; more_data = hls_coding_quadtree(s, x0, y0, log2_cb_size - 1, cb_depth + 1); if (more_data < 0) return more_data; if (more_data && x1 < s->sps->width) more_data = hls_coding_quadtree(s, x1, y0, log2_cb_size - 1, cb_depth + 1); if (more_data && y1 < s->sps->height) more_data = hls_coding_quadtree(s, x0, y1, log2_cb_size - 1, cb_depth + 1); if (more_data && x1 < s->sps->width && y1 < s->sps->height) { return hls_coding_quadtree(s, x1, y1, log2_cb_size - 1, cb_depth + 1); } if (more_data) return ((x1 + cb_size_split) < s->sps->width || (y1 + cb_size_split) < s->sps->height); else return 0; } else { ret = hls_coding_unit(s, x0, y0, log2_cb_size); if (ret < 0) return ret; if ((!((x0 + cb_size) % (1 << (s->sps->log2_ctb_size))) || (x0 + cb_size >= s->sps->width)) && (!((y0 + cb_size) % (1 << (s->sps->log2_ctb_size))) || (y0 + cb_size >= s->sps->height))) { int end_of_slice_flag = ff_hevc_end_of_slice_flag_decode(s); return !end_of_slice_flag; } else { return 1; } } return 0; }
1threat
bool vhost_net_query(VHostNetState *net, VirtIODevice *dev) { return false; }
1threat
Laravel 5: using bcrypt on same string gives different values : <p>I am using Laravel's <code>bcrypt</code> function for hashing passwords. When I do,</p> <pre><code>bcrypt('secret') </code></pre> <p>I get</p> <pre><code>=&gt; "$2y$10$mnPgYt2xm9pxb/c2I.SH.uuhgrOj4WajDQTJYssUbTjmPOcgQybcu" </code></pre> <p>But if I run it again, I get</p> <pre><code>=&gt; "$2y$10$J8h.Xmf6muivJ4bDweUlcu/BaNzI2wlBiAcop30PbPoKa0kDaf9xi" </code></pre> <p>and so on...</p> <p>So, won't the password matching process fail if I get different values every time?</p>
0debug
int cpu_x86_register(X86CPU *cpu, const char *cpu_model) { CPUX86State *env = &cpu->env; x86_def_t def1, *def = &def1; Error *error = NULL; char *name, *features; gchar **model_pieces; memset(def, 0, sizeof(*def)); model_pieces = g_strsplit(cpu_model, ",", 2); if (!model_pieces[0]) { error_setg(&error, "Invalid/empty CPU model name"); goto out; } name = model_pieces[0]; features = model_pieces[1]; if (cpu_x86_find_by_name(def, name) < 0) { error_setg(&error, "Unable to find CPU definition: %s", name); goto out; } if (kvm_enabled()) { def->kvm_features |= kvm_default_features; } def->ext_features |= CPUID_EXT_HYPERVISOR; object_property_set_str(OBJECT(cpu), def->vendor, "vendor", &error); object_property_set_int(OBJECT(cpu), def->level, "level", &error); object_property_set_int(OBJECT(cpu), def->family, "family", &error); object_property_set_int(OBJECT(cpu), def->model, "model", &error); object_property_set_int(OBJECT(cpu), def->stepping, "stepping", &error); env->cpuid_features = def->features; env->cpuid_ext_features = def->ext_features; env->cpuid_ext2_features = def->ext2_features; env->cpuid_ext3_features = def->ext3_features; object_property_set_int(OBJECT(cpu), def->xlevel, "xlevel", &error); env->cpuid_kvm_features = def->kvm_features; env->cpuid_svm_features = def->svm_features; env->cpuid_ext4_features = def->ext4_features; env->cpuid_7_0_ebx_features = def->cpuid_7_0_ebx_features; env->cpuid_xlevel2 = def->xlevel2; object_property_set_int(OBJECT(cpu), (int64_t)def->tsc_khz * 1000, "tsc-frequency", &error); object_property_set_str(OBJECT(cpu), def->model_id, "model-id", &error); if (error) { goto out; } cpu_x86_parse_featurestr(cpu, features, &error); out: g_strfreev(model_pieces); if (error) { fprintf(stderr, "%s\n", error_get_pretty(error)); error_free(error); return -1; } return 0; }
1threat
SQL Query to STIRP OFF time part using DateAdd() : Team, I searched online and don't get proper answers to my need. Basically, with below in my query am getting output in Date column as WHERE DATE >= DATEADD(MONTH, -3, GETDATE()) Output: Date: 2017-12-1 00:00:00:00 I don't want to see those 0s at all and just want pure date value present. my date column should only show me date and nothing for time, not even 0s
0debug
how to run a testng.xml file from a maven project in command prompt : <p>To run testng xml as a suite we need lib and bin folder to be used in class path bu since i am using maven project i don't have such folders how to run testng xml in maven project</p>
0debug
int usb_desc_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { const USBDesc *desc = usb_device_get_usb_desc(dev); int ret = -1; assert(desc != NULL); switch(request) { case DeviceOutRequest | USB_REQ_SET_ADDRESS: dev->addr = value; trace_usb_set_addr(dev->addr); ret = 0; break; case DeviceRequest | USB_REQ_GET_DESCRIPTOR: ret = usb_desc_get_descriptor(dev, value, data, length); break; case DeviceRequest | USB_REQ_GET_CONFIGURATION: data[0] = dev->config->bConfigurationValue; ret = 1; break; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION: ret = usb_desc_set_config(dev, value); trace_usb_set_config(dev->addr, value, ret); break; case DeviceRequest | USB_REQ_GET_STATUS: data[0] = 0; if (dev->config->bmAttributes & 0x40) { data[0] |= 1 << USB_DEVICE_SELF_POWERED; } if (dev->remote_wakeup) { data[0] |= 1 << USB_DEVICE_REMOTE_WAKEUP; } data[1] = 0x00; ret = 2; break; case DeviceOutRequest | USB_REQ_CLEAR_FEATURE: if (value == USB_DEVICE_REMOTE_WAKEUP) { dev->remote_wakeup = 0; ret = 0; } trace_usb_clear_device_feature(dev->addr, value, ret); break; case DeviceOutRequest | USB_REQ_SET_FEATURE: if (value == USB_DEVICE_REMOTE_WAKEUP) { dev->remote_wakeup = 1; ret = 0; } trace_usb_set_device_feature(dev->addr, value, ret); break; case InterfaceRequest | USB_REQ_GET_INTERFACE: if (index < 0 || index >= dev->ninterfaces) { break; } data[0] = dev->altsetting[index]; ret = 1; break; case InterfaceOutRequest | USB_REQ_SET_INTERFACE: ret = usb_desc_set_interface(dev, index, value); trace_usb_set_interface(dev->addr, index, value, ret); break; } return ret; }
1threat
Add weights to .pb file exported by TensorFlow : <p>My project uses Python to train a MLP on TensorFlow and then I export the graph and the weights in that way:</p> <pre><code>tf.train.write_graph(sess.graph_def, "./", "inp.txt", True) saver.save(sess, 'variables/model.ckpt', global_step=1) </code></pre> <p>Now, although it is fine to use both files to import it back to Python it seems impossible to use it for Android or C++ since it cannot inport the checkpoint .ckpt.</p> <p>Right now, I'm using the script <code>freeze_graph.py</code> provided by google to join both files into one by doing:</p> <pre><code>bazel-bin/tensorflow/python/tools/freeze_graph --input_graph=inp.txt --input_checkpoint=variables/model.ckpt-1 --output_graph=newoutput.pb --output_node_names=output </code></pre> <p>My question is, is there a way to use another function instead of <code>tf.train.write_graph</code> to export it with the weights included?</p>
0debug
Evernote API Change Alert Notification : <p>When there is a new release with a version change, or any release that may cause deprecation, how are developers notified? is there an email list that we can sign up for? </p> <p>I have been documenting this for almost 200 api's, some use twitter, some send alert emails, some rely on statuspage, admins who have created apps, and even some have no system at all. I am trying to find out how developers are notified when a new release to the evernote api is imminent.</p>
0debug
Android Sqlite insert null object reference : <p>I'm taking an intro to android programming course running into some issues adding to the sqlite database</p> <p>Any suggestions what might be causing this error. I think it is related to not having the proper assignment to the mDatabase field variable. </p> <p>It seems like the issue is that mDatabase variable in the addCustomer function needs different context.</p> <pre><code> private static ContentValues getContentValues(Customer customer) { ContentValues values = new ContentValues(); values.put(UUID, customer.getId().toString()); values.put(FULL_NAME, customer.getName()); values.put(ADDRESS, customer.getAddress()); values.put(CREDIT_CARD_NUMBER, customer.getCreditCardNumber()); values.put(EMAIL, customer.getEmail()); values.put(SESSIONS_REMAINING, customer.getSessionsRemaining()); values.put(PRINT_RECEIPT, customer.getPrintReceipt() ? 1 : 0); values.put(EMAIL_RECEIPT, customer.getEmailReceipt() ? 1 : 0); return values; } public void addCustomer(Customer c) { ContentValues values = getContentValues(c); mDatabase.insert(CustomerDbSchema.CustomerTable.NAME, null, values); Log.d("DATABASE", "Customer Added"); } </code></pre> <p>File Links on Github below:</p> <p><a href="https://github.com/zcbuhler/FitnessTracker/blob/master/app/src/main/java/com/z/buhler/fitnesstracker/database/CustomerBaseHelper.java" rel="nofollow noreferrer">CustomerDataBase.java</a></p> <p><a href="https://github.com/zcbuhler/FitnessTracker/blob/master/app/src/main/java/com/z/buhler/fitnesstracker/database/CustomerCursorWrapper.java" rel="nofollow noreferrer">CustomerCursorWrapper.java</a></p> <p><a href="https://github.com/zcbuhler/FitnessTracker/blob/master/app/src/main/java/com/z/buhler/fitnesstracker/database/CustomerDbSchema.java" rel="nofollow noreferrer">CustomerDBSchema.java</a></p> <p><a href="https://github.com/zcbuhler/FitnessTracker/blob/master/app/src/main/java/com/z/buhler/fitnesstracker/Customer.java" rel="nofollow noreferrer">Customer.java</a></p> <p><a href="https://github.com/zcbuhler/FitnessTracker/blob/master/app/src/main/java/com/z/buhler/fitnesstracker/AddCustomerActivity.java" rel="nofollow noreferrer">AddCustomerActivity.java</a></p>
0debug
MemoryRegion *pci_address_space(PCIDevice *dev) { return dev->bus->address_space_mem; }
1threat
Hashset ordering issue : <p>Recently I came across this</p> <pre><code>String s = "9495963"; Set&lt;Character&gt; set = new HashSet&lt;Character&gt;(); for(char e : s.toCharArray()){ set.add(e); } System.out.println(set);//[3, 4, 5, 6, 9] </code></pre> <p>The output i got was [3, 4, 5, 6, 9], so, if HashSet doesn't preserve any order then how come these numbers were arranged in the ascending order?</p>
0debug
static void omap_prcm_dpll_update(struct omap_prcm_s *s) { omap_clk dpll = omap_findclk(s->mpu, "dpll"); omap_clk dpll_x2 = omap_findclk(s->mpu, "dpll"); omap_clk core = omap_findclk(s->mpu, "core_clk"); int mode = (s->clken[9] >> 0) & 3; int mult, div; mult = (s->clksel[5] >> 12) & 0x3ff; div = (s->clksel[5] >> 8) & 0xf; if (mult == 0 || mult == 1) mode = 1; s->dpll_lock = 0; switch (mode) { case 0: fprintf(stderr, "%s: bad EN_DPLL\n", __FUNCTION__); break; case 1: case 2: omap_clk_setrate(dpll, 1, 1); omap_clk_setrate(dpll_x2, 1, 1); break; case 3: s->dpll_lock = 1; omap_clk_setrate(dpll, div + 1, mult); omap_clk_setrate(dpll_x2, div + 1, mult * 2); break; } switch ((s->clksel[6] >> 0) & 3) { case 0: omap_clk_reparent(core, omap_findclk(s->mpu, "clk32-kHz")); break; case 1: omap_clk_reparent(core, dpll); break; case 2: omap_clk_reparent(core, dpll_x2); break; case 3: fprintf(stderr, "%s: bad CORE_CLK_SRC\n", __FUNCTION__); break; } }
1threat
Asterisk in function type : <p>I found some code online for a <a href="http://www.taywils.me/2014/11/15/boostchatclient.html" rel="nofollow noreferrer">C++ Chat Server</a>. And in the code below contains something I don't get</p> <pre><code>string* buildPrompt() { // Code for chat server } </code></pre> <p>What is that asterisk after <code>string</code>? If I remove it, will the code stop working?</p>
0debug
void acpi_build(AcpiBuildTables *tables, MachineState *machine) { PCMachineState *pcms = PC_MACHINE(machine); PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); GArray *table_offsets; unsigned facs, dsdt, rsdt, fadt; AcpiPmInfo pm; AcpiMiscInfo misc; AcpiMcfgInfo mcfg; Range pci_hole, pci_hole64; uint8_t *u; size_t aml_len = 0; GArray *tables_blob = tables->table_data; AcpiSlicOem slic_oem = { .id = NULL, .table_id = NULL }; acpi_get_pm_info(&pm); acpi_get_misc_info(&misc); acpi_get_pci_holes(&pci_hole, &pci_hole64); acpi_get_slic_oem(&slic_oem); table_offsets = g_array_new(false, true , sizeof(uint32_t)); ACPI_BUILD_DPRINTF("init ACPI tables\n"); bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE, tables_blob, 64 , false ); facs = tables_blob->len; build_facs(tables_blob, tables->linker); dsdt = tables_blob->len; build_dsdt(tables_blob, tables->linker, &pm, &misc, &pci_hole, &pci_hole64, machine); aml_len += tables_blob->len - dsdt; fadt = tables_blob->len; acpi_add_table(table_offsets, tables_blob); build_fadt(tables_blob, tables->linker, &pm, facs, dsdt, slic_oem.id, slic_oem.table_id); aml_len += tables_blob->len - fadt; acpi_add_table(table_offsets, tables_blob); build_madt(tables_blob, tables->linker, pcms); if (misc.has_hpet) { acpi_add_table(table_offsets, tables_blob); build_hpet(tables_blob, tables->linker); } if (misc.tpm_version != TPM_VERSION_UNSPEC) { acpi_add_table(table_offsets, tables_blob); build_tpm_tcpa(tables_blob, tables->linker, tables->tcpalog); if (misc.tpm_version == TPM_VERSION_2_0) { acpi_add_table(table_offsets, tables_blob); build_tpm2(tables_blob, tables->linker); } } if (pcms->numa_nodes) { acpi_add_table(table_offsets, tables_blob); build_srat(tables_blob, tables->linker, machine); } if (acpi_get_mcfg(&mcfg)) { acpi_add_table(table_offsets, tables_blob); build_mcfg_q35(tables_blob, tables->linker, &mcfg); } if (x86_iommu_get_default()) { IommuType IOMMUType = x86_iommu_get_type(); if (IOMMUType == TYPE_AMD) { acpi_add_table(table_offsets, tables_blob); build_amd_iommu(tables_blob, tables->linker); } else if (IOMMUType == TYPE_INTEL) { acpi_add_table(table_offsets, tables_blob); build_dmar_q35(tables_blob, tables->linker); } } if (pcms->acpi_nvdimm_state.is_enabled) { nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, pcms->acpi_nvdimm_state.dsm_mem, machine->ram_slots); } for (u = acpi_table_first(); u; u = acpi_table_next(u)) { unsigned len = acpi_table_len(u); acpi_add_table(table_offsets, tables_blob); g_array_append_vals(tables_blob, u, len); } rsdt = tables_blob->len; build_rsdt(tables_blob, tables->linker, table_offsets, slic_oem.id, slic_oem.table_id); build_rsdp(tables->rsdp, tables->linker, rsdt); if (pcmc->legacy_acpi_table_size) { int legacy_aml_len = pcmc->legacy_acpi_table_size + ACPI_BUILD_LEGACY_CPU_AML_SIZE * max_cpus; int legacy_table_size = ROUND_UP(tables_blob->len - aml_len + legacy_aml_len, ACPI_BUILD_ALIGN_SIZE); if (tables_blob->len > legacy_table_size) { error_report("Warning: migration may not work."); } g_array_set_size(tables_blob, legacy_table_size); } else { if (tables_blob->len > ACPI_BUILD_TABLE_SIZE / 2) { error_report("Warning: ACPI tables are larger than 64k."); error_report("Warning: migration may not work."); error_report("Warning: please remove CPUs, NUMA nodes, " "memory slots or PCI bridges."); } acpi_align_size(tables_blob, ACPI_BUILD_TABLE_SIZE); } acpi_align_size(tables->linker->cmd_blob, ACPI_BUILD_ALIGN_SIZE); g_array_free(table_offsets, true); }
1threat
Parse Long from String exception : <p>I got a very bizzared exception when trying to parse the simple String into a long value. </p> <pre><code>public class Utils { public static double tryParseLong(String s) { try { return Long.parseLong("45.6", 10); } catch (Exception e) { e.printStackTrace(); } finally { return 0; } } </code></pre> <p>}</p> <p><code>java.lang.NumberFormatException: For input string: "45.6"</code></p>
0debug
static void versatile_init(MachineState *machine, int board_id) { ARMCPU *cpu; MemoryRegion *sysmem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); qemu_irq pic[32]; qemu_irq sic[32]; DeviceState *dev, *sysctl; SysBusDevice *busdev; DeviceState *pl041; PCIBus *pci_bus; NICInfo *nd; I2CBus *i2c; int n; int done_smc = 0; DriveInfo *dinfo; if (!machine->cpu_model) { machine->cpu_model = "arm926"; } cpu = cpu_arm_init(machine->cpu_model); if (!cpu) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } memory_region_init_ram(ram, NULL, "versatile.ram", machine->ram_size, &error_abort); vmstate_register_ram_global(ram); memory_region_add_subregion(sysmem, 0, ram); sysctl = qdev_create(NULL, "realview_sysctl"); qdev_prop_set_uint32(sysctl, "sys_id", 0x41007004); qdev_prop_set_uint32(sysctl, "proc_id", 0x02000000); qdev_init_nofail(sysctl); sysbus_mmio_map(SYS_BUS_DEVICE(sysctl), 0, 0x10000000); dev = sysbus_create_varargs("pl190", 0x10140000, qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ), qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_FIQ), NULL); for (n = 0; n < 32; n++) { pic[n] = qdev_get_gpio_in(dev, n); } dev = sysbus_create_simple(TYPE_VERSATILE_PB_SIC, 0x10003000, NULL); for (n = 0; n < 32; n++) { sysbus_connect_irq(SYS_BUS_DEVICE(dev), n, pic[n]); sic[n] = qdev_get_gpio_in(dev, n); } sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3]); sysbus_create_simple("pl050_mouse", 0x10007000, sic[4]); dev = qdev_create(NULL, "versatile_pci"); busdev = SYS_BUS_DEVICE(dev); qdev_init_nofail(dev); sysbus_mmio_map(busdev, 0, 0x10001000); sysbus_mmio_map(busdev, 1, 0x41000000); sysbus_mmio_map(busdev, 2, 0x42000000); sysbus_mmio_map(busdev, 3, 0x43000000); sysbus_mmio_map(busdev, 4, 0x44000000); sysbus_mmio_map(busdev, 5, 0x50000000); sysbus_mmio_map(busdev, 6, 0x60000000); sysbus_connect_irq(busdev, 0, sic[27]); sysbus_connect_irq(busdev, 1, sic[28]); sysbus_connect_irq(busdev, 2, sic[29]); sysbus_connect_irq(busdev, 3, sic[30]); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci"); for(n = 0; n < nb_nics; n++) { nd = &nd_table[n]; if (!done_smc && (!nd->model || strcmp(nd->model, "smc91c111") == 0)) { smc91c111_init(nd, 0x10010000, sic[25]); done_smc = 1; } else { pci_nic_init_nofail(nd, pci_bus, "rtl8139", NULL); } } if (usb_enabled(false)) { pci_create_simple(pci_bus, -1, "pci-ohci"); } n = drive_get_max_bus(IF_SCSI); while (n >= 0) { pci_create_simple(pci_bus, -1, "lsi53c895a"); n--; } sysbus_create_simple("pl011", 0x101f1000, pic[12]); sysbus_create_simple("pl011", 0x101f2000, pic[13]); sysbus_create_simple("pl011", 0x101f3000, pic[14]); sysbus_create_simple("pl011", 0x10009000, sic[6]); sysbus_create_simple("pl080", 0x10130000, pic[17]); sysbus_create_simple("sp804", 0x101e2000, pic[4]); sysbus_create_simple("sp804", 0x101e3000, pic[5]); sysbus_create_simple("pl061", 0x101e4000, pic[6]); sysbus_create_simple("pl061", 0x101e5000, pic[7]); sysbus_create_simple("pl061", 0x101e6000, pic[8]); sysbus_create_simple("pl061", 0x101e7000, pic[9]); dev = sysbus_create_simple("pl110_versatile", 0x10120000, pic[16]); qdev_connect_gpio_out(sysctl, 0, qdev_get_gpio_in(dev, 0)); sysbus_create_varargs("pl181", 0x10005000, sic[22], sic[1], NULL); sysbus_create_varargs("pl181", 0x1000b000, sic[23], sic[2], NULL); sysbus_create_simple("pl031", 0x101e8000, pic[10]); dev = sysbus_create_simple("versatile_i2c", 0x10002000, NULL); i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c"); i2c_create_slave(i2c, "ds1338", 0x68); pl041 = qdev_create(NULL, "pl041"); qdev_prop_set_uint32(pl041, "nc_fifo_depth", 512); qdev_init_nofail(pl041); sysbus_mmio_map(SYS_BUS_DEVICE(pl041), 0, 0x10004000); sysbus_connect_irq(SYS_BUS_DEVICE(pl041), 0, sic[24]); dinfo = drive_get(IF_PFLASH, 0, 0); if (!pflash_cfi01_register(VERSATILE_FLASH_ADDR, NULL, "versatile.flash", VERSATILE_FLASH_SIZE, dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL, VERSATILE_FLASH_SECT_SIZE, VERSATILE_FLASH_SIZE / VERSATILE_FLASH_SECT_SIZE, 4, 0x0089, 0x0018, 0x0000, 0x0, 0)) { fprintf(stderr, "qemu: Error registering flash memory.\n"); } versatile_binfo.ram_size = machine->ram_size; versatile_binfo.kernel_filename = machine->kernel_filename; versatile_binfo.kernel_cmdline = machine->kernel_cmdline; versatile_binfo.initrd_filename = machine->initrd_filename; versatile_binfo.board_id = board_id; arm_load_kernel(cpu, &versatile_binfo); }
1threat
SQL noob - Car dealership stock orders list : This may have already been asked before, but I couldn't find much. Please redirect me if so. I work for a big car dealership in Switzerland. We receive dayly a List of cars in our carparks located all around the country. This list serves us to find which car our clients are looking for, so that we can propose them an offer. The list is huge and difficult to work with. For instance all optional and modelversions are written all in one cell.... So I had the idea to build a database, with a research form and a report in Ms Access so that we just need to load this list in an excel sheet, run a formatting macro in order to have a proper list to work with, then feed it to the database through table connection. This will definitely save us a lot of time So, at the end of the formatting macro my list look kinda like this:[formatted car list][1] Since the same Optionals on different cars have different prices I need to have my Data to look like this:[target table format][2], so that in my report I can do a table join query and have a list of the car's optionals with their prices. Is there a way to do a "Table Normalisation" in MS Access? Ty all for the answers in advance! [1]: https://i.stack.imgur.com/jWVBF.jpg [2]: https://i.stack.imgur.com/kDs8i.jpg
0debug
import math def find_Digits(n): if (n < 0): return 0; if (n <= 1): return 1; x = ((n * math.log10(n / math.e) + math.log10(2 * math.pi * n) /2.0)); return math.floor(x) + 1;
0debug
Please explain DEFER's behaivour in golang : <p>As I know, defer is usually used to close or free resources. And using <code>defer FUNC ()</code> inside the block (function) of the code ensures that <code>FUNC ()</code> will call in case of any return from this block(function) or panic in this block (function).</p> <p>So - how to explain <code>defer</code> behavior in this code: (<a href="https://play.golang.org/p/FPA0wrRyw1f" rel="nofollow noreferrer">Example</a>):</p> <pre><code>package main import ( "fmt" "errors" ) func test() error { err := errors.New("some error") return err } func main() { if err := test(); err!=nil { fmt.Println("ERROR EXIT") return } defer fmt.Println("DEFER EXIT") fmt.Println("NORMAL EXIT") } </code></pre> <p>I expected to see this:</p> <pre><code>ERROR EXIT DEFER EXIT </code></pre> <p>But got it:</p> <pre><code>ERROR EXIT </code></pre> <p>Where am I wrong?</p>
0debug
void msix_save(PCIDevice *dev, QEMUFile *f) { unsigned n = dev->msix_entries_nr; if (!(dev->cap_present & QEMU_PCI_CAP_MSIX)) { return; } qemu_put_buffer(f, dev->msix_table_page, n * PCI_MSIX_ENTRY_SIZE); qemu_put_buffer(f, dev->msix_table_page + MSIX_PAGE_PENDING, (n + 7) / 8); }
1threat
void test_clone(void) { uint8_t *stack1, *stack2; int pid1, pid2, status1, status2; stack1 = malloc(STACK_SIZE); pid1 = chk_error(clone(thread1_func, stack1 + STACK_SIZE, CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello1")); stack2 = malloc(STACK_SIZE); pid2 = chk_error(clone(thread2_func, stack2 + STACK_SIZE, CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello2")); while (waitpid(pid1, &status1, 0) != pid1); while (waitpid(pid2, &status2, 0) != pid2); if (thread1_res != 5 || thread2_res != 6) error("clone"); }
1threat
static void nvram_writel (void *opaque, target_phys_addr_t addr, uint32_t value) { M48t59State *NVRAM = opaque; m48t59_write(NVRAM, addr, (value >> 24) & 0xff); m48t59_write(NVRAM, addr + 1, (value >> 16) & 0xff); m48t59_write(NVRAM, addr + 2, (value >> 8) & 0xff); m48t59_write(NVRAM, addr + 3, value & 0xff); }
1threat
int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, BlockDriver *drv) { int ret, open_flags; char tmp_filename[PATH_MAX]; char backing_filename[PATH_MAX]; bs->read_only = 0; bs->is_temporary = 0; bs->encrypted = 0; bs->autogrow = 0; if (flags & BDRV_O_AUTOGROW) bs->autogrow = 1; if (flags & BDRV_O_SNAPSHOT) { BlockDriverState *bs1; int64_t total_size; bs1 = bdrv_new(""); if (!bs1) { return -ENOMEM; } if (bdrv_open(bs1, filename, 0) < 0) { bdrv_delete(bs1); return -1; } total_size = bdrv_getlength(bs1) >> SECTOR_BITS; bdrv_delete(bs1); get_tmp_filename(tmp_filename, sizeof(tmp_filename)); realpath(filename, backing_filename); if (bdrv_create(&bdrv_qcow2, tmp_filename, total_size, backing_filename, 0) < 0) { return -1; } filename = tmp_filename; bs->is_temporary = 1; } pstrcpy(bs->filename, sizeof(bs->filename), filename); if (flags & BDRV_O_FILE) { drv = find_protocol(filename); if (!drv) return -ENOENT; } else { if (!drv) { drv = find_image_format(filename); if (!drv) return -1; } } bs->drv = drv; bs->opaque = qemu_mallocz(drv->instance_size); bs->total_sectors = 0; if (bs->opaque == NULL && drv->instance_size > 0) return -1; if (!(flags & BDRV_O_FILE)) open_flags = BDRV_O_RDWR | (flags & BDRV_O_DIRECT); else open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT); ret = drv->bdrv_open(bs, filename, open_flags); if (ret == -EACCES && !(flags & BDRV_O_FILE)) { ret = drv->bdrv_open(bs, filename, BDRV_O_RDONLY); bs->read_only = 1; } if (ret < 0) { qemu_free(bs->opaque); bs->opaque = NULL; bs->drv = NULL; return ret; } if (drv->bdrv_getlength) { bs->total_sectors = bdrv_getlength(bs) >> SECTOR_BITS; } #ifndef _WIN32 if (bs->is_temporary) { unlink(filename); } #endif if (bs->backing_file[0] != '\0') { bs->backing_hd = bdrv_new(""); if (!bs->backing_hd) { fail: bdrv_close(bs); return -ENOMEM; } path_combine(backing_filename, sizeof(backing_filename), filename, bs->backing_file); if (bdrv_open(bs->backing_hd, backing_filename, 0) < 0) goto fail; } bs->media_changed = 1; if (bs->change_cb) bs->change_cb(bs->change_opaque); return 0; }
1threat
How to read CheckBox out of a text file WPF : <p>Well i have figured out how to save a checkbox value into a text file but now i need to now how to read it an load the settings for de application.</p> <pre><code>private void Load_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == true) { using (StreamReader read = new StreamReader(File.OpenRead(ofd.FileName))) { TBSOMS.Text = read.ReadLine(); TBWVB.Text = read.ReadLine(); TBWNB.Text = read.ReadLine(); TBASPMM1.Text = read.ReadLine(); TBASPMM2.Text = read.ReadLine(); TBDUM.Text = read.ReadLine(); TBADPR.Text = read.ReadLine(); TBAR.Text = read.ReadLine(); // Not working part CBXY1.IsChecked = read.ReadLine(); read.Close(); read.Dispose(); } } } </code></pre> <p>everything works properly except the checkbox value and i cant figure out how to fix it</p>
0debug
static void virtio_blk_rw_complete(void *opaque, int ret) { VirtIOBlockReq *next = opaque; while (next) { VirtIOBlockReq *req = next; next = req->mr_next; trace_virtio_blk_rw_complete(req, ret); if (req->qiov.nalloc != -1) { qemu_iovec_destroy(&req->qiov); } if (ret) { int p = virtio_ldl_p(VIRTIO_DEVICE(req->dev), &req->out.type); bool is_read = !(p & VIRTIO_BLK_T_OUT); /* Note that memory may be dirtied on read failure. If the * virtio request is not completed here, as is the case for * BLOCK_ERROR_ACTION_STOP, the memory may not be copied * correctly during live migration. While this is ugly, * it is acceptable because the device is free to write to * the memory until the request is completed (which will * happen on the other side of the migration). if (virtio_blk_handle_rw_error(req, -ret, is_read)) { continue; } } virtio_blk_req_complete(req, VIRTIO_BLK_S_OK); block_acct_done(blk_get_stats(req->dev->blk), &req->acct); virtio_blk_free_request(req); } }
1threat
How to send an email by javascript : <p>I am making a simple website where we save something by email; i found out how to open the email, but i cant get it to email a specific thing.</p> <p>this is my code:</p> <pre><code> var a = function(){ b = document.getElementById("email").value; m = document.getElementById("Text").value; window.open("mailto:"+b); }; </code></pre> <p>I'm trying to make it so it emails m as the body.</p>
0debug
String to python statement? : I want to convert a string to python statement? 1.Taking string input from a text file like eg. *'dataframe['Column_name'].sum()'* 2.Executing the string as python statement eg. *dataframe['Column_name'].sum()* 3.Storing the result in some variable
0debug
Angular2, how to clear URL query params on router navigate : <p>I am struggling with clearing out URL params during nav in Angular 2.4.2. I have tried attaching every option to clear the params in the below navigation line, or any mix therein with navigate, or navigateByUrl, but cannot figure out how to accomplish.</p> <pre><code>this.router.navigateByUrl(this.router.url, { queryParams: {}, preserveQueryParams: false }); </code></pre> <p>As an example I am at route <code>/section1/page1?key1=abc&amp;key2=def</code> and want to stay at the same route but remove all the url parameters, so the end result should be <code>/section/page1</code></p>
0debug
Separate each character in a string : <p>Hi everyone i am new member! I'm having a problem. I transmit data between Arduino Due and C #. C # receives a string a = "0.0.1.0.1.1100" from Arduino Due I want to separate each character in the string a, I tried the Substring function but it was not effective. Is it something strange?</p>
0debug
No database selected, even though explictly stated : <p>I have a query running in a script, and when it's run in mysql workbench it works fine.</p> <p>However, running the script results in 'no database selected' error in powershell. I've followed the error prompts but you can see in my query I explicitly state the database for each table, i.e. (ambition.ambition_totals).</p> <p>Is there another constraint I should add to this?</p> <pre><code>$stmt3 = mysqli_prepare($conn2, "UPDATE ambition.ambition_totals a INNER JOIN (SELECT c.user AS UserID, COUNT(*) AS dealers, ROUND((al.NumberOfDealers / al.NumberOfDealerContacts) * 100 ,2) AS percent FROM jfi_dealers.contact_events c JOIN jackson_id.users u ON c.user = u.id JOIN jfi_dealers.dealers d ON c.dealer_num = d.dealer_num LEFT JOIN ( SELECT user_id, COUNT(*) AS NumberOfDealerContacts, SUM(CASE WHEN ( d.next_call_date + INTERVAL 7 DAY) THEN 1 ELSE 0 END) AS NumberOfDealers FROM jackson_id.attr_list AS al JOIN jfi_dealers.dealers AS d ON d.csr = al.data WHERE al.attr_id = 14 GROUP BY user_id) AS al ON al.user_id = c.user GROUP BY UserID) as cu on cu.UserID = a.ext_id SET a.dealers_contacted = cu.dealers, a.percent_up_to_date = cu.percent; ") or die(mysqli_error($conn2)); </code></pre>
0debug
new at google distance matrix api with python and got the following error: : <p><bold>This is my code :</bold></p> <p>from googlemaps import Client as GoogleMaps mapServices=GoogleMaps('') start = 'texarkana' end = 'atlanta' direction= mapServices.directions(start, end) for step in direction['Direction']['Routes'][0]['Steps']: print (step['descriptionHtml'])</p> 1. List item <p><bold>error i am getting:</bold></p> <p>File "C:\Python27\directions.py", line 7, in <module> for step in direction['Direction']['Routes'][0]['Steps']: TypeError: list indices must be integers, not str</p>
0debug
OR notation and bit shift why = sign why 1 : <p>I am new to C. Can someone tell me what is happening with these instructions which are from sample code setting up timer interrupts in an Atmel in an Arduino</p> <pre><code> TCCR2A |= (1 &lt;&lt; WGM21); // Set CS21 bit for 8 prescaler TCCR2B |= (1 &lt;&lt; CS21); // enable timer compare interrupt TIMSK2 |= (1 &lt;&lt; OCIE2A); </code></pre> <p>Thanks.</p>
0debug
php divide with 'easy' numbers : <p>I'm working on a program in PHP that lets you train for making calculations without a calculator. The problem I run into is that when generating random numbers for the sums you can get awkward numbers like 4 divided by 7. Is there an easy way to generate easy sums like 9 divided by 3?</p> <p>Thanks!</p>
0debug
Should Sequelize migrations update model files? : <p>Are Sequelize migrations supposed to keep your model files in line with your database?</p> <p>I used the sequelize cli to bootstrap a simple project and create a model <code>node_modules/.bin/sequelize model:generate --name User --attributes email:string</code>. I migrated this with no issue. </p> <p>Then I created the following migration file to add a notNull constraint to the user email attribute.</p> <p><strong>updateEmail migration</strong></p> <pre><code>const models = require("../models") module.exports = { up: (queryInterface, Sequelize) =&gt; { return queryInterface.changeColumn(models.User.tableName, 'email',{ type: Sequelize.STRING, allowNull: false, }); }, down: (queryInterface, Sequelize) =&gt; { return queryInterface.changeColumn(models.User.tableName, 'email',{ type: Sequelize.STRING, }); }, }; </code></pre> <p>The database schema updated to add the constraint but the model file did not. Is there a way to automatically update the model files as you make migrations?</p>
0debug
Strange if-else condition calling : Please help me go through this : print("%i", session.subsessions.count) // prints 3 print("%i", self.iSessionNumber) // prints 6 print("%i", self.sessions.count - 1) // prints 6 if session.subsessions.count > 1 || self.iSessionNumber == self.sessions.count - 1 { // if called } else { // else called } Clearly, if condition should be called. But strangely, else is getting called. No idea why
0debug
Adding "Open Anaconda Prompt here" to context menu (Windows) : <p>I'd like to add an option on my context menu (Windows 7 and 10) to open an Anaconda Prompt into the file location when I right-click the folder, but I can't figure out the right registry key.</p> <p>Here's what I know how to do: </p> <ul> <li>Add an item to the context menu that opens a normal command window at the folder location </li> <li>Open an Anaconda prompt from cmd (run their "activate.bat" file) </li> </ul> <p>What I can't figure out is how to combine these steps into a single registry key so I can open an Anaconda Prompt and then cd in that prompt to the current folder. But maybe I'm approaching this the wrong way.</p> <p>Help from internet gurus is appreciated.</p>
0debug
Golang multiple json tag names for one field : <p>It it possible in Golang to use more than one name for a JSON struct tag ?</p> <pre><code>type Animation struct { Name string `json:"name"` Repeat int `json:"repeat"` Speed uint `json:"speed"` Pattern Pattern `json:"pattern",json:"frames"` } </code></pre>
0debug
static void release_buffer(AVCodecContext *avctx, AVFrame *pic) { int i; CVPixelBufferRef cv_buffer = (CVPixelBufferRef)pic->data[3]; CVPixelBufferUnlockBaseAddress(cv_buffer, 0); CVPixelBufferRelease(cv_buffer); for (i = 0; i < 4; i++) pic->data[i] = NULL; }
1threat
Remove the Middle Name letter from firstName Column in SQL : <p>I have a column with FirstName = JOYCE A I want to remove the "A" i.e, middle name &amp; write the SQL command for it Result should be <code>FirstName = JOYCE</code></p> <p>Please help.</p>
0debug
static void pcie_cap_slot_hotplug_common(PCIDevice *hotplug_dev, DeviceState *dev, uint8_t **exp_cap, Error **errp) { *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; uint16_t sltsta = pci_get_word(*exp_cap + PCI_EXP_SLTSTA); PCIE_DEV_PRINTF(PCI_DEVICE(dev), "hotplug state: 0x%x\n", sltsta); if (sltsta & PCI_EXP_SLTSTA_EIS) { error_setg_errno(errp, -EBUSY, "slot is electromechanically locked"); } }
1threat
static void flat_print_str(WriterContext *wctx, const char *key, const char *value) { FlatContext *flat = wctx->priv; AVBPrint buf; flat_print_key_prefix(wctx); av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED); printf("%s=", flat_escape_key_str(&buf, key, flat->sep)); av_bprint_clear(&buf); printf("\"%s\"\n", flat_escape_value_str(&buf, value)); av_bprint_finalize(&buf, NULL); }
1threat
Can anyone help me convert a table such as this example into a dynamic one in javascript by using the for loop? : ## Heading Can anyone help me learn how to convert an html table into a dynamic javascript table using the for loop?? This is an example i found in my book and wanted to see how i could go about doing this. Thank you!!!## ---------- ## Heading There are sections of the table that need to have the rows combined and he colums combined. I have been struggling with this for some time. Any help would be appreciated. I did not include the the CSS portion of the code only the table. ## ---------- <html> <body> <table class="table"> <tr> <th colspan= "3" class= "MH">Conversion Tables</th> </tr> <tr> <th rowspan="3" class="heading1">Meters to <br />Feet</th> <td>1 meter</td> <td>3.28 feet</td> </tr> <tr class="difrow"> <td>50 meters</td> <td>164.04 feet</td> </tr> <tr> <td>100 meters</td> <td>328.08 feet</td> </tr> <tr class="difrow"> <th rowspan="3" class="heading1">Kilometers to <br />Miles</th> <td>1 kilometer</td> <td>0.62 miles</td> </tr> <tr> <td>50 kilometers</td> <td>31.07 miles</td> </tr> <tr class="difrow"> <td>100 kilometers</td> <td>62.14 miles</td> </tr> </table> </body> </html>
0debug
document.write('<script src="evil.js"></script>');
1threat
Retrieve data from a json object with square brackets enclosing the value of some object : <p>I have a Jsonobject that contain some values that were an Arraylist before converting it to Jsonobject </p> <pre><code>[{"id":4,"name":"shirt","attributeName":["size"],"attributeValue":["6-7"],"attributeStock":["3"]}] </code></pre> <p>how can get attributeName &amp; attributeValue &amp; attributeStock like an Arraylist</p>
0debug
static void virtio_net_tx_bh(void *opaque) { VirtIONetQueue *q = opaque; VirtIONet *n = q->n; VirtIODevice *vdev = VIRTIO_DEVICE(n); int32_t ret; assert(vdev->vm_running); q->tx_waiting = 0; if (unlikely(!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK))) { return; } ret = virtio_net_flush_tx(q); if (ret == -EBUSY) { return; } if (ret >= n->tx_burst) { qemu_bh_schedule(q->tx_bh); q->tx_waiting = 1; return; } virtio_queue_set_notification(q->tx_vq, 1); if (virtio_net_flush_tx(q) > 0) { virtio_queue_set_notification(q->tx_vq, 0); qemu_bh_schedule(q->tx_bh); q->tx_waiting = 1; } }
1threat
Rewritre URL htaccsess using GET method : I have a page name ***detail.php*** which handle variable from ```GET``` method and the URL displayed will be like ```domain.com/detail.php?v=tEDdwXC2dkq```, but I want change it into ```domain.com/detail?v=tEDdwXC2dkq```. ***.htaccess*** ``` RewriteEngine On RewriteRule ^domain.com/detail.php?v=(.+)$ domain.com/detail?v=$1 ``` But it didnt work. Is there anything I missed?
0debug
How should i decide to choose one of collection types when I coding? : <p>Many times I avoid to use arrays, because of must be careful to work its size, and I must certainly know data type of elements. </p> <p>I notice, I usually use List, I am not sure this is necessary many times. </p> <p>I would like to know how to design code when I work with collections. </p> <p>Can someone help me to approach to collections? Thanks.</p> <pre><code> * Arrays * List and List&lt;T&gt; * Dictionary, Hashtable, Queue, Stack ...etc. * Sets </code></pre>
0debug
static av_cold int dilate_init(AVFilterContext *ctx, const char *args) { OCVContext *s = ctx->priv; DilateContext *dilate = s->priv; char default_kernel_str[] = "3x3+0x0/rect"; char *kernel_str; const char *buf = args; int ret; dilate->nb_iterations = 1; if (args) kernel_str = av_get_token(&buf, "|"); if ((ret = parse_iplconvkernel(&dilate->kernel, *kernel_str ? kernel_str : default_kernel_str, ctx)) < 0) return ret; av_free(kernel_str); sscanf(buf, "|%d", &dilate->nb_iterations); av_log(ctx, AV_LOG_VERBOSE, "iterations_nb:%d\n", dilate->nb_iterations); if (dilate->nb_iterations <= 0) { av_log(ctx, AV_LOG_ERROR, "Invalid non-positive value '%d' for nb_iterations\n", dilate->nb_iterations); return AVERROR(EINVAL); } return 0; }
1threat
Problems importing pandas.plotting : <p>When I import pandas, everything is fine and working. Yet, when I try to import something from <code>pandas.plotting</code> im getting an error. What could be the source of this? </p> <p>Here is how the output looks like:</p> <pre><code>&gt;&gt;&gt; import pandas &gt;&gt;&gt; from pandas.plotting import scatter_matrix Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; ImportError: No module named plotting </code></pre> <p>The pandas version Im using is: <code>0.19.2</code></p>
0debug
TensorFlow - regularization with L2 loss, how to apply to all weights, not just last one? : <p>I am playing with a ANN which is part of Udacity DeepLearning course.</p> <p>I have an assignment which involves introducing generalization to the network with one hidden ReLU layer using L2 loss. I wonder how to properly introduce it so that ALL weights are penalized, not only weights of the output layer.</p> <p>Code for network <em>without</em> generalization is at the bottom of the post (code to actually run the training is out of the scope of the question).</p> <p>Obvious way of introducing the L2 is to replace the loss calculation with something like this (if beta is 0.01):</p> <pre><code>loss = tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits(out_layer, tf_train_labels) + 0.01*tf.nn.l2_loss(out_weights)) </code></pre> <p>But in such case it will take into account values of output layer's weights. I am not sure, how do we properly penalize the weights which come INTO the hidden ReLU layer. Is it needed at all or introducing penalization of output layer will somehow keep the hidden weights in check also?</p> <pre><code>#some importing from __future__ import print_function import numpy as np import tensorflow as tf from six.moves import cPickle as pickle from six.moves import range #loading data pickle_file = '/home/maxkhk/Documents/Udacity/DeepLearningCourse/SourceCode/tensorflow/examples/udacity/notMNIST.pickle' with open(pickle_file, 'rb') as f: save = pickle.load(f) train_dataset = save['train_dataset'] train_labels = save['train_labels'] valid_dataset = save['valid_dataset'] valid_labels = save['valid_labels'] test_dataset = save['test_dataset'] test_labels = save['test_labels'] del save # hint to help gc free up memory print('Training set', train_dataset.shape, train_labels.shape) print('Validation set', valid_dataset.shape, valid_labels.shape) print('Test set', test_dataset.shape, test_labels.shape) #prepare data to have right format for tensorflow #i.e. data is flat matrix, labels are onehot image_size = 28 num_labels = 10 def reformat(dataset, labels): dataset = dataset.reshape((-1, image_size * image_size)).astype(np.float32) # Map 0 to [1.0, 0.0, 0.0 ...], 1 to [0.0, 1.0, 0.0 ...] labels = (np.arange(num_labels) == labels[:,None]).astype(np.float32) return dataset, labels train_dataset, train_labels = reformat(train_dataset, train_labels) valid_dataset, valid_labels = reformat(valid_dataset, valid_labels) test_dataset, test_labels = reformat(test_dataset, test_labels) print('Training set', train_dataset.shape, train_labels.shape) print('Validation set', valid_dataset.shape, valid_labels.shape) print('Test set', test_dataset.shape, test_labels.shape) #now is the interesting part - we are building a network with #one hidden ReLU layer and out usual output linear layer #we are going to use SGD so here is our size of batch batch_size = 128 #building tensorflow graph graph = tf.Graph() with graph.as_default(): # Input data. For the training data, we use a placeholder that will be fed # at run time with a training minibatch. tf_train_dataset = tf.placeholder(tf.float32, shape=(batch_size, image_size * image_size)) tf_train_labels = tf.placeholder(tf.float32, shape=(batch_size, num_labels)) tf_valid_dataset = tf.constant(valid_dataset) tf_test_dataset = tf.constant(test_dataset) #now let's build our new hidden layer #that's how many hidden neurons we want num_hidden_neurons = 1024 #its weights hidden_weights = tf.Variable( tf.truncated_normal([image_size * image_size, num_hidden_neurons])) hidden_biases = tf.Variable(tf.zeros([num_hidden_neurons])) #now the layer itself. It multiplies data by weights, adds biases #and takes ReLU over result hidden_layer = tf.nn.relu(tf.matmul(tf_train_dataset, hidden_weights) + hidden_biases) #time to go for output linear layer #out weights connect hidden neurons to output labels #biases are added to output labels out_weights = tf.Variable( tf.truncated_normal([num_hidden_neurons, num_labels])) out_biases = tf.Variable(tf.zeros([num_labels])) #compute output out_layer = tf.matmul(hidden_layer,out_weights) + out_biases #our real output is a softmax of prior result #and we also compute its cross-entropy to get our loss loss = tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits(out_layer, tf_train_labels)) #now we just minimize this loss to actually train the network optimizer = tf.train.GradientDescentOptimizer(0.5).minimize(loss) #nice, now let's calculate the predictions on each dataset for evaluating the #performance so far # Predictions for the training, validation, and test data. train_prediction = tf.nn.softmax(out_layer) valid_relu = tf.nn.relu( tf.matmul(tf_valid_dataset, hidden_weights) + hidden_biases) valid_prediction = tf.nn.softmax( tf.matmul(valid_relu, out_weights) + out_biases) test_relu = tf.nn.relu( tf.matmul( tf_test_dataset, hidden_weights) + hidden_biases) test_prediction = tf.nn.softmax(tf.matmul(test_relu, out_weights) + out_biases) </code></pre>
0debug
static int get_bool(QEMUFile *f, void *pv, size_t size) { bool *v = pv; *v = qemu_get_byte(f); return 0; }
1threat
static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features, uint32_t *ext_features, uint32_t *ext2_features, uint32_t *ext3_features) { int i; int found = 0; for ( i = 0 ; i < 32 ; i++ ) if (feature_name[i] && !strcmp (flagname, feature_name[i])) { *features |= 1 << i; found = 1; } for ( i = 0 ; i < 32 ; i++ ) if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) { *ext_features |= 1 << i; found = 1; } for ( i = 0 ; i < 32 ; i++ ) if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) { *ext2_features |= 1 << i; found = 1; } for ( i = 0 ; i < 32 ; i++ ) if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) { *ext3_features |= 1 << i; found = 1; } if (!found) { fprintf(stderr, "CPU feature %s not found\n", flagname); } }
1threat
int spapr_tce_dma_write(VIOsPAPRDevice *dev, uint64_t taddr, const void *buf, uint32_t size) { #ifdef DEBUG_TCE fprintf(stderr, "spapr_tce_dma_write taddr=0x%llx size=0x%x\n", (unsigned long long)taddr, size); #endif if (dev->flags & VIO_PAPR_FLAG_DMA_BYPASS) { cpu_physical_memory_write(taddr, buf, size); return 0; } while (size) { uint64_t tce; uint32_t lsize; uint64_t txaddr; if (taddr >= dev->rtce_window_size) { #ifdef DEBUG_TCE fprintf(stderr, "spapr_tce_dma_write out of bounds\n"); #endif return H_DEST_PARM; } tce = dev->rtce_table[taddr >> SPAPR_VIO_TCE_PAGE_SHIFT].tce; lsize = MIN(size, ((~taddr) & SPAPR_VIO_TCE_PAGE_MASK) + 1); if (!(tce & 2)) { return H_DEST_PARM; } txaddr = (tce & ~SPAPR_VIO_TCE_PAGE_MASK) | (taddr & SPAPR_VIO_TCE_PAGE_MASK); #ifdef DEBUG_TCE fprintf(stderr, " -> write to txaddr=0x%llx, size=0x%x\n", (unsigned long long)txaddr, lsize); #endif cpu_physical_memory_write(txaddr, buf, lsize); buf += lsize; taddr += lsize; size -= lsize; } return 0; }
1threat
VBA to get custom data in excel. : I want to get data from this website into excel. website: http://smsprank.ga/true/pro.php?no=62390012XX (replace xx with number) https://ibb.co/bFgtF9- I can do this in excel by data>from website. but I want to get 100s of numbers or URL which I have in excel, how do I automate this in excel VBA?
0debug
static inline int decode_picture_parameter_set(H264Context *h, int bit_length){ MpegEncContext * const s = &h->s; unsigned int tmp, pps_id= get_ue_golomb(&s->gb); PPS *pps; pps = alloc_parameter_set(h, (void **)h->pps_buffers, pps_id, MAX_PPS_COUNT, sizeof(PPS), "pps"); if(pps == NULL) return -1; tmp= get_ue_golomb(&s->gb); if(tmp>=MAX_SPS_COUNT || h->sps_buffers[tmp] == NULL){ av_log(h->s.avctx, AV_LOG_ERROR, "sps_id out of range\n"); return -1; } pps->sps_id= tmp; pps->cabac= get_bits1(&s->gb); pps->pic_order_present= get_bits1(&s->gb); pps->slice_group_count= get_ue_golomb(&s->gb) + 1; if(pps->slice_group_count > 1 ){ pps->mb_slice_group_map_type= get_ue_golomb(&s->gb); av_log(h->s.avctx, AV_LOG_ERROR, "FMO not supported\n"); switch(pps->mb_slice_group_map_type){ case 0: #if 0 | for( i = 0; i <= num_slice_groups_minus1; i++ ) | | | | run_length[ i ] |1 |ue(v) | #endif break; case 2: #if 0 | for( i = 0; i < num_slice_groups_minus1; i++ ) | | | |{ | | | | top_left_mb[ i ] |1 |ue(v) | | bottom_right_mb[ i ] |1 |ue(v) | | } | | | #endif break; case 3: case 4: case 5: #if 0 | slice_group_change_direction_flag |1 |u(1) | | slice_group_change_rate_minus1 |1 |ue(v) | #endif break; case 6: #if 0 | slice_group_id_cnt_minus1 |1 |ue(v) | | for( i = 0; i <= slice_group_id_cnt_minus1; i++ | | | |) | | | | slice_group_id[ i ] |1 |u(v) | #endif break; } } pps->ref_count[0]= get_ue_golomb(&s->gb) + 1; pps->ref_count[1]= get_ue_golomb(&s->gb) + 1; if(pps->ref_count[0]-1 > 32-1 || pps->ref_count[1]-1 > 32-1){ av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n"); pps->ref_count[0]= pps->ref_count[1]= 1; return -1; } pps->weighted_pred= get_bits1(&s->gb); pps->weighted_bipred_idc= get_bits(&s->gb, 2); pps->init_qp= get_se_golomb(&s->gb) + 26; pps->init_qs= get_se_golomb(&s->gb) + 26; pps->chroma_qp_index_offset[0]= get_se_golomb(&s->gb); pps->deblocking_filter_parameters_present= get_bits1(&s->gb); pps->constrained_intra_pred= get_bits1(&s->gb); pps->redundant_pic_cnt_present = get_bits1(&s->gb); pps->transform_8x8_mode= 0; h->dequant_coeff_pps= -1; memcpy(pps->scaling_matrix4, h->sps_buffers[pps->sps_id]->scaling_matrix4, sizeof(pps->scaling_matrix4)); memcpy(pps->scaling_matrix8, h->sps_buffers[pps->sps_id]->scaling_matrix8, sizeof(pps->scaling_matrix8)); if(get_bits_count(&s->gb) < bit_length){ pps->transform_8x8_mode= get_bits1(&s->gb); decode_scaling_matrices(h, h->sps_buffers[pps->sps_id], pps, 0, pps->scaling_matrix4, pps->scaling_matrix8); pps->chroma_qp_index_offset[1]= get_se_golomb(&s->gb); } else { pps->chroma_qp_index_offset[1]= pps->chroma_qp_index_offset[0]; } build_qp_table(pps, 0, pps->chroma_qp_index_offset[0]); build_qp_table(pps, 1, pps->chroma_qp_index_offset[1]); if(pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1]) h->pps.chroma_qp_diff= 1; if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(h->s.avctx, AV_LOG_DEBUG, "pps:%u sps:%u %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d/%d %s %s %s %s\n", pps_id, pps->sps_id, pps->cabac ? "CABAC" : "CAVLC", pps->slice_group_count, pps->ref_count[0], pps->ref_count[1], pps->weighted_pred ? "weighted" : "", pps->init_qp, pps->init_qs, pps->chroma_qp_index_offset[0], pps->chroma_qp_index_offset[1], pps->deblocking_filter_parameters_present ? "LPAR" : "", pps->constrained_intra_pred ? "CONSTR" : "", pps->redundant_pic_cnt_present ? "REDU" : "", pps->transform_8x8_mode ? "8x8DCT" : "" ); } return 0; }
1threat
Merging dataframes on an index is more efficient in Pandas : <p>Why is merging dataframes in Pandas on an index more efficient (faster) than on a column? </p> <pre class="lang-py prettyprint-override"><code>import pandas as pd # Dataframes share the ID column df = pd.DataFrame({'ID': [0, 1, 2, 3, 4], 'Job': ['teacher', 'scientist', 'manager', 'teacher', 'nurse']}) df2 = pd.DataFrame({'ID': [2, 3, 4, 5, 6, 7, 8], 'Level': [12, 15, 14, 20, 21, 11, 15], 'Age': [33, 41, 42, 50, 45, 28, 32]}) </code></pre> <p><a href="https://i.stack.imgur.com/SZ8pV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SZ8pV.png" alt="enter image description here"></a></p> <pre class="lang-py prettyprint-override"><code>df = df.set_index('ID') df2 = df2.set_index('ID') </code></pre> <p><a href="https://i.stack.imgur.com/NaXvo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NaXvo.png" alt="enter image description here"></a></p> <p>This represents about a 3.5 times speed up! (Using Pandas 0.23.0) </p> <p>Reading through the <a href="https://pandas.pydata.org/pandas-docs/stable/internals.html" rel="noreferrer">Pandas internals page</a> it says an Index "Populates a dict of label to location in Cython to do O(1) lookups." Does this mean that doing operations with an index is more efficient than with columns? Is it a best practice to always use the index for operations such as merges? </p> <p>I read through the <a href="https://pandas.pydata.org/pandas-docs/stable/merging.html#database-style-dataframe-joining-merging" rel="noreferrer">documentation for joining and merging</a> and it doesn't explicitly mention any benefits to using the index. </p>
0debug
PHP parameter variable vs reference : <p>What is the difference between in php function </p> <ul> <li>A parameter passage by <strong>variable</strong></li> <li>A parameter pass by <strong>reference</strong>?</li> </ul>
0debug
Removing things from a list correctally : I am currently working on making an [Akinator][1]-like game that currently only does Zelda Breath of the Wild species. For some reason, when I enter all of the information for coocoo, the output is Gerudo. Please help. Here is the code: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> class Thing(): # The general class for a object def __init__(self, area, race, ally, living, extra): self.area = area self.race = race self.ally = ally self.living = living self.extra = extra class Guess(): # The class for the guess def __init__(self): self.area = None self.race = None self.ally = bool self.living = bool self.extra = str talus = Thing("everywhere", "talus", False, True, " rocky") coocoo = Thing("everywhere", "coocoo", True, True, " a fierce, chicken-like friend") zora = Thing("in the zora area", "zora", True, True, " swimming") rito = Thing("in the rito area", "rito", True, True, " flying") goron = Thing("in the goron area", "goron", True, True, " rolling") gerudo = Thing("in the gerudo area", "gerudo", True, True, " a women") hylean = Thing("everywhere", "hylean", True, True, " good and bad") guardian = Thing("everywhere", "guardian", False, False, " mechanical") moblin = Thing("everywhere", "moblin", False, True, " related to the bokoblin") staloblin = Thing("everywhere", "staloblin", False, False, " a large undead enemy") bokoblin = Thing("everywhere", "bokoblin", False, True, " a basic enemy") stalkoblin = Thing("everywhere", "stalkoblin", False, False, " a basic undead enemy") lynel = Thing("everywhere", "lynel", False, True, " a horse-like beast") octorok = Thing("everywhere", "octorok", False, True, " a rock-shooting monster") lizafos = Thing("everywhere", "lizafos", False, True, " a scaley, speeding, baddie") stalzafos = Thing("everywhere", "stalzafos", False, False, " a fast, skeletal enemy") spirit = Thing("everywhere", "spirit", True, False, " a helpful ghost") def akinator(): everything = [talus, zora, rito, goron, gerudo, hylean, guardian, moblin, stalkoblin, staloblin, bokoblin, lynel, octorok, lizafos, stalzafos, spirit, coocoo] possible_areas = ["everywhere", "in the zora area", "in the rito area", "in the goron area", "in the gerudo area", "in the hylean greenlands"] guess = Guess() alive = input("Is it alive? y/n ") if alive == "n": guess.living = False elif alive == "y": guess.living = True for i in everything: if i.living != guess.living: everything.pop(everything.index(i)) ally = input("Is it one of your allies? y/n ") if ally == "n": guess.ally = False elif ally == "y": guess.ally = True for i in everything: if i.ally != guess.ally: everything.pop(everything.index(i)) for i in possible_areas: area = input("Do they live " + i + "? y/n ") if area == "y": guess.area = i break for i in everything: if i.area != guess.area: everything.pop(everything.index(i)) for i in everything: extra = input("Is it" + i.extra + "? y/n ") if extra == "n": everything.pop(everything.index(i)) if extra == "y": print("Is it a "+ i.race +"?") quit() print("Is it a "+everything[0].race+"?") akinator() <!-- end snippet --> Thank you in advance. [1]: http://en.akinator.com/
0debug
uiautomatorviewer - Error: Could not create the Java Virtual Machine : <p>I am trying to run <code>uiautomatorviewer</code> in terminal. I am getting this error:</p> <pre><code>-Djava.ext.dirs=/Users/&lt;Username&gt;/Library/Android/sdk/tools/lib/x86_64:/Users/&lt;Username&gt;/Library/Android/sdk/tools/lib is not supported. Use -classpath instead. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. </code></pre> <p>I think this might be related to the java version I am using. Here is the output of <code>java -version</code>:</p> <pre><code>java version "10" 2018-03-20 Java(TM) SE Runtime Environment 18.3 (build 10+46) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode) </code></pre> <p>I have already seen <a href="https://stackoverflow.com/questions/47029810/uiautomatorviewer-could-not-create-java-virtual-machine">this question on SO</a>, but it recommends downgrading to java 8.</p> <p>Am I missing anything here? I would appreciate any help.</p>
0debug
static void dbdma_writel (void *opaque, target_phys_addr_t addr, uint32_t value) { int channel = addr >> DBDMA_CHANNEL_SHIFT; DBDMA_channel *ch = (DBDMA_channel *)opaque + channel; int reg = (addr - (channel << DBDMA_CHANNEL_SHIFT)) >> 2; DBDMA_DPRINTF("writel 0x" TARGET_FMT_plx " <= 0x%08x\n", addr, value); DBDMA_DPRINTF("channel 0x%x reg 0x%x\n", (uint32_t)addr >> DBDMA_CHANNEL_SHIFT, reg); if (reg == DBDMA_CMDPTR_LO && (ch->regs[DBDMA_STATUS] & cpu_to_be32(RUN | ACTIVE))) return; ch->regs[reg] = value; switch(reg) { case DBDMA_CONTROL: dbdma_control_write(ch); break; case DBDMA_CMDPTR_LO: ch->regs[DBDMA_CMDPTR_LO] &= cpu_to_be32(~0xf); dbdma_cmdptr_load(ch); break; case DBDMA_STATUS: case DBDMA_INTR_SEL: case DBDMA_BRANCH_SEL: case DBDMA_WAIT_SEL: break; case DBDMA_XFER_MODE: case DBDMA_CMDPTR_HI: case DBDMA_DATA2PTR_HI: case DBDMA_DATA2PTR_LO: case DBDMA_ADDRESS_HI: case DBDMA_BRANCH_ADDR_HI: case DBDMA_RES1: case DBDMA_RES2: case DBDMA_RES3: case DBDMA_RES4: break; } }
1threat
static int decorrelate(TAKDecContext *s, int c1, int c2, int length) { GetBitContext *gb = &s->gb; int32_t *p1 = s->decoded[c1] + 1; int32_t *p2 = s->decoded[c2] + 1; int i; int dshift, dfactor; switch (s->dmode) { case 1: for (i = 0; i < length; i++) { int32_t a = p1[i]; int32_t b = p2[i]; p2[i] = a + b; } break; case 2: for (i = 0; i < length; i++) { int32_t a = p1[i]; int32_t b = p2[i]; p1[i] = b - a; } break; case 3: for (i = 0; i < length; i++) { int32_t a = p1[i]; int32_t b = p2[i]; a -= b >> 1; p1[i] = a; p2[i] = a + b; } break; case 4: FFSWAP(int32_t*, p1, p2); case 5: dshift = get_bits_esc4(gb); dfactor = get_sbits(gb, 10); for (i = 0; i < length; i++) { int32_t a = p1[i]; int32_t b = p2[i]; b = dfactor * (b >> dshift) + 128 >> 8 << dshift; p1[i] = b - a; } break; case 6: FFSWAP(int32_t*, p1, p2); case 7: { int length2, order_half, filter_order, dval1, dval2; int tmp, x, code_size; if (length < 256) return AVERROR_INVALIDDATA; dshift = get_bits_esc4(gb); filter_order = 8 << get_bits1(gb); dval1 = get_bits1(gb); dval2 = get_bits1(gb); AV_ZERO128(s->filter + 8); for (i = 0; i < filter_order; i++) { if (!(i & 3)) code_size = 14 - get_bits(gb, 3); s->filter[i] = get_sbits(gb, code_size); } order_half = filter_order / 2; length2 = length - (filter_order - 1); if (dval1) { for (i = 0; i < order_half; i++) { int32_t a = p1[i]; int32_t b = p2[i]; p1[i] = a + b; } } if (dval2) { for (i = length2 + order_half; i < length; i++) { int32_t a = p1[i]; int32_t b = p2[i]; p1[i] = a + b; } } for (i = 0; i < filter_order; i++) s->residues[i] = *p2++ >> dshift; p1 += order_half; x = FF_ARRAY_ELEMS(s->residues) - filter_order; for (; length2 > 0; length2 -= tmp) { tmp = FFMIN(length2, x); for (i = 0; i < tmp; i++) s->residues[filter_order + i] = *p2++ >> dshift; for (i = 0; i < tmp; i++) { int v = 1 << 9; v += s->adsp.scalarproduct_int16(&s->residues[i], s->filter, 16); v = (av_clip_intp2(v >> 10, 13) << dshift) - *p1; *p1++ = v; } memcpy(s->residues, &s->residues[tmp], 2 * filter_order); } emms_c(); break; } } return 0; }
1threat
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
java check Operating System : <p>Is it possible to check the current Operating System with Java? I want my program to do something different on Linux.</p> <p><strong>Something like that</strong> </p> <pre><code>if(os == Linux) { </code></pre> <p>...</p> <p>}</p>
0debug
static void xtensa_lx60_init(MachineState *machine) { static const LxBoardDesc lx60_board = { .flash_base = 0xf8000000, .flash_size = 0x00400000, .flash_sector_size = 0x10000, .sram_size = 0x20000, }; lx_init(&lx60_board, machine); }
1threat
Need to convert information from textarea to table : <p>I would like know, is it possible to convert this type of information</p> <blockquote> <p>1 AA 146O 07JUL BOSCDG SS1 645P 740A+* TH/FR E<br> 2 AA 147O 18JUL CDGBOS SS1 1040A 1245P * MO E<br> ></p> </blockquote> <p>to this kind table <a href="https://i.stack.imgur.com/RAe6i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RAe6i.png" alt="enter image description here"></a></p> <p>This is a flight ticket which is building in program Galileo, i would like to convert this info to understandable flight quote. How it's can be done. I know how to make it if i will enter everything separately, but is it possible to split and convert in one click?</p> <p>Any ideas how it can be done?</p>
0debug
Why does my python code write random symbols on the write() function PYTHON 2.7 : I have this python code: f = open("database.txt", "r+") f.write("Hello!") print f.read() f.close() and when I run the code the idle shows me: -t But when I see the database.txt file this is whats inside: Hello!t stdouts #007700t stderrc   C s | | _ d | _ d S( N( R4 R* t owin( R R4 ( ( s' C:\Python27\lib\idlelib\OutputWindow.pyR … s  c   C s0 | j s | j ƒ n | j j | | | ƒ d S( N( RP t setupR ( R R R R ( ( s' C:\Python27\lib\idlelib\OutputWindow.pyR ‰ s   c   C sx t | j ƒ | _ } | j } x6 | j j ƒ D]% \ } } | r/ | j | |  q/ q/ W| j d ƒ | j j | _ d S( Nt sel( R R4 RP R t tagdefst itemst tag_configuret tag_raiseR ( R RP R t tagt cnf( ( s' C:\Python27\lib\idlelib\OutputWindow.pyRQ Ž s   ( RG RH RS R R RQ ( ( ( s' C:\Python27\lib\idlelib\OutputWindow.pyRK } s   ( ( t Tkintert idlelib.EditorWindowR R- R2 t idlelibR R RK ( ( ( s' C:\Python27\lib\idlelib\OutputWindow.pyt <module> s   vWindow.pyt short_title s c   C s | j ƒ r d Sd Sd S( Nt yest no( t get_saved( R ( ( s' C:\Python27\lib\idlelib\OutputWindow.pyt maybesave s  t insertc   C ss t | t ƒ r< y t | t j ƒ } Wq< t k r8 q< Xn | j j | | | ƒ | j j | ƒ | j j ƒ d S( N( t isinstancet strt unicodeR t encodingt UnicodeErrorR R t seet update( R t st tagst mark( ( s' C:\Python27\lib\idlelib\OutputWindow.pyt write% s  c   C s" x | D] } | j | ƒ q Wd S( N( R ( R t linest line( ( s' C:\Python27\lib\idlelib\OutputWindow.pyt writelines2 s  c   C s d S( N( ( R ( ( s' C:\Python27\lib\idlelib\OutputWindow.pyt flush6 s t Cuts <<cut>>t rmenu_check_cutt Copys <<copy>>t rmenu_check_copyt Pastes <<paste>>t rmenu_check_pastes Go to file/lines <<goto-file-line>>s file "([^"]*)", line (\d+)s ([^\s]+)\((\d+)\)s ^(\s*\S.*?):\s*(\d+):s ([^\s]+):\s*(\d+):s ^\s*(\S.*?):\s*(\d+):c  C sô | j d k rQ g } x- | j D]" } | j t j | t j ƒ ƒ q W| | _ n | j j d d ƒ } | j | ƒ } | sÅ | j j d d ƒ } | j | ƒ } | sÅ t j d d d | j ƒd Sn | \ } } | j j | ƒ } | j | ƒ d S( Ns insert linestarts insert lineends insert -1line linestarts insert -1line lineends No special linesT The line you point at doesn't look like a valid file name followed by a line number.t parent( t file_line_progst Nonet file_line_patst appendt ret compilet IGNORECASER t gett _file_line_helpert tkMessageBoxt showerrort flistt opent gotoline( R t eventt lt patR t resultR t linenot edit( ( s' C:\Python27\lib\idlelib\OutputWindow.pyR N s(       c   C sª xz | j D]k } | j | ƒ } | r | j d d ƒ \ } } y t | d ƒ } | j ƒ PWqu t k rq q qu Xq q Wd Sy | t | ƒ f SWn t k r¥ d SXd S( Ni i t r( R) t searcht groupR5 t closet IOErrorR* t intt TypeError( R R t progt matchR R; t f( ( s' C:\Python27\lib\idlelib\OutputWindow.pyR1 i s    ( ( R" s <<cut>>R# ( R$ s <<copy>>R% ( R& s <<paste>>R' N( NNN( s Go to file/lines <<goto-file-line>>N( t __name__t __module__t __doc__R R R R R R R! R* t rmenu_specsR+ R) R R1 ( ( ( s' C:\Python27\lib\idlelib\OutputWindow.pyR  s*          t OnDemandOutputWindowc  B sE e Z i i d d 6d 6i d d 6d 6Z d „ Z d „ Z d „ Z RS( t bluet fore
0debug
static av_cold int xvid_encode_close(AVCodecContext *avctx) { struct xvid_context *x = avctx->priv_data; xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL); if( avctx->extradata != NULL ) av_free(avctx->extradata); if( x->twopassbuffer != NULL ) { av_free(x->twopassbuffer); av_free(x->old_twopassbuffer); } if( x->twopassfile != NULL ) av_free(x->twopassfile); if( x->intra_matrix != NULL ) av_free(x->intra_matrix); if( x->inter_matrix != NULL ) av_free(x->inter_matrix); return 0; }
1threat
Ho to access R.java programmtically : How to access R.java programmatically? I know the path to R.java class on the C: drive but I want to access it programmatically in Android, can I access R.java using either of `Environment.getExternalStorageDirectory()` or `openFileInput`
0debug
try - catch with syntax error : <pre><code>try { $stmt = $db-&gt;query('SELECT title FROM never-ending-book'); while($row = $stmt-&gt;fetch()){ echo '&lt;div class="lev3"&gt;'.$row['title'].'&lt;/div&gt;'; } }catch(PDOException $e) { echo $e-&gt;getMessage(); }; </code></pre> <p>result: </p> <pre><code>SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-ending-book' at line 1 </code></pre> <p>Where is the syntax error and why is <code>never-ending-book</code> become <code>near'-ending-book</code>?</p>
0debug
*ngIf not working as expected with observable : <p>So I have these 2 buttons:</p> <pre><code>&lt;a class="router-link nav-item" routerLink="/login" *ngIf="!isLoggedIn$ | async"&gt; Login &lt;/a&gt; &lt;a class="router-link nav-item" (click)="onLogout()" *ngIf="isLoggedIn$ | async"&gt; Logout &lt;/a&gt; </code></pre> <p>And the logout button works perfectly, as soon as the user is logged in the button appears. But the login button never appears.</p> <p>This is the code behind the <code>isLoggedIn$</code>:</p> <pre><code>isLoggedIn$: Observable&lt;boolean&gt;; ngOnInit() { this.isLoggedIn$ = this.authService.isLoggedIn; } </code></pre> <p>AuthService:</p> <pre><code>private loggedIn = new BehaviorSubject&lt;boolean&gt;(false); get isLoggedIn() { return this.loggedIn.asObservable(); } </code></pre> <p>Hope this is enough information and the problem is clear, thanks in advance!</p>
0debug
Kivy (Python) TypeError: expected string or buffer : <p>I am new to Kivy and I am trying to make an App that count words in a string and display the number of words on a new popup , And I keep getting this error message even with using str() . Type-error: expected string or buffer Here is the code :</p> <pre><code>from kivy.app import App from kivy.uix.popup import Popup from kivy.uix.label import Label from kivy.uix.boxlayout import BoxLayout import re class CountRoot(BoxLayout): def clk(self, text_input): text = Label(text="Hello, {}!".format(text_input)) res = re.findall("(\S+)", text) nw = Popup(title="Our Title!", content=res,size_hint=(.7, .7)) nw.open() class CountApp(App): def build(self): return CountRoot() if __name__ == "__main__": CountApp().run() </code></pre> <p>Here is the kivy file : </p> <pre><code>&lt;CountRoot&gt;: orientation: "vertical" padding: root.width * .02, root.height * .02 spacing: "10dp" TextInput: id: text_input hint_text: "Enter Text" font_size: "30dp" Button: text: "Press Me" on_release: root.clk(text_input.text) </code></pre>
0debug
array_search doesn't work on a nested array : <pre><code>$needle = 'foo'; $haystack = [ 'bar' =&gt; [ 'foo' ], 'baz' =&gt; [ 'qux' ] ]; // if 'foo' in of the arrays of $haystack, return its key // in this case its 'bar' </code></pre> <p><code>array_search</code> seems to work on simple arrays. What do I need for my case?</p>
0debug
Can react js web code be used for building mobile apps using react native? : <p>I am working on a pet project ( web application ) and I was wondering if I should use react because it would be easy to create native apps from this code (in future if I need to).</p> <ul> <li><p>And if the answer is yes, what are the best practices to follow for most resuse?</p></li> <li><p>If the answer is no, can you recommend an alternative?</p></li> </ul> <p><strong>Some more information about my situation.</strong></p> <p>I am relatively new to react and my alternative will be good ol' html with bootstrap and jquery. I am considering using asp.net mvc and web api.</p>
0debug
How to call REST from jenkins workflow : <p>I wonder how to call REST API from a (groovy) Jenkins workflow script. I can execute "sh 'curl -X POST ...'" - it works, but building the request as a curl command is cumbersome and processing the response gets complicated. I'd prefer a native Groovy HTTP Client to program in groovy - which one should I start with? As the script is run in Jenkins, there is the step of copying all needed dependency jars to the groovy installation on Jenkins, so something light-weight would be appreciated.</p>
0debug
int vnc_display_open(DisplayState *ds, const char *display) { VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display; const char *options; int password = 0; int reverse = 0; int to_port = 0; #ifdef CONFIG_VNC_TLS int tls = 0, x509 = 0; #endif if (!vnc_display) return -1; vnc_display_close(ds); if (strcmp(display, "none") == 0) return 0; if (!(vs->display = strdup(display))) return -1; options = display; while ((options = strchr(options, ','))) { options++; if (strncmp(options, "password", 8) == 0) { password = 1; } else if (strncmp(options, "reverse", 7) == 0) { reverse = 1; } else if (strncmp(options, "to=", 3) == 0) { to_port = atoi(options+3) + 5900; #ifdef CONFIG_VNC_TLS } else if (strncmp(options, "tls", 3) == 0) { tls = 1; } else if (strncmp(options, "x509", 4) == 0) { char *start, *end; x509 = 1; if (strncmp(options, "x509verify", 10) == 0) vs->tls.x509verify = 1; start = strchr(options, '='); end = strchr(options, ','); if (start && (!end || (start < end))) { int len = end ? end-(start+1) : strlen(start+1); char *path = qemu_strndup(start + 1, len); VNC_DEBUG("Trying certificate path '%s'\n", path); if (vnc_tls_set_x509_creds_dir(vs, path) < 0) { fprintf(stderr, "Failed to find x509 certificates/keys in %s\n", path); qemu_free(path); qemu_free(vs->display); vs->display = NULL; return -1; } qemu_free(path); } else { fprintf(stderr, "No certificate path provided\n"); qemu_free(vs->display); vs->display = NULL; return -1; } #endif } } if (password) { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509VNC; } else { VNC_DEBUG("Initializing VNC server with TLS password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSVNC; } } else { #endif VNC_DEBUG("Initializing VNC server with password auth\n"); vs->auth = VNC_AUTH_VNC; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif } else { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509NONE; } else { VNC_DEBUG("Initializing VNC server with TLS no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSNONE; } } else { #endif VNC_DEBUG("Initializing VNC server with no auth\n"); vs->auth = VNC_AUTH_NONE; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif } if (reverse) { if (strncmp(display, "unix:", 5) == 0) vs->lsock = unix_connect(display+5); else vs->lsock = inet_connect(display, SOCK_STREAM); if (-1 == vs->lsock) { free(vs->display); vs->display = NULL; return -1; } else { int csock = vs->lsock; vs->lsock = -1; vnc_connect(vs, csock); } return 0; } else { char *dpy; dpy = qemu_malloc(256); if (strncmp(display, "unix:", 5) == 0) { pstrcpy(dpy, 256, "unix:"); vs->lsock = unix_listen(display+5, dpy+5, 256-5); } else { vs->lsock = inet_listen(display, dpy, 256, SOCK_STREAM, 5900); } if (-1 == vs->lsock) { free(dpy); return -1; } else { free(vs->display); vs->display = dpy; } } return qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_read, NULL, vs); }
1threat
Code Igniter authentication library : <p>I just learn new Code Igniter, look for login with register and authentication so I could get user group role like admin and member and other. </p> <p>I would like to know what is the best Code Igniter authentication library which fits my requirements. </p> <p>Anyone could help me with this?</p> <p>Thanks</p>
0debug
void qio_dns_resolver_lookup_async(QIODNSResolver *resolver, SocketAddressLegacy *addr, QIOTaskFunc func, gpointer opaque, GDestroyNotify notify) { QIOTask *task; struct QIODNSResolverLookupData *data = g_new0(struct QIODNSResolverLookupData, 1); data->addr = QAPI_CLONE(SocketAddressLegacy, addr); task = qio_task_new(OBJECT(resolver), func, opaque, notify); qio_task_run_in_thread(task, qio_dns_resolver_lookup_worker, data, qio_dns_resolver_lookup_data_free); }
1threat
static int flac_read_header(AVFormatContext *s, AVFormatParameters *ap) { int ret, metadata_last=0, metadata_type, metadata_size, found_streaminfo=0; uint8_t header[4]; uint8_t *buffer=NULL; AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_FLAC; st->need_parsing = AVSTREAM_PARSE_FULL; if (avio_rl32(s->pb) != MKTAG('f','L','a','C')) { avio_seek(s->pb, -4, SEEK_CUR); return 0; } while (!s->pb->eof_reached && !metadata_last) { avio_read(s->pb, header, 4); avpriv_flac_parse_block_header(header, &metadata_last, &metadata_type, &metadata_size); switch (metadata_type) { case FLAC_METADATA_TYPE_STREAMINFO: case FLAC_METADATA_TYPE_CUESHEET: case FLAC_METADATA_TYPE_VORBIS_COMMENT: buffer = av_mallocz(metadata_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!buffer) { return AVERROR(ENOMEM); } if (avio_read(s->pb, buffer, metadata_size) != metadata_size) { av_freep(&buffer); return AVERROR(EIO); } break; default: ret = avio_skip(s->pb, metadata_size); if (ret < 0) return ret; } if (metadata_type == FLAC_METADATA_TYPE_STREAMINFO) { FLACStreaminfo si; if (found_streaminfo) { av_freep(&buffer); return AVERROR_INVALIDDATA; } if (metadata_size != FLAC_STREAMINFO_SIZE) { av_freep(&buffer); return AVERROR_INVALIDDATA; } found_streaminfo = 1; st->codec->extradata = buffer; st->codec->extradata_size = metadata_size; buffer = NULL; avpriv_flac_parse_streaminfo(st->codec, &si, st->codec->extradata); if (si.samplerate > 0) { avpriv_set_pts_info(st, 64, 1, si.samplerate); if (si.samples > 0) st->duration = si.samples; } } else if (metadata_type == FLAC_METADATA_TYPE_CUESHEET) { uint8_t isrc[13]; uint64_t start; const uint8_t *offset; int i, j, chapters, track, ti; if (metadata_size < 431) return AVERROR_INVALIDDATA; offset = buffer + 395; chapters = bytestream_get_byte(&offset) - 1; if (chapters <= 0) return AVERROR_INVALIDDATA; for (i = 0; i < chapters; i++) { if (offset + 36 - buffer > metadata_size) return AVERROR_INVALIDDATA; start = bytestream_get_be64(&offset); track = bytestream_get_byte(&offset); bytestream_get_buffer(&offset, isrc, 12); isrc[12] = 0; offset += 14; ti = bytestream_get_byte(&offset); if (ti <= 0) return AVERROR_INVALIDDATA; for (j = 0; j < ti; j++) offset += 12; avpriv_new_chapter(s, track, st->time_base, start, AV_NOPTS_VALUE, isrc); } } else { if (!found_streaminfo) { av_freep(&buffer); return AVERROR_INVALIDDATA; } if (metadata_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) { if (ff_vorbis_comment(s, &s->metadata, buffer, metadata_size)) { av_log(s, AV_LOG_WARNING, "error parsing VorbisComment metadata\n"); } } av_freep(&buffer); } } return 0; }
1threat
int64_t bdrv_get_block_status_above(BlockDriverState *bs, BlockDriverState *base, int64_t sector_num, int nb_sectors, int *pnum) { Coroutine *co; BdrvCoGetBlockStatusData data = { .bs = bs, .base = base, .sector_num = sector_num, .nb_sectors = nb_sectors, .pnum = pnum, .done = false, }; if (qemu_in_coroutine()) { bdrv_get_block_status_above_co_entry(&data); } else { AioContext *aio_context = bdrv_get_aio_context(bs); co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry); qemu_coroutine_enter(co, &data); while (!data.done) { aio_poll(aio_context, true); } } return data.ret; }
1threat
static void simple_string(void) { int i; struct { const char *encoded; const char *decoded; } test_cases[] = { { "\"hello world\"", "hello world" }, { "\"the quick brown fox jumped over the fence\"", "the quick brown fox jumped over the fence" }, {} }; for (i = 0; test_cases[i].encoded; i++) { QObject *obj; QString *str; obj = qobject_from_json(test_cases[i].encoded); g_assert(obj != NULL); g_assert(qobject_type(obj) == QTYPE_QSTRING); str = qobject_to_qstring(obj); g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0); str = qobject_to_json(obj); g_assert(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0); qobject_decref(obj); QDECREF(str); } }
1threat
av_cold void swri_resample_dsp_x86_init(ResampleContext *c) { int av_unused mm_flags = av_get_cpu_flags(); switch(c->format){ case AV_SAMPLE_FMT_S16P: if (ARCH_X86_32 && EXTERNAL_MMXEXT(mm_flags)) { c->dsp.resample = c->linear ? ff_resample_linear_int16_mmxext : ff_resample_common_int16_mmxext; } if (EXTERNAL_SSE2(mm_flags)) { c->dsp.resample = c->linear ? ff_resample_linear_int16_sse2 : ff_resample_common_int16_sse2; } if (EXTERNAL_XOP(mm_flags)) { c->dsp.resample = c->linear ? ff_resample_linear_int16_xop : ff_resample_common_int16_xop; } break; case AV_SAMPLE_FMT_FLTP: if (EXTERNAL_SSE(mm_flags)) { c->dsp.resample = c->linear ? ff_resample_linear_float_sse : ff_resample_common_float_sse; } if (EXTERNAL_AVX(mm_flags)) { c->dsp.resample = c->linear ? ff_resample_linear_float_avx : ff_resample_common_float_avx; } if (EXTERNAL_FMA3(mm_flags)) { c->dsp.resample = c->linear ? ff_resample_linear_float_fma3 : ff_resample_common_float_fma3; } if (EXTERNAL_FMA4(mm_flags)) { c->dsp.resample = c->linear ? ff_resample_linear_float_fma4 : ff_resample_common_float_fma4; } break; case AV_SAMPLE_FMT_DBLP: if (EXTERNAL_SSE2(mm_flags)) { c->dsp.resample = c->linear ? ff_resample_linear_double_sse2 : ff_resample_common_double_sse2; } break; } }
1threat
Why the statements oDiv[i].style.z-index = arr[i][3]; didn't work? : <p>I had consoled arr[i][3] and I'm sure that it was absolutely correct,else,others statements worked and I don't know why. The code was listed as follows</p> <pre><code> for(var i = 0; i&lt;oDiv.length;i++){ arr.push([getAttr(oDiv[i],"left"),getAttr(oDiv[i],"top"), getAttr(oDiv[i],"opacity"),getAttr(oDiv[i],"z-index")]); //console.log(arr); it shows a correct value; } oBtn[0].onclick = function(){ arr.unshift(arr[arr.length-1]); arr.pop(); for (var i = 0; i&lt;arr.length; i++) { oDiv[i].style.left = arr[i][0]; oDiv[i].style.top = arr[i][1]; oDiv[i].style.opacity = arr[i][2]; //these three statements worked; oDiv[i].style.z-index = arr[i][3]; //it doesn't work. } } </code></pre>
0debug
static void handle_event(int event) { static bool logged; if (event & ~PVPANIC_PANICKED && !logged) { qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", event); logged = true; } if (event & PVPANIC_PANICKED) { panicked_mon_event("pause"); vm_stop(RUN_STATE_GUEST_PANICKED); return; } }
1threat
void gic_update(GICState *s) { int best_irq; int best_prio; int irq; int irq_level, fiq_level; int cpu; int cm; for (cpu = 0; cpu < s->num_cpu; cpu++) { cm = 1 << cpu; s->current_pending[cpu] = 1023; if (!(s->ctlr & (GICD_CTLR_EN_GRP0 | GICD_CTLR_EN_GRP1)) || !(s->cpu_ctlr[cpu] & (GICC_CTLR_EN_GRP0 | GICC_CTLR_EN_GRP1))) { qemu_irq_lower(s->parent_irq[cpu]); qemu_irq_lower(s->parent_fiq[cpu]); continue; } best_prio = 0x100; best_irq = 1023; for (irq = 0; irq < s->num_irq; irq++) { if (GIC_TEST_ENABLED(irq, cm) && gic_test_pending(s, irq, cm) && (irq < GIC_INTERNAL || GIC_TARGET(irq) & cm)) { if (GIC_GET_PRIORITY(irq, cpu) < best_prio) { best_prio = GIC_GET_PRIORITY(irq, cpu); best_irq = irq; } } } if (best_irq != 1023) { trace_gic_update_bestirq(cpu, best_irq, best_prio, s->priority_mask[cpu], s->running_priority[cpu]); } irq_level = fiq_level = 0; if (best_prio < s->priority_mask[cpu]) { s->current_pending[cpu] = best_irq; if (best_prio < s->running_priority[cpu]) { int group = GIC_TEST_GROUP(best_irq, cm); if (extract32(s->ctlr, group, 1) && extract32(s->cpu_ctlr[cpu], group, 1)) { if (group == 0 && s->cpu_ctlr[cpu] & GICC_CTLR_FIQ_EN) { DPRINTF("Raised pending FIQ %d (cpu %d)\n", best_irq, cpu); fiq_level = 1; } else { DPRINTF("Raised pending IRQ %d (cpu %d)\n", best_irq, cpu); irq_level = 1; } } } } qemu_set_irq(s->parent_irq[cpu], irq_level); qemu_set_irq(s->parent_fiq[cpu], fiq_level); } }
1threat
static void piix4_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PIIX4PMState *s = PIIX4_PM(hotplug_dev); if (s->acpi_memory_hotplug.is_enabled && object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) { nvdimm_acpi_plug_cb(hotplug_dev, dev); } else { acpi_memory_plug_cb(hotplug_dev, &s->acpi_memory_hotplug, dev, errp); } } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { if (!xen_enabled()) { acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, errp); } } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { if (s->cpu_hotplug_legacy) { legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp); } else { acpi_cpu_plug_cb(hotplug_dev, &s->cpuhp_state, dev, errp); } } else { error_setg(errp, "acpi: device plug request for not supported device" " type: %s", object_get_typename(OBJECT(dev))); } }
1threat
int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int64_t pts, int64_t dts, int64_t pos) { int index, i; uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE]; if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) { s->next_frame_offset = s->cur_offset = pos; s->flags |= PARSER_FLAG_FETCHED_OFFSET; } if (buf_size == 0) { memset(dummy_buf, 0, sizeof(dummy_buf)); buf = dummy_buf; } else if (s->cur_offset + buf_size != s->cur_frame_end[s->cur_frame_start_index]) { i = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1); s->cur_frame_start_index = i; s->cur_frame_offset[i] = s->cur_offset; s->cur_frame_end[i] = s->cur_offset + buf_size; s->cur_frame_pts[i] = pts; s->cur_frame_dts[i] = dts; s->cur_frame_pos[i] = pos; } if (s->fetch_timestamp) { s->fetch_timestamp = 0; s->last_pts = s->pts; s->last_dts = s->dts; s->last_pos = s->pos; ff_fetch_timestamp(s, 0, 0); } index = s->parser->parser_parse(s, avctx, (const uint8_t **) poutbuf, poutbuf_size, buf, buf_size); if (*poutbuf_size) { s->frame_offset = s->next_frame_offset; s->next_frame_offset = s->cur_offset + index; s->fetch_timestamp = 1; } if (index < 0) index = 0; s->cur_offset += index; return index; }
1threat
static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc) { int addr_regl, addr_reg1, addr_meml; int data_regl, data_regh, data_reg1, data_reg2; int mem_index, s_bits; #if defined(CONFIG_SOFTMMU) uint8_t *label1_ptr, *label2_ptr; int sp_args; #endif #if TARGET_LONG_BITS == 64 # if defined(CONFIG_SOFTMMU) uint8_t *label3_ptr; # endif int addr_regh, addr_reg2, addr_memh; #endif data_regl = *args++; if (opc == 3) { data_regh = *args++; #if defined(TCG_TARGET_WORDS_BIGENDIAN) data_reg1 = data_regh; data_reg2 = data_regl; #else data_reg1 = data_regl; data_reg2 = data_regh; #endif } else { data_reg1 = data_regl; data_reg2 = 0; data_regh = 0; } addr_regl = *args++; #if TARGET_LONG_BITS == 64 addr_regh = *args++; # if defined(TCG_TARGET_WORDS_BIGENDIAN) addr_reg1 = addr_regh; addr_reg2 = addr_regl; addr_memh = 0; addr_meml = 4; # else addr_reg1 = addr_regl; addr_reg2 = addr_regh; addr_memh = 4; addr_meml = 0; # endif #else addr_reg1 = addr_regl; addr_meml = 0; #endif mem_index = *args; s_bits = opc; #if defined(CONFIG_SOFTMMU) tcg_out_opc_sa(s, OPC_SRL, TCG_REG_A0, addr_regl, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS); tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_A0, TCG_REG_A0, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS); tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, TCG_AREG0); tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0, offsetof(CPUState, tlb_table[mem_index][0].addr_write) + addr_meml); tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T0, TARGET_PAGE_MASK | ((1 << s_bits) - 1)); tcg_out_opc_reg(s, OPC_AND, TCG_REG_T0, TCG_REG_T0, addr_regl); # if TARGET_LONG_BITS == 64 label3_ptr = s->code_ptr; tcg_out_opc_br(s, OPC_BNE, TCG_REG_T0, TCG_REG_AT); tcg_out_nop(s); tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0, offsetof(CPUState, tlb_table[mem_index][0].addr_write) + addr_memh); label1_ptr = s->code_ptr; tcg_out_opc_br(s, OPC_BEQ, addr_regh, TCG_REG_AT); tcg_out_nop(s); reloc_pc16(label3_ptr, (tcg_target_long) s->code_ptr); # else label1_ptr = s->code_ptr; tcg_out_opc_br(s, OPC_BEQ, TCG_REG_T0, TCG_REG_AT); tcg_out_nop(s); # endif sp_args = TCG_REG_A0; tcg_out_mov(s, sp_args++, addr_reg1); # if TARGET_LONG_BITS == 64 tcg_out_mov(s, sp_args++, addr_reg2); # endif switch(opc) { case 0: tcg_out_opc_imm(s, OPC_ANDI, sp_args++, data_reg1, 0xff); break; case 1: tcg_out_opc_imm(s, OPC_ANDI, sp_args++, data_reg1, 0xffff); break; case 2: tcg_out_mov(s, sp_args++, data_reg1); break; case 3: sp_args = (sp_args + 1) & ~1; tcg_out_mov(s, sp_args++, data_reg1); tcg_out_mov(s, sp_args++, data_reg2); break; default: tcg_abort(); } if (sp_args > TCG_REG_A3) { tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_AT, mem_index); tcg_out_st(s, TCG_TYPE_I32, TCG_REG_AT, TCG_REG_SP, 16); } else { tcg_out_movi(s, TCG_TYPE_I32, sp_args, mem_index); } tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T9, (tcg_target_long)qemu_st_helpers[s_bits]); tcg_out_opc_reg(s, OPC_JALR, TCG_REG_RA, TCG_REG_T9, 0); tcg_out_nop(s); label2_ptr = s->code_ptr; tcg_out_opc_br(s, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO); tcg_out_nop(s); reloc_pc16(label1_ptr, (tcg_target_long) s->code_ptr); tcg_out_opc_imm(s, OPC_LW, TCG_REG_A0, TCG_REG_A0, offsetof(CPUState, tlb_table[mem_index][0].addend) + addr_meml); tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, addr_regl); #else if (GUEST_BASE == (int16_t)GUEST_BASE) { tcg_out_opc_imm(s, OPC_ADDIU, TCG_REG_A0, addr_reg1, GUEST_BASE); } else { tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A0, GUEST_BASE); tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, addr_reg1); } #endif switch(opc) { case 0: tcg_out_opc_imm(s, OPC_SB, data_reg1, TCG_REG_A0, 0); break; case 1: if (TCG_NEED_BSWAP) { tcg_out_bswap16(s, TCG_REG_T0, data_reg1); tcg_out_opc_imm(s, OPC_SH, TCG_REG_T0, TCG_REG_A0, 0); } else { tcg_out_opc_imm(s, OPC_SH, data_reg1, TCG_REG_A0, 0); } break; case 2: if (TCG_NEED_BSWAP) { tcg_out_bswap32(s, TCG_REG_T0, data_reg1); tcg_out_opc_imm(s, OPC_SW, TCG_REG_T0, TCG_REG_A0, 0); } else { tcg_out_opc_imm(s, OPC_SW, data_reg1, TCG_REG_A0, 0); } break; case 3: if (TCG_NEED_BSWAP) { tcg_out_bswap32(s, TCG_REG_T0, data_reg2); tcg_out_opc_imm(s, OPC_SW, TCG_REG_T0, TCG_REG_A0, 0); tcg_out_bswap32(s, TCG_REG_T0, data_reg1); tcg_out_opc_imm(s, OPC_SW, TCG_REG_T0, TCG_REG_A0, 4); } else { tcg_out_opc_imm(s, OPC_SW, data_reg1, TCG_REG_A0, 0); tcg_out_opc_imm(s, OPC_SW, data_reg2, TCG_REG_A0, 4); } break; default: tcg_abort(); } #if defined(CONFIG_SOFTMMU) reloc_pc16(label2_ptr, (tcg_target_long) s->code_ptr); #endif }
1threat
static void gen_spr_405 (CPUPPCState *env) { spr_register(env, SPR_4xx_CCR0, "CCR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00700000); spr_register(env, SPR_405_DBCR1, "DBCR1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_405_DVC1, "DVC1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_405_DVC2, "DVC2", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_405_IAC3, "IAC3", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_405_IAC4, "IAC4", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_405_SLER, "SLER", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_40x_sler, 0x00000000); spr_register(env, SPR_405_SU0R, "SU0R", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_USPRG0, "USPRG0", &spr_read_ureg, SPR_NOACCESS, &spr_read_ureg, SPR_NOACCESS, 0x00000000); spr_register(env, SPR_SPRG4, "SPRG4", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_USPRG4, "USPRG4", &spr_read_ureg, SPR_NOACCESS, &spr_read_ureg, SPR_NOACCESS, 0x00000000); spr_register(env, SPR_SPRG5, "SPRG5", SPR_NOACCESS, SPR_NOACCESS, spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_USPRG5, "USPRG5", &spr_read_ureg, SPR_NOACCESS, &spr_read_ureg, SPR_NOACCESS, 0x00000000); spr_register(env, SPR_SPRG6, "SPRG6", SPR_NOACCESS, SPR_NOACCESS, spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_USPRG6, "USPRG6", &spr_read_ureg, SPR_NOACCESS, &spr_read_ureg, SPR_NOACCESS, 0x00000000); spr_register(env, SPR_SPRG7, "SPRG7", SPR_NOACCESS, SPR_NOACCESS, spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_USPRG7, "USPRG7", &spr_read_ureg, SPR_NOACCESS, &spr_read_ureg, SPR_NOACCESS, 0x00000000); }
1threat