problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static uint8_t get_tlm(Jpeg2000DecoderContext *s, int n)
{
uint8_t Stlm, ST, SP, tile_tlm, i;
bytestream_get_byte(&s->buf);
Stlm = bytestream_get_byte(&s->buf);
ST = (Stlm >> 4) & 0x03;
SP = (Stlm >> 6) & 0x01;
tile_tlm = (n - 4) / ((SP + 1) * 2 + ST);
for (i = 0; i < tile_tlm; i++) {
switch (ST) {
case 0:
break;
case 1:
bytestream_get_byte(&s->buf);
break;
case 2:
bytestream_get_be16(&s->buf);
break;
case 3:
bytestream_get_be32(&s->buf);
break;
}
if (SP == 0) {
bytestream_get_be16(&s->buf);
} else {
bytestream_get_be32(&s->buf);
}
}
return 0;
}
| 1threat
|
Android project with Java and Kotlin files, kapt or annotationProcessor? : <p>I would like to know if in an <strong>Android</strong> project mixing <strong>Java</strong> and <strong>Kotlin</strong> files we must use annotationProcessor or kapt, or both ? </p>
<p>In my understanding <strong>annotationProcessor</strong> must be used for <strong>Java</strong> files using annotations for code generation, and <strong>kapt</strong> must be used for <strong>Kotlin</strong> files using annotations for code generation.</p>
<p>I have a project mixing both languages, and I just have replaced all the annotationProcessor dependencies in the build.gradle by kapt.
Surprisingly it builds and seems to run correctly but I do not understand why kapt works well even with Java files... </p>
<p>Can someone explain to me ?</p>
<p>Thank you</p>
| 0debug
|
Add a new CSS class in Chrome developer tool : <p>Is it possible to add a whole new CSS class like this in Chrome dev tools?</p>
<pre><code>.myclass {
background-color: yellow;
}
</code></pre>
| 0debug
|
static int adts_aac_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, fsize;
ret = av_get_packet(s->pb, pkt, ADTS_HEADER_SIZE);
if (ret < 0)
return ret;
if (ret < ADTS_HEADER_SIZE) {
av_packet_unref(pkt);
return AVERROR(EIO);
}
if ((AV_RB16(pkt->data) >> 4) != 0xfff) {
av_packet_unref(pkt);
return AVERROR_INVALIDDATA;
}
fsize = (AV_RB32(pkt->data + 3) >> 13) & 0x1FFF;
if (fsize < ADTS_HEADER_SIZE) {
av_packet_unref(pkt);
return AVERROR_INVALIDDATA;
}
return av_append_packet(s->pb, pkt, fsize - ADTS_HEADER_SIZE);
}
| 1threat
|
SQL query in Spark/scala Size exceeds Integer.MAX_VALUE : <p>I am trying to create a simple sql query on S3 events using Spark. I am loading ~30GB of JSON files as following:</p>
<pre><code>val d2 = spark.read.json("s3n://myData/2017/02/01/1234");
d2.persist(org.apache.spark.storage.StorageLevel.MEMORY_AND_DISK);
d2.registerTempTable("d2");
</code></pre>
<p>Then I am trying to write to file the result of my query:</p>
<pre><code>val users_count = sql("select count(distinct data.user_id) from d2");
users_count.write.format("com.databricks.spark.csv").option("header", "true").save("s3n://myfolder/UsersCount.csv");
</code></pre>
<p>But Spark is throwing the following exception:</p>
<pre><code>java.lang.IllegalArgumentException: Size exceeds Integer.MAX_VALUE
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:869)
at org.apache.spark.storage.DiskStore$$anonfun$getBytes$2.apply(DiskStore.scala:103)
at org.apache.spark.storage.DiskStore$$anonfun$getBytes$2.apply(DiskStore.scala:91)
at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1287)
at org.apache.spark.storage.DiskStore.getBytes(DiskStore.scala:105)
at org.apache.spark.storage.BlockManager.getLocalValues(BlockManager.scala:439)
at org.apache.spark.storage.BlockManager.getOrElseUpdate(BlockManager.scala:672)
at org.apache.spark.rdd.RDD.getOrCompute(RDD.scala:330)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:281)
at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:38)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:319)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:283)
at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:38)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:319)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:283)
at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:38)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:319)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:283)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:79)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:47)
at org.apache.spark.scheduler.Task.run(Task.scala:85)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:274)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
</code></pre>
<p>Note that the same query works for smaller amounts of data. What's the problem here?</p>
| 0debug
|
Difference between pull and select in dplyr? : <p>It seems like <code>dplyr::pull()</code> and <code>dplyr::select()</code> do the same thing. Is there a difference besides that <code>dplyr::pull()</code> only selects 1 variable?</p>
| 0debug
|
static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
uint16_t vendor, uint16_t device,
uint16_t class_code, uint8_t pif)
{
uint8_t *config;
uint32_t size;
proxy->vdev = vdev;
config = proxy->pci_dev.config;
pci_config_set_vendor_id(config, vendor);
pci_config_set_device_id(config, device);
config[0x08] = VIRTIO_PCI_ABI_VERSION;
config[0x09] = pif;
pci_config_set_class(config, class_code);
config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL;
config[0x2c] = vendor & 0xFF;
config[0x2d] = (vendor >> 8) & 0xFF;
config[0x2e] = vdev->device_id & 0xFF;
config[0x2f] = (vdev->device_id >> 8) & 0xFF;
config[0x3d] = 1;
if (vdev->nvectors && !msix_init(&proxy->pci_dev, vdev->nvectors, 1, 0,
TARGET_PAGE_SIZE)) {
pci_register_bar(&proxy->pci_dev, 1,
msix_bar_size(&proxy->pci_dev),
PCI_ADDRESS_SPACE_MEM,
msix_mmio_map);
} else
vdev->nvectors = 0;
proxy->pci_dev.config_write = virtio_write_config;
size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev) + vdev->config_len;
if (size & (size-1))
size = 1 << qemu_fls(size);
pci_register_bar(&proxy->pci_dev, 0, size, PCI_ADDRESS_SPACE_IO,
virtio_map);
qemu_register_reset(virtio_pci_reset, proxy);
virtio_bind_device(vdev, &virtio_pci_bindings, proxy);
}
| 1threat
|
static void free_field_queue(PullupField *head, PullupField **last)
{
PullupField *f = head;
while (f) {
av_free(f->diffs);
av_free(f->combs);
av_free(f->vars);
if (f == *last) {
av_freep(last);
break;
}
f = f->next;
av_freep(&f->prev);
};
}
| 1threat
|
What is the difference between Jest Mock functions and Sinon spies : <p>I am mocking a function with Jest and the documentation says they are really 'spies'. I have also seen the use of spies in SinonJS but I could find no clear difference between the two. If they are serving the same purpose, is there any reason to choose one over the other?</p>
<p><a href="http://facebook.github.io/jest/docs/mock-function-api.html#mockfnmockimplementationfn" rel="noreferrer">Jest Mock Functions</a></p>
<p><a href="http://sinonjs.org/" rel="noreferrer">SinonJS</a></p>
| 0debug
|
int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, int *pnum)
{
Coroutine *co;
BdrvCoGetBlockStatusData data = {
.bs = bs,
.sector_num = sector_num,
.nb_sectors = nb_sectors,
.pnum = pnum,
.done = false,
};
if (qemu_in_coroutine()) {
bdrv_get_block_status_co_entry(&data);
} else {
co = qemu_coroutine_create(bdrv_get_block_status_co_entry);
qemu_coroutine_enter(co, &data);
while (!data.done) {
qemu_aio_wait();
}
}
return data.ret;
}
| 1threat
|
criteria 1:= Array("<>David","<>Steven") .... Isn't working in vb Macro excel : Please help me, why not working when I give comparison not equals in Array by Filter.
VB macro excel
| 0debug
|
Java "If" and "ReseltSet" code Error : Plz help me.... this code no error shows... but when its run and finished it show error.
this is my code:[enter image description here][1]
this is error:[enter image description here][2]
[1]: https://i.stack.imgur.com/coVMg.png
[2]: https://i.stack.imgur.com/8COxh.png
| 0debug
|
I am confused on something very simple, how do i add something after an input in javascript? : An example would be if I type !greet user1 it would output "Hello user1" and if i input !greet Bob it would output "Hello Bob". I have searched the internet but it always leads to something that says the exact same thing regardless of what you type. I am new to this kind of thing and greatly appreciate your help. If it matters i am using Atom editor to edit the code and node.js so i can port it into a discord bot.
| 0debug
|
C++ -- New line seen in command prompt but the same string is seen with \n in file output : I have this code which runs fine
#include <iostream>
#include <set>
#include <sstream>
int main()
{
std::set<std::string> a;
a.insert("foo");
a.insert("bar");
a.insert("zoo");
a.insert("should");
a.insert("work");
std::stringstream b;
std::set<std::string>::iterator it;
for (it = a.begin(); it != a.end(); it++)
{
b << " " << *it <<"," <<"\n";
}
std::string aaa = b.str();
std::cout <<aaa;
}
**Output in command prompt:**
bar, //new line after ","
foo, //new line after ","
should,
work,
zoo,
If I try to write the same string aaa in file I am expecting the same output to get print in the file i.e. every string after "," in new line, rather I am getting output in my file as follows (In single line with \n):
" bar,\n foo,\n should,\n work,\n zoo,\n"
Can anyone help me with this?
Thanks.
| 0debug
|
Ruby- String .Match() function cannot match when a String Contains Text After Parenthesis : guys!
I am trying to match strings and I have come across an interesting issue that I have never seen before.
This works:
str= "California (LA) rocks"
match_string="rocks"
str.match(match_string)
=> #<MatchData "rocks">
Why does this not work (which I really want it to work):
match_string="(LA) rocks"
str.match(match_string)
=> nil
| 0debug
|
return vs do nothing after if statement : <p>What is the difference between these two functions in terms of code execution. The result is the same, but will the compiler optimize both to the same outputted assembly?</p>
<pre><code>void some_func()
{
if (!something)
return;
//rest of code
}
void other_func()
{
if (something) {
//rest of code
}
}
</code></pre>
| 0debug
|
Module not found: Error: Can't resolve '@angular/animations' : <p>After using "npm install" and starting local server by "npm start" I started getting this error:-</p>
<pre><code>ERROR in ./~/@angular/material/@angular/material.es5.js
Module not found: Error: Can't resolve '@angular/animations' in '/home/ashvini/Desktop/HN-Angular2/node_modules/@angular/material/@angular'
@ ./~/@angular/material/@angular/material.es5.js 20:0-81
@ ./src/app/app.module.ts
@ ./src/main.ts`enter code here`
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
webpack: Failed to compile.
</code></pre>
<p>This is related to angular material design but I am not able to understand what I need to do to resolve this issue.</p>
<p>Before "npm install" it was working fine.</p>
| 0debug
|
How can I check same elements in Array? : <p>I have an array, and I want an output if it contains more than 1 of the same element.</p>
<p>Example:</p>
<pre><code>my_array = [1, 2, 3, 1];
</code></pre>
| 0debug
|
Arduino App with Android, Android Studio or App Inventor? : <p>Which is more convenient to use for an Android app for Arduino, Android Studio or App Inventor.</p>
<p>I have made apps with both.</p>
| 0debug
|
What's the difference between mustRunAfter and dependsOn in Gradle? : <p>Whether taskB mustRunAfter taskA, or taskB dependsOn taskA, it seems that taskA runs first, then taskB runs. What's the difference?</p>
| 0debug
|
Transparent PageRoute in Flutter for displaying a (semi-) transparent page : <p>Would it be possible to have a page route with a transparent background so I can show a (semi-)transparent page on top of an existing page?</p>
<p><a href="https://i.stack.imgur.com/Mu2NE.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Mu2NE.jpg" alt="semi-transparent screen transition"></a></p>
| 0debug
|
void qemu_cond_broadcast(QemuCond *cond)
{
BOOLEAN result;
if (cond->waiters == 0) {
return;
}
cond->target = 0;
result = ReleaseSemaphore(cond->sema, cond->waiters, NULL);
if (!result) {
error_exit(GetLastError(), __func__);
}
WaitForSingleObject(cond->continue_event, INFINITE);
}
| 1threat
|
static void mainstone_common_init(int ram_size, int vga_ram_size,
DisplayState *ds, const char *kernel_filename,
const char *kernel_cmdline, const char *initrd_filename,
const char *cpu_model, enum mainstone_model_e model, int arm_id)
{
uint32_t mainstone_ram = 0x04000000;
uint32_t mainstone_rom = 0x00800000;
struct pxa2xx_state_s *cpu;
qemu_irq *mst_irq;
int index;
if (!cpu_model)
cpu_model = "pxa270-c5";
if (ram_size < mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE) {
fprintf(stderr, "This platform requires %i bytes of memory\n",
mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE);
exit(1);
}
cpu = pxa270_init(mainstone_ram, ds, cpu_model);
cpu_register_physical_memory(0, mainstone_rom,
qemu_ram_alloc(mainstone_rom) | IO_MEM_ROM);
cpu->env->regs[15] = PXA2XX_SDRAM_BASE;
index = drive_get_index(IF_PFLASH, 0, 0);
if (index == -1) {
fprintf(stderr, "Two flash images must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_register(MST_FLASH_0, mainstone_ram + PXA2XX_INTERNAL_SIZE,
drives_table[index].bdrv,
256 * 1024, 128, 4, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
index = drive_get_index(IF_PFLASH, 0, 1);
if (index == -1) {
fprintf(stderr, "Two flash images must be given with the "
"'pflash' parameter\n");
exit(1);
}
if (!pflash_register(MST_FLASH_1, mainstone_ram + PXA2XX_INTERNAL_SIZE,
drives_table[index].bdrv,
256 * 1024, 128, 4, 0, 0, 0, 0)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
exit(1);
}
mst_irq = mst_irq_init(cpu, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0);
pxa2xx_mmci_handlers(cpu->mmc, mst_irq[MMC_IRQ], mst_irq[MMC_IRQ]);
smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]);
arm_load_kernel(cpu->env, mainstone_ram, kernel_filename, kernel_cmdline,
initrd_filename, arm_id, PXA2XX_SDRAM_BASE);
}
| 1threat
|
Wordpress Column shortcodes not displaying the proper size : <p>I have a column shortcode plugin but the one_half column shortcodes seem to be going too long in the content area and dipping down to the next line when there are 2 "one_half" columns next to each other. What could be causing this? You can see the issue here <a href="https://shuttleexpress.com/seattle/corporate-event/large-group-charters-for-corporates-and-events/" rel="nofollow noreferrer">https://shuttleexpress.com/seattle/corporate-event/large-group-charters-for-corporates-and-events/</a> where the benefits and book ahead should be on the same row.</p>
| 0debug
|
static int local_symlink(FsContext *ctx, const char *oldpath,
const char *newpath)
{
return symlink(oldpath, rpath(ctx, newpath));
}
| 1threat
|
import math
def tn_gp(a,n,r):
tn = a * (math.pow(r, n - 1))
return tn
| 0debug
|
static int check_slice_end(RV34DecContext *r, MpegEncContext *s)
{
int bits;
if(s->mb_y >= s->mb_height)
return 1;
if(!s->mb_num_left)
return 1;
if(r->s.mb_skip_run > 1)
return 0;
bits = get_bits_left(&s->gb);
if(bits < 0 || (bits < 8 && !show_bits(&s->gb, bits)))
return 1;
return 0;
}
| 1threat
|
haw to insialase a recorde table on pl/sql? : SET ServerOutPut ON;
DECLARE
TYPE enreg IS RECORD
(mot varchar(30),sig varchar(30));
TYPE tab IS TABLE OF enreg;
t tab := tab({'html','html'},{'css','css'});
BEGIN
Dbms_output.put_line(t(1).mot) ;
END;
| 0debug
|
Export to csv/excel from kibana : <p>I am building a proof of concept using Elasticsearch Logstash and Kibana for one of my projects. I have the dashboard with the graphs working without any issue. One of the requirements for my project is the ability to download the file(csv/excel).
In kibana the only option i saw for downloading the file is by clicking on edit button on the visualization created. Is it possible to add a link on the dashboard that would allow users to download the file without going into the edit mode. And secondly I would like to disable/hide the edit mode for anyone other than me who views the dashboard.
Thanks</p>
| 0debug
|
How much time to approve my app on google play? : <p>I have released my first android app on google play two days ago but it has not approved yet. Is that normal? how much time will i wait more?</p>
| 0debug
|
Swift: index(of:) doesn't exist? : <p>I keep trying to use index(of:) on Array objects but it doesn't come up in the autocomplete (or whatever that menu is called) and, of course, doesn't build. I see it right there in the documentation! It's there! I want it! What's going on here?</p>
<p>(Btw this isn't the only Array method I can't access. For just one example, I can't use suffix(from:), I can only use suffix(maxLength:), plus it's implemented as suffix(_ maxLength:) even though the documentation lists it as requiring an argument name)</p>
| 0debug
|
static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
{
int32_t disp21, disp16, disp12 __attribute__((unused));
uint16_t fn11;
uint8_t opc, ra, rb, rc, fpfn, fn7, lit;
bool islit, real_islit;
TCGv va, vb, vc, tmp, tmp2;
TCGv_i32 t32;
DisasJumpType ret;
opc = extract32(insn, 26, 6);
ra = extract32(insn, 21, 5);
rb = extract32(insn, 16, 5);
rc = extract32(insn, 0, 5);
real_islit = islit = extract32(insn, 12, 1);
lit = extract32(insn, 13, 8);
disp21 = sextract32(insn, 0, 21);
disp16 = sextract32(insn, 0, 16);
disp12 = sextract32(insn, 0, 12);
fn11 = extract32(insn, 5, 11);
fpfn = extract32(insn, 5, 6);
fn7 = extract32(insn, 5, 7);
if (rb == 31 && !islit) {
islit = true;
lit = 0;
}
ret = DISAS_NEXT;
switch (opc) {
case 0x00:
ret = gen_call_pal(ctx, insn & 0x03ffffff);
break;
case 0x01:
goto invalid_opc;
case 0x02:
goto invalid_opc;
case 0x03:
goto invalid_opc;
case 0x04:
goto invalid_opc;
case 0x05:
goto invalid_opc;
case 0x06:
goto invalid_opc;
case 0x07:
goto invalid_opc;
case 0x09:
disp16 = (uint32_t)disp16 << 16;
case 0x08:
va = dest_gpr(ctx, ra);
if (rb == 31) {
tcg_gen_movi_i64(va, disp16);
} else {
tcg_gen_addi_i64(va, load_gpr(ctx, rb), disp16);
}
break;
case 0x0A:
REQUIRE_AMASK(BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0);
break;
case 0x0B:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1);
break;
case 0x0C:
REQUIRE_AMASK(BWX);
gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 0);
break;
case 0x0D:
REQUIRE_AMASK(BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0);
break;
case 0x0E:
REQUIRE_AMASK(BWX);
gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0);
break;
case 0x0F:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1);
break;
case 0x10:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (ra == 31) {
if (fn7 == 0x00) {
tcg_gen_ext32s_i64(vc, vb);
break;
}
if (fn7 == 0x29) {
tcg_gen_neg_i64(vc, vb);
break;
}
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_add_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x02:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x09:
tcg_gen_sub_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x0B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x0F:
if (ra == 31) {
gen_helper_cmpbe0(vc, vb);
} else {
gen_helper_cmpbge(vc, va, vb);
}
break;
case 0x12:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(tmp, tmp, vb);
tcg_gen_ext32s_i64(vc, tmp);
tcg_temp_free(tmp);
break;
case 0x1D:
tcg_gen_setcond_i64(TCG_COND_LTU, vc, va, vb);
break;
case 0x20:
tcg_gen_add_i64(vc, va, vb);
break;
case 0x22:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x29:
tcg_gen_sub_i64(vc, va, vb);
break;
case 0x2B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 2);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x2D:
tcg_gen_setcond_i64(TCG_COND_EQ, vc, va, vb);
break;
case 0x32:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_add_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3B:
tmp = tcg_temp_new();
tcg_gen_shli_i64(tmp, va, 3);
tcg_gen_sub_i64(vc, tmp, vb);
tcg_temp_free(tmp);
break;
case 0x3D:
tcg_gen_setcond_i64(TCG_COND_LEU, vc, va, vb);
break;
case 0x40:
tmp = tcg_temp_new();
tcg_gen_ext32s_i64(tmp, va);
tcg_gen_ext32s_i64(vc, vb);
tcg_gen_add_i64(tmp, tmp, vc);
tcg_gen_ext32s_i64(vc, tmp);
gen_helper_check_overflow(cpu_env, vc, tmp);
tcg_temp_free(tmp);
break;
case 0x49:
tmp = tcg_temp_new();
tcg_gen_ext32s_i64(tmp, va);
tcg_gen_ext32s_i64(vc, vb);
tcg_gen_sub_i64(tmp, tmp, vc);
tcg_gen_ext32s_i64(vc, tmp);
gen_helper_check_overflow(cpu_env, vc, tmp);
tcg_temp_free(tmp);
break;
case 0x4D:
tcg_gen_setcond_i64(TCG_COND_LT, vc, va, vb);
break;
case 0x60:
tmp = tcg_temp_new();
tmp2 = tcg_temp_new();
tcg_gen_eqv_i64(tmp, va, vb);
tcg_gen_mov_i64(tmp2, va);
tcg_gen_add_i64(vc, va, vb);
tcg_gen_xor_i64(tmp2, tmp2, vc);
tcg_gen_and_i64(tmp, tmp, tmp2);
tcg_gen_shri_i64(tmp, tmp, 63);
tcg_gen_movi_i64(tmp2, 0);
gen_helper_check_overflow(cpu_env, tmp, tmp2);
tcg_temp_free(tmp);
tcg_temp_free(tmp2);
break;
case 0x69:
tmp = tcg_temp_new();
tmp2 = tcg_temp_new();
tcg_gen_xor_i64(tmp, va, vb);
tcg_gen_mov_i64(tmp2, va);
tcg_gen_sub_i64(vc, va, vb);
tcg_gen_xor_i64(tmp2, tmp2, vc);
tcg_gen_and_i64(tmp, tmp, tmp2);
tcg_gen_shri_i64(tmp, tmp, 63);
tcg_gen_movi_i64(tmp2, 0);
gen_helper_check_overflow(cpu_env, tmp, tmp2);
tcg_temp_free(tmp);
tcg_temp_free(tmp2);
break;
case 0x6D:
tcg_gen_setcond_i64(TCG_COND_LE, vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x11:
if (fn7 == 0x20) {
if (rc == 31) {
break;
}
if (ra == 31) {
vc = dest_gpr(ctx, rc);
if (islit) {
tcg_gen_movi_i64(vc, lit);
} else {
tcg_gen_mov_i64(vc, load_gpr(ctx, rb));
}
break;
}
}
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
if (fn7 == 0x28 && ra == 31) {
tcg_gen_not_i64(vc, vb);
break;
}
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_and_i64(vc, va, vb);
break;
case 0x08:
tcg_gen_andc_i64(vc, va, vb);
break;
case 0x14:
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x16:
tmp = tcg_temp_new();
tcg_gen_andi_i64(tmp, va, 1);
tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx),
vb, load_gpr(ctx, rc));
tcg_temp_free(tmp);
break;
case 0x20:
tcg_gen_or_i64(vc, va, vb);
break;
case 0x24:
tcg_gen_movcond_i64(TCG_COND_EQ, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x26:
tcg_gen_movcond_i64(TCG_COND_NE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x28:
tcg_gen_orc_i64(vc, va, vb);
break;
case 0x40:
tcg_gen_xor_i64(vc, va, vb);
break;
case 0x44:
tcg_gen_movcond_i64(TCG_COND_LT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x46:
tcg_gen_movcond_i64(TCG_COND_GE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x48:
tcg_gen_eqv_i64(vc, va, vb);
break;
case 0x61:
REQUIRE_REG_31(ra);
tcg_gen_andi_i64(vc, vb, ~ctx->amask);
break;
case 0x64:
tcg_gen_movcond_i64(TCG_COND_LE, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x66:
tcg_gen_movcond_i64(TCG_COND_GT, vc, va, load_zero(ctx),
vb, load_gpr(ctx, rc));
break;
case 0x6C:
REQUIRE_REG_31(ra);
tcg_gen_movi_i64(vc, ctx->implver);
break;
default:
goto invalid_opc;
}
break;
case 0x12:
vc = dest_gpr(ctx, rc);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x02:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x06:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x0B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x01);
break;
case 0x12:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x16:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x1B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x22:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x26:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x2B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x30:
if (islit) {
gen_zapnoti(vc, va, ~lit);
} else {
gen_helper_zap(vc, va, load_gpr(ctx, rb));
}
break;
case 0x31:
if (islit) {
gen_zapnoti(vc, va, lit);
} else {
gen_helper_zapnot(vc, va, load_gpr(ctx, rb));
}
break;
case 0x32:
gen_msk_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x34:
if (islit) {
tcg_gen_shri_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shr_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x36:
gen_ext_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x39:
if (islit) {
tcg_gen_shli_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_shl_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x3B:
gen_ins_l(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x3C:
if (islit) {
tcg_gen_sari_i64(vc, va, lit & 0x3f);
} else {
tmp = tcg_temp_new();
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(tmp, vb, 0x3f);
tcg_gen_sar_i64(vc, va, tmp);
tcg_temp_free(tmp);
}
break;
case 0x52:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x57:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x5A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x03);
break;
case 0x62:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x67:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x6A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0x0f);
break;
case 0x72:
gen_msk_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x77:
gen_ins_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
case 0x7A:
gen_ext_h(ctx, vc, va, rb, islit, lit, 0xff);
break;
default:
goto invalid_opc;
}
break;
case 0x13:
vc = dest_gpr(ctx, rc);
vb = load_gpr_lit(ctx, rb, lit, islit);
va = load_gpr(ctx, ra);
switch (fn7) {
case 0x00:
tcg_gen_mul_i64(vc, va, vb);
tcg_gen_ext32s_i64(vc, vc);
break;
case 0x20:
tcg_gen_mul_i64(vc, va, vb);
break;
case 0x30:
tmp = tcg_temp_new();
tcg_gen_mulu2_i64(tmp, vc, va, vb);
tcg_temp_free(tmp);
break;
case 0x40:
tmp = tcg_temp_new();
tcg_gen_ext32s_i64(tmp, va);
tcg_gen_ext32s_i64(vc, vb);
tcg_gen_mul_i64(tmp, tmp, vc);
tcg_gen_ext32s_i64(vc, tmp);
gen_helper_check_overflow(cpu_env, vc, tmp);
tcg_temp_free(tmp);
break;
case 0x60:
tmp = tcg_temp_new();
tmp2 = tcg_temp_new();
tcg_gen_muls2_i64(vc, tmp, va, vb);
tcg_gen_sari_i64(tmp2, vc, 63);
gen_helper_check_overflow(cpu_env, tmp, tmp2);
tcg_temp_free(tmp);
tcg_temp_free(tmp2);
break;
default:
goto invalid_opc;
}
break;
case 0x14:
REQUIRE_AMASK(FIX);
vc = dest_fpr(ctx, rc);
switch (fpfn) {
case 0x04:
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_extrl_i64_i32(t32, va);
gen_helper_memory_to_s(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x0A:
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtf(vc, cpu_env, vb);
break;
case 0x0B:
REQUIRE_REG_31(ra);
gen_sqrts(ctx, rb, rc, fn11);
break;
case 0x14:
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_gpr(ctx, ra);
tcg_gen_extrl_i64_i32(t32, va);
gen_helper_memory_to_f(vc, t32);
tcg_temp_free_i32(t32);
break;
case 0x24:
REQUIRE_REG_31(rb);
va = load_gpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
case 0x2A:
REQUIRE_REG_31(ra);
vb = load_fpr(ctx, rb);
gen_helper_sqrtg(vc, cpu_env, vb);
break;
case 0x02B:
REQUIRE_REG_31(ra);
gen_sqrtt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x15:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
switch (fpfn) {
case 0x00:
gen_helper_addf(vc, cpu_env, va, vb);
break;
case 0x01:
gen_helper_subf(vc, cpu_env, va, vb);
break;
case 0x02:
gen_helper_mulf(vc, cpu_env, va, vb);
break;
case 0x03:
gen_helper_divf(vc, cpu_env, va, vb);
break;
case 0x1E:
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x20:
gen_helper_addg(vc, cpu_env, va, vb);
break;
case 0x21:
gen_helper_subg(vc, cpu_env, va, vb);
break;
case 0x22:
gen_helper_mulg(vc, cpu_env, va, vb);
break;
case 0x23:
gen_helper_divg(vc, cpu_env, va, vb);
break;
case 0x25:
gen_helper_cmpgeq(vc, cpu_env, va, vb);
break;
case 0x26:
gen_helper_cmpglt(vc, cpu_env, va, vb);
break;
case 0x27:
gen_helper_cmpgle(vc, cpu_env, va, vb);
break;
case 0x2C:
REQUIRE_REG_31(ra);
gen_helper_cvtgf(vc, cpu_env, vb);
break;
case 0x2D:
REQUIRE_REG_31(ra);
goto invalid_opc;
case 0x2F:
REQUIRE_REG_31(ra);
gen_helper_cvtgq(vc, cpu_env, vb);
break;
case 0x3C:
REQUIRE_REG_31(ra);
gen_helper_cvtqf(vc, cpu_env, vb);
break;
case 0x3E:
REQUIRE_REG_31(ra);
gen_helper_cvtqg(vc, cpu_env, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x16:
switch (fpfn) {
case 0x00:
gen_adds(ctx, ra, rb, rc, fn11);
break;
case 0x01:
gen_subs(ctx, ra, rb, rc, fn11);
break;
case 0x02:
gen_muls(ctx, ra, rb, rc, fn11);
break;
case 0x03:
gen_divs(ctx, ra, rb, rc, fn11);
break;
case 0x20:
gen_addt(ctx, ra, rb, rc, fn11);
break;
case 0x21:
gen_subt(ctx, ra, rb, rc, fn11);
break;
case 0x22:
gen_mult(ctx, ra, rb, rc, fn11);
break;
case 0x23:
gen_divt(ctx, ra, rb, rc, fn11);
break;
case 0x24:
gen_cmptun(ctx, ra, rb, rc, fn11);
break;
case 0x25:
gen_cmpteq(ctx, ra, rb, rc, fn11);
break;
case 0x26:
gen_cmptlt(ctx, ra, rb, rc, fn11);
break;
case 0x27:
gen_cmptle(ctx, ra, rb, rc, fn11);
break;
case 0x2C:
REQUIRE_REG_31(ra);
if (fn11 == 0x2AC || fn11 == 0x6AC) {
gen_cvtst(ctx, rb, rc, fn11);
} else {
gen_cvtts(ctx, rb, rc, fn11);
}
break;
case 0x2F:
REQUIRE_REG_31(ra);
gen_cvttq(ctx, rb, rc, fn11);
break;
case 0x3C:
REQUIRE_REG_31(ra);
gen_cvtqs(ctx, rb, rc, fn11);
break;
case 0x3E:
REQUIRE_REG_31(ra);
gen_cvtqt(ctx, rb, rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x17:
switch (fn11) {
case 0x010:
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_cvtlq(vc, vb);
break;
case 0x020:
if (rc == 31) {
} else {
vc = dest_fpr(ctx, rc);
va = load_fpr(ctx, ra);
if (ra == rb) {
tcg_gen_mov_i64(vc, va);
} else {
vb = load_fpr(ctx, rb);
gen_cpy_mask(vc, va, vb, 0, 0x8000000000000000ULL);
}
}
break;
case 0x021:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 1, 0x8000000000000000ULL);
break;
case 0x022:
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
va = load_fpr(ctx, ra);
gen_cpy_mask(vc, va, vb, 0, 0xFFF0000000000000ULL);
break;
case 0x024:
va = load_fpr(ctx, ra);
gen_helper_store_fpcr(cpu_env, va);
if (ctx->tb_rm == QUAL_RM_D) {
ctx->tb_rm = -1;
}
break;
case 0x025:
va = dest_fpr(ctx, ra);
gen_helper_load_fpcr(va, cpu_env);
break;
case 0x02A:
gen_fcmov(ctx, TCG_COND_EQ, ra, rb, rc);
break;
case 0x02B:
gen_fcmov(ctx, TCG_COND_NE, ra, rb, rc);
break;
case 0x02C:
gen_fcmov(ctx, TCG_COND_LT, ra, rb, rc);
break;
case 0x02D:
gen_fcmov(ctx, TCG_COND_GE, ra, rb, rc);
break;
case 0x02E:
gen_fcmov(ctx, TCG_COND_LE, ra, rb, rc);
break;
case 0x02F:
gen_fcmov(ctx, TCG_COND_GT, ra, rb, rc);
break;
case 0x030:
case 0x130:
case 0x530:
REQUIRE_REG_31(ra);
vc = dest_fpr(ctx, rc);
vb = load_fpr(ctx, rb);
gen_helper_cvtql(vc, cpu_env, vb);
gen_fp_exc_raise(rc, fn11);
break;
default:
goto invalid_opc;
}
break;
case 0x18:
switch ((uint16_t)disp16) {
case 0x0000:
break;
case 0x0400:
break;
case 0x4000:
tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
break;
case 0x4400:
tcg_gen_mb(TCG_MO_ST_ST | TCG_BAR_SC);
break;
case 0x8000:
break;
case 0xA000:
break;
case 0xC000:
va = dest_gpr(ctx, ra);
if (ctx->base.tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
gen_helper_load_pcc(va, cpu_env);
gen_io_end();
ret = DISAS_PC_STALE;
} else {
gen_helper_load_pcc(va, cpu_env);
}
break;
case 0xE000:
gen_rx(ctx, ra, 0);
break;
case 0xE800:
break;
case 0xF000:
gen_rx(ctx, ra, 1);
break;
case 0xF800:
break;
case 0xFC00:
break;
default:
goto invalid_opc;
}
break;
case 0x19:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
va = dest_gpr(ctx, ra);
ret = gen_mfpr(ctx, va, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1A:
vb = load_gpr(ctx, rb);
tcg_gen_andi_i64(cpu_pc, vb, ~3);
if (ra != 31) {
tcg_gen_movi_i64(ctx->ir[ra], ctx->base.pc_next);
}
ret = DISAS_PC_UPDATED;
break;
case 0x1B:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
{
TCGv addr = tcg_temp_new();
vb = load_gpr(ctx, rb);
va = dest_gpr(ctx, ra);
tcg_gen_addi_i64(addr, vb, disp12);
switch ((insn >> 12) & 0xF) {
case 0x0:
tcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LESL);
break;
case 0x1:
tcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LEQ);
break;
case 0x2:
gen_qemu_ldl_l(va, addr, MMU_PHYS_IDX);
break;
case 0x3:
gen_qemu_ldq_l(va, addr, MMU_PHYS_IDX);
break;
case 0x4:
goto invalid_opc;
case 0x5:
goto invalid_opc;
break;
case 0x6:
goto invalid_opc;
case 0x7:
goto invalid_opc;
case 0x8:
goto invalid_opc;
case 0x9:
goto invalid_opc;
case 0xA:
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LESL);
break;
case 0xB:
tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX, MO_LEQ);
break;
case 0xC:
goto invalid_opc;
case 0xD:
goto invalid_opc;
case 0xE:
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LESL);
break;
case 0xF:
tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX, MO_LEQ);
break;
}
tcg_temp_free(addr);
break;
}
#else
goto invalid_opc;
#endif
case 0x1C:
vc = dest_gpr(ctx, rc);
if (fn7 == 0x70) {
REQUIRE_AMASK(FIX);
REQUIRE_REG_31(rb);
va = load_fpr(ctx, ra);
tcg_gen_mov_i64(vc, va);
break;
} else if (fn7 == 0x78) {
REQUIRE_AMASK(FIX);
REQUIRE_REG_31(rb);
t32 = tcg_temp_new_i32();
va = load_fpr(ctx, ra);
gen_helper_s_to_memory(t32, va);
tcg_gen_ext_i32_i64(vc, t32);
tcg_temp_free_i32(t32);
break;
}
vb = load_gpr_lit(ctx, rb, lit, islit);
switch (fn7) {
case 0x00:
REQUIRE_AMASK(BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext8s_i64(vc, vb);
break;
case 0x01:
REQUIRE_AMASK(BWX);
REQUIRE_REG_31(ra);
tcg_gen_ext16s_i64(vc, vb);
break;
case 0x30:
REQUIRE_AMASK(CIX);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
tcg_gen_ctpop_i64(vc, vb);
break;
case 0x31:
REQUIRE_AMASK(MVI);
REQUIRE_NO_LIT;
va = load_gpr(ctx, ra);
gen_helper_perr(vc, va, vb);
break;
case 0x32:
REQUIRE_AMASK(CIX);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
tcg_gen_clzi_i64(vc, vb, 64);
break;
case 0x33:
REQUIRE_AMASK(CIX);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
tcg_gen_ctzi_i64(vc, vb, 64);
break;
case 0x34:
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_unpkbw(vc, vb);
break;
case 0x35:
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_unpkbl(vc, vb);
break;
case 0x36:
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_pkwb(vc, vb);
break;
case 0x37:
REQUIRE_AMASK(MVI);
REQUIRE_REG_31(ra);
REQUIRE_NO_LIT;
gen_helper_pklb(vc, vb);
break;
case 0x38:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minsb8(vc, va, vb);
break;
case 0x39:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minsw4(vc, va, vb);
break;
case 0x3A:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minub8(vc, va, vb);
break;
case 0x3B:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_minuw4(vc, va, vb);
break;
case 0x3C:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxub8(vc, va, vb);
break;
case 0x3D:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxuw4(vc, va, vb);
break;
case 0x3E:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsb8(vc, va, vb);
break;
case 0x3F:
REQUIRE_AMASK(MVI);
va = load_gpr(ctx, ra);
gen_helper_maxsw4(vc, va, vb);
break;
default:
goto invalid_opc;
}
break;
case 0x1D:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
vb = load_gpr(ctx, rb);
ret = gen_mtpr(ctx, vb, insn & 0xffff);
break;
#else
goto invalid_opc;
#endif
case 0x1E:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
if (rb == 31) {
ctx->lit = vb = tcg_temp_new();
tcg_gen_ld_i64(vb, cpu_env, offsetof(CPUAlphaState, exc_addr));
} else {
vb = load_gpr(ctx, rb);
}
tcg_gen_movi_i64(cpu_lock_addr, -1);
tmp = tcg_temp_new();
tcg_gen_movi_i64(tmp, 0);
st_flag_byte(tmp, ENV_FLAG_RX_SHIFT);
tcg_gen_andi_i64(tmp, vb, 1);
st_flag_byte(tmp, ENV_FLAG_PAL_SHIFT);
tcg_temp_free(tmp);
tcg_gen_andi_i64(cpu_pc, vb, ~3);
ret = DISAS_PC_UPDATED_NOCHAIN;
break;
#else
goto invalid_opc;
#endif
case 0x1F:
#ifndef CONFIG_USER_ONLY
REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
{
switch ((insn >> 12) & 0xF) {
case 0x0:
va = load_gpr(ctx, ra);
vb = load_gpr(ctx, rb);
tmp = tcg_temp_new();
tcg_gen_addi_i64(tmp, vb, disp12);
tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LESL);
tcg_temp_free(tmp);
break;
case 0x1:
va = load_gpr(ctx, ra);
vb = load_gpr(ctx, rb);
tmp = tcg_temp_new();
tcg_gen_addi_i64(tmp, vb, disp12);
tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LEQ);
tcg_temp_free(tmp);
break;
case 0x2:
ret = gen_store_conditional(ctx, ra, rb, disp12,
MMU_PHYS_IDX, MO_LESL);
break;
case 0x3:
ret = gen_store_conditional(ctx, ra, rb, disp12,
MMU_PHYS_IDX, MO_LEQ);
break;
case 0x4:
goto invalid_opc;
case 0x5:
goto invalid_opc;
case 0x6:
goto invalid_opc;
case 0x7:
goto invalid_opc;
case 0x8:
goto invalid_opc;
case 0x9:
goto invalid_opc;
case 0xA:
goto invalid_opc;
case 0xB:
goto invalid_opc;
case 0xC:
goto invalid_opc;
case 0xD:
goto invalid_opc;
case 0xE:
goto invalid_opc;
case 0xF:
goto invalid_opc;
}
break;
}
#else
goto invalid_opc;
#endif
case 0x20:
gen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0);
break;
case 0x21:
gen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0);
break;
case 0x22:
gen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0);
break;
case 0x23:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0);
break;
case 0x24:
gen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0);
break;
case 0x25:
gen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0);
break;
case 0x26:
gen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0);
break;
case 0x27:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0);
break;
case 0x28:
gen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0);
break;
case 0x29:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0);
break;
case 0x2A:
gen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0);
break;
case 0x2B:
gen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0);
break;
case 0x2C:
gen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0);
break;
case 0x2D:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0);
break;
case 0x2E:
ret = gen_store_conditional(ctx, ra, rb, disp16,
ctx->mem_idx, MO_LESL);
break;
case 0x2F:
ret = gen_store_conditional(ctx, ra, rb, disp16,
ctx->mem_idx, MO_LEQ);
break;
case 0x30:
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x31:
ret = gen_fbcond(ctx, TCG_COND_EQ, ra, disp21);
break;
case 0x32:
ret = gen_fbcond(ctx, TCG_COND_LT, ra, disp21);
break;
case 0x33:
ret = gen_fbcond(ctx, TCG_COND_LE, ra, disp21);
break;
case 0x34:
ret = gen_bdirect(ctx, ra, disp21);
break;
case 0x35:
ret = gen_fbcond(ctx, TCG_COND_NE, ra, disp21);
break;
case 0x36:
ret = gen_fbcond(ctx, TCG_COND_GE, ra, disp21);
break;
case 0x37:
ret = gen_fbcond(ctx, TCG_COND_GT, ra, disp21);
break;
case 0x38:
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1);
break;
case 0x39:
ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0);
break;
case 0x3A:
ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0);
break;
case 0x3B:
ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0);
break;
case 0x3C:
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1);
break;
case 0x3D:
ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0);
break;
case 0x3E:
ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0);
break;
case 0x3F:
ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0);
break;
invalid_opc:
ret = gen_invalid(ctx);
break;
}
return ret;
}
| 1threat
|
int float64_is_nan( float64 a1 )
{
float64u u;
uint64_t a;
u.f = a1;
a = u.i;
return ( LIT64( 0xFFF0000000000000 ) < (bits64) ( a<<1 ) );
}
| 1threat
|
static void nvic_systick_trigger(void *opaque, int n, int level)
{
NVICState *s = opaque;
if (level) {
armv7m_nvic_set_pending(s, ARMV7M_EXCP_SYSTICK);
}
}
| 1threat
|
static void ide_sector_write_cb(void *opaque, int ret)
{
IDEState *s = opaque;
int n;
if (ret == -ECANCELED) {
return;
}
block_acct_done(blk_get_stats(s->blk), &s->acct);
s->pio_aiocb = NULL;
s->status &= ~BUSY_STAT;
if (ret != 0) {
if (ide_handle_rw_error(s, -ret, IDE_RETRY_PIO)) {
return;
}
}
n = s->nsector;
if (n > s->req_nb_sectors) {
n = s->req_nb_sectors;
}
s->nsector -= n;
ide_set_sector(s, ide_get_sector(s) + n);
if (s->nsector == 0) {
ide_transfer_stop(s);
} else {
int n1 = s->nsector;
if (n1 > s->req_nb_sectors) {
n1 = s->req_nb_sectors;
}
ide_transfer_start(s, s->io_buffer, n1 * BDRV_SECTOR_SIZE,
ide_sector_write);
}
if (win2k_install_hack && ((++s->irq_count % 16) == 0)) {
timer_mod(s->sector_write_timer,
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (get_ticks_per_sec() / 1000));
} else {
ide_set_irq(s->bus);
}
}
| 1threat
|
How to mock aiohttp.client.ClientSession.get async context manager : <p>I have some troubles with mocking aiohttp.client.ClientSession.get context manager. I found some articles and here is one example that seems was working: <a href="http://pfertyk.me/2017/06/testing-asynchronous-context-managers-in-python/" rel="noreferrer">article 1</a></p>
<p>So my code that I want to test:</p>
<p><strong>async_app.py</strong></p>
<pre><code>import random
from aiohttp.client import ClientSession
async def get_random_photo_url():
while True:
async with ClientSession() as session:
async with session.get('random.photos') as resp:
json = await resp.json()
photos = json['photos']
if not photos:
continue
return random.choice(photos)['img_src']
</code></pre>
<p>And test:</p>
<p><strong>test_async_app.py</strong></p>
<pre><code>from asynctest import CoroutineMock, MagicMock, patch
from asynctest import TestCase as TestCaseAsync
from async_app import get_random_photo_url
class AsyncContextManagerMock(MagicMock):
async def __aenter__(self):
return self.aenter
async def __aexit__(self, *args):
pass
class TestAsyncExample(TestCaseAsync):
@patch('aiohttp.client.ClientSession.get', new_callable=AsyncContextManagerMock)
async def test_call_api_again_if_photos_not_found(self, mock_get):
mock_get.return_value.aenter.json = CoroutineMock(side_effect=[{'photos': []},
{'photos': [{'img_src': 'a.jpg'}]}])
image_url = await get_random_photo_url()
assert mock_get.call_count == 2
assert mock_get.return_value.aenter.json.call_count == 2
assert image_url == 'a.jpg'
</code></pre>
<p>When I'm running test, I'm getting an error:</p>
<pre><code>(test-0zFWLpVX) ➜ test python -m unittest test_async_app.py -v
test_call_api_again_if_photos_not_found (test_async_app.TestAsyncExample) ... ERROR
======================================================================
ERROR: test_call_api_again_if_photos_not_found (test_async_app.TestAsyncExample)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/kamyanskiy/.local/share/virtualenvs/test-0zFWLpVX/lib/python3.6/site-packages/asynctest/case.py", line 294, in run
self._run_test_method(testMethod)
File "/home/kamyanskiy/.local/share/virtualenvs/test-0zFWLpVX/lib/python3.6/site-packages/asynctest/case.py", line 351, in _run_test_method
self.loop.run_until_complete(result)
File "/home/kamyanskiy/.local/share/virtualenvs/test-0zFWLpVX/lib/python3.6/site-packages/asynctest/case.py", line 221, in wrapper
return method(*args, **kwargs)
File "/usr/lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete
return future.result()
File "/home/kamyanskiy/.local/share/virtualenvs/test-0zFWLpVX/lib/python3.6/site-packages/asynctest/_awaitable.py", line 21, in wrapper
return await coroutine(*args, **kwargs)
File "/home/kamyanskiy/.local/share/virtualenvs/test-0zFWLpVX/lib/python3.6/site-packages/asynctest/mock.py", line 588, in __next__
return self.gen.send(None)
File "/home/kamyanskiy/work/test/test_async_app.py", line 23, in test_call_api_again_if_photos_not_found
image_url = await get_random_photo_url()
File "/home/kamyanskiy/work/test/async_app.py", line 9, in get_random_photo_url
json = await resp.json()
TypeError: object MagicMock can't be used in 'await' expression
----------------------------------------------------------------------
Ran 1 test in 0.003s
FAILED (errors=1)
</code></pre>
<p>So I've tried to debug - here is what I can see:</p>
<pre><code>> /home/kamyanskiy/work/test/async_app.py(10)get_random_photo_url()
9 import ipdb; ipdb.set_trace()
---> 10 json = await resp.json()
11 photos = json['photos']
ipdb> resp.__aenter__()
<generator object CoroutineMock._mock_call.<locals>.<lambda> at 0x7effad980048>
ipdb> resp.aenter
<MagicMock name='get().__aenter__().aenter' id='139636643357584'>
ipdb> resp.__aenter__().json()
*** AttributeError: 'generator' object has no attribute 'json'
ipdb> resp.__aenter__()
<generator object CoroutineMock._mock_call.<locals>.<lambda> at 0x7effad912468>
ipdb> resp.json()
<MagicMock name='get().__aenter__().json()' id='139636593767928'>
ipdb> session
<aiohttp.client.ClientSession object at 0x7effb15548d0>
ipdb> next(resp.__aenter__())
TypeError: object MagicMock can't be used in 'await' expression
</code></pre>
<p>So what is proper way to mock async context manager ?</p>
| 0debug
|
how can I write increment in Scala? : <p>Is there a way I can write this Java code in Scala:</p>
<pre><code>int foo () { return this.i++; }
</code></pre>
<p>other than:</p>
<pre><code>def foo : int = {
val t = this.i
this.i += 1
t
}
</code></pre>
| 0debug
|
How to preserve data around a column index in each row of pandas data frame? : If I have an array with column indices for each row like this:
array = [NaN, 3, 4, 3, NaN]
And a pandas data frame like this:
1 2 3 4 5 6
1 1 NaN NaN NaN NaN 1
2 1 1 1 NaN NaN 1
3 NaN 1 1 1 1 1
4 NaN 1 1 1 NaN 1
5 1 NaN 1 NaN NaN 1
How do I keep values that overlap with my column index for each row such that I get a data frame like this:
1 2 3 4 5 6
1 NaN NaN NaN NaN NaN NaN
2 1 1 1 NaN NaN NaN
3 NaN 1 1 1 1 1
4 NaN 1 1 1 NaN NaN
5 NaN NaN NaN NaN NaN NaN
Where data associated with my rows column index is preserved?
| 0debug
|
static int send_dma_request(int cmd, uint64_t sector, int nb_sectors,
PrdtEntry *prdt, int prdt_entries)
{
QPCIDevice *dev;
uint16_t bmdma_base;
uintptr_t guest_prdt;
size_t len;
bool from_dev;
uint8_t status;
int flags;
dev = get_pci_device(&bmdma_base);
flags = cmd & ~0xff;
cmd &= 0xff;
switch (cmd) {
case CMD_READ_DMA:
from_dev = true;
break;
case CMD_WRITE_DMA:
from_dev = false;
break;
default:
g_assert_not_reached();
outb(IDE_BASE + reg_device, 0 | LBA);
outb(bmdma_base + bmreg_cmd, 0);
outb(bmdma_base + bmreg_status, BM_STS_INTR);
len = sizeof(*prdt) * prdt_entries;
guest_prdt = guest_alloc(guest_malloc, len);
memwrite(guest_prdt, prdt, len);
outl(bmdma_base + bmreg_prdt, guest_prdt);
outb(IDE_BASE + reg_nsectors, nb_sectors);
outb(IDE_BASE + reg_lba_low, sector & 0xff);
outb(IDE_BASE + reg_lba_middle, (sector >> 8) & 0xff);
outb(IDE_BASE + reg_lba_high, (sector >> 16) & 0xff);
outb(IDE_BASE + reg_command, cmd);
outb(bmdma_base + bmreg_cmd, BM_CMD_START | (from_dev ? BM_CMD_WRITE : 0));
if (flags & CMDF_ABORT) {
outb(bmdma_base + bmreg_cmd, 0);
do {
status = inb(bmdma_base + bmreg_status);
} while ((status & (BM_STS_ACTIVE | BM_STS_INTR)) == BM_STS_ACTIVE);
g_assert_cmpint(get_irq(IDE_PRIMARY_IRQ), ==, !!(status & BM_STS_INTR));
assert_bit_set(inb(IDE_BASE + reg_status), DRDY);
assert_bit_clear(inb(IDE_BASE + reg_status), BSY | DRQ);
g_assert(!get_irq(IDE_PRIMARY_IRQ));
if (status & BM_STS_ACTIVE) {
outb(bmdma_base + bmreg_cmd, 0);
free_pci_device(dev);
return status;
| 1threat
|
How to create random size table in Python : <p>I am new to Python, and I am trying to write a function called get_table. It's purpose is to get the data for the table from the random number library function. It should create the table, making sure that is it square and return it. I have no idea where to start, so any help would be appreciated! </p>
| 0debug
|
What is DYMTLInitPlatform platform initialization successful log when the application starts? : <p>I've just updated to Xcode 8/iOS 10 SDK and now when I compile and run my app, I'm getting <code>[DYMTLInitPlatform] platform initialization successful</code> before all the other logs in the output.</p>
<p>It's not harmful or anything, but I was wondering what that message is related to, which wasn't there with Xcode 7.3/iOS 9.3 SDK.</p>
| 0debug
|
void watchdog_add_model(WatchdogTimerModel *model)
{
LIST_INSERT_HEAD(&watchdog_list, model, entry);
}
| 1threat
|
Headless automation with Nodejs Selenium Webdriver : <p>I am working with an automation tool which has to be deployed inside an ubuntu server, my wonder is if is possible to use chrome in a silent way with Selenium Webdriver.</p>
<p>I've tried the following code so far, but it keeps opening the browser (I'm doing the tests in a Windows 10):</p>
<pre><code> var webdriver = require('selenium-webdriver'),
chrome = require('selenium-webdriver/chrome')
By = webdriver.By,
until = webdriver.until,
options = new chrome.Options();
options.addArguments('--headless');
var path = require('chromedriver').path;
var service = new chrome.ServiceBuilder(path).build();
chrome.setDefaultService(service);
var driver = new webdriver.Builder().forBrowser('chrome').withCapabilities(options.toCapabilities()).build();
driver.get('https://www.google.com');
</code></pre>
<p>Note that the addArguments('--headless') is the parameter that should make the navigation silent, but apparently it's not working or I am missing something I am not aware of.</p>
<p>If there is something I am missing, please tell me because I don't know if what I want to do is possible, as It is the frist time I work with this kind of technology.</p>
<p>Thanks.</p>
| 0debug
|
CPP reduce << operator chain in std::cout : Is there any way to reduce the chain of << operator from the statements like following ?
std::cout << var1 << "!=" << var2;
<pre>printf()</pre> may be an option but anything else ?
Because as the number of the operator << increases so the running time too;
Is it possible to efficiently reduce the << chain ?
| 0debug
|
Delay between two functions of one method android studio : I am new to Android Studio. I want to put delay between Animation of button AND opening of second activity, So that animation runs and then splashActivity opens.
btn.setOnClickListener(new View.OnClickListener(){
public void onClick(View arg0){
Animation anim4 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.splash_anim);
btn.startAnimation(anim4);
startActivity(new Intent(MainActivity.this, splashActivity.class));
}
});
| 0debug
|
Replace li end text using jquery :
I am trying to replace the content of li and <a> tags.
Tried below code.
<html>
<head>Sample</head>
<body>
<a href="#">
<input type="checkbox" class="layer-input-filter"
name="testname">Test <span class="count">5</span>
</a>
<a href="#">
<input type="checkbox" class="layer-input-filter"
name="testname1">Test1 <span class="count">10</span>
</a>
<ul>
<li><a href="#" rel="noopener">Mixed assessment guidelines</a>
</li>
<li><a href="" target="_blank" rel="noopener">Specimen </a></li>
<li><a href="#" rel="noopener">Plagiarism </a></li>
<li><a href="" target="_blank" rel="noopener">Download </a></li>
<li><a href="#" rel="noopener">Qualification update</a></li>
<li><a href="" target="_blank" rel="noopener">Specimen</a></li>
<li><a href="#" rel="noopener">Exam guide update</a></li>
<li><a href="" target="_blank" rel="noopener">Guide </a></li>
</ul>
<script>
$(document).ready(function($) {
$("body").find('li').each(function (index) {
//checks that the text isnt empty, no need to store that.
if ($(this).text() != '') {
var str = $(this).text();
var str1 = $(this).clone().children().remove().end().text();
//console.log("li text",str1);
var newstring = str + str.substring(0, str.length * value);
console.log(newstring);
//$(this).html($(this).html().replace(str,newstring));
$(this).text(newstring);
}
});
});
</script>
</body>
</html>
I need to replace the text of every li inside the body. so used above jquery for it. But its not working.
Can anyone help me with this please, Thanks
| 0debug
|
How do I print the 'cnt' variable from the second method in the 'main' method? Thank you : [I want to print the returned 'cnt' varible in the 'main' method][1]
[1]: https://i.stack.imgur.com/N5wxR.png
| 0debug
|
How to get the system date as the command line parameter in console application : I need to set the system date as the command line parameter in the debug tab of the Project Property in the Console application.
What are the value set it come as same string but i need the system date every day. Its possible? Please help anyone.
| 0debug
|
static void test_qemu_strtoull_full_correct(void)
{
const char *str = "18446744073709551614";
uint64_t res = 999;
int err;
err = qemu_strtoull(str, NULL, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 18446744073709551614LLU);
}
| 1threat
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
int ff_h263_decode_mb(MpegEncContext *s,
DCTELEM block[6][64])
{
int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
INT16 *mot_val;
static INT8 quant_tab[4] = { -1, -2, 1, 2 };
s->error_status_table[s->mb_x + s->mb_y*s->mb_width]= 0;
if(s->mb_x==0) PRINT_MB_TYPE("\n");
if (s->pict_type == P_TYPE || s->pict_type==S_TYPE) {
if (get_bits1(&s->gb)) {
s->mb_intra = 0;
for(i=0;i<6;i++)
s->block_last_index[i] = -1;
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE){
PRINT_MB_TYPE("G");
s->mcsel=1;
s->mv[0][0][0]= get_amv(s, 0);
s->mv[0][0][1]= get_amv(s, 1);
s->mb_skiped = 0;
}else{
PRINT_MB_TYPE("S");
s->mcsel=0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
s->mb_skiped = 1;
}
goto end;
}
cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
if (cbpc < 0)
return -1;
if (cbpc > 20)
cbpc+=3;
else if (cbpc == 20)
fprintf(stderr, "Stuffing !");
dquant = cbpc & 8;
s->mb_intra = ((cbpc & 4) != 0);
if (s->mb_intra) goto intra;
if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE && (cbpc & 16) == 0)
s->mcsel= get_bits1(&s->gb);
else s->mcsel= 0;
cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
cbp = (cbpc & 3) | ((cbpy ^ 0xf) << 2);
if (dquant) {
change_qscale(s, quant_tab[get_bits(&s->gb, 2)]);
}
if((!s->progressive_sequence) && (cbp || (s->workaround_bugs&FF_BUG_XVID_ILACE)))
s->interlaced_dct= get_bits1(&s->gb);
s->mv_dir = MV_DIR_FORWARD;
if ((cbpc & 16) == 0) {
if(s->mcsel){
PRINT_MB_TYPE("G");
s->mv_type = MV_TYPE_16X16;
mx= get_amv(s, 0);
my= get_amv(s, 1);
s->mv[0][0][0] = mx;
s->mv[0][0][1] = my;
}else if((!s->progressive_sequence) && get_bits1(&s->gb)){
PRINT_MB_TYPE("f");
s->mv_type= MV_TYPE_FIELD;
s->field_select[0][0]= get_bits1(&s->gb);
s->field_select[0][1]= get_bits1(&s->gb);
h263_pred_motion(s, 0, &pred_x, &pred_y);
for(i=0; i<2; i++){
mx = h263_decode_motion(s, pred_x, s->f_code);
if (mx >= 0xffff)
return -1;
my = h263_decode_motion(s, pred_y/2, s->f_code);
if (my >= 0xffff)
return -1;
s->mv[0][i][0] = mx;
s->mv[0][i][1] = my;
}
}else{
PRINT_MB_TYPE("P");
s->mv_type = MV_TYPE_16X16;
h263_pred_motion(s, 0, &pred_x, &pred_y);
if (s->umvplus_dec)
mx = h263p_decode_umotion(s, pred_x);
else
mx = h263_decode_motion(s, pred_x, s->f_code);
if (mx >= 0xffff)
return -1;
if (s->umvplus_dec)
my = h263p_decode_umotion(s, pred_y);
else
my = h263_decode_motion(s, pred_y, s->f_code);
if (my >= 0xffff)
return -1;
s->mv[0][0][0] = mx;
s->mv[0][0][1] = my;
if (s->umvplus_dec && (mx - pred_x) == 1 && (my - pred_y) == 1)
skip_bits1(&s->gb);
}
} else {
PRINT_MB_TYPE("4");
s->mv_type = MV_TYPE_8X8;
for(i=0;i<4;i++) {
mot_val = h263_pred_motion(s, i, &pred_x, &pred_y);
if (s->umvplus_dec)
mx = h263p_decode_umotion(s, pred_x);
else
mx = h263_decode_motion(s, pred_x, s->f_code);
if (mx >= 0xffff)
return -1;
if (s->umvplus_dec)
my = h263p_decode_umotion(s, pred_y);
else
my = h263_decode_motion(s, pred_y, s->f_code);
if (my >= 0xffff)
return -1;
s->mv[0][i][0] = mx;
s->mv[0][i][1] = my;
if (s->umvplus_dec && (mx - pred_x) == 1 && (my - pred_y) == 1)
skip_bits1(&s->gb);
mot_val[0] = mx;
mot_val[1] = my;
}
}
} else if(s->pict_type==B_TYPE) {
int modb1;
int modb2;
int mb_type;
int xy;
s->mb_intra = 0;
s->mcsel=0;
if(s->mb_x==0){
for(i=0; i<2; i++){
s->last_mv[i][0][0]=
s->last_mv[i][0][1]=
s->last_mv[i][1][0]=
s->last_mv[i][1][1]= 0;
}
}
s->mb_skiped= s->next_picture.mbskip_table[s->mb_y * s->mb_width + s->mb_x];
if(s->mb_skiped){
for(i=0;i<6;i++)
s->block_last_index[i] = -1;
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
s->mv[1][0][0] = 0;
s->mv[1][0][1] = 0;
PRINT_MB_TYPE("s");
goto end;
}
modb1= get_bits1(&s->gb);
if(modb1){
mb_type=4;
cbp=0;
}else{
int field_mv;
modb2= get_bits1(&s->gb);
mb_type= get_vlc2(&s->gb, mb_type_b_vlc.table, MB_TYPE_B_VLC_BITS, 1);
if(modb2) cbp= 0;
else cbp= get_bits(&s->gb, 6);
if (mb_type!=MB_TYPE_B_DIRECT && cbp) {
if(get_bits1(&s->gb)){
change_qscale(s, get_bits1(&s->gb)*4 - 2);
}
}
field_mv=0;
if(!s->progressive_sequence){
if(cbp)
s->interlaced_dct= get_bits1(&s->gb);
if(mb_type!=MB_TYPE_B_DIRECT && get_bits1(&s->gb)){
field_mv=1;
if(mb_type!=MB_TYPE_B_BACKW){
s->field_select[0][0]= get_bits1(&s->gb);
s->field_select[0][1]= get_bits1(&s->gb);
}
if(mb_type!=MB_TYPE_B_FORW){
s->field_select[1][0]= get_bits1(&s->gb);
s->field_select[1][1]= get_bits1(&s->gb);
}
}
}
s->mv_dir = 0;
if(mb_type!=MB_TYPE_B_DIRECT && !field_mv){
s->mv_type= MV_TYPE_16X16;
if(mb_type!=MB_TYPE_B_BACKW){
s->mv_dir = MV_DIR_FORWARD;
mx = h263_decode_motion(s, s->last_mv[0][0][0], s->f_code);
my = h263_decode_motion(s, s->last_mv[0][0][1], s->f_code);
s->last_mv[0][1][0]= s->last_mv[0][0][0]= s->mv[0][0][0] = mx;
s->last_mv[0][1][1]= s->last_mv[0][0][1]= s->mv[0][0][1] = my;
}
if(mb_type!=MB_TYPE_B_FORW){
s->mv_dir |= MV_DIR_BACKWARD;
mx = h263_decode_motion(s, s->last_mv[1][0][0], s->b_code);
my = h263_decode_motion(s, s->last_mv[1][0][1], s->b_code);
s->last_mv[1][1][0]= s->last_mv[1][0][0]= s->mv[1][0][0] = mx;
s->last_mv[1][1][1]= s->last_mv[1][0][1]= s->mv[1][0][1] = my;
}
if(mb_type!=MB_TYPE_B_DIRECT)
PRINT_MB_TYPE(mb_type==MB_TYPE_B_FORW ? "F" : (mb_type==MB_TYPE_B_BACKW ? "B" : "T"));
}else if(mb_type!=MB_TYPE_B_DIRECT){
s->mv_type= MV_TYPE_FIELD;
if(mb_type!=MB_TYPE_B_BACKW){
s->mv_dir = MV_DIR_FORWARD;
for(i=0; i<2; i++){
mx = h263_decode_motion(s, s->last_mv[0][i][0] , s->f_code);
my = h263_decode_motion(s, s->last_mv[0][i][1]/2, s->f_code);
s->last_mv[0][i][0]= s->mv[0][i][0] = mx;
s->last_mv[0][i][1]= (s->mv[0][i][1] = my)*2;
}
}
if(mb_type!=MB_TYPE_B_FORW){
s->mv_dir |= MV_DIR_BACKWARD;
for(i=0; i<2; i++){
mx = h263_decode_motion(s, s->last_mv[1][i][0] , s->b_code);
my = h263_decode_motion(s, s->last_mv[1][i][1]/2, s->b_code);
s->last_mv[1][i][0]= s->mv[1][i][0] = mx;
s->last_mv[1][i][1]= (s->mv[1][i][1] = my)*2;
}
}
if(mb_type!=MB_TYPE_B_DIRECT)
PRINT_MB_TYPE(mb_type==MB_TYPE_B_FORW ? "f" : (mb_type==MB_TYPE_B_BACKW ? "b" : "t"));
}
}
if(mb_type==4 || mb_type==MB_TYPE_B_DIRECT){
if(mb_type==4)
mx=my=0;
else{
mx = h263_decode_motion(s, 0, 1);
my = h263_decode_motion(s, 0, 1);
}
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
ff_mpeg4_set_direct_mv(s, mx, my);
}
if(mb_type<0 || mb_type>4){
printf("illegal MB_type\n");
return -1;
}
} else {
cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1);
if (cbpc < 0)
return -1;
dquant = cbpc & 4;
s->mb_intra = 1;
intra:
s->ac_pred = 0;
if (s->h263_pred || s->h263_aic) {
s->ac_pred = get_bits1(&s->gb);
if (s->ac_pred && s->h263_aic)
s->h263_aic_dir = get_bits1(&s->gb);
}
PRINT_MB_TYPE(s->ac_pred ? "A" : "I");
cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
if(cbpy<0) return -1;
cbp = (cbpc & 3) | (cbpy << 2);
if (dquant) {
change_qscale(s, quant_tab[get_bits(&s->gb, 2)]);
}
if(!s->progressive_sequence)
s->interlaced_dct= get_bits1(&s->gb);
if (s->h263_pred) {
for (i = 0; i < 6; i++) {
if (mpeg4_decode_block(s, block[i], i, cbp&32, 1) < 0)
return -1;
cbp+=cbp;
}
} else {
for (i = 0; i < 6; i++) {
if (h263_decode_block(s, block[i], i, cbp&32) < 0)
return -1;
cbp+=cbp;
}
}
goto end;
}
if (s->h263_pred) {
for (i = 0; i < 6; i++) {
if (mpeg4_decode_block(s, block[i], i, cbp&32, 0) < 0)
return -1;
cbp+=cbp;
}
} else {
for (i = 0; i < 6; i++) {
if (h263_decode_block(s, block[i], i, cbp&32) < 0)
return -1;
cbp+=cbp;
}
}
end:
if(s->codec_id==CODEC_ID_MPEG4){
if(mpeg4_is_resync(s)){
if(s->pict_type==B_TYPE && s->next_picture.mbskip_table[s->mb_y * s->mb_width + s->mb_x+1])
return SLICE_OK;
return SLICE_END;
}
}else{
int v= show_bits(&s->gb, 16);
if(get_bits_count(&s->gb) + 16 > s->gb.size*8){
v>>= get_bits_count(&s->gb) + 16 - s->gb.size*8;
}
if(v==0)
return SLICE_END;
}
return SLICE_OK;
}
| 1threat
|
static void vnc_connect(VncDisplay *vd, int csock)
{
VncState *vs = qemu_mallocz(sizeof(VncState));
int i;
vs->csock = csock;
vs->lossy_rect = qemu_mallocz(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));
for (i = 0; i < VNC_STAT_ROWS; ++i) {
vs->lossy_rect[i] = qemu_mallocz(VNC_STAT_COLS * sizeof (uint8_t));
}
VNC_DEBUG("New client on socket %d\n", csock);
dcl->idle = 0;
socket_set_nonblock(vs->csock);
qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs);
vnc_client_cache_addr(vs);
vnc_qmp_event(vs, QEVENT_VNC_CONNECTED);
vs->vd = vd;
vs->ds = vd->ds;
vs->last_x = -1;
vs->last_y = -1;
vs->as.freq = 44100;
vs->as.nchannels = 2;
vs->as.fmt = AUD_FMT_S16;
vs->as.endianness = 0;
#ifdef CONFIG_VNC_THREAD
qemu_mutex_init(&vs->output_mutex);
#endif
QTAILQ_INSERT_HEAD(&vd->clients, vs, next);
vga_hw_update();
vnc_write(vs, "RFB 003.008\n", 12);
vnc_flush(vs);
vnc_read_when(vs, protocol_version, 12);
reset_keys(vs);
if (vs->vd->lock_key_sync)
vs->led = qemu_add_led_event_handler(kbd_leds, vs);
vs->mouse_mode_notifier.notify = check_pointer_type_change;
qemu_add_mouse_mode_change_notifier(&vs->mouse_mode_notifier);
vnc_init_timer(vd);
}
| 1threat
|
Why should I keep the state flat : <p>I'm using ReactJs with Redux and on some tutorials and codes I see people suggesting and using normalizr to <strong>keep the state flat</strong>. But what is the real advantage in keeping it flat ? Will I encounter any problems if I don't ? Is it necessary ?</p>
| 0debug
|
Clearing an array in 2019 : So a few years ago it was bad practice to do
array = [];
because if the array was referenced somewhere that reference wasn't updated or smth like that.
The correct way was supposed to be `array.length = 0;`
Anyway, javascript has been updated now, and there's a framework called Vue.js
Vue does not catch `array.length = 0;` so the property won't be reactive. But it does catch `array = [];`
My question is, can we use now `array = [];`, or is javascript still broken?
| 0debug
|
How to “inverse match” with regex without content? : <p>I have read <a href="https://stackoverflow.com/questions/164414/how-to-inverse-match-with-regex">How to "inverse match" with regex?</a> and i would like to know if i can apply it to a non-content regex. In particular i'm talking about: <code>^[A-z0-9+\/]{44}$</code></p>
<p>I tried <a href="https://regex101.com/r/NmOs7Z/1" rel="nofollow noreferrer">https://regex101.com/r/NmOs7Z/1</a> but it does not work</p>
| 0debug
|
Assertion Failed: You must include an 'id' for account in an object passed to 'push' Ember.js v-2.4 : <p>I'm new to Ember and I can't find anywhere a solution to my problem. I have read the questions here in stack and in other ember forums, but none of them seems to work for me.</p>
<p>I'm trying to create a simple signup form. I should note that for the backend I use django.
Here is my code:</p>
<p>Server Response: </p>
<pre><code>[{"username":"user1","password":"123","email":"user1@example.com"},
{"username":"user2","password":"456","email":"user2@example.com"}]
</code></pre>
<p>Ember Model:</p>
<pre><code>import DS from 'ember-data';
export default DS.Model.extend({
username: DS.attr(),
password: DS.attr(),
email: DS.attr()
});
</code></pre>
<p>Ember Adapter:
import DS from 'ember-data';</p>
<pre><code>export default DS.RESTAdapter.extend({
host: '/api',
contentType: 'application/json',
dataType: 'json',
headers: {
username: 'XXXX',
password: 'XXXX'
}
});
</code></pre>
<p>Ember Serializer:</p>
<pre><code>import DS from 'ember-data';
export default DS.JSONSerializer.extend({
primaryKey: '_id'
});
</code></pre>
<p>Ember Route:
import Ember from 'ember';</p>
<pre><code>export default Ember.Route.extend({
model() {
return this.store.findAll('account');
}
});
</code></pre>
<p>Ember Controller:</p>
<pre><code>import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
signup(){
console.log('My username is: ', this.get('username'));
console.log('My password is: ', this.get('password'));
console.log('My email is: ', this.get('email'));
var account = this.store.createRecord('account', {
username: this.get('username'),
password: this.get('password'),
email: this.get('email')
});
account.save();
}
}
});
</code></pre>
<p>With this implementation I get the aforementioned error. Any help would be appreciated. Thank you in advance.</p>
| 0debug
|
Iterating through 2 dataframes, nested for loop Python. Need help optimizing : I have 2 CSV files.
One with Hostnames and IPs.
The second with IP information (Netmask, Cidr, Subnet Name etc..)
I currently have a situation like the following.
for i, ipAddress in CSV1:
for j, ipNetwork in CSV1:
if ipAddress in ipNetwork:
append ipNetwork['Subnet Name']
Unfortunately, the first csv has 9000 IPs and the second list has 30'000 subnets. This is taking a huge amount of time to iterate through. I know this was an awful way of implementing this but I knew I could always improve.
Can anyone advise how better I can solve this problem? How can I search through and compare elements in each to shorten the runtime of this script?
| 0debug
|
How can a function run "as if" on a new thread without doing so? : <p>Per [futures.async]/3 bullet 1 of the C++ Standard, when a function <code>f</code> is passed to <code>std::async</code> with the <code>std::launch::async</code> launch policy, <code>f</code> will run "as if in a new thread of execution". </p>
<p>Given that <code>f</code> can do anything, including loop infinitely and block forever, how can an implementation offer the behavior of <code>f</code> running on its own thread without actually running it on its own thread? That is, how can an implementation take advantage of the "as if" wiggle room the Standard provides?</p>
| 0debug
|
Did computers have started storing 0.1 correctly? : While learning about `floating point arithmetic` I came across something, I quote, `a float/double can't store 0.1 precisely`.
There is a [question][1] on SO pointing the same thing and accepted answer is also very convincing. However I thought of trying it out on my own computer, so I wrote following program as below
double a = 0.1;
if (a == 0.1)
{
Console.WriteLine("True");
}
else
{
Console.WriteLine("False");
}
Console.Read();
and console printed `True`. Shocking to as I was already convinced with something else. Can anyone tell me whats going on with floating point arithmetic? Or I just got a computer that store numeric values as `base 10`, :D
[1]: https://stackoverflow.com/q/1398753/3664659
| 0debug
|
Is it possible to use axios.all with a then() for each promise? : <p>I have a React component that triggers an event to fetch data. This results in a dynamic number of stored proc calls to fetch data, and the data from each call is stored in a totally different location. Then I need to re-render once all of the data is received and available. I'm using promises with axios.</p>
<p>Since the number of axios calls is dynamic, I'm building an array and inserting it into <code>axios.all</code> as follows:</p>
<pre><code>let promises = [];
for (let i = 0; i < requests.length; i++) {
promises.push(axios.get(request[i].url, { params: {...} }));
}
axios.all(promises).then(/* use the data */);
</code></pre>
<p>The problem is that each axios request returns data that gets added to an object in a totally different place. Since I have no way to put them all in the correct place in a single <code>then</code> (how would I know which response goes in which location?), I tried doing something like this:</p>
<pre><code>let promises = [];
for (let i = 0; i < requests.length; i++) {
promises.push(
axios.get(request[i].url, { params: {...} })
.then(response => {myObject[request[i].saveLocation] = response.data;})
);
}
axios.all(promises).then(/* use the data */);
</code></pre>
<p>However, this doesn't work as I expected. The <code>then</code> after each <code>get</code> is executed, but not until well after the <code>then</code> attached to <code>axios.all</code>. Obviously this is a problem because my code tries to use the data before it has been saved to the object.</p>
<p>Is there a way to have a separate <code>then</code> call for each <code>axios.get</code> that will be executed after its corresponding promise is resolved, and then have a final <code>then</code> that will be executed only after <em>all</em> of the promises are resolved, to use the data now that the object has been populated?</p>
| 0debug
|
Have Android App communicate to PHP file. : I'm trying to have my android app communicate with my friends php file which stores data into our database and then registers that data for a new user account. I am new to PHP but I can read it. But whatever I try, nothing seems to be able to be passing the values through to his post requests. Ive tried everything from Volley Requests to JSON Parsing and I cant get it to work.
Here is his PHP file.
enter code here
<?php
ini_set('display_errors', 1);
header('Content-type: text/html; charset=utf-8');
//$user = (int)$_POST['user_id'];
$email = $_POST['email'];
$password1 = $_POST['psw'];
$password2 = $_POST['psw-repeat'];
$first = $_POST['first_name'];
$last = $_POST['last_name'];
//<input type="checkbox" checked="checked"> Remember me
include 'connRW.php';
$stmt = $connRW->prepare("SELECT * FROM AdUsers WHERE email = :email or
fb_email
= :fb_email");
$stmt->bindValue(':email', $email);
$stmt->bindValue(':fb_email', $email);
$stmt->execute();
$row1 = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt = $connRW->prepare("SELECT * FROM AdPublishers WHERE email = :email or
fb_email = :fb_email");
$stmt->bindValue(':email', $email);
$stmt->bindValue(':fb_email', $email);
$stmt->execute();
$row2 = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$row1 && !$row2 && $password1)
{
if ($password1 == $password2) {
$pwsaltedhashed = password_hash($password1, PASSWORD_DEFAULT);
$stmt = $connRW->prepare("SELECT raadz_user_id FROM GetNext");
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$next_user_id = $row["raadz_user_id"] + 1;
$stmt = $connRW->prepare("UPDATE GetNext SET raadz_user_id =
:next_user_id");
$stmt->bindValue(':next_user_id', $next_user_id, PDO::PARAM_INT);
$stmt->execute();
$stmt = $connRW->prepare("INSERT INTO AdUsers ( raadz_user_id, email,
password, first_name, last_name )
VALUES ( :user_id, :email, :password, :first_name, :last_name
)");
$stmt->bindValue(':user_id', $next_user_id, PDO::PARAM_INT);
$stmt->bindValue(':email', $email);
$stmt->bindValue(':password', $pwsaltedhashed);
$stmt->bindValue(':first_name', $first);
$stmt->bindValue(':last_name', $last);
$stmt->execute();
$confirm_string = $next_user_id . substr($first, 0, 2) . substr($last,
0, 2);
And this is my Java class in Android Studio I'm using:
enter code here
public class RegisterActivity extends AppCompatActivity {
TextView tvLogin;
Button bRegister;
EditText etEmail;
EditText etPassword;
EditText etPasswordRepeat;
EditText etfirstName;
EditText etlastName;
String url = "https://example.com/usersignup.php";
String gEmail;
String gPassword;
String gPasswordRepeat;
String gFirst;
String gLast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
etEmail = (EditText) findViewById(R.id.etEmail);
etPassword = (EditText) findViewById(R.id.etPassword);
etPasswordRepeat = (EditText) findViewById(R.id.etPasswordRepeat);
etfirstName = (EditText) findViewById(R.id.firstName);
etlastName = (EditText) findViewById(R.id.lastName);
tvLogin = (TextView) findViewById(R.id.tvLogin);
bRegister = (Button) findViewById(R.id.bRegister);
gEmail = etEmail.getText().toString();
gPassword = etPassword.getText().toString();
gPasswordRepeat = etPasswordRepeat.getText().toString();
gFirst = etfirstName.getText().toString();
gLast = etlastName.getText().toString();
tvLogin.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), MainActivity.class);
startActivity(intent);
}
});
bRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String url = "https://raadz.com/usersignup.php";
StringRequest MyStringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
if(response.contains("Message could not be send.")) {
Toast.makeText(getApplicationContext(), "Message not sent", Toast.LENGTH_SHORT).show();
}
if(response.contains("Message has been sent")){
Toast.makeText(getApplicationContext(), "Message sent", Toast.LENGTH_SHORT).show();
}
//This code is executed if the server responds, whether or not the response contains data.
//The String 'response' contains the server's response.
}
}, new Response.ErrorListener() { //Create an error listener to handle errors appropriately.
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
//This code is executed if there is an error.
}
}) {
protected Map<String, String> getParams() {
Map<String, String> MyData = new HashMap<String, String>();
MyData.put("email", gEmail);
MyData.put("psw", gPassword);
MyData.put("psw-repeat", gPasswordRepeat);
MyData.put("first_name", gFirst);
MyData.put("last_name", gLast);
return MyData;
}
};
MySingleton.getInstance(getAppContext()).addToRequestQueue(MyStringRequest);
}
});
}
}
What am I doing wrong?
| 0debug
|
find a minimum spanning tree in different sets :
Here I have two connected undirected graphs G1 = [V ; E1] and G2 =
[V ; E2] on the same set of vertices V . And assume edges in E1 and E2 have different colors. Let w(e) be the weight of edge e ∈ E1 ∪ E2.
I want to find a minimum weight spanning tree (MSF) among those spanning trees which have at least one edge in each set E1 and E2. In this condition, how to find a proper algorithm for this? I got stuck here a whole night.
| 0debug
|
In which directory should i navigate to to kill the docker containers : I've read the command for docker kill .Now exactly how to stop
all container or kill the container
• Should i navigate the docker folder in program files in cmd
• Should i navigate to botium folder which i created for botium box in cmd
Which of the above 2 should i do .Currently i have docker desktop version
I
| 0debug
|
Is it worth using distinct() with collect(toSet()) : <p>When collecting the elements of a stream into a set, is there any advantage (or drawback) to also specifying <code>.distinct()</code> on the stream? For example:</p>
<pre><code>return items.stream().map(...).distinct().collect(toSet());
</code></pre>
<p>Given that the set will already remove duplicates, this seems redundant, but does it offer any performance advantage or disadvantage? Does the answer depend on whether the stream is parallel/sequential or ordered/unordered?</p>
| 0debug
|
SAPUI5: Multilevel filter in read operation in Odata : I need help in filter to read oData. I need filter as following while performing oModel.read().
<pre>
(
((USERID EQ 'KSA') OR (USERID EQ 'KSW'))
AND
((USERID NE 'KUMARNISH2') OR (USERID NE 'KUMARNISH3'))
)
</pre>
Anybody can help me?
| 0debug
|
Find command and semi-path : <pre><code>/volume1/Folder/0000/AAA/one
/volume1/Folder/0001/AAA/two
/volume1/Folder/0001/BBB/three
/volume1/Folder/0002/CCC/four
...
</code></pre>
<p>I want to get a .txt file, with all not-empty folders directories. But I want this file to write without the <code>/volume1/Folder/</code>, ie, I want to print it like this :</p>
<pre><code>0000/AAA/one
0001/AAA/two
0001/BBB/three
0002/CCC/four
...
</code></pre>
<p>This is the code that I'm using, but this is writing the full path (and I know that by adding -printf '%f\n' it writes only the last folder, but I don't want that!)</p>
<pre><code> find /volume1/Folder/* -mtime -1 -type d -maxdepth 2 -not -empty > /volume1/Folder/NotEmptyFolders.txt
</code></pre>
<p>Can someone help me?</p>
| 0debug
|
static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
int mm_flags)
{
const int high_bit_depth = avctx->bits_per_raw_sample > 8;
#if HAVE_INLINE_ASM
c->put_pixels_clamped = ff_put_pixels_clamped_mmx;
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
c->add_pixels_clamped = ff_add_pixels_clamped_mmx;
if (!high_bit_depth) {
c->clear_block = clear_block_mmx;
c->clear_blocks = clear_blocks_mmx;
c->draw_edges = draw_edges_mmx;
SET_HPEL_FUNCS(put, [0], 16, mmx);
SET_HPEL_FUNCS(put_no_rnd, [0], 16, mmx);
SET_HPEL_FUNCS(avg, [0], 16, mmx);
SET_HPEL_FUNCS(avg_no_rnd, , 16, mmx);
SET_HPEL_FUNCS(put, [1], 8, mmx);
SET_HPEL_FUNCS(put_no_rnd, [1], 8, mmx);
SET_HPEL_FUNCS(avg, [1], 8, mmx);
switch (avctx->idct_algo) {
case FF_IDCT_AUTO:
case FF_IDCT_SIMPLEMMX:
c->idct_put = ff_simple_idct_put_mmx;
c->idct_add = ff_simple_idct_add_mmx;
c->idct = ff_simple_idct_mmx;
c->idct_permutation_type = FF_SIMPLE_IDCT_PERM;
break;
case FF_IDCT_XVIDMMX:
c->idct_put = ff_idct_xvid_mmx_put;
c->idct_add = ff_idct_xvid_mmx_add;
c->idct = ff_idct_xvid_mmx;
break;
}
}
c->gmc = gmc_mmx;
c->add_bytes = add_bytes_mmx;
if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
c->h263_v_loop_filter = h263_v_loop_filter_mmx;
c->h263_h_loop_filter = h263_h_loop_filter_mmx;
}
#endif
#if HAVE_YASM
c->vector_clip_int32 = ff_vector_clip_int32_mmx;
#endif
}
| 1threat
|
static void ahci_reg_init(AHCIState *s)
{
int i;
s->control_regs.cap = (s->ports - 1) |
(AHCI_NUM_COMMAND_SLOTS << 8) |
(AHCI_SUPPORTED_SPEED_GEN1 << AHCI_SUPPORTED_SPEED) |
HOST_CAP_NCQ | HOST_CAP_AHCI;
s->control_regs.impl = (1 << s->ports) - 1;
s->control_regs.version = AHCI_VERSION_1_0;
for (i = 0; i < s->ports; i++) {
s->dev[i].port_state = STATE_RUN;
}
}
| 1threat
|
how can i use head in place of struct node? : i made a function to create a node in linked list which takes a integer as argument ,my program is running fine when i am using this function but my doubt is in malloc used here
What I have tried:
my structure is
struct{
int data;
struct node*}
this is my insert function
void insert(int x){
struct node *temp=(struct node*)malloc(sizeof(struct node));
temp->data=x;
temp->next=head;
head=temp;
}
note i declared head as a global variable as
struct node* head;
clearly head is a pointer variable(pointer to struct node) which will take only 4 bytes
in memory whereas (struct node) will take 8 bytes in memory
my doubt is this when i am using head in sizeof operator instead of struct node that is
struct node *temp=(struct node*)malloc(sizeof(head));
i am getting no error
no warning and getting the exact answer as was before but memory allocation will be different for head(4bytes) and struct node(8 bytes) it should affect my program??
| 0debug
|
Vector with a variable range does not work : Here is my function:
when I do this:
`std::list<int> pigeonhole[100];` it works, but i need a variable here.
when I put this,
std::list<int> pigeonhole(range);
the following part fails; it says no operator "[]" matches these operands :
pigeonhole[arr[i]-min].push_back(arr[i]);
same thing with this part: `pigeonhole[i]`
void pigeonholeSort(int arr[], int n)
{
int min = arr[0], max = arr[0];
for (int i = 1; i < n; i++)
{
if (arr[i] < min)
min = arr[i];
if (arr[i] > max)
max = arr[i];
}
int range = max - min +1;
std::list<int> pigeonhole(range);
for (int i = 0; i < n; i++)
pigeonhole[arr[i]-min].push_back(arr[i]);
int index = 0;
for (int i = 0; i < max; i++)
{
list<int>::iterator it;
for (it = pigeonhole[i].begin(); it != pigeonhole[i].end(); ++it)
arr[index++] = *it;
}
}
| 0debug
|
Docker parallel operations limit : <p>Is there a limit to the number of parallel Docker push/pulls you can do? </p>
<blockquote>
<p>E.g. if you thread Docker pull / push commands such that they are
pulling/pushing different images at the same time what would be the
upper limit to the number of parallel push/pulls</p>
</blockquote>
<p>Or alternatively</p>
<blockquote>
<p>On one terminal you do docker pull ubuntu on another you do docker
pull httpd etc - what would be the limit Docker would support? </p>
</blockquote>
| 0debug
|
Python regular expression always return None : <p>I want to get userid from url like:</p>
<pre><code>http://space.bilibili.com/1950746/#!/channel/detail?cid=1757&order=&page=1
</code></pre>
<p>and it should be like 1950746.</p>
<p>And here is the code:</p>
<pre><code>url='http://space.bilibili.com/1950746/#!/channel/detail?cid=1757&order=&page=1'
b=userid=re.match(r'\d{7}', url)
print(b)
</code></pre>
<p>The result is None.</p>
| 0debug
|
Does I give instructions to Dji Pjhantom 4 using onboard sdk : I have Dji Phantom 4 and I need to track object using it so can I give instructions to it using onboard sdk as its only for Matrix 100 and if not is there any other way to five it instructions using ROS or with linux operating system.
| 0debug
|
How to query elasticsearch for greater than and less than? : <p>I want to get values between 1000 and 2000. I tried this query:</p>
<pre><code>{
"query": {
"bool": {
"filter": [{
"range": {
"price": {
"gte": 1000
},
"price": {
"lte": 2000
}
}
}]
}
}
}
</code></pre>
<p>But this doesn't give satisfactory results. Greater than works fine. I am using elasticsearch v6.3. Please help with solution for both inclusive and exclusive of both values.</p>
| 0debug
|
Differences between vue instance and vue component? : <p>I'm new to vue js and have some questions when learning it.</p>
<p>I'm now a little confused about the relationship between its instance and component. As far as I learned, every app build by vue should only have one instance and one instance only, it can have as many components as you like if needed. But recently I've seen a demo, and in that demo it has more than one instance.</p>
<p>So my question is, is that ok to have multiple intances in one app( the demo code works fine, but is that the correct way)? What's the best practice to use instance and component in vue app?</p>
| 0debug
|
After uploding file clicking submit button getting Exception IOE : This is My JSP Page and I am getting Exception after uploading file and Click on submitt button
<%@page import="com.oreilly.servlet.*,java.sql.*,databaseconnection.*,java.util.*,java.io.*,javax.servlet.*, javax.servlet.http.*"%>
<%
String h1=null;
String saveFile="";
String contentType = request.getContentType();
if((contentType != null)&&(contentType.indexOf("multipart/form-data") >= 0)){
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while(totalBytesRead < formDataLength){
byteRead = in.read(dataBytes, totalBytesRead,formDataLength);
totalBytesRead += byteRead;
}
int ch;
StringBuffer strContent = new StringBuffer("");
FileInputStream fin = null;
String file = new String(dataBytes);
saveFile = file.substring(file.indexOf("filename=\"") + 10);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\""));
int lastIndex = contentType.lastIndexOf("=");
String boundary = contentType.substring(lastIndex + 1,contentType.length());
int pos;
pos = file.indexOf("filename=\"");
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
int boundaryLocation = file.indexOf(boundary, pos) - 4;
int startPos = ((file.substring(0, pos)).getBytes()).length;
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
File ff = new File(saveFile);
FileOutputStream fileOut = new FileOutputStream(ff);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
fin = new FileInputStream(ff);
while ((ch = fin.read()) != -1)
strContent.append((char) ch);
fin.close();
String ss=(strContent.toString());
//StringBuffer s=new StringBuffer(ss);
String date=(String)session.getAttribute("date");
String keypoints=(String)session.getAttribute("keypoints");
/*
String[] strArray =null;
strArray=keypoints.split(",");
for (String str : strArray) {
// String a="<a href>"+str+" </a>";
//String b="(?i)"+str;
h=ss.replaceAll(str,"<a href>"+str+" </a>");
}
*/
##
> [Heading][1]
##
%>
-------------------------------------------------------------------------------
My Exception is
=====================
java.io.IOException: An exception occurred processing JSP page /upload.jsp at line 41
38: int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
39: System.out.println(saveFile);
40: File ff = new File(saveFile);
41: FileOutputStream fileOut = new FileOutputStream(ff);
42:
43: fileOut.write(dataBytes, startPos, (endPos - startPos));
44:
Stacktrace:
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:466)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2503)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2492)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: springframework-license.txt (Access is denied)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
at org.apache.jsp.upload_jsp._jspService(upload_jsp.java:163)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
... 27 more
[1]: https://i.stack.imgur.com/kT6TY.png
| 0debug
|
static void spr_write_tbl(DisasContext *ctx, int sprn, int gprn)
{
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_store_tbl(cpu_env, cpu_gpr[gprn]);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_stop_exception(ctx);
}
}
| 1threat
|
Call parent method with component : <p>I have a component and want to add a click listener that runs a method in the parent template in Vue. Is this possible?</p>
<pre><code><template>
<custom-element @click="someMethod"></custom-element>
</template>
<script>
export default {
name: 'template',
methods: {
someMethod: function() {
console.log(true);
}
}
</script>
</code></pre>
| 0debug
|
void bdrv_drain_all(void)
{
bool busy = true;
BlockDriverState *bs;
while (busy) {
QTAILQ_FOREACH(bs, &bdrv_states, list) {
if (bdrv_start_throttled_reqs(bs)) {
busy = true;
}
}
busy = bdrv_requests_pending_all();
busy |= aio_poll(qemu_get_aio_context(), busy);
}
}
| 1threat
|
Merging txt files whose last letters repeat in python : <p>I have a folder that includes txt files. Txt files' names always end up with those years '_1980', '_1981' '_1982' ... '_2015', but their names start with different numbers. I want to merge txt files whose file names start with same letters/numbers but finish with those numbers above.
As an example for the txt files,
<a href="https://i.stack.imgur.com/P335f.jpg" rel="nofollow noreferrer">example</a></p>
<p>Eventually, merged file are abc_allyears.txt and xyz_allyears.txt and so on 'otherletters'_allyears.txt</p>
<p>Can you write related python code?
Thank you.</p>
| 0debug
|
void visit_start_list(Visitor *v, const char *name, Error **errp)
{
if (!error_is_set(errp)) {
v->start_list(v, name, errp);
}
}
| 1threat
|
void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
void *opaque)
{
BlockDriver *drv;
int count = 0;
const char **formats = NULL;
QLIST_FOREACH(drv, &bdrv_drivers, list) {
if (drv->format_name) {
bool found = false;
int i = count;
while (formats && i && !found) {
found = !strcmp(formats[--i], drv->format_name);
}
if (!found) {
formats = g_realloc(formats, (count + 1) * sizeof(char *));
formats[count++] = drv->format_name;
it(opaque, drv->format_name);
}
}
}
g_free(formats);
}
| 1threat
|
Is it safe to return a casted reference? : <p>Let <code>Point</code> be a class whose instances can be explicitly casted to a <code>wxPoint</code>:</p>
<pre><code>class Point{
private:
int x;
int y;
public:
explicit operator wxPoint() const
{
return wxPoint(x, y);
}
// More stuff
}
</code></pre>
<p>I have a function that returns a reference to an object of type <code>Point</code>. The header of such a function is:</p>
<pre><code>const Point& GetPoint();
</code></pre>
<p>My question: is it safe to define the following <code>Foo</code> function?</p>
<pre><code>const wxPoint& Foo() const{
return (wxPoint&) GetPoint();
}
</code></pre>
<p>First I implemented <code>Foo</code> with <code>return (wxPoint) GetPoint();</code>, but that created a new (local) object and therefore a useful warning is triggered. The code shown here compiles without warnings.</p>
<p>All the information I found on this kind of casting refers to inherited classes, which is not the case here.</p>
<p>An explanation of what is exactly going on when casting a reference in this way would be really appreciated.</p>
| 0debug
|
How to parse a csv that uses ^A (i.e. \001) as the delimiter with spark-csv? : <p>Terribly new to spark and hive and big data and scala and all. I'm trying to write a simple function that takes an sqlContext, loads a csv file from s3 and returns a DataFrame. The problem is that this particular csv uses the ^A (i.e. \001) character as the delimiter and the dataset is huge so I can't just do a "s/\001/,/g" on it. Besides, the fields might contain commas or other characters I might use as a delimiter.</p>
<p>I know that the spark-csv package that I'm using has a delimiter option, but I don't know how to set it so that it will read \001 as one character and not something like an escaped 0, 0 and 1. Perhaps I should use hiveContext or something?</p>
| 0debug
|
What is pass-through load balancer? How is it different from proxy load balancer? : <p>Google Cloud Network load balancer is a pass-through load balancer and not a proxy load balancer. ( <a href="https://cloud.google.com/compute/docs/load-balancing/network/" rel="noreferrer">https://cloud.google.com/compute/docs/load-balancing/network/</a> ). </p>
<p>I can not find any resources in general on a pass through LB. Both HAProxy and Nginx seems to be proxy LBs. I'm guessing that pass through LB would be redirecting the clients directly to the servers. In what scenarios it would be beneficial?</p>
<p>Are there any other type of load balancers except pass-through and proxy?</p>
| 0debug
|
xunit Assert.ThrowsAsync() does not work properly? : <p>So I have a test like the following:</p>
<pre><code> [Fact]
public void Test1()
{
Assert.ThrowsAsync<ArgumentNullException>(() => MethodThatThrows());
}
private async Task MethodThatThrows()
{
await Task.Delay(100);
throw new NotImplementedException();
}
</code></pre>
<p>To my surprise, Test1 passes successfully. To make it fail I have to write like this:</p>
<pre><code>Assert.Throws<ArgumentNullException>(() => MethodThatThrows().Wait());
</code></pre>
<p>What is the purpose of ThrowsAsync(), if it does not work in the scenario above?</p>
| 0debug
|
How to logout and redirect to login page using Laravel 5.4? : <p>I am using Laravel 5.4 and trying to implement authentication system. I used php artisan command make:auth to setup it. I edited the views according to my layout. Now, when I am trying to logout it throwing me this error</p>
<p>NotFoundHttpException in RouteCollection.php line 161:</p>
<p>could any one help me how to logout?</p>
| 0debug
|
AutoCompleteView in Dialog Box : <p>I am trying to implement a AutoCompleteView inside one of my dialog boxes. I have been following some tutorials but cant seem to see when I am going wrong. When ever I click the button to launch the dialog box the app crashes with the below error. Is the AutoCompleteView correct?</p>
<p><strong>Error</strong></p>
<pre><code>01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: FATAL EXCEPTION: main
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: Process: com.example.rory.prototypev2, PID: 5481
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.Cursor android.database.sqlite.SQLiteDatabase.query(java.lang.String, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String, java.lang.String, java.lang.String)' on a null object reference
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at com.example.rory.prototypev2.DBMain.getIngredientsForInput(DBMain.java:418)
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at com.example.rory.prototypev2.enterRecipe$1.onClick(enterRecipe.java:72)
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at android.view.View.performClick(View.java:5204)
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at android.view.View$PerformClick.run(View.java:21153)
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
01-29 12:47:59.018 5481-5481/com.example.rory.prototypev2 E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
</code></pre>
<p><strong>Dialog with AutoCompleteView</strong></p>
<pre><code> ingredient = (Button) findViewById(R.id.showIngredientDialog);
ingredient.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
db1.open();
String filler = "Filler";
recipe_number = db1.insertRecipe(filler);
// custom ingredient_dialog
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.ingredient_dialog);
dialog.setTitle("Add Ingredient");
// set the custom ingredient_dialog components
//final EditText ingredient = (EditText) dialog.findViewById(R.id.name);
String[] list = db1.getIngredientsForInput();
text = (AutoCompleteTextView)findViewById(R.id.name);
ArrayAdapter adapter3 = new ArrayAdapter(getApplicationContext(),android.R.layout.simple_list_item_1,list);
text.setAdapter(adapter3);
text.setThreshold(1);
</code></pre>
<p><strong>Dialog XML</strong></p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<AutoCompleteTextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_marginTop="72dp"
android:hint="AutoComplete TextView">
<requestFocus />
</AutoCompleteTextView>
<Spinner
android:id="@+id/measurement"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/name"
android:layout_alignParentStart="true"
android:entries="@array/measurements"/>
<Spinner
android:id="@+id/unit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/measurement"
android:layout_alignParentStart="true"
android:entries="@array/units"/>
<Button
android:id="@+id/dialogButtonNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:layout_below="@+id/unit"
android:layout_toStartOf="@+id/dialogButtonOK" />
<Button
android:id="@+id/dialogButtonOK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Ok "
android:layout_marginRight="5dp"
android:layout_below="@+id/unit"
android:layout_toEndOf="@+id/name"
android:gravity="center"/>
</code></pre>
<p></p>
<p><strong>getIngredientsForInput()</strong></p>
<pre><code> public String[] getIngredientsForInput()
{
Cursor cursor = this.sqliteDBInstance.query(CONTENTS_TABLE, new String[] {KEY_CONTENTS_NAME}, null, null, null, null, null);
if(cursor.getCount() >0)
{
String[] str = new String[cursor.getCount()];
int i = 0;
while (cursor.moveToNext())
{
str[i] = cursor.getString(cursor.getColumnIndex(KEY_CONTENTS_NAME));
i++;
}
return str;
}
else
{
return new String[] {};
}
}
</code></pre>
| 0debug
|
C# array in arrays : How do you create array that would produce exactly like the output below?
January April July October
2014 -- 1 2 3 4
2015 -- 5 6 7 8
2016 -- 9 10 11 12
Row [3] = 2014, 2015, 2016.
Column [4] = January, April, July, October.
Value [2014, January] = 1, Value [2014, April] = 2, Value [2014, July] = 3, Value [2014, October] = 4,and so on...
Please help me to figure it out as I'm self-learning C# at the moment.
| 0debug
|
In Ionic 2, how do I create a custom directive that uses Ionic components? : <p>Creating a basic directive is simple:</p>
<pre><code>import {Component} from 'angular2/core';
@Component({
selector: 'my-component',
template: '<div>Hello!</div>'
})
export class MyComponent {
constructor() {
}
}
</code></pre>
<p>This works as expected. However, if I want to use Ionic components in my directive things blow up.</p>
<pre><code>import {Component} from 'angular2/core';
@Component({
selector: 'my-component',
template: '<ion-list><ion-item>I am an item</ion-item></ion-list>'
})
export class MyComponent {
constructor() {
}
}
</code></pre>
<p>The directive is rendered, but Ionic components are not transformed, and so wont look/work properly.</p>
<p>I can't find any examples on this. How should I do this?</p>
| 0debug
|
how to split string taken as input and i want to separate it with comas in c : char exp[50];
// printf("Enter the postfix expression :");
// scanf("%s", exp);
my desired output is when 567+* as input
5,newline
5,6,newline
5,6,7,newline......
| 0debug
|
an error that i don't understand on c++ : So this is my code
#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int kol=0, x;
cout << "Insert a number: ";
cin >> x;
while (x > 0);
{
div_t output;
output = x;
x = div(output, 10);
kol += kol;
}
cout << "Amount: " << kol << endl;
system ("pause");
return 0;
}
and i got this error
Error 1 error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversation)
can someone tell me what i did wrong and how to fix?
| 0debug
|
How to find id of html element using php : <p>This is not a duplicated question. I have a html tag that has id.
I want to find value of id using php. How to do that? Is it possible?
For example:</p>
<pre><code><p id="par"><?php /* find value of id */ ?></p>
</code></pre>
<p>I want to find "par" using php.
Please answer exactly, for example some people say use html-dom but they don't know how. </p>
| 0debug
|
static void query_facilities(void)
{
unsigned long hwcap = qemu_getauxval(AT_HWCAP);
if (hwcap & HWCAP_S390_STFLE) {
register int r0 __asm__("0");
register void *r1 __asm__("1");
r1 = &facilities;
asm volatile(".word 0xb2b0,0x1000"
: "=r"(r0) : "0"(0), "r"(r1) : "memory", "cc");
}
}
| 1threat
|
Thumnails for images in Instagram Graph API : <p>I'd like to ask if there is any way to get thumbnail image for media returned from Instagram Graph API? I can get an image URL by using following endpoint: <code>/{InstagramUserId}/media?fields=media_url</code></p>
<p>However it only returns one size. Old Instagram API returned various sizes like <code>low_resolution</code>, <code>thumbnail</code>, <code>standard_size</code>. Is it possible to get similar result by using Instagram Grahp API? </p>
| 0debug
|
Curl_http_done: called premature : <p>I'm building a new service, and when I curl it I see a message Curl_http_done: called premature. I can't find any documentation on what it means and am wondering if my service is not conforming to some http spec?</p>
<pre><code>➜ ~ git:(master) ✗ curl localhost:6764/health -vv
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 6764 (#0)
> GET /health HTTP/1.1
> Host: localhost:6764
> User-Agent: curl/7.51.0
> Accept: */*
>
< HTTP/1.1 200 OK
< content-encoding: application/json
< content-length: 16
< connection: close
<
{"status":"ok"}
* Curl_http_done: called premature == 0
* Closing connection 0
</code></pre>
| 0debug
|
size_t qsb_set_length(QEMUSizedBuffer *qsb, size_t new_len)
{
if (new_len <= qsb->size) {
qsb->used = new_len;
} else {
qsb->used = qsb->size;
}
return qsb->used;
}
| 1threat
|
How to Remove Brackets and Quotes : <p>How do to remove Brackets and Quotes which is display when variable result is called in the label below. </p>
<pre><code>sql = "SELECT question FROM questions WHERE id='1'"
cursor.execute(sql)
result = cursor.fetchone()enter code here
print result
# print(result)
root6 = Tk()
root6.title("EVALUATION -FORM")
root6.geometry("450x300")
var6 = IntVar()
# disconnect from server
db.close()
k = Label(root6, text=result)
k.pack()
k.place(x=20, y=15)
</code></pre>
| 0debug
|
How can i fetch the html content inside div with class=container in angular2 : I want to fetch the **HTML** content inside the class 'container'. After searching i am able to write some code but i have not been able to fetch the html content needed. Please help
>It will be better if i can do it using id than class
my `edit.component.ts` function is shown below-
selectDiv() {
//create a new HTMLElement from nativeElement
var hElement: HTMLElement = this.elRef.nativeElement;
//now you can simply get your elements with their class name
var allDivs = hElement.getElementsByClassName('container');
//do something with selected elements
console.log(allDivs);
}
my `edit.component.html` code is below:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button (click)="selectDiv()">select div</button>
<div id="container" class="container">
<p id="alert" contenteditable="true">
EDIT ME
</p>
</div>
| 0debug
|
Error:could not create the Java Virtual Machine Error:A fatal exception has occured.Program will exit : <p>I have just installed Java SE Development Kit 8u91 on my 64 bit Windows-10 OS. I set my <em>path</em> variables . I tried <strong>java --version</strong> in my command prompt it gave me an error.</p>
<pre><code>c:\Users\Onlymanu>java --version
Unrecognized option: --version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
</code></pre>
<p>But when i tried <strong>java -version</strong> it worked. </p>
<p>I tried initializing <em>_JAVA_OPTIONS</em> environment variable and ever tried re-installation none of them worked. Can any one help me please?</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.