problem
stringlengths
26
131k
labels
class label
2 classes
static inline uint32_t reloc_pc16_val(tcg_insn_unit *pc, tcg_insn_unit *target) { ptrdiff_t disp = target - (pc + 1); assert(disp == (int16_t)disp); return disp & 0xffff; }
1threat
gdb_handlesig (CPUState *env, int sig) { GDBState *s; char buf[256]; int n; s = &gdbserver_state; if (gdbserver_fd < 0 || s->fd < 0) return sig; cpu_single_step(env, 0); tb_flush(env); if (sig != 0) { snprintf(buf, sizeof(buf), "S%02x", sig); put_packet(s, buf); } if (s->fd < 0) return sig; sig = 0; s->state = RS_IDLE; s->running_state = 0; while (s->running_state == 0) { n = read (s->fd, buf, 256); if (n > 0) { int i; for (i = 0; i < n; i++) gdb_read_byte (s, buf[i]); } else if (n == 0 || errno != EAGAIN) { return sig; } } sig = s->signal; s->signal = 0; return sig; }
1threat
How to query document reference type from firestore using flutter : <p>I have a field in my customers collection referencing a list of collection references that point to orders, how do I retrieve all the orders from my customer collection. What I hope to do is retrieve a list of orders for a specific customer based on an id. Thank you!</p> <p><a href="https://i.stack.imgur.com/IkStg.png" rel="nofollow noreferrer">Customers collection with order references</a></p> <p><a href="https://i.stack.imgur.com/y6cJP.png" rel="nofollow noreferrer">Order data that I want to retrieve</a></p>
0debug
static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id) { VirtIOSerial *s = opaque; VirtIOSerialPort *port; uint32_t max_nr_ports, nr_active_ports, ports_map; unsigned int i; if (version_id > 3) { virtio_load(&s->vdev, f); if (version_id < 2) { return 0; qemu_get_be16s(f, &s->config.cols); qemu_get_be16s(f, &s->config.rows); qemu_get_be32s(f, &max_nr_ports); if (max_nr_ports > s->config.max_nr_ports) { for (i = 0; i < (max_nr_ports + 31) / 32; i++) { qemu_get_be32s(f, &ports_map); if (ports_map != s->ports_map[i]) { qemu_get_be32s(f, &nr_active_ports); for (i = 0; i < nr_active_ports; i++) { uint32_t id; bool host_connected; id = qemu_get_be32(f); port = find_port_by_id(s, id); port->guest_connected = qemu_get_byte(f); host_connected = qemu_get_byte(f); if (host_connected != port->host_connected) { send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, port->host_connected); if (version_id > 2) { uint32_t elem_popped; qemu_get_be32s(f, &elem_popped); if (elem_popped) { qemu_get_be32s(f, &port->iov_idx); qemu_get_be64s(f, &port->iov_offset); qemu_get_buffer(f, (unsigned char *)&port->elem, sizeof(port->elem)); virtqueue_map_sg(port->elem.in_sg, port->elem.in_addr, port->elem.in_num, 1); virtqueue_map_sg(port->elem.out_sg, port->elem.out_addr, port->elem.out_num, 1); virtio_serial_throttle_port(port, false); return 0;
1threat
I can't create a struct with the data retrieved from request : <p>I'm trying to get the values passed by json in my API, example below:</p> <p><a href="https://i.stack.imgur.com/R9bMI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R9bMI.png" alt="Insomnia data"></a></p> <p>The code:</p> <p><a href="https://i.stack.imgur.com/wYAZj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wYAZj.png" alt="handle code"></a></p> <p>The struct</p> <p><a href="https://i.stack.imgur.com/6s468.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6s468.png" alt="Gerente struct"></a></p> <p>I already tried to use <code>`json:"nome"`</code></p> <p>I already tried to change the declaration, the way to instantiate the struct and already tried several approaches to get the values and create the "gerente object"</p> <p>The result is always the same.</p> <p><a href="https://i.stack.imgur.com/y4RSn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y4RSn.png" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/8NRil.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8NRil.png" alt="enter image description here"></a></p>
0debug
Why does C# have 'readonly' and 'const'? : <p>I come from a C++ background and am trying to become proficient in C#. It seems like C# always has 2 types of modifiers wherever C++ had one. For example, in C++ there is <code>&amp;</code> for references and then in C# there is <code>ref</code> and <code>out</code> and I have to learn the subtle differences between them. Same with <code>readonly</code> and <code>const</code>, which are the topic of this thread. Can someone explain to me what the subtle differences are between the 2? Maybe show me a situation where I accidentally use the wrong one and my code breaks. </p>
0debug
IDEWorkspaceChecks.plist file suddenly appear after updated xcode : <p>I suddenly start having this file in my xcode project after I updated my xcode:</p> <pre><code>myProject.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist </code></pre> <p>What does this file do? Should I exclude it in version control?</p>
0debug
Kotlin Test Coverage : <p>Does anyone know if a good test coverage tool (preferably Gradle plugin) exists for Kotlin? I've looked into JaCoCo a bit, but it doesn't seem to reliably support Kotlin.</p>
0debug
int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s, void *data, uint32_t length, uint64_t offset) { int ret = 0; VHDXLogSequence logs = { .valid = true, .count = 1, .hdr = { 0 } }; bdrv_flush(bs); ret = vhdx_log_write(bs, s, data, length, offset); if (ret < 0) { goto exit; } logs.log = s->log; bdrv_flush(bs); ret = vhdx_log_flush(bs, s, &logs); if (ret < 0) { goto exit; } s->log = logs.log; exit: return ret; }
1threat
Mobile Safari multi select bug : <p>If found a really annoying bug on the current (iOS 9.2) mobile safari (first appearing since iOS 7!)</p> <p>If you using multi select fields on mobile safari - like this:</p> <pre class="lang-html prettyprint-override"><code>&lt;select multiple&gt; &lt;option value="test1"&gt;Test 1&lt;/option&gt; &lt;option value="test2"&gt;Test 2&lt;/option&gt; &lt;option value="test3"&gt;Test 3&lt;/option&gt; &lt;/select&gt; </code></pre> <p>You will have problems with automatically selection!</p> <p>iOS is automatically selecting the first option after you opened the select (without any user interaction) - but it will not show it to you with the blue select "check".</p> <p>So if you now select the second option, the select will tell you that two options are selected (but only highlighting one as selected)...</p> <p>If you now close and open the select again, iOS will automatically deselect the first value - if you repeat, it will be selected again without any user interaction.</p> <p>Thats a really annoying system bug, which is breaking the user experience!</p>
0debug
Java - Number of 1s = 0s in bit string : Interested in using bitwise operators to count number of 1s = 0s in a bit string. If 1s=0s then output. Any ideas on using Java to accomplish this. Thank you. `public void function(int binaryNumber) { BigInteger val = new BigInteger(String.valueOf(binaryNumber)); val = val.abs(); int count = val.bitCount(); String binaryString = val.toString(2); System.out.println("count = " + count); System.out.println("bin = " + binaryString); }`
0debug
static OfDpaGroup *of_dpa_group_alloc(uint32_t id) { OfDpaGroup *group = g_malloc0(sizeof(OfDpaGroup)); if (!group) { return NULL; } group->id = id; return group; }
1threat
static int decode_nal_sei_message(GetBitContext *gb, void *logctx, HEVCSEI *s, const HEVCParamSets *ps, int nal_unit_type) { int payload_type = 0; int payload_size = 0; int byte = 0xFF; av_log(logctx, AV_LOG_DEBUG, "Decoding SEI\n"); while (byte == 0xFF) { byte = get_bits(gb, 8); payload_type += byte; } byte = 0xFF; while (byte == 0xFF) { byte = get_bits(gb, 8); payload_size += byte; } if (nal_unit_type == HEVC_NAL_SEI_PREFIX) { return decode_nal_sei_prefix(gb, logctx, s, ps, payload_type, payload_size); } else { return decode_nal_sei_suffix(gb, logctx, s, payload_type, payload_size); } }
1threat
How does JS remove the quotation marks before and after the string? : <p>How can I remove the quotation marks on both sides?</p> <p><strong>Want the result as follows</strong></p> <pre><code>[{"id":1,"photo":"111"},{"id":2,"photo":"222"}] </code></pre> <p><strong>my code:</strong></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var a = "[{"id":1,"photo":"111"},{"id":2,"photo":"222"}]"</code></pre> </div> </div> </p>
0debug
static void net_dump_cleanup(VLANClientState *vc) { DumpState *s = vc->opaque; close(s->fd); qemu_free(s); }
1threat
Convert dataframe numeric column to character : <p>I have a data frame with character and numeric columns, when plotting a PCA later on, I need to plot character columns so I wanted to convert column "station" to character.</p> <p>The data frame:</p> <pre><code>coldata &lt;- data.frame(Location = c(West,West,East,East), Station = c(1,2,3,4), A = c("0.3","0.2","0.8","1")) </code></pre> <p>And the type of columns:</p> <pre><code>sapply(coldata, mode) location station A "character" "numeric" "numeric" </code></pre> <p>I would like to have this:</p> <pre><code>sapply(coldata, mode) location station A "character" "character" "numeric" </code></pre> <p>Can a column be labelled as "character" if containing numbers? Or would I have to convert the numbers into words: ie: 1, 2, 3,4 to one, two, three, four? </p> <p>I have seen many posts converting character into numeric, but not numeric to character.</p>
0debug
how application user select that is he like to receive notification or not in android using firebase : <p>In my application i can send notification to all users by FCM Console. Now i want that users select that they like to receive notifications or not , and only users that like it receive notifications.</p> <p>please guide me</p>
0debug
How to order array based on category? : <p>I've got the following array of objects:</p> <pre><code>var source = [ {"name": "title_1", "category": "order"}, {"name": "title_2", "category": "purchase"}, {"name": "title_3", "category": "order"}, {"name": "title_4", "category": "detail"}, {"name": "title_5", "category": "order"}, {"name": "title_6", "category": "purchase"}, ] </code></pre> <p>I need to sort this array out to get elements in order (first - orders, second - detail, third - purchase):</p> <pre><code>console.log(source.sort(function () { // todo: ? })) </code></pre> <p><em>Expected result:</em></p> <pre><code>[ {"name": "title_1", "category": "order"}, {"name": "title_3", "category": "order"}, {"name": "title_5", "category": "order"}, {"name": "title_4", "category": "detail"}, {"name": "title_2", "category": "purchase"}, {"name": "title_6", "category": "purchase"}, ] </code></pre> <p>How to write sort function to get expected result?</p>
0debug
vubr_backend_recv_cb(int sock, void *ctx) { VubrDev *vubr = (VubrDev *) ctx; VuDev *dev = &vubr->vudev; VuVirtq *vq = vu_get_queue(dev, 0); VuVirtqElement *elem = NULL; struct iovec mhdr_sg[VIRTQUEUE_MAX_SIZE]; struct virtio_net_hdr_mrg_rxbuf mhdr; unsigned mhdr_cnt = 0; int hdrlen = vubr->hdrlen; int i = 0; struct virtio_net_hdr hdr = { .flags = 0, .gso_type = VIRTIO_NET_HDR_GSO_NONE }; DPRINT("\n\n *** IN UDP RECEIVE CALLBACK ***\n\n"); DPRINT(" hdrlen = %d\n", hdrlen); if (!vu_queue_enabled(dev, vq) || !vu_queue_started(dev, vq) || !vu_queue_avail_bytes(dev, vq, hdrlen, 0)) { DPRINT("Got UDP packet, but no available descriptors on RX virtq.\n"); return; } do { struct iovec *sg; ssize_t ret, total = 0; unsigned int num; elem = vu_queue_pop(dev, vq, sizeof(VuVirtqElement)); if (!elem) { break; } if (elem->in_num < 1) { fprintf(stderr, "virtio-net contains no in buffers\n"); break; } sg = elem->in_sg; num = elem->in_num; if (i == 0) { if (hdrlen == 12) { mhdr_cnt = iov_copy(mhdr_sg, ARRAY_SIZE(mhdr_sg), sg, elem->in_num, offsetof(typeof(mhdr), num_buffers), sizeof(mhdr.num_buffers)); } iov_from_buf(sg, elem->in_num, 0, &hdr, sizeof hdr); total += hdrlen; ret = iov_discard_front(&sg, &num, hdrlen); assert(ret == hdrlen); } struct msghdr msg = { .msg_name = (struct sockaddr *) &vubr->backend_udp_dest, .msg_namelen = sizeof(struct sockaddr_in), .msg_iov = sg, .msg_iovlen = elem->in_num, .msg_flags = MSG_DONTWAIT, }; do { ret = recvmsg(vubr->backend_udp_sock, &msg, 0); } while (ret == -1 && (errno == EINTR)); if (i == 0) { iov_restore_front(elem->in_sg, sg, hdrlen); } if (ret == -1) { if (errno == EWOULDBLOCK) { vu_queue_rewind(dev, vq, 1); break; } vubr_die("recvmsg()"); } total += ret; iov_truncate(elem->in_sg, elem->in_num, total); vu_queue_fill(dev, vq, elem, total, i++); free(elem); elem = NULL; } while (false); if (mhdr_cnt) { mhdr.num_buffers = i; iov_from_buf(mhdr_sg, mhdr_cnt, 0, &mhdr.num_buffers, sizeof mhdr.num_buffers); } vu_queue_flush(dev, vq, i); vu_queue_notify(dev, vq); free(elem); }
1threat
MySQL 8 create new user with password not working : <p>I am using MySQL for several years and the command for the creating the new user till the MySQL 5.x version is as follow:</p> <pre><code>GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password'; </code></pre> <p>Recently I installed the MySQL 8. In that, this command is not working.</p> <p>It is throwing following error while firing above command:</p> <pre><code>ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'password'' at line 1 </code></pre> <p>Is there any change of syntax in MySQL 8? What is the correct syntax for creating new user command in MySQL 8?</p> <p>Note: I tried this syntax in MySQL 5.x versions. It is working correctly in that.</p>
0debug
Building a iOS app with Fastlane inside Docker : <p>I'm trying to streamline my iOS development builds and read about Docker.</p> <p>If I understood it right, I could create an image that would include all the dependencies and my fellow devs could just pull it and build inside it.</p> <p>Point is now, does this also work with Fastlane (which uses the Xcode cli tools I think) and "Docker for Mac"?</p> <p>Also, I'm using React-Native, which seems to start a second process for bundling the JavaScript that will be included in the <em>native</em> build later and I read Docker only allows one process, is this a problem?</p>
0debug
Why when spinning object I need to set the speed value to 2000 to make it spin fast? : I want it to spin at speed from 0 to very fast. But if I'm changing the value of the spin to 10 it's almost not moving and 200 make it move slowly. 2000 make it move fast. But why only when changing to 2000 it's spinning fast ? public float rotationSpeed; private void Update() { scaling.objectToScale.transform.Rotate(Vector3.up, rotationSpeed * Time.deltaTime); }
0debug
Kotlin equivalent of Java's equalsIgnoreCase : <p>What is the equivalent of Java <code>equalsIgnoreCase</code> in Kotlin to compare <code>String</code> values?</p> <p>I have used <code>equals</code> but it's not case insensitive. </p>
0debug
PHP PDO Trouble with WHERE LIKE : I'm new to PHP and was wondering how I can execute a like query. Here is my Model //For search public function getSearchResults($username){ $stmt = $this->_connection->prepare("SELECT * FROM users WHERE username LIKE :username"); $stmt->execute(['username' => $username]); $stmt->setFetchMode(PDO::FETCH_CLASS, "User"); return $stmt->fetch(); } Then in my controller function search($name){ //Get search results $searchResults = $this->model('User'); $searchResults = $searchResults->getSearchResults($name); $data = (array) $searchResults; $this->view('User/search', $data); } However this isn't working, how can I use a like clause? **Edit Fixed It with the following** I added $stmt->execute(['username' => '%'.$username.'%']); instead of $stmt->execute(['username' => $username]);
0debug
How to install specific version of Kubernetes? : <p>I install the latest version of Kubernetes with the following command on Raspberry PI 3 running Raspbian Stretch.</p> <pre><code>$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - &amp;&amp; \ echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list &amp;&amp; \ sudo apt-get update -q &amp;&amp; \ sudo apt-get install -qy kubeadm </code></pre> <p>Currently this will install v1.10.0.</p> <p>How can I install a specific version of Kubernetes? Let's say v1.9.6.</p>
0debug
How to use the font-awesome library with ajax : I might be asking a dumb question, but I am a newbie in javascript and its libs. I came across the same problem as [this post][1], and in the accepted answer, there was this line <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> However, after adding this line I have a navbar icon even though I did not include a img in my html. I also cannot manipulate the position of this icon built with this stylesheet. Can anyone explain what it does in this context? (referring to the [post][1]) I noticed that without this line of code the CSS and Javascript cannot be applied to a simple `<img class="search" src="icon.png" width="30" height="30">` And how is it possible for me adjust the location of the icon with this line of code? [1]: https://stackoverflow.com/questions/46803710/how-to-make-a-drop-down-menu-from-an-icon-in-a-navbar
0debug
static void icp_pic_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { icp_pic_state *s = (icp_pic_state *)opaque; switch (offset >> 2) { case 2: s->irq_enabled |= value; break; case 3: s->irq_enabled &= ~value; break; case 4: if (value & 1) icp_pic_set_irq(s, 0, 1); break; case 5: if (value & 1) icp_pic_set_irq(s, 0, 0); break; case 10: s->fiq_enabled |= value; break; case 11: s->fiq_enabled &= ~value; break; case 0: case 1: case 8: case 9: default: printf ("icp_pic_write: Bad register offset 0x%x\n", (int)offset); return; } icp_pic_update(s); }
1threat
TypeError: Cannot match against 'undefined' or 'null' : <p><strong>Code</strong></p> <pre><code>client.createPet(pet, (err, {name, breed, age}) =&gt; { if (err) { return t.error(err, 'no error') } t.equal(pet, {name, breed, age}, 'should be equivalent') }) </code></pre> <p><strong>Error</strong></p> <pre><code>client.createPet(pet, (err, {name, breed, age}) =&gt; { ^ TypeError: Cannot match against 'undefined' or 'null'. </code></pre> <p>Why am I getting this error? My knowledge of ES6 led me to presume that this error should only arise if the <em>array or object being destructured or its children</em> is <code>undefined</code> or <code>null</code>.</p> <p>I wasn't aware that function parameters are used as a match. And if they are then why is it only an error if I try to destructure one of them? (that isn't <code>undefined</code> or <code>null</code>).</p>
0debug
int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun) { int64_t nb_sectors; uint32_t lba; uint32_t len; int cmdlen; int is_write; s->command = buf[0]; s->tag = tag; s->sector_count = 0; s->buf_pos = 0; s->buf_len = 0; is_write = 0; DPRINTF("Command: 0x%02x", buf[0]); switch (s->command >> 5) { case 0: lba = buf[3] | (buf[2] << 8) | ((buf[1] & 0x1f) << 16); len = buf[4]; cmdlen = 6; break; case 1: case 2: lba = buf[5] | (buf[4] << 8) | (buf[3] << 16) | (buf[2] << 24); len = buf[8] | (buf[7] << 8); cmdlen = 10; break; case 4: lba = buf[5] | (buf[4] << 8) | (buf[3] << 16) | (buf[2] << 24); len = buf[13] | (buf[12] << 8) | (buf[11] << 16) | (buf[10] << 24); cmdlen = 16; break; case 5: lba = buf[5] | (buf[4] << 8) | (buf[3] << 16) | (buf[2] << 24); len = buf[9] | (buf[8] << 8) | (buf[7] << 16) | (buf[6] << 24); cmdlen = 12; break; default: BADF("Unsupported command length, command %x\n", s->command); goto fail; } #ifdef DEBUG_SCSI { int i; for (i = 1; i < cmdlen; i++) { printf(" 0x%02x", buf[i]); } printf("\n"); } #endif if (lun || buf[1] >> 5) { DPRINTF("Unimplemented LUN %d\n", lun ? lun : buf[1] >> 5); goto fail; } switch (s->command) { case 0x0: DPRINTF("Test Unit Ready\n"); break; case 0x03: DPRINTF("Request Sense (len %d)\n", len); if (len < 4) goto fail; memset(buf, 0, 4); s->buf[0] = 0xf0; s->buf[1] = 0; s->buf[2] = s->sense; s->buf_len = 4; break; case 0x12: DPRINTF("Inquiry (len %d)\n", len); if (len < 36) { BADF("Inquiry buffer too small (%d)\n", len); } memset(s->buf, 0, 36); if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) { s->buf[0] = 5; s->buf[1] = 0x80; memcpy(&s->buf[16], "QEMU CD-ROM ", 16); } else { s->buf[0] = 0; memcpy(&s->buf[16], "QEMU HARDDISK ", 16); } memcpy(&s->buf[8], "QEMU ", 8); memcpy(&s->buf[32], QEMU_VERSION, 4); s->buf[2] = 3; s->buf[3] = 2; s->buf[4] = 32; s->buf_len = 36; break; case 0x16: DPRINTF("Reserve(6)\n"); if (buf[1] & 1) goto fail; break; case 0x17: DPRINTF("Release(6)\n"); if (buf[1] & 1) goto fail; break; case 0x1a: case 0x5a: { char *p; int page; page = buf[2] & 0x3f; DPRINTF("Mode Sense (page %d, len %d)\n", page, len); p = s->buf; memset(p, 0, 4); s->buf[1] = 0; s->buf[3] = 0; if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) { s->buf[2] = 0x80; } p += 4; if ((page == 8 || page == 0x3f)) { p[0] = 8; p[1] = 0x12; p[2] = 4; p += 19; } if ((page == 0x3f || page == 0x2a) && (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM)) { p[0] = 0x2a; p[1] = 0x14; p[2] = 3; p[3] = 0; p[4] = 0x7f; p[5] = 0xff; p[6] = 0x2d | (bdrv_is_locked(s->bdrv)? 2 : 0); p[7] = 0; p[8] = (50 * 176) >> 8; p[9] = (50 * 176) & 0xff; p[10] = 0 >> 8; p[11] = 0 & 0xff; p[12] = 2048 >> 8; p[13] = 2048 & 0xff; p[14] = (16 * 176) >> 8; p[15] = (16 * 176) & 0xff; p[18] = (16 * 176) >> 8; p[19] = (16 * 176) & 0xff; p[20] = (16 * 176) >> 8; current p[21] = (16 * 176) & 0xff; p += 21; } s->buf_len = p - s->buf; s->buf[0] = s->buf_len - 4; if (s->buf_len > len) s->buf_len = len; } break; case 0x1b: DPRINTF("Start Stop Unit\n"); break; case 0x1e: DPRINTF("Prevent Allow Medium Removal (prevent = %d)\n", buf[4] & 3); bdrv_set_locked(s->bdrv, buf[4] & 1); break; case 0x25: DPRINTF("Read Capacity\n"); memset(s->buf, 0, 8); bdrv_get_geometry(s->bdrv, &nb_sectors); s->buf[0] = (nb_sectors >> 24) & 0xff; s->buf[1] = (nb_sectors >> 16) & 0xff; s->buf[2] = (nb_sectors >> 8) & 0xff; s->buf[3] = nb_sectors & 0xff; s->buf[4] = 0; s->buf[5] = 0; s->buf[6] = s->cluster_size * 2; s->buf[7] = 0; s->buf_len = 8; break; case 0x08: case 0x28: DPRINTF("Read (sector %d, count %d)\n", lba, len); s->sector = lba * s->cluster_size; s->sector_count = len * s->cluster_size; break; case 0x0a: case 0x2a: DPRINTF("Write (sector %d, count %d)\n", lba, len); s->sector = lba * s->cluster_size; s->sector_count = len * s->cluster_size; is_write = 1; break; case 0x35: DPRINTF("Syncronise cache (sector %d, count %d)\n", lba, len); bdrv_flush(s->bdrv); break; case 0x43: { int start_track, format, msf, toclen; msf = buf[1] & 2; format = buf[2] & 0xf; start_track = buf[6]; bdrv_get_geometry(s->bdrv, &nb_sectors); DPRINTF("Read TOC (track %d format %d msf %d)\n", start_track, format, msf >> 1); switch(format) { case 0: toclen = cdrom_read_toc(nb_sectors, s->buf, msf, start_track); break; case 1: toclen = 12; memset(s->buf, 0, 12); s->buf[1] = 0x0a; s->buf[2] = 0x01; s->buf[3] = 0x01; break; case 2: toclen = cdrom_read_toc_raw(nb_sectors, s->buf, msf, start_track); break; default: goto error_cmd; } if (toclen > 0) { if (len > toclen) len = toclen; s->buf_len = len; break; } error_cmd: DPRINTF("Read TOC error\n"); goto fail; } case 0x46: DPRINTF("Get Configuration (rt %d, maxlen %d)\n", buf[1] & 3, len); memset(s->buf, 0, 8); s->buf[7] = 8; s->buf_len = 8; break; case 0x56: DPRINTF("Reserve(10)\n"); if (buf[1] & 3) goto fail; break; case 0x57: DPRINTF("Release(10)\n"); if (buf[1] & 3) goto fail; break; case 0xa0: DPRINTF("Report LUNs (len %d)\n", len); if (len < 16) goto fail; memset(s->buf, 0, 16); s->buf[3] = 8; s->buf_len = 16; break; default: DPRINTF("Unknown SCSI command (%2.2x)\n", buf[0]); fail: scsi_command_complete(s, SENSE_ILLEGAL_REQUEST); return 0; } if (s->sector_count == 0 && s->buf_len == 0) { scsi_command_complete(s, SENSE_NO_SENSE); } len = s->sector_count * 512 + s->buf_len; return is_write ? -len : len; }
1threat
Testing abstract classes with arguments on constructor : <p>I'm trying to learn about tests but I'm facing some problems whilst testing abstract classes. I know I could create a concrete subclass that inherit from Dog, like ConcreteDog, but if I add a new abstract method to Dog, I would have to add a empty method to ConcreteDog so. That would not be so cool I guess.</p> <pre><code>public abstract class Dog { private final int id; public Dog(int id) { this.id = id; } public int getId() { return id; } public abstract void makeSound(); } ... public class DogTest { @Test public void testGetId() { int id = 42; // How to pass id to Dog constructor ? Dog dog = Mockito.mock(Dog.class, Mockito.CALL_REAL_METHODS); assertTrue(dog.getId() == id); } } </code></pre> <p>What I'm trying to do is somehow call the Mock with the constructor, like</p> <pre><code>Mockito.mock(Dog(id).class, Mockito.CALL_REAL_METHODS); </code></pre> <p>I don't know if it's possible with mockito, but there is a way of doing that using mockito or another tool ?</p>
0debug
static void coroutine_fn mirror_iteration(MirrorBlockJob *s) { BlockDriverState *source = s->common.bs; int nb_sectors, sectors_per_chunk, nb_chunks; int64_t end, sector_num, next_chunk, next_sector, hbitmap_next_sector; MirrorOp *op; s->sector_num = hbitmap_iter_next(&s->hbi); if (s->sector_num < 0) { bdrv_dirty_iter_init(source, s->dirty_bitmap, &s->hbi); s->sector_num = hbitmap_iter_next(&s->hbi); trace_mirror_restart_iter(s, bdrv_get_dirty_count(source, s->dirty_bitmap)); assert(s->sector_num >= 0); } hbitmap_next_sector = s->sector_num; sector_num = s->sector_num; sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS; end = s->common.len >> BDRV_SECTOR_BITS; nb_chunks = 0; nb_sectors = 0; next_sector = sector_num; next_chunk = sector_num / sectors_per_chunk; while (test_bit(next_chunk, s->in_flight_bitmap)) { trace_mirror_yield_in_flight(s, sector_num, s->in_flight); qemu_coroutine_yield(); } do { int added_sectors, added_chunks; if (!bdrv_get_dirty(source, s->dirty_bitmap, next_sector) || test_bit(next_chunk, s->in_flight_bitmap)) { assert(nb_sectors > 0); break; } added_sectors = sectors_per_chunk; if (s->cow_bitmap && !test_bit(next_chunk, s->cow_bitmap)) { bdrv_round_to_clusters(s->target, next_sector, added_sectors, &next_sector, &added_sectors); if (next_sector < sector_num) { assert(nb_sectors == 0); sector_num = next_sector; next_chunk = next_sector / sectors_per_chunk; } } added_sectors = MIN(added_sectors, end - (sector_num + nb_sectors)); added_chunks = (added_sectors + sectors_per_chunk - 1) / sectors_per_chunk; while (nb_chunks == 0 && s->buf_free_count < added_chunks) { trace_mirror_yield_buf_busy(s, nb_chunks, s->in_flight); qemu_coroutine_yield(); } if (s->buf_free_count < nb_chunks + added_chunks) { trace_mirror_break_buf_busy(s, nb_chunks, s->in_flight); break; } bitmap_set(s->in_flight_bitmap, next_chunk, added_chunks); nb_sectors += added_sectors; nb_chunks += added_chunks; next_sector += added_sectors; next_chunk += added_chunks; } while (next_sector < end); op = g_slice_new(MirrorOp); op->s = s; op->sector_num = sector_num; op->nb_sectors = nb_sectors; qemu_iovec_init(&op->qiov, nb_chunks); next_sector = sector_num; while (nb_chunks-- > 0) { MirrorBuffer *buf = QSIMPLEQ_FIRST(&s->buf_free); QSIMPLEQ_REMOVE_HEAD(&s->buf_free, next); s->buf_free_count--; qemu_iovec_add(&op->qiov, buf, s->granularity); if (next_sector > hbitmap_next_sector && bdrv_get_dirty(source, s->dirty_bitmap, next_sector)) { hbitmap_next_sector = hbitmap_iter_next(&s->hbi); } next_sector += sectors_per_chunk; } bdrv_reset_dirty(source, sector_num, nb_sectors); s->in_flight++; trace_mirror_one_iteration(s, sector_num, nb_sectors); bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors, mirror_read_complete, op); }
1threat
defind degree of freedom in eBayes function : I want to define degree of freedom in eBayes function for microarray analysis how can i change default degree of freedom in that? . . . fit2 <- eBayes(fit2, 0.01) like this
0debug
Spark-Shell Startup Errors : <p>I am seeing errors when starting <code>spark-shell</code>, using <code>spark-1.6.0-bin-hadoop2.6</code>. This is new behavior that just arose.</p> <p>The upshot of the failures displayed in the log messages below, is that sqlContext is not available (but sc is).</p> <p>Is there some kind of Derby lock that could be released? <code>Another instance of Derby may have already booted the database /root/spark-1.6.0-bin-hadoop2.6/bin/metastore_db.</code></p> <pre><code>&lt;console&gt;:16: error: not found: value sqlContext import sqlContext.implicits._ ^ &lt;console&gt;:16: error: not found: value sqlContext import sqlContext.sql 16/05/25 11:00:00 ERROR Schema: Failed initialising database. Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@c2191a8, see the next exception for details. org.datanucleus.exceptions.NucleusDataStoreException: Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@c2191a8, see the next exception for details. 16/05/25 11:06:02 WARN Hive: Failed to access metastore. This class should not accessed in runtime. org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient 16/05/25 11:06:02 ERROR Schema: Failed initialising database. Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@372e972d, see the next exception for details. org.datanucleus.exceptions.NucleusDataStoreException: Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@372e972d, see the next exception for details. Caused by: java.sql.SQLException: Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@c2191a8, see the next exception for details. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source) ... 134 more Caused by: java.sql.SQLException: Another instance of Derby may have already booted the database /root/spark-1.6.0-bin-hadoop2.6/bin/metastore_db. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) ... 131 more Caused by: ERROR XSDB6: Another instance of Derby may have already booted the database /root/spark-1.6.0-bin-hadoop2.6/bin/metastore_db. </code></pre>
0debug
int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive) { int ret; struct flock fl = { .l_whence = SEEK_SET, .l_start = start, .l_len = len, .l_type = exclusive ? F_WRLCK : F_RDLCK, }; ret = fcntl(fd, QEMU_GETLK, &fl); if (ret == -1) { return -errno; } else { return fl.l_type == F_UNLCK ? 0 : -EAGAIN; } }
1threat
static int v9fs_do_mkdir(V9fsState *s, V9fsString *path, mode_t mode) { return s->ops->mkdir(&s->ctx, path->data, mode); }
1threat
How do I have an array that has a set of coordinates in c++? : <p>I'm trying to record the coordinates in an array. So I want to record something like {{0,0},{0,1},{1,1}}. I thought about separating both integers by a space, and have the entire thing as a string, so (15 5) would be different than (1 55). I assume it's not very efficient, and using string arrays are very difficult.</p> <p>Here's the (bad) code I have so far:</p> <pre><code>#include &lt;string&gt; #include &lt;iostream&gt; using namespace std; int main(int argc, const char * argv[]) { bool going=true; int x=0; int y=0; string coordinates[] = {}; while (going==true){ to_string(y)+","+to_string(x) &gt;&gt; coordinates; x++; } return 0; } </code></pre> <p>What do I use?</p>
0debug
React testing library: Test styles (specifically background image) : <p>I'm building a React app with TypeScript. I do my component tests with react-testing-library.</p> <p>I'm buildilng a <a href="https://materializecss.com/parallax.html" rel="noreferrer">parallax</a> component for my landing page.</p> <p>The component is passed the image via props and sets it via JSS as a background image:</p> <pre><code>&lt;div className={parallaxClasses} style={{ backgroundImage: "url(" + image + ")", ...this.state }} &gt; {children} &lt;/div&gt; </code></pre> <p>Here is the unit test that I wrote:</p> <pre><code>import React from "react"; import { cleanup, render } from "react-testing-library"; import Parallax, { OwnProps } from "./Parallax"; afterEach(cleanup); const createTestProps = (props?: object): OwnProps =&gt; ({ children: null, filter: "primary", image: require("../../assets/images/bridge.jpg"), ...props }); describe("Parallax", () =&gt; { const props = createTestProps(); const { getByText } = render(&lt;Parallax {...props} /&gt;); describe("rendering", () =&gt; { test("it renders the image", () =&gt; { expect(getByText(props.image)).toBeDefined(); }); }); }); </code></pre> <p>But it fails saying:</p> <pre><code>● Parallax › rendering › it renders the image Unable to find an element with the text: bridge.jpg. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. &lt;body&gt; &lt;div&gt; &lt;div class="Parallax-parallax-3 Parallax-primaryColor-4" style="background-image: url(bridge.jpg); transform: translate3d(0,0px,0);" /&gt; &lt;/div&gt; &lt;/body&gt; 16 | describe("rendering", () =&gt; { 17 | test("it renders the image", () =&gt; { &gt; 18 | expect(getByText(props.image)).toBeDefined(); | ^ 19 | }); 20 | }); 21 | }); at getElementError (node_modules/dom-testing-library/dist/query-helpers.js:30:10) at getAllByText (node_modules/dom-testing-library/dist/queries.js:336:45) at firstResultOrNull (node_modules/dom-testing-library/dist/query-helpers.js:38:30) at getByText (node_modules/dom-testing-library/dist/queries.js:346:42) at Object.getByText (src/components/Parallax/Parallax.test.tsx:18:14) </code></pre> <p>How can I test that the image is being set as a background image correctly with Jest and react-testing-library?</p>
0debug
Overloading Operator [][] c++ : <p>Let there be a class :</p> <pre><code>template &lt;class A_Type,int sizeA,int sizeB&gt; class Matrix { A_Type myMatrix[sizeA][sizeB]; int sizeA_Val; int sizeB_Val; public: Matrix(); Matrix(A_Type val); int getSizeA()const{return sizeA_Val;} ; int getSizeB()const{return sizeB_Val;}; A_Type mini() const; double avg() const; Matrix operator+(const Matrix&amp; b) { Matrix&lt;A_Type,sizeA,sizeB&gt; tmpNew; for (int i=0;i&lt;sizeA;i++){ for (intj=0;j&lt;sizeB;j++){ tmpNew[i][j]=myMatrix[i][j]+b[i][j]; } } return box; } }; </code></pre> <p>it is working exept to the <code>Matrix operator+(const Matrix&amp; b)</code> function</p> <p>i want it to work co i want to create operator [][], is it possible?</p> <p>i want for example if i see mat[i][j] it will return the value in the mat->myMatrix[i][j]</p> <p>is it possible?</p>
0debug
static int kvm_get_msrs(X86CPU *cpu) { CPUX86State *env = &cpu->env; struct kvm_msr_entry *msrs = cpu->kvm_msr_buf->entries; int ret, i; uint64_t mtrr_top_bits; kvm_msr_buf_reset(cpu); kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_CS, 0); kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_ESP, 0); kvm_msr_entry_add(cpu, MSR_IA32_SYSENTER_EIP, 0); kvm_msr_entry_add(cpu, MSR_PAT, 0); if (has_msr_star) { kvm_msr_entry_add(cpu, MSR_STAR, 0); } if (has_msr_hsave_pa) { kvm_msr_entry_add(cpu, MSR_VM_HSAVE_PA, 0); } if (has_msr_tsc_aux) { kvm_msr_entry_add(cpu, MSR_TSC_AUX, 0); } if (has_msr_tsc_adjust) { kvm_msr_entry_add(cpu, MSR_TSC_ADJUST, 0); } if (has_msr_tsc_deadline) { kvm_msr_entry_add(cpu, MSR_IA32_TSCDEADLINE, 0); } if (has_msr_misc_enable) { kvm_msr_entry_add(cpu, MSR_IA32_MISC_ENABLE, 0); } if (has_msr_smbase) { kvm_msr_entry_add(cpu, MSR_IA32_SMBASE, 0); } if (has_msr_feature_control) { kvm_msr_entry_add(cpu, MSR_IA32_FEATURE_CONTROL, 0); } if (has_msr_bndcfgs) { kvm_msr_entry_add(cpu, MSR_IA32_BNDCFGS, 0); } if (has_msr_xss) { kvm_msr_entry_add(cpu, MSR_IA32_XSS, 0); } if (!env->tsc_valid) { kvm_msr_entry_add(cpu, MSR_IA32_TSC, 0); env->tsc_valid = !runstate_is_running(); } #ifdef TARGET_X86_64 if (lm_capable_kernel) { kvm_msr_entry_add(cpu, MSR_CSTAR, 0); kvm_msr_entry_add(cpu, MSR_KERNELGSBASE, 0); kvm_msr_entry_add(cpu, MSR_FMASK, 0); kvm_msr_entry_add(cpu, MSR_LSTAR, 0); } #endif kvm_msr_entry_add(cpu, MSR_KVM_SYSTEM_TIME, 0); kvm_msr_entry_add(cpu, MSR_KVM_WALL_CLOCK, 0); if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF)) { kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_EN, 0); } if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_PV_EOI)) { kvm_msr_entry_add(cpu, MSR_KVM_PV_EOI_EN, 0); } if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_STEAL_TIME)) { kvm_msr_entry_add(cpu, MSR_KVM_STEAL_TIME, 0); } if (has_msr_architectural_pmu) { kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL, 0); kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, 0); kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_STATUS, 0); kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_OVF_CTRL, 0); for (i = 0; i < MAX_FIXED_COUNTERS; i++) { kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR0 + i, 0); } for (i = 0; i < num_architectural_pmu_counters; i++) { kvm_msr_entry_add(cpu, MSR_P6_PERFCTR0 + i, 0); kvm_msr_entry_add(cpu, MSR_P6_EVNTSEL0 + i, 0); } } if (env->mcg_cap) { kvm_msr_entry_add(cpu, MSR_MCG_STATUS, 0); kvm_msr_entry_add(cpu, MSR_MCG_CTL, 0); if (has_msr_mcg_ext_ctl) { kvm_msr_entry_add(cpu, MSR_MCG_EXT_CTL, 0); } for (i = 0; i < (env->mcg_cap & 0xff) * 4; i++) { kvm_msr_entry_add(cpu, MSR_MC0_CTL + i, 0); } } if (has_msr_hv_hypercall) { kvm_msr_entry_add(cpu, HV_X64_MSR_HYPERCALL, 0); kvm_msr_entry_add(cpu, HV_X64_MSR_GUEST_OS_ID, 0); } if (cpu->hyperv_vapic) { kvm_msr_entry_add(cpu, HV_X64_MSR_APIC_ASSIST_PAGE, 0); } if (cpu->hyperv_time) { kvm_msr_entry_add(cpu, HV_X64_MSR_REFERENCE_TSC, 0); } if (has_msr_hv_crash) { int j; for (j = 0; j < HV_CRASH_PARAMS; j++) { kvm_msr_entry_add(cpu, HV_X64_MSR_CRASH_P0 + j, 0); } } if (has_msr_hv_runtime) { kvm_msr_entry_add(cpu, HV_X64_MSR_VP_RUNTIME, 0); } if (cpu->hyperv_synic) { uint32_t msr; kvm_msr_entry_add(cpu, HV_X64_MSR_SCONTROL, 0); kvm_msr_entry_add(cpu, HV_X64_MSR_SIEFP, 0); kvm_msr_entry_add(cpu, HV_X64_MSR_SIMP, 0); for (msr = HV_X64_MSR_SINT0; msr <= HV_X64_MSR_SINT15; msr++) { kvm_msr_entry_add(cpu, msr, 0); } } if (has_msr_hv_stimer) { uint32_t msr; for (msr = HV_X64_MSR_STIMER0_CONFIG; msr <= HV_X64_MSR_STIMER3_COUNT; msr++) { kvm_msr_entry_add(cpu, msr, 0); } } if (env->features[FEAT_1_EDX] & CPUID_MTRR) { kvm_msr_entry_add(cpu, MSR_MTRRdefType, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix64K_00000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix16K_80000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix16K_A0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_C0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_C8000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_D0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_D8000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_E0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_E8000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_F0000, 0); kvm_msr_entry_add(cpu, MSR_MTRRfix4K_F8000, 0); for (i = 0; i < MSR_MTRRcap_VCNT; i++) { kvm_msr_entry_add(cpu, MSR_MTRRphysBase(i), 0); kvm_msr_entry_add(cpu, MSR_MTRRphysMask(i), 0); } } ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, cpu->kvm_msr_buf); if (ret < 0) { return ret; } if (ret < cpu->kvm_msr_buf->nmsrs) { struct kvm_msr_entry *e = &cpu->kvm_msr_buf->entries[ret]; error_report("error: failed to get MSR 0x%" PRIx32, (uint32_t)e->index); } assert(ret == cpu->kvm_msr_buf->nmsrs); if (cpu->fill_mtrr_mask) { QEMU_BUILD_BUG_ON(TARGET_PHYS_ADDR_SPACE_BITS > 52); assert(cpu->phys_bits <= TARGET_PHYS_ADDR_SPACE_BITS); mtrr_top_bits = MAKE_64BIT_MASK(cpu->phys_bits, 52 - cpu->phys_bits); } else { mtrr_top_bits = 0; } for (i = 0; i < ret; i++) { uint32_t index = msrs[i].index; switch (index) { case MSR_IA32_SYSENTER_CS: env->sysenter_cs = msrs[i].data; break; case MSR_IA32_SYSENTER_ESP: env->sysenter_esp = msrs[i].data; break; case MSR_IA32_SYSENTER_EIP: env->sysenter_eip = msrs[i].data; break; case MSR_PAT: env->pat = msrs[i].data; break; case MSR_STAR: env->star = msrs[i].data; break; #ifdef TARGET_X86_64 case MSR_CSTAR: env->cstar = msrs[i].data; break; case MSR_KERNELGSBASE: env->kernelgsbase = msrs[i].data; break; case MSR_FMASK: env->fmask = msrs[i].data; break; case MSR_LSTAR: env->lstar = msrs[i].data; break; #endif case MSR_IA32_TSC: env->tsc = msrs[i].data; break; case MSR_TSC_AUX: env->tsc_aux = msrs[i].data; break; case MSR_TSC_ADJUST: env->tsc_adjust = msrs[i].data; break; case MSR_IA32_TSCDEADLINE: env->tsc_deadline = msrs[i].data; break; case MSR_VM_HSAVE_PA: env->vm_hsave = msrs[i].data; break; case MSR_KVM_SYSTEM_TIME: env->system_time_msr = msrs[i].data; break; case MSR_KVM_WALL_CLOCK: env->wall_clock_msr = msrs[i].data; break; case MSR_MCG_STATUS: env->mcg_status = msrs[i].data; break; case MSR_MCG_CTL: env->mcg_ctl = msrs[i].data; break; case MSR_MCG_EXT_CTL: env->mcg_ext_ctl = msrs[i].data; break; case MSR_IA32_MISC_ENABLE: env->msr_ia32_misc_enable = msrs[i].data; break; case MSR_IA32_SMBASE: env->smbase = msrs[i].data; break; case MSR_IA32_FEATURE_CONTROL: env->msr_ia32_feature_control = msrs[i].data; break; case MSR_IA32_BNDCFGS: env->msr_bndcfgs = msrs[i].data; break; case MSR_IA32_XSS: env->xss = msrs[i].data; break; default: if (msrs[i].index >= MSR_MC0_CTL && msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) { env->mce_banks[msrs[i].index - MSR_MC0_CTL] = msrs[i].data; } break; case MSR_KVM_ASYNC_PF_EN: env->async_pf_en_msr = msrs[i].data; break; case MSR_KVM_PV_EOI_EN: env->pv_eoi_en_msr = msrs[i].data; break; case MSR_KVM_STEAL_TIME: env->steal_time_msr = msrs[i].data; break; case MSR_CORE_PERF_FIXED_CTR_CTRL: env->msr_fixed_ctr_ctrl = msrs[i].data; break; case MSR_CORE_PERF_GLOBAL_CTRL: env->msr_global_ctrl = msrs[i].data; break; case MSR_CORE_PERF_GLOBAL_STATUS: env->msr_global_status = msrs[i].data; break; case MSR_CORE_PERF_GLOBAL_OVF_CTRL: env->msr_global_ovf_ctrl = msrs[i].data; break; case MSR_CORE_PERF_FIXED_CTR0 ... MSR_CORE_PERF_FIXED_CTR0 + MAX_FIXED_COUNTERS - 1: env->msr_fixed_counters[index - MSR_CORE_PERF_FIXED_CTR0] = msrs[i].data; break; case MSR_P6_PERFCTR0 ... MSR_P6_PERFCTR0 + MAX_GP_COUNTERS - 1: env->msr_gp_counters[index - MSR_P6_PERFCTR0] = msrs[i].data; break; case MSR_P6_EVNTSEL0 ... MSR_P6_EVNTSEL0 + MAX_GP_COUNTERS - 1: env->msr_gp_evtsel[index - MSR_P6_EVNTSEL0] = msrs[i].data; break; case HV_X64_MSR_HYPERCALL: env->msr_hv_hypercall = msrs[i].data; break; case HV_X64_MSR_GUEST_OS_ID: env->msr_hv_guest_os_id = msrs[i].data; break; case HV_X64_MSR_APIC_ASSIST_PAGE: env->msr_hv_vapic = msrs[i].data; break; case HV_X64_MSR_REFERENCE_TSC: env->msr_hv_tsc = msrs[i].data; break; case HV_X64_MSR_CRASH_P0 ... HV_X64_MSR_CRASH_P4: env->msr_hv_crash_params[index - HV_X64_MSR_CRASH_P0] = msrs[i].data; break; case HV_X64_MSR_VP_RUNTIME: env->msr_hv_runtime = msrs[i].data; break; case HV_X64_MSR_SCONTROL: env->msr_hv_synic_control = msrs[i].data; break; case HV_X64_MSR_SIEFP: env->msr_hv_synic_evt_page = msrs[i].data; break; case HV_X64_MSR_SIMP: env->msr_hv_synic_msg_page = msrs[i].data; break; case HV_X64_MSR_SINT0 ... HV_X64_MSR_SINT15: env->msr_hv_synic_sint[index - HV_X64_MSR_SINT0] = msrs[i].data; break; case HV_X64_MSR_STIMER0_CONFIG: case HV_X64_MSR_STIMER1_CONFIG: case HV_X64_MSR_STIMER2_CONFIG: case HV_X64_MSR_STIMER3_CONFIG: env->msr_hv_stimer_config[(index - HV_X64_MSR_STIMER0_CONFIG)/2] = msrs[i].data; break; case HV_X64_MSR_STIMER0_COUNT: case HV_X64_MSR_STIMER1_COUNT: case HV_X64_MSR_STIMER2_COUNT: case HV_X64_MSR_STIMER3_COUNT: env->msr_hv_stimer_count[(index - HV_X64_MSR_STIMER0_COUNT)/2] = msrs[i].data; break; case MSR_MTRRdefType: env->mtrr_deftype = msrs[i].data; break; case MSR_MTRRfix64K_00000: env->mtrr_fixed[0] = msrs[i].data; break; case MSR_MTRRfix16K_80000: env->mtrr_fixed[1] = msrs[i].data; break; case MSR_MTRRfix16K_A0000: env->mtrr_fixed[2] = msrs[i].data; break; case MSR_MTRRfix4K_C0000: env->mtrr_fixed[3] = msrs[i].data; break; case MSR_MTRRfix4K_C8000: env->mtrr_fixed[4] = msrs[i].data; break; case MSR_MTRRfix4K_D0000: env->mtrr_fixed[5] = msrs[i].data; break; case MSR_MTRRfix4K_D8000: env->mtrr_fixed[6] = msrs[i].data; break; case MSR_MTRRfix4K_E0000: env->mtrr_fixed[7] = msrs[i].data; break; case MSR_MTRRfix4K_E8000: env->mtrr_fixed[8] = msrs[i].data; break; case MSR_MTRRfix4K_F0000: env->mtrr_fixed[9] = msrs[i].data; break; case MSR_MTRRfix4K_F8000: env->mtrr_fixed[10] = msrs[i].data; break; case MSR_MTRRphysBase(0) ... MSR_MTRRphysMask(MSR_MTRRcap_VCNT - 1): if (index & 1) { env->mtrr_var[MSR_MTRRphysIndex(index)].mask = msrs[i].data | mtrr_top_bits; } else { env->mtrr_var[MSR_MTRRphysIndex(index)].base = msrs[i].data; } break; } } return 0; }
1threat
Parse Javascript fetch in PHP : <p>I'm calling a post request through Javascript and here's how it looks,</p> <pre><code>function syncDeviceId(deviceID, mod){ var request = new Request('url', { method: 'POST', body: JSON.stringify({ uuid: unique_id, }), mode: 'cors' }) fetch(request).then(function(data) { return }) </code></pre> <p>And I'm trying to retreive the values like this,</p> <pre><code>&lt;?php $post['uuid'] = $_POST['uuid']; ?&gt; </code></pre> <p>This is returned as empty, how can I retrieve the values from the fetch post request in PHP. Thanks</p>
0debug
int ff_mlz_decompression(MLZ* mlz, GetBitContext* gb, int size, unsigned char *buff) { MLZDict *dict = mlz->dict; unsigned long output_chars; int string_code, last_string_code, char_code; string_code = 0; char_code = -1; last_string_code = -1; output_chars = 0; while (output_chars < size) { string_code = input_code(gb, mlz->dic_code_bit); switch (string_code) { case FLUSH_CODE: case MAX_CODE: ff_mlz_flush_dict(mlz); char_code = -1; last_string_code = -1; break; case FREEZE_CODE: mlz->freeze_flag = 1; break; default: if (string_code > mlz->current_dic_index_max) { av_log(mlz->context, AV_LOG_ERROR, "String code %d exceeds maximum value of %d.\n", string_code, mlz->current_dic_index_max); if (string_code == (int) mlz->bump_code) { ++mlz->dic_code_bit; mlz->current_dic_index_max *= 2; mlz->bump_code = mlz->current_dic_index_max - 1; } else { if (string_code >= mlz->next_code) { int ret = decode_string(mlz, &buff[output_chars], last_string_code, &char_code, size - output_chars); if (ret < 0 || ret > size - output_chars) { av_log(mlz->context, AV_LOG_ERROR, "output chars overflow\n"); output_chars += ret; ret = decode_string(mlz, &buff[output_chars], char_code, &char_code, size - output_chars); if (ret < 0 || ret > size - output_chars) { av_log(mlz->context, AV_LOG_ERROR, "output chars overflow\n"); output_chars += ret; set_new_entry_dict(dict, mlz->next_code, last_string_code, char_code); mlz->next_code++; } else { int ret = decode_string(mlz, &buff[output_chars], string_code, &char_code, size - output_chars); if (ret < 0 || ret > size - output_chars) { av_log(mlz->context, AV_LOG_ERROR, "output chars overflow\n"); output_chars += ret; if (output_chars <= size && !mlz->freeze_flag) { if (last_string_code != -1) { set_new_entry_dict(dict, mlz->next_code, last_string_code, char_code); mlz->next_code++; } else { break; last_string_code = string_code; break;
1threat
Selectively inheriting from any of multiple classes at runtime : <p>I'm doing scientific computing and I'm beginner in c++. <code>MyNLP</code> is a class which contain all the problem data and methods. I'm using third party libraries for numerical optimization. Each third party is a specific algorithm to solve my problem. In order to use each library, my <code>MyNLP</code> class need to inherit corresponding class from third party library.</p> <p>For example,</p> <pre><code>Class MyNLP :public IPOPT { }; </code></pre> <p>enable me to use IPOPT algorithm to solve my problem. Similarly, </p> <pre><code>class MyNLP: public SQP { }; </code></pre> <p>enable me to use SQP algorithm.</p> <p>But in my case, only at the run-time, program decides which class it should inherit. I have to inherit either one of third party class. Could any one give a technique to achieve this in cpp? </p>
0debug
How to perform PyCUDA 3x3 matrix inversion with same accuracy than numpy linalg "inv" or "pinv" function : I am facing an issue of accuracy about my code which performs **a high number (128, 256, 512) of 3x3 matrix inversion**. When I use the original version, i.e the numpy classical function `np.linalg.inv` or `np.linakg.pinv`, everything works fine. Unfortunately, with the CUDA code below, I get `nan` and `inf` values into inverted matrix. For example, if I use classical numpy "`inv`", I get for the first iteration the inverted 3x3 matrix : 4.715266047722758306e-10 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 2.811147187396482366e-28 -2.811147186834252285e-48 -5.622294374792964645e-38 0.000000000000000000e+00 -2.811147186834252285e-48 2.811147187396482366e-28 -5.622294374230735768e-48 0.000000000000000000e+00 -5.622294374792964645e-38 -5.622294374230735768e-48 5.622294374792964732e-28 To check the validity of this inverse matrix, I have multiplied it by original matrix and the result is the identity matrix. But with CUDA GPU inversion, I get after this same iteration : 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 -inf -inf -9.373764907941219970e-01 -inf inf nan -inf nan So, I woul like to increase the precision into my CUDA kernel or python code to avoid these `nan`and `inf` values. Here is the CUDA kernel code and calling part of my main code (I have commented the classical method with numpy `inv` function : # Create arrayFullCross_vec array arrayFullCross_vec = np.zeros((dimBlocks,dimBlocks,integ_prec,integ_prec)) # Create arrayFullCross_vec array invCrossMatrix_gpu = np.zeros((dimBlocks*dimBlocks*integ_prec**2)) # Create arrayFullCross_vec array invCrossMatrix = np.zeros((dimBlocks,dimBlocks,integ_prec,integ_prec)) # Build observables covariance matrix #arrayFullCross_vec = buildObsCovarianceMatrix3_vec(k_ref, mu_ref, ir) arrayFullCross_vec = buildObsCovarianceMatrix4_vec(k_ref, mu_ref, ir) """ # Compute integrand from covariance matrix for r_p in range(integ_prec): for s_p in range(integ_prec): # original version (without GPU) invCrossMatrix[:,:,r_p,s_p] = np.linalg.inv(arrayFullCross_vec[:,:,r_p,s_p]) """ # GPU version invCrossMatrix_gpu = gpuinv4x4(arrayFullCross_vec.flatten(),integ_prec**2) invCrossMatrix = invCrossMatrix_gpu.reshape(dimBlocks,dimBlocks,integ_prec,integ_prec) """ and here the CUDA kernel code and `gpuinv4x4` function : kernel = SourceModule(""" __device__ unsigned getoff(unsigned &off){ unsigned ret = off & 0x0F; off = off >> 4; return ret; } const int block_size = 256; const unsigned tmsk = 0xFFFFFFFF; // in-place is acceptable i.e. out == in) // T = double or double only typedef double T; __global__ void inv4x4(const T * __restrict__ in, T * __restrict__ out, const size_t n, const unsigned * __restrict__ pat){ __shared__ T si[block_size]; size_t idx = threadIdx.x+blockDim.x*blockIdx.x; if (idx < n*16){ si[threadIdx.x] = in[idx]; unsigned lane = threadIdx.x & 15; unsigned sibase = threadIdx.x & 0x03F0; __syncwarp(); unsigned off = pat[lane]; T a,b; a = si[sibase + getoff(off)]; a *= si[sibase + getoff(off)]; a *= si[sibase + getoff(off)]; if (!getoff(off)) a = -a; b = si[sibase + getoff(off)]; b *= si[sibase + getoff(off)]; b *= si[sibase + getoff(off)]; if (getoff(off)) a += b; else a -=b; off = pat[lane+16]; b = si[sibase + getoff(off)]; b *= si[sibase + getoff(off)]; b *= si[sibase + getoff(off)]; if (getoff(off)) a += b; else a -=b; b = si[sibase + getoff(off)]; b *= si[sibase + getoff(off)]; b *= si[sibase + getoff(off)]; if (getoff(off)) a += b; else a -=b; off = pat[lane+32]; b = si[sibase + getoff(off)]; b *= si[sibase + getoff(off)]; b *= si[sibase + getoff(off)]; if (getoff(off)) a += b; else a -=b; b = si[sibase + getoff(off)]; b *= si[sibase + getoff(off)]; b *= si[sibase + getoff(off)]; if (getoff(off)) a += b; else a -=b; T det = si[sibase + (lane>>2)]*a; det += __shfl_down_sync(tmsk, det, 4, 16); // first add det += __shfl_down_sync(tmsk, det, 8, 16); // second add det = __shfl_sync(tmsk, det, 0, 16); // broadcast out[idx] = a / det; } } """) # python function for inverting 4x4 matrices # n should be an even number def gpuinv4x4(inp, n): # internal constants not to be modified hpat = ( 0x0EB51FA5, 0x1EB10FA1, 0x0E711F61, 0x1A710B61, 0x1EB40FA4, 0x0EB01FA0, 0x1E700F60, 0x0A701B60, 0x0DB41F94, 0x1DB00F90, 0x0D701F50, 0x19700B50, 0x1DA40E94, 0x0DA01E90, 0x1D600E50, 0x09601A50, 0x1E790F69, 0x0E391F29, 0x1E350F25, 0x0A351B25, 0x0E781F68, 0x1E380F28, 0x0E341F24, 0x1A340B24, 0x1D780F58, 0x0D381F18, 0x1D340F14, 0x09341B14, 0x0D681E58, 0x1D280E18, 0x0D241E14, 0x19240A14, 0x0A7D1B6D, 0x1A3D0B2D, 0x063D172D, 0x16390729, 0x1A7C0B6C, 0x0A3C1B2C, 0x163C072C, 0x06381728, 0x097C1B5C, 0x193C0B1C, 0x053C171C, 0x15380718, 0x196C0A5C, 0x092C1A1C, 0x152C061C, 0x05281618) # Convert parameters into numpy array # float32 """ inpd = np.array(inp, dtype=np.float32) hpatd = np.array(hpat, dtype=np.uint32) output = np.empty((n*16), dtype= np.float32) """ # float64 """ inpd = np.array(inp, dtype=np.float64) hpatd = np.array(hpat, dtype=np.uint32) output = np.empty((n*16), dtype= np.float64) """ # float128 inpd = np.array(inp, dtype=np.float128) hpatd = np.array(hpat, dtype=np.uint32) output = np.empty((n*16), dtype= np.float128) # Get kernel function matinv4x4 = kernel.get_function("inv4x4") # Define block, grid and compute blockDim = (256,1,1) # do not change gridDim = ((n/16)+1,1,1) # Kernel function matinv4x4 ( cuda.In(inpd), cuda.Out(output), np.uint64(n), cuda.In(hpatd), block=blockDim, grid=gridDim) return output As you can see, I tried to increase accuracy of inverting operation by replacing `np.float32` by `np.float64` or `np.float128` but problem remains. I have also replaced `typedef float T;` by `typedef double T;`but without success. Anyone could help me to perform the right inversion of these matrices and mostly avoid the 'nan' and 'inf' values ? I think this is a real issue of precision but I can't find how to circumvent this problem. Regards
0debug
removing a "," from the end of a string : i have a string array that has "lastname," in the first cell i want to remove the " , " please help. ** I don't want help with the rest just how to pull the coma's out of the last names. this is the input given 1 T T T T T F T T F F Bobb, Bill 123456789 T T T T T F T T F F Lou, Mary 974387643 F T T T T F T T F F Bobb, Sam 213458679 F T F T f t 6 T F f Bobb, Joe 315274986 t t t t t f t t f f ZZZZ this is the output wanted Results for quiz 1: 123-45-6789 Bill Bobb 10 974-38-7643 Mary Lou 9 213-45-8679 Sam Bobb 5 315-27-4986 Joe Bobb 10 The average score is 8.5 this is what i have while(!input.equalsIgnoreCase("zzzz")) //while the input is not "zzzz" loop will run { String [] key = input.split ("\\s+"); //takes String input and converts it to an array seperated by " " input = br.readLine (); while(!input.equalsIgnoreCase("zzzz")) { String [] student = input.split ("\\s+");//takes in student information seperated by " " String lname = student[0].substring(0); String id = student[2].substring(0,3) + "-" + student[2].substring(3,5)+"-"+ student[2].substring(5);//inserts "-" into id# System.out.println (id); System.out.println (lname.trim("\,")); input = br.readLine (); } } System.out.println ("thank you, you suck"); } }
0debug
Trying to divide a tow numbers keep getting Dividebyzero error : Ok so here is my problem, i have this code [please open picture][1] ok so here is my problem. I have a hotel that can only accept 6 adults per room. the adults are (inTotal) and now i am trying to divide the number of rooms by how many adults i have to get a ratio, then if the ratio is bigger than 1/6 i am trying to show that message box demanding they enter an amount where no more than six people can be in one room, but keep getting the dividebyzeroexception error. Anyother ways of having such ratio or how do i solve this please [1]: https://i.stack.imgur.com/9GFjJ.png
0debug
How to add new DAGs to Airflow? : <p>I have defined a DAG in a file called <code>tutorial_2.py</code> (actually a copy of the <code>tutorial.py</code> provided in the <code>airflow</code> tutorial, except with the <code>dag_id</code> changed to <code>tutorial_2</code>).</p> <p>When I look inside my default, unmodified <code>airflow.cfg</code> (located in <code>~/airflow</code>), I see that <code>dags_folder</code> is set to <code>/home/alex/airflow/dags</code>. </p> <p>I do <code>cd /home/alex/airflow; mkdir dags; cd dags; cp [...]/tutorial_2.py tutorial_2.py</code>. Now I have a <code>dags</code> folder matching the path set in <code>airflow.cfg</code> , containing the <code>tutorial_2.py</code> file I created earlier.</p> <p>However, when I run <code>airflow list_dags</code>, I only get the names corresponding with the default, tutorial DAGs.</p> <p>I would like to have <code>tutorial_2</code> show up in my DAG list, so that I can begin interacting with. Neither <code>python tutorial_2.py</code> nor <code>airflow resetdb</code> have caused it to appear in the list.</p> <p>How do I remedy this?</p>
0debug
how can i fix string matrix index problem? : I'm trying to store name and address of persons in the form of 2d array, but when i run my it accepts less values only . For example if i give the array 2 rows and 2 columns , it accepts only 3 values. I've tried searching on other forums , couldn't get the proper answer. I also changed the dimension values but it gives wrong result only. ```import java.util.*; ```class findme{ ```public static void main(String args[]){ ```Scanner scan=new Scanner(System.in); ```System.out.print("enter the number of person: "); ```int per=scan.nextInt(); ```System.out.print("enter the number of address: "); ```int addr=scan.nextInt(); ```String addrs[][]=new String[per][addr]; ```for(int i=0;i<per;i++){ ```for(int j=0;j<addr;j++){ ```addrs[i][j]=scan.nextLine(); ```} ```} ```} ```}
0debug
Calling non static method in static method : <p>I am having a little issue with my code. I am trying to find the runtime to compare to some math that I have prepared for the problem. I have one method in particular that I am testing that goes like this:</p> <pre><code> public static int foo(int n, int k){ long startTime = System.nanoTime(); if(n&lt;=k){ long endTime = System.nanoTime(); System.out.println("checkFoo"); System.out.println("start time: " +startTime); System.out.println("end time: " +endTime); return 1; } else{ return foo(n/k,k) + 1; } } </code></pre> <p>I test this code in my main method in the following way: </p> <pre><code>public static void main(String[] args){ foo(1, 1); foo(5, 1); foo(10, 1); foo(100, 1); } </code></pre> <p>I get an error where it says </p> <pre><code>Exception in thread "main" java.lang.StackOverflowError </code></pre> <p>and then it repeats the line:</p> <pre><code>at Problem3.foo(Problem3.java:42) </code></pre> <p>I am wondering if this has to do with the fact that foo is supposed to return an int and maybe I am just not calling the function correctly. If that is the case, what is considered the correct way to call this function so that it also prints out the information that I need it to? Or is this error completely different than how I am understanding it to be?</p>
0debug
static int get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, MapEntry *e) { int64_t ret; int depth; depth = 0; for (;;) { ret = bdrv_get_block_status(bs, sector_num, nb_sectors, &nb_sectors); if (ret < 0) { return ret; } assert(nb_sectors); if (ret & (BDRV_BLOCK_ZERO|BDRV_BLOCK_DATA)) { break; } bs = backing_bs(bs); if (bs == NULL) { ret = 0; break; } depth++; } e->start = sector_num * BDRV_SECTOR_SIZE; e->length = nb_sectors * BDRV_SECTOR_SIZE; e->flags = ret & ~BDRV_BLOCK_OFFSET_MASK; e->offset = ret & BDRV_BLOCK_OFFSET_MASK; e->depth = depth; e->bs = bs; return 0; }
1threat
How can I search for specific file contents in all files in both current folder and all subfolders : <p>Using Mac terminal server linux/bash commands, how can I search for a particular text string in all *.txt files in the current folder plus all files in the subfolders inside the current folder? </p>
0debug
static void spapr_cpu_reset(void *opaque) { PowerPCCPU *cpu = opaque; CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; cpu_reset(cs); cs->halted = 1; env->spr[SPR_HIOR] = 0; env->external_htab = (uint8_t *)spapr->htab; if (kvm_enabled() && !env->external_htab) { env->external_htab = (void *)1; } env->htab_base = -1; env->htab_mask = HTAB_SIZE(spapr) - 1; env->spr[SPR_SDR1] = (target_ulong)(uintptr_t)spapr->htab | (spapr->htab_shift - 18); }
1threat
Gridview in C# dont show data and a big eror : i am trying to show my data table with a grid view protected void show_data(object sender, EventArgs e) { string str = "Data Source=(LocalDB)\\MSSQLLocalDB;"; str += "AttachDbFilename=|DataDirectory|DinoData.mdf;"; str += "Integrated Security= True"; SqlConnection c; c = new SqlConnection(str); GV.DataSource = User; GV.DataBind(); } the eror: > An exception of type 'System.InvalidOperationException' occurred in > System.Web.dll but was not handled in user code > > Additional information: Data source is an invalid type. It must be > either an IListSource, IEnumerable, or IDataSource. what should i do? and if i want to show only part of the table with gridview how to do it? thanks for helping
0debug
Node JS ctrl + C doesn't stop server (after starting server with "npm start") : <p>When I start my server with <code>node app.js</code> in the command line (using Git Bash), I can stop it using ctrl + C.</p> <p>In my package.json file i got this start-script that allows me to use the command <code>npm start</code> to start the server:</p> <pre><code>"scripts": { "start": "node app" }, </code></pre> <p>When I do this, the server starts as normal:</p> <pre><code>$ npm start &gt; nodekb@1.0.0 start C:\Projects\nodekb &gt; node app.js Server started on port 3000... </code></pre> <p>But when i ctrl + C now, the server does not get stopped (the node process still remains in task manager). This means that I get an error when I try to do <code>npm start</code> again, because port 3000 is still being used.</p> <p>I'm following a tutorial on youtube (<a href="https://youtu.be/sB3acNJeNKE?t=6m24s" rel="noreferrer">video with timestamp</a>), and when this guy ctrl + C and then runs <code>npm start</code> again, it works as normal.</p> <p>Any ideas why my server process is not stopped when I use ctrl + C?</p> <p>My app.js file if needed:</p> <pre><code>var express = require("express"); var path = require("path"); //Init app var app = express(); //Load View Engine app.set("views", path.join(__dirname, "views")); app.set("view engine", "pug"); //Home Route app.get("/", function(req, res) { res.render("index", { title: "Hello" }); }); //Add route app.get("/articles/add", function (req, res) { res.render("add_article", { title: "Add Article" }); }); //Start server app.listen(3000, function() { console.log("Server started on port 3000..."); }); </code></pre> <p>Thanks!</p>
0debug
int qcow2_pre_write_overlap_check(BlockDriverState *bs, int chk, int64_t offset, int64_t size) { int ret = qcow2_check_metadata_overlap(bs, chk, offset, size); if (ret < 0) { return ret; } else if (ret > 0) { int metadata_ol_bitnr = ffs(ret) - 1; char *message; QObject *data; assert(metadata_ol_bitnr < QCOW2_OL_MAX_BITNR); fprintf(stderr, "qcow2: Preventing invalid write on metadata (overlaps " "with %s); image marked as corrupt.\n", metadata_ol_names[metadata_ol_bitnr]); message = g_strdup_printf("Prevented %s overwrite", metadata_ol_names[metadata_ol_bitnr]); data = qobject_from_jsonf("{ 'device': %s, 'msg': %s, 'offset': %" PRId64 ", 'size': %" PRId64 " }", bs->device_name, message, offset, size); monitor_protocol_event(QEVENT_BLOCK_IMAGE_CORRUPTED, data); g_free(message); qobject_decref(data); qcow2_mark_corrupt(bs); bs->drv = NULL; return -EIO; } return 0; }
1threat
Is it possible to copy a directory from a Google Compute Engine instance to my local machine? : <p>With scp I can add the <code>-r</code> flag to download directories to my local machine via ssh. </p> <p>When using:</p> <pre><code>gcloud compute scp -r </code></pre> <p>it sais that '-r' is not an available option. Without -r I get an error saying that my source path is a directory. (Implying I can only download single files.)</p> <p>Is there an equivalent to <code>-r</code> flag for <code>gcloud compute scp</code> command?</p>
0debug
Disable Spring Cloud AWS autoconfiguration for local development : <p>I use the following Maven dependency which autoconfigures all necessary parameters to make my project work on AWS:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt; &lt;artifactId&gt;spring-cloud-starter-aws&lt;/artifactId&gt; &lt;version&gt;1.2.2.RELEASE&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>I don't have any critical functionality depending on AWS though, it's just to load a few files from S3 at runtime. So during local development (and also testing), I don't need any AWS autoconfiguration.</p> <p>The logical error I get when running locally is:</p> <pre><code>... Caused by: java.lang.IllegalStateException: There is no EC2 meta data available, because the application is not running in the EC2 environment. Region detection is only possible if the application is running on a EC2 instance at org.springframework.util.Assert.state(Assert.java:392) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.cloud.aws.core.region.Ec2MetadataRegionProvider.getRegion(Ec2MetadataRegionProvider.java:39) ~[spring-cloud-aws-core-1.2.2.RELEASE.jar:1.2.2.RELEASE] at org.springframework.cloud.aws.core.config.AmazonWebserviceClientFactoryBean.createInstance(AmazonWebserviceClientFactoryBean.java:98) ~[spring-cloud-aws-core-1.2.2.RELEASE.jar:1.2.2.RELEASE] at org.springframework.cloud.aws.core.config.AmazonWebserviceClientFactoryBean.createInstance(AmazonWebserviceClientFactoryBean.java:44) ~[spring-cloud-aws-core-1.2.2.RELEASE.jar:1.2.2.RELEASE] ... </code></pre> <p>Is there a clean, working solution for both testing and local development?</p>
0debug
void ff_aac_search_for_ltp(AACEncContext *s, SingleChannelElement *sce, int common_window) { int w, g, w2, i, start = 0, count = 0; int saved_bits = -(15 + FFMIN(sce->ics.max_sfb, MAX_LTP_LONG_SFB)); float *C34 = &s->scoefs[128*0], *PCD = &s->scoefs[128*1]; float *PCD34 = &s->scoefs[128*2]; const int max_ltp = FFMIN(sce->ics.max_sfb, MAX_LTP_LONG_SFB); if (sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE) { if (sce->ics.ltp.lag) { memset(&sce->lcoeffs[0], 0.0f, 3072*sizeof(sce->lcoeffs[0])); memset(&sce->ics.ltp, 0, sizeof(LongTermPrediction)); } return; } if (!sce->ics.ltp.lag) return; for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { start = 0; for (g = 0; g < sce->ics.num_swb; g++) { int bits1 = 0, bits2 = 0; float dist1 = 0.0f, dist2 = 0.0f; if (w*16+g > max_ltp) { start += sce->ics.swb_sizes[g]; continue; } for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { int bits_tmp1, bits_tmp2; FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; for (i = 0; i < sce->ics.swb_sizes[g]; i++) PCD[i] = sce->coeffs[start+(w+w2)*128+i] - sce->lcoeffs[start+(w+w2)*128+i]; abs_pow34_v(C34, &sce->coeffs[start+(w+w2)*128], sce->ics.swb_sizes[g]); abs_pow34_v(PCD34, PCD, sce->ics.swb_sizes[g]); dist1 += quantize_band_cost(s, &sce->coeffs[start+(w+w2)*128], C34, sce->ics.swb_sizes[g], sce->sf_idx[(w+w2)*16+g], sce->band_type[(w+w2)*16+g], s->lambda/band->threshold, INFINITY, &bits_tmp1, NULL, 0); dist2 += quantize_band_cost(s, PCD, PCD34, sce->ics.swb_sizes[g], sce->sf_idx[(w+w2)*16+g], sce->band_type[(w+w2)*16+g], s->lambda/band->threshold, INFINITY, &bits_tmp2, NULL, 0); bits1 += bits_tmp1; bits2 += bits_tmp2; } if (dist2 < dist1 && bits2 < bits1) { for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) for (i = 0; i < sce->ics.swb_sizes[g]; i++) sce->coeffs[start+(w+w2)*128+i] -= sce->lcoeffs[start+(w+w2)*128+i]; sce->ics.ltp.used[w*16+g] = 1; saved_bits += bits1 - bits2; count++; } start += sce->ics.swb_sizes[g]; } } sce->ics.ltp.present = !!count && (saved_bits >= 0); sce->ics.predictor_present = !!sce->ics.ltp.present; if (!sce->ics.ltp.present && !!count) { for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { start = 0; for (g = 0; g < sce->ics.num_swb; g++) { if (sce->ics.ltp.used[w*16+g]) { for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { for (i = 0; i < sce->ics.swb_sizes[g]; i++) { sce->coeffs[start+(w+w2)*128+i] += sce->lcoeffs[start+(w+w2)*128+i]; } } } start += sce->ics.swb_sizes[g]; } } } }
1threat
Comparing two integers in : java : Actally i am in pretty interesting problem when i run this method with n = 64, its gives me x = 64 but beside running the if statement it runs the else statement. the actal answer need to be 32 but it return 64. /** * Complete the method to find the largest power of 2 less than the given number * Use a loop */ public class MathUtil { public int largestPowerOf2(int n) { //TODO: implement this method. int i = 0; while(n > 1) { n = n / 2; i++; } System.out.printf("i = %d\n" , i); int x = (int)Math.pow(2,i); System.out.println(x); if(x == n) { return (int)Math.pow(2,i - 1); } else { return (int)Math.pow(2, i); } } }
0debug
List of exe to open randomly : <p>I would like to create a program where I have a list of game and open them randomly. I would like to know how to create a a list of exe file and how to choose a random element of a list</p>
0debug
SyntaxError: Unexpected identifier - express.js : <p>I have the the following server created with <code>express.js</code></p> <pre><code>const express = require('express') const app = express() var bodyParser = require('body-parser'); var cors = require('cors'); app.use(cors()); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); app.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header('Access-Control-Allow-Methods', 'DELETE, PUT'); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); next(); }); app.post('/api/v1/login.json', function (req, res) { var user = login(req.body.email, req.body.password) if user !== null { res.status(200).json({token: "test_token"}); } else { res.status(401).json({error: 'Niepoprawny email lub hasło.'}); } }) app.listen(3000, function () { console.log('server listening on port 3000') }) const users = [ { id: 1, email: 'test@user.com', password: 'password', access_token: 'test_user_access_token' }, { id: 2, email: 'second@user.com', password: 'password', access_token: 'second_user_access_token' } ] function login(email, password) { return users.find(x =&gt; x.email === email &amp;&amp; x.password === password); } </code></pre> <p>When I try to run it, it returns following error:</p> <pre><code> if user !== null { ^^^^ SyntaxError: Unexpected identifier </code></pre> <p>How can I fix this?</p>
0debug
unique Identifier for cell phone, tablet and laptop : I am working on application where security is top concern. so I cannot really use mac address. I need help in finding out a way to uniquely and permanently identifying mobile device, tablet and/or laptop/pc. I want to retrieve that unique identifier through program (Coldfusion). Thanks,
0debug
void virtio_net_set_config_size(VirtIONet *n, uint32_t host_features) { int i, config_size = 0; for (i = 0; feature_sizes[i].flags != 0; i++) { if (host_features & feature_sizes[i].flags) { config_size = MAX(feature_sizes[i].end, config_size); } } n->config_size = config_size; }
1threat
static inline void rgb2rgb_init_c(void) { rgb15to16 = rgb15to16_c; rgb15tobgr24 = rgb15tobgr24_c; rgb15to32 = rgb15to32_c; rgb16tobgr24 = rgb16tobgr24_c; rgb16to32 = rgb16to32_c; rgb16to15 = rgb16to15_c; rgb24tobgr16 = rgb24tobgr16_c; rgb24tobgr15 = rgb24tobgr15_c; rgb24tobgr32 = rgb24tobgr32_c; rgb32to16 = rgb32to16_c; rgb32to15 = rgb32to15_c; rgb32tobgr24 = rgb32tobgr24_c; rgb24to15 = rgb24to15_c; rgb24to16 = rgb24to16_c; rgb24tobgr24 = rgb24tobgr24_c; shuffle_bytes_2103 = shuffle_bytes_2103_c; rgb32tobgr16 = rgb32tobgr16_c; rgb32tobgr15 = rgb32tobgr15_c; yv12toyuy2 = yv12toyuy2_c; yv12touyvy = yv12touyvy_c; yuv422ptoyuy2 = yuv422ptoyuy2_c; yuv422ptouyvy = yuv422ptouyvy_c; yuy2toyv12 = yuy2toyv12_c; planar2x = planar2x_c; rgb24toyv12 = rgb24toyv12_c; interleaveBytes = interleaveBytes_c; vu9_to_vu12 = vu9_to_vu12_c; yvu9_to_yuy2 = yvu9_to_yuy2_c; uyvytoyuv420 = uyvytoyuv420_c; uyvytoyuv422 = uyvytoyuv422_c; yuyvtoyuv420 = yuyvtoyuv420_c; yuyvtoyuv422 = yuyvtoyuv422_c; }
1threat
I have purchased a domain name from go daddy , i need to host this domain on my local computer , I have tomcat 7 running on it : <p>I have tried editing the host tag in server.XML , but it didn't work out.</p> <p>can I do this? I don't want to host it on godaddy.com. Can I host it on my local computer, so that everyone can access the domain from anywhere? If yes, where exactly I need to change the configuration ?</p>
0debug
static void net_rx_packet(void *opaque, const uint8_t *buf, size_t size) { struct XenNetDev *netdev = opaque; netif_rx_request_t rxreq; RING_IDX rc, rp; void *page; if (netdev->xendev.be_state != XenbusStateConnected) return; 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; } 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; } 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; } 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); }
1threat
def chinese_zodiac(year): if (year - 2000) % 12 == 0: sign = 'Dragon' elif (year - 2000) % 12 == 1: sign = 'Snake' elif (year - 2000) % 12 == 2: sign = 'Horse' elif (year - 2000) % 12 == 3: sign = 'sheep' elif (year - 2000) % 12 == 4: sign = 'Monkey' elif (year - 2000) % 12 == 5: sign = 'Rooster' elif (year - 2000) % 12 == 6: sign = 'Dog' elif (year - 2000) % 12 == 7: sign = 'Pig' elif (year - 2000) % 12 == 8: sign = 'Rat' elif (year - 2000) % 12 == 9: sign = 'Ox' elif (year - 2000) % 12 == 10: sign = 'Tiger' else: sign = 'Hare' return sign
0debug
static uint64_t alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, int n_start, int n_end, int *num, QCowL2Meta *m) { BDRVQcowState *s = bs->opaque; int l2_index, ret; uint64_t l2_offset, *l2_table, cluster_offset; int nb_clusters, i = 0; ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index); if (ret == 0) return 0; nb_clusters = size_to_clusters(s, n_end << 9); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); cluster_offset = be64_to_cpu(l2_table[l2_index]); if (cluster_offset & QCOW_OFLAG_COPIED) { nb_clusters = count_contiguous_clusters(nb_clusters, s->cluster_size, &l2_table[l2_index], 0); cluster_offset &= ~QCOW_OFLAG_COPIED; m->nb_clusters = 0; goto out; } if (cluster_offset & QCOW_OFLAG_COMPRESSED) nb_clusters = 1; while (i < nb_clusters) { i += count_contiguous_clusters(nb_clusters - i, s->cluster_size, &l2_table[l2_index + i], 0); if(be64_to_cpu(l2_table[l2_index + i])) break; i += count_contiguous_free_clusters(nb_clusters - i, &l2_table[l2_index + i]); cluster_offset = be64_to_cpu(l2_table[l2_index + i]); if ((cluster_offset & QCOW_OFLAG_COPIED) || (cluster_offset & QCOW_OFLAG_COMPRESSED)) break; } nb_clusters = i; cluster_offset = alloc_clusters(bs, nb_clusters * s->cluster_size); m->offset = offset; m->n_start = n_start; m->nb_clusters = nb_clusters; out: m->nb_available = MIN(nb_clusters << (s->cluster_bits - 9), n_end); *num = m->nb_available - n_start; return cluster_offset; }
1threat
void net_slirp_smb(const char *exported_dir) { struct in_addr vserver_addr = { .s_addr = 0 }; if (legacy_smb_export) { fprintf(stderr, "-smb given twice\n"); exit(1); } legacy_smb_export = exported_dir; if (!QTAILQ_EMPTY(&slirp_stacks)) { slirp_smb(QTAILQ_FIRST(&slirp_stacks), NULL, exported_dir, vserver_addr); } }
1threat
How to get all tweets in twitter through code? : <p>What is the best way to retrieve all tweets by all users in twitter? Ideally using python code and API calls. I understand that Twitter don't make tweets older than a time frame available for us to download. I don't care about them. But all tweets that are available to us for download.</p>
0debug
static av_cold int libx265_encode_init(AVCodecContext *avctx) { libx265Context *ctx = avctx->priv_data; ctx->api = x265_api_get(av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth_minus1 + 1); if (!ctx->api) ctx->api = x265_api_get(0); if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL && !av_pix_fmt_desc_get(avctx->pix_fmt)->log2_chroma_w) { av_log(avctx, AV_LOG_ERROR, "4:2:2 and 4:4:4 support is not fully defined for HEVC yet. " "Set -strict experimental to encode anyway.\n"); return AVERROR(ENOSYS); } avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) { av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n"); return AVERROR(ENOMEM); } ctx->params = ctx->api->param_alloc(); if (!ctx->params) { av_log(avctx, AV_LOG_ERROR, "Could not allocate x265 param structure.\n"); return AVERROR(ENOMEM); } if (ctx->api->param_default_preset(ctx->params, ctx->preset, ctx->tune) < 0) { int i; av_log(avctx, AV_LOG_ERROR, "Error setting preset/tune %s/%s.\n", ctx->preset, ctx->tune); av_log(avctx, AV_LOG_INFO, "Possible presets:"); for (i = 0; x265_preset_names[i]; i++) av_log(avctx, AV_LOG_INFO, " %s", x265_preset_names[i]); av_log(avctx, AV_LOG_INFO, "\n"); av_log(avctx, AV_LOG_INFO, "Possible tunes:"); for (i = 0; x265_tune_names[i]; i++) av_log(avctx, AV_LOG_INFO, " %s", x265_tune_names[i]); av_log(avctx, AV_LOG_INFO, "\n"); return AVERROR(EINVAL); } ctx->params->frameNumThreads = avctx->thread_count; ctx->params->fpsNum = avctx->time_base.den; ctx->params->fpsDenom = avctx->time_base.num * avctx->ticks_per_frame; ctx->params->sourceWidth = avctx->width; ctx->params->sourceHeight = avctx->height; ctx->params->bEnablePsnr = !!(avctx->flags & CODEC_FLAG_PSNR); if ((avctx->color_primaries <= AVCOL_PRI_BT2020 && avctx->color_primaries != AVCOL_PRI_UNSPECIFIED) || (avctx->color_trc <= AVCOL_TRC_BT2020_12 && avctx->color_trc != AVCOL_TRC_UNSPECIFIED) || (avctx->colorspace <= AVCOL_SPC_BT2020_CL && avctx->colorspace != AVCOL_SPC_UNSPECIFIED)) { ctx->params->vui.bEnableVideoSignalTypePresentFlag = 1; ctx->params->vui.bEnableColorDescriptionPresentFlag = 1; ctx->params->vui.colorPrimaries = avctx->color_primaries; ctx->params->vui.transferCharacteristics = avctx->color_trc; ctx->params->vui.matrixCoeffs = avctx->colorspace; } if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0) { char sar[12]; int sar_num, sar_den; av_reduce(&sar_num, &sar_den, avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den, 65535); snprintf(sar, sizeof(sar), "%d:%d", sar_num, sar_den); if (ctx->api->param_parse(ctx->params, "sar", sar) == X265_PARAM_BAD_VALUE) { av_log(avctx, AV_LOG_ERROR, "Invalid SAR: %d:%d.\n", sar_num, sar_den); return AVERROR_INVALIDDATA; } } switch (avctx->pix_fmt) { case AV_PIX_FMT_YUV420P: case AV_PIX_FMT_YUV420P10: ctx->params->internalCsp = X265_CSP_I420; break; case AV_PIX_FMT_YUV422P: case AV_PIX_FMT_YUV422P10: ctx->params->internalCsp = X265_CSP_I422; break; case AV_PIX_FMT_YUV444P: case AV_PIX_FMT_YUV444P10: ctx->params->internalCsp = X265_CSP_I444; break; } if (ctx->crf >= 0) { char crf[6]; snprintf(crf, sizeof(crf), "%2.2f", ctx->crf); if (ctx->api->param_parse(ctx->params, "crf", crf) == X265_PARAM_BAD_VALUE) { av_log(avctx, AV_LOG_ERROR, "Invalid crf: %2.2f.\n", ctx->crf); return AVERROR(EINVAL); } } else if (avctx->bit_rate > 0) { ctx->params->rc.bitrate = avctx->bit_rate / 1000; ctx->params->rc.rateControlMode = X265_RC_ABR; } if (!(avctx->flags & CODEC_FLAG_GLOBAL_HEADER)) ctx->params->bRepeatHeaders = 1; if (ctx->x265_opts) { AVDictionary *dict = NULL; AVDictionaryEntry *en = NULL; if (!av_dict_parse_string(&dict, ctx->x265_opts, "=", ":", 0)) { while ((en = av_dict_get(dict, "", en, AV_DICT_IGNORE_SUFFIX))) { int parse_ret = ctx->api->param_parse(ctx->params, en->key, en->value); switch (parse_ret) { case X265_PARAM_BAD_NAME: av_log(avctx, AV_LOG_WARNING, "Unknown option: %s.\n", en->key); break; case X265_PARAM_BAD_VALUE: av_log(avctx, AV_LOG_WARNING, "Invalid value for %s: %s.\n", en->key, en->value); break; default: break; } } av_dict_free(&dict); } } ctx->encoder = ctx->api->encoder_open(ctx->params); if (!ctx->encoder) { av_log(avctx, AV_LOG_ERROR, "Cannot open libx265 encoder.\n"); libx265_encode_close(avctx); return AVERROR_INVALIDDATA; } if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { x265_nal *nal; int nnal; avctx->extradata_size = ctx->api->encoder_headers(ctx->encoder, &nal, &nnal); if (avctx->extradata_size <= 0) { av_log(avctx, AV_LOG_ERROR, "Cannot encode headers.\n"); libx265_encode_close(avctx); return AVERROR_INVALIDDATA; } avctx->extradata = av_malloc(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate HEVC header of size %d.\n", avctx->extradata_size); libx265_encode_close(avctx); return AVERROR(ENOMEM); } memcpy(avctx->extradata, nal[0].payload, avctx->extradata_size); } return 0; }
1threat
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
static void init_excp_620 (CPUPPCState *env) { #if !defined(CONFIG_USER_ONLY) env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; env->excp_vectors[POWERPC_EXCP_FPA] = 0x00000E00; env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; env->hreset_vector = 0x0000000000000100ULL; #endif }
1threat
static int raw_decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int linesize_align = 4; RawVideoContext *context = avctx->priv_data; AVFrame * frame = (AVFrame *) data; AVPicture * picture = (AVPicture *) data; frame->pict_type = avctx->coded_frame->pict_type; frame->interlaced_frame = avctx->coded_frame->interlaced_frame; frame->top_field_first = avctx->coded_frame->top_field_first; frame->reordered_opaque = avctx->reordered_opaque; frame->pkt_pts = avctx->pkt->pts; frame->pkt_pos = avctx->pkt->pos; if(context->tff>=0){ frame->interlaced_frame = 1; frame->top_field_first = context->tff; } if (context->buffer) { int i; uint8_t *dst = context->buffer; buf_size = context->length - 256*4; if (avctx->bits_per_coded_sample == 4){ for(i=0; 2*i+1 < buf_size; i++){ dst[2*i+0]= buf[i]>>4; dst[2*i+1]= buf[i]&15; } linesize_align = 8; } else { for(i=0; 4*i+3 < buf_size; i++){ dst[4*i+0]= buf[i]>>6; dst[4*i+1]= buf[i]>>4&3; dst[4*i+2]= buf[i]>>2&3; dst[4*i+3]= buf[i] &3; } linesize_align = 16; } buf= dst; } if(avctx->codec_tag == MKTAG('A', 'V', '1', 'x') || avctx->codec_tag == MKTAG('A', 'V', 'u', 'p')) buf += buf_size - context->length; if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0)) return -1; avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height); if((avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length) || (av_pix_fmt_descriptors[avctx->pix_fmt].flags & PIX_FMT_PSEUDOPAL)) { frame->data[1]= context->palette; } if (avctx->pix_fmt == PIX_FMT_PAL8) { const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); if (pal) { memcpy(frame->data[1], pal, AVPALETTE_SIZE); frame->palette_has_changed = 1; } } if((avctx->pix_fmt==PIX_FMT_BGR24 || avctx->pix_fmt==PIX_FMT_GRAY8 || avctx->pix_fmt==PIX_FMT_RGB555LE || avctx->pix_fmt==PIX_FMT_RGB555BE || avctx->pix_fmt==PIX_FMT_RGB565LE || avctx->pix_fmt==PIX_FMT_MONOWHITE || avctx->pix_fmt==PIX_FMT_PAL8) && FFALIGN(frame->linesize[0], linesize_align)*avctx->height <= buf_size) frame->linesize[0] = FFALIGN(frame->linesize[0], linesize_align); if(context->flip) flip(avctx, picture); if ( avctx->codec_tag == MKTAG('Y', 'V', '1', '2') || avctx->codec_tag == MKTAG('Y', 'V', '1', '6') || avctx->codec_tag == MKTAG('Y', 'V', '2', '4') || avctx->codec_tag == MKTAG('Y', 'V', 'U', '9')) FFSWAP(uint8_t *, picture->data[1], picture->data[2]); if(avctx->codec_tag == AV_RL32("yuv2") && avctx->pix_fmt == PIX_FMT_YUYV422) { int x, y; uint8_t *line = picture->data[0]; for(y = 0; y < avctx->height; y++) { for(x = 0; x < avctx->width; x++) line[2*x + 1] ^= 0x80; line += picture->linesize[0]; } } *data_size = sizeof(AVPicture); return buf_size; }
1threat
static av_always_inline void dnxhd_decode_dct_block(DNXHDContext *ctx, DCTELEM *block, int n, int qscale, int index_bits, int level_bias, int level_shift) { int i, j, index1, index2, len; int level, component, sign; const uint8_t *weight_matrix; OPEN_READER(bs, &ctx->gb); if (n&2) { component = 1 + (n&1); weight_matrix = ctx->cid_table->chroma_weight; } else { component = 0; weight_matrix = ctx->cid_table->luma_weight; } UPDATE_CACHE(bs, &ctx->gb); GET_VLC(len, bs, &ctx->gb, ctx->dc_vlc.table, DNXHD_DC_VLC_BITS, 1); if (len) { level = GET_CACHE(bs, &ctx->gb); LAST_SKIP_BITS(bs, &ctx->gb, len); sign = ~level >> 31; level = (NEG_USR32(sign ^ level, len) ^ sign) - sign; ctx->last_dc[component] += level; } block[0] = ctx->last_dc[component]; for (i = 1; ; i++) { UPDATE_CACHE(bs, &ctx->gb); GET_VLC(index1, bs, &ctx->gb, ctx->ac_vlc.table, DNXHD_VLC_BITS, 2); level = ctx->cid_table->ac_level[index1]; if (!level) { break; } sign = SHOW_SBITS(bs, &ctx->gb, 1); SKIP_BITS(bs, &ctx->gb, 1); if (ctx->cid_table->ac_index_flag[index1]) { level += SHOW_UBITS(bs, &ctx->gb, index_bits) << 6; SKIP_BITS(bs, &ctx->gb, index_bits); } if (ctx->cid_table->ac_run_flag[index1]) { UPDATE_CACHE(bs, &ctx->gb); GET_VLC(index2, bs, &ctx->gb, ctx->run_vlc.table, DNXHD_VLC_BITS, 2); i += ctx->cid_table->run[index2]; } if (i > 63) { av_log(ctx->avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", n, i); break; } j = ctx->scantable.permutated[i]; level = (2*level+1) * qscale * weight_matrix[i]; if (level_bias < 32 || weight_matrix[i] != level_bias) level += level_bias; level >>= level_shift; block[j] = (level^sign) - sign; } CLOSE_READER(bs, &ctx->gb); }
1threat
is there any easy way to get number of weekend in a month in java : <p>I want to find number of weekend (here weekend may be one or more day) from a particular month of particular date. Like if number of weekend is 2 i.e. saturday and sunday than how to calculate total number of weekend from a date like 2019-11-15 in java.</p>
0debug
React-MobX Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean : <p>I get the following error: If you are migrating from Babylon/Babel 6 or want to use the old decorators proposal, you should use the 'decorators-legacy' plugin instead of 'decorators'.</p> <p><strong>package.json</strong></p> <pre><code>"@babel/plugin-proposal-decorators": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.1.2.tgz", "integrity": "sha512-YooynBO6PmBgHvAd0fl5e5Tq/a0pEC6RqF62ouafme8FzdIVH41Mz/u1dn8fFVm4jzEJ+g/MsOxouwybJPuP8Q==", "requires": { "@babel/helper-plugin-utils": "^7.0.0", "@babel/helper-replace-supers": "^7.1.0", "@babel/helper-split-export-declaration": "^7.0.0", "@babel/plugin-syntax-decorators": "^7.1.0" } }, "@babel/plugin-syntax-decorators": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-decorators/-/plugin-syntax-decorators-7.1.0.tgz", "integrity": "sha512-uQvRSbgQ0nQg3jsmIixXXDCgSpkBolJ9X7NYThMKCcjvE8dN2uWJUzTUNNAeuKOjARTd+wUQV0ztXpgunZYKzQ==", "requires": { "@babel/helper-plugin-utils": "^7.0.0" } }, "babel-plugin-syntax-decorators": { "version": "6.13.0", "resolved": "http://registry.npmjs.org/babel-plugin-syntax-decorators/-/babel-plugin-syntax-decorators-6.13.0.tgz", "integrity": "sha1-MSVjtNvePMgGzuPkFszurd0RrAs=", "dev": true }, "babel-plugin-transform-decorators-legacy": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/babel-plugin-transform-decorators-legacy/-/babel-plugin-transform-decorators-legacy-1.3.5.tgz", "integrity": "sha512-jYHwjzRXRelYQ1uGm353zNzf3QmtdCfvJbuYTZ4gKveK7M9H1fs3a5AKdY1JUDl0z97E30ukORW1dzhWvsabtA==", "dev": true, "requires": { "babel-plugin-syntax-decorators": "^6.1.18", "babel-runtime": "^6.2.0", "babel-template": "^6.3.0" } }, "requires": { "@babel/plugin-proposal-decorators": "7.1.2", } </code></pre> <p><strong>tsconfig.json</strong></p> <pre><code>{ "compilerOptions": { "experimentalDecorators": true, "allowJs": true } } </code></pre>
0debug
audio player jwplayer wma files failes with error - Task Queue failed at step 5 : i have a jw player which plays mp3 files but wma files it gives the error "Task Queue failed at step 5: Playlist could not be loaded: Playlist file did not contain a valid playlist" i thought of two reasons 1. there is no support for wma but please confirm me this. 2. somewhere i need to setup the type of file i am using in this player. if wma not supported in jwplayer how can play wma and mp3 files in my website?
0debug
why cant i run a java program from another java program? : I am running the following code. I ask the user to enter a java program. The user's program will compile correctly, and if there is any error it will be pointed out. But when I try to run the program it wont run at all. Instead I get a "Program finished with exit code 0". How do i solve this problem? import java.io.*; import java.util.*; public class myprog1 { public static void main(String [] args) throws IOException, InterruptedException { System.out.println("enter the candidate name"); Scanner scan = new Scanner(System.in); String cname = scan.next(); String cfilename = "candidate.java"; String file1 = "/home/prakasha/IdeaProjects/" + cname; String file2 = "/home/prakasha/IdeaProjects/"; File file = new File("/home/prakasha/IdeaProjects/" + cname); file.mkdir(); if (!file.exists()) { System.out.println("filenotfound"); } else { System.out.println("the code is stored in his dir :" + cname); File fobj = new File(file, "/" + cfilename); FileWriter fw = new FileWriter(fobj); System.out.println("enter the code"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String code = br.readLine(); fw.append(code); System.out.println(fobj); fw.close(); ProcessBuilder pb = new ProcessBuilder ("javac", file1 + "/" + cfilename); pb.inheritIO(); Process process = pb.start(); process.waitFor(); BufferedReader is = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; // reading the output while ((line = is.readLine()) != null) System.out.println(line); ProcessBuilder pb1 = new ProcessBuilder ("java", file1 + "/" + "candidate"); System.out.println(file1 + "/" + "candidate"); pb.inheritIO(); Process process1 = pb1.start(); BufferedReader reading = new BufferedReader(new InputStreamReader(process1.getInputStream())); String line1; while ((line1 = reading.readLine()) != null) System.out.println(line1); } } }
0debug
what is the use of "$$" in angularjs? : <p>can any one please help me to understand what is the use of $$. I came across a code snippet like "$scope.$$watchers" and could not understand it.</p> <p>Thanks in advance.</p>
0debug
Remove Some Character From Records Using SQL : <p>I am having question mark symbol(?) in between first name and last name of Customers in some records, I want to replace all "?" with a space.</p> <pre><code>UPDATE Customers //What to write here? WHERE Name LIKE '%?%'; </code></pre>
0debug
transfrom code from php to javascript : How to transform the following code from php to javascript? $str = ''; for ($i = 0; $i < 256; $i++) { $str .= chr($i); } I know String.fromCharCode() in javascript is similar to chr() in php, but it seems fromCharCode(n) is diffenent from chr(n) when n greater than 127.
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
Spring Boot + Thymeleaf ERROR java.lang.ClassNotFoundException: org.thymeleaf.dom.Attribute : <p>I have the following problem using Spring Boot and thymeleaf and I can not fix it. The error occurs when I run the Application class, right after the error occurs.</p> <p>My layout with thymeleaf lies</p> <p><strong>main\resources\templates</strong></p> <p><strong>HomeController</strong></p> <pre><code>@Controller public class HomeController { @GetMapping("/") public String root() { return "page/home"; } } </code></pre> <p><strong>Application</strong></p> <pre><code>@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } </code></pre> <p><strong>POM</strong></p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;nz.net.ultraq.thymeleaf&lt;/groupId&gt; &lt;artifactId&gt;thymeleaf-layout-dialect&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt; &lt;optional&gt;true&lt;/optional&gt; &lt;/dependency&gt; </code></pre> <p><strong>LOG ERROR</strong></p> <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'viewResolver' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$Thymeleaf3Configuration$Thymeleaf3ViewResolverConfiguration': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration$$EnhancerBySpringCGLIB$$71bf139e]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'layoutDialect' defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$ThymeleafWebLayoutConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [nz.net.ultraq.thymeleaf.LayoutDialect]: Factory method 'layoutDialect' threw exception; nested exception is java.lang.NoClassDefFoundError: org/thymeleaf/dom/Attribute at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] at gervasio.system.Application.main(Application.java:10) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121] at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_121] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.2.RELEASE.jar:1.5.2.RELEASE] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$Thymeleaf3Configuration$Thymeleaf3ViewResolverConfiguration': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration$$EnhancerBySpringCGLIB$$71bf139e]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'layoutDialect' defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$ThymeleafWebLayoutConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [nz.net.ultraq.thymeleaf.LayoutDialect]: Factory method 'layoutDialect' threw exception; nested exception is java.lang.NoClassDefFoundError: org/thymeleaf/dom/Attribute at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:372) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:519) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:508) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1189) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:261) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.web.servlet.view.ContentNegotiatingViewResolver.initServletContext(ContentNegotiatingViewResolver.java:178) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:80) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:74) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:121) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:97) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] ... 20 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration$$EnhancerBySpringCGLIB$$71bf139e]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'layoutDialect' defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$ThymeleafWebLayoutConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [nz.net.ultraq.thymeleaf.LayoutDialect]: Factory method 'layoutDialect' threw exception; nested exception is java.lang.NoClassDefFoundError: org/thymeleaf/dom/Attribute at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:279) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:372) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] ... 50 common frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration$$EnhancerBySpringCGLIB$$71bf139e]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'layoutDialect' defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$ThymeleafWebLayoutConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [nz.net.ultraq.thymeleaf.LayoutDialect]: Factory method 'layoutDialect' threw exception; nested exception is java.lang.NoClassDefFoundError: org/thymeleaf/dom/Attribute at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:271) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] ... 72 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'layoutDialect' defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$ThymeleafWebLayoutConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [nz.net.ultraq.thymeleaf.LayoutDialect]: Factory method 'layoutDialect' threw exception; nested exception is java.lang.NoClassDefFoundError: org/thymeleaf/dom/Attribute at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1309) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1275) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1180) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1096) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectProvider.getIfAvailable(DefaultListableBeanFactory.java:1655) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration.&lt;init&gt;(ThymeleafAutoConfiguration.java:193) ~[spring-boot-autoconfigure-1.5.2.RELEASE.jar:1.5.2.RELEASE] at org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration$$EnhancerBySpringCGLIB$$71bf139e.&lt;init&gt;(&lt;generated&gt;) ~[spring-boot-autoconfigure-1.5.2.RELEASE.jar:1.5.2.RELEASE] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_121] at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_121] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_121] at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[na:1.8.0_121] at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] ... 74 common frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [nz.net.ultraq.thymeleaf.LayoutDialect]: Factory method 'layoutDialect' threw exception; nested exception is java.lang.NoClassDefFoundError: org/thymeleaf/dom/Attribute at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] ... 95 common frames omitted Caused by: java.lang.NoClassDefFoundError: org/thymeleaf/dom/Attribute at nz.net.ultraq.thymeleaf.LayoutDialect.&lt;clinit&gt;(LayoutDialect.groovy:50) ~[thymeleaf-layout-dialect-1.4.0.jar:na] at org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafWebLayoutConfiguration.layoutDialect(ThymeleafAutoConfiguration.java:219) ~[spring-boot-autoconfigure-1.5.2.RELEASE.jar:1.5.2.RELEASE] at org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafWebLayoutConfiguration$$EnhancerBySpringCGLIB$$5982f641.CGLIB$layoutDialect$0(&lt;generated&gt;) ~[spring-boot-autoconfigure-1.5.2.RELEASE.jar:1.5.2.RELEASE] at org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafWebLayoutConfiguration$$EnhancerBySpringCGLIB$$5982f641$$FastClassBySpringCGLIB$$715c3b8a.invoke(&lt;generated&gt;) ~[spring-boot-autoconfigure-1.5.2.RELEASE.jar:1.5.2.RELEASE] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE] at org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafWebLayoutConfiguration$$EnhancerBySpringCGLIB$$5982f641.layoutDialect(&lt;generated&gt;) ~[spring-boot-autoconfigure-1.5.2.RELEASE.jar:1.5.2.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121] at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_121] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE] ... 96 common frames omitted Caused by: java.lang.ClassNotFoundException: org.thymeleaf.dom.Attribute at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_121] at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_121] at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[na:1.8.0_121] at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_121] ... 108 common frames omitted </code></pre>
0debug
Math - comparison of 2 algoritmn : [Two expression with A and B][1] [1]: https://i.stack.imgur.com/9hlVH.png A = 2^(2(log_3 n)) B = 6(n^2) Is that A=O(B)? how to solve this?
0debug
Mocking static classes with Powermock2 and Kotlin : <p>in Android I've been using the version <strong>1.6.1</strong> of Powermock and all this implementation worked really good for statics. It's not working now at all when I changed to <strong>2.0.0-beta.5</strong>. Indeed, it didn't even work upgrading from my previous <strong>1.6.1</strong> to <strong>1.7.1</strong>.</p> <p>I have this implementation:</p> <pre><code>// Power Mockito testImplementation "org.powermock:powermock-api-mockito2:2.0.0-beta.5" testImplementation "org.powermock:powermock-module-junit4-rule-agent:2.0.0-beta.5" testImplementation "org.powermock:powermock-module-junit4:2.0.0-beta.5" //testImplementation 'org.powermock:powermock-module-junit4-rule:2.0.0-beta.5' // Mockito testImplementation "org.mockito:mockito-core:2.11.0" testImplementation "com.nhaarman:mockito-kotlin-kt1.1:1.5.0" androidTestImplementation("com.nhaarman:mockito-kotlin-kt1.1:1.5.0", { exclude group: 'org.mockito', module: 'mockito-core' }) androidTestImplementation 'org.mockito:mockito-android:2.11.0' </code></pre> <p>and I'm trying to mock a static the same way I was doing with <strong>1.6.1:</strong></p> <pre><code>@RunWith(PowerMockRunner::class) @PrepareForTest(SharedPreferencesHelper.Companion::class, ConfigUseCaseTests::class) class ConfigUseCaseTests { lateinit var context: Context @Before fun setUp() { context = mock() } @Test fun getConfigs_fromJson() { PowerMockito.mockStatic(SharedPreferencesHelper.Companion::class.java) val instance = mock&lt;SharedPreferencesHelper.Companion&gt;() doReturn("foo") .whenever(instance) .loadString(isA(), anyString(), anyString(), anyString()) // whenever(instance.loadString(isA(), anyString(), anyString(), anyString())).thenReturn("foo") // This shows the same error PowerMockito.whenNew(SharedPreferencesHelper.Companion::class.java) .withAnyArguments() .thenReturn(instance) val mockedFoo = instance.loadString(context, "", "", "") // This shows "foo" val mockedCompanion = SharedPreferencesHelper.loadString(context, "", "", "") // This is throwing NullPointerException Assert.assertEquals(mockedCompanion, "foo") } } </code></pre> <p>My <strong>SharedPreferencesHelper</strong> looks like:</p> <pre><code>class SharedPreferencesHelper { companion object { @Suppress("NON_FINAL_MEMBER_IN_OBJECT") open fun loadString(context: Context, fileName: String, key: String, defaultValue: String?): String? { val sharedPreferences = getWithFileName(context, fileName) return if (!sharedPreferences.contains(key)) { defaultValue } else { sharedPreferences.getString(key, defaultValue) } } } } </code></pre> <p>I've tried to play with the <code>open</code> but it didn't work.</p> <p><strong>Exception:</strong> (I don't understand it at all)</p> <pre><code>java.lang.NullPointerException at my.package.ConfigUseCaseTests.getConfigs_fromJson(ConfigUseCaseTests.kt:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68) at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:326) at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:89) at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:97) at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:310) at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:131) </code></pre> <p>I can say, sometimes IT WORKS!! I'm adding the video because it looks amazing that it happens just sometimes: <a href="https://youtu.be/YZObVLcERBo" rel="noreferrer">https://youtu.be/YZObVLcERBo</a> (watch at the middle and the end)</p>
0debug
static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { ARMCPU *cpu = arm_env_get_cpu(env); if (env->cp15.c1_sys == value) { return; } env->cp15.c1_sys = value; tlb_flush(CPU(cpu), 1); }
1threat
ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, ram_addr_t size, void *host) { RAMBlock *new_block, *block; size = TARGET_PAGE_ALIGN(size); new_block = qemu_mallocz(sizeof(*new_block)); if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { char *id = dev->parent_bus->info->get_dev_path(dev); if (id) { snprintf(new_block->idstr, sizeof(new_block->idstr), "%s/", id); qemu_free(id); pstrcat(new_block->idstr, sizeof(new_block->idstr), name); QLIST_FOREACH(block, &ram_list.blocks, next) { if (!strcmp(block->idstr, new_block->idstr)) { fprintf(stderr, "RAMBlock \"%s\" already registered, abort!\n", new_block->idstr); new_block->offset = find_ram_offset(size); if (host) { new_block->host = host; new_block->flags |= RAM_PREALLOC_MASK; } else { if (mem_path) { #if defined (__linux__) && !defined(TARGET_S390X) new_block->host = file_ram_alloc(new_block, size, mem_path); if (!new_block->host) { new_block->host = qemu_vmalloc(size); qemu_madvise(new_block->host, size, QEMU_MADV_MERGEABLE); #else fprintf(stderr, "-mem-path option unsupported\n"); exit(1); #endif } else { #if defined(TARGET_S390X) && defined(CONFIG_KVM) new_block->host = mmap((void*)0x800000000, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, -1, 0); #else if (xen_mapcache_enabled()) { xen_ram_alloc(new_block->offset, size); } else { new_block->host = qemu_vmalloc(size); #endif qemu_madvise(new_block->host, size, QEMU_MADV_MERGEABLE); new_block->length = size; QLIST_INSERT_HEAD(&ram_list.blocks, new_block, next); ram_list.phys_dirty = qemu_realloc(ram_list.phys_dirty, last_ram_offset() >> TARGET_PAGE_BITS); memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS), 0xff, size >> TARGET_PAGE_BITS); if (kvm_enabled()) kvm_setup_guest_memory(new_block->host, size); return new_block->offset;
1threat
Error with tkinter class : <p>I am making a basic temperture converter, I have it so you can convert celcius to farenheight, and now im trying to make it so you can switch. I have this code:</p> <pre><code>from tkinter import * bool1 = True class App: def __init__(self, master): frame = Frame(master) frame.pack() self.x = Label(frame, text = 'Celcius:').grid(row = 0, column = 0) self.c_var = DoubleVar() Entry(frame, textvariable = self.c_var).grid(row = 0, column = 1) self.z = Label(frame, text = 'Farenheight:').grid(row = 1, column = 0) self.result_var = DoubleVar() Label(frame, textvariable = self.result_var).grid(row = 1, column = 1) b1 = Button(frame, text = 'Switch', command = self.switch) b1.grid(row = 2, columnspan = 2) button = Button(frame, text = 'Convert', command = self.convert) button.grid(row = 3, columnspan = 2) return None def convert(self): c = self.c_var.get() c = c * (9/5) + 32 self.result_var.set(c) def switch(self): global bool1 if bool1 == True: bool1 = False self.x.config(text = 'Farenheight:') else: bool1 = True self.z['text'] = 'Celcius:' root = Tk() root.wm_title('Temp Converter') app = App(root) root.mainloop() </code></pre> <p>The error message I am getting is:</p> <pre><code>Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\keith\AppData\Local\Programs\Python\Python35- 32\lib\tkinter\__init__.py", line 1550, in __call__ return self.func(*args) File "C:\Users\keith\Desktop\tkinter.py", line 26, in switch self.x.config(text = 'Farenheight:') AttributeError: 'NoneType' object has no attribute 'config' </code></pre>
0debug
finding max value of finishes per date : <p>Pardon for the title, but I absolutely have no idea as to how to describe this.</p> <p>I've got a table like this:</p> <pre><code>trackID playerID score date 1 2 4510 1494075555 1 2 4507 1494076300 1 2 4513 1494076561 2 3 39455 1494083772 3 3 5665 1494089018 2 2 38444 1494074519 4 3 34443 1494089138 5 3 56443 1494260918 </code></pre> <p>I want only the first finish per track, a track can have multiple players finish on the same date. I want to have the max amount of first finishes on a single day.</p> <p>In the table above, player 3 finished 3 maps for the first time on the 6.5.2017. On the 8.5.2017 he only finished a single track. I only want to include the date he finished the most tracks.</p> <p>Result I want:</p> <pre><code>playerID trackID count(trackID) date 3 2,3,4 3 6.5.2017 2 1,2 2 6.5.2017 </code></pre>
0debug
Android Studio Change Array Value Part 2 : On part 1 i did ask how to delete an element of my array if the user selects an action instead of another.I did got an answer about making my string array an array list.Now i 'd like to know how to give id values to my data in order to display the next children on that value.For example i would like to display the cities of greece if the user press yes to greece.This is a general question i have and i am writing a small sample of code to give you understand what i mean. int randome=0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Button no = (Button) findViewById(R.id.No); final Button yes=(Button) findViewById(R.id.Yes); final TextView tvMessage=(TextView) findViewById(R.id.tvMessage); final ArrayList<String> country = new ArrayList<>(); country.add("Do you wanna see an Action Movie???"); country.add("Do you wanna see a Comedy Movie???"); country.add("Do you wanna see a Drama Movie???"); no.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (randome>=0 && randome<country.size()){ country.remove(randome); Random rand = new Random(); randome = rand.nextInt(country.size()); tvMessage.setText(country.get(randome)); } } }); yes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Random rand = new Random(); randome = rand.nextInt(country.size()); tvMessage.setText(country.get(randome)); } }); } That's what i used for the first part "Android Studio Change Array Value" with the array list.If there is now way to do it with array list then i should do it with string array like that i guess String[][] countriesAndCities= new String[][]; countriesAndCities [0][0] = "United Kingdom"; countriesAndCities [0][1] = "London"; countriesAndCities [1][0] = "USA"; countriesAndCities [1][1] = "Washington"; countriesAndCities [2][0] = "India"; countriesAndCities [2][1] = "New Delhi";
0debug
Parameter ScheduleExpression is not valid : <p>I'm trying to setup a Cloudwatch Scheduled Event and my cron expression seems to be invalid, though I can't figure out why.</p> <p>My cron expression is:</p> <p>cron(5,15,25,35,45,55 * * * *)</p> <p>I want it to run on the 5th, 15th, 25th, 35th, 45th and 55th minute of every hour of every day. This seems to coincide with the AWS Scheduled Events documentation here <a href="http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html" rel="noreferrer">http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html</a>.</p> <p>The above documentation allows for minutes to be represented with comma separated values between 0 and 59, and hours, day-of-month (or day-of-week), month and year to be reflected with a * wildcard to reflect ALL.</p> <p>I have tried setting the cron expression on the Lambda console (when creating the function and choosing Cloudwatch Schedule Event), and in the Cloudwatch console (along with choosing the target of the trigger). Neither worked with my custom cron expression.</p> <p>I have tried the following:</p> <pre><code>5,15,25,35,45,55 * * * * 5,15,25,35,45,55 * ? * * cron(5,15,25,35,45,55 * * * *) cron(5,15,25,35,45,55 * ? * *) </code></pre> <p>Everytime I get an error saying the ScheduleExpression is not valid. I can, however, use one of the premade rate() expressions.</p> <p>How can I use my own custom cron expression?</p> <p>Thanks.</p>
0debug
Casting an Int to a boolean Issue in C++ : If we assume that an int takes 4 bytes and a bool takes 1 byte, what happens to the other 3 bytes when an int is casted to a bool. do those bytes become free and can be overwritten by any other assignment. I saw something like this in a code: ``` void foo(bool e){ int a; bool s; e = e >> 24; ... } void mainFunc(){ int *arg = (int*)malloc(sizeof(int)); *arg = xxxx; foo((bool)arg); } ``` Is this a right thing to do?
0debug
av_cold int ff_snow_common_init(AVCodecContext *avctx){ SnowContext *s = avctx->priv_data; int width, height; int i, j; s->avctx= avctx; s->max_ref_frames=1; ff_me_cmp_init(&s->mecc, avctx); ff_hpeldsp_init(&s->hdsp, avctx->flags); ff_videodsp_init(&s->vdsp, 8); ff_dwt_init(&s->dwt); ff_h264qpel_init(&s->h264qpel, 8); #define mcf(dx,dy)\ s->qdsp.put_qpel_pixels_tab [0][dy+dx/4]=\ s->qdsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\ s->h264qpel.put_h264_qpel_pixels_tab[0][dy+dx/4];\ s->qdsp.put_qpel_pixels_tab [1][dy+dx/4]=\ s->qdsp.put_no_rnd_qpel_pixels_tab[1][dy+dx/4]=\ s->h264qpel.put_h264_qpel_pixels_tab[1][dy+dx/4]; mcf( 0, 0) mcf( 4, 0) mcf( 8, 0) mcf(12, 0) mcf( 0, 4) mcf( 4, 4) mcf( 8, 4) mcf(12, 4) mcf( 0, 8) mcf( 4, 8) mcf( 8, 8) mcf(12, 8) mcf( 0,12) mcf( 4,12) mcf( 8,12) mcf(12,12) #define mcfh(dx,dy)\ s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\ s->hdsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\ mc_block_hpel ## dx ## dy ## 16;\ s->hdsp.put_pixels_tab [1][dy/4+dx/8]=\ s->hdsp.put_no_rnd_pixels_tab[1][dy/4+dx/8]=\ mc_block_hpel ## dx ## dy ## 8; mcfh(0, 0) mcfh(8, 0) mcfh(0, 8) mcfh(8, 8) init_qexp(); width= s->avctx->width; height= s->avctx->height; FF_ALLOCZ_ARRAY_OR_GOTO(avctx, s->spatial_idwt_buffer, width, height * sizeof(IDWTELEM), fail); FF_ALLOCZ_ARRAY_OR_GOTO(avctx, s->spatial_dwt_buffer, width, height * sizeof(DWTELEM), fail); FF_ALLOCZ_ARRAY_OR_GOTO(avctx, s->temp_dwt_buffer, width, sizeof(DWTELEM), fail); FF_ALLOCZ_ARRAY_OR_GOTO(avctx, s->temp_idwt_buffer, width, sizeof(IDWTELEM), fail); FF_ALLOC_ARRAY_OR_GOTO(avctx, s->run_buffer, ((width + 1) >> 1), ((height + 1) >> 1) * sizeof(*s->run_buffer), fail); for(i=0; i<MAX_REF_FRAMES; i++) { for(j=0; j<MAX_REF_FRAMES; j++) ff_scale_mv_ref[i][j] = 256*(i+1)/(j+1); s->last_picture[i] = av_frame_alloc(); if (!s->last_picture[i]) goto fail; } s->mconly_picture = av_frame_alloc(); s->current_picture = av_frame_alloc(); if (!s->mconly_picture || !s->current_picture) goto fail; return 0; fail: return AVERROR(ENOMEM); }
1threat
How to best program a and b or not a and c : What would be the best approach to set a boolean variable that is supposed to be true for **(a && b) || (!a && c)**. My first idea would be to simply write it down like that: $result = ($a && $b) || (!$a && $c); But would it be in any way better or more time efficient to do something like this: $result = false; if ( $a ) { $result = $b; } else { $result = $c; }
0debug
XSD - xs:all rewritten in [sequence + choice] or [dtd] : Short and **heavy** (at least for me right now). As the title describes, I try to get rid of `<xs:all>` in following xsd part: <xs:element name="root"> <xs:complexType> <xs:all> <xs:element minOccurs="1" name="box-type-1"/> <xs:element minOccurs="0" name="box-type-2"/> <xs:element minOccurs="0" name="box-type-3"/> <xs:element minOccurs="0" name="box-type-4"/> </xs:all> </xs:complextype> </xs:element> A big help would be: - The really identical construct of the <xs:all> in a `<xs:sequence>` + `<xs:choice>` style. AFAIK it's possible, correct me if not. - http://stackoverflow.com/a/7833274/6805256 This answer shows the DTD equivalent of a similar schema. Then I convert the valid and non corrupt DTD via oxygen to a xsd schema. [Output of the generated xsd is a version without any '<xs:all>'. (that roundtripping...)] **BUT** i can't adapt it to my needs and precise case. Further more: I need the non-xs:all variant in an online editor that can't handle '<xs:all>' at all. YES it will be a huge overload and not maintainable. + too bad i can't show you my browser history about this topic to show any effort. i wouldn't ask, if i would be able to solve.
0debug
static bool use_exit_tb(DisasContext *ctx) { return ((ctx->base.tb->cflags & CF_LAST_IO) || ctx->base.singlestep_enabled || singlestep); }
1threat
static int theora_decode_tables(AVCodecContext *avctx, GetBitContext gb) { Vp3DecodeContext *s = avctx->priv_data; int i, n, matrices; if (s->theora >= 0x030200) { n = get_bits(&gb, 3); for (i = 0; i < 64; i++) s->filter_limit_values[i] = get_bits(&gb, n); } if (s->theora >= 0x030200) n = get_bits(&gb, 4) + 1; else n = 16; for (i = 0; i < 64; i++) s->coded_ac_scale_factor[i] = get_bits(&gb, n); if (s->theora >= 0x030200) n = get_bits(&gb, 4) + 1; else n = 16; for (i = 0; i < 64; i++) s->coded_dc_scale_factor[i] = get_bits(&gb, n); if (s->theora >= 0x030200) matrices = get_bits(&gb, 9) + 1; else matrices = 3; if (matrices != 3) { av_log(avctx,AV_LOG_ERROR, "unsupported matrices: %d\n", matrices); } for (i = 0; i < 64; i++) s->coded_intra_y_dequant[i] = get_bits(&gb, 8); for (i = 0; i < 64; i++) s->coded_intra_c_dequant[i] = get_bits(&gb, 8); for (i = 0; i < 64; i++) s->coded_inter_dequant[i] = get_bits(&gb, 8); n = matrices - 3; while(n--) for (i = 0; i < 64; i++) skip_bits(&gb, 8); for (i = 0; i <= 1; i++) { for (n = 0; n <= 2; n++) { int newqr; if (i > 0 || n > 0) newqr = get_bits(&gb, 1); else newqr = 1; if (!newqr) { if (i > 0) get_bits(&gb, 1); } else { int qi = 0; skip_bits(&gb, av_log2(matrices-1)+1); while (qi < 63) { qi += get_bits(&gb, av_log2(63-qi)+1) + 1; skip_bits(&gb, av_log2(matrices-1)+1); } if (qi > 63) { av_log(avctx, AV_LOG_ERROR, "invalid qi %d > 63\n", qi); return -1; } } } } for (s->hti = 0; s->hti < 80; s->hti++) { s->entries = 0; s->huff_code_size = 1; if (!get_bits(&gb, 1)) { s->hbits = 0; read_huffman_tree(avctx, &gb); s->hbits = 1; read_huffman_tree(avctx, &gb); } } s->theora_tables = 1; return 0; }
1threat
static void sdp_service_record_build(struct sdp_service_record_s *record, struct sdp_def_service_s *def, int handle) { int len = 0; uint8_t *data; int *uuid; record->uuids = 0; while (def->attributes[record->attributes].data.type) { len += 3; len += sdp_attr_max_size(&def->attributes[record->attributes ++].data, &record->uuids); } record->uuids = pow2ceil(record->uuids); record->attribute_list = g_malloc0(record->attributes * sizeof(*record->attribute_list)); record->uuid = g_malloc0(record->uuids * sizeof(*record->uuid)); data = g_malloc(len); record->attributes = 0; uuid = record->uuid; while (def->attributes[record->attributes].data.type) { record->attribute_list[record->attributes].pair = data; len = 0; data[len ++] = SDP_DTYPE_UINT | SDP_DSIZE_2; data[len ++] = def->attributes[record->attributes].id >> 8; data[len ++] = def->attributes[record->attributes].id & 0xff; len += sdp_attr_write(data + len, &def->attributes[record->attributes].data, &uuid); if (def->attributes[record->attributes].id == SDP_ATTR_RECORD_HANDLE) def->attributes[record->attributes].data.value.uint = handle; record->attribute_list[record->attributes ++].len = len; data += len; } qsort(record->attribute_list, record->attributes, sizeof(*record->attribute_list), (void *) sdp_attributeid_compare); qsort(record->uuid, record->uuids, sizeof(*record->uuid), (void *) sdp_uuid_compare); }
1threat
How build older version projects in VS2015 : <p>I am trying to compile this <a href="https://code.msdn.microsoft.com/Using-the-DropDownList-67f9367d" rel="nofollow noreferrer">old project(link to old project)</a> But I am getting a lot of missing namespaces which cannot be resolved. Usually, when I open older projects I can resolve these by clicking the lightbulb and import correct namespace but there are none suggested.</p>
0debug
static int pick_geometry(FDrive *drv) { BlockBackend *blk = drv->blk; const FDFormat *parse; uint64_t nb_sectors, size; int i; int match, size_match, type_match; bool magic = drv->drive == FLOPPY_DRIVE_TYPE_AUTO; if (!drv->blk || !blk_is_inserted(drv->blk) || drv->drive == FLOPPY_DRIVE_TYPE_NONE) { return -1; } blk_get_geometry(blk, &nb_sectors); match = size_match = type_match = -1; for (i = 0; ; i++) { parse = &fd_formats[i]; if (parse->drive == FLOPPY_DRIVE_TYPE_NONE) { break; } size = (parse->max_head + 1) * parse->max_track * parse->last_sect; if (nb_sectors == size) { if (magic || parse->drive == drv->drive) { goto out; } else if (drive_size(parse->drive) == drive_size(drv->drive)) { match = (match == -1) ? i : match; } else { size_match = (size_match == -1) ? i : size_match; } } else if (type_match == -1) { if ((parse->drive == drv->drive) || (magic && (parse->drive == get_fallback_drive_type(drv)))) { type_match = i; } } } if (match == -1) { if (size_match != -1) { parse = &fd_formats[size_match]; FLOPPY_DPRINTF("User requested floppy drive type '%s', " "but inserted medium appears to be a " "%d sector '%s' type\n", FloppyDriveType_lookup[drv->drive], nb_sectors, FloppyDriveType_lookup[parse->drive]); } match = type_match; } if (match == -1) { error_setg(&error_abort, "No candidate geometries present in table " " for floppy drive type '%s'", FloppyDriveType_lookup[drv->drive]); } parse = &(fd_formats[match]); out: if (parse->max_head == 0) { drv->flags &= ~FDISK_DBL_SIDES; } else { drv->flags |= FDISK_DBL_SIDES; } drv->max_track = parse->max_track; drv->last_sect = parse->last_sect; drv->disk = parse->drive; drv->media_rate = parse->rate; return 0; }
1threat