problem
stringlengths
26
131k
labels
class label
2 classes
"Google Play services are updating" in Google Maps API : <p>I have an Android app which makes use of Google Maps. All of a sudden, it stopped working in release mode. The Map view tells <em>Google Play services are updating</em> on the emulator and on real devices. Searching on the net everyone talks about the API key file, but this is not my problem!</p> <p>I have tried every possible different combination of release settings, and <strong>I have found out</strong> that the problem occurs when I set <code>debuggable = false</code> in the build configuration (with <code>debuggable = true</code> it works). I can't understand why Maps aren't working because, of course, the APK is not debuggable. I have also tried multiple versions of Google Play services, even the latest (<code>10.2.0</code>). No difference.</p> <p>What can I do? Please help as I can't release any new release on Play Store until I fix this bug.</p> <p><a href="https://i.stack.imgur.com/lS8C5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lS8C5.png" alt="enter image description here"></a></p>
0debug
void apic_init_reset(DeviceState *dev) { APICCommonState *s = APIC_COMMON(dev); APICCommonClass *info = APIC_COMMON_GET_CLASS(s); int i; if (!s) { return; } s->tpr = 0; s->spurious_vec = 0xff; s->log_dest = 0; s->dest_mode = 0xf; memset(s->isr, 0, sizeof(s->isr)); memset(s->tmr, 0, sizeof(s->tmr)); memset(s->irr, 0, sizeof(s->irr)); for (i = 0; i < APIC_LVT_NB; i++) { s->lvt[i] = APIC_LVT_MASKED; } s->esr = 0; memset(s->icr, 0, sizeof(s->icr)); s->divide_conf = 0; s->count_shift = 0; s->initial_count = 0; s->initial_count_load_time = 0; s->next_time = 0; s->wait_for_sipi = !cpu_is_bsp(s->cpu); if (s->timer) { timer_del(s->timer); } s->timer_expiry = -1; if (info->reset) { info->reset(s); } }
1threat
static void qemu_announce_self_once(void *opaque) { static int count = SELF_ANNOUNCE_ROUNDS; QEMUTimer *timer = *(QEMUTimer **)opaque; qemu_foreach_nic(qemu_announce_self_iter, NULL); if (--count) { qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 50 + (SELF_ANNOUNCE_ROUNDS - count - 1) * 100); } else { qemu_del_timer(timer); qemu_free_timer(timer); } }
1threat
static uint16_t mlp_checksum16(const uint8_t *buf, unsigned int buf_size) { uint16_t crc; if (!crc_init) { av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D)); crc_init = 1; } crc = av_crc(crc_2D, 0, buf, buf_size - 2); crc ^= AV_RL16(buf + buf_size - 2); return crc; }
1threat
How does ap fromMaybe compose? : <p>There I was, writing a function that takes a value as input, calls a function on that input, and if the result of that is <code>Just x</code>, it should return <code>x</code>; otherwise, it should return the original input.</p> <p>In other words, this function (that I didn't know what to call):</p> <pre><code>foo :: (a -&gt; Maybe a) -&gt; a -&gt; a foo f x = fromMaybe x (f x) </code></pre> <p>Since it seems like a general-purpose function, I wondered if it wasn't already defined, so <a href="https://twitter.com/ploeh/status/684418608454352896">I asked on Twitter</a>, and <a href="https://twitter.com/bitemyapp/status/684467784793886720">Chris Allen replied</a> that it's <code>ap fromMaybe</code>.</p> <p>That sounded promising, so I fired up GHCI and started experimenting:</p> <pre><code>Prelude Control.Monad Data.Maybe&gt; :type ap ap :: Monad m =&gt; m (a -&gt; b) -&gt; m a -&gt; m b Prelude Control.Monad Data.Maybe&gt; :type fromMaybe fromMaybe :: a -&gt; Maybe a -&gt; a Prelude Control.Monad Data.Maybe&gt; :type ap fromMaybe ap fromMaybe :: (b -&gt; Maybe b) -&gt; b -&gt; b </code></pre> <p>The type of <code>ap fromMaybe</code> certainly looks correct, and a couple of experiments seem to indicate that it has the desired behaviour as well.</p> <p>But <strong>how does it work?</strong></p> <p>The <code>fromMaybe</code> function seems clear to me, and in isolation, I think I understand what <code>ap</code> does - at least in the context of <code>Maybe</code>. When <code>m</code> is <code>Maybe</code>, it has the type <code>Maybe (a -&gt; b) -&gt; Maybe a -&gt; Maybe b</code>.</p> <p>What I don't understand is how <code>ap fromMaybe</code> even compiles. To me, this expression looks like partial application, but I may be getting that wrong. If this is the case, however, I don't understand how the types match up.</p> <p>The first argument to <code>ap</code> is <code>m (a -&gt; b)</code>, but <code>fromMaybe</code> has the type <code>a -&gt; Maybe a -&gt; a</code>. How does that match? Which <code>Monad</code> instance does the compiler infer that <code>m</code> is? How does <code>fromMaybe</code>, which takes two (curried) arguments, turn into a function that takes a single argument?</p> <p>Can someone help me connect the dots?</p>
0debug
List comprehension to extract multiple fields from list of tuples : <p>I have a list of tuples</p> <pre><code>servers = [('server1', 80 , 1, 2), ('server2', 443, 3, 4)] </code></pre> <p>I want to create a new list that only has the first two fields as in:</p> <pre><code> [('server1', 80), ('server2', 443)] </code></pre> <p>but I cannot see how to craft a list comprehension for more than one element.</p> <pre><code>hosts = [x[0] for x in servers] # this works to give me ['server1', server2'] hostswithports = [x[0], x[1] for x in servers] # this does not work </code></pre> <p>I prefer to learn the pythonic way vs using a loop - what am I doing wrong?</p>
0debug
Using JavaFX Application.stop() method over Shutdownhook : <p>So im using shutdownhook to clean up, bud since its not always guaranteed that shutdownhooks thread executes , should i just push this code onto JavaFX Application Thread (method stop()) which executes every time i close my application? Code is not expensive to run its basically just close socket if not closed and kill processs if not killed.</p> <p><strong>Is it good practice to use Application.stop() to cleanup over ShutdownHook?</strong></p> <p>Quote from doc:</p> <blockquote> <p>This method is called when the application should stop, and provides a convenient place to prepare for application exit and destroy resources. The implementation of this method provided by the Application class does nothing.</p> <p>NOTE: This method is called on the JavaFX Application Thread.</p> </blockquote> <p>Is this method only intended to clean up resources of UI? So far i dont see reason using shutdownhook over stop() at all.</p>
0debug
What will be correct SQL query for below question : I have created two table 1st(`Receive_Amount_Details`) for crediting amount from Site(Construction Site) Owner and 2nd(`SitewiseEmployee`) for debiting amount to pay laborer. I want SUM of all `Amount_Received` from `Receive_Amount_Details`, SUM of `Amount` from `SitewiseEmployee` and single `Date` column as output table. Here both table have `Date` column, but i want a single column for output. Output table contain only three column `Date`, `Total_Receive_Amount_from_siteowner` and `Total_Amount_Payed_to_Labour`. On output table if any single day amount not received and labour payed should be on the output table and also if any single day amount received but not payed to labour also need to come on the output table. THANKS IN ADVANCE FOR HELP :) ``` CREATE TABLE `Receive_Amount_Details` ( `Id` int(10) NOT NULL AUTO_INCREMENT, `SiteId` int(5) NOT NULL, `Amount_Received` int(10) NOT NULL, `Date` date NOT NULL, PRIMARY KEY (`Id`), KEY `SiteId` (`SiteId`), CONSTRAINT `Receive_Amount_Details_ibfk_1` FOREIGN KEY (`SiteId`) REFERENCES `SiteList` (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 ``` and ``` CREATE TABLE `SitewiseEmployee` ( `Id` int(10) NOT NULL AUTO_INCREMENT, `SiteId` int(5) NOT NULL, `EmployeeId` int(10) NOT NULL, `Amount` varchar(10) DEFAULT NULL, `Date` date NOT NULL, PRIMARY KEY (`Id`), KEY `SiteId` (`SiteId`), KEY `EmployeeId` (`EmployeeId`), CONSTRAINT `SitewiseEmployee_ibfk_1` FOREIGN KEY (`SiteId`) REFERENCES `SiteList` (`Id`), CONSTRAINT `SitewiseEmployee_ibfk_2` FOREIGN KEY (`EmployeeId`) REFERENCES `Employee` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 ```
0debug
How to check input string must follow below sequece? : I have a String and I just want to validate this string please help me how can I did this... my String is like "one=1&two=2" is a valid String String like `"sdassa=2&3=4" ` and `"23=2&sa=32fd"` is also valid invalid is like `"12one=&13&=3"` is not a valid String please help me to validate this String.
0debug
static int decode_dc_progressive(MJpegDecodeContext *s, int16_t *block, int component, int dc_index, uint16_t *quant_matrix, int Al) { int val; s->bdsp.clear_block(block); val = mjpeg_decode_dc(s, dc_index); if (val == 0xfffff) { av_log(s->avctx, AV_LOG_ERROR, "error dc\n"); return AVERROR_INVALIDDATA; } val = (val * (quant_matrix[0] << Al)) + s->last_dc[component]; s->last_dc[component] = val; block[0] = val; return 0; }
1threat
java could anybody explain this type of logic : <pre><code> public class Second { public static void main(String[] args) { System.out.println(1&gt;2?22:43); int a,b; a=11; b=(a==116)?22:33; System.out.println(b); } } </code></pre> <p> I am java beginner i am having hard time on understanding this code it does prints 22 but i'm not getting the logic behind it and what are these called if i have to know more about them.</p> <p><p>Are there any similar types of logic that i should keep my eye any suggestions will help.Thank you !! </p>
0debug
static int old_codec47(SANMVideoContext *ctx, int top, int left, int width, int height) { int i, j, seq, compr, new_rot, tbl_pos, skip; int stride = ctx->pitch; uint8_t *dst = ((uint8_t*)ctx->frm0) + left + top * stride; uint8_t *prev1 = (uint8_t*)ctx->frm1; uint8_t *prev2 = (uint8_t*)ctx->frm2; uint32_t decoded_size; tbl_pos = bytestream2_tell(&ctx->gb); seq = bytestream2_get_le16(&ctx->gb); compr = bytestream2_get_byte(&ctx->gb); new_rot = bytestream2_get_byte(&ctx->gb); skip = bytestream2_get_byte(&ctx->gb); bytestream2_skip(&ctx->gb, 9); decoded_size = bytestream2_get_le32(&ctx->gb); bytestream2_skip(&ctx->gb, 8); if (skip & 1) bytestream2_skip(&ctx->gb, 0x8080); if (!seq) { ctx->prev_seq = -1; memset(prev1, 0, ctx->height * stride); memset(prev2, 0, ctx->height * stride); av_dlog(ctx->avctx, "compression %d\n", compr); switch (compr) { case 0: if (bytestream2_get_bytes_left(&ctx->gb) < width * height) return AVERROR_INVALIDDATA; for (j = 0; j < height; j++) { bytestream2_get_bufferu(&ctx->gb, dst, width); dst += stride; break; case 1: if (bytestream2_get_bytes_left(&ctx->gb) < ((width + 1) >> 1) * ((height + 1) >> 1)) return AVERROR_INVALIDDATA; for (j = 0; j < height; j += 2) { for (i = 0; i < width; i += 2) { dst[i] = dst[i + 1] = dst[stride + i] = dst[stride + i + 1] = bytestream2_get_byteu(&ctx->gb); dst += stride * 2; break; case 2: if (seq == ctx->prev_seq + 1) { for (j = 0; j < height; j += 8) { for (i = 0; i < width; i += 8) { if (process_block(ctx, dst + i, prev1 + i, prev2 + i, stride, tbl_pos + 8, 8)) return AVERROR_INVALIDDATA; dst += stride * 8; prev1 += stride * 8; prev2 += stride * 8; break; case 3: memcpy(ctx->frm0, ctx->frm2, ctx->pitch * ctx->height); break; case 4: memcpy(ctx->frm0, ctx->frm1, ctx->pitch * ctx->height); break; case 5: if (rle_decode(ctx, dst, decoded_size)) return AVERROR_INVALIDDATA; break; default: av_log(ctx->avctx, AV_LOG_ERROR, "subcodec 47 compression %d not implemented\n", compr); return AVERROR_PATCHWELCOME; if (seq == ctx->prev_seq + 1) ctx->rotate_code = new_rot; else ctx->rotate_code = 0; ctx->prev_seq = seq; return 0;
1threat
static uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len) { VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev); uint32_t val = 0; if (ranges_overlap(addr, len, PCI_ROM_ADDRESS, 4) || (pdev->cap_present & QEMU_PCI_CAP_MSIX && ranges_overlap(addr, len, pdev->msix_cap, MSIX_CAP_LENGTH)) || (pdev->cap_present & QEMU_PCI_CAP_MSI && ranges_overlap(addr, len, pdev->msi_cap, vdev->msi_cap_size))) { val = pci_default_read_config(pdev, addr, len); } else { if (pread(vdev->fd, &val, len, vdev->config_offset + addr) != len) { error_report("%s(%04x:%02x:%02x.%x, 0x%x, 0x%x) failed: %m", __func__, vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function, addr, len); return -errno; } val = le32_to_cpu(val); } if (unlikely(ranges_overlap(addr, len, PCI_HEADER_TYPE, 1))) { uint32_t mask = PCI_HEADER_TYPE_MULTI_FUNCTION; if (len == 4) { mask <<= 16; } if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { val |= mask; } else { val &= ~mask; } } DPRINTF("%s(%04x:%02x:%02x.%x, @0x%x, len=0x%x) %x\n", __func__, vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function, addr, len, val); return val; }
1threat
Run `docker-php-ext-install` FROM container other than php : <p>I have a problem with Docker (docker-compose). I want to install some PHP extensions using <code>docker-compose.yml</code>, but I am unable to do this, because my .yml has <code>FROM ubuntu</code> and not <code>FROM php</code>. Is there any way I can achieve or access the <code>docker-php-ext-install</code>?</p> <h3>Dockerfile</h3> <pre><code>FROM ubuntu:16.04 RUN apt -yqq update RUN apt -yqq install nginx iputils-ping RUN docker-php-ext-install pdo pdo_mysql mbstring WORKDIR /usr/local/src COPY docker/nginx/dev.conf /etc/nginx/conf.d/dev.conf COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf CMD ["nginx"] </code></pre> <h3>docker-compose.yml</h3> <pre><code>version: "2" services: mariadb: image: mariadb environment: - MYSQL_ALLOW_EMPTY_PASSWORD=1 - MYSQL_ROOT_PASSWORD= phpmyadmin: image: phpmyadmin/phpmyadmin ports: - "8080:80" restart: always environment: - PMA_HOST=mariadb links: - mariadb php: image: php:7.1.1-fpm ports: - "9000:9000" volumes: - .:/dogopic links: - mariadb nginx: build: . ports: - "8000:80" volumes: - .:/dogopic links: - php </code></pre> <h3>Console output (fragment)</h3> <pre><code>Step 5/9 : RUN docker-php-ext-install pdo pdo_mysql mbstring ---&gt; Running in 445f8c82883d /bin/sh: 1: docker-php-ext-install: not found </code></pre>
0debug
static int check_image_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, const int linesizes[4]) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); int i; for (i = 0; i < 4; i++) { int plane = desc->comp[i].plane; if (!data[plane] || !linesizes[plane]) return 0; } return 1; }
1threat
static void create_one_flash(const char *name, hwaddr flashbase, hwaddr flashsize) { DriveInfo *dinfo = drive_get_next(IF_PFLASH); DeviceState *dev = qdev_create(NULL, "cfi.pflash01"); const uint64_t sectorlength = 256 * 1024; if (dinfo && qdev_prop_set_drive(dev, "drive", blk_bs(blk_by_legacy_dinfo(dinfo)))) { abort(); } qdev_prop_set_uint32(dev, "num-blocks", flashsize / sectorlength); qdev_prop_set_uint64(dev, "sector-length", sectorlength); qdev_prop_set_uint8(dev, "width", 4); qdev_prop_set_uint8(dev, "device-width", 2); qdev_prop_set_uint8(dev, "big-endian", 0); qdev_prop_set_uint16(dev, "id0", 0x89); qdev_prop_set_uint16(dev, "id1", 0x18); qdev_prop_set_uint16(dev, "id2", 0x00); qdev_prop_set_uint16(dev, "id3", 0x00); qdev_prop_set_string(dev, "name", name); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, flashbase); }
1threat
static void gen_compute_eflags_z(DisasContext *s, TCGv reg, bool inv) { switch (s->cc_op) { case CC_OP_DYNAMIC: gen_compute_eflags(s); case CC_OP_EFLAGS: tcg_gen_shri_tl(reg, cpu_cc_src, 6); tcg_gen_andi_tl(reg, reg, 1); if (inv) { tcg_gen_xori_tl(reg, reg, 1); } break; default: { int size = (s->cc_op - CC_OP_ADDB) & 3; TCGv t0 = gen_ext_tl(reg, cpu_cc_dst, size, false); tcg_gen_setcondi_tl(inv ? TCG_COND_NE : TCG_COND_EQ, reg, t0, 0); } break; } }
1threat
could std::list<char> be converted to std::list<int> in c++ : <p>I have this Question in my Uni Home work.could std:list-char be converted to std:list-int in c++.I hope to get right Answers from you as soon as possible.</p>
0debug
static void qmp_output_start_struct(Visitor *v, const char *name, void **obj, size_t unused, Error **errp) { QmpOutputVisitor *qov = to_qov(v); QDict *dict = qdict_new(); qmp_output_add(qov, name, dict); qmp_output_push(qov, dict, obj); }
1threat
static void integratorcp_init(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { CPUState *env; ram_addr_t ram_offset; qemu_irq pic[32]; qemu_irq *cpu_pic; DeviceState *dev; int i; if (!cpu_model) cpu_model = "arm926"; env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } ram_offset = qemu_ram_alloc(ram_size); cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM); cpu_register_physical_memory(0x80000000, ram_size, ram_offset | IO_MEM_RAM); dev = qdev_create(NULL, "integrator_core"); qdev_prop_set_uint32(dev, "memsz", ram_size >> 20); qdev_init(dev); sysbus_mmio_map((SysBusDevice *)dev, 0, 0x10000000); cpu_pic = arm_pic_init_cpu(env); dev = sysbus_create_varargs("integrator_pic", 0x14000000, cpu_pic[ARM_PIC_CPU_IRQ], cpu_pic[ARM_PIC_CPU_FIQ], NULL); for (i = 0; i < 32; i++) { pic[i] = qdev_get_gpio_in(dev, i); } sysbus_create_simple("integrator_pic", 0xca000000, pic[26]); sysbus_create_varargs("integrator_pit", 0x13000000, pic[5], pic[6], pic[7], NULL); sysbus_create_simple("pl031", 0x15000000, pic[8]); sysbus_create_simple("pl011", 0x16000000, pic[1]); sysbus_create_simple("pl011", 0x17000000, pic[2]); icp_control_init(0xcb000000); sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3]); sysbus_create_simple("pl050_mouse", 0x19000000, pic[4]); sysbus_create_varargs("pl181", 0x1c000000, pic[23], pic[24], NULL); if (nd_table[0].vlan) smc91c111_init(&nd_table[0], 0xc8000000, pic[27]); sysbus_create_simple("pl110", 0xc0000000, pic[22]); integrator_binfo.ram_size = ram_size; integrator_binfo.kernel_filename = kernel_filename; integrator_binfo.kernel_cmdline = kernel_cmdline; integrator_binfo.initrd_filename = initrd_filename; arm_load_kernel(env, &integrator_binfo); }
1threat
java 8 merge all elements of ListB into ListA if not present : <p>I need to merge all elements of a <strong>listB</strong> into another list <strong>listA</strong>. </p> <p>If an element is already present (based on a custom equality-check) in <strong>listA</strong> I don't want to add it.</p> <p>I don't want to use Set, and I don't want to override equals() and hashCode(). </p> <p>Reasons are, I don't want to prevent duplicates in listA per se, I only want to not merge from listB if there are already elements in listA which I consider being equal.</p> <p>I don't want to override equals() and hashCode() since that would mean I need to make sure, my implementation of equals() for the elements hold in every circumstance. It might however be, that elements from listB are not fully initialized, i.e. they might miss an object id, where that might be present in elements of listA.</p> <p>My current approach involves an interface and a Utility-Function:</p> <pre class="lang-java prettyprint-override"><code>public interface HasEqualityFunction&lt;T&gt; { public boolean hasEqualData(T other); } public class AppleVariety implements HasEqualityFunction&lt;AppleVariety&gt; { private String manufacturerName; private String varietyName; @Override public boolean hasEqualData(AppleVariety other) { return (this.manufacturerName.equals(other.getManufacturerName()) &amp;&amp; this.varietyName.equals(other.getVarietyName())); } // ... getter-Methods here } public class CollectionUtils { public static &lt;T extends HasEqualityFunction&gt; void merge( List&lt;T&gt; listA, List&lt;T&gt; listB) { if (listB.isEmpty()) { return; } Predicate&lt;T&gt; exists = (T x) -&gt; { return listA.stream().noneMatch( x::hasEqualData); }; listA.addAll(listB.stream() .filter(exists) .collect(Collectors.toList()) ); } } </code></pre> <p>And then I'd use it like this:</p> <pre class="lang-java prettyprint-override"><code>... List&lt;AppleVariety&gt; appleVarietiesFromOnePlace = ... init here with some elements List&lt;AppleVariety&gt; appleVarietiesFromAnotherPlace = ... init here with some elements CollectionUtils.merge(appleVarietiesFromOnePlace, appleVarietiesFromAnotherPlace); ... </code></pre> <p>to get my new list in listA with all elements merged from B.</p> <p>Is this a good approach? Is there a better/easier way to accomplish the same?</p>
0debug
static int64_t guest_file_handle_add(HANDLE fh, Error **errp) { GuestFileHandle *gfh; int64_t handle; handle = ga_get_fd_handle(ga_state, errp); if (handle < 0) { return -1; } gfh = g_malloc0(sizeof(GuestFileHandle)); gfh->id = handle; gfh->fh = fh; QTAILQ_INSERT_TAIL(&guest_file_state.filehandles, gfh, next); return handle; }
1threat
alert('Hello ' + user_input);
1threat
Checking string value in a string using c# : <p>I have following code in my project</p> <pre><code>var ReturnStr = Final_BOM.Tables[0].Rows[0]["NEW_BOM_IDS"].ToString(); </code></pre> <p>the above line returns "12,13" but some times only "12"</p> <pre><code>var ReturnBOM = dsBOMDEfault.Tables[0].Rows[0]["Item_ID"].ToString(); </code></pre> <p>the above line returns "14,15,13".</p> <p>I want to check ReturnBOM values in ReturnStr </p> <p>Can any one help how to check</p>
0debug
How to get the v-for index in Vue.js? : <p>I have a Vue component like bellow:</p> <pre><code>&lt;div v-for="item in items" :key="there I want get the for-loop index" &gt; &lt;/div&gt; ... data(){ items: [{name:'a'}, {name:'b'}...] } </code></pre> <p>How can I get the index when I execute the for-loop in my vue.js?</p>
0debug
void ff_put_h264_qpel4_mc13_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hv_qrt_4w_msa(src + stride - 2, src - (stride * 2), stride, dst, stride, 4); }
1threat
error: invalid operands to binary expression 'float' : <p>Hello and sorry if this question has been asked before, but I'm working on the Josephus problem and this is the code that I´ve written.</p> <pre><code>#include&lt;stdio.h&gt; #include&lt;cs50.h&gt; #include&lt;math.h&gt; int main(void) { printf("Number of people: "); float f=GetFloat(); const int a=pow(2,floor(log(f)/log(2))); float c= 2*(f-2^a)+1; printf("%f\n", c); } </code></pre> <p>When I try to compile it it gives me this error message.</p> <pre><code>clang -ggdb3 -O0 -std=c99 -Wall -Werror Josephus.c -lcs50 -lm -o Josephus Josephus.c:11:20: error: invalid operands to binary expression ('float' and 'float') float c= 2*(f-2^a)+1; ~~~^~ </code></pre> <p>The equation I'm trying to write in the code is c = 2(f – 2^a) + 1 Where "c" is the number I'm looking for, "f" is the number of people and "a" is the largets power of 2 smaller than f.</p> <p>Sorry for any and all grammatical mistakes and my lack of knowledge of the topic, I'm new to programming. Cheers!</p>
0debug
iWatch: how to change label background color in iwatch : <p>I have added a label but not able to change the background color of this label in iWatch.</p> <p>Can anyone help me out on this</p> <p>Thanks in advance.</p>
0debug
Event that triggers when the application is forced ended using task manager : <p>Is there anything I can do with my program wherein I have to do something when my application has been terminated using task manager?</p> <p>I hope you can help me in this matter.</p> <p>Thank you!</p>
0debug
How to make faster this code? : I have written this code for solving Euler Project No 12. But my code not works fast. How can I make faster it? I have readen some suggests about finding divisors, but the logic of using sqrt for n could not understand. If you can explain the logic of it. Thanks in advance CODE: def sumdiv(n): l=[d for d in range(1,int(n/2)+1) if n%d==0] # used n/2 to short loop return len(l)+1 # added n itself trnums=[1,3] while sumdiv(trnums[-1])<=501: k=trnums[-1]-trnums[-2]+1 trnums.append(trnums[-1]+k) print(trnums[-2:])
0debug
Find which cell value has the most number of rows? : <p>The excel spreadsheet at my work has a column for date and I'm trying to find out which date shows up the most. Is there a way to do that?</p>
0debug
SQLAlchemy ER diagram in python 3 : <p>Does anyone know a way to make an ER diagram from SQLAlchemy models in python 3. I found sqlalchemy_schemadisplay, which is python 2 because of pydot and ERAlchemy which is also python 2 only. </p>
0debug
Swift 4: With Codable `Generic parameter 'T' could not be inferred` : <p>I am getting the following error:</p> <p><code>Generic parameter 'T' could not be inferred</code> </p> <p>on line: <code>let data = try encoder.encode(obj)</code></p> <p>Here is the code</p> <pre><code>import Foundation struct User: Codable { var firstName: String var lastName: String } let u1 = User(firstName: "Ann", lastName: "A") let u2 = User(firstName: "Ben", lastName: "B") let u3 = User(firstName: "Charlie", lastName: "C") let u4 = User(firstName: "David", lastName: "D") let a = [u1, u2, u3, u4] var ret = [[String: Any]]() for i in 0..&lt;a.count { let param = [ "a" : a[i], "b" : 45 ] as [String : Any] ret.append(param) } let obj = ["obj": ret] let encoder = JSONEncoder() encoder.outputFormatting = .prettyPrinted let data = try encoder.encode(obj) // This line produces an error print(String(data: data, encoding: .utf8)!) </code></pre> <p>What am I doing wrong?</p>
0debug
static void socket_connect_data_free(socket_connect_data *c) { qapi_free_SocketAddressLegacy(c->saddr); g_free(c->model); g_free(c->name); g_free(c); }
1threat
Stream filter regex : <pre><code>List&lt;File&gt; fileListToProcess = Arrays.stream(allFolderPath) .filter(myFile -&gt; myFile.getName().matches("archive_")) .collect(Collectors.toList()); </code></pre> <p>I am filtering files which starts with "archive_" to process using regex and streams. This does not work. What am i doing wrong here? </p>
0debug
pass array from textbox into parameter : <p>please look at my code :</p> <pre><code>var translateArraySourceTexts = Textbox.Text.Split(new Char[] { '.' }); string requestBody = string.Format(body, from, "text/plain", translateArraySourceTexts[0], translateArraySourceTexts[1], ....., to); </code></pre> <p>What happened is, I have a textbox to input sentences. I want the sentences are separated for each sentence indicated by "."</p> <p>Then, I want to use all the array to be appended to string request body. Because currently I am using "translateArraySourceTexts[0], translateArraySourceTexts[1] ,.......translateArraySourceTexts[9999].</p> <p>Please share to me your thought!</p>
0debug
PostMessage from a sandboxed iFrame to the main window, origin is always null : <p>There's something I don't get about the event origin with javascript postMessage event.</p> <p>Here is my main page:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;h1&gt;Test&lt;/h1&gt; &lt;h2&gt;Outside&lt;/h2&gt; &lt;iframe src="iframe-include.html" width="100%" height="100" sandbox="allow-scripts"&gt;&lt;/iframe&gt; &lt;script type="text/javascript"&gt; window.addEventListener('message', function (event) { console.log(event); }, false); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And my iFrame content</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;h3&gt;Inside&lt;/h3&gt; &lt;script type="text/javascript"&gt; var counter = 1, domain = window.location.protocol + '//' + window.location.host, send = function () { window.setTimeout(function () { console.log('iframe says:', domain); window.parent.postMessage(counter, domain); counter += 1; send(); }, 3000); }; send(); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Looking at the console, the origin property of the event object is always null, even if the domain variable in the iFrame is correct.</p> <p>My console says:</p> <pre><code>iframe-include.html:11 iframe says: http://127.0.0.1:8181 iframe.html:11 MessageEvent {isTrusted: true, data: 2, origin: "null", lastEventId: "", source: Window…} </code></pre> <p>In every doc, it says that it's important to check on event.origin inside de "message" event listener. But how to do that if it's always null?</p> <p>Thanks for the help</p>
0debug
What is the differences between storage classes : <p>Could you explain easily all differences between the four storage classes with examples and usages.</p> <p>I have found some information but I could not understand well.</p> <p>I only know 2 things:</p> <p>1) When we use the keyword 'static' in a function the variable still remains after the function ends. but what about outside of the function is it necessary?</p> <p>2) When we use extern for a variable we can use it from anywhere. but I know when we declare (int variablename) on top lines it still can be used from anywhere.</p> <p>am I right about the 2 things or the only things that I know are incorrect?</p> <p>and another question:are the 4 stroge classes are special for c or are they same in any other languages</p>
0debug
int coroutine_fn bdrv_co_flush(BlockDriverState *bs) { int ret; BdrvTrackedRequest req; if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs) || bdrv_is_sg(bs)) { return 0; } tracked_request_begin(&req, bs, 0, 0, BDRV_TRACKED_FLUSH); int current_gen = bs->write_gen; while (bs->flush_started_gen != bs->flushed_gen) { qemu_co_queue_wait(&bs->flush_queue); } bs->flush_started_gen = current_gen; if (bs->drv->bdrv_co_flush) { ret = bs->drv->bdrv_co_flush(bs); goto out; } BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_OS); if (bs->drv->bdrv_co_flush_to_os) { ret = bs->drv->bdrv_co_flush_to_os(bs); if (ret < 0) { goto out; } } if (bs->open_flags & BDRV_O_NO_FLUSH) { goto flush_parent; } if (bs->flushed_gen == current_gen) { goto flush_parent; } BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_DISK); if (bs->drv->bdrv_co_flush_to_disk) { ret = bs->drv->bdrv_co_flush_to_disk(bs); } else if (bs->drv->bdrv_aio_flush) { BlockAIOCB *acb; CoroutineIOCompletion co = { .coroutine = qemu_coroutine_self(), }; acb = bs->drv->bdrv_aio_flush(bs, bdrv_co_io_em_complete, &co); if (acb == NULL) { ret = -EIO; } else { qemu_coroutine_yield(); ret = co.ret; } } else { ret = 0; } if (ret < 0) { goto out; } flush_parent: ret = bs->file ? bdrv_co_flush(bs->file->bs) : 0; out: bs->flushed_gen = current_gen; qemu_co_queue_restart_all(&bs->flush_queue); tracked_request_end(&req); return ret; }
1threat
def binomial_coeffi(n, k): if (k == 0 or k == n): return 1 return (binomial_coeffi(n - 1, k - 1) + binomial_coeffi(n - 1, k)) def rencontres_number(n, m): if (n == 0 and m == 0): return 1 if (n == 1 and m == 0): return 0 if (m == 0): return ((n - 1) * (rencontres_number(n - 1, 0)+ rencontres_number(n - 2, 0))) return (binomial_coeffi(n, m) * rencontres_number(n - m, 0))
0debug
Using ConstraintLayout with custom Android Dialog : <p>I'm creating a custom Dialog by extending Dialog and using setContentView(). The problem is when I try to show the Dialog it only shows the background shadow instead of my custom layout. I've managed to get the custom layout to show by wrapping it in a RelativeLayout, but I'm wondering if there is a better solution or something I'm doing wrong. Using constraintLayout version 1.0.2. Thanks!</p> <p>Here is my Custom Dialog:</p> <pre><code>class EventsFilterDialog(context: Context): Dialog(context) { init { setContentView(R.layout.dialog_events_filter) setCancelable(true) } } </code></pre> <p>Here is a simplified version of my R.layout.dialog_events_filter that has the exact same result:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@color/white" android:layout_width="match_parent" android:layout_height="wrap_content"&gt; &lt;TextView android:id="@+id/headerTv" android:text="@string/events_filters" android:textColor="@color/white" android:textSize="18sp" android:textStyle="bold" android:gravity="center" android:background="@color/colorPrimaryLight" android:padding="16dp" android:layout_width="0dp" android:layout_height="wrap_content" app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" /&gt; &lt;View android:id="@+id/middleView" android:layout_width="0dp" android:layout_height="256dp" app:layout_constraintTop_toBottomOf="@+id/headerTv" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" /&gt; &lt;TextView android:id="@+id/closeTv" android:text="@string/close" android:textColor="@color/white" android:textAllCaps="true" android:textStyle="bold" android:gravity="center" android:background="@color/colorPrimaryLight" android:layout_width="0dp" android:layout_height="48dp" app:layout_constraintTop_toBottomOf="@+id/middleView" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toLeftOf="@+id/applyTv" /&gt; &lt;TextView android:id="@+id/applyTv" android:text="@string/apply_filter" android:textColor="@color/white" android:textAllCaps="true" android:textStyle="bold" android:gravity="center" android:background="@color/colorAccent" android:layout_width="0dp" android:layout_height="48dp" app:layout_constraintTop_toBottomOf="@+id/middleView" app:layout_constraintLeft_toRightOf="@+id/closeTv" app:layout_constraintRight_toRightOf="parent"/&gt; &lt;/android.support.constraint.ConstraintLayout&gt; </code></pre>
0debug
Android phones and how they switch from mobile data and wifi automatically : <p>How do phones choose which to prioritize when wifi and mobile data are on? Would love to know what governs the decision on this like the code or the drivers on the android phone. </p> <p>Currently working on a project focused on building an app capable of failing over from a WiFi connection to a different line like SMS network if the internet line goes down. Looking to help disaster management institutions with the resiliency of their communication.</p>
0debug
Js how can i delete message with a selfbot : i want to send a message every 1min (this is ok) but i want to delete the message instantly after he his sent (i need help for that) i tried some things but it don't work //THIS CODE IS RIGHT const Discord = require('discord.js'); const client = new Discord.Client(); const token = "**************************************"; client.login(token); client.on('ready', () => { var testecrit = client.channels.find(channel => channel.id === '592118296770510893'); console.log("Je suis pret patron"); setInterval(() => { testecrit.send("le test de l envoi est concluant."); },5000); }); So what will be the code that i need to add to my existing code, to delete the message sent instantly ?
0debug
numpy.ufunc has the wrong size, try recompiling. even with the latest pandas and numpy versions : <p>Im using pandas in a container and I get the following error:</p> <pre><code>Traceback (most recent call last): File "/volumes/dependencies/site-packages/celery/app/trace.py", line 374, in trace_task R = retval = fun(*args, **kwargs) File "/volumes/dependencies/site-packages/celery/app/trace.py", line 629, in __protected_call__ return self.run(*args, **kwargs) File "/volumes/code/autoai/celery/data_template/api.py", line 16, in run_data_template_task data_template.run(data_bundle, columns=columns) File "/volumes/code/autoai/models/data_template.py", line 504, in run self.to_parquet(data_bundle, columns=columns) File "/volumes/code/autoai/models/data_template.py", line 162, in to_parquet }, parquet_path=data_file.path, directory="", dataset=self) File "/volumes/code/autoai/core/datasets/parquet_converter.py", line 46, in convert file_system.write_dataframe(parquet_path, chunk, directory, append=append) File "/volumes/code/autoai/core/file_systems.py", line 76, in write_dataframe append=append) File "/volumes/dependencies/site-packages/pandas/core/frame.py", line 1945, in to_parquet compression=compression, **kwargs) File "/volumes/dependencies/site-packages/pandas/io/parquet.py", line 256, in to_parquet impl = get_engine(engine) File "/volumes/dependencies/site-packages/pandas/io/parquet.py", line 40, in get_engine return FastParquetImpl() File "/volumes/dependencies/site-packages/pandas/io/parquet.py", line 180, in __init__ import fastparquet File "/volumes/dependencies/site-packages/fastparquet/__init__.py", line 8, in &lt;module&gt; from .core import read_thrift File "/volumes/dependencies/site-packages/fastparquet/core.py", line 13, in &lt;module&gt; from . import encoding File "/volumes/dependencies/site-packages/fastparquet/encoding.py", line 11, in &lt;module&gt; from .speedups import unpack_byte_array File "__init__.pxd", line 861, in init fastparquet.speedups ValueError: numpy.ufunc has the wrong size, try recompiling. Expected 192, got 216 </code></pre> <p>I read on <a href="https://stackoverflow.com/questions/17709641/valueerror-numpy-dtype-has-the-wrong-size-try-recompiling">other answers</a> that this message shows up when pandas is compiled against a newer numpy version than the one you have installed. But updating both pandas and numpy did not work for me. I tried to find out if I have a few versions of numpy, but <code>pip show numpy</code> seems to show the latest version. </p> <p>Also, in a weird way, this happens only when I deploy locally and not on the server. </p> <p>Any ideas how to go about fixing that? Or at least how to debug my numpy and pandas versions (if there are multiple versions how do I check that)</p> <p>I tried: upgrading both packages and removing and reinstalling them. No help there.</p>
0debug
static int ast2500_rambits(AspeedSDMCState *s) { switch (s->ram_size >> 20) { case 128: return ASPEED_SDMC_AST2500_128MB; case 256: return ASPEED_SDMC_AST2500_256MB; case 512: return ASPEED_SDMC_AST2500_512MB; case 1024: return ASPEED_SDMC_AST2500_1024MB; default: break; } error_report("warning: Invalid RAM size 0x%" PRIx64 ". Using default 512M", s->ram_size); s->ram_size = 512 << 20; return ASPEED_SDMC_AST2500_512MB; }
1threat
Date Formatting Returns Nil : <p>I'm getting nil when trying to create a date from a string. What am I doing wrong?</p> <pre><code>let createdAt = passesDictionary["createdAt"] as? String print(createdAt) let dateFormatter = NSDateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd" let createdDate = dateFormatter.dateFromString(createdAt!) print(createdDate) </code></pre> <p>createdAt is Optional("2016-05-03T19:17:00.434Z"), but createdDate is nil.</p>
0debug
static void ahci_start_dma(IDEDMA *dma, IDEState *s, BlockCompletionFunc *dma_cb) { #ifdef DEBUG_AHCI AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma); #endif DPRINTF(ad->port_no, "\n"); s->io_buffer_offset = 0; dma_cb(s, 0); }
1threat
i am not getting the installation of the pyaudio library into my system : running build_py creating build creating build\lib.win-amd64-3.7 copying src\pyaudio.py -> build\lib.win-amd64-3.7 running build_ext building '_portaudio' extension error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/ ---------------------------------------- Command "c:\users\vishwas\appdata\local\programs\python\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Vishwas\\AppData\\Local\\Temp\\pip-install-g9skf8fa\\PyAudio\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Vishwas\AppData\Local\Temp\pip-record-8gf9jsxc\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Vishwas\AppData\Local\Temp\pip-install-g9skf8fa\PyAudio\ "Where is it releated to python and c++" i have tried all the methods even easy_install but didn't work C:\Users\Vishwas>pip install PyAudio Collecting PyAudio Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz Installing collected packages: PyAudio Running setup.py install for PyAudio ... error Complete output from command c:\users\vishwas\appdata\local\programs\python\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Vishwas\\AppData\\Local\\Temp\\pip-install-g9skf8fa\\PyAudio\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Vishwas\AppData\Local\Temp\pip-record-8gf9jsxc\install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build\lib.win-amd64-3.7 copying src\pyaudio.py -> build\lib.win-amd64-3.7 running build_ext building '_portaudio' extension error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/ ---------------------------------------- Command "c:\users\vishwas\appdata\local\programs\python\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Vishwas\\AppData\\Local\\Temp\\pip-install-g9skf8fa\\PyAudio\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Vishwas\AppData\Local\Temp\pip-record-8gf9jsxc\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Vishwas\AppData\Local\Temp\pip-install-g9skf8fa\PyAudio\
0debug
v-for and v-if not working together in vue.js : <p>A form is used to submit text and two options which tell vue which column to display the text in. When the col2 radio button is checked the submitted text should display in column 2. This is not happening, on column 1 text is displaying.</p> <p>I have two radio buttons which should pass the value 'one' or 'two' to a newInfo.option On submnit a method pushed the form data to the array 'info'.</p> <pre><code>&lt;input type="radio" id="col1" value="one" v-model="newInfo.col"&gt; &lt;input type="radio" id="col2" value="two" v-model="newInfo.col"&gt; </code></pre> <p>This data is being pushed to the array 'info' correctly and I can iterate through it. I know this is working because I can iterate through the array, an console.log all the data in it. All the submitted form data is there.</p> <p>Next I iterate through this array twice in the template. Once for info.col==="one" and the other iteration should only display when info.col==="two". I am using a v-for and v-if together, which the vue.js documentation says is ok to do,</p> <p><a href="https://vuejs.org/v2/guide/conditional.html#v-if-with-v-for" rel="noreferrer">https://vuejs.org/v2/guide/conditional.html#v-if-with-v-for</a></p> <pre><code>&lt;div class="row"&gt; &lt;div class="col-md-6"&gt; &lt;ol&gt; &lt;li v-for="item in info" v-if="item.col==='one'"&gt; text: {{ item.text }}, col: {{ item.col }} &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;div class="col-md-6"&gt; &lt;ol&gt; &lt;li v-for="item in info" v-if="!item.col==='two'"&gt; text: {{ item.text }}, col: {{ item.col }} &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The full vue.js code is on github <a href="https://github.com/shanegibney/vueRadioButtons" rel="noreferrer">here</a></p> <p>And it is running on gh-pages <a href="https://shanegibney.github.io/vueRadioButtons/#/" rel="noreferrer">here</a></p>
0debug
PHP creating and downloading zip, no error but doesn't work : <pre><code>function downloadZipFunction() { echo 'entered downloadzipfunction'; //$files = $myArray; global $files; print_r($files); echo 'plis rch here'; # create new zip opbject $zip = new ZipArchive(); echo "before tempnam"; # create a temp file &amp; open it $tmp_file = tempnam('./docs/','tmp'); echo "after tempnam"; echo $tmp_file; $zip-&gt;open($tmp_file, ZipArchive::CREATE); # loop through each file foreach($files as $file){ echo "entered foreach"; # download file $download_file = file_get_contents("docs/".$file); echo "docs/".$file; #add it to the zip $zip-&gt;addFromString(basename($file),$download_file); echo basename($file); } # close zip $zip-&gt;close(); # send the file to the browser as a download header('Content-disposition: attachment; filename= docs_$prop.zip'); header('Content-type: application/zip'); readfile($tmp_file); echo $tmp_file; //unlink($tmp_file); } </code></pre> <p>It outputs 'entered downloadzipfunctionArray ( [0] => 1514223591754.xml ) plis rch here' but nothing else after that, no error. No file is created on the server as well.</p>
0debug
Copy Selected Data from DataGridView to another one when DataGridView is bounded : <p>I have a small issue and I am trying to solve this problem a long time ago. My problem is that i would like to copy a Selected DATA from a DataGridView to another but these DataGridViews are bounded. Thanks For Helping IF you need help just send my a message. Thank Romeo</p>
0debug
static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, QDict *options, int flags, BlockDriver *drv, Error **errp) { int ret, open_flags; const char *filename; const char *node_name = NULL; Error *local_err = NULL; assert(drv != NULL); assert(bs->file == NULL); assert(options != NULL && bs->options != options); if (file != NULL) { filename = file->filename; } else { filename = qdict_get_try_str(options, "filename"); } if (drv->bdrv_needs_filename && !filename) { error_setg(errp, "The '%s' block driver requires a file name", drv->format_name); return -EINVAL; } trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name); node_name = qdict_get_try_str(options, "node-name"); bdrv_assign_node_name(bs, node_name, &local_err); if (local_err) { error_propagate(errp, local_err); return -EINVAL; } qdict_del(options, "node-name"); if (file != NULL && drv->bdrv_file_open) { bdrv_swap(file, bs); return 0; } bs->open_flags = flags; bs->guest_block_size = 512; bs->request_alignment = 512; bs->zero_beyond_eof = true; open_flags = bdrv_open_flags(bs, flags); bs->read_only = !(open_flags & BDRV_O_RDWR); if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) { error_setg(errp, !bs->read_only && bdrv_is_whitelisted(drv, true) ? "Driver '%s' can only be used for read-only devices" : "Driver '%s' is not whitelisted", drv->format_name); return -ENOTSUP; } assert(bs->copy_on_read == 0); if (flags & BDRV_O_COPY_ON_READ) { if (!bs->read_only) { bdrv_enable_copy_on_read(bs); } else { error_setg(errp, "Can't use copy-on-read on read-only device"); return -EINVAL; } } if (filename != NULL) { pstrcpy(bs->filename, sizeof(bs->filename), filename); } else { bs->filename[0] = '\0'; } pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), bs->filename); bs->drv = drv; bs->opaque = g_malloc0(drv->instance_size); bs->enable_write_cache = !!(flags & BDRV_O_CACHE_WB); if (drv->bdrv_file_open) { assert(file == NULL); assert(!drv->bdrv_needs_filename || filename != NULL); ret = drv->bdrv_file_open(bs, options, open_flags, &local_err); } else { if (file == NULL) { error_setg(errp, "Can't use '%s' as a block driver for the " "protocol level", drv->format_name); ret = -EINVAL; goto free_and_fail; } bs->file = file; ret = drv->bdrv_open(bs, options, open_flags, &local_err); } if (ret < 0) { if (local_err) { error_propagate(errp, local_err); } else if (bs->filename[0]) { error_setg_errno(errp, -ret, "Could not open '%s'", bs->filename); } else { error_setg_errno(errp, -ret, "Could not open image"); } goto free_and_fail; } if (bs->encrypted) { error_report("Encrypted images are deprecated"); error_printf("Support for them will be removed in a future release.\n" "You can use 'qemu-img convert' to convert your image" " to an unencrypted one.\n"); } ret = refresh_total_sectors(bs, bs->total_sectors); if (ret < 0) { error_setg_errno(errp, -ret, "Could not refresh total sector count"); goto free_and_fail; } bdrv_refresh_limits(bs, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto free_and_fail; } assert(bdrv_opt_mem_align(bs) != 0); assert(bdrv_min_mem_align(bs) != 0); assert((bs->request_alignment != 0) || bs->sg); return 0; free_and_fail: bs->file = NULL; g_free(bs->opaque); bs->opaque = NULL; bs->drv = NULL; return ret; }
1threat
Symfony there are no commands defined in the "make" namespace : <p>Following the documentation found <a href="https://symfony.com/doc/current/doctrine.html" rel="noreferrer">here</a> I enter <code>php bin/console make:entity Product</code> in Terminal and get the following error:</p> <p><code>[Symfony\Component\Console\Exception\CommandNotFoundException]<br> There are no commands defined in the "make" namespace.</code></p>
0debug
void helper_lock(void) { spin_lock(&global_cpu_lock); }
1threat
form onsubmit won't work unless in Javascript : <p>I recently started doing form validation and I am trying to understand something. I have yet to find this anywhere else on SE.</p> <p>When I have <code>onsubmit="return validateForm()"</code> or <code>onsubmit="validateForm()"</code> in the <code>&lt;form&gt;</code> element, the form does not do anything. However, when I remove <code>onsbumit</code> from the form tag and instead do <code>document.forms["favorite"].onsubmit = function validateForm()</code> in the JS file, it works fine. </p> <p>I got it working, but I am trying to understand why the "normal" method of <code>onsubmit</code> in the html isn't working.</p> <p>For reference, here is my code as it works now:</p> <p>HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;script type="text/javascript" src="form.js"&gt;&lt;/script&gt; &lt;title&gt;Form&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form name="favorite" action="#" method="post"&gt; Favorite Car Brand: &lt;input type="text" name="car"&gt; &lt;input type="submit" value="Submit"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>JS:</p> <pre><code>window.onload = function(){ document.forms["favorite"].onsubmit = function validateForm(){ var input = document.forms["favorite"]["car"].value; if(input == ""){ alert("You missed an entry"); return false; } } } </code></pre>
0debug
How to automatically populate CreatedDate and ModifiedDate? : <p>I am learning ASP.NET Core MVC and my model is</p> <pre><code>namespace Joukyuu.Models { public class Passage { public int PassageId { get; set; } public string Contents { get; set; } public DateTime CreatedDate { get; set; } public DateTime ModifiedDate { get; set; } } } </code></pre> <p>The <code>Passage</code> table is used to save passages I wrote.</p> <h1>Scenario</h1> <ul> <li><p><code>Create</code> view just has one field <code>Contents</code> to input a passage. <code>CreatedDate</code> and <code>ModifiedDate</code> must be automatically set equal by the server (using UTC format).</p></li> <li><p><code>Edit</code> view just has one field <code>Contents</code> to edit a passage. <code>ModifiedDate</code> must be automatically set by the server.</p></li> </ul> <h1>Question</h1> <p>What attributes I have to attach to the <code>CreatedDate</code> and <code>ModifiedDate</code> properties to make them automatically populated by the server based on the above scenario?</p>
0debug
Mockito asks to add @PrepareForTest for the class even after adding @PrepareForTest : <p>I have the following simple code. I have a class (TestClass) and I want to test "someMethod". There is an external static method which is called by my "someMethod". I want to Powermock that static method to return me some dummy object. I have the @PrepareForTest(ExternalClass.class) in the begining, but when I execute it gives the error:</p> <p><em>The class ExternalClass not prepared for test. To prepare this class, add class to the <code>'@PrepareForTest'</code> annotation. In case if you don't use this annotation, add the annotation on class or method level.</em></p> <p>Please help me to point out what is wrong with the way I have used <code>@PrepareForTest</code></p> <pre><code>@RunWith(PowerMockRunner.class) @PrepareForTest(ExternalClass.class) public class xyzTest { @Mock private RestTemplate restTemplate; @Mock private TestClass testClass; @BeforeClass private void setUpBeforeClass() { MockitoAnnotations.initMocks(this); } @Test public void testSuccessCase() { Boolean mockResponse = true; ResponseEntity&lt;Boolean&gt; response = new ResponseEntity&lt;Boolean&gt;(mockResponse, HttpStatus.OK); SomeClass someClass = new SomeClass("test", "1.0.0", "someUrl", "someMetaData"); PowerMockito.mockStatic(ExternalClass.class); Mockito.when(restTemplate.postForEntity(any(String.class), any(String.class), eq(Boolean.class))).thenReturn(response); Mockito.when(ExternalClass.getSomeClass(any(String.class))).thenReturn(someClass); Boolean result = testClass.someMethod("test"); Assert.isTrue(result); Mockito.verify(restTemplate, times(1)).postForObject(any(String.class), any(String.class), any()); } } </code></pre>
0debug
static void coded_frame_add(void *list, struct FrameListData *cx_frame) { struct FrameListData **p = list; while (*p != NULL) p = &(*p)->next; *p = cx_frame; cx_frame->next = NULL; }
1threat
A div is shown but not hide even when hide() event given : <script type="text/javascript"> $(document).ready(function() { $("#total1").show(); }); $(".nstSlider1").on('click', function() { $("#total1").show(); $("#total2, , #total4, #total3").css('display', 'none'); }); $(".nstSlider2").on('click', function() { $("#total2").show(); $("#total4, , #total1, #total3").css('display', 'none'); }); $(".nstSlider3").on('click', function() { $("#total3").show(); $("#total2, , #total1, #total4").css('display', 'none'); }); $(".nstSlider4").on('click', function() { $("#total4").show(); $("#total2, #total1, #total3").css('display', 'none'); }); </script> When i click on .nstSlider1, it shows #total1 and hide other #total2, #total3, #total4...but when i click on .nstSlider2, it also shows #total2, but does not hide #total1...hence when i click on .nstSlider3, #total3 was shown, but others are again not hided...why?any help is much appreciated.
0debug
alert('Hello ' + user_input);
1threat
def tuple_to_int(nums): result = int(''.join(map(str,nums))) return result
0debug
static int xen_pt_config_reg_init(XenPCIPassthroughState *s, XenPTRegGroup *reg_grp, XenPTRegInfo *reg) { XenPTReg *reg_entry; uint32_t data = 0; int rc = 0; reg_entry = g_new0(XenPTReg, 1); reg_entry->reg = reg; if (reg->init) { rc = reg->init(s, reg_entry->reg, reg_grp->base_offset + reg->offset, &data); if (rc < 0) { free(reg_entry); return rc; } if (data == XEN_PT_INVALID_REG) { free(reg_entry); return 0; } reg_entry->data = data; } QLIST_INSERT_HEAD(&reg_grp->reg_tbl_list, reg_entry, entries); return 0; }
1threat
import re def check_substring(string, sample) : if (sample in string): y = "\A" + sample x = re.search(y, string) if x : return ("string starts with the given substring") else : return ("string doesnt start with the given substring") else : return ("entered string isnt a substring")
0debug
my tkinter wont quit when i press quit button it just changes location : this is the code and when i run it the quit button doesn't work: def quit2(): menu.destroy() def menu1(): menu=Tk() global menu play=Button(menu, text='play', command =main) play.pack() quit1=Button(menu, text='quit', command=quit2) quit1.pack() menu.mainloop() while True: menu1()
0debug
PCIDevice *pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn) { PCINE2000State *d; NE2000State *s; uint8_t *pci_conf; d = (PCINE2000State *)pci_register_device(bus, "NE2000", sizeof(PCINE2000State), devfn, NULL, NULL); pci_conf = d->dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_REALTEK); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_REALTEK_8029); pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET); pci_conf[0x0e] = 0x00; pci_conf[0x3d] = 1; pci_register_io_region(&d->dev, 0, 0x100, PCI_ADDRESS_SPACE_IO, ne2000_map); s = &d->ne2000; s->irq = d->dev.irq[0]; s->pci_dev = (PCIDevice *)d; memcpy(s->macaddr, nd->macaddr, 6); ne2000_reset(s); s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, ne2000_receive, ne2000_can_receive, s); qemu_format_nic_info_str(s->vc, s->macaddr); register_savevm("ne2000", -1, 3, ne2000_save, ne2000_load, s); return (PCIDevice *)d; }
1threat
What is the difference between Q_ENUM and Q_ENUMS : <p>I just found multiple examples showing the usage of <code>Q_ENUM</code> and <code>Q_ENUMS</code> and looking into the definition of <code>Q_ENUM</code> showed me that it includes <code>Q_ENUMS</code> and other definitions.</p> <p>I am not sure which one to write when using the enum in <code>Q_PROPERTY</code>, Qml/QtQuick, in signals/slots, QVariants and <code>qDebug()</code> output.</p> <p>It seems like the <code>Q_ENUM</code> is the better one as it is defined using <code>Q_ENUMS</code>, but I'm just guessing here.</p> <p>What exactly are the differences, why are there two at all and which one should be prefered?</p>
0debug
Delete SSH key without SSH access : <p>My sshd is refusing to restart because of the following error:</p> <p><code>@ WARNING: UNPROTECTED PRIVATE KEY FILE! @</code></p> <p>However, i cant figure out how to delete the unsafe ssh keys without having the ssh access. What to do?</p>
0debug
static void pc_compat_1_6(MachineState *machine) { pc_compat_1_7(machine); rom_file_has_mr = false; has_acpi_build = false; }
1threat
IOError: [Errno 28] No space left on device while installing TensorFlow : <p>I am trying to install TensorFlow in my local directory using the following command.</p> <pre><code>export TF_BINARY_URL=http://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0-cp27-none-linux_x86_64.whl pip install --install-option="--prefix=$PYTHONUSERBASE" --upgrade $TF_BINARY_URL </code></pre> <p>I am getting the following error:</p> <pre><code>IOError: [Errno 28] No space left on device </code></pre> <p>Then I did <code>df</code> to see the following:</p> <pre><code>Filesystem 1K-blocks Used Available Use% Mounted on tmpfs 10240 10240 0 100% /tmp tmpfs 10240 10240 0 100% /var/tmp </code></pre> <p>Is there a way I can install TF without the temp files being downloaded in <code>/tmp</code> or <code>/var/tmp</code>? Thanks.</p>
0debug
How to play video full screen in landscape using exoplayer : <p>I am using exoplayer to play video from url in my android app. In portrait everything work as expected (using viewpager, fragments and tabs inside activity). My goal is to play the video in full screen when the user is in landscape. It means only the video will play in landscape and all other details will desapear and return back to the original layout when portrait. How can I achieve this please? or what is the best way to achieve this? any sample code will be appreciate.</p> <p><a href="https://i.stack.imgur.com/xXOAd.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/xXOAd.jpg" alt="Video to be play when portrait"></a></p>
0debug
result of creating purchline with not existing purch order : While importing purchline through data import export framework with a purchase order that does not exist, will the Standard AX creates the purchase header or through an error stating that purchase id does not exist???
0debug
hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) { X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; target_ulong pde_addr, pte_addr; uint64_t pte; hwaddr paddr; uint32_t page_offset; int page_size; if (env->cr[4] & CR4_PAE_MASK) { target_ulong pdpe_addr; uint64_t pde, pdpe; #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) { uint64_t pml4e_addr, pml4e; int32_t sext; sext = (int64_t)addr >> 47; if (sext != 0 && sext != -1) return -1; pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) & env->a20_mask; pml4e = ldq_phys(pml4e_addr); if (!(pml4e & PG_PRESENT_MASK)) return -1; pdpe_addr = ((pml4e & ~0xfff & ~(PG_NX_MASK | PG_HI_USER_MASK)) + (((addr >> 30) & 0x1ff) << 3)) & env->a20_mask; pdpe = ldq_phys(pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) return -1; } else #endif { pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) & env->a20_mask; pdpe = ldq_phys(pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) return -1; } pde_addr = ((pdpe & ~0xfff & ~(PG_NX_MASK | PG_HI_USER_MASK)) + (((addr >> 21) & 0x1ff) << 3)) & env->a20_mask; pde = ldq_phys(pde_addr); if (!(pde & PG_PRESENT_MASK)) { return -1; } if (pde & PG_PSE_MASK) { page_size = 2048 * 1024; pte = pde & ~( (page_size - 1) & ~0xfff); } else { pte_addr = ((pde & ~0xfff & ~(PG_NX_MASK | PG_HI_USER_MASK)) + (((addr >> 12) & 0x1ff) << 3)) & env->a20_mask; page_size = 4096; pte = ldq_phys(pte_addr); } pte &= ~(PG_NX_MASK | PG_HI_USER_MASK); if (!(pte & PG_PRESENT_MASK)) return -1; } else { uint32_t pde; if (!(env->cr[0] & CR0_PG_MASK)) { pte = addr; page_size = 4096; } else { pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) & env->a20_mask; pde = ldl_phys(pde_addr); if (!(pde & PG_PRESENT_MASK)) return -1; if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { pte = pde & ~0x003ff000; page_size = 4096 * 1024; } else { pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask; pte = ldl_phys(pte_addr); if (!(pte & PG_PRESENT_MASK)) return -1; page_size = 4096; } } pte = pte & env->a20_mask; } page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1); paddr = (pte & TARGET_PAGE_MASK) + page_offset; return paddr; }
1threat
Calculate cumulative sum based on other columns in R : I have a data frame like this: wpt ID Fuel Dist Express Local 1 S36 12 1 1 0 2 S36 14 4 1 0 inter S36 15 7 0 1 3 S36 18 10 0 1 inter S36 20 12 1 0 4 S36 23 17 1 0 5 S36 30 20 1 0 6 W09 45 9 0 1 7 W09 48 14 0 1 8 W09 50 15 0 1 I want to get **cumulative sum of Fuel and Dist** under each **Express and Local type**. The ideal output would be: ID sum.fuel sum.dist Express Local S36 12 11 1 0 S36 3 3 0 1 W09 5 6 0 1 **Note:** There are **multiple blocks grouped by Express and Local**; To be clear, for **"S36"** under **Express** the cumulative fuel is defined by (14-12)+(23-20). Thanks in advance!!!
0debug
What's a space leak? : <p>I found the haskell wiki page on space leaks, which claims to list examples of real-world leaks, which it doesn't. It doesn't really say what a space leak is; it just links to the page for memory leaks. </p> <p>What's a space leak?</p>
0debug
static int print_size(DeviceState *dev, Property *prop, char *dest, size_t len) { uint64_t *ptr = qdev_get_prop_ptr(dev, prop); char suffixes[] = {'T', 'G', 'M', 'K', 'B'}; int i = 0; uint64_t div; for (div = 1ULL << 40; !(*ptr / div) ; div >>= 10) { i++; } return snprintf(dest, len, "%0.03f%c", (double)*ptr/div, suffixes[i]); }
1threat
static int get_logical_cpus(AVCodecContext *avctx) { int ret, nb_cpus = 1; #if HAVE_SCHED_GETAFFINITY && defined(CPU_COUNT) cpu_set_t cpuset; CPU_ZERO(&cpuset); ret = sched_getaffinity(0, sizeof(cpuset), &cpuset); if (!ret) { nb_cpus = CPU_COUNT(&cpuset); } #elif HAVE_GETSYSTEMINFO SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); nb_cpus = sysinfo.dwNumberOfProcessors; #elif HAVE_SYSCTL && defined(HW_NCPU) int mib[2] = { CTL_HW, HW_NCPU }; size_t len = sizeof(nb_cpus); ret = sysctl(mib, 2, &nb_cpus, &len, NULL, 0); if (ret == -1) nb_cpus = 0; #elif HAVE_SYSCONF && defined(_SC_NPROC_ONLN) nb_cpus = sysconf(_SC_NPROC_ONLN); #elif HAVE_SYSCONF && defined(_SC_NPROCESSORS_ONLN) nb_cpus = sysconf(_SC_NPROCESSORS_ONLN); #endif av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus); return FFMIN(nb_cpus, MAX_AUTO_THREADS); }
1threat
static void apply_mdct(AC3EncodeContext *s) { int blk, ch; for (ch = 0; ch < s->channels; ch++) { for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { AC3Block *block = &s->blocks[blk]; const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE]; apply_window(&s->dsp, s->windowed_samples, input_samples, s->mdct.window, AC3_WINDOW_SIZE); block->exp_shift[ch] = normalize_samples(s); mdct512(&s->mdct, block->mdct_coef[ch], s->windowed_samples); } } }
1threat
im trying to find the volume of a shape but the definition is not working : <p>i want the code to ask for the radius and length then the program will calculate pi<em>radius</em>radius*length from the definition area the print out the radius for example if at asks me the radius i put 5 same with the length it should say the volume is 392.75 </p> <pre><code>def calculate_volume(radius, length): pi=3.142 vol=pi*radius*radius*length #main program radius = int(input("enter radius: ")) length = int(input("enter length: ")) volume = calculate_volume(radius, length) print("the volume: ",volume) </code></pre>
0debug
How to set RecyclerView Max Height : <p>I want to set Max Height of RecylerView.I am able to set max height using below code.Below code makes height 60% of current screen.</p> <pre><code> DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int a = (displaymetrics.heightPixels * 60) / 100; recyclerview1.getLayoutParams().height = a; </code></pre> <p>But now problem is that, if it have no item then also its height is 60%. So I want to set its height 0 when no item in it.</p> <p>I want to achieve like something.</p> <pre><code> if(recyclerview's height &gt; maxHeight) then set recyclerview's height to maxHeight else dont change the height of recyclerview. </code></pre> <p>How can i set it? Please help me, I am stuck with it</p>
0debug
int qed_write_l1_table_sync(BDRVQEDState *s, unsigned int index, unsigned int n) { int ret = -EINPROGRESS; async_context_push(); qed_write_l1_table(s, index, n, qed_sync_cb, &ret); while (ret == -EINPROGRESS) { qemu_aio_wait(); } async_context_pop(); return ret; }
1threat
read huge file using for loop : I have a huge file abc.txt and wanted to read line by line, not all at once. I can do as below: filename="c:\abc.txt" with open (filename, "r") as fb: for content in fb: # do something .... I am not understanding here one thing. As you see "fb" is a file pointer over here. How the "for" loop is processing the pointer directly internally even without using any readline or read function ?
0debug
sigterm_handler(int sig) { received_sigterm = sig; received_nb_signals++; term_exit_sigsafe(); if(received_nb_signals > 3) exit_program(123); }
1threat
JAVA: Implementing a Demo/Tester Program : I have a project for my java programming course. The **instructions** are that we have to create a simple class and a tester class, and the class must include a Default constructor; Parameterized constructor with three parameters (make, model and price); Accessor method called getMake( ) to return the make; Accessor method called getModel( ) to return the model; Accessor method called getPrice( ) to return the price; Mutator method setMake( String newMake) to set the make; Mutator method setModel( String newModel) to set the model; and a Mutator method setPrice( double newPrice ) to set the price.. I have created my class and tester program, and my class compiles perfectly. *When I try to run it, though get the error that there is no main method*. Now, I followed my professor's example for the tester program and I get several errors on that. If anyone could give me the a pointer in the right direction, I would appreciate it. **My question is this: How do I implement my tester program?** Do I need to create a zip file? I've tried doing so and didn't seem to help much... The following is my code for the class: public class Automobile { private String make; private String model; private double price; public Automobile() { make = "Lexus2017"; model = "RX"; } public Automobile(String initMake, String initModel, double initPrice) { make = initMake; model = initModel; price = initPrice; } public String getMake() { return make; } public String getModel() { return model; } public double getPrice() { return price; } public void setMake(String newMake) { make = newMake; } public void setModel(String newModel) { model = newModel; } Also, the following is my tester class(the one that has a lot of errors): public class AutomobileTester { public static void main(String[] args) { Automobile make = new Automobile("Lexus 2017"); System.out.println("The car is " + make.getMake()); Automobile model = new Automobile("RX"); System.out.println("The car is " + Automobile.getModel()); Automobile price = new Automobile("43020"); System.out.println("The car is " + Automobile.getPrice()); // Use the mutator to change the make variable Automobile.setMake("Lexus 2017"); System.out.println("The car is " + backDoor.getState()); // Use the mutator to change the model variable Automobile.setModel("RX"); System.out.println("The car is called " + backDoor.getName()); Automobile.setPrice("43020"); System.out.println("The car is " + price.getPrice()); } } *This is my first time working with constructors, and I'm very new to Java, so I'm sorry for any obvious errors. Thank you ahead of time for your time and help.*
0debug
void cpu_exit(CPUArchState *env) { CPUState *cpu = ENV_GET_CPU(env); cpu->exit_request = 1; cpu_unlink_tb(cpu); }
1threat
Is there any limit of data while tcp transfering between Client-server? : <p>I want to transfer 32k data between client-server with WinSock2. Is it possible or there is a limitation with data?</p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
static ssize_t usbnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size) { USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque; struct rndis_packet_msg_type *msg; if (s->rndis) { msg = (struct rndis_packet_msg_type *) s->in_buf; if (!s->rndis_state == RNDIS_DATA_INITIALIZED) return -1; if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf)) return -1; memset(msg, 0, sizeof(struct rndis_packet_msg_type)); msg->MessageType = cpu_to_le32(RNDIS_PACKET_MSG); msg->MessageLength = cpu_to_le32(size + sizeof(struct rndis_packet_msg_type)); msg->DataOffset = cpu_to_le32(sizeof(struct rndis_packet_msg_type) - 8); msg->DataLength = cpu_to_le32(size); memcpy(msg + 1, buf, size); s->in_len = size + sizeof(struct rndis_packet_msg_type); } else { if (size > sizeof(s->in_buf)) return -1; memcpy(s->in_buf, buf, size); s->in_len = size; } s->in_ptr = 0; return size; }
1threat
i have to show all the rows in my query where in here am i making mistakes. : -- public Section SectionView(object id, SqlConnection conn) { using (SqlCommand cmd = new SqlCommand()) { if (conn.State == ConnectionState.Closed) conn.Open(); SqlDataAdapter sqlda = new SqlDataAdapter("TMR_SECTION_VIEW", conn); SqlDataAdapter da = new SqlDataAdapter("data", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "TMR_SECTION_VIEW"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@sectionID", id.ToString); cmd.Parameters.AddWithValue("@name", name); da.SelectCommand = cmd; DataTable dt = new DataTable(); DataTable dtbl = new DataTable(); sqlda.Fill(dtbl); cmd.ExecuteNonQuery(); return id; } } my store procedures query is ALTER PROCEDURE [dbo].[TMR_SECTION_VIEW] @sectionID int, @name varchar(100) AS BEGIN SELECT * FROM Section Where sectionid = @sectionID END
0debug
static void disas_simd_3same_int(DisasContext *s, uint32_t insn) { int is_q = extract32(insn, 30, 1); int u = extract32(insn, 29, 1); int size = extract32(insn, 22, 2); int opcode = extract32(insn, 11, 5); int rm = extract32(insn, 16, 5); int rn = extract32(insn, 5, 5); int rd = extract32(insn, 0, 5); int pass; switch (opcode) { case 0x13: if (u && size != 0) { unallocated_encoding(s); return; } case 0x0: case 0x2: case 0x4: case 0xc: case 0xd: case 0xe: case 0xf: case 0x12: if (size == 3) { unallocated_encoding(s); return; } break; case 0x16: if (size == 0 || size == 3) { unallocated_encoding(s); return; } break; default: if (size == 3 && !is_q) { unallocated_encoding(s); return; } break; } if (!fp_access_check(s)) { return; } if (size == 3) { for (pass = 0; pass < (is_q ? 2 : 1); pass++) { TCGv_i64 tcg_op1 = tcg_temp_new_i64(); TCGv_i64 tcg_op2 = tcg_temp_new_i64(); TCGv_i64 tcg_res = tcg_temp_new_i64(); read_vec_element(s, tcg_op1, rn, pass, MO_64); read_vec_element(s, tcg_op2, rm, pass, MO_64); handle_3same_64(s, opcode, u, tcg_res, tcg_op1, tcg_op2); write_vec_element(s, tcg_res, rd, pass, MO_64); tcg_temp_free_i64(tcg_res); tcg_temp_free_i64(tcg_op1); tcg_temp_free_i64(tcg_op2); } } else { for (pass = 0; pass < (is_q ? 4 : 2); pass++) { TCGv_i32 tcg_op1 = tcg_temp_new_i32(); TCGv_i32 tcg_op2 = tcg_temp_new_i32(); TCGv_i32 tcg_res = tcg_temp_new_i32(); NeonGenTwoOpFn *genfn = NULL; NeonGenTwoOpEnvFn *genenvfn = NULL; read_vec_element_i32(s, tcg_op1, rn, pass, MO_32); read_vec_element_i32(s, tcg_op2, rm, pass, MO_32); switch (opcode) { case 0x0: { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_hadd_s8, gen_helper_neon_hadd_u8 }, { gen_helper_neon_hadd_s16, gen_helper_neon_hadd_u16 }, { gen_helper_neon_hadd_s32, gen_helper_neon_hadd_u32 }, }; genfn = fns[size][u]; break; } case 0x1: { static NeonGenTwoOpEnvFn * const fns[3][2] = { { gen_helper_neon_qadd_s8, gen_helper_neon_qadd_u8 }, { gen_helper_neon_qadd_s16, gen_helper_neon_qadd_u16 }, { gen_helper_neon_qadd_s32, gen_helper_neon_qadd_u32 }, }; genenvfn = fns[size][u]; break; } case 0x2: { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_rhadd_s8, gen_helper_neon_rhadd_u8 }, { gen_helper_neon_rhadd_s16, gen_helper_neon_rhadd_u16 }, { gen_helper_neon_rhadd_s32, gen_helper_neon_rhadd_u32 }, }; genfn = fns[size][u]; break; } case 0x4: { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_hsub_s8, gen_helper_neon_hsub_u8 }, { gen_helper_neon_hsub_s16, gen_helper_neon_hsub_u16 }, { gen_helper_neon_hsub_s32, gen_helper_neon_hsub_u32 }, }; genfn = fns[size][u]; break; } case 0x5: { static NeonGenTwoOpEnvFn * const fns[3][2] = { { gen_helper_neon_qsub_s8, gen_helper_neon_qsub_u8 }, { gen_helper_neon_qsub_s16, gen_helper_neon_qsub_u16 }, { gen_helper_neon_qsub_s32, gen_helper_neon_qsub_u32 }, }; genenvfn = fns[size][u]; break; } case 0x6: { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_cgt_s8, gen_helper_neon_cgt_u8 }, { gen_helper_neon_cgt_s16, gen_helper_neon_cgt_u16 }, { gen_helper_neon_cgt_s32, gen_helper_neon_cgt_u32 }, }; genfn = fns[size][u]; break; } case 0x7: { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_cge_s8, gen_helper_neon_cge_u8 }, { gen_helper_neon_cge_s16, gen_helper_neon_cge_u16 }, { gen_helper_neon_cge_s32, gen_helper_neon_cge_u32 }, }; genfn = fns[size][u]; break; } case 0x8: { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_shl_s8, gen_helper_neon_shl_u8 }, { gen_helper_neon_shl_s16, gen_helper_neon_shl_u16 }, { gen_helper_neon_shl_s32, gen_helper_neon_shl_u32 }, }; genfn = fns[size][u]; break; } case 0x9: { static NeonGenTwoOpEnvFn * const fns[3][2] = { { gen_helper_neon_qshl_s8, gen_helper_neon_qshl_u8 }, { gen_helper_neon_qshl_s16, gen_helper_neon_qshl_u16 }, { gen_helper_neon_qshl_s32, gen_helper_neon_qshl_u32 }, }; genenvfn = fns[size][u]; break; } case 0xa: { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_rshl_s8, gen_helper_neon_rshl_u8 }, { gen_helper_neon_rshl_s16, gen_helper_neon_rshl_u16 }, { gen_helper_neon_rshl_s32, gen_helper_neon_rshl_u32 }, }; genfn = fns[size][u]; break; } case 0xb: { static NeonGenTwoOpEnvFn * const fns[3][2] = { { gen_helper_neon_qrshl_s8, gen_helper_neon_qrshl_u8 }, { gen_helper_neon_qrshl_s16, gen_helper_neon_qrshl_u16 }, { gen_helper_neon_qrshl_s32, gen_helper_neon_qrshl_u32 }, }; genenvfn = fns[size][u]; break; } case 0xc: { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_max_s8, gen_helper_neon_max_u8 }, { gen_helper_neon_max_s16, gen_helper_neon_max_u16 }, { gen_max_s32, gen_max_u32 }, }; genfn = fns[size][u]; break; } case 0xd: { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_min_s8, gen_helper_neon_min_u8 }, { gen_helper_neon_min_s16, gen_helper_neon_min_u16 }, { gen_min_s32, gen_min_u32 }, }; genfn = fns[size][u]; break; } case 0xe: case 0xf: { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_abd_s8, gen_helper_neon_abd_u8 }, { gen_helper_neon_abd_s16, gen_helper_neon_abd_u16 }, { gen_helper_neon_abd_s32, gen_helper_neon_abd_u32 }, }; genfn = fns[size][u]; break; } case 0x10: { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_add_u8, gen_helper_neon_sub_u8 }, { gen_helper_neon_add_u16, gen_helper_neon_sub_u16 }, { tcg_gen_add_i32, tcg_gen_sub_i32 }, }; genfn = fns[size][u]; break; } case 0x11: { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_tst_u8, gen_helper_neon_ceq_u8 }, { gen_helper_neon_tst_u16, gen_helper_neon_ceq_u16 }, { gen_helper_neon_tst_u32, gen_helper_neon_ceq_u32 }, }; genfn = fns[size][u]; break; } case 0x13: if (u) { assert(size == 0); genfn = gen_helper_neon_mul_p8; break; } case 0x12: { static NeonGenTwoOpFn * const fns[3] = { gen_helper_neon_mul_u8, gen_helper_neon_mul_u16, tcg_gen_mul_i32, }; genfn = fns[size]; break; } case 0x16: { static NeonGenTwoOpEnvFn * const fns[2][2] = { { gen_helper_neon_qdmulh_s16, gen_helper_neon_qrdmulh_s16 }, { gen_helper_neon_qdmulh_s32, gen_helper_neon_qrdmulh_s32 }, }; assert(size == 1 || size == 2); genenvfn = fns[size - 1][u]; break; } default: g_assert_not_reached(); } if (genenvfn) { genenvfn(tcg_res, cpu_env, tcg_op1, tcg_op2); } else { genfn(tcg_res, tcg_op1, tcg_op2); } if (opcode == 0xf || opcode == 0x12) { static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_add_u8, gen_helper_neon_sub_u8 }, { gen_helper_neon_add_u16, gen_helper_neon_sub_u16 }, { tcg_gen_add_i32, tcg_gen_sub_i32 }, }; bool is_sub = (opcode == 0x12 && u); genfn = fns[size][is_sub]; read_vec_element_i32(s, tcg_op1, rd, pass, MO_32); genfn(tcg_res, tcg_op1, tcg_res); } write_vec_element_i32(s, tcg_res, rd, pass, MO_32); tcg_temp_free_i32(tcg_res); tcg_temp_free_i32(tcg_op1); tcg_temp_free_i32(tcg_op2); } } if (!is_q) { clear_vec_high(s, rd); } }
1threat
void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, MemoryRegion *mr, uint64_t align, bool gap, Error **errp) { int slot; MachineState *machine = MACHINE(qdev_get_machine()); PCDIMMDevice *dimm = PC_DIMM(dev); Error *local_err = NULL; uint64_t existing_dimms_capacity = 0; uint64_t addr; addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err); if (local_err) { addr = pc_dimm_get_free_addr(hpms->base, memory_region_size(&hpms->mr), !addr ? NULL : &addr, align, gap, memory_region_size(mr), &local_err); if (local_err) { existing_dimms_capacity = pc_existing_dimms_capacity(&local_err); if (local_err) { if (existing_dimms_capacity + memory_region_size(mr) > machine->maxram_size - machine->ram_size) { error_setg(&local_err, "not enough space, currently 0x%" PRIx64 " in use of total hot pluggable 0x" RAM_ADDR_FMT, existing_dimms_capacity, machine->maxram_size - machine->ram_size); object_property_set_int(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err); if (local_err) { trace_mhp_pc_dimm_assigned_address(addr); slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, &local_err); if (local_err) { slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL : &slot, machine->ram_slots, &local_err); if (local_err) { object_property_set_int(OBJECT(dev), slot, PC_DIMM_SLOT_PROP, &local_err); if (local_err) { trace_mhp_pc_dimm_assigned_slot(slot); if (kvm_enabled() && !kvm_has_free_slot(machine)) { error_setg(&local_err, "hypervisor has no free memory slots left"); memory_region_add_subregion(&hpms->mr, addr - hpms->base, mr); vmstate_register_ram(mr, dev); numa_set_mem_node_id(addr, memory_region_size(mr), dimm->node); out: error_propagate(errp, local_err);
1threat
Python, Error: "function is not defined" , : <p>I have 2 <code>@classmethod</code>: one of them is 'operators' and other one is 'pretty_print_2'. in 'operators' i need to call 'pretty_print_2'. </p> <p>The first method is as follow:</p> <pre><code> @classmethod def operators(cls, operator_filter=None, limit_filter=0, ncores=1, exec_mode='sync'): ... response = None try: if Cube.client is None: raise RuntimeError('Cube.client is None') query = 'oph_operators_list ' if operator_filter is not None: query += 'operator_filter=' + str(operator_filter) + ';' if limit_filter is not None: query += 'limit_filter=' + str(limit_filter) + ';' if ncores is not None: query += 'ncores=' + str(ncores) + ';' if exec_mode is not None: query += 'exec_mode=' + str(exec_mode) + ';' if Cube.client.submit(query) is None: raise RuntimeError() if Cube.client.last_response is not None: response = Cube.client.deserialize_response() except Exception as e: print(get_linenumber(), "Something went wrong:", e) raise RuntimeError() else: cls.pretty_print_2(response) </code></pre> <p>The second method is as follow:</p> <pre><code>@classmethod def pretty_print_2(response): </code></pre> <p>but when i run the script I faced the following error:</p> <pre><code> cls.pretty_print_2(response) TypeError: pretty_print_2() takes 1 positional argument but 2 were given </code></pre> <p>I will be appreciated for any suggestion. Thank you.</p>
0debug
DateTime + 12 hours showing same DateTime. Why? : <p>When I am increasing DateTime value by any hours, the result is OKAY, but when I increase it by 12 hours, it is not increasing. <hr/> Please see the following code for details: <br/><br/><br/><br/></p> <pre><code>$creation_date = new DateTime('2016-09-07 06:00:00', new DateTimeZone('Asia/Kolkata')); $expiration_date = new DateTime('2016-09-07 06:00:00', new DateTimeZone('Asia/Kolkata')); </code></pre> <p>When I increase the <code>$expiration_date</code> variable by 1 hour, 3 hour, 8 hour, 24 hours etc., the result is perfect. For example,</p> <p>Case 1:<br/> </p> <pre><code>$expiration_date-&gt;add(new DateInterval('PT1H')); echo "Creation Date: ".$creation_date-&gt;format('Asia/Kolkata')."&lt;br/&gt;Expiration Date: ".$expiration_date-&gt;format('Asia/Kolkata'); </code></pre> <p>Result 1:<br/><br> Creation Date: 2016-09-07 06:00:00<br/> Expiration Date: 2016-09-07 07:00:00</p> <p>Case 2:<br/> </p> <pre><code>$expiration_date-&gt;add(new DateInterval('PT3H')); echo "Creation Date: ".$creation_date-&gt;format('Asia/Kolkata')."&lt;br/&gt;Expiration Date: ".$expiration_date-&gt;format('Asia/Kolkata'); </code></pre> <p>Result 2:<br/> Creation Date: 2016-09-07 06:00:00<br/> Expiration Date: 2016-09-07 09:00:00</p> <p>Case 3:<br/> </p> <pre><code>$expiration_date-&gt;add(new DateInterval('PT8H')); echo "Creation Date: ".$creation_date-&gt;format('Asia/Kolkata')."&lt;br/&gt;Expiration Date: ".$expiration_date-&gt;format('Asia/Kolkata'); </code></pre> <p>Result 3:<br/> Creation Date: 2016-09-07 06:00:00<br/> Expiration Date: 2016-09-07 02:00:00</p> <p>Case 4:<br/> </p> <pre><code>$expiration_date-&gt;add(new DateInterval('PT24H')); echo "Creation Date: ".$creation_date-&gt;format('Asia/Kolkata')."&lt;br/&gt;Expiration Date: ".$expiration_date-&gt;format('Asia/Kolkata'); </code></pre> <p>Result 4:<br/> Creation Date: 2016-09-07 06:00:00<br/> Expiration Date: 2016-09-08 06:00:00</p> <p><strong>But when I increase the <code>$expiration_date</code> variable by <em>12 hours</em>, the date is not getting increased!<br/><br/>They are showing the same datetime!</strong></p> <p>Case 5:<br/> </p> <pre><code>$expiration_date-&gt;add(new DateInterval('PT12H')); echo "Creation Date: ".$creation_date-&gt;format('Asia/Kolkata')."&lt;br/&gt;Expiration Date: ".$expiration_date-&gt;format('Asia/Kolkata'); </code></pre> <p>Result 5:<br/> Creation Date: 2016-09-07 06:00:00<br/> Expiration Date: 2016-09-07 06:00:00 <br/><br/><br/><br/> What am I doing wrong?</p>
0debug
How to use CMD to backup files to .zip for archive : So this one's a multi-parter (Windows 7) I have a folder structure as so: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> C: SyncFolder Backups [User] FolderA Subfolder1 Subfolder2 FolderB Subfolder3 <!-- end snippet --> My aim is to use the folder 'SyncFolder' as a backup system for certain files (Sync folder is actually a folder placed there by a file syncing service). At present, I have the following within the Sync folder: - a .bat file containing a ROBOCOPY command (which copies 1 file) - a .vbs file which is used to call the .bat file (to avoid the CMD window appearing). This VBS file is being called once per hour by Windows Task Scheduler - the file which is being copied So here are my questions: I'm looking for a code (preferably an edit to the existing .bat, as I'm not overly-technical) which can: - Copy Subfolder1 in its entirety into a .zip file, which is named YYYYMMDDHHMM_SubFolder1_Backup (where the date & time is automatically populated) - Move the newly-created .zip file to SyncFolder\Backups (or create it there in the first place?) - Deletes (or overwrites?) the previous backup - Repeats for each Subfolder specified (perhaps as an additional command line?) - Logs the details of the backup to a .log file located in SyncFolder (i.e. Name of .zip created, Date&Time of backup, size of .zip created) **I'm aware this might be a bit ambitious for CMD or a .bat, but I'm open to any suggestions, but please do bear in mind that I'm not highly technical, so any walk-throughs would be immensely appreciated!**
0debug
Store Parsed JSON on the SharedPreferences? : I am Able to Parse JSON Data.Exactly what is the issue is that ,i want to store the Student ID in the SharedPreference without suffix i.e means only the integer is to be stored? I have tried to split the JSON Value with REGEX but not able,since i have not used regex.How can this issue be solved?? { "StdID":S001, "NAME":"Kirsten Green", "PHONENO":"095-517-0049", "DOB":"2009-12-28T00:00:00", "CLASS":9, "GENDER":"M", "ADDRESS":"8254 At Ave", "NATIONALITY":"Belgium", "ENROLLEDYEAR":"2016-04-21T00:00:00", "Photo":null, "Cat_ID":5, "base64":null, "studentDetails":{ "StdID":1, "GUARDIAN_PHONE_NO":"002-283-4824", "MOBILE_NO":"1-377-762-8548", "First_NAME":"Maile", "Last_Name":"Lancaster", "Relation":"Father", "DOB":"2017-02-22T00:00:00", "Education":"Ph.D", "Occupation":"Etiam ligula tortor,", "Income":"20000-30000", "Email":"urna@sed.ca", "AddLine1":"Ap #416-4247 Sollicitudin Av.", "AddLine2":"Ap #801-7380 Imperdiet Avenue", "State":"ME", "Country":"Israel" }, "Marks":null, "stdCategory":{ "Cat_ID":5, "Category":"Normal" } } My Java Class public class Login extends AppCompatActivity implements View.OnClickListener { EditText userName, Password; Button login; public static final String LOGIN_URL = "http://192.168.100.5:84/Token"; public static final String KEY_USERNAME = "UserName"; public static final String KEY_PASSWORD = "Password"; String username, password; String accesstoken, tokentype, expiresin, masterid, name, access, issue, expires; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); userName = (EditText) findViewById(R.id.login_name); Password = (EditText) findViewById(R.id.login_password); userName.setHint(Html.fromHtml("<font color='#008b8b' style='italic'>Username</font>")); Password.setHint(Html.fromHtml("<font color='#008b8b'>Password</font>")); login = (Button) findViewById(R.id.login); login.setOnClickListener(this); } private void UserLogin() { username = userName.getText().toString().trim(); password = Password.getText().toString().trim(); StringRequest stringRequest = new StringRequest(Request.Method.POST, LOGIN_URL, new Response.Listener<String>() { @Override public void onResponse(String response) { try { JSONObject jsonObject = new JSONObject(response); accesstoken = jsonObject.getString("access_token"); tokentype = jsonObject.getString("token_type"); expiresin = jsonObject.getString("expires_in"); username = jsonObject.getString("userName"); masterid = jsonObject.getString("MasterID"); //String[] parts = masterid.split("[0-9]"); //System.out.println(Arrays.toString(parts)); // parts = masterid.split("/[0-9]/g"); // parts = masterid.preg_replace('/[^0-9]/', '', $string); name = jsonObject.getString("Name"); access = jsonObject.getString("Access"); issue = jsonObject.getString(".issued"); expires = jsonObject.getString(".expires"); SessionManagement session = new SessionManagement(Login.this); session.createLoginSession(accesstoken, tokentype, expiresin, username, masterid, name, access, issue, expires); // System.out.println(Arrays.toString(parts)); openProfile(); } catch (JSONException e) { Toast.makeText(getApplicationContext(), "Fetch failed!", Toast.LENGTH_SHORT).show(); e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(Login.this, error.toString(), Toast.LENGTH_LONG).show(); } }) { @Override public Map<String, String> getHeaders() throws AuthFailureError { Map<String, String> params = new HashMap<String, String>(); // params.put("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); return params; } @Override protected Map<String, String> getParams() { Map<String, String> map = new HashMap<String, String>(); map.put(KEY_USERNAME, username); map.put(KEY_PASSWORD, password); map.put("grant_type", "password"); return map; } }; stringRequest.setRetryPolicy(new DefaultRetryPolicy( 60000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); RequestQueue requestQueue = Volley.newRequestQueue(this); requestQueue.add(stringRequest); } private void openProfile() { Intent intent = new Intent(this, Home.class); intent.putExtra(KEY_USERNAME, username); startActivity(intent); } @Override public void onClick(View v) { UserLogin(); } } can we neglect suffix used in JSON Data and store only integer?
0debug
PHP, preg_match and double quotes : <p>I am a complete noob here. I am trying to extract Marine Corp. (without quotes from $data. I've searched and searched for how to deal with double quotes but am coming up short. Can someone please offer some guidance? Thank you. </p> <pre><code>$data = '"title":{"rendered":"Marine Corp."}'; preg_match('/title":{"rendered":"(.*)"}/U',$data,$matches); echo $matches[0]; //=&gt; target </code></pre>
0debug
How can we build and distribute python scripts in a windows environment : <p>My team is enjoying using python to solve problems for our business. We write many small independent scripty applications.</p> <p>However, we have to have a central windows box that runs these along with legacy applications.</p> <p>Our challenge is going through a build and deploy process.</p> <p>We want to have Bamboo check the script out of git, install requirements and run tests, then if all is green, just deploy to our production box.</p> <p>We'd like libraries to be isolated from script to script so we don't have dependency issues.</p> <p>We've tried to get virtualenvs to be portable but that seems a no go.</p> <p>Pex looked promising, but it doesn't work on windows.</p> <p>Ideally you'd see a folder like so:</p> <pre><code>AppOne /Script.py /Libs /bar.egg /foo.egg AppTwo /Script2.py /Libs /fnord.egg /fleebly.py </code></pre> <p>Are we thinking about this wrong? What's the pythonic way to distribute scripts within an enterprise?</p>
0debug
int bdrv_pwrite(BlockDriverState *bs, int64_t offset, const void *buf, int bytes) { QEMUIOVector qiov; struct iovec iov = { .iov_base = (void *) buf, .iov_len = bytes, }; if (bytes < 0) { return -EINVAL; } qemu_iovec_init_external(&qiov, &iov, 1); return bdrv_pwritev(bs, offset, &qiov); }
1threat
How can i access a method inside the another method in another class? : Whenever I create an Android app. I use a switch statement to access multiple buttons. When I click a button how can I understand which button was pressed., from another class? The other class is not an activity class. can anyone show me the right code.? for better understand. My first class is... public void onClick(View v){ switch (v.getId()){ case R.id.button1 : GifView.mymethod(R.id.button1); final Dialog dialog1=new Dialog(context); dialog1.setContentView(R.layout.dialog); Button finish1= (Button) dialog1.findViewById(R.id.finish); finish1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog1.dismiss(); } }); dialog1.show(); break; I want pass this button id onto another class.. private void init(Context context) { switch(?????){ case R.id.button1: setFocusable(true); gifInputStream = getResources().openRawResource(R.drawable.hen); gifMovie = Movie.decodeStream(gifInputStream); movieWidth = gifMovie.width(); movieHeight = gifMovie.height(); movieDuration = gifMovie.duration(); break; what can i do inside the switch statement? public static int mymethod(int id) { int buttonId=id; return buttonId; }
0debug
int qsv_transcode_init(OutputStream *ost) { InputStream *ist; const enum AVPixelFormat *pix_fmt; AVDictionaryEntry *e; const AVOption *opt; int flags = 0; int err, i; QSVContext *qsv = NULL; AVQSVContext *hwctx = NULL; mfxIMPL impl; mfxVersion ver = { { 3, 1 } }; if (!ost->enc->pix_fmts) return 0; for (pix_fmt = ost->enc->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++) if (*pix_fmt == AV_PIX_FMT_QSV) break; if (*pix_fmt == AV_PIX_FMT_NONE) return 0; if (strcmp(ost->avfilter, "null") || ost->source_index < 0) return 0; ist = input_streams[ost->source_index]; if (ist->hwaccel_id != HWACCEL_QSV || !ist->dec || !ist->dec->pix_fmts) return 0; for (pix_fmt = ist->dec->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++) if (*pix_fmt == AV_PIX_FMT_QSV) break; if (*pix_fmt == AV_PIX_FMT_NONE) return 0; for (i = 0; i < nb_output_streams; i++) if (output_streams[i] != ost && output_streams[i]->source_index == ost->source_index) return 0; av_log(NULL, AV_LOG_VERBOSE, "Setting up QSV transcoding\n"); qsv = av_mallocz(sizeof(*qsv)); hwctx = av_qsv_alloc_context(); if (!qsv || !hwctx) goto fail; impl = choose_implementation(ist); err = MFXInit(impl, &ver, &qsv->session); if (err != MFX_ERR_NONE) { av_log(NULL, AV_LOG_ERROR, "Error initializing an MFX session: %d\n", err); goto fail; } e = av_dict_get(ost->encoder_opts, "flags", NULL, 0); opt = av_opt_find(ost->enc_ctx, "flags", NULL, 0, 0); if (e && opt) av_opt_eval_flags(ost->enc_ctx, opt, e->value, &flags); qsv->ost = ost; hwctx->session = qsv->session; hwctx->iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY; hwctx->opaque_alloc = 1; hwctx->nb_opaque_surfaces = 16; ost->hwaccel_ctx = qsv; ost->enc_ctx->hwaccel_context = hwctx; ost->enc_ctx->pix_fmt = AV_PIX_FMT_QSV; ist->hwaccel_ctx = qsv; ist->dec_ctx->pix_fmt = AV_PIX_FMT_QSV; ist->resample_pix_fmt = AV_PIX_FMT_QSV; return 0; fail: av_freep(&hwctx); av_freep(&qsv); return AVERROR_UNKNOWN; }
1threat
int avcodec_close(AVCodecContext *avctx) { if (ff_lockmgr_cb) { if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN)) return -1; } entangled_thread_counter++; if(entangled_thread_counter != 1){ av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); entangled_thread_counter--; return -1; } if (HAVE_THREADS && avctx->thread_opaque) avcodec_thread_free(avctx); if (avctx->codec->close) avctx->codec->close(avctx); avcodec_default_free_buffers(avctx); av_freep(&avctx->priv_data); avctx->codec = NULL; entangled_thread_counter--; if (ff_lockmgr_cb) { (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE); } return 0; }
1threat