problem
stringlengths
26
131k
labels
class label
2 classes
static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size) { struct XenNetDev *netdev = qemu_get_nic_opaque(nc); netif_rx_request_t rxreq; RING_IDX rc, rp; void *page; if (netdev->xendev.be_state != XenbusStateConnected) { return -1; } rc = netdev->rx_ring.req_cons; rp = netdev->rx_ring.sring->req_prod; xen_rmb(); if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) { xen_be_printf(&netdev->xendev, 2, "no buffer, drop packet\n"); return -1; } if (size > XC_PAGE_SIZE - NET_IP_ALIGN) { xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)", (unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN); return -1; } memcpy(&rxreq, RING_GET_REQUEST(&netdev->rx_ring, rc), sizeof(rxreq)); netdev->rx_ring.req_cons = ++rc; page = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev, netdev->xendev.dom, rxreq.gref, PROT_WRITE); if (page == NULL) { xen_be_printf(&netdev->xendev, 0, "error: rx gref dereference failed (%d)\n", rxreq.gref); net_rx_response(netdev, &rxreq, NETIF_RSP_ERROR, 0, 0, 0); return -1; } memcpy(page + NET_IP_ALIGN, buf, size); xc_gnttab_munmap(netdev->xendev.gnttabdev, page, 1); net_rx_response(netdev, &rxreq, NETIF_RSP_OKAY, NET_IP_ALIGN, size, 0); return size; }
1threat
Number Value Input Exception : <p>I trying to solve this code so it repeats exception until input is a number. right now it stop right first attempt and I do know how to place while loop.</p> <pre><code>int nomer2; WriteLine("Write Number"); try { nomer2 = Convert.ToInt32(ReadLine()); WriteLine("here is my Number {0}", nomer2); } catch (Exception) { WriteLine("Error: Enter Number"); } </code></pre>
0debug
static uint64_t sectors_covered_by_bitmap_cluster(const BDRVQcow2State *s, const BdrvDirtyBitmap *bitmap) { uint32_t sector_granularity = bdrv_dirty_bitmap_granularity(bitmap) >> BDRV_SECTOR_BITS; return (uint64_t)sector_granularity * (s->cluster_size << 3); }
1threat
how to sort the date list in python : <p>I have a list in python as follows..</p> <pre><code>[Timestamp('2016-01-03 10:38:52'), Timestamp('2016-01-18 09:37:29'), Timestamp('2016-02-06 09:44:44'), Timestamp('2016-02-07 11:11:28'), Timestamp('2016-02-15 11:24:41'), Timestamp('2016-02-20 12:46:07'), Timestamp('2016-02-21 11:07:11')] </code></pre> <p>I want to sort this with ascending order</p> <p>I tried with <code>temp_list.sort()</code> but it does not display any output</p>
0debug
how can i check from an url that an .html extension is present or not : i store a list of url in a sting array , i wants to check whether there is .html extension present or not in the last of each url. String line[]={"https://google.com","http://www.deathbycaptcha.com/user/login.html"}; for( int i=0;i<=line.length;i++) { int m=line[i].length(); System.out.println(" lenth of url "+m); } i am unable to find that logic. please help me. thanks in advance.
0debug
static bool bdrv_exceed_iops_limits(BlockDriverState *bs, bool is_write, double elapsed_time, uint64_t *wait) { uint64_t iops_limit = 0; double ios_limit, ios_base; double slice_time, wait_time; if (bs->io_limits.iops[BLOCK_IO_LIMIT_TOTAL]) { iops_limit = bs->io_limits.iops[BLOCK_IO_LIMIT_TOTAL]; } else if (bs->io_limits.iops[is_write]) { iops_limit = bs->io_limits.iops[is_write]; } else { if (wait) { *wait = 0; } return false; } slice_time = bs->slice_end - bs->slice_start; slice_time /= (NANOSECONDS_PER_SECOND); ios_limit = iops_limit * slice_time; ios_base = bs->nr_ops[is_write] - bs->io_base.ios[is_write]; if (bs->io_limits.iops[BLOCK_IO_LIMIT_TOTAL]) { ios_base += bs->nr_ops[!is_write] - bs->io_base.ios[!is_write]; } if (ios_base + 1 <= ios_limit) { if (wait) { *wait = 0; } return false; } wait_time = (ios_base + 1) / iops_limit; if (wait_time > elapsed_time) { wait_time = wait_time - elapsed_time; } else { wait_time = 0; } bs->slice_time = wait_time * BLOCK_IO_SLICE_TIME * 10; bs->slice_end += bs->slice_time - 3 * BLOCK_IO_SLICE_TIME; if (wait) { *wait = wait_time * BLOCK_IO_SLICE_TIME * 10; } return true; }
1threat
static void dma_bdrv_cb(void *opaque, int ret) { DMAAIOCB *dbs = (DMAAIOCB *)opaque; target_phys_addr_t cur_addr, cur_len; void *mem; dbs->acb = NULL; dbs->sector_num += dbs->iov.size / 512; dma_bdrv_unmap(dbs); qemu_iovec_reset(&dbs->iov); if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) { dbs->common.cb(dbs->common.opaque, ret); qemu_iovec_destroy(&dbs->iov); qemu_aio_release(dbs); return; } while (dbs->sg_cur_index < dbs->sg->nsg) { cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte; cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte; mem = cpu_physical_memory_map(cur_addr, &cur_len, !dbs->to_dev); if (!mem) break; qemu_iovec_add(&dbs->iov, mem, cur_len); dbs->sg_cur_byte += cur_len; if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) { dbs->sg_cur_byte = 0; ++dbs->sg_cur_index; } } if (dbs->iov.size == 0) { cpu_register_map_client(dbs, continue_after_map_failure); return; } dbs->acb = dbs->io_func(dbs->bs, dbs->sector_num, &dbs->iov, dbs->iov.size / 512, dma_bdrv_cb, dbs); if (!dbs->acb) { dma_bdrv_unmap(dbs); qemu_iovec_destroy(&dbs->iov); return; } }
1threat
int opt_loglevel(void *optctx, const char *opt, const char *arg) { const struct { const char *name; int level; } log_levels[] = { { "quiet" , AV_LOG_QUIET }, { "panic" , AV_LOG_PANIC }, { "fatal" , AV_LOG_FATAL }, { "error" , AV_LOG_ERROR }, { "warning", AV_LOG_WARNING }, { "info" , AV_LOG_INFO }, { "verbose", AV_LOG_VERBOSE }, { "debug" , AV_LOG_DEBUG }, }; char *tail; int level; int i; for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) { if (!strcmp(log_levels[i].name, arg)) { av_log_set_level(log_levels[i].level); return 0; } } level = strtol(arg, &tail, 10); if (*tail) { av_log(NULL, AV_LOG_FATAL, "Invalid loglevel \"%s\". " "Possible levels are numbers or:\n", arg); for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name); exit(1); } av_log_set_level(level); return 0; }
1threat
Unnecessary code generating in HTML website : <p>I developed HTML website. Used HTML and CSS only.</p> <p>While looking into view source, it is showing unnecessary code at the end of the page and files too.</p> <p>How can i solve this?</p> <p><a href="https://i.stack.imgur.com/fT4G4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fT4G4.png" alt="enter image description here"></a></p>
0debug
how to encrypt the password in mysql using md5 : <pre><code>public function login($email, $password){ $stmt = $this-&gt;pdo-&gt;prepare("SELECT 'user_id' FROM 'users' WHERE 'email'=:email AND 'password' = :password"); $stmt-&gt;bindParam(":email", $email, PDO::PARAM_STR); $stmt-&gt;bindParam(":password", md5($password), PDO::PARAM_STR); $stmt-&gt;execute(); $user = $stmt-&gt;fetch(PDO::FETCH_OBJ); $count = $stmt-&gt;rowCount(); if($count &gt;0){ $_SESSION['user_id'] = $user-&gt;user_id; header('Location: home.php'); }else{ return false; } } </code></pre> <p>by using md5 in password I am getting an error : Only variables should be passed by reference in D:\xammp\htdocs\twitter\core\classes\user.php on line 18</p> <p>and on removing md5, I am getting error for invalid password though I am entering the correct password as in database.</p>
0debug
int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev) { struct kvm_irq_routing_entry kroute = {}; int virq; MSIMessage msg = {0, 0}; if (dev) { msg = pci_get_msi_message(dev, vector); } if (kvm_gsi_direct_mapping()) { return kvm_arch_msi_data_to_gsi(msg.data); } if (!kvm_gsi_routing_enabled()) { return -ENOSYS; } virq = kvm_irqchip_get_virq(s); if (virq < 0) { return virq; } kroute.gsi = virq; kroute.type = KVM_IRQ_ROUTING_MSI; kroute.flags = 0; kroute.u.msi.address_lo = (uint32_t)msg.address; kroute.u.msi.address_hi = msg.address >> 32; kroute.u.msi.data = le32_to_cpu(msg.data); if (kvm_msi_devid_required()) { kroute.flags = KVM_MSI_VALID_DEVID; kroute.u.msi.devid = pci_requester_id(dev); } if (kvm_arch_fixup_msi_route(&kroute, msg.address, msg.data, dev)) { kvm_irqchip_release_virq(s, virq); return -EINVAL; } trace_kvm_irqchip_add_msi_route(dev ? dev->name : (char *)"N/A", vector, virq); kvm_add_routing_entry(s, &kroute); kvm_arch_add_msi_route_post(&kroute, vector, dev); kvm_irqchip_commit_routes(s); return virq; }
1threat
How do i show 100% clarity element in div opacity : <p>I have a div with opacity: 40% . But i want the text in div show with opacity 100%</p> <pre><code>#box { Background-color:#000; Opacity:40%; } </code></pre>
0debug
i want filter value in subject and show in option tag in html using javascript : var user = [ { "id": 1, "firstname": "kalpit", "lastname": "dwivedi", "age" : 20, "hometown" : "jhansi", "job" : "web design", "subject" : ["Hindi", "English"] }, { "id": 2, "firstname": "golu", "lastname": "gupta", "age": 30, "hometown": "Vadodara", "job": "qa tester", "subject" : ["Hindi", "Socilogy"] }, { "id": 3, "firstname": "john", "lastname": "doe", "age": 35, "hometown": "newport", "job": "oprater", "subject" : ["English", "Socilogy"] }, { "id": 4, "firstname": "mohit", "lastname": "khare", "age": 40, "hometown": "kochi", "job": "civil", "subject" : ["infa", "angularjs"] }
0debug
Firestore schema versioning and backward compatibility with android app to prevent crashes : <p>Firestore a NOSQL is a Document oriented database. Now how to manage versioning of the data as I use it with Firebase SDK and Android applications?</p> <p>For e.g. let's say I have a JSON schema that I launch with my 1.0.0version of my android app. Later 1.0.1 comes up where I have to add some extra fields for the newer documents. Since I changed the structure to have additional information, it only applies to new documents.</p> <p>Therefore, using this logic, I can see my Android application must be able to deal with all versions of JSON tree if used against this project I create in the firebase console with Firestore. But this can be very painful right, that I have carry the deadweight of backward compatibility endlessly? Is there a way to have some sort of version like in protobuf or something the android app can send to firestore server side so that automatically we can do something to prevent crashes on the android app when it sees new fields? </p> <p>See also this thread, the kind of problem the engineer has posted. You can end up with this kind of problem as new fields get discovered in your JSON tree by the android app <a href="https://stackoverflow.com/questions/49235874/add-new-field-or-change-the-structure-on-all-firestore-documents">Add new field or change the structure on all Firestore documents</a></p> <p>Any suggestions for how we should go about this?</p> <p>In node.js architecture we handle this with default-> v1.1/update or default-> v1.0/update, that way we can manage the routes.</p> <p>But for android+firebase SKD-> talking to Firestore NOSQL, how do I manage the versioning of the json schema. </p>
0debug
int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv) { BusChild *kid; I2CSlaveClass *sc; I2CNode *node; if (address == I2C_BROADCAST) { bus->broadcast = true; } QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) { DeviceState *qdev = kid->child; I2CSlave *candidate = I2C_SLAVE(qdev); if ((candidate->address == address) || (bus->broadcast)) { node = g_malloc(sizeof(struct I2CNode)); node->elt = candidate; QLIST_INSERT_HEAD(&bus->current_devs, node, next); if (!bus->broadcast) { break; } } } if (QLIST_EMPTY(&bus->current_devs)) { return 1; } QLIST_FOREACH(node, &bus->current_devs, next) { sc = I2C_SLAVE_GET_CLASS(node->elt); if (sc->event) { sc->event(node->elt, recv ? I2C_START_RECV : I2C_START_SEND); } } return 0; }
1threat
how can I do this like that please help me? : MySql -- 1.picture is a table ,table name SatisBasligi. -- 2.picture is a output . how can Δ± write a cod for picture One needs to write code according to the second. [enter image description here][1] ---------------------------------------------- [enter image description here][2] ---------------------------------------------- [1]: https://i.stack.imgur.com/dHXn2.png [2]: https://i.stack.imgur.com/JJi6j.png
0debug
static void tracked_request_begin(BdrvTrackedRequest *req, BlockDriverState *bs, int64_t sector_num, int nb_sectors, bool is_write) *req = (BdrvTrackedRequest){ .bs = bs, .sector_num = sector_num, .nb_sectors = nb_sectors, .is_write = is_write, }; QLIST_INSERT_HEAD(&bs->tracked_requests, req, list);
1threat
How to set the dual color to a button : <p><a href="https://i.stack.imgur.com/1FCd0.png" rel="nofollow"><img src="https://i.stack.imgur.com/1FCd0.png" alt="enter image description here"></a></p> <p>How to set dual color to an button. Any ideas.</p>
0debug
Rails: set params but do not save : <p>What's the call to update a Rails record with new params, say, stored in a <code>hash</code> variable? This:</p> <pre><code>@user.update(hash) </code></pre> <p>Will <em>save</em> the record, and since I want to put the call in a callback I don't want to save it, just prepare it to be saved correctly in the callback.</p>
0debug
How to disable App Signing from Google Play Console : <p>How can I disable App Signing from Google Play Console for all the apps already uploaded on Play store and for new apps?</p>
0debug
static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, EventNotifierHandler *handler, int n) { BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s))); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); VirtIOSCSIVring *r; int rc; rc = k->set_host_notifier(qbus->parent, n, true); if (rc != 0) { fprintf(stderr, "virtio-scsi: Failed to set host notifier (%d)\n", rc); s->dataplane_fenced = true; return NULL; } r = g_new(VirtIOSCSIVring, 1); r->host_notifier = *virtio_queue_get_host_notifier(vq); r->guest_notifier = *virtio_queue_get_guest_notifier(vq); aio_set_event_notifier(s->ctx, &r->host_notifier, false, handler); r->parent = s; if (!vring_setup(&r->vring, VIRTIO_DEVICE(s), n)) { fprintf(stderr, "virtio-scsi: VRing setup failed\n"); goto fail_vring; } return r; fail_vring: aio_set_event_notifier(s->ctx, &r->host_notifier, false, NULL); k->set_host_notifier(qbus->parent, n, false); g_free(r); return NULL; }
1threat
def first_odd(nums): first_odd = next((el for el in nums if el%2!=0),-1) return first_odd
0debug
static void guest_fsfreeze_init(void) { guest_fsfreeze_state.status = GUEST_FSFREEZE_STATUS_THAWED; }
1threat
static void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch) { int bin, blk, gs; int end_bap, gaq_mode; GetBitContext *gbc = &s->gbc; int gaq_gain[AC3_MAX_COEFS]; gaq_mode = get_bits(gbc, 2); end_bap = (gaq_mode < 2) ? 12 : 17; gs = 0; if (gaq_mode == EAC3_GAQ_12 || gaq_mode == EAC3_GAQ_14) { for (bin = s->start_freq[ch]; bin < s->end_freq[ch]; bin++) { if (s->bap[ch][bin] > 7 && s->bap[ch][bin] < end_bap) gaq_gain[gs++] = get_bits1(gbc) << (gaq_mode-1); } } else if (gaq_mode == EAC3_GAQ_124) { int gc = 2; for (bin = s->start_freq[ch]; bin < s->end_freq[ch]; bin++) { if (s->bap[ch][bin] > 7 && s->bap[ch][bin] < 17) { if (gc++ == 2) { int group_code = get_bits(gbc, 5); if (group_code > 26) { av_log(s->avctx, AV_LOG_WARNING, "GAQ gain group code out-of-range\n"); group_code = 26; } gaq_gain[gs++] = ff_ac3_ungroup_3_in_5_bits_tab[group_code][0]; gaq_gain[gs++] = ff_ac3_ungroup_3_in_5_bits_tab[group_code][1]; gaq_gain[gs++] = ff_ac3_ungroup_3_in_5_bits_tab[group_code][2]; gc = 0; } } } } gs=0; for (bin = s->start_freq[ch]; bin < s->end_freq[ch]; bin++) { int hebap = s->bap[ch][bin]; int bits = ff_eac3_bits_vs_hebap[hebap]; if (!hebap) { for (blk = 0; blk < 6; blk++) { s->pre_mantissa[ch][bin][blk] = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000; } } else if (hebap < 8) { int v = get_bits(gbc, bits); for (blk = 0; blk < 6; blk++) { s->pre_mantissa[ch][bin][blk] = ff_eac3_mantissa_vq[hebap][v][blk] << 8; } } else { int gbits, log_gain; if (gaq_mode != EAC3_GAQ_NO && hebap < end_bap) { log_gain = gaq_gain[gs++]; } else { log_gain = 0; } gbits = bits - log_gain; for (blk = 0; blk < 6; blk++) { int mant = get_sbits(gbc, gbits); if (log_gain && mant == -(1 << (gbits-1))) { int b; int mbits = bits - (2 - log_gain); mant = get_sbits(gbc, mbits); mant <<= (23 - (mbits - 1)); if (mant >= 0) b = 1 << (23 - log_gain); else b = ff_eac3_gaq_remap_2_4_b[hebap-8][log_gain-1] << 8; mant += ((ff_eac3_gaq_remap_2_4_a[hebap-8][log_gain-1] * (int64_t)mant) >> 15) + b; } else { mant <<= 24 - bits; if (!log_gain) { mant += (ff_eac3_gaq_remap_1[hebap-8] * (int64_t)mant) >> 15; } } s->pre_mantissa[ch][bin][blk] = mant; } } idct6(s->pre_mantissa[ch][bin]); } }
1threat
def count_alpha_dig_spl(string): alphabets=digits = special = 0 for i in range(len(string)): if(string[i].isalpha()): alphabets = alphabets + 1 elif(string[i].isdigit()): digits = digits + 1 else: special = special + 1 return (alphabets,digits,special)
0debug
ISADevice *isa_try_create(ISABus *bus, const char *name) { DeviceState *dev; if (!bus) { hw_error("Tried to create isa device %s with no isa bus present.", name); } dev = qdev_try_create(BUS(bus), name); return ISA_DEVICE(dev); }
1threat
int main(int argc, char* argv[]) { FILE *f[2]; uint8_t *buf[2], *plane[2][3]; int *temp; uint64_t ssd[3] = {0,0,0}; double ssim[3] = {0,0,0}; int frame_size, w, h; int frames, seek; int i; if( argc<4 || 2 != sscanf(argv[3], "%dx%d", &w, &h) ) { printf("tiny_ssim <file1.yuv> <file2.yuv> <width>x<height> [<seek>]\n"); return -1; } f[0] = fopen(argv[1], "rb"); f[1] = fopen(argv[2], "rb"); sscanf(argv[3], "%dx%d", &w, &h); frame_size = w*h*3/2; for( i=0; i<2; i++ ) { buf[i] = malloc(frame_size); plane[i][0] = buf[i]; plane[i][1] = plane[i][0] + w*h; plane[i][2] = plane[i][1] + w*h/4; } temp = malloc((2*w+12)*sizeof(*temp)); seek = argc<5 ? 0 : atoi(argv[4]); fseek(f[seek<0], seek < 0 ? -seek : seek, SEEK_SET); for( frames=0;; frames++ ) { uint64_t ssd_one[3]; double ssim_one[3]; if( fread(buf[0], frame_size, 1, f[0]) != 1) break; if( fread(buf[1], frame_size, 1, f[1]) != 1) break; for( i=0; i<3; i++ ) { ssd_one[i] = ssd_plane ( plane[0][i], plane[1][i], w*h>>2*!!i ); ssim_one[i] = ssim_plane( plane[0][i], w>>!!i, plane[1][i], w>>!!i, w>>!!i, h>>!!i, temp, NULL ); ssd[i] += ssd_one[i]; ssim[i] += ssim_one[i]; } printf("Frame %d | ", frames); print_results(ssd_one, ssim_one, 1, w, h); printf(" \r"); fflush(stdout); } if( !frames ) return 0; printf("Total %d frames | ", frames); print_results(ssd, ssim, frames, w, h); printf("\n"); return 0; }
1threat
static int qemu_rdma_search_ram_block(RDMAContext *rdma, uint64_t block_offset, uint64_t offset, uint64_t length, uint64_t *block_index, uint64_t *chunk_index) { uint64_t current_addr = block_offset + offset; RDMALocalBlock *block = g_hash_table_lookup(rdma->blockmap, (void *) block_offset); assert(block); assert(current_addr >= block->offset); assert((current_addr + length) <= (block->offset + block->length)); *block_index = block->index; *chunk_index = ram_chunk_index(block->local_host_addr, block->local_host_addr + (current_addr - block->offset)); return 0; }
1threat
Unity C# | Array of ints - does not exist in the current context : I try to make an array of ints: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Test : MonoBehaviour { int[] levelsSolvedCounter = new int[3]; levelsSolvedCounter[0] = 10; } But I get an error "The name 'levelsSolvedCounter' does not exist in the current context", although in online compiler (https://dotnetfiddle.net/) the code works just fine.
0debug
static void nbd_refresh_filename(BlockDriverState *bs) { QDict *opts = qdict_new(); const char *path = qdict_get_try_str(bs->options, "path"); const char *host = qdict_get_try_str(bs->options, "host"); const char *port = qdict_get_try_str(bs->options, "port"); const char *export = qdict_get_try_str(bs->options, "export"); qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("nbd"))); if (path && export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd+unix: } else if (path && !export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd+unix: } else if (!path && export && port) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd: } else if (!path && export && !port) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd: } else if (!path && !export && port) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd: } else if (!path && !export && !port) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nbd: } if (path) { qdict_put_obj(opts, "path", QOBJECT(qstring_from_str(path))); } else if (port) { qdict_put_obj(opts, "host", QOBJECT(qstring_from_str(host))); qdict_put_obj(opts, "port", QOBJECT(qstring_from_str(port))); } else { qdict_put_obj(opts, "host", QOBJECT(qstring_from_str(host))); } if (export) { qdict_put_obj(opts, "export", QOBJECT(qstring_from_str(export))); } bs->full_open_options = opts; }
1threat
Global types in typescript : <p>Is there a way to make a file in your typescript file that defines globally accessible types?</p> <p>I like typescript but find that when i want to be truly type safe I have to explicitly import types from all over the system. It's rather annoying.</p>
0debug
How to register a service worker's scope one directory above where the service_worker.js is located : <p>MY directories are as follows.</p> <pre><code>public_html/ sw/ </code></pre> <p>The "sw/" is where I want to put all service workers, but then have those service workers with a scope to all the files in "public_html/". </p> <p><strong>JS</strong></p> <pre><code>&lt;script&gt; if ('serviceWorker' in navigator) { navigator.serviceWorker.register('sw/notifications.js', { scope: '../sw/' }).then(function(reg) { // registration worked console.log('Registration succeeded. Scope is ' + reg.scope); }).catch(function(error) { // registration failed console.log('Registration failed with ' + error); }); }; &lt;/script&gt; </code></pre> <p>How do I allow this sort of scope?</p>
0debug
DisplaySurface *qemu_create_displaysurface_from(int width, int height, int bpp, int linesize, uint8_t *data) { DisplaySurface *surface = g_new0(DisplaySurface, 1); surface->pf = qemu_default_pixelformat(bpp); surface->format = qemu_pixman_get_format(&surface->pf); assert(surface->format != 0); surface->image = pixman_image_create_bits(surface->format, width, height, (void *)data, linesize); assert(surface->image != NULL); #ifdef HOST_WORDS_BIGENDIAN surface->flags = QEMU_BIG_ENDIAN_FLAG; #endif return surface; }
1threat
How to render table from json array? : <p>I've JSON array and I need to render it to table using React </p> <pre><code>lockers: [ { id: 1, status: 0, size: "s" }, { id: 2, status: 0, size: "m" }, { id: 3, status: 0, size: "l" }, { id: 4, status: 0, size: "s" }, { id: 5, status: 0, size: "m" }, { id: 6, status: 0, size: "l" }, { id: 7, status: 0, size: "s" }, { id: 8, status: 0, size: "m" }, { id: 9, status: 0, size: "l" }, { id: 10, status: 0, size: "s" }, { id: 11, status: 0, size: "m" }, { id: 12, status: 0, size: "l" }, { id: 13, status: 0, size: "xl" } ] </code></pre> <p>I expect the output like this, please help</p> <pre><code>s m l xl 1 2 3 13 4 5 6 - 7 8 9 - 10 11 12 - </code></pre>
0debug
How to make an customized push notification message for weather app in android studio : <p>How to make an customized push notification message for weather app </p> <pre><code> Android Studio </code></pre> <p>Eg: if the climate is rainy that is 22 degree we want to send a message as a push notification "Take An Umbrella With You"</p>
0debug
Jenkins: Cannot define variable in pipeline stage : <p>I'm trying to create a declarative Jenkins pipeline script but having issues with simple variable declaration.</p> <p>Here is my script:</p> <pre><code>pipeline { agent none stages { stage("first") { def foo = "foo" // fails with "WorkflowScript: 5: Expected a step @ line 5, column 13." sh "echo ${foo}" } } } </code></pre> <p>However, I get this error:</p> <pre><code>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 5: Expected a step @ line 5, column 13. def foo = "foo" ^ </code></pre> <p>I'm on Jenkins 2.7.4 and Pipeline 2.4.</p>
0debug
Inserting data in a singly link list by specifying the nth node position. : So the logic goes like this: Suppose the link list consists of (6,7,8) as data and I pass insert(1,5),so the list will be as (5,6,7,8). Similarly on insert(3,2) link list is (6,7,2,8). I tried compiling the below code but it gives me an error stating-Undefined reference to main by '-start'.I tried debugging,even searching for answers but found no help.Kindly suggest a solution.Any further suggestions and bug fixes shall be welcomed. (I have used codepad for compiling) #include<iostream> using namespace std; class Link_no { struct node { int data; node *next; }; void insert(int n,int d,node *head) { node *temp=new node(); temp->data=d; temp->next=NULL; node *temp1; if(n==1) { temp->next=head; head=temp; return; } else temp1=head; { for(int i=0;i<n-1;i++) { temp1=temp1->next; } temp->next=temp1; temp1=temp; } } void print(node *start) { node *temp=start; while(temp!=NULL) { cout<<temp->data<<endl; temp=temp->next; } } int main() { node *head=NULL; Link_no o1; o1.insert(1,5,head); o1.insert(2,7,head); o1.insert(1,9,head); o1.print(head); return 0; } }
0debug
av_cold void ff_msmpeg4_encode_init(MpegEncContext *s) { static int init_done=0; int i; ff_msmpeg4_common_init(s); if(s->msmpeg4_version>=4){ s->min_qcoeff= -255; s->max_qcoeff= 255; } if (!init_done) { init_done = 1; init_mv_table(&ff_mv_tables[0]); init_mv_table(&ff_mv_tables[1]); for(i=0;i<NB_RL_TABLES;i++) ff_init_rl(&ff_rl_table[i], ff_static_rl_table_store[i]); for(i=0; i<NB_RL_TABLES; i++){ int level; for (level = 1; level <= MAX_LEVEL; level++) { int run; for(run=0; run<=MAX_RUN; run++){ int last; for(last=0; last<2; last++){ rl_length[i][level][run][last]= get_size_of_code(s, &ff_rl_table[ i], last, run, level, 0); } } } } } }
1threat
Accessing credentials in Jenkins with the Credentials Parameter plugin : <p>My Jenkins box needs to access Stash and Jira through their REST apis. For that I need to store their credentials.</p> <p>The way I am doing is via the Credentials Parameter, which asks me for a Name, Credential type, Required, Default Value, and a Description.</p> <p>I define a Name as CREDENTIAL_PARAMETER, in the type I set it as "Username with password", and then I pick one credential from the list in the Default Value.</p> <p>Next in the Build section I define that a shell should be executed, which is something like</p> <pre><code>echo $CREDENTIAL_PARAMETER </code></pre> <p>I was expecting to get something like "username:password" as the CREDENTIAL_PARAMETER. However, I get a hash that I think is how the username and password can be retrieved.</p> <p>How can I get the credentials based on the hash using bash?</p>
0debug
static int vt82c686b_mc97_initfn(PCIDevice *dev) { VT686MC97State *s = DO_UPCAST(VT686MC97State, dev, dev); uint8_t *pci_conf = s->dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_MC97); pci_config_set_class(pci_conf, PCI_CLASS_COMMUNICATION_OTHER); pci_config_set_revision(pci_conf, 0x30); pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE | PCI_COMMAND_VGA_PALETTE); pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM); pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03); return 0; }
1threat
how to update item from listview in main form to textbox in second form in wondows form aplication in c#? : I create a program for an accountant. I have buttons for add product, delete product, add quantity of products, sell product and profit(count profit from all products in list) and listview for products with columns product, quantity, purchase price and profit. I have problem with button "add quantity of products" my idea is, when I select product in listview and than click on the button "add quantity of products" I want to open a new window (new form) and to pass all the values from selected item from listview to second form, make mathematical calculations with that values and then pass that new values to selected item in first form ie to update select item in list view. How can I resolve that? This is my code: Form1: public string Proi; //Form 3 = Nabavka............................................................................................................ public string Kol; public string Nab; public string Prof; public int Index; private void button3_Click(object sender, EventArgs e) { Form3 form3 = new Form3(); form3.Show(); form3.Hide(); if (listView1.SelectedItems.Count > 0) { this.listView1.Items[0].Focused = true; this.listView1.Items[0].Selected = true; this.Index = listView1.FocusedItem.Index; ListViewItem selectedItem = new ListViewItem(); form3.GetData(listView1.Items[listView1.FocusedItem.Index].SubItems[0].Text, listView1.Items[listView1.FocusedItem.Index].SubItems[1].Text, listView1.Items[listView1.FocusedItem.Index].SubItems[2].Text, listView1.Items[listView1.FocusedItem.Index].SubItems[3].Text); if (form3.ShowDialog() == DialogResult.OK) { this.listView1.SelectedItems[Index].Remove(); Values(form3.Prozz, form3.Kolii, form3.Cenaa, form3.Proff); ListViewItem lvi = new ListViewItem(Proi); lvi.SubItems.Add(Kol); lvi.SubItems.Add(Nab); lvi.SubItems.Add(Prof); this.listView1.Items.Add(lvi); } } } public void Values(string P, string K, string N, string p) { Proi = P; Kol = K; Nab = N; Prof = p; } Form2: public void GetData(string Proi, string Kol, string Cena, string Profit) { textBox1.Text = Kol; textBox2.Text = Cena; textBox3.Text = Profit; textBox6.Text = Proi; } public void SetData(string Proz, string Kol, string NabCena, string Prof) { int x = int.Parse(textBox1.Text); double y = double.Parse(textBox2.Text); double z = double.Parse(textBox3.Text); int a = int.Parse(textBox4.Text); double b = double.Parse(textBox5.Text); int Kolicina = x + a; double sumNabavnaCena = (x * y + a * b) / (x + a); double Profit = z - Kolicina * sumNabavnaCena; Prozz = textBox6.Text; Kolii = Convert.ToString(Kolicina); Cenaa = Convert.ToString(sumNabavnaCena); Proff = Convert.ToString(Profit); } private void textBox3_TextChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { Form1 form1 = new Form1(); this.button1.Text = "OK"; this.button1.DialogResult = DialogResult.OK; this.Close(); } } }
0debug
static void register_multipage(MemoryRegionSection *section) { target_phys_addr_t start_addr = section->offset_within_address_space; ram_addr_t size = section->size; target_phys_addr_t addr; uint16_t section_index = phys_section_add(section); assert(size); addr = start_addr; phys_page_set(addr >> TARGET_PAGE_BITS, size >> TARGET_PAGE_BITS, section_index); }
1threat
static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame) { FramePool *pool = avctx->internal->pool; int i, ret; switch (avctx->codec_type) { case AVMEDIA_TYPE_VIDEO: { AVPicture picture; int size[4] = { 0 }; int w = frame->width; int h = frame->height; int tmpsize, unaligned; if (pool->format == frame->format && pool->width == frame->width && pool->height == frame->height) return 0; avcodec_align_dimensions2(avctx, &w, &h, pool->stride_align); if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) { w += EDGE_WIDTH * 2; h += EDGE_WIDTH * 2; } do { av_image_fill_linesizes(picture.linesize, avctx->pix_fmt, w); w += w & ~(w - 1); unaligned = 0; for (i = 0; i < 4; i++) unaligned |= picture.linesize[i] % pool->stride_align[i]; } while (unaligned); tmpsize = av_image_fill_pointers(picture.data, avctx->pix_fmt, h, NULL, picture.linesize); if (tmpsize < 0) return -1; for (i = 0; i < 3 && picture.data[i + 1]; i++) size[i] = picture.data[i + 1] - picture.data[i]; size[i] = tmpsize - (picture.data[i] - picture.data[0]); for (i = 0; i < 4; i++) { av_buffer_pool_uninit(&pool->pools[i]); pool->linesize[i] = picture.linesize[i]; if (size[i]) { pool->pools[i] = av_buffer_pool_init(size[i] + 16, NULL); if (!pool->pools[i]) { ret = AVERROR(ENOMEM); goto fail; } } } pool->format = frame->format; pool->width = frame->width; pool->height = frame->height; break; } case AVMEDIA_TYPE_AUDIO: { int ch = av_frame_get_channels(frame); int planar = av_sample_fmt_is_planar(frame->format); int planes = planar ? ch : 1; if (pool->format == frame->format && pool->planes == planes && pool->channels == ch && frame->nb_samples == pool->samples) return 0; av_buffer_pool_uninit(&pool->pools[0]); ret = av_samples_get_buffer_size(&pool->linesize[0], ch, frame->nb_samples, frame->format, 0); if (ret < 0) goto fail; pool->pools[0] = av_buffer_pool_init(pool->linesize[0], NULL); if (!pool->pools[0]) { ret = AVERROR(ENOMEM); goto fail; } pool->format = frame->format; pool->planes = planes; pool->channels = ch; pool->samples = frame->nb_samples; break; } default: av_assert0(0); } return 0; fail: for (i = 0; i < 4; i++) av_buffer_pool_uninit(&pool->pools[i]); pool->format = -1; pool->planes = pool->channels = pool->samples = 0; pool->width = pool->height = 0; return ret; }
1threat
How to set index type 'text' using mongodb compass? : <p>I am currently using mongodb compass, I want to create index with type 'text'. I followed steps given on <a href="https://docs.mongodb.com/manual/indexes/#single-field" rel="noreferrer">https://docs.mongodb.com/manual/indexes/#single-field</a>. However, I failed to create index with type 'text'. In compass GUI, dropdown titled 'Select a type' does not show type 'text' in it's dropdown. Am I missing anything ?</p> <p>Thanks, in advance.</p>
0debug
Can this Haskell expression be written without brackets or back-ticks? : mul (add 2 3) 5 Can the dot (.) and dollar ($) operators alone replace the brackets?
0debug
Defining a defualt value for my javascript function parameter will raise the following error on IE " SCRIPT1006: Expected ')'" : <p>I have the followig function inside my javascript file:-</p> <pre><code>function showOrHideField(curField="") { </code></pre> <p>where i am defining a function which take a parameter with defualt value <code>""</code>, now this is working well on Firefox. but on IE11 i got the following exception:-</p> <pre><code>SCRIPT1006: Expected ')' </code></pre> <p>so can anyone advice on this please? Thanks</p>
0debug
static void gen_flt3_ldst (DisasContext *ctx, uint32_t opc, int fd, int fs, int base, int index) { const char *opn = "extended float load/store"; int store = 0; gen_op_cp1_64bitmode(); if (base == 0) { if (index == 0) gen_op_reset_T0(); else GEN_LOAD_REG_TN(T0, index); } else if (index == 0) { GEN_LOAD_REG_TN(T0, base); } else { GEN_LOAD_REG_TN(T0, base); GEN_LOAD_REG_TN(T1, index); gen_op_addr_add(); } switch (opc) { case OPC_LWXC1: op_ldst(lwc1); GEN_STORE_FTN_FREG(fd, WT0); opn = "lwxc1"; break; case OPC_LDXC1: op_ldst(ldc1); GEN_STORE_FTN_FREG(fd, DT0); opn = "ldxc1"; break; case OPC_LUXC1: op_ldst(luxc1); GEN_STORE_FTN_FREG(fd, DT0); opn = "luxc1"; break; case OPC_SWXC1: GEN_LOAD_FREG_FTN(WT0, fs); op_ldst(swc1); opn = "swxc1"; store = 1; break; case OPC_SDXC1: GEN_LOAD_FREG_FTN(DT0, fs); op_ldst(sdc1); opn = "sdxc1"; store = 1; break; case OPC_SUXC1: GEN_LOAD_FREG_FTN(DT0, fs); op_ldst(suxc1); opn = "suxc1"; store = 1; break; default: MIPS_INVAL(opn); generate_exception(ctx, EXCP_RI); return; } MIPS_DEBUG("%s %s, %s(%s)", opn, fregnames[store ? fs : fd], regnames[index], regnames[base]); }
1threat
What are these errors while connecting to mySQL? : I am trying to make a user registration system using PDO in PHP and I'm unable to connect to the mySQL database. It always says access denied and there is some fatal error as well. I tried resetting mySQL and other things available on the internet but nothing worked. <?php class userClass { /* User Login */ public function userLogin($usernameEmail,$password) { $db = getDB(); $hash_password= hash('sha256', $password); $stmt = $db->prepare("SELECT uid FROM users WHERE (username=:usernameEmail or email=:usernameEmail) AND password=:hash_password"); $stmt->bindParam("usernameEmail", $usernameEmail,PDO::PARAM_STR) ; $stmt->bindParam("hash_password", $hash_password,PDO::PARAM_STR) ; $stmt->execute(); $count=$stmt->rowCount(); $data=$stmt->fetch(PDO::FETCH_OBJ); $db = null; if($count) { $_SESSION['uid']=$data->uid; return true; } else { return false; } } /* User Registration */ public function userRegistration($username,$password,$email,$name) { try{ $db = getDB(); $st = $db->prepare("SELECT uid FROM users WHERE username=:username OR email=:email"); $st->bindParam("username", $username,PDO::PARAM_STR); $st->bindParam("email", $email,PDO::PARAM_STR); $st->execute(); $count=$st->rowCount(); if($count<1) { $stmt = $db->prepare("INSERT INTO users(username,password,email,name) VALUES (:username,:hash_password,:email,:name)"); $stmt->bindParam("username", $username,PDO::PARAM_STR) ; $hash_password= hash('sha256', $password); $stmt->bindParam("hash_password", $hash_password,PDO::PARAM_STR) ; $stmt->bindParam("email", $email,PDO::PARAM_STR) ; $stmt->bindParam("name", $name,PDO::PARAM_STR) ; $stmt->execute(); $uid=$db->lastInsertId(); $db = null; $_SESSION['uid']=$uid; return true; } else { $db = null; return false; } } catch(PDOException $e) { echo '{"error":{"text":'. $e->getMessage() .'}}'; } } /* User Details */ public function userDetails($uid) { try{ $db = getDB(); $stmt = $db->prepare("SELECT email,username,name FROM users WHERE uid=:uid"); $stmt->bindParam("uid", $uid,PDO::PARAM_INT); $stmt->execute(); $data = $stmt->fetch(PDO::FETCH_OBJ); return $data; } catch(PDOException $e) { echo '{"error":{"text":'. $e->getMessage() .'}}'; } } } ?> These are the errors I'm getting. Connection failed: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) Fatal error: Uncaught Error: Call to a member function prepare() on null in C:\xampp\htdocs\auctionsystem\class\userClass.php:33 Stack trace: #0 C:\xampp\htdocs\auctionsystem\index.php(40): userClass->userRegistration('anurag', 'anurag123', 'anurag@email.co...', 'Anurag Pal') #1 {main} thrown in C:\xampp\htdocs\auctionsystem\class\userClass.php on line 33
0debug
How to check weather the count is increased or not using selenium webdriver : WebElement element = driver.findElement(By.xpath("//*[@id='filter-row']/div[2]")); String text = element.getText(); // 7 humans How can i read the numbers 7 only from that text
0debug
static void spapr_phb_realize(DeviceState *dev, Error **errp) { sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); SysBusDevice *s = SYS_BUS_DEVICE(dev); sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(s); PCIHostState *phb = PCI_HOST_BRIDGE(s); char *namebuf; int i; PCIBus *bus; uint64_t msi_window_size = 4096; sPAPRTCETable *tcet; const unsigned windows_supported = sphb->ddw_enabled ? SPAPR_PCI_DMA_MAX_WINDOWS : 1; if (sphb->index != (uint32_t)-1) { sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr); Error *local_err = NULL; if ((sphb->buid != (uint64_t)-1) || (sphb->dma_liobn[0] != (uint32_t)-1) || (sphb->dma_liobn[1] != (uint32_t)-1 && windows_supported == 2) || (sphb->mem_win_addr != (hwaddr)-1) || (sphb->mem64_win_addr != (hwaddr)-1) || (sphb->io_win_addr != (hwaddr)-1)) { error_setg(errp, "Either \"index\" or other parameters must" " be specified for PAPR PHB, not both"); return; } smc->phb_placement(spapr, sphb->index, &sphb->buid, &sphb->io_win_addr, &sphb->mem_win_addr, &sphb->mem64_win_addr, windows_supported, sphb->dma_liobn, &local_err); if (local_err) { error_propagate(errp, local_err); return; } } if (sphb->buid == (uint64_t)-1) { error_setg(errp, "BUID not specified for PHB"); return; } if ((sphb->dma_liobn[0] == (uint32_t)-1) || ((sphb->dma_liobn[1] == (uint32_t)-1) && (windows_supported > 1))) { error_setg(errp, "LIOBN(s) not specified for PHB"); return; } if (sphb->mem_win_addr == (hwaddr)-1) { error_setg(errp, "Memory window address not specified for PHB"); return; } if (sphb->io_win_addr == (hwaddr)-1) { error_setg(errp, "IO window address not specified for PHB"); return; } if (sphb->mem64_win_size != 0) { if (sphb->mem64_win_addr == (hwaddr)-1) { error_setg(errp, "64-bit memory window address not specified for PHB"); return; } if (sphb->mem_win_size > SPAPR_PCI_MEM32_WIN_SIZE) { error_setg(errp, "32-bit memory window of size 0x%"HWADDR_PRIx " (max 2 GiB)", sphb->mem_win_size); return; } if (sphb->mem64_win_pciaddr == (hwaddr)-1) { sphb->mem64_win_pciaddr = sphb->mem64_win_addr; } } else if (sphb->mem_win_size > SPAPR_PCI_MEM32_WIN_SIZE) { sphb->mem64_win_size = sphb->mem_win_size - SPAPR_PCI_MEM32_WIN_SIZE; sphb->mem64_win_addr = sphb->mem_win_addr + SPAPR_PCI_MEM32_WIN_SIZE; sphb->mem64_win_pciaddr = SPAPR_PCI_MEM_WIN_BUS_OFFSET + SPAPR_PCI_MEM32_WIN_SIZE; sphb->mem_win_size = SPAPR_PCI_MEM32_WIN_SIZE; } if (spapr_pci_find_phb(spapr, sphb->buid)) { error_setg(errp, "PCI host bridges must have unique BUIDs"); return; } if (sphb->numa_node != -1 && (sphb->numa_node >= MAX_NODES || !numa_info[sphb->numa_node].present)) { error_setg(errp, "Invalid NUMA node ID for PCI host bridge"); return; } sphb->dtbusname = g_strdup_printf("pci@%" PRIx64, sphb->buid); namebuf = g_strdup_printf("%s.mmio", sphb->dtbusname); memory_region_init(&sphb->memspace, OBJECT(sphb), namebuf, UINT64_MAX); g_free(namebuf); namebuf = g_strdup_printf("%s.mmio32-alias", sphb->dtbusname); memory_region_init_alias(&sphb->mem32window, OBJECT(sphb), namebuf, &sphb->memspace, SPAPR_PCI_MEM_WIN_BUS_OFFSET, sphb->mem_win_size); g_free(namebuf); memory_region_add_subregion(get_system_memory(), sphb->mem_win_addr, &sphb->mem32window); if (sphb->mem64_win_pciaddr != (hwaddr)-1) { namebuf = g_strdup_printf("%s.mmio64-alias", sphb->dtbusname); memory_region_init_alias(&sphb->mem64window, OBJECT(sphb), namebuf, &sphb->memspace, sphb->mem64_win_pciaddr, sphb->mem64_win_size); g_free(namebuf); if (sphb->mem64_win_addr != (hwaddr)-1) { memory_region_add_subregion(get_system_memory(), sphb->mem64_win_addr, &sphb->mem64window); } } namebuf = g_strdup_printf("%s.io", sphb->dtbusname); memory_region_init(&sphb->iospace, OBJECT(sphb), namebuf, SPAPR_PCI_IO_WIN_SIZE); g_free(namebuf); namebuf = g_strdup_printf("%s.io-alias", sphb->dtbusname); memory_region_init_alias(&sphb->iowindow, OBJECT(sphb), namebuf, &sphb->iospace, 0, SPAPR_PCI_IO_WIN_SIZE); g_free(namebuf); memory_region_add_subregion(get_system_memory(), sphb->io_win_addr, &sphb->iowindow); bus = pci_register_bus(dev, NULL, pci_spapr_set_irq, pci_spapr_map_irq, sphb, &sphb->memspace, &sphb->iospace, PCI_DEVFN(0, 0), PCI_NUM_PINS, TYPE_PCI_BUS); phb->bus = bus; qbus_set_hotplug_handler(BUS(phb->bus), DEVICE(sphb), NULL); namebuf = g_strdup_printf("%s.iommu-root", sphb->dtbusname); memory_region_init(&sphb->iommu_root, OBJECT(sphb), namebuf, UINT64_MAX); g_free(namebuf); address_space_init(&sphb->iommu_as, &sphb->iommu_root, sphb->dtbusname); #ifdef CONFIG_KVM if (kvm_enabled()) { msi_window_size = getpagesize(); } #endif memory_region_init_io(&sphb->msiwindow, OBJECT(sphb), &spapr_msi_ops, spapr, "msi", msi_window_size); memory_region_add_subregion(&sphb->iommu_root, SPAPR_PCI_MSI_WINDOW, &sphb->msiwindow); pci_setup_iommu(bus, spapr_pci_dma_iommu, sphb); pci_bus_set_route_irq_fn(bus, spapr_route_intx_pin_to_irq); QLIST_INSERT_HEAD(&spapr->phbs, sphb, list); for (i = 0; i < PCI_NUM_PINS; i++) { uint32_t irq; Error *local_err = NULL; irq = spapr_ics_alloc_block(spapr->ics, 1, true, false, &local_err); if (local_err) { error_propagate(errp, local_err); error_prepend(errp, "can't allocate LSIs: "); return; } sphb->lsi_table[i].irq = irq; } if (sphb->dr_enabled) { for (i = 0; i < PCI_SLOT_MAX * 8; i++) { spapr_dr_connector_new(OBJECT(phb), TYPE_SPAPR_DRC_PCI, (sphb->index << 16) | i); } } if (((sphb->page_size_mask & qemu_getrampagesize()) == 0) && kvm_enabled()) { error_report("System page size 0x%lx is not enabled in page_size_mask " "(0x%"PRIx64"). Performance may be slow", qemu_getrampagesize(), sphb->page_size_mask); } for (i = 0; i < windows_supported; ++i) { tcet = spapr_tce_new_table(DEVICE(sphb), sphb->dma_liobn[i]); if (!tcet) { error_setg(errp, "Creating window#%d failed for %s", i, sphb->dtbusname); return; } memory_region_add_subregion(&sphb->iommu_root, 0, spapr_tce_get_iommu(tcet)); } sphb->msi = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free); }
1threat
Applying static keyword to a class in java : <p>My problem is regarding the application of Static keyword for a class. As it is easy to apply static keyword for instance variables and methods but while coming to classes it is not working. finally please help me to solve the code</p> <pre><code>static class Box{ static int width,depth,height; static void volume(int w,int d,int h){ double vol=w*d*h; System.out.println(vol); } } class ClassStaticTest{ public static void main(String[] args){ //Box b=new Box(); width=10; height=10; depth=10; Box.volume(10,10,10); } } </code></pre>
0debug
def left_rotate(s,d): tmp = s[d : ] + s[0 : d] return tmp
0debug
regular expression : I want regular expression for below code can anyone help greatly appreciated abc-def-smdp-01 Here i want to match all hypen and smdp i want ignore abc and def and 01 can anyone help like this --smdp-
0debug
static void decode_finish_row(H264Context *h, H264SliceContext *sl) { int top = 16 * (h->mb_y >> FIELD_PICTURE(h)); int pic_height = 16 * h->mb_height >> FIELD_PICTURE(h); int height = 16 << FRAME_MBAFF(h); int deblock_border = (16 + 4) << FRAME_MBAFF(h); if (h->deblocking_filter) { if ((top + height) >= pic_height) height += deblock_border; top -= deblock_border; } if (top >= pic_height || (top + height) < 0) return; height = FFMIN(height, pic_height - top); if (top < 0) { height = top + height; top = 0; } ff_h264_draw_horiz_band(h, sl, top, height); if (h->droppable) return; ff_thread_report_progress(&h->cur_pic_ptr->tf, top + height - 1, h->picture_structure == PICT_BOTTOM_FIELD); }
1threat
Uncaught Error: Rendered fewer hooks than expected. This may be caused by an accidental early return statement in React Hooks : <p>Given the following component, when I press down on the age selector and change the value to 15, such that I render a form without the driver license field, I get the error:</p> <pre><code>Uncaught Error: Rendered fewer hooks than expected. This may be caused by an accidental early return statement. at invariant (react-dom.development.js:55) at finishHooks (react-dom.development.js:11581) at updateFunctionComponent (react-dom.development.js:14262) at beginWork (react-dom.development.js:15103) at performUnitOfWork (react-dom.development.js:17817) at workLoop (react-dom.development.js:17857) at HTMLUnknownElement.callCallback (react-dom.development.js:149) at Object.invokeGuardedCallbackDev (react-dom.development.js:199) at invokeGuardedCallback (react-dom.development.js:256) at replayUnitOfWork (react-dom.development.js:17113) at renderRoot (react-dom.development.js:17957) at performWorkOnRoot (react-dom.development.js:18808) at performWork (react-dom.development.js:18716) at flushInteractiveUpdates$1 (react-dom.development.js:18987) at batchedUpdates (react-dom.development.js:2210) at dispatchEvent (react-dom.development.js:4946) at interactiveUpdates$1 (react-dom.development.js:18974) at interactiveUpdates (react-dom.development.js:2217) at dispatchInteractiveEvent (react-dom.development.js:4923) </code></pre> <p>Example code below:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const {useState} = React; function App() { const [name, setName] = useState('Mary'); const [age, setAge] = useState(16); if (age &lt; 16) { return ( &lt;div&gt; Name:{' '} &lt;input value={name} onChange={e =&gt; { setName(e.target.value); }} /&gt; &lt;br /&gt; Age:{' '} &lt;input value={age} type="number" onChange={e =&gt; { setAge(+e.target.value); }} /&gt; &lt;/div&gt; ); } const [license, setLicense] = useState('A123456'); return ( &lt;div&gt; Name:{' '} &lt;input value={name} onChange={e =&gt; { setName(e.target.value); }} /&gt; &lt;br /&gt; Age:{' '} &lt;input value={age} type="number" onChange={e =&gt; { setAge(+e.target.value); }} /&gt; &lt;br /&gt; Driver License:{' '} &lt;input value={license} onChange={e =&gt; { setLicense(e.target.value); }} /&gt; &lt;/div&gt; ); } ReactDOM.render(&lt;App /&gt;, document.querySelector('#app'));</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://unpkg.com/react@16.7.0-alpha.0/umd/react.development.js"&gt;&lt;/script&gt; &lt;script src="https://unpkg.com/react-dom@16.7.0-alpha.0/umd/react-dom.development.js"&gt;&lt;/script&gt; &lt;div id="app"&gt;&lt;/div&gt;</code></pre> </div> </div> </p>
0debug
Example of Big O of 2^n : <p>So I can picture what an algorithm is that has a complexity of n^c, just the number of nested for loops. </p> <pre><code>for (var i = 0; i &lt; dataset.len; i++ { for (var j = 0; j &lt; dataset.len; j++) { //do stuff with i and j } } </code></pre> <p>Log is something that splits the data set in half every time, binary search does this (not entirely sure what code for this looks like). </p> <p>But what is a simple example of an algorithm that is c^n or more specifically 2^n. Is O(2^n) based on loops through data? Or how data is split? Or something else entirely?</p>
0debug
PHP not working in HTML : <p>Guys Im so frustrated with this and almost ready to give up on the whole thing.</p> <p>I installed wamp server on win7 and all services running..I can browse to a php file on my web server and it works as expected but if I try to include it into my html it never runs and chromes dumb ass debugger never says anything is wrong here is an example of my html and php file which reside in the same directory..</p> <p>file grrr.php</p> <pre><code>&lt;?php echo "I HATE PHP" ;?&gt; </code></pre> <p>file test.html</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;HTML&gt; &lt;Body&gt; &lt;?php include 'grrr.php';?&gt; &lt;/Body&gt; &lt;/HTML&gt; </code></pre> <p>Seems easy enough but nothing but a blank screen. although if i browse to grrr.php instead of test.html I get the expected output. What am I doing wrong...I have no hair left.</p>
0debug
How to move all files and folder from one folder to another of S3 bucket in php with some short way? : <p>I have to move all files and folders from one folder or another of S3 bucket in php. I know a way to do the same thing is - <strong>1) get all objects list from the source folder 2) copy all objects into destination folder 3) delete all objects from source folder</strong></p> <p>Is there any other short way to do the same. If so then please share with me, It would be appreciated, Thanks in advance</p>
0debug
Automating axis bank website : <p>I am trying to select Accounts that come under Products heading using Actions. Although it should have been done easily but i am unable to do same. Can anyone please help.</p> <pre><code> [Account under Product heading][1] driver.get("http://www.axisbank.com/"); Thread.sleep(2000); Actions action=new Actions(driver); WebElement account=driver.findElement(By.xpath("//*[@id='product-menu']/div[2]/div/div/ul[1]/li[1]/a")); WebElement prod=driver.findElement(By.xpath("html/body/form/div[5]/div[1]/div[3]/div/div[1]/div[2]/div/div/ul[1]/li[1]/a")); action.moveToElement(prod).build().perform(); Thread.sleep(2000); action.moveToElement(account).click().perform(); </code></pre>
0debug
Symfony Exception detected : The file was found but the class was not in it, the class name or namespace probably has a typo. : <p>The autoloader expected class "Sdz\BlogBundle\Controller\DefaultController" to be defined in file "C:\wamp64\www\Symfony\vendor\composer/../../src\Sdz\BlogBundle\Controller\DefaultController.php". The file was found but the class was not in it, the class name or namespace probably has a typo. 500 Internal Server Error - RuntimeException </p> <p>Stack Trace</p> <pre><code>in vendor\symfony\symfony\src\Symfony\Component\Debug\DebugClassLoader.php at line 223 - throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class)); } throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); } if (self::$caseCheck) { $real = explode('\\', $class.strrchr($file, '.')); </code></pre>
0debug
static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk, int width, int height, int bandpos) { int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1, y; int clnpass_cnt = 0; int bpass_csty_symbol = codsty->cblk_style & JPEG2000_CBLK_BYPASS; int vert_causal_ctx_csty_symbol = codsty->cblk_style & JPEG2000_CBLK_VSC; av_assert0(width <= JPEG2000_MAX_CBLKW); av_assert0(height <= JPEG2000_MAX_CBLKH); for (y = 0; y < height; y++) memset(t1->data[y], 0, width * sizeof(**t1->data)); if (!cblk->length) return 0; for (y = 0; y < height + 2; y++) memset(t1->flags[y], 0, (width + 2) * sizeof(**t1->flags)); cblk->data[cblk->length] = 0xff; cblk->data[cblk->length+1] = 0xff; ff_mqc_initdec(&t1->mqc, cblk->data); while (passno--) { switch(pass_t) { case 0: decode_sigpass(t1, width, height, bpno + 1, bandpos, bpass_csty_symbol && (clnpass_cnt >= 4), vert_causal_ctx_csty_symbol); break; case 1: decode_refpass(t1, width, height, bpno + 1); if (bpass_csty_symbol && clnpass_cnt >= 4) ff_mqc_initdec(&t1->mqc, cblk->data); break; case 2: decode_clnpass(s, t1, width, height, bpno + 1, bandpos, codsty->cblk_style & JPEG2000_CBLK_SEGSYM, vert_causal_ctx_csty_symbol); clnpass_cnt = clnpass_cnt + 1; if (bpass_csty_symbol && clnpass_cnt >= 4) ff_mqc_initdec(&t1->mqc, cblk->data); break; } pass_t++; if (pass_t == 3) { bpno--; pass_t = 0; } } return 0; }
1threat
Creation tool for flutter? : <p>does anyone know if there is a way to build a flutter UI just by dragging items onto the screen? Like I want a text layer, then I will just drag the text item on the screen and move it around? Like with swift?</p>
0debug
eth_calc_pseudo_hdr_csum(struct ip_header *iphdr, uint16_t csl) { struct ip_pseudo_header ipph; ipph.ip_src = iphdr->ip_src; ipph.ip_dst = iphdr->ip_dst; ipph.ip_payload = cpu_to_be16(csl); ipph.ip_proto = iphdr->ip_p; ipph.zeros = 0; return net_checksum_add(sizeof(ipph), (uint8_t *) &ipph); }
1threat
Estimote SDK vs Altbeacon Library for Android Development : <p>What are the pros and cons of using the Estimote SDK or the Altbeacon beacon library for developing Android apps using BLE beacons?</p> <p>I am only talking about the Estimte SDK not their cloud services. I don't necessarily want to use Estimote beacons but as far as I understand the SDK works with any iBeacon or Eddystone beacons (without the cloud services).</p>
0debug
How to get this like a list? From TOP to BOTTOM : i have a database and i am trying to get a list on PHP whit foreach, but even if i do that the list are returning like this: `RiquelmeMacielLewBrMarcuus` but i want to get so: `RiquelmeMaciel LewBr Marcuus` My code: `<?php //Incluindo a conexΓ£o com banco de dados include_once("conexao.php"); $result_usuario = "SELECT * FROM usuarios ORDER BY id"; $resultado_usuario = mysqli_query($conn, $result_usuario); $resultado = mysqli_fetch_assoc($resultado_usuario); ?> <?php foreach($resultado_usuario as $teste){ echo '<td class="mdl-data-table__cell--non-numeric name">'.$teste['nome'].'</td>'; } ?>` Image: [here][1] [1]: https://i.stack.imgur.com/bNOdy.png
0debug
Operators &= and ~1U in C : <p>What does this piece of code do <code>s &amp;= ~1U</code> if <code>s=8</code>? I assume that it has to do something with binary, but dont know what exactly?</p> <p>Thanks in advance!</p>
0debug
void block_job_sleep_ns(BlockJob *job, QEMUClockType type, int64_t ns) { assert(job->busy); if (block_job_is_cancelled(job)) { return; } job->busy = false; if (block_job_is_paused(job)) { qemu_coroutine_yield(); } else { co_aio_sleep_ns(blk_get_aio_context(job->blk), type, ns); } job->busy = true; }
1threat
Weird histogram behavior when using range argument : I want to compare distributions of values in two arrays, but the histogram display changes when I specify range argument: def plot_compare(values1, values2, bins=100, range=None): fig = plt.figure(figsize=(8,6)) ax = fig.add_subplot(111) ax.hist(values1.ravel(), alpha=0.5, bins=bins, range=range, color= 'b', label='1') ax.hist(values2.ravel(), alpha=0.5, bins=bins, range=range, color= 'r', label='2') ax.legend(loc='upper right', prop={'size':14}) plt.show() plot_compare(a1, a2) [![enter image description here][1]][1] plot_compare(a1, a2, range=(-1200, 300)) [![enter image description here][2]][2] What's happening, and how do I make the proper comparison? My goal is to get a visual clue of how the values are different in two arrays. [1]: https://i.stack.imgur.com/wheqa.png [2]: https://i.stack.imgur.com/sx5Xn.png
0debug
static void gen_swap_asi(DisasContext *dc, TCGv dst, TCGv src, TCGv addr, int insn) { TCGv_i32 r_asi, r_size, r_sign; TCGv_i64 s64, t64 = tcg_temp_new_i64(); r_asi = gen_get_asi(dc, insn); r_size = tcg_const_i32(4); r_sign = tcg_const_i32(0); gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_size, r_sign); tcg_temp_free_i32(r_sign); s64 = tcg_temp_new_i64(); tcg_gen_extu_tl_i64(s64, src); gen_helper_st_asi(cpu_env, addr, s64, r_asi, r_size); tcg_temp_free_i64(s64); tcg_temp_free_i32(r_size); tcg_temp_free_i32(r_asi); tcg_gen_trunc_i64_tl(dst, t64); tcg_temp_free_i64(t64); }
1threat
"%+%" function returning NULL : <p>I am trying to use %+% to concatenate. I am trying the following:</p> <pre><code>&gt;nrow(myData) 1200 &gt; a = "ORG_" %+% 1:nrow(myData) </code></pre> <p>I expect the results to be like:</p> <pre><code>ORG_1 ORG_2 ORG_3 . . . ORG_1200 </code></pre> <p>But, I am getting:</p> <pre><code>&gt; a NULL </code></pre> <p>Please help.</p>
0debug
Gradle home cannot be found on Mac : <p>I've installed <code>gradle</code> on MAC using terminal.</p> <p><code>brew install gradle</code></p> <p>Gradle has been installed successfully.</p> <pre><code>gradle -v ------------------------------------------------------------ Gradle 3.3 ------------------------------------------------------------ Build time: 2017-01-03 15:31:04 UTC Revision: 075893a3d0798c0c1f322899b41ceca82e4e134b Groovy: 2.4.7 Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015 JVM: 1.8.0_112 (Oracle Corporation 25.112-b16) OS: Mac OS X 10.12.3 x86_64 </code></pre> <p>but I can not find gradle home.</p> <pre><code>echo $GRADLE_HOME [empty result] </code></pre> <p>the first step to determine home directory is detect location of <code>gradle</code> instruction:</p> <pre><code>which gradle /usr/local/bin/gradle </code></pre> <p>there is incomprehensible bash file.</p> <hr> <p>Any ideas how to detect gradle home directory via terminal?</p>
0debug
static uint64_t exynos4210_uart_read(void *opaque, target_phys_addr_t offset, unsigned size) { Exynos4210UartState *s = (Exynos4210UartState *)opaque; uint32_t res; switch (offset) { case UERSTAT: res = s->reg[I_(UERSTAT)]; s->reg[I_(UERSTAT)] = 0; return res; case UFSTAT: s->reg[I_(UFSTAT)] = fifo_elements_number(&s->rx) & 0xff; if (fifo_empty_elements_number(&s->rx) == 0) { s->reg[I_(UFSTAT)] |= UFSTAT_Rx_FIFO_FULL; s->reg[I_(UFSTAT)] &= ~0xff; } return s->reg[I_(UFSTAT)]; case URXH: if (s->reg[I_(UFCON)] & UFCON_FIFO_ENABLE) { if (fifo_elements_number(&s->rx)) { res = fifo_retrieve(&s->rx); #if DEBUG_Rx_DATA fprintf(stderr, "%c", res); #endif if (!fifo_elements_number(&s->rx)) { s->reg[I_(UTRSTAT)] &= ~UTRSTAT_Rx_BUFFER_DATA_READY; } else { s->reg[I_(UTRSTAT)] |= UTRSTAT_Rx_BUFFER_DATA_READY; } } else { s->reg[I_(UINTSP)] |= UINTSP_ERROR; exynos4210_uart_update_irq(s); res = 0; } } else { s->reg[I_(UTRSTAT)] &= ~UTRSTAT_Rx_BUFFER_DATA_READY; res = s->reg[I_(URXH)]; } return res; case UTXH: PRINT_DEBUG("UART%d: Trying to read from WO register: %s [%04x]\n", s->channel, exynos4210_uart_regname(offset), offset); break; default: return s->reg[I_(offset)]; } return 0; }
1threat
int net_init_hubport(const NetClientOptions *opts, const char *name, NetClientState *peer, Error **errp) { const NetdevHubPortOptions *hubport; assert(opts->type == NET_CLIENT_OPTIONS_KIND_HUBPORT); assert(!peer); hubport = opts->u.hubport; net_hub_add_port(hubport->hubid, name); return 0; }
1threat
C++ basic inheritance : <p>While learning C++ Classes - Basic Inheritance - my program returned an error saying: "C++ forbids comparison between pointer and integer and C++ forbids comparison between pointer and integer". Where did I go wrong? Thanks for your help! :-) </p> <pre><code>#include &lt;iostream&gt; using namespace std; class Pizza { public: int slices; char topping[10]; bool pepperoni , cheese ; }; int main() { // Make your own Pizza! Pizza pizza; cout &lt;&lt; "\n You can have Cheese or Pepperoni Pizza!"; cout &lt;&lt; "\n Type [cheese] or [pepperoni] \n"; cin &gt;&gt; pizza.topping[10]; if (pizza.topping[10] == "pepperoni") { pizza.pepperoni = true;} if (pizza.pepperoni == true) {cout &lt;&lt; "How many slices of pepperoni would you like?";}; if ( pizza.topping[10] == "cheese") { pizza.cheese = true;} if (pizza.cheese == true) {cout &lt;&lt; "How many slices of cheese would you like?";}; cin &gt;&gt; pizza.slices; if (pizza.slices &gt;= 1) {cout &lt;&lt; "You ordered " &lt;&lt; pizza.slices &lt;&lt; " slices of " &lt;&lt; pizza.topping[10] &lt;&lt; " Pizza!"; } else if (pizza.slices &lt;= 0) {cout &lt;&lt; "Change your mind?"; } else { cout &lt;&lt;"Can't Decide? That's Okay.";} } </code></pre>
0debug
UITabbarController in Xcode 8 shows a blue rectangle inside a storyboard view : <p>How can I fix this ? I can't see anything at all.</p> <p><a href="https://i.stack.imgur.com/TPmmU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TPmmU.png" alt="enter image description here"></a></p>
0debug
Show post of different category in even odd position in wordpress : i need to show data in even or odd standard of different category in wordpress. for example one post of news type and another is second category.
0debug
Imagine you have a movie collection, and you want to write code that returns your review for each one. Here are the movies and your reviews: : <p>i am getting confused , how to do this task</p> <blockquote> <p>Imagine you have a movie collection, and you want to write code that returns your review for each one. Here are the movies and your reviews:</p> <pre><code>"Toy Story 2" - "Great story. Mean prospector." "Finding Nemo" - "Cool animation, and funny turtles." "The Lion King" - "Great songs." </code></pre> <p>Write a function named getReview that takes in a movie name and returns its review based on the information above. If given a movie name not found just return "I don't know!". Use a structure learned in an earlier lesson (NOT if/else statements) to write this function.</p> </blockquote> <pre><code>var getReview = function (movie) { var a = ["Toy Story 2","Finding Nemo","The Lion King"] for(a[0]="Toy Story 2"){console.log("Great story. Mean prospector.")} for(a[0]="Finding Nemo"){console.log("Cool animation, and funny turtles.")} for(a[0]="The Lion King" ){console.log( "Great songs.")} }; </code></pre> <p>some sugguest the rightway to doit.</p>
0debug
Constructor in Inheritance something goes wrong : <p>I am doing something wrong on constructor what it is.I cant understand.I know you may not understand the code because is another language.I have done an abstract class Metafores and subclasses,Aerio,Meikto,Stereo.Please check my code i have done something wrong on my constructors but i dont know what it is.How should it be?</p> <pre><code> package eksetash1; public class Aerio extends Metafores { private int SyskeuasiasAeriou; public Aerio(){ } public Aerio(int SyskeuasiaAeriou,int gettyposProiontos,int gettyposMetaforas,int gettyposMetrisis,String getonomaProiontos,double gettimiMonadas){ super(gettyposProiontos,gettyposMetaforas,gettyposMetrisis,getonomaProiontos,gettimiMonadas); this.SyskeuasiasAeriou=SyskeuasiasAeriou; } @Override int gettyposProiontos() { return 3; } @Override int gettyposMetaforas() { return 0; } @Override int gettyposMetrisis(){ return 0; } @Override double gettimiMonadas(){ return 0; } @Override String getonomaProiontos(){ return null; } } //end package eksetash1; public class Eksetash1 { static int N; //apo to plhktrologio static String Typos; public static void main(String[] args) { Metafores[] pin = new Metafores[N]; for (int i = 0; i &lt; 10; i++) { pin[i] = new Stereo(); pin[i+10] = new Ygro(); pin[i+20] = new Aerio(); pin[i+30]=new Meikto(); } // exceptions System.out.println("An einai Ygro,aeria,meiktou barous tha exoume eksairesh-grapste analoga"); if ((Typos = UserInput.getString()).equalsIgnoreCase("Ygro")) { throw new IllegalExceptionMetaforas("Ta ygra dn metaferontai me aeroplano "); } System.out.println("An einai aeria tha exoume eksairesh"); if ((Typos = UserInput.getString()).equalsIgnoreCase("aeria")) { throw new IllegalExceptionMetaforas("Ta aeria dn metaferontai me to aeroplano"); } System.out.println("An einai meiktou barous"); if ((Typos = UserInput.getString()).equalsIgnoreCase("meiktou barous")) { throw new IllegalExceptionMetaforas("Meiktou barous dn metaferontai me to aeroplano"); } } }//end main package eksetash1; //class exception public class IllegalExceptionMetaforas extends RuntimeException{ public IllegalExceptionMetaforas (String s){ super(s); } }//end exception illegal package eksetash1; //another class Meikto public class Meikto extends Metafores { private String perigrafhSyskeuasias; public Meikto(){ } //constructor public Meikto(String perigrafhSyskeuasias,int gettyposProiontos,int gettyposMetaforas,int gettyposMetrisis,String getonomaProiontos,double gettimiMonadas){ super(gettyposProiontos,gettyposMetaforas,gettyposMetrisis,getonomaProiontos,gettimiMonadas); this.perigrafhSyskeuasias=perigrafhSyskeuasias; } @Override int gettyposProiontos() { return 4; } @Override int gettyposMetaforas() { return 0; } @Override int gettyposMetrisis(){ return 0; } @Override double gettimiMonadas(){ return 0; } @Override String getonomaProiontos(){ return perigrafhSyskeuasias ; } } //end package eksetash1; // class Stereo public class Stereo extends Metafores { private String perigrafhYlikou; public Stereo(){ } // consructor public Stereo(String perigrafhYlikou,int gettyposProiontos,int gettyposMetaforas,int gettyposMetrisis,String getonomaProiontos,double gettimiMonadas){ super(gettyposProiontos,gettyposMetaforas,gettyposMetrisis,getonomaProiontos,gettimiMonadas); this.perigrafhYlikou=perigrafhYlikou; } public void settyposProiontos(String typos){ typos=typos; } @Override int gettyposProiontos() { return 1; } @Override int gettyposMetaforas() { return 0; } @Override int gettyposMetrisis(){ return 0; } @Override double gettimiMonadas(){ return 0; } @Override String getonomaProiontos(){ return perigrafhYlikou; } } //end stereo //abstract class Metafores package eksetash1; public abstract class Metafores { abstract int gettyposProiontos(); abstract int gettyposMetaforas(); abstract int gettyposMetrisis(); abstract String getonomaProiontos(); abstract double gettimiMonadas(); static String Typos; public Metafores(){ } //constructor public Metafores(int gettyposProiontos,int gettyposMetaforas,int gettyposMetrisis,int getonomaProiontos,double gettimiMonadas){ } public void getTyposProiontos(){ System.out.println("Grapste Stereo"); if ((Typos = UserInput.getString()).equalsIgnoreCase("Stereo")) { Stero.settyposProiontos(1); Stereo.gettyposProiontos(1);//stereo=1 } System.out.println("Grapste Ygro"); if ((Typos = UserInput.getString()).equalsIgnoreCase("Ygro")) { Ygro.settyposProiontos(2); Ygro.gettyposProiontos(2);//ygro=2 } System.out.println("Grapste Aerio"); if ((Typos = UserInput.getString()).equalsIgnoreCase("Aerio")) { Aerio.settyposPriontos(3); Aerio.gettyposProiontos(3);//aerio=3 } System.out.println("Grapste Meikto"); if ((Typos = UserInput.getString()).equalsIgnoreCase("Meikto")) { Meikto.settyposProiontos(4); Meikto.gettyposProiontos(4);//meikto=4 } } public void getTyposMetaforas(){ System.out.println("Grapste Stereo"); if ((Typos = UserInput.getString()).equalsIgnoreCase("Stereo")) { Stero.settyposMetaforas(); Stereo.gettyposMetaforas(); } System.out.println("Grapste Ygro"); if ((Typos = UserInput.getString()).equalsIgnoreCase("Ygro")) { Ygro.settyposMetaforas(); Ygro.gettyposMetaforas(); } System.out.println("Grapste Aerio"); if ((Typos = UserInput.getString()).equalsIgnoreCase("Aerio")) { Aerio.settyposMetaforas(3); Aerio.gettyposMetaforas(3); } System.out.println("Grapste Meikto"); if ((Typos = UserInput.getString()).equalsIgnoreCase("Meikto")) { Meikto.settyposMetaforas(4); Meikto.gettyposProiontos(4); } } } </code></pre>
0debug
Angular 5 - HttpClient Post not posting : <p>I have a httpClient post, through a service, that's not giving my any errors but it's not posting the data to the database either.</p> <p>Here is the code:</p> <p>dataService.ts</p> <pre><code>import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) }; @Injectable() export class DataService { constructor(private http: HttpClient) {} insertData() { const body = JSON.stringify({firstName: 'Joele', lastName: 'Smith4'}); return this.http.post('http://myurl/index.php', body, httpOptions); } } </code></pre> <p>app.component.ts</p> <pre><code>import { Component } from '@angular/core'; import { DataService } from './services/data.service'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { constructor(private dataService: DataService) {} myInsert() { if (this.dataService.insertData()) { alert('Data Inserted Successfully'); } } } </code></pre> <p>and finally app.component.html</p> <pre><code>&lt;div (click)="myInsert()"&gt;Click Me&lt;/div&gt; </code></pre> <p>I've checked on chrome network for the post but nothing is shown there. How can I fix this?</p>
0debug
How to write complexity of a program? Please help me to write big Oh notation : What is the number of steps it will take to run Program 2 in the worst case? Express your answer in terms of n, the size of the input x. def program2(x): total = 0 for i in range(1000): total = i while x > 0: x = x//2 total += x return total
0debug
android studio setting string to intent : String c="MainActivty.class"; Intent ints =new Intent(getApplication(),c); startActivity(ints); How can i do this on the click of the button i.e specify c to an Intent
0debug
How to make this code work in Javascript? : **Statement** This code worked so far but I would like to make it run without using `<form>...</form>` What should I need to change in the javascript part? *Any method or suggestion?* - Using elememt.onclick() instead of using element.addEventListener() ? geoconverter.html ``` <html> <body> <div class="row justify-content-center"> <div class="container"> <h3>Please enter location name :</h3> <form id="locPost"> <!--HERE--> <div class="form-group"> <input size="50" type="text" id="getGPS" required> </div> <button style="font-size:18px;border:2px solid black" type="submit" name="Convert" class="btn btn-primary">Convert <i class="fas fa-location-arrow"></i></button> <button style="font-size:18px;border:2px solid black" onclick="location.reload();" class="btn btn-success">Refresh Page <i class="fas fa-sync"></i></button> <div class="form-group"></div> <div class="form-group"> <label>Latitude</label>:&emsp; <input id="latte" style="font-size:1em" type="text" maxlength="10" step="any" name="lat" readonly> </div> <div class="form-group"> <label>Longitude</label>: <input id="longer" style="font-size:1em" type="text" maxlength="10" step="any" name="lng" readonly> </div> <div class="row justify-content-center"> <button style="font-size:18px;border:2px solid black" onclick="window.close()" class="btn btn-danger">Close Geoconverter <i class="fas fa-times"></i></button> </div> </form> <!--AND HERE--> </div> </div> </body> </html> <script> // Get location form var locationForm = document.getElementById('locPost'); // Listen for submit locationForm.addEventListener('submit', geocode); function geocode(e) { // Prevent actual submit e.preventDefault(); var location = document.getElementById('getGPS').value; axios.get('https://maps.googleapis.com/maps/api/geocode/json',{ params:{ address:location, key:'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' //Paste your Google API KEY HERE! } }) .then(function(response) { // Get Lat-Long var latpos = response.data.results[0].geometry.location.lat; var lngpos = response.data.results[0].geometry.location.lng; document.getElementById('latte').value = latpos; document.getElementById('longer').value = lngpos; }) } </script> ``` **Expectation** It will be able to run and get the result exactly the same as before.
0debug
Find one or create with Mongoose : <p>I have </p> <pre><code>Page.findById(pageId).then(page =&gt; { const pageId = page.id; .. }); </code></pre> <p>My problem is that if no page id is given, it should just take the first available page given some conditions, which is done by</p> <pre><code>Page.findOne({}).then(page =&gt; { const pageId = page.id; .. }); </code></pre> <p>but if no page is found, it should create a new page and use this, which is done with</p> <pre><code>Page.create({}).then(page =&gt; { const pageId = page.id; .. }); </code></pre> <p>But how do I combine all this to as few lines as possible?</p> <p>I have a lot of logic going on inside</p> <pre><code>page =&gt; { ... } </code></pre> <p>so I would very much like to do this smart, so I can avoid doing it like this</p> <pre><code>if (pageId) { Page.findById(pageId).then(page =&gt; { const pageId = page.id; .. }); } else { Page.findOne({}).then(page =&gt; { if (page) { const pageId = page.id; .. } else { Page.create({}).then(page =&gt; { const pageId = page.id; .. }); } }); } </code></pre> <p>I am thinking I maybe could assign a static to the schema with something like</p> <pre><code>pageSchema.statics.findOneOrCreate = function (condition, doc, callback) { const self = this; self.findOne(condition).then(callback).catch((err, result) =&gt; { self.create(doc).then(callback); }); }; </code></pre>
0debug
Hi everyone, when i make the math of any number * 1% it gives me a long number, i wanted to cut it down to 2 decimal C# WPF conversion : <p>My question here is how can i convert the result of the math into a two decimal result?{ private void BtnAjoutInteret_Click(object sender, RoutedEventArgs e)//When i press the ok button</p> <pre><code> try { for (int i = 1; i &lt; clients.ListesClients.Count; i++)// For all the bank clients add //one percent to the sum why is it so hard to post a question on stackoverflow { double interet = .01; clients.ListesClients[i].Balance = (clients.ListesClients[i].Balance * interet) + (clients.ListesClients[i].Balance); clients.AjustementCompte(clients.ListesClients[0]);//once the one percent is added use the methode to add the new balance to the txtfile. } MessageBox.Show("Transaction accepter"); LviewListeClients.Items.Refresh(); } catch (Exception) { MessageBox.Show("erreur 5 "); return; } } public void AjustementCompte(Client Nouvelle)//This is the method to add the new balance { //listeClients.Add(NouvelleTransaction); StreamWriter Writer = new StreamWriter(filename); foreach (Client client in ListesClients) { Writer.WriteLine($"{client.ID};{client.TypeDeCompte};{client.Balance}"); } Writer.Close(); } } </code></pre>
0debug
static void cmd_read_cdvd_capacity(IDEState *s, uint8_t* buf) { uint64_t total_sectors = s->nb_sectors >> 2; if (total_sectors == 0) { ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); return; } cpu_to_ube32(buf, total_sectors - 1); cpu_to_ube32(buf + 4, 2048); ide_atapi_cmd_reply(s, 8, 8); }
1threat
static int handle_sigp(S390CPU *cpu, uint8_t ipa1, uint32_t ipb) { CPUS390XState *env = &cpu->env; const uint8_t r1 = ipa1 >> 4; const uint8_t r3 = ipa1 & 0x0f; int ret; uint8_t order; uint64_t *status_reg; uint64_t param; S390CPU *dst_cpu = NULL; cpu_synchronize_state(CPU(cpu)); order = decode_basedisp_rs(env, ipb, NULL) & SIGP_ORDER_MASK; status_reg = &env->regs[r1]; param = (r1 % 2) ? env->regs[r1] : env->regs[r1 + 1]; if (qemu_mutex_trylock(&qemu_sigp_mutex)) { ret = SIGP_CC_BUSY; goto out; } switch (order) { case SIGP_SET_ARCH: ret = sigp_set_architecture(cpu, param, status_reg); break; default: dst_cpu = s390_cpu_addr2state(env->regs[r3]); ret = handle_sigp_single_dst(dst_cpu, order, param, status_reg); } qemu_mutex_unlock(&qemu_sigp_mutex); out: trace_kvm_sigp_finished(order, CPU(cpu)->cpu_index, dst_cpu ? CPU(dst_cpu)->cpu_index : -1, ret); if (ret >= 0) { setcc(cpu, ret); return 0; } return ret; }
1threat
nested for loop in a function array : <p>I am working on a c++ homework assignment for arrays and functions, and this is what I have so far and am not even sure if I am on the right path or not. These are the exact instructions.. </p> <p><em>Write a program to ask the user to enter a total of N numbers which you will store in main local array of Define N as a constant int and initialize it to 6. You will write the following functions: FillArray( ) – accepts two inputs: (1) the array. (2) the array size. Returns nothing. β€’ Prompts the user to enter N elements (N = the array size and the variables you pass should have been defined as a constant int in main( ) β€’ Use a for loop to enter and store the value of each element in the array</em></p> <pre><code>#include &lt;iostream&gt; using namespace std; int main(){ cout &lt;&lt; "Enter 6 numbers for the array:" &lt;&lt; endl; FillArray(); return 0; } void FillArray(){ int n; int array[6] = { 0, 0, 0, 0, 0, 0,}; void fillarray(const int n[], int size); for (; n &gt; 6; n++) cin &gt;&gt; array[n]; cout &lt;&lt; "Thank you\n"; } </code></pre> <p>Any suggestions or help would be appreciated.. thank you!</p>
0debug
Flutter - Collapsing ExpansionTile after choosing an item : <p>I'm trying to get <code>ExpansionTile</code> to collapse after I choose an item, but it does not close the list that was opened.</p> <p>I tried to use the <code>onExpansionChanged</code> property but I did not succeed</p> <p>How could you solve this problem?</p> <p>Insert a gif demonstrating that <code>ExpansionTile</code> does not collapse after choosing an item, and below is also the code used.</p> <p><a href="https://i.stack.imgur.com/WNjaz.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/WNjaz.gif" alt="enter image description here"></a></p> <pre><code>import 'package:flutter/material.dart'; void main() { runApp(new ExpansionTileSample()); } class ExpansionTileSample extends StatefulWidget { @override ExpansionTileSampleState createState() =&gt; new ExpansionTileSampleState(); } class ExpansionTileSampleState extends State&lt;ExpansionTileSample&gt; { String foos = 'One'; @override Widget build(BuildContext context) { return new MaterialApp( home: new Scaffold( appBar: new AppBar( title: const Text('ExpansionTile'), ), body: new ExpansionTile( title: new Text(this.foos), backgroundColor: Theme.of(context).accentColor.withOpacity(0.025), children: &lt;Widget&gt;[ new ListTile( title: const Text('One'), onTap: () { setState(() { this.foos = 'One'; }); }, ), new ListTile( title: const Text('Two'), onTap: () { setState(() { this.foos = 'Two'; }); }, ), new ListTile( title: const Text('Three'), onTap: () { setState(() { this.foos = 'Three'; }); }, ), ] ), ), ); } } </code></pre>
0debug
The requested package ... could not be found in any version : <p>When I want to require my project, the following errors shows up:</p> <p><em>The requested package mvc-php/framework could not be found in any version, there may be a typo in the package name.</em></p> <p>The "mvc-php/framework" is a git folder.</p> <pre><code>{ "name": "mvc-php/app", "repositories": [ { "type": "path", "url": "/Users/youri/Documents/Github/framework" } ], "require": { "php": "&gt;=7.0", "mvc-php/framework": "master" }, "autoload": { "psr-4": { "App\\": "app/" } } } </code></pre> <p>Project i want to require:</p> <pre><code>{ "name": "mvc-php/framework", "description": "PHP MVC framework", "autoload": { "psr-4": { "Mvc\\" : "src/" } }, "require": { "php": "&gt;=7.0" } } </code></pre>
0debug
cant turn on acer switch 10 ; black screen : <p>the problem is interesting. i have instaled windows 10 32bit on this tablet and touch screen didnt work. so i troubleshoted hardware and it said the problem is with cpu core. it said thad it musts reinstall the driver. ok, i did it. while it was doing this proces it sudently turned off. i presed power on button and it started runing but it cant go to windows, even acer logo doesnt shows up(cant go to bios). there is only black screen. also i cant turn it off right now.</p> <p>where is the problem, and how to fix it?</p>
0debug
static int mov_write_identification(AVIOContext *pb, AVFormatContext *s) { MOVMuxContext *mov = s->priv_data; int i; mov_write_ftyp_tag(pb,s); if (mov->mode == MODE_PSP) { int video_streams_nb = 0, audio_streams_nb = 0, other_streams_nb = 0; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) video_streams_nb++; else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) audio_streams_nb++; else other_streams_nb++; } if (video_streams_nb != 1 || audio_streams_nb != 1 || other_streams_nb) { av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n"); return AVERROR(EINVAL); } mov_write_uuidprof_tag(pb, s); } return 0; }
1threat
output of expression in ( i-- - ++i) in java : <pre><code>int i = 11; i = i-- - ++i; System.out.println( i-- - ++i ); </code></pre> <p>Output: 0</p> <p>Please can you people explain? It is really confusing </p>
0debug
How to create screen sharing application C# : <p>I have recently tried to make a screen sharing application, but it does not work. It works to share my own screen for myself, but not with my friend. Does the other user need to be connected to the same internet? I would really appreciate some help! :)</p>
0debug
who to add mousDown event in chromium browser c# wpf : I use in chromium webBrowser WPF in my program c# and when I tried to add a mouseDown event it doesn't work. my chromium control in a userControl. any idea?
0debug
I don't understand this concept. In ruby what do you mean when you say multi line comment using this symbol <<? : I don't understand this concept. In ruby what do you mean when you say multi line comment using this symbol << ?
0debug
query with group function gives error " Invalid use of group function" : I have 3 tables: users table: contains the userid, email, contact no like table:which contains picture ids, and userids who liked it picture posted table: which conatins picture ids, user id who posted it I want to get the no of likes each user got from the above tables: I am using the below query , it is giving an error , what would be the correct one : select sum(count(pid)) from p_like where pid in ( select pid from p_picuser where userid in ( SELECT userid from p_users ) ) GROUP BY pid
0debug
google map did not show in the html using div : <html> <head> <script async defer src="https://maps.googleapis.com/maps/api/js?key=mykeyM&callback=myMap" type="text/javascript"> </script> </head> <body> <script> function myMap() { var mapProp= { center:new google.maps.LatLng(37.00,22.077462), zoom:15, }; var map=new google.maps.Map(document.getElementById("googleMap"),mapProp); } </script> <div class="container" id="fh5co-contact-section"> <div class="row"> <div class="col-md-3 col-md-push-1 animate-box"> <h3>Our Address</h3> <ul class="contact-info"> <li><i class="icon-mail"></i><a href="#">test@gmail.com</a></li> <li><i class="icon-globe2"></i><a href="#">www.test.com</a></li> </ul> </div> <div class="col-lg-9 col-md-6 col-sm-9 col-xs-12"> <div id="googleMap" style="width:100px;height:450px;"></div> </div> </div> </div> </body> </html>
0debug
static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque) { CURLState *s = ((CURLState*)opaque); size_t realsize = size * nmemb; int i; DPRINTF("CURL: Just reading %zd bytes\n", realsize); if (!s || !s->orig_buf) goto read_end; if (s->buf_off >= s->buf_len) { return 0; } realsize = MIN(realsize, s->buf_len - s->buf_off); memcpy(s->orig_buf + s->buf_off, ptr, realsize); s->buf_off += realsize; for(i=0; i<CURL_NUM_ACB; i++) { CURLAIOCB *acb = s->acb[i]; if (!acb) continue; if ((s->buf_off >= acb->end)) { qemu_iovec_from_buf(acb->qiov, 0, s->orig_buf + acb->start, acb->end - acb->start); acb->common.cb(acb->common.opaque, 0); qemu_aio_release(acb); s->acb[i] = NULL; } } read_end: return realsize; }
1threat
quadratic equation roots c function : The problem(C programming) ================================ Write a function that calculates the real and imaginary roots of the quadratic equation ax^2 +bx+c = 0. You should handle the three types of roots. Hint: use this function prototype: π’Šπ’π’• 𝒄𝒂𝒍𝒄𝒖𝒍𝒂𝒕𝒆𝑹𝒐𝒐𝒕𝒔(π’Šπ’π’• 𝒂, π’Šπ’π’• 𝒃, π’Šπ’π’• 𝒄, 𝒇𝒍𝒐𝒂𝒕 βˆ— π’“π’π’π’•πŸ, 𝒇𝒍𝒐𝒂𝒕 βˆ— π’“π’π’π’•πŸ) ================================ my questions: * how can a function solving quadratic equation returns an int?? I am clueless on what that means ** I changed the fuction return type to *void()* but I couldn't handle the 2 imaginary roots not sure how to return real+imag****i*** ================================ here 's what I reached so far ================================ #include <stdio.h> #include <stdlib.h> #include <math.h> int calculateRoots(int a,int b,int c,float* root1,float* root2); int main() { float r1,r2; int a,b,c; printf("enter the coefficients :\n"); scanf("%d%d%d",&a,&b,&c); printf("roots of equation are:%d and %d",calculateRoots(a,b,c,&r1,&r2)); return 0; } void calculateRoots(int a,int b,int c,float* root1,float* root2) { float x=b*b-4*a*c; if(x==0) { *root1=(-1*b)/(2*a); *root2=(-1*b)/(2*a); } else if(x>0) { *root1=(-1*b+x)/(2*a) ; *root2=(-1*b-x)/(2*a) ; } if(x<0) { root1=// Any help here } }
0debug
Need help for converting an integer to binary : <p>Im new to C++ and I need to make a program that can convert a decimal number into a binary one. This is what ive got so far, but it only shows 0000 0000 0000 0000 (the spaces are intended)</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;iostream&gt; #include &lt;windows.h&gt; #include &lt;math.h&gt; float EntierAConvertir; int main() { printf("Entrez l'entier Γ  convertir\n"); scanf("%lf", &amp;EntierAConvertir); for(long double i = 16; i != 0; i-- ) { if (EntierAConvertir &gt; (pow(2,i-1))) { printf("1"); } else if (EntierAConvertir &lt; (pow(2,i-1))) { printf("0"); } if (i == 13 | i==9 | i == 5) { printf(" "); } } system("pause"); return 0; } </code></pre> <p>Help is very appreciated! :)</p>
0debug