problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void do_attach(USBDevice *dev)
{
USBBus *bus = usb_bus_from_device(dev);
USBPort *port;
if (dev->attached) {
fprintf(stderr, "Warning: tried to attach usb device %s twice\n",
dev->devname);
return;
}
dev->attached++;
port = TAILQ_FIRST(&bus->free);
TAILQ_REMOVE(&bus->free, port, next);
bus->nfree--;
usb_attach(port, dev);
TAILQ_INSERT_TAIL(&bus->used, port, next);
bus->nused++;
}
| 1threat
|
static void vmport_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = vmport_realizefn;
dc->no_user = 1;
}
| 1threat
|
Get highest range from the overlapping ranges : <p>I have a file with ranges. I want the highest ranges from the list and remove other small overlapping ranges:</p>
<pre><code>chr1A 77568 86766
chr1A 203138 204427
chr1A 204428 222994
chr1A 204428 206534
chr1A 206538 207965
chr1A 207967 213097
chr1A 213098 221111
chr1A 213098 213863
chr1A 213864 214195
chr1A 214196 221111
chr1A 221112 222994
chr1A 222995 223876
chr1A 223882 227109
chr1A 305432 314629
chr1A 323643 325976
chr1A 431741 451601
chr1A 431741 435137
chr1A 435141 436568
chr1A 436570 441700
chr1A 441701 449710
chr1A 441701 442466
chr1A 442467 442798
chr1A 442799 449710
chr1A 449711 451601
</code></pre>
<p>For example:</p>
<p>The first and second ranges are unique so these are kept.</p>
<p>Third to 11th ranges have overlapping, only highest one <code>chr1A 204428 222994</code> is kept and so on.</p>
<p>I want the output like this:</p>
<pre><code>chr1A 77568 86766
chr1A 203138 204427
chr1A 204428 222994
chr1A 222995 223876
chr1A 223882 227109
chr1A 305432 314629
chr1A 323643 325976
chr1A 431741 451601
</code></pre>
<p>I hope to get the solution in perl, bash or any other unix tool. Thanks</p>
| 0debug
|
static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
ByteIOContext *pb = s->pb;
pkt_type_t pkt_type;
int pkt_len;
while (!url_feof(pb)) {
int track_type, track_id, ret;
int field_nr;
int stream_index;
if (!parse_packet_header(pb, &pkt_type, &pkt_len)) {
if (!url_feof(pb))
av_log(s, AV_LOG_ERROR, "GXF: sync lost\n");
return -1;
}
if (pkt_type == PKT_FLT) {
gxf_read_index(s, pkt_len);
continue;
}
if (pkt_type != PKT_MEDIA) {
url_fskip(pb, pkt_len);
continue;
}
if (pkt_len < 16) {
av_log(s, AV_LOG_ERROR, "GXF: invalid media packet length\n");
continue;
}
pkt_len -= 16;
track_type = get_byte(pb);
track_id = get_byte(pb);
stream_index = get_sindex(s, track_id, track_type);
if (stream_index < 0)
return stream_index;
field_nr = get_be32(pb);
get_be32(pb);
get_be32(pb);
get_byte(pb);
get_byte(pb);
, it might be better to take this into account
ret = av_get_packet(pb, pkt, pkt_len);
pkt->stream_index = stream_index;
pkt->dts = field_nr;
return ret;
}
return AVERROR(EIO);
}
| 1threat
|
How can i replace special characters by regex and objective c : Helle everyone.
Now i want to replace special character as - _ and i want to use regex to replace it.
Please help me. Thank you so much.
| 0debug
|
How to mock a Kotlin singleton object? : <p>Given a Kotlin singleton object and a fun that call it's method</p>
<pre><code>object SomeObject {
fun someFun() {}
}
fun callerFun() {
SomeObject.someFun()
}
</code></pre>
<p>Is there a way to mock call to <code>SomeObject.someFun()</code>?</p>
| 0debug
|
Linux: Can't get home directory of user which contains whitespace : <p>I register standard user from GUI in CentOS 7(Shambala). From vipw file I changed its the users content<br>
<code>sha mbala:x:1001:1001:sha mbala:/home/sha mbala:/bin/bash</code><br>
and now I'm having trouble with entering in home directory with<br></p>
<pre><code>cd ~sha mbala
</code></pre>
<p>I Also tried<br></p>
<pre><code>cd ~sha\ mbala
</code></pre>
<p>The problem is that I need to enter home directory using ~.</p>
| 0debug
|
How fix attr/colorError in Android studio : org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugResources'.
Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
C:\Users\Jarup\.gradle\caches\transforms-1\files-1.1\card-form-3.5.0.aar\cb262b69320916545281c54ceaa4ba26\res\values\values.xml:57:5-60:13: AAPT: error: style attribute 'attr/colorError (aka com.example.lun.pocket_health_advisor:attr/colorError)' not found.
Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
C:\Users\Jarup\AndroidStudioProjects\healthcare\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2493: error: style attribute 'attr/colorError (aka com.example.lun.pocket_health_advisor:attr/colorError)' not found.
error: failed linking references.
| 0debug
|
static QDict *monitor_parse_arguments(Monitor *mon,
const char **endp,
const mon_cmd_t *cmd)
{
const char *typestr;
char *key;
int c;
const char *p = *endp;
char buf[1024];
QDict *qdict = qdict_new();
typestr = cmd->args_type;
for(;;) {
typestr = key_get_info(typestr, &key);
if (!typestr)
break;
c = *typestr;
typestr++;
switch(c) {
case 'F':
case 'B':
case 's':
{
int ret;
while (qemu_isspace(*p))
p++;
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
break;
}
}
ret = get_str(buf, sizeof(buf), &p);
if (ret < 0) {
switch(c) {
case 'F':
monitor_printf(mon, "%s: filename expected\n",
cmd->name);
break;
case 'B':
monitor_printf(mon, "%s: block device name expected\n",
cmd->name);
break;
default:
monitor_printf(mon, "%s: string expected\n", cmd->name);
break;
}
goto fail;
}
qdict_put(qdict, key, qstring_from_str(buf));
}
break;
case 'O':
{
QemuOptsList *opts_list;
QemuOpts *opts;
opts_list = qemu_find_opts(key);
if (!opts_list || opts_list->desc->name) {
goto bad_type;
}
while (qemu_isspace(*p)) {
p++;
}
if (!*p)
break;
if (get_str(buf, sizeof(buf), &p) < 0) {
goto fail;
}
opts = qemu_opts_parse_noisily(opts_list, buf, true);
if (!opts) {
goto fail;
}
qemu_opts_to_qdict(opts, qdict);
qemu_opts_del(opts);
}
break;
case '/':
{
int count, format, size;
while (qemu_isspace(*p))
p++;
if (*p == '/') {
p++;
count = 1;
if (qemu_isdigit(*p)) {
count = 0;
while (qemu_isdigit(*p)) {
count = count * 10 + (*p - '0');
p++;
}
}
size = -1;
format = -1;
for(;;) {
switch(*p) {
case 'o':
case 'd':
case 'u':
case 'x':
case 'i':
case 'c':
format = *p++;
break;
case 'b':
size = 1;
p++;
break;
case 'h':
size = 2;
p++;
break;
case 'w':
size = 4;
p++;
break;
case 'g':
case 'L':
size = 8;
p++;
break;
default:
goto next;
}
}
next:
if (*p != '\0' && !qemu_isspace(*p)) {
monitor_printf(mon, "invalid char in format: '%c'\n",
*p);
goto fail;
}
if (format < 0)
format = default_fmt_format;
if (format != 'i') {
if (size < 0)
size = default_fmt_size;
default_fmt_size = size;
}
default_fmt_format = format;
} else {
count = 1;
format = default_fmt_format;
if (format != 'i') {
size = default_fmt_size;
} else {
size = -1;
}
}
qdict_put(qdict, "count", qint_from_int(count));
qdict_put(qdict, "format", qint_from_int(format));
qdict_put(qdict, "size", qint_from_int(size));
}
break;
case 'i':
case 'l':
case 'M':
{
int64_t val;
while (qemu_isspace(*p))
p++;
if (*typestr == '?' || *typestr == '.') {
if (*typestr == '?') {
if (*p == '\0') {
typestr++;
break;
}
} else {
if (*p == '.') {
p++;
while (qemu_isspace(*p))
p++;
} else {
typestr++;
break;
}
}
typestr++;
}
if (get_expr(mon, &val, &p))
goto fail;
if ((c == 'i') && ((val >> 32) & 0xffffffff)) {
monitor_printf(mon, "\'%s\' has failed: ", cmd->name);
monitor_printf(mon, "integer is for 32-bit values\n");
goto fail;
} else if (c == 'M') {
if (val < 0) {
monitor_printf(mon, "enter a positive value\n");
goto fail;
}
val <<= 20;
}
qdict_put(qdict, key, qint_from_int(val));
}
break;
case 'o':
{
int64_t val;
char *end;
while (qemu_isspace(*p)) {
p++;
}
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
break;
}
}
val = qemu_strtosz_MiB(p, &end);
if (val < 0) {
monitor_printf(mon, "invalid size\n");
goto fail;
}
qdict_put(qdict, key, qint_from_int(val));
p = end;
}
break;
case 'T':
{
double val;
while (qemu_isspace(*p))
p++;
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
break;
}
}
if (get_double(mon, &val, &p) < 0) {
goto fail;
}
if (p[0] && p[1] == 's') {
switch (*p) {
case 'm':
val /= 1e3; p += 2; break;
case 'u':
val /= 1e6; p += 2; break;
case 'n':
val /= 1e9; p += 2; break;
}
}
if (*p && !qemu_isspace(*p)) {
monitor_printf(mon, "Unknown unit suffix\n");
goto fail;
}
qdict_put(qdict, key, qfloat_from_double(val));
}
break;
case 'b':
{
const char *beg;
bool val;
while (qemu_isspace(*p)) {
p++;
}
beg = p;
while (qemu_isgraph(*p)) {
p++;
}
if (p - beg == 2 && !memcmp(beg, "on", p - beg)) {
val = true;
} else if (p - beg == 3 && !memcmp(beg, "off", p - beg)) {
val = false;
} else {
monitor_printf(mon, "Expected 'on' or 'off'\n");
goto fail;
}
qdict_put(qdict, key, qbool_from_bool(val));
}
break;
case '-':
{
const char *tmp = p;
int skip_key = 0;
c = *typestr++;
if (c == '\0')
goto bad_type;
while (qemu_isspace(*p))
p++;
if (*p == '-') {
p++;
if(c != *p) {
if(!is_valid_option(p, typestr)) {
monitor_printf(mon, "%s: unsupported option -%c\n",
cmd->name, *p);
goto fail;
} else {
skip_key = 1;
}
}
if(skip_key) {
p = tmp;
} else {
p++;
qdict_put(qdict, key, qbool_from_bool(true));
}
}
}
break;
case 'S':
{
int len;
while (qemu_isspace(*p)) {
p++;
}
if (*typestr == '?') {
typestr++;
if (*p == '\0') {
break;
}
}
len = strlen(p);
if (len <= 0) {
monitor_printf(mon, "%s: string expected\n",
cmd->name);
goto fail;
}
qdict_put(qdict, key, qstring_from_str(p));
p += len;
}
break;
default:
bad_type:
monitor_printf(mon, "%s: unknown type '%c'\n", cmd->name, c);
goto fail;
}
g_free(key);
key = NULL;
}
while (qemu_isspace(*p))
p++;
if (*p != '\0') {
monitor_printf(mon, "%s: extraneous characters at the end of line\n",
cmd->name);
goto fail;
}
return qdict;
fail:
QDECREF(qdict);
g_free(key);
return NULL;
}
| 1threat
|
def find_gcd(x, y):
while(y):
x, y = y, x % y
return x
def get_gcd(l):
num1 = l[0]
num2 = l[1]
gcd = find_gcd(num1, num2)
for i in range(2, len(l)):
gcd = find_gcd(gcd, l[i])
return gcd
| 0debug
|
Select prices the last 5 rows of the table : i would like to know how could i get the last 5 rows and only show the prices that has the same value.
Here is an example of my Table
IDPRICES | PRICES <br/>
39 | 500 <br/>
38 | 300 <br/>
37 | 100 <br/>
36 | 200 <br/>
35 | 500
now i only want to show the values rows 35 and 39
Here is an example of my Query
select idprices, prices from test.prices
order by idprices desc
limit 5
;
| 0debug
|
Implement Row Limit in sql data fetch : <p>In SQL Server, I want to restrict users to fetch all the data from the table. For example, If user execute, "select * from table", it will show only 100 rows, although i have millions of rows in table, so that it will not impact my production. I have more then 1000 tables in my database.</p>
<p>Thanks in advance!!</p>
| 0debug
|
Explanation stored procedure : I Am trying to understand a stored procedure, but i don't get it. I'm totally new to stored procedures. I have ordered a book about t-sql but it didn't arrived yet. I'm litterally stuck.
Can someone please explain to me what the following stored procedure, exactly does?
[Stored procedure][1]
I know that ALTER stands for, modifying the stored procedure,
@ Region and @ State are the parameters.
Begin is where the stored procedure starts
When do you have to use '' , like in the first select statement?
What exaclty is the LO. and PR. ?
[1]: http://i.stack.imgur.com/xQP1G.png
| 0debug
|
static int vpc_create(const char *filename, QEMUOptionParameter *options)
{
uint8_t buf[1024];
struct vhd_footer *footer = (struct vhd_footer *) buf;
QEMUOptionParameter *disk_type_param;
int fd, i;
uint16_t cyls = 0;
uint8_t heads = 0;
uint8_t secs_per_cyl = 0;
int64_t total_sectors;
int64_t total_size;
int disk_type;
int ret = -EIO;
total_size = get_option_parameter(options, BLOCK_OPT_SIZE)->value.n;
disk_type_param = get_option_parameter(options, BLOCK_OPT_SUBFMT);
if (disk_type_param && disk_type_param->value.s) {
if (!strcmp(disk_type_param->value.s, "dynamic")) {
disk_type = VHD_DYNAMIC;
} else if (!strcmp(disk_type_param->value.s, "fixed")) {
disk_type = VHD_FIXED;
} else {
return -EINVAL;
}
} else {
disk_type = VHD_DYNAMIC;
}
fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
if (fd < 0) {
return -EIO;
}
total_sectors = total_size / BDRV_SECTOR_SIZE;
for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) {
if (calculate_geometry(total_sectors + i, &cyls, &heads,
&secs_per_cyl))
{
ret = -EFBIG;
goto fail;
}
}
total_sectors = (int64_t) cyls * heads * secs_per_cyl;
memset(buf, 0, 1024);
memcpy(footer->creator, "conectix", 8);
memcpy(footer->creator_app, "qemu", 4);
memcpy(footer->creator_os, "Wi2k", 4);
footer->features = be32_to_cpu(0x02);
footer->version = be32_to_cpu(0x00010000);
if (disk_type == VHD_DYNAMIC) {
footer->data_offset = be64_to_cpu(HEADER_SIZE);
} else {
footer->data_offset = be64_to_cpu(0xFFFFFFFFFFFFFFFFULL);
}
footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE);
footer->major = be16_to_cpu(0x0005);
footer->minor = be16_to_cpu(0x0003);
if (disk_type == VHD_DYNAMIC) {
footer->orig_size = be64_to_cpu(total_sectors * 512);
footer->size = be64_to_cpu(total_sectors * 512);
} else {
footer->orig_size = be64_to_cpu(total_size);
footer->size = be64_to_cpu(total_size);
}
footer->cyls = be16_to_cpu(cyls);
footer->heads = heads;
footer->secs_per_cyl = secs_per_cyl;
footer->type = be32_to_cpu(disk_type);
footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE));
if (disk_type == VHD_DYNAMIC) {
ret = create_dynamic_disk(fd, buf, total_sectors);
} else {
ret = create_fixed_disk(fd, buf, total_size);
}
fail:
qemu_close(fd);
return ret;
}
| 1threat
|
How to mock new Date() in java using power mockito : <p>I am currently have a requirement where in, need to mock new Date() to a specific date for all the test cases.</p>
<pre><code>@Before
public void setUp() throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date NOW = sdf.parse("2015-09-26 00:00:00");
whenNew(Date.class).withAnyArguments().thenReturn(NOW);
}
</code></pre>
<p>So i used the above code to mock it , but still when i see the output of the test results, i could still see the actual "new Date()" is executed.</p>
<p>So i added this in @before block in all the test files. So can you please help to know if I am missing anything?</p>
| 0debug
|
static uint32_t m5206_mbar_readb(void *opaque, target_phys_addr_t offset)
{
m5206_mbar_state *s = (m5206_mbar_state *)opaque;
offset &= 0x3ff;
if (offset >= 0x200) {
hw_error("Bad MBAR read offset 0x%x", (int)offset);
}
if (m5206_mbar_width[offset >> 2] > 1) {
uint16_t val;
val = m5206_mbar_readw(opaque, offset & ~1);
if ((offset & 1) == 0) {
val >>= 8;
}
return val & 0xff;
}
return m5206_mbar_read(s, offset, 1);
}
| 1threat
|
av_cold void ff_fft_init_arm(FFTContext *s)
{
if (HAVE_NEON) {
s->fft_permute = ff_fft_permute_neon;
s->fft_calc = ff_fft_calc_neon;
s->imdct_calc = ff_imdct_calc_neon;
s->imdct_half = ff_imdct_half_neon;
s->mdct_calc = ff_mdct_calc_neon;
s->permutation = FF_MDCT_PERM_INTERLEAVE;
}
}
| 1threat
|
int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, int *pnum)
{
int64_t ret = bdrv_get_block_status(bs, sector_num, nb_sectors, pnum);
if (ret < 0) {
return ret;
}
return (ret & BDRV_BLOCK_ALLOCATED);
}
| 1threat
|
static inline TranslationBlock *tb_find_fast(void)
{
TranslationBlock *tb;
target_ulong cs_base, pc;
uint64_t flags;
#if defined(TARGET_I386)
flags = env->hflags;
flags |= (env->eflags & (IOPL_MASK | TF_MASK | VM_MASK));
flags |= env->intercept;
cs_base = env->segs[R_CS].base;
pc = cs_base + env->eip;
#elif defined(TARGET_ARM)
flags = env->thumb | (env->vfp.vec_len << 1)
| (env->vfp.vec_stride << 4);
if ((env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR)
flags |= (1 << 6);
if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30))
flags |= (1 << 7);
flags |= (env->condexec_bits << 8);
cs_base = 0;
pc = env->regs[15];
#elif defined(TARGET_SPARC)
#ifdef TARGET_SPARC64
flags = (((env->pstate & PS_PEF) >> 1) | ((env->fprs & FPRS_FEF) << 2))
| (env->pstate & PS_PRIV) | ((env->lsu & (DMMU_E | IMMU_E)) >> 2);
#else
flags = (env->psref << 4) | env->psrs;
#endif
cs_base = env->npc;
pc = env->pc;
#elif defined(TARGET_PPC)
flags = env->hflags;
cs_base = 0;
pc = env->nip;
#elif defined(TARGET_MIPS)
flags = env->hflags & (MIPS_HFLAG_TMASK | MIPS_HFLAG_BMASK);
cs_base = 0;
pc = env->PC[env->current_tc];
#elif defined(TARGET_M68K)
flags = (env->fpcr & M68K_FPCR_PREC)
| (env->sr & SR_S)
| ((env->macsr >> 4) & 0xf);
cs_base = 0;
pc = env->pc;
#elif defined(TARGET_SH4)
flags = env->flags;
cs_base = 0;
pc = env->pc;
#elif defined(TARGET_ALPHA)
flags = env->ps;
cs_base = 0;
pc = env->pc;
#elif defined(TARGET_CRIS)
flags = env->pregs[PR_CCS] & (U_FLAG | X_FLAG);
cs_base = 0;
pc = env->pc;
#else
#error unsupported CPU
#endif
tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];
if (__builtin_expect(!tb || tb->pc != pc || tb->cs_base != cs_base ||
tb->flags != flags, 0)) {
tb = tb_find_slow(pc, cs_base, flags);
if (tb_invalidated_flag) {
T0 = 0;
}
}
return tb;
}
| 1threat
|
How to covert a string to time stamp in java? : Here is my code,
SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
Date dft = (Date) format.parse("16-MAY-2018 09:30:22");
I am getting below exception
> java.text.ParseException: Unparseable date: "16-MAY-2018 09:30:22"
I have searched over stackoverflow and many other sites, referred kind of questions, but didn't find a solution for this.
| 0debug
|
Problems creating custom txt names in C : I am having trouble creating custom filenames in C. The goal is to use custom files to print data to for separate entities. My current code for the printing to the file is:
```
void output(int t, double rx[], double ry[], double rz[], double vx[], double vy[], double vz[], double fx[], double fy[], double fz[])
{
for(int i = 0; i < Npart; i++)
{
char name[20];
sprintf(name, "Part_%d.txt", i);
fptr = fopen(name, "a");
fprintf(fptr, "%4d, %10.2e, %10.2e, %10.2e, %10.2e, %10.2e, %10.2e, %10.2e, %10.2e, %10.2e\n", t, rx[i], ry[i], rz[i], vx[i], vy[i], vz[i], fx[i], fy[i], fz[i]);
}
}
```
The fptr has been initialised using *FILE.
In this code Npart is currently only 2 entities (its set to 2 by a #define), but will be a lot bigger once I progress the program. Sadly when running this code it seems to work for low numbers of outputs, until 464 per file to be exact.
After that I get the following error message:
```
timestep made, time is 463
Segmentation fault (core dumped)
```
When removing the output functionality and running the code without it no problems occur. Is there any clear mistake I have made in this code?
| 0debug
|
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/logging/LogFactory : <p>Similar questions have need asked already. But this one seems to be more complicated than previous ones because of changes in compatibility of Android Platforms.</p>
<p>Here is my error log from Pixel and Pixel2 which are signed up for Android Beta Program</p>
<pre><code>08-16 13:20:53.146 9630-9630/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: me.project.android.dev, PID: 9630
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/logging/LogFactory;
at com.amazonaws.util.VersionInfoUtils.<clinit>(VersionInfoUtils.java:41)
at com.amazonaws.util.VersionInfoUtils.c(VersionInfoUtils.java:77)
at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:43)
//project specific class reference removed
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.commons.logging.LogFactory" on path: DexPathList[[zip file "/data/app/me.project.android.dev-0SPRJnc8-4voauRU7Y20zQ==/base.apk"],nativeLibraryDirectories=[/data/app/me.project.android.dev-0SPRJnc8-4voauRU7Y20zQ==/lib/arm64, /data/app/me.project.android.dev-0SPRJnc8-4voauRU7Y20zQ==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.amazonaws.util.VersionInfoUtils.<clinit>(VersionInfoUtils.java:41)
at com.amazonaws.util.VersionInfoUtils.c(VersionInfoUtils.java:77)
at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:43)
//project specific class reference removed
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
</code></pre>
<p>Same code when ran on Devices running Android 7.0 and below, it works perfectly fine.</p>
<p>I tried adding dependency to my project too</p>
<pre><code>implementation "commons-logging:commons-logging:1.2"
</code></pre>
<p>Adding this dependency makes the app work in Pixel and Pixel but then it crashes in all other devices with Exception saying </p>
<pre><code>org.apache.commons.logging.impl.LogFactoryImpl does not extend or implement org.apache.commons.logging.LogFactory
</code></pre>
<p>I tried doing all the changes in ProGuard already. Here is my proguard configuration</p>
<pre><code>-keep class org.apache.commons.logging.impl.LogFactoryImpl
-keep class org.apache.commons.logging.LogFactory
-keepnames class org.apache.commons.logging.impl.* {*;}
-keepnames class org.apache.commons.logging.*
-keepclassmembers class org.apache.commons.logging.impl.* {*;}
-keepclassmembers class org.apache.commons.logging.*
-keepnames interface org.apache.commons.logging.impl.* {*;}
-keepnames interface org.apache.commons.logging.*
</code></pre>
<p>Still causing the crash.</p>
<p>This issue is related to Amazon AWS SDK - <a href="https://github.com/aws/aws-sdk-android/issues/476" rel="noreferrer">https://github.com/aws/aws-sdk-android/issues/476</a></p>
<p>Is there any workaround till AWS updates their SDK to fix this issue?</p>
| 0debug
|
void qemu_put_be16(QEMUFile *f, unsigned int v)
{
qemu_put_byte(f, v >> 8);
qemu_put_byte(f, v);
}
| 1threat
|
Nginx location configuration (subfolders) : <p>lets say I've a path like:</p>
<pre><code>/var/www/myside/
</code></pre>
<p>that path contains two folders... let's say
<code>/static</code> and <code>/manage</code></p>
<p>I'd like to configure nginx to have an access to:</p>
<p><code>/static</code> folder on <code>/</code> (eg. <a href="http://example.org/" rel="noreferrer">http://example.org/</a>)
this folder has some .html files. </p>
<p><code>/manage</code> folder on <code>/manage</code> (eg. <a href="http://example.org/manage" rel="noreferrer">http://example.org/manage</a>) in this case this folder contains Slim's PHP framework code - that means the index.php file is in <code>public</code> subfolder (eg. /var/www/mysite/manage/public/index.php)</p>
<p>I've tried a lot of combinations such as </p>
<pre><code>server {
listen 80;
server_name example.org;
error_log /usr/local/etc/nginx/logs/mysite/error.log;
access_log /usr/local/etc/nginx/logs/mysite/access.log;
root /var/www/mysite;
location /manage {
root $uri/manage/public;
try_files $uri /index.php$is_args$args;
}
location / {
root $uri/static/;
index index.html;
}
location ~ \.php {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
}
</code></pre>
<p>}</p>
<p>The <code>/</code> works correctly anyway <code>manage</code> doesn't. Am I doing something wrong? Does anybody know what should I change?</p>
<p>Matthew.</p>
| 0debug
|
av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
{
int n = 1 << nbits;
int ret;
s->nbits = nbits;
s->inverse = trans == IDFT_C2R || trans == DFT_C2R;
s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1;
if (nbits < 4 || nbits > 16)
return AVERROR(EINVAL);
if ((ret = ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C)) < 0)
return ret;
ff_init_ff_cos_tabs(nbits);
s->tcos = ff_cos_tabs[nbits];
s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(n>>2);
#if !CONFIG_HARDCODED_TABLES
{
int i;
const double theta = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1) * 2 * M_PI / n;
for (i = 0; i < (n >> 2); i++)
s->tsin[i] = sin(i * theta);
}
#endif
s->rdft_calc = rdft_calc_c;
if (ARCH_ARM) ff_rdft_init_arm(s);
return 0;
}
| 1threat
|
static int vp9_raw_reorder_make_output(AVBSFContext *bsf,
AVPacket *out,
VP9RawReorderFrame *last_frame)
{
VP9RawReorderContext *ctx = bsf->priv_data;
VP9RawReorderFrame *next_output = last_frame,
*next_display = last_frame, *frame;
int s, err;
for (s = 0; s < FRAME_SLOTS; s++) {
frame = ctx->slot[s];
if (!frame)
continue;
if (frame->needs_output && (!next_output ||
frame->sequence < next_output->sequence))
next_output = frame;
if (frame->needs_display && (!next_display ||
frame->pts < next_display->pts))
next_display = frame;
}
if (!next_output && !next_display)
return AVERROR_EOF;
if (!next_display || (next_output &&
next_output->sequence < next_display->sequence))
frame = next_output;
else
frame = next_display;
if (frame->needs_output && frame->needs_display &&
next_output == next_display) {
av_log(bsf, AV_LOG_DEBUG, "Output and display frame "
"%"PRId64" (%"PRId64") in order.\n",
frame->sequence, frame->pts);
av_packet_move_ref(out, frame->packet);
frame->needs_output = frame->needs_display = 0;
} else if (frame->needs_output) {
if (frame->needs_display) {
av_log(bsf, AV_LOG_DEBUG, "Output frame %"PRId64" "
"(%"PRId64") for later display.\n",
frame->sequence, frame->pts);
} else {
av_log(bsf, AV_LOG_DEBUG, "Output unshown frame "
"%"PRId64" (%"PRId64") to keep order.\n",
frame->sequence, frame->pts);
}
av_packet_move_ref(out, frame->packet);
out->pts = out->dts;
frame->needs_output = 0;
} else {
PutBitContext pb;
av_assert0(!frame->needs_output && frame->needs_display);
if (frame->slots == 0) {
av_log(bsf, AV_LOG_ERROR, "Attempting to display frame "
"which is no longer available?\n");
frame->needs_display = 0;
return AVERROR_INVALIDDATA;
}
s = ff_ctz(frame->slots);
av_assert0(s < FRAME_SLOTS);
av_log(bsf, AV_LOG_DEBUG, "Display frame %"PRId64" "
"(%"PRId64") from slot %d.\n",
frame->sequence, frame->pts, s);
frame->packet = av_packet_alloc();
if (!frame->packet)
return AVERROR(ENOMEM);
err = av_new_packet(out, 2);
if (err < 0)
return err;
init_put_bits(&pb, out->data, 2);
put_bits(&pb, 2, 2);
put_bits(&pb, 1, frame->profile & 1);
put_bits(&pb, 1, (frame->profile >> 1) & 1);
if (frame->profile == 3) {
put_bits(&pb, 1, 0);
}
put_bits(&pb, 1, 1);
put_bits(&pb, 3, s);
while (put_bits_count(&pb) < 16)
put_bits(&pb, 1, 0);
flush_put_bits(&pb);
out->pts = out->dts = frame->pts;
frame->needs_display = 0;
}
return 0;
}
| 1threat
|
Unable to resolve module 'AccessibilityInfo', when trying to create release bundle : <p>I am running </p>
<pre><code>react-native bundle --platform windows --dev false --entry-file index.windows.js --bundle-output windows/app/ReactAssets/index.windows.bundle --assets-dest windows/app/ ReactAssets/
</code></pre>
<p>command to create release bundle, but I am getting following error</p>
<pre><code>Unable to resolve module `AccessibilityInfo` from `C:\Users\godha.pranay\project\node_modules\react-native\Libraries\react-native\react-native-implementation.js`: Module does not exist in the module map
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset Metro Bundler cache: `rm -rf $TMPDIR/react-*` or `npm start -- --reset-cache`. 4. Remove haste cache: `rm -rf $TMPDIR/haste-map-react-native-packager-*`.
</code></pre>
<p>I tried everything recommended on internet, nothing is working. I am totally stuck on it. Please help.</p>
| 0debug
|
How to instantiate and apply directives programmatically? : <p>I know that in ng2 we have <code>ComponentFactoryResolver</code> that can resolve factories that we can apply to a <code>ViewContainerRef</code>.</p>
<p>But, is there something similar for directives? a way to instantiate them and apply them to the projected content from a component?</p>
| 0debug
|
static int split_init(AVFilterContext *ctx, const char *args, void *opaque)
{
int i, nb_outputs = 2;
if (args) {
nb_outputs = strtol(args, NULL, 0);
if (nb_outputs <= 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid number of outputs specified: %d.\n",
nb_outputs);
return AVERROR(EINVAL);
}
}
for (i = 0; i < nb_outputs; i++) {
char name[32];
AVFilterPad pad = { 0 };
snprintf(name, sizeof(name), "output%d", i);
pad.type = !strcmp(ctx->name, "split") ? AVMEDIA_TYPE_VIDEO : AVMEDIA_TYPE_AUDIO;
pad.name = av_strdup(name);
avfilter_insert_outpad(ctx, i, &pad);
}
return 0;
}
| 1threat
|
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet)
{
ProresContext *ctx = avctx->priv_data;
uint8_t *orig_buf, *buf, *slice_hdr, *slice_sizes, *tmp;
uint8_t *picture_size_pos;
PutBitContext pb;
int x, y, i, mb, q = 0;
int sizes[4] = { 0 };
int slice_hdr_size = 2 + 2 * (ctx->num_planes - 1);
int frame_size, picture_size, slice_size;
int pkt_size, ret;
uint8_t frame_flags;
*avctx->coded_frame = *pic;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
pkt_size = ctx->frame_size_upper_bound;
if ((ret = ff_alloc_packet(pkt, pkt_size + FF_MIN_BUFFER_SIZE)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
orig_buf = pkt->data;
orig_buf += 4;
bytestream_put_be32 (&orig_buf, FRAME_ID);
buf = orig_buf;
tmp = buf;
buf += 2; size will be stored here
bytestream_put_be16 (&buf, 0);
bytestream_put_buffer(&buf, ctx->vendor, 4);
bytestream_put_be16 (&buf, avctx->width);
bytestream_put_be16 (&buf, avctx->height);
frame_flags = ctx->chroma_factor << 6;
if (avctx->flags & CODEC_FLAG_INTERLACED_DCT)
frame_flags |= pic->top_field_first ? 0x04 : 0x08;
bytestream_put_byte (&buf, frame_flags);
bytestream_put_byte (&buf, 0);
bytestream_put_byte (&buf, avctx->color_primaries);
bytestream_put_byte (&buf, avctx->color_trc);
bytestream_put_byte (&buf, avctx->colorspace);
bytestream_put_byte (&buf, 0x40 | (ctx->alpha_bits >> 3));
bytestream_put_byte (&buf, 0);
if (ctx->quant_sel != QUANT_MAT_DEFAULT) {
bytestream_put_byte (&buf, 0x03);
for (i = 0; i < 64; i++)
bytestream_put_byte(&buf, ctx->quant_mat[i]);
for (i = 0; i < 64; i++)
bytestream_put_byte(&buf, ctx->quant_mat[i]);
} else {
bytestream_put_byte (&buf, 0x00);
}
bytestream_put_be16 (&tmp, buf - orig_buf);
for (ctx->cur_picture_idx = 0;
ctx->cur_picture_idx < ctx->pictures_per_frame;
ctx->cur_picture_idx++) {
picture_size_pos = buf + 1;
bytestream_put_byte (&buf, 0x40); size (in bits)
buf += 4;
bytestream_put_be16 (&buf, ctx->slices_per_picture);
bytestream_put_byte (&buf, av_log2(ctx->mbs_per_slice) << 4);
slice_sizes = buf;
buf += ctx->slices_per_picture * 2;
if (!ctx->force_quant) {
ret = avctx->execute2(avctx, find_quant_thread, NULL, NULL,
ctx->mb_height);
if (ret)
return ret;
}
for (y = 0; y < ctx->mb_height; y++) {
int mbs_per_slice = ctx->mbs_per_slice;
for (x = mb = 0; x < ctx->mb_width; x += mbs_per_slice, mb++) {
q = ctx->force_quant ? ctx->force_quant
: ctx->slice_q[mb + y * ctx->slices_width];
while (ctx->mb_width - x < mbs_per_slice)
mbs_per_slice >>= 1;
bytestream_put_byte(&buf, slice_hdr_size << 3);
slice_hdr = buf;
buf += slice_hdr_size - 1;
init_put_bits(&pb, buf, (pkt_size - (buf - orig_buf)) * 8);
ret = encode_slice(avctx, pic, &pb, sizes, x, y, q,
mbs_per_slice);
if (ret < 0)
return ret;
bytestream_put_byte(&slice_hdr, q);
slice_size = slice_hdr_size + sizes[ctx->num_planes - 1];
for (i = 0; i < ctx->num_planes - 1; i++) {
bytestream_put_be16(&slice_hdr, sizes[i]);
slice_size += sizes[i];
}
bytestream_put_be16(&slice_sizes, slice_size);
buf += slice_size - slice_hdr_size;
}
}
if (ctx->pictures_per_frame == 1)
picture_size = buf - picture_size_pos - 6;
else
picture_size = buf - picture_size_pos + 1;
bytestream_put_be32(&picture_size_pos, picture_size);
}
orig_buf -= 8;
frame_size = buf - orig_buf;
bytestream_put_be32(&orig_buf, frame_size);
pkt->size = frame_size;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| 1threat
|
void qbus_create_inplace(BusState *bus, BusInfo *info,
DeviceState *parent, const char *name)
{
char *buf;
int i,len;
bus->info = info;
bus->parent = parent;
if (name) {
bus->name = qemu_strdup(name);
} else if (parent && parent->id) {
len = strlen(parent->id) + 16;
buf = qemu_malloc(len);
snprintf(buf, len, "%s.%d", parent->id, parent->num_child_bus);
bus->name = buf;
} else {
len = strlen(info->name) + 16;
buf = qemu_malloc(len);
len = snprintf(buf, len, "%s.%d", info->name,
parent ? parent->num_child_bus : 0);
for (i = 0; i < len; i++)
buf[i] = qemu_tolower(buf[i]);
bus->name = buf;
}
QLIST_INIT(&bus->children);
if (parent) {
QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling);
parent->num_child_bus++;
}
}
| 1threat
|
static inline void RENAME(rgb24to15)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_15mask),"m"(green_15mask));
mm_end = end - 11;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 3%1, %%mm3\n\t"
"punpckldq 6%1, %%mm0\n\t"
"punpckldq 9%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psrlq $3, %%mm0\n\t"
"psrlq $3, %%mm3\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm3\n\t"
"psrlq $6, %%mm1\n\t"
"psrlq $6, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $9, %%mm2\n\t"
"psrlq $9, %%mm5\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_15mask):"memory");
d += 4;
s += 12;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
const int b= *s++;
const int g= *s++;
const int r= *s++;
*d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7);
}
}
| 1threat
|
static void qmp_input_type_str(Visitor *v, const char *name, char **obj,
Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
QString *qstr = qobject_to_qstring(qmp_input_get_object(qiv, name, true));
if (!qstr) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"string");
return;
}
*obj = g_strdup(qstring_get_str(qstr));
}
| 1threat
|
C++ - Repeat std::getline() as user integer input? : <p>How to repeat std::getline() as user number input like this method:</p>
<pre><code> std::string num;
std::cout << "How many subjects you want to sum: ";
std::getline (std::cin,num);
</code></pre>
<p>Then take user number input and repeat std::getline() many times as input to sum all the subjects marks user will input them after the first questions.</p>
| 0debug
|
static void sp804_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
sp804_state *s = (sp804_state *)opaque;
if (offset < 0x20) {
arm_timer_write(s->timer[0], offset, value);
return;
}
if (offset < 0x40) {
arm_timer_write(s->timer[1], offset - 0x20, value);
return;
}
hw_error("%s: Bad offset %x\n", __func__, (int)offset);
}
| 1threat
|
Error message after successfully pushing to Heroku : <pre><code>remote: Verifying deploy... done.
fatal: protocol error: bad line length character: fata
error: error in sideband demultiplexer
</code></pre>
<p>This just randomly started showing up. My changes are being saved in git and pushing successfully to Heroku. I have no idea what this means or what caused it as I have not done anything new at all. </p>
| 0debug
|
INSERT into MySQL database with JavaScript but without Node.js : <p>I want to <code>INSERT</code> data into my MySQL database.</p>
<p>After some research I found out I can use something called <code>Node.js</code> to do this.</p>
<p>But it seems to complicated for this small thing I want to do.</p>
<p>Is there a way to do this only with JavaScript, without <code>Node.js</code>?</p>
<p>Background: In my web-based iOS app I want to integrate a <code>Favorite</code> button. When the user clicks on the <code>Favorite</code> button on any site some data get stored in my MySQL database (user id, favorited webpage, title of webpage) and the <code>Favorite</code> button changes its color to signal it's favorite and put in the favorite section.</p>
<p>Following problem if doing this with PHP and not JavaScript: The user have to click the <code>Back</code> button twice to get out of this page, because reloading for storing in the database created a new entry in browser history.</p>
<p>Or is there another solution to prevent to the user have to click the back button twice to get out of this page?</p>
| 0debug
|
Ruby Regex - get persons name : <p>Given consistent strings like this:</p>
<pre><code>Manual stage: <b>Release</b> by <a href="https://test/builds/browse/user/a0123456">Joe Bloggs</a>
Changes by <a href="https://test/builds/browse/user/b234556">John Doe</a>
</code></pre>
<p>is there a simple regex I could use to pull the persons name?
is there a simple regex I could to pull the ID (which is at the end of the URL e.g. b1234345)?</p>
<p>Thanks</p>
| 0debug
|
static void vhost_dev_sync_region(struct vhost_dev *dev,
MemoryRegionSection *section,
uint64_t mfirst, uint64_t mlast,
uint64_t rfirst, uint64_t rlast)
{
uint64_t start = MAX(mfirst, rfirst);
uint64_t end = MIN(mlast, rlast);
vhost_log_chunk_t *from = dev->log + start / VHOST_LOG_CHUNK;
vhost_log_chunk_t *to = dev->log + end / VHOST_LOG_CHUNK + 1;
uint64_t addr = (start / VHOST_LOG_CHUNK) * VHOST_LOG_CHUNK;
if (end < start) {
return;
}
assert(end / VHOST_LOG_CHUNK < dev->log_size);
assert(start / VHOST_LOG_CHUNK < dev->log_size);
for (;from < to; ++from) {
vhost_log_chunk_t log;
int bit;
if (!*from) {
addr += VHOST_LOG_CHUNK;
continue;
}
log = __sync_fetch_and_and(from, 0);
while ((bit = sizeof(log) > sizeof(int) ?
ffsll(log) : ffs(log))) {
ram_addr_t ram_addr;
bit -= 1;
ram_addr = section->offset_within_region + bit * VHOST_LOG_PAGE;
memory_region_set_dirty(section->mr, ram_addr, VHOST_LOG_PAGE);
log &= ~(0x1ull << bit);
}
addr += VHOST_LOG_CHUNK;
}
}
| 1threat
|
How to iterate over files in an S3 bucket? : <p>I have a large number of files (>1,000) stored in an S3 bucket, and I would like to iterate over them (e.g. in a <code>for</code> loop) to extract data from them using <code>boto3</code>.</p>
<p>However, I notice that in accordance with <a href="http://boto3.readthedocs.io/en/latest/reference/services/s3.html#S3.Client.list_objects" rel="noreferrer">http://boto3.readthedocs.io/en/latest/reference/services/s3.html#S3.Client.list_objects</a>, the <code>list_objects()</code> method of the <code>Client</code> class only lists up to 1,000 objects:</p>
<pre><code>In [1]: import boto3
In [2]: client = boto3.client('s3')
In [11]: apks = client.list_objects(Bucket='iper-apks')
In [16]: type(apks['Contents'])
Out[16]: list
In [17]: len(apks['Contents'])
Out[17]: 1000
</code></pre>
<p>However, I would like to list <strong>all</strong> the objects, even if there are more than 1,000. How could I achieve this?</p>
| 0debug
|
Extracting the first number after ']' in R : I would like to extract the first number after ']' in a character vector
> dput(dense[1:8])
c(" 481 denseSlack[0,SMITH]", " 0 0 ",
" 482 denseSlack[0,JOHNSON]", " 1 0 ",
" 483 denseSlack[0,WILLIAMS]", " 0 0 ",
" 484 denseSlack[0,JONES]", " 1 0 "
)
The output should be a vector (0,1,0,1).
How can I do this in R?
| 0debug
|
BlockAIOCB *bdrv_aio_flush(BlockDriverState *bs,
BlockCompletionFunc *cb, void *opaque)
{
trace_bdrv_aio_flush(bs, opaque);
Coroutine *co;
BlockAIOCBCoroutine *acb;
acb = qemu_aio_get(&bdrv_em_co_aiocb_info, bs, cb, opaque);
acb->need_bh = true;
acb->req.error = -EINPROGRESS;
co = qemu_coroutine_create(bdrv_aio_flush_co_entry);
qemu_coroutine_enter(co, acb);
bdrv_co_maybe_schedule_bh(acb);
return &acb->common;
}
| 1threat
|
When bulding a CNN, I am getting complaints from Keras that do not make sense to me. : <p>My input shape is supposed to be 100x100. It represents a sentence. Each word is a vector of 100 dimensions and there are 100 words at maximum in a sentence. </p>
<p>I feed eight sentences to the CNN.I am not sure whether this means my input shape should be 100x100x8 instead. </p>
<p>Then the following lines</p>
<pre><code>Convolution2D(10, 3, 3, border_mode='same',
input_shape=(100, 100))
</code></pre>
<p>complains:</p>
<p>Input 0 is incompatible with layer convolution2d_1: expected ndim=4, found ndim=3</p>
<p>This does not make sense to me as my input dimension is 2. I can get through it by changing input_shape to (100,100,8). But the "expected ndim=4" bit just does not make sense to me. </p>
<p>I also cannot see why a convolution layer of 3x3 with 10 filters do not accept input of 100x100. </p>
<p>Even I get thru the complains about the "expected ndim=4". I run into problem in my activation layer. There it complains:</p>
<p>Cannot apply softmax to a tensor that is not 2D or 3D. Here, ndim=4</p>
<p>Can anyone explain what is going on here and how to fix it? Many thanks. </p>
| 0debug
|
static int vcr1_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
VCR1Context *const a = avctx->priv_data;
AVFrame *const p = data;
const uint8_t *bytestream = avpkt->data;
const uint8_t *bytestream_end = bytestream + avpkt->size;
int i, x, y, ret;
if(avpkt->size < 16 + avctx->height + avctx->width*avctx->height*5/8){
av_log(avctx, AV_LOG_ERROR, "Insufficient input data.\n");
return AVERROR(EINVAL);
}
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
return ret;
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
for (i = 0; i < 16; i++) {
a->delta[i] = *bytestream++;
bytestream++;
}
for (y = 0; y < avctx->height; y++) {
int offset;
uint8_t *luma = &p->data[0][y * p->linesize[0]];
if ((y & 3) == 0) {
uint8_t *cb = &p->data[1][(y >> 2) * p->linesize[1]];
uint8_t *cr = &p->data[2][(y >> 2) * p->linesize[2]];
av_assert0 (bytestream_end - bytestream >= 4 + avctx->width);
for (i = 0; i < 4; i++)
a->offset[i] = *bytestream++;
offset = a->offset[0] - a->delta[bytestream[2] & 0xF];
for (x = 0; x < avctx->width; x += 4) {
luma[0] = offset += a->delta[bytestream[2] & 0xF];
luma[1] = offset += a->delta[bytestream[2] >> 4];
luma[2] = offset += a->delta[bytestream[0] & 0xF];
luma[3] = offset += a->delta[bytestream[0] >> 4];
luma += 4;
*cb++ = bytestream[3];
*cr++ = bytestream[1];
bytestream += 4;
}
} else {
av_assert0 (bytestream_end - bytestream >= avctx->width / 2);
offset = a->offset[y & 3] - a->delta[bytestream[2] & 0xF];
for (x = 0; x < avctx->width; x += 8) {
luma[0] = offset += a->delta[bytestream[2] & 0xF];
luma[1] = offset += a->delta[bytestream[2] >> 4];
luma[2] = offset += a->delta[bytestream[3] & 0xF];
luma[3] = offset += a->delta[bytestream[3] >> 4];
luma[4] = offset += a->delta[bytestream[0] & 0xF];
luma[5] = offset += a->delta[bytestream[0] >> 4];
luma[6] = offset += a->delta[bytestream[1] & 0xF];
luma[7] = offset += a->delta[bytestream[1] >> 4];
luma += 8;
bytestream += 4;
}
}
}
*got_frame = 1;
return bytestream - avpkt->data;
}
| 1threat
|
database connection issue with PHP : Issue Is with the database connection for a open source Project(php).
Everything works fine apart from the database connection required for login.Following is the error that can be seen after login.
Warning: require_once(../mysqli_connect.php): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/airline-ticket-reservation-system-master/login_handler.php on line 44
Fatal error: require_once(): Failed opening required '../mysqli_connect.php' (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/airline-ticket-reservation-system-master/login_handler.php on line 44
mysqli_connect.php
`````````````````````
<?php
DEFINE('DB_USER','Harry');
DEFINE('DB_PASSWORD','passpasshello');
DEFINE('DB_HOST','localhost');
DEFINE('DB_NAME','airline_reservation');
$dbc=mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME)
OR dies('Could not connect to MySQL:' .
mysqli_connect_error());
?>[enter image description here][1]
[1]: https://i.stack.imgur.com/PK1gA.jpg
| 0debug
|
How to get rid of ArrayIndexOutOfBoundsException: 3 : <p>I am new in Java and try to understand how it works two dimensional arrays, and i encounter this erros. Thanks</p>
<p>public class Main {</p>
<pre><code>public static int n, m, a[][];
public static void main(String []args){
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
m=sc.nextInt();
a=new int[n][m];
int i,j,s=0;
for (i=0;i<n;i++)
for ( j=0;j<m;j++){
a[i][j]=sc.nextInt();
}
for (i=0;i<a.length;i++){
for (j=0;j<a[i].length;j++){
if (a[i][j+1]>a[i+1][j]) s=s+a[i][j+1];
else s=s+a[i+1][j];
}
}
System.out.println(s);
sc.close();
}
</code></pre>
<p>}</p>
| 0debug
|
How to run a specific maven test class from the terminal? : <p>I have a maven project with junit tests classes.
I want to run a tests in a specific class . how can i do that from the terminal ?
for example i have a test spring junit test class named AccountServiceImplTest under the package com.openmind.service.impl . how can i run all or individual junit tests declared in this test class . I dont want to use mvn clean test as this run all the tests within the project.
appreciate any help
thank you so much</p>
| 0debug
|
static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
{
MpegEncContext *s = &ctx->m;
int width, height, vo_ver_id;
skip_bits(gb, 1);
s->vo_type = get_bits(gb, 8);
if (get_bits1(gb) != 0) {
vo_ver_id = get_bits(gb, 4);
skip_bits(gb, 3);
} else {
vo_ver_id = 1;
}
s->aspect_ratio_info = get_bits(gb, 4);
if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
s->avctx->sample_aspect_ratio.num = get_bits(gb, 8);
s->avctx->sample_aspect_ratio.den = get_bits(gb, 8);
} else {
s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[s->aspect_ratio_info];
}
if ((ctx->vol_control_parameters = get_bits1(gb))) {
int chroma_format = get_bits(gb, 2);
if (chroma_format != CHROMA_420)
av_log(s->avctx, AV_LOG_ERROR, "illegal chroma format\n");
s->low_delay = get_bits1(gb);
if (get_bits1(gb)) {
get_bits(gb, 15);
skip_bits1(gb);
get_bits(gb, 15);
skip_bits1(gb);
get_bits(gb, 15);
skip_bits1(gb);
get_bits(gb, 3);
get_bits(gb, 11);
skip_bits1(gb);
get_bits(gb, 15);
skip_bits1(gb);
}
} else {
if (s->picture_number == 0)
s->low_delay = 0;
}
ctx->shape = get_bits(gb, 2);
if (ctx->shape != RECT_SHAPE)
av_log(s->avctx, AV_LOG_ERROR, "only rectangular vol supported\n");
if (ctx->shape == GRAY_SHAPE && vo_ver_id != 1) {
av_log(s->avctx, AV_LOG_ERROR, "Gray shape not supported\n");
skip_bits(gb, 4);
}
check_marker(gb, "before time_increment_resolution");
s->avctx->framerate.num = get_bits(gb, 16);
if (!s->avctx->framerate.num) {
av_log(s->avctx, AV_LOG_ERROR, "framerate==0\n");
return AVERROR_INVALIDDATA;
}
ctx->time_increment_bits = av_log2(s->avctx->framerate.num - 1) + 1;
if (ctx->time_increment_bits < 1)
ctx->time_increment_bits = 1;
check_marker(gb, "before fixed_vop_rate");
if (get_bits1(gb) != 0)
s->avctx->framerate.den = get_bits(gb, ctx->time_increment_bits);
else
s->avctx->framerate.den = 1;
s->avctx->time_base = av_inv_q(av_mul_q(s->avctx->framerate, (AVRational){s->avctx->ticks_per_frame, 1}));
ctx->t_frame = 0;
if (ctx->shape != BIN_ONLY_SHAPE) {
if (ctx->shape == RECT_SHAPE) {
check_marker(gb, "before width");
width = get_bits(gb, 13);
check_marker(gb, "before height");
height = get_bits(gb, 13);
check_marker(gb, "after height");
if (width && height &&
!(s->width && s->codec_tag == AV_RL32("MP4S"))) {
if (s->width && s->height &&
(s->width != width || s->height != height))
s->context_reinit = 1;
s->width = width;
s->height = height;
}
}
s->progressive_sequence =
s->progressive_frame = get_bits1(gb) ^ 1;
s->interlaced_dct = 0;
if (!get_bits1(gb) && (s->avctx->debug & FF_DEBUG_PICT_INFO))
av_log(s->avctx, AV_LOG_INFO,
"MPEG4 OBMC not supported (very likely buggy encoder)\n");
if (vo_ver_id == 1)
ctx->vol_sprite_usage = get_bits1(gb);
else
ctx->vol_sprite_usage = get_bits(gb, 2);
if (ctx->vol_sprite_usage == STATIC_SPRITE)
av_log(s->avctx, AV_LOG_ERROR, "Static Sprites not supported\n");
if (ctx->vol_sprite_usage == STATIC_SPRITE ||
ctx->vol_sprite_usage == GMC_SPRITE) {
if (ctx->vol_sprite_usage == STATIC_SPRITE) {
skip_bits(gb, 13);
skip_bits1(gb);
skip_bits(gb, 13);
skip_bits1(gb);
skip_bits(gb, 13);
skip_bits1(gb);
skip_bits(gb, 13);
skip_bits1(gb);
}
ctx->num_sprite_warping_points = get_bits(gb, 6);
if (ctx->num_sprite_warping_points > 3) {
av_log(s->avctx, AV_LOG_ERROR,
"%d sprite_warping_points\n",
ctx->num_sprite_warping_points);
ctx->num_sprite_warping_points = 0;
return AVERROR_INVALIDDATA;
}
s->sprite_warping_accuracy = get_bits(gb, 2);
ctx->sprite_brightness_change = get_bits1(gb);
if (ctx->vol_sprite_usage == STATIC_SPRITE)
skip_bits1(gb);
}
if (get_bits1(gb) == 1) {
s->quant_precision = get_bits(gb, 4);
if (get_bits(gb, 4) != 8)
av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n");
if (s->quant_precision != 5)
av_log(s->avctx, AV_LOG_ERROR,
"quant precision %d\n", s->quant_precision);
if (s->quant_precision<3 || s->quant_precision>9) {
s->quant_precision = 5;
}
} else {
s->quant_precision = 5;
}
if ((s->mpeg_quant = get_bits1(gb))) {
int i, v;
for (i = 0; i < 64; i++) {
int j = s->idsp.idct_permutation[i];
v = ff_mpeg4_default_intra_matrix[i];
s->intra_matrix[j] = v;
s->chroma_intra_matrix[j] = v;
v = ff_mpeg4_default_non_intra_matrix[i];
s->inter_matrix[j] = v;
s->chroma_inter_matrix[j] = v;
}
if (get_bits1(gb)) {
int last = 0;
for (i = 0; i < 64; i++) {
int j;
v = get_bits(gb, 8);
if (v == 0)
break;
last = v;
j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
s->intra_matrix[j] = last;
s->chroma_intra_matrix[j] = last;
}
for (; i < 64; i++) {
int j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
s->intra_matrix[j] = last;
s->chroma_intra_matrix[j] = last;
}
}
if (get_bits1(gb)) {
int last = 0;
for (i = 0; i < 64; i++) {
int j;
v = get_bits(gb, 8);
if (v == 0)
break;
last = v;
j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
s->inter_matrix[j] = v;
s->chroma_inter_matrix[j] = v;
}
for (; i < 64; i++) {
int j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
s->inter_matrix[j] = last;
s->chroma_inter_matrix[j] = last;
}
}
}
if (vo_ver_id != 1)
s->quarter_sample = get_bits1(gb);
else
s->quarter_sample = 0;
if (get_bits_left(gb) < 4) {
av_log(s->avctx, AV_LOG_ERROR, "VOL Header truncated\n");
return AVERROR_INVALIDDATA;
}
if (!get_bits1(gb)) {
int pos = get_bits_count(gb);
int estimation_method = get_bits(gb, 2);
if (estimation_method < 2) {
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
}
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
}
if (!check_marker(gb, "in complexity estimation part 1")) {
skip_bits_long(gb, pos - get_bits_count(gb));
goto no_cplx_est;
}
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_i += 4 * get_bits1(gb);
}
if (!get_bits1(gb)) {
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_b += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
}
if (!check_marker(gb, "in complexity estimation part 2")) {
skip_bits_long(gb, pos - get_bits_count(gb));
goto no_cplx_est;
}
if (estimation_method == 1) {
ctx->cplx_estimation_trash_i += 8 * get_bits1(gb);
ctx->cplx_estimation_trash_p += 8 * get_bits1(gb);
}
} else
av_log(s->avctx, AV_LOG_ERROR,
"Invalid Complexity estimation method %d\n",
estimation_method);
} else {
no_cplx_est:
ctx->cplx_estimation_trash_i =
ctx->cplx_estimation_trash_p =
ctx->cplx_estimation_trash_b = 0;
}
ctx->resync_marker = !get_bits1(gb);
s->data_partitioning = get_bits1(gb);
if (s->data_partitioning)
ctx->rvlc = get_bits1(gb);
if (vo_ver_id != 1) {
ctx->new_pred = get_bits1(gb);
if (ctx->new_pred) {
av_log(s->avctx, AV_LOG_ERROR, "new pred not supported\n");
skip_bits(gb, 2);
skip_bits1(gb);
}
if (get_bits1(gb))
av_log(s->avctx, AV_LOG_ERROR,
"reduced resolution VOP not supported\n");
} else {
ctx->new_pred = 0;
}
ctx->scalability = get_bits1(gb);
if (ctx->scalability) {
GetBitContext bak = *gb;
int h_sampling_factor_n;
int h_sampling_factor_m;
int v_sampling_factor_n;
int v_sampling_factor_m;
skip_bits1(gb);
skip_bits(gb, 4);
skip_bits1(gb);
h_sampling_factor_n = get_bits(gb, 5);
h_sampling_factor_m = get_bits(gb, 5);
v_sampling_factor_n = get_bits(gb, 5);
v_sampling_factor_m = get_bits(gb, 5);
ctx->enhancement_type = get_bits1(gb);
if (h_sampling_factor_n == 0 || h_sampling_factor_m == 0 ||
v_sampling_factor_n == 0 || v_sampling_factor_m == 0) {
ctx->scalability = 0;
*gb = bak;
} else
av_log(s->avctx, AV_LOG_ERROR, "scalability not supported\n");
}
}
if (s->avctx->debug&FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG, "tb %d/%d, tincrbits:%d, qp_prec:%d, ps:%d, %s%s%s%s\n",
s->avctx->framerate.den, s->avctx->framerate.num,
ctx->time_increment_bits,
s->quant_precision,
s->progressive_sequence,
ctx->scalability ? "scalability " :"" , s->quarter_sample ? "qpel " : "",
s->data_partitioning ? "partition " : "", ctx->rvlc ? "rvlc " : ""
);
}
return 0;
}
| 1threat
|
React/RCTBridgeDelegate.h' file not found : <p>I have created a new project called auth using react-native init auth at terminal.When i tried to run the project using react-native run-ios. The build failed and gave a error 'React/RCTBridgeDelegate.h' file not found.</p>
<p>Tried to update the react native version</p>
<p>react-native run-ios at terminal in mac</p>
<p>I expect the build to be successful and see the ios simulator
The actual result which i got is build failed and hence cant see the simulator</p>
| 0debug
|
Android Error [java.lang.NullPointerException: 'void android.support.v7.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference] : <p>I have my main which contain a menu drawer with some fragments. Then a host page before to display the main. I have some errors about that <code>Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference</code></p>
<p>I tried to change it <code>getSupportActionBar().setDisplayHomeAsUpEnabled(true);</code>
but still nothing even with <code>public class MainActivity extends Activity {</code> or <code>public class MainActivity extends AppcompactActivity {</code></p>
<p>There is my main:</p>
<pre><code> package thyroid.com.thyroid;
import thyroid.com.thyroid.adapter.NavDrawerListAdapter;
import thyroid.com.thyroid.model.NavDrawerItem;
import java.util.ArrayList;
import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;
public class MainActivity extends Activity {
private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
private ActionBarDrawerToggle mDrawerToggle;
// nav drawer title
private CharSequence mDrawerTitle;
// used to store app title
private CharSequence mTitle;
// slide menu items
private String[] navMenuTitles;
private TypedArray navMenuIcons;
private ArrayList<NavDrawerItem> navDrawerItems;
private NavDrawerListAdapter adapter;
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
private GoogleApiClient client;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTitle = mDrawerTitle = getTitle();
// load slide menu items
navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
// nav drawer icons from resources
navMenuIcons = getResources()
.obtainTypedArray(R.array.nav_drawer_icons);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
navDrawerItems = new ArrayList<NavDrawerItem>();
// adding nav drawer items to array
// Home
navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
// Find People
navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1)));
// Photos
navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1)));
// Communities, Will add a counter here
navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1), true, "22"));
// Pages
navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
// What's hot, We will add a counter here
navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1), true, "50+"));
// Recycle the typed array
navMenuIcons.recycle();
mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
// setting the nav drawer list adapter
adapter = new NavDrawerListAdapter(getApplicationContext(),
navDrawerItems);
mDrawerList.setAdapter(adapter);
// enabling action bar app icon and behaving it as toggle button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer, //nav menu toggle icon
R.string.app_name, // nav drawer open - description for accessibility
R.string.app_name // nav drawer close - description for accessibility
) {
public void onDrawerClosed(View view) {
getSupportActionBar().setTitle(mTitle);
// calling onPrepareOptionsMenu() to show action bar icons
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
getSupportActionBar().setTitle(mDrawerTitle);
// calling onPrepareOptionsMenu() to hide action bar icons
invalidateOptionsMenu();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
if (savedInstanceState == null) {
// on first time display view for first nav item
displayView(0);
}
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
private ActionBar getSupportActionBar() {
return null;
}
@Override
public void onStart() {
super.onStart();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client.connect();
Action viewAction = Action.newAction(
Action.TYPE_VIEW, // TODO: choose an action type.
"Main Page", // TODO: Define a title for the content shown.
// TODO: If you have web page content that matches this app activity's content,
// make sure this auto-generated web page URL is correct.
// Otherwise, set the URL to null.
Uri.parse("http://host/path"),
// TODO: Make sure this auto-generated app URL is correct.
Uri.parse("android-app://thyroid.com.thyroid/http/host/path")
);
AppIndex.AppIndexApi.start(client, viewAction);
}
@Override
public void onStop() {
super.onStop();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
Action viewAction = Action.newAction(
Action.TYPE_VIEW, // TODO: choose an action type.
"Main Page", // TODO: Define a title for the content shown.
// TODO: If you have web page content that matches this app activity's content,
// make sure this auto-generated web page URL is correct.
// Otherwise, set the URL to null.
Uri.parse("http://host/path"),
// TODO: Make sure this auto-generated app URL is correct.
Uri.parse("android-app://thyroid.com.thyroid/http/host/path")
);
AppIndex.AppIndexApi.end(client, viewAction);
client.disconnect();
}
/**
* Slide menu item click listener
*/
private class SlideMenuClickListener implements
ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// display view for selected nav drawer item
displayView(position);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// toggle nav drawer on selecting action bar app icon/title
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
// Handle action bar actions click
switch (item.getItemId()) {
case R.id.action_settings:
return true;
default:
return super.onOptionsItemSelected(item);
}
}
/* *
* Called when invalidateOptionsMenu() is triggered
*/
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// if nav drawer is opened, hide the action items
boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
menu.findItem(R.id.action_settings).setVisible(!drawerOpen);
return super.onPrepareOptionsMenu(menu);
}
/**
* Diplaying fragment view for selected nav drawer list item
*/
private void displayView(int position) {
// update the main content by replacing fragments
Fragment fragment = null;
switch (position) {
case 0:
fragment = new LoginFragment();
break;
case 1:
fragment = new RegisterFragment();
break;
case 2:
fragment = new LoginFragment();
break;
case 3:
fragment = new LoginFragment();
break;
case 4:
fragment = new LoginFragment();
break;
case 5:
fragment = new LoginFragment();
break;
default:
break;
}
if (fragment != null) {
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.frame_container, fragment).commit();
// update selected item and title, then close the drawer
mDrawerList.setItemChecked(position, true);
mDrawerList.setSelection(position);
setTitle(navMenuTitles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
} else {
// error in creating fragment
Log.e("MainActivity", "Error in creating fragment");
}
}
@Override
public void setTitle(CharSequence title) {
mTitle = title;
getSupportActionBar().setTitle(mTitle);
}
/**
* When using the ActionBarDrawerToggle, you must call it during
* onPostCreate() and onConfigurationChanged()...
*/
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
mDrawerToggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Pass any configuration change to the drawer toggls
mDrawerToggle.onConfigurationChanged(newConfig);
}
}
</code></pre>
<p>Here one of the fragment:</p>
<pre><code> package thyroid.com.thyroid;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.AppCompatButton;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import thyroid.com.thyroid.model.ServerRequest;
import thyroid.com.thyroid.model.ServerResponse;
import thyroid.com.thyroid.model.User;
public class LoginFragment extends Fragment implements View.OnClickListener{
private AppCompatButton btn_login;
private EditText et_email,et_password;
private TextView tv_register,tv_reset_password;
private ProgressBar progress;
private SharedPreferences pref;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_login,container,false);
initViews(view);
return view;
}
private void initViews(View view){
pref = getActivity().getPreferences(0);
btn_login = (AppCompatButton)view.findViewById(R.id.btn_login);
tv_register = (TextView)view.findViewById(R.id.tv_register);
tv_reset_password = (TextView)view.findViewById(R.id.tv_reset_password);
et_email = (EditText)view.findViewById(R.id.et_email);
et_password = (EditText)view.findViewById(R.id.et_password);
progress = (ProgressBar)view.findViewById(R.id.progress);
btn_login.setOnClickListener(this);
tv_register.setOnClickListener(this);
tv_reset_password.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.tv_register:
goToRegister();
break;
case R.id.btn_login:
String email = et_email.getText().toString();
String password = et_password.getText().toString();
if(!email.isEmpty() && !password.isEmpty()) {
progress.setVisibility(View.VISIBLE);
loginProcess(email,password);
} else {
Snackbar.make(getView(), "Fields are empty !", Snackbar.LENGTH_LONG).show();
}
break;
case R.id.tv_reset_password:
goToResetPassword();
break;
}
}
private void loginProcess(String email,String password){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constants.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
RequestInterface requestInterface = retrofit.create(RequestInterface.class);
User user = new User();
user.setEmail(email);
user.setPassword(password);
ServerRequest request = new ServerRequest();
request.setOperation(Constants.LOGIN_OPERATION);
request.setUser(user);
Call<ServerResponse> response = requestInterface.operation(request);
response.enqueue(new Callback<ServerResponse>() {
@Override
public void onResponse(Call<ServerResponse> call, retrofit2.Response<ServerResponse> response) {
ServerResponse resp = response.body();
Snackbar.make(getView(), resp.getMessage(), Snackbar.LENGTH_LONG).show();
if(resp.getResult().equals(Constants.SUCCESS)){
SharedPreferences.Editor editor = pref.edit();
editor.putBoolean(Constants.IS_LOGGED_IN,true);
editor.putString(Constants.EMAIL,resp.getUser().getEmail());
editor.putString(Constants.NAME,resp.getUser().getName());
editor.putString(Constants.UNIQUE_ID,resp.getUser().getUnique_id());
editor.apply();
goToProfile();
}
progress.setVisibility(View.INVISIBLE);
}
@Override
public void onFailure(Call<ServerResponse> call, Throwable t) {
progress.setVisibility(View.INVISIBLE);
Log.d(Constants.TAG,"failed");
Snackbar.make(getView(), t.getLocalizedMessage(), Snackbar.LENGTH_LONG).show();
}
});
}
private void goToResetPassword(){
Fragment reset = new Fragment();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.fragment_frame,reset);
ft.commit();
}
private void goToRegister(){
Fragment register = new RegisterFragment();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.fragment_frame,register);
ft.commit();
}
private void goToProfile(){
Fragment profile = new ProfileFragment();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.fragment_frame,profile);
ft.commit();
}
}
</code></pre>
<p>And now the .class which is the "host page" before the main:</p>
<pre><code>package thyroid.com.thyroid;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import static thyroid.com.thyroid.R.id.button;
public class SplashScreen extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
Button button = (Button) findViewById(R.id.button);
assert button != null;
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(),MainActivity.class);
startActivityForResult(intent,0);
}
});
Thread timerThread = new Thread() {
public void run() {
try {
sleep(6000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
Intent intent = new Intent(SplashScreen.this, MainActivity.class);
startActivity(intent);
}
}
};
timerThread.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
}
</code></pre>
<p>This is my errors:</p>
<pre><code>06-20 11:23:33.603 29939-29939/thyroid.com.thyroid E/AndroidRuntime: FATAL EXCEPTION: main
Process: thyroid.com.thyroid, PID: 29939
java.lang.RuntimeException: Unable to start activity ComponentInfo{thyroid.com.thyroid/thyroid.com.thyroid.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference
at thyroid.com.thyroid.MainActivity.onCreate(MainActivity.java:101)
at android.app.Activity.performCreate(Activity.java:5976)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
</code></pre>
| 0debug
|
Adding data to datable from a dialog box - jsf - primafaces : i'm new to JSF and having this problem of adding data to my datatable from a dialog box. I click on a commandButton "add" , a dialog box should appear and then i should save the data entries , but when i check them i find them empty - (datatble single row selection).
the code :
<p:commandButton process="singleDT" update=":form:add" icon="ui-icon-plus" value="Add" oncomplete="PF('addDialog').show()" />
<p:dataTable id="singleDT" var="o" value="#{UserBean.listE}" selectionMode="single" selection="#{UserBean.selectedEvent}" rowKey="#{o.id_event}">
<p:column headerText="Id">
<h:outputText value="#{o.id_event}" />
</p:column>
<p:column headerText="Event">
<h:outputText value="#{o.event}" />
</p:column>
<p:column headerText="Date">
<h:outputText value="#{o.date_event}" />
</p:column>
</p:dataTable>
the dialog box when the button "add" is clicked :
<p:dialog header="Addevent" widgetVar="addDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false">
<p:outputPanel id="ajouter" style="text-align:center;">
<p:panelGrid columns="2" columnClasses="label,value">
<h:outputText value="Id:" />
<h:inputText value="#{UserBean.selectedEvent.id_event}" />
<h:outputText value="Event" />
<h:inputText value="#{UserBean.selectedEvent.event}" />
<h:outputText value="Date " />
<h:inputText value="#{UserBean.selectedEvent.date_event}" />
</p:panelGrid>
</p:outputPanel>
<p:commandButton action="#{UserBean.Add}" icon="ui-icon-edit" value="Add" />
<p:commandButton process="singleDT" update=":form:add" icon="ui-icon-cancel" value="Cancel" oncomplete="PF('addDialog').hide()" />
</p:dialog>
the UserBean method add() :
public void Add()
{
System.out.println("adding");
event e=new event();
e.setId_event(id_event);
e.setEvent(event);
e.setDate_event(date_event);
serviceevent.add(e);
System.out.println("added to database ");
listE= serviceevent.findAll();
System.out.println("refrech ");
}
the stack error :
juin 29, 2017 8:56:52 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute
AVERTISSEMENT: /test2.xhtml @84,75 value="#{UserBean.selectedEvent.id_event}": Target Unreachable, 'selectedEvent' returned null
javax.el.PropertyNotFoundException: /test2.xhtml @84,75 value="#{UserBean.selectedEvent.id_event}": Target Unreachable, 'selectedEvent' returned null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
at javax.faces.component.UIInput.validate(UIInput.java:960)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at org.primefaces.component.dialog.Dialog.processValidators(Dialog.java:423)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
If any one can help ,or explain what im missing , Thank you!
| 0debug
|
remove html tags from the json response in android : Hi from the below response want to remove <p> <br> unwanted tags and blank spaces and want to bold display heading should be bold
can any one help me
String termsnconditions=listSalesStageOpportunity.get(position).getTermsnconditions();
Resonse :
"<p>Price : Price offered for the above configuration only.<br />\r\nTax : Above mentioned price is inclusive of custom duty, Excise, Freight up to site and GST.<br />\r\n Local levies such as Octroi / Entry tax if any, the same will be at Purchaser’s account.<br />\r\nValidity : This price is valid for a week from the date of the proposal.<br />\r\nPayment : 100% Advance<br />\r\nInstallation : Genworks Specialist / Representative at your site will give Training and Installation without any additional cost.<br />\r\nWarranty : 12 Months from the date of installation or 13 Months from the date of Invoice. Warraty will be provided for hardware items only and consumables items are not a part of warranty.</p>"
String terms=termsnconditions.replaceAll("<p>","");
terms_condition.setText(terms);
| 0debug
|
Delete the last Char of a PHP String : <p>My Problem : i cant delete the last char of a string : </p>
<pre><code> foreach($_POST['checkbox'] as $item)
{
$string .= $item.', ';
}
$markte=rtrim($string ,", ");
</code></pre>
| 0debug
|
How do I check whether a scanned integer is indeed an integer? : <p>I'm pretty new to Java, I program in C# which is very similar, but I have some troubles defending my code in java.</p>
<p>I'd like to defend my code against illegal input such as string,char,special char.</p>
<p>I want every time an input other than int to STAY in the do-while loop(exact place marked with ?????????)</p>
<p>Here is my code, pretty simple, it takes numbers and calculates the minimum number,maximum, avg,sum.
If the number -1 is entered, either the program won't start or the loop would stop and calculation will be printed.</p>
<p>Thanks in advance for your help!</p>
<pre><code>public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
//Variables
int count=0;
int sum=0;
int max=0;
int min=0;
//Initializing minimum value for a reference
System.out.print("Enter a number ");
int number = scan.nextInt();
if(number!=-1){
min=number;
count++;
sum+=number;
}
while(number!=-1){
do {
System.out.print("Enter a number or -1 to stop: ");
number = scan.nextInt();
}while((Integer.toString(number)==null)||???????????? (Check for illegal input));
if(number==-1){
break;
}
else {
sum+=number;
count++;
if(number>max) {
max=number;
}
else if(number<min) {
min=number;
}
}
}
if(count!=0)
{
System.out.println("The Maximum number is: "+max);
System.out.println("The Minimum number is: "+min);
System.out.println("The Sum of all entered numbers is: "+sum);
System.out.println("The Average of all entered numbers is: "+(double)sum/(double)count);
System.out.println("T H E E N D");
}
else {
System.out.println("T H E E N D");
}
scan.close();
}
</code></pre>
<p>}</p>
| 0debug
|
build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
const char *oem_id, const char *oem_table_id)
{
AcpiRsdtDescriptorRev1 *rsdt;
size_t rsdt_len;
int i;
const int table_data_len = (sizeof(uint32_t) * table_offsets->len);
rsdt_len = sizeof(*rsdt) + table_data_len;
rsdt = acpi_data_push(table_data, rsdt_len);
memcpy(rsdt->table_offset_entry, table_offsets->data, table_data_len);
for (i = 0; i < table_offsets->len; ++i) {
bios_linker_loader_add_pointer(linker,
ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
&rsdt->table_offset_entry[i],
sizeof(uint32_t));
}
build_header(linker, table_data,
(void *)rsdt, "RSDT", rsdt_len, 1, oem_id, oem_table_id);
}
| 1threat
|
"This version of C:\TURBOC3\BIN\TCC.EXE is not compatible with the version of Windows you're running. : <p>I have downloaded zip file of Turbo C++ 3.2 for my windows 10 64-bit. I can not run it in cmd because it gives mentioned error. But it perfectly runs in turbo c++. I have set environment variables. what should i do?</p>
| 0debug
|
CPUState *ppc405ep_init (target_phys_addr_t ram_bases[2],
target_phys_addr_t ram_sizes[2],
uint32_t sysclk, qemu_irq **picp,
int do_init)
{
clk_setup_t clk_setup[PPC405EP_CLK_NB], tlb_clk_setup;
qemu_irq dma_irqs[4], gpt_irqs[5], mal_irqs[4];
CPUState *env;
qemu_irq *pic, *irqs;
memset(clk_setup, 0, sizeof(clk_setup));
env = ppc4xx_init("405ep", &clk_setup[PPC405EP_CPU_CLK],
&tlb_clk_setup, sysclk);
clk_setup[PPC405EP_CPU_CLK].cb = tlb_clk_setup.cb;
clk_setup[PPC405EP_CPU_CLK].opaque = tlb_clk_setup.opaque;
ppc4xx_plb_init(env);
ppc4xx_pob_init(env);
ppc4xx_opba_init(0xef600600);
irqs = g_malloc0(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
irqs[PPCUIC_OUTPUT_INT] =
((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
irqs[PPCUIC_OUTPUT_CINT] =
((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];
pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);
*picp = pic;
ppc4xx_sdram_init(env, pic[17], 2, ram_bases, ram_sizes, do_init);
ppc405_ebc_init(env);
dma_irqs[0] = pic[5];
dma_irqs[1] = pic[6];
dma_irqs[2] = pic[7];
dma_irqs[3] = pic[8];
ppc405_dma_init(env, dma_irqs);
ppc405_i2c_init(0xef600500, pic[2]);
ppc405_gpio_init(0xef600700);
if (serial_hds[0] != NULL) {
serial_mm_init(0xef600300, 0, pic[0], PPC_SERIAL_MM_BAUDBASE,
serial_hds[0], 1, 1);
}
if (serial_hds[1] != NULL) {
serial_mm_init(0xef600400, 0, pic[1], PPC_SERIAL_MM_BAUDBASE,
serial_hds[1], 1, 1);
}
ppc405_ocm_init(env);
gpt_irqs[0] = pic[19];
gpt_irqs[1] = pic[20];
gpt_irqs[2] = pic[21];
gpt_irqs[3] = pic[22];
gpt_irqs[4] = pic[23];
ppc4xx_gpt_init(0xef600000, gpt_irqs);
mal_irqs[0] = pic[11];
mal_irqs[1] = pic[12];
mal_irqs[2] = pic[13];
mal_irqs[3] = pic[14];
ppc405_mal_init(env, mal_irqs);
ppc405ep_cpc_init(env, clk_setup, sysclk);
return env;
}
| 1threat
|
How to store the output of a command in a variable at the same time as printing the output? : <p>Say I want to <code>echo</code> something and capture it in a variable, at the same time I see it in my screen.</p>
<pre><code>echo "hello" | tee tmp_file
var=$(< tmp_file)
</code></pre>
<p>So now I could see <code>hello</code> in my terminal as well as saving it into the variable <code>$var</code>.</p>
<p>However, is there any way to do this without having to use a temporary file? <code>tee</code> doesn't seem to be the solution, since it says (from <code>man tee</code>) <em>read from standard input and write to standard output and files</em>, whereas here it is two times standard output.</p>
<p>I am in Bash 4.3, if this matters.</p>
| 0debug
|
static int vnc_update_stats(VncDisplay *vd, struct timeval * tv)
{
int width = pixman_image_get_width(vd->guest.fb);
int height = pixman_image_get_height(vd->guest.fb);
int x, y;
struct timeval res;
int has_dirty = 0;
for (y = 0; y < height; y += VNC_STAT_RECT) {
for (x = 0; x < width; x += VNC_STAT_RECT) {
VncRectStat *rect = vnc_stat_rect(vd, x, y);
rect->updated = false;
}
}
qemu_timersub(tv, &VNC_REFRESH_STATS, &res);
if (timercmp(&vd->guest.last_freq_check, &res, >)) {
return has_dirty;
}
vd->guest.last_freq_check = *tv;
for (y = 0; y < height; y += VNC_STAT_RECT) {
for (x = 0; x < width; x += VNC_STAT_RECT) {
VncRectStat *rect= vnc_stat_rect(vd, x, y);
int count = ARRAY_SIZE(rect->times);
struct timeval min, max;
if (!timerisset(&rect->times[count - 1])) {
continue ;
}
max = rect->times[(rect->idx + count - 1) % count];
qemu_timersub(tv, &max, &res);
if (timercmp(&res, &VNC_REFRESH_LOSSY, >)) {
rect->freq = 0;
has_dirty += vnc_refresh_lossy_rect(vd, x, y);
memset(rect->times, 0, sizeof (rect->times));
continue ;
}
min = rect->times[rect->idx];
max = rect->times[(rect->idx + count - 1) % count];
qemu_timersub(&max, &min, &res);
rect->freq = res.tv_sec + res.tv_usec / 1000000.;
rect->freq /= count;
rect->freq = 1. / rect->freq;
}
}
return has_dirty;
}
| 1threat
|
Should we do nil check for non optional variables : I have a function abc as follows and I should throw an error when the arguments passed are empty of nil,, should I check for nil too? or only empty is enough ?
public func abc(forURL serviceUrl:String,serviceID:String, error:inout Error? )throws ->[AnyHashable : Any]{
guard serviceUrl != nil, !serviceUrl.isEmpty else {
let argError:Error = MapError.emptyArgumentUrl.error()
error = argError
throw argError
}
guard !serviceID.isEmpty else {
let argError:Error = MapError.emptyArgumentServiceId.error()
error = argError
throw argError
}
| 0debug
|
whats does if(variable ) means in c language? : I m currently preparing for gate , I have come across a question
#include<stdio.h>
main()
{
static int var=6;
printf("%d\t",var--);
if(var)
main();
}
output is 6 5 4 3 2 1
i wanna know why it terminated after 1??
| 0debug
|
static void aarch64_numa_cpu(const void *data)
{
char *cli;
QDict *resp;
QList *cpus;
const QObject *e;
cli = make_cli(data, "-smp 2 "
"-numa node,nodeid=0 -numa node,nodeid=1 "
"-numa cpu,node-id=1,thread-id=0 "
"-numa cpu,node-id=0,thread-id=1");
qtest_start(cli);
cpus = get_cpus(&resp);
g_assert(cpus);
while ((e = qlist_pop(cpus))) {
QDict *cpu, *props;
int64_t thread, node;
cpu = qobject_to_qdict(e);
g_assert(qdict_haskey(cpu, "props"));
props = qdict_get_qdict(cpu, "props");
g_assert(qdict_haskey(props, "node-id"));
node = qdict_get_int(props, "node-id");
g_assert(qdict_haskey(props, "thread-id"));
thread = qdict_get_int(props, "thread-id");
if (thread == 0) {
g_assert_cmpint(node, ==, 1);
} else if (thread == 1) {
g_assert_cmpint(node, ==, 0);
} else {
g_assert(false);
}
}
QDECREF(resp);
qtest_end();
g_free(cli);
}
| 1threat
|
How to share extensions and settings with VS Code stable and insider build? : <p>I have installed both the versions of VS Code stable and insiders build on my machine.</p>
<p>But the problem is that insiders are not showing all the settings and extensions I am using in the stable version.</p>
<p>So, how to share all the stuff with the insiders build.</p>
| 0debug
|
what's wrong in SELECT STATEMENT? : im using this code to get the last number in a fields where date of fields is today date:
cn.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Application.StartupPath & "\bysys.mdb")
rs.Open("Select max(snum) From tblbill where idate = #" & Format(Today.Date, "dd/MM/yyyy") & "# ", cn, 1, 2)
If IsDBNull(Rs.Fields(0).Value) Then
TextBox6.Text = 1
Else
TextBox6.Text = Rs.Fields(0).Value + 1
End If
sometimes it works correctly
but sometimes, always return 1..
please help!
| 0debug
|
ElidedSemicolonAndRightBrace expected : <p>I have the following code ("codes" is an array variable):</p>
<pre><code>Arrays.asList(codes)
.stream()
.filter(code -> code.hasCountries())
.sorted()
.toArray()
);
</code></pre>
<p>The compiler gives me the following error:</p>
<blockquote>
<p>Syntax error on token ")", ElidedSemicolonAndRightBrace expected</p>
</blockquote>
<p>What's wrong here?</p>
| 0debug
|
Any idea how I could structure my project? : <p>I've been teaching python courses for a while and I've started doing my own project to practice with the knowledge I learned. The problem is when it comes to structuring that I'm a little lost since I've always programmed on the web.</p>
<p>My project is about a virtual assistant, the one who listens and from that command makes an action.</p>
<p>I have it structured in this way:</p>
<pre><code>main.py
vs
• mediator.py
• commands.py
• skills.py
</code></pre>
<p>in skills.py I have connections like listening, speaking, etc.</p>
<p>in commands.py a dictionary, where the value is the command and the key the function that you have to execute, making use of the skills.</p>
<p>in the mediator.py, I'm calling commands functions.</p>
<p>in the main.py I call the mediator.</p>
<p>I'm not using an object because I do not know in what way I can implement the. Any idea or opinion is good, thank you.</p>
| 0debug
|
When I should use render: h => h(App)? : <p>By the <a href="https://vuejs.org/v2/guide/render-function.html" rel="noreferrer">docs</a> I do not fully understand when I should use <code>render: h => h(App)</code> function.</p>
<p>For example I have very simple Vue app:</p>
<pre><code>import Vue from 'vue'
import App from './App.vue'
new Vue({
el: '#app',
components: { App }
})
</code></pre>
<p>What is the case when I need add to code: <code>render: h => h(App)</code>?</p>
| 0debug
|
Load data from the database to mat-table when click Next page : <p>I am using angular 7 with spring boot, and i am use mat-table, i don't want load for example all the data from database in one load, i want to load data just when click on next page in mat-table.
and This image for my mat-table.</p>
<p><a href="https://i.stack.imgur.com/OSKLW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OSKLW.png" alt="mat-table image"></a></p>
<p>how i can do that in angular 7 and spring boot together, if anybody have solution please give me it, thanks.</p>
| 0debug
|
static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end,
const char *in, int x1, int y1, int x2, int y2)
{
char c, *param, buffer[128], tmp[128];
int len, tag_close, sptr = 1, line_start = 1, an = 0, end = 0;
SrtStack stack[16];
stack[0].tag[0] = 0;
strcpy(stack[0].param[PARAM_SIZE], "{\\fs}");
strcpy(stack[0].param[PARAM_COLOR], "{\\c}");
strcpy(stack[0].param[PARAM_FACE], "{\\fn}");
if (x1 >= 0 && y1 >= 0) {
if (x2 >= 0 && y2 >= 0 && (x2 != x1 || y2 != y1))
out += snprintf(out, out_end-out,
"{\\an1}{\\move(%d,%d,%d,%d)}", x1, y1, x2, y2);
else
out += snprintf(out, out_end-out, "{\\an1}{\\pos(%d,%d)}", x1, y1);
}
for (; out < out_end && !end && *in; in++) {
switch (*in) {
case '\r':
break;
case '\n':
if (line_start) {
end = 1;
break;
}
while (out[-1] == ' ')
out--;
out += snprintf(out, out_end-out, "\\N");
line_start = 1;
break;
case ' ':
if (!line_start)
*out++ = *in;
break;
case '{':
an += sscanf(in, "{\\an%*1u}%c", &c) == 1;
if ((an != 1 && sscanf(in, "{\\%*[^}]}%n%c", &len, &c) > 0) ||
sscanf(in, "{%*1[CcFfoPSsYy]:%*[^}]}%n%c", &len, &c) > 0) {
in += len - 1;
} else
*out++ = *in;
break;
case '<':
tag_close = in[1] == '/';
if (sscanf(in+tag_close+1, "%127[^>]>%n%c", buffer, &len,&c) >= 2) {
if ((param = strchr(buffer, ' ')))
*param++ = 0;
if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
( tag_close && sptr > 0 && !strcmp(stack[sptr-1].tag, buffer))) {
int i, j, unknown = 0;
in += len + tag_close;
if (!tag_close)
memset(stack+sptr, 0, sizeof(*stack));
if (!strcmp(buffer, "font")) {
if (tag_close) {
for (i=PARAM_NUMBER-1; i>=0; i--)
if (stack[sptr-1].param[i][0])
for (j=sptr-2; j>=0; j--)
if (stack[j].param[i][0]) {
out += snprintf(out, out_end-out,
"%s", stack[j].param[i]);
break;
}
} else {
while (param) {
if (!strncmp(param, "size=", 5)) {
unsigned font_size;
param += 5 + (param[5] == '"');
if (sscanf(param, "%u", &font_size) == 1) {
snprintf(stack[sptr].param[PARAM_SIZE],
sizeof(stack[0].param[PARAM_SIZE]),
"{\\fs%u}", font_size);
}
} else if (!strncmp(param, "color=", 6)) {
param += 6 + (param[6] == '"');
snprintf(stack[sptr].param[PARAM_COLOR],
sizeof(stack[0].param[PARAM_COLOR]),
"{\\c&H%X&}",
html_color_parse(avctx, param));
} else if (!strncmp(param, "face=", 5)) {
param += 5 + (param[5] == '"');
len = strcspn(param,
param[-1] == '"' ? "\"" :" ");
av_strlcpy(tmp, param,
FFMIN(sizeof(tmp), len+1));
param += len;
snprintf(stack[sptr].param[PARAM_FACE],
sizeof(stack[0].param[PARAM_FACE]),
"{\\fn%s}", tmp);
}
if ((param = strchr(param, ' ')))
param++;
}
for (i=0; i<PARAM_NUMBER; i++)
if (stack[sptr].param[i][0])
out += snprintf(out, out_end-out,
"%s", stack[sptr].param[i]);
}
} else if (!buffer[1] && strspn(buffer, "bisu") == 1) {
out += snprintf(out, out_end-out,
"{\\%c%d}", buffer[0], !tag_close);
} else {
unknown = 1;
snprintf(tmp, sizeof(tmp), "</%s>", buffer);
}
if (tag_close) {
sptr--;
} else if (unknown && !strstr(in, tmp)) {
in -= len + tag_close;
*out++ = *in;
} else
av_strlcpy(stack[sptr++].tag, buffer,
sizeof(stack[0].tag));
break;
}
}
default:
*out++ = *in;
break;
}
if (*in != ' ' && *in != '\r' && *in != '\n')
line_start = 0;
}
out = FFMIN(out, out_end-3);
while (!strncmp(out-2, "\\N", 2))
out -= 2;
while (out[-1] == ' ')
out--;
out += snprintf(out, out_end-out, "\r\n");
return in;
}
| 1threat
|
multiple condition in ternary operator in jsx : <pre><code><div style={{'backgroundColor': status === 'approved' ? 'blue' : 'black'}}>
</div>
</code></pre>
<p>black is the default color but what if I want to add the 3rd condition? </p>
<p>status can be 'approved', 'rejected', 'pending' or more.</p>
| 0debug
|
Rstudio and Google Drive Syncing Problems: "The process cannot access the file because it is being used by another process" : <p>So I'm using RStudio and storing my files on Google Drive (the version with folders on your system, acting like Dropbox). I'm using it because it provides a lot more space for free than Dropbox, and I need that space for the projects I'm working on.</p>
<p>When I attempt to write any document at all -- an R script, an RMarkdown file, etc... -- I get the error mentioned in the title. This doesn't happen using Dropbox. I have found answers for this question for Dropbox, but the solution (tell Dropbox not to sync the Rproj file) doesn't seem applicable to Google Drive (if it is, please correct me). </p>
<p>Currently, I'm pausing Google Drive, which is fine, but I often forget to resume it and that causes headaches.</p>
<p>Thanks for your help!</p>
| 0debug
|
Check if a row in one data frame exist in another data frame : <p>I have a data frame A like this:</p>
<p><a href="https://i.stack.imgur.com/uu12A.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uu12A.png" alt="enter image description here"></a></p>
<p>And another data frame B which looks like this:</p>
<p><a href="https://i.stack.imgur.com/DI78z.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DI78z.png" alt="enter image description here"></a></p>
<p>I want to add a column 'Exist' to data frame A so that if User and Movie both exist in data frame B then 'Exist' is True, otherwise it is False.
So A should become like this:
<a href="https://i.stack.imgur.com/sPxfb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sPxfb.png" alt="enter image description here"></a></p>
| 0debug
|
Which is better Theano? : **I want to install Theano on my windows 8.1 x64 machine. I already have anaconda (latest 64 bit) with python 2.7.x version.**
**I have two options of installing:**
# Option 1 : from pip
pip install Theano
**And**
# Option 2 : Bleeding edge from git
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
**Can someone let me know the major differences between two and which one is suggested to install?**
| 0debug
|
golang if initialization statement scoped to inner if block. Why? : <p>I've found a bug in my code</p>
<pre><code>func receive() (err error) {
if v, err := produce(); err == nil {
fmt.Println("value: ", v)
}
return
}
</code></pre>
<p>Error is never returning from this function, but I was absolutely sure it should.</p>
<p>After some testing I understood that <code>err</code> is redeclared in the if statement. More than that - all variables are always redeclared in short variable assignment inside <code>if</code> statement, despite they were declared before.</p>
<p>This is working code</p>
<pre><code>func receive() (err error) {
v, err := produce()
if err == nil {
fmt.Println("value: ", v)
}
return
}
</code></pre>
<p>Here is an example: <a href="https://play.golang.org/p/1AWBsPbLiI1" rel="nofollow noreferrer">https://play.golang.org/p/1AWBsPbLiI1</a></p>
<p>Seems like if statement </p>
<pre><code>//some code
if <init_statement>; <expression> {}
//more code
</code></pre>
<p>is equivalent to </p>
<pre><code>//some code
{
<init_statement>
if expression {}
}
//more code
</code></pre>
<p>So, my questions:</p>
<p>1) why existing variables are not used</p>
<p>2) why such scoping is not mentioned in documentation/language spec</p>
<p>3) why compiler doesn't say that no one returns a value</p>
| 0debug
|
def check_none(test_tup):
res = any(map(lambda ele: ele is None, test_tup))
return (res)
| 0debug
|
Background Fetch at Specific Time : <p>I am looking for solution to get data in background mode even app is terminated.
There are lots of tutorials and answers available for this questions, but my questions is different than other. I haven't find any proper solution on stackoverflow, so posted this question.</p>
<p>I have scenario which I can explain. I'm using realm database which store event date, name, time, address etc. Now the thing is that, I want to write a code which are execute in background, In this code I want to get all event data and compare their date with today's date. And based on days remaining between these days fire local notification to remind user about how many days are remaining for specific event.</p>
<blockquote>
<p>I want to call this background fetch method exactly 8 AM in local time everyday. </p>
</blockquote>
<p>I haven't write any code due to confused with Background fetch and implementation. Can anyone know how to implement this ?</p>
<p>Help will be appreciated.</p>
| 0debug
|
Undefined Reference to deck::array1 in c++ : <p>I have header file in which I have static function which are public and i have a private static array. In my c++ file file i am calling my array from one of this static function and getting error "UNDEFINED REFERENCE TO abc::ARRAY". why I am getting this error?
When I remove static from array and function it works properly. But I need to make them static to use in another c++ file</p>
<p><a href="https://i.stack.imgur.com/I3TqO.jpg" rel="nofollow noreferrer">See my code for reference</a></p>
| 0debug
|
e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
{
E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque;
struct e1000_rx_desc desc;
dma_addr_t base;
unsigned int n, rdt;
uint32_t rdh_start;
uint16_t vlan_special = 0;
uint8_t vlan_status = 0, vlan_offset = 0;
uint8_t min_buf[MIN_BUF_SIZE];
size_t desc_offset;
size_t desc_size;
size_t total_size;
if (!(s->mac_reg[RCTL] & E1000_RCTL_EN))
return -1;
if (size < sizeof(min_buf)) {
memcpy(min_buf, buf, size);
memset(&min_buf[size], 0, sizeof(min_buf) - size);
buf = min_buf;
size = sizeof(min_buf);
}
if (!receive_filter(s, buf, size))
return size;
if (vlan_enabled(s) && is_vlan_packet(s, buf)) {
vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(buf + 14)));
memmove((uint8_t *)buf + 4, buf, 12);
vlan_status = E1000_RXD_STAT_VP;
vlan_offset = 4;
size -= 4;
}
rdh_start = s->mac_reg[RDH];
desc_offset = 0;
total_size = size + fcs_len(s);
if (!e1000_has_rxbufs(s, total_size)) {
set_ics(s, 0, E1000_ICS_RXO);
return -1;
}
do {
desc_size = total_size - desc_offset;
if (desc_size > s->rxbuf_size) {
desc_size = s->rxbuf_size;
}
base = rx_desc_base(s) + sizeof(desc) * s->mac_reg[RDH];
pci_dma_read(&s->dev, base, &desc, sizeof(desc));
desc.special = vlan_special;
desc.status |= (vlan_status | E1000_RXD_STAT_DD);
if (desc.buffer_addr) {
if (desc_offset < size) {
size_t copy_size = size - desc_offset;
if (copy_size > s->rxbuf_size) {
copy_size = s->rxbuf_size;
}
pci_dma_write(&s->dev, le64_to_cpu(desc.buffer_addr),
buf + desc_offset + vlan_offset, copy_size);
}
desc_offset += desc_size;
desc.length = cpu_to_le16(desc_size);
if (desc_offset >= total_size) {
desc.status |= E1000_RXD_STAT_EOP | E1000_RXD_STAT_IXSM;
} else {
desc.status &= ~E1000_RXD_STAT_EOP;
}
} else {
DBGOUT(RX, "Null RX descriptor!!\n");
}
pci_dma_write(&s->dev, base, &desc, sizeof(desc));
if (++s->mac_reg[RDH] * sizeof(desc) >= s->mac_reg[RDLEN])
s->mac_reg[RDH] = 0;
s->check_rxov = 1;
if (s->mac_reg[RDH] == rdh_start) {
DBGOUT(RXERR, "RDH wraparound @%x, RDT %x, RDLEN %x\n",
rdh_start, s->mac_reg[RDT], s->mac_reg[RDLEN]);
set_ics(s, 0, E1000_ICS_RXO);
return -1;
}
} while (desc_offset < total_size);
s->mac_reg[GPRC]++;
s->mac_reg[TPR]++;
n = s->mac_reg[TORL] + size + 4;
if (n < s->mac_reg[TORL])
s->mac_reg[TORH]++;
s->mac_reg[TORL] = n;
n = E1000_ICS_RXT0;
if ((rdt = s->mac_reg[RDT]) < s->mac_reg[RDH])
rdt += s->mac_reg[RDLEN] / sizeof(desc);
if (((rdt - s->mac_reg[RDH]) * sizeof(desc)) <= s->mac_reg[RDLEN] >>
s->rxbuf_min_shift)
n |= E1000_ICS_RXDMT0;
set_ics(s, 0, n);
return size;
}
| 1threat
|
int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
const void *pp, unsigned pp_size,
const void *qm, unsigned qm_size,
int (*commit_bs_si)(AVCodecContext *,
DECODER_BUFFER_DESC *bs,
DECODER_BUFFER_DESC *slice))
{
AVDXVAContext *ctx = avctx->hwaccel_context;
unsigned buffer_count = 0;
#if CONFIG_D3D11VA
D3D11_VIDEO_DECODER_BUFFER_DESC buffer11[4];
#endif
#if CONFIG_DXVA2
DXVA2_DecodeBufferDesc buffer2[4];
#endif
DECODER_BUFFER_DESC *buffer,*buffer_slice;
int result, runs = 0;
HRESULT hr;
unsigned type;
do {
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, INFINITE, FALSE);
hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder,
ff_dxva2_get_surface(frame),
0, NULL);
}
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
hr = IDirectXVideoDecoder_BeginFrame(DXVA2_CONTEXT(ctx)->decoder,
ff_dxva2_get_surface(frame),
NULL);
#endif
if (hr == E_PENDING)
av_usleep(2000);
} while (hr == E_PENDING && ++runs < 50);
if (FAILED(hr)) {
av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%lx\n", hr);
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
#endif
return -1;
}
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
buffer = &buffer11[buffer_count];
type = D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS;
}
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
buffer = &buffer2[buffer_count];
type = DXVA2_PictureParametersBufferType;
}
#endif
result = ff_dxva2_commit_buffer(avctx, ctx, buffer,
type,
pp, pp_size, 0);
if (result) {
av_log(avctx, AV_LOG_ERROR,
"Failed to add picture parameter buffer\n");
goto end;
}
buffer_count++;
if (qm_size > 0) {
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
buffer = &buffer11[buffer_count];
type = D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX;
}
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
buffer = &buffer2[buffer_count];
type = DXVA2_InverseQuantizationMatrixBufferType;
}
#endif
result = ff_dxva2_commit_buffer(avctx, ctx, buffer,
type,
qm, qm_size, 0);
if (result) {
av_log(avctx, AV_LOG_ERROR,
"Failed to add inverse quantization matrix buffer\n");
goto end;
}
buffer_count++;
}
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
buffer = &buffer11[buffer_count + 0];
buffer_slice = &buffer11[buffer_count + 1];
}
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
buffer = &buffer2[buffer_count + 0];
buffer_slice = &buffer2[buffer_count + 1];
}
#endif
result = commit_bs_si(avctx,
buffer,
buffer_slice);
if (result) {
av_log(avctx, AV_LOG_ERROR,
"Failed to add bitstream or slice control buffer\n");
goto end;
}
buffer_count += 2;
assert(buffer_count == 1 + (qm_size > 0) + 2);
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
hr = ID3D11VideoContext_SubmitDecoderBuffers(D3D11VA_CONTEXT(ctx)->video_context,
D3D11VA_CONTEXT(ctx)->decoder,
buffer_count, buffer11);
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
DXVA2_DecodeExecuteParams exec = {
.NumCompBuffers = buffer_count,
.pCompressedBuffers = buffer2,
.pExtensionData = NULL,
};
hr = IDirectXVideoDecoder_Execute(DXVA2_CONTEXT(ctx)->decoder, &exec);
}
#endif
if (FAILED(hr)) {
av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%lx\n", hr);
result = -1;
}
end:
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
hr = ID3D11VideoContext_DecoderEndFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder);
if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
}
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
hr = IDirectXVideoDecoder_EndFrame(DXVA2_CONTEXT(ctx)->decoder, NULL);
#endif
if (FAILED(hr)) {
av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%lx\n", hr);
result = -1;
}
return result;
}
| 1threat
|
static target_long monitor_get_tbu (const struct MonitorDef *md, int val)
{
CPUState *env = mon_get_cpu();
if (!env)
return 0;
return cpu_ppc_load_tbu(env);
}
| 1threat
|
Very strange error : class SignUp: UIViewController {
@IBOutlet weak var buttonNameTxt: UITextField! @IBOutlet weak var buttonEmailTxt: UITextField! @IBOutlet weak var buttonPwdTxt: UITextField!
override func viewDidLoad() { super.viewDidLoad()
}
@IBAction func buttonSignIn(_ sender: UIButton){
let usermainname:NSString = buttonNameTxt.text! as NSString let username:NSString = buttonEmailTxt.text! as NSString let password:NSString = buttonPwdTxt.text! as NSString
let myURL = NSURL(string: "https:\mev.com/api/login")
let request = NSMutableURLRequest(url: myURL as! URL) request.httpMethod = "Post"
let postString = "name = (usermainname) email = (username) &passwod = (password) " request.httpBody = postString.data(using: String.Encoding.utf8)
let task = URLSession.shared.dataTask(with: request as URLRequest) { data , response , error in
do {
let err: NSError? let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
print(json as Any)
if let parseJSON = json { let resultValue = parseJSON["status"] as? String print ("result:(resultValue)")
var isUserRegister:Bool = false if resultValue == "success" {isUserRegister = true}
var messageToDisplay:String = parseJSON["massage"] as! String if isUserRegister {
messageToDisplay = parseJSON["massage"] as! String
}
}
} catch {
print("error") }
This is error
2016-11-16 12:37:16.328505 MevicsPromo[12011:692688] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/HardBuf/Library/Developer/CoreSimulator/Devices/E3B4C6A4-A49D-4363-89D5-31931EA513A8/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles 2016-11-16 12:37:16.328782 MevicsPromo[12011:692688] [MC] Reading from private effective user settings. 2016-11-16 12:37:18.276331 MevicsPromo[12011:692798] 0x60000014e4f0 Copy matching assets reply: XPC_TYPE_DICTIONARY { count = 1, transaction: 0, voucher = 0x0, contents = "Result" => : 29 } 2016-11-16 12:37:18.277030 MevicsPromo[12011:692798] 0x608000357b80 Daemon configuration query reply: XPC_TYPE_DICTIONARY { count = 2, transaction: 0, voucher = 0x0, contents = "Dictionary" => { count = 1, transaction: 0, voucher = 0x0, contents = "ServerURL" => { count = 3, transaction: 0, voucher = 0x0, contents = "com.apple.CFURL.magic" => C3853DCC-9776-4114-B6C1-FD9F51944A6D "com.apple.CFURL.string" => { length = 30, contents = "https:\mesu.apple.com/assets/" } "com.apple.CFURL.base" => : null-object } } "Result" => : 0 } 2016-11-16 12:37:18.277318 MevicsPromo[12011:692798] http:\ru.stackoverflow.com/editing-help[MobileAssetError:29] Unable to copy asset information from https:\mesu.apple.com/assets/ for asset type com.apple.MobileAsset.TextInput.SpellChecker
| 0debug
|
JavaScript Regex that matches words starting with a dot, that do not end with a (. : <p>I am trying to write a regex that matches JavaScript properties only, for a highlight plugin.</p>
<ol>
<li>It should start with a dot but not include it </li>
<li>It should match any word that contains: [_$A-z]</li>
<li>The word cannot end with (</li>
</ol>
<p>so from:</p>
<pre><code>element.classList.add(animationClass);
</code></pre>
<p>it matches only</p>
<pre><code>classList
</code></pre>
<p>and from:</p>
<pre><code>element.classList.anotherProperty = '';
</code></pre>
<p>it matches</p>
<pre><code>classList and anotherProperty
</code></pre>
| 0debug
|
C# CS0136/CS0165 Errors Text-Based RPG : <p>I'm currently making a test text-based RPG, I'm currently on the currency system and I am receiving an error. I'm not sure why.</p>
<pre><code>for (int gold; gold <= 10; gold++){
if (gold == 10) {
break;
Console.WriteLine("You now have " + gold + " Gold Pieces"); }
}
</code></pre>
<p>I'm not the most experienced coder ever, I'm still really new to C# so if you have anything that may help me get through this or even a better way to give the currency to the player, it would be appreciated.</p>
<p>Thank you.</p>
| 0debug
|
static void ffserver_apply_stream_config(AVCodecContext *enc, const AVDictionary *conf, AVDictionary **opts)
{
AVDictionaryEntry *e;
if ((e = av_dict_get(conf, "VideoBitRateRangeMin", NULL, 0)))
ffserver_set_int_param(&enc->rc_min_rate, e->value, 1000, INT_MIN,
INT_MAX, NULL, 0, NULL);
if ((e = av_dict_get(conf, "VideoBitRateRangeMax", NULL, 0)))
ffserver_set_int_param(&enc->rc_max_rate, e->value, 1000, INT_MIN,
INT_MAX, NULL, 0, NULL);
if ((e = av_dict_get(conf, "Debug", NULL, 0)))
ffserver_set_int_param(&enc->debug, e->value, 0, INT_MIN, INT_MAX,
NULL, 0, NULL);
if ((e = av_dict_get(conf, "Strict", NULL, 0)))
ffserver_set_int_param(&enc->strict_std_compliance, e->value, 0,
INT_MIN, INT_MAX, NULL, 0, NULL);
if ((e = av_dict_get(conf, "VideoBufferSize", NULL, 0)))
ffserver_set_int_param(&enc->rc_buffer_size, e->value, 8*1024,
INT_MIN, INT_MAX, NULL, 0, NULL);
if ((e = av_dict_get(conf, "VideoBitRateTolerance", NULL, 0)))
ffserver_set_int_param(&enc->bit_rate_tolerance, e->value, 1000,
INT_MIN, INT_MAX, NULL, 0, NULL);
if ((e = av_dict_get(conf, "VideoBitRate", NULL, 0)))
ffserver_set_int_param(&enc->bit_rate, e->value, 1000, INT_MIN,
INT_MAX, NULL, 0, NULL);
if ((e = av_dict_get(conf, "VideoSizeWidth", NULL, 0)))
ffserver_set_int_param(&enc->width, e->value, 0, INT_MIN, INT_MAX,
NULL, 0, NULL);
if ((e = av_dict_get(conf, "VideoSizeHeight", NULL, 0)))
ffserver_set_int_param(&enc->height, e->value, 0, INT_MIN, INT_MAX,
NULL, 0, NULL);
if ((e = av_dict_get(conf, "PixelFormat", NULL, 0))) {
int val;
ffserver_set_int_param(&val, e->value, 0, INT_MIN, INT_MAX, NULL, 0,
NULL);
enc->pix_fmt = val;
}
if ((e = av_dict_get(conf, "VideoGopSize", NULL, 0)))
ffserver_set_int_param(&enc->gop_size, e->value, 0, INT_MIN, INT_MAX,
NULL, 0, NULL);
if ((e = av_dict_get(conf, "VideoFrameRateNum", NULL, 0)))
ffserver_set_int_param(&enc->time_base.num, e->value, 0, INT_MIN,
INT_MAX, NULL, 0, NULL);
if ((e = av_dict_get(conf, "VideoFrameRateDen", NULL, 0)))
ffserver_set_int_param(&enc->time_base.den, e->value, 0, INT_MIN,
INT_MAX, NULL, 0, NULL);
if ((e = av_dict_get(conf, "VideoQDiff", NULL, 0)))
ffserver_set_int_param(&enc->max_qdiff, e->value, 0, INT_MIN, INT_MAX,
NULL, 0, NULL);
if ((e = av_dict_get(conf, "VideoQMax", NULL, 0)))
ffserver_set_int_param(&enc->qmax, e->value, 0, INT_MIN, INT_MAX, NULL,
0, NULL);
if ((e = av_dict_get(conf, "VideoQMin", NULL, 0)))
ffserver_set_int_param(&enc->qmin, e->value, 0, INT_MIN, INT_MAX, NULL,
0, NULL);
if ((e = av_dict_get(conf, "LumiMask", NULL, 0)))
ffserver_set_float_param(&enc->lumi_masking, e->value, 0, -FLT_MAX,
FLT_MAX, NULL, 0, NULL);
if ((e = av_dict_get(conf, "DarkMask", NULL, 0)))
ffserver_set_float_param(&enc->dark_masking, e->value, 0, -FLT_MAX,
FLT_MAX, NULL, 0, NULL);
if (av_dict_get(conf, "BitExact", NULL, 0))
enc->flags |= CODEC_FLAG_BITEXACT;
if (av_dict_get(conf, "DctFastint", NULL, 0))
enc->dct_algo = FF_DCT_FASTINT;
if (av_dict_get(conf, "IdctSimple", NULL, 0))
enc->idct_algo = FF_IDCT_SIMPLE;
if (av_dict_get(conf, "VideoHighQuality", NULL, 0))
enc->mb_decision = FF_MB_DECISION_BITS;
if ((e = av_dict_get(conf, "VideoTag", NULL, 0)))
enc->codec_tag = MKTAG(e->value[0], e->value[1], e->value[2], e->value[3]);
if (av_dict_get(conf, "Qscale", NULL, 0)) {
enc->flags |= CODEC_FLAG_QSCALE;
ffserver_set_int_param(&enc->global_quality, e->value, FF_QP2LAMBDA,
INT_MIN, INT_MAX, NULL, 0, NULL);
}
if (av_dict_get(conf, "Video4MotionVector", NULL, 0)) {
enc->mb_decision = FF_MB_DECISION_BITS;
enc->flags |= CODEC_FLAG_4MV;
}
if ((e = av_dict_get(conf, "AudioChannels", NULL, 0)))
ffserver_set_int_param(&enc->channels, e->value, 0, INT_MIN, INT_MAX,
NULL, 0, NULL);
if ((e = av_dict_get(conf, "AudioSampleRate", NULL, 0)))
ffserver_set_int_param(&enc->sample_rate, e->value, 0, INT_MIN,
INT_MAX, NULL, 0, NULL);
if ((e = av_dict_get(conf, "AudioBitRate", NULL, 0)))
ffserver_set_int_param(&enc->bit_rate, e->value, 0, INT_MIN, INT_MAX,
NULL, 0, NULL);
av_opt_set_dict2(enc->priv_data, opts, AV_OPT_SEARCH_CHILDREN);
av_opt_set_dict2(enc, opts, AV_OPT_SEARCH_CHILDREN);
if (av_dict_count(*opts))
av_log(NULL, AV_LOG_ERROR, "Something went wrong, %d options not set!!!\n", av_dict_count(*opts));
}
| 1threat
|
static inline void RENAME(yuv2yuvX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, long dstW, long chrDstW)
{
#ifdef HAVE_MMX
if (c->flags & SWS_ACCURATE_RND){
if (uDest){
YSCALEYUV2YV12X_ACCURATE( 0, CHR_MMX_FILTER_OFFSET, uDest, chrDstW)
YSCALEYUV2YV12X_ACCURATE(4096, CHR_MMX_FILTER_OFFSET, vDest, chrDstW)
}
YSCALEYUV2YV12X_ACCURATE(0, LUM_MMX_FILTER_OFFSET, dest, dstW)
}else{
if (uDest){
YSCALEYUV2YV12X( 0, CHR_MMX_FILTER_OFFSET, uDest, chrDstW)
YSCALEYUV2YV12X(4096, CHR_MMX_FILTER_OFFSET, vDest, chrDstW)
}
YSCALEYUV2YV12X(0, LUM_MMX_FILTER_OFFSET, dest, dstW)
}
#else
#ifdef HAVE_ALTIVEC
yuv2yuvX_altivec_real(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, vDest, dstW, chrDstW);
#else
yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, vDest, dstW, chrDstW);
#endif
#endif
}
| 1threat
|
MacOS Catalina UDID Copy for iPhone : <p>How to copy UDID of the iPhone?</p>
<p><a href="https://i.stack.imgur.com/w8ZvE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/w8ZvE.png" alt="enter image description here"></a></p>
<p>I want to register my iPhone as a tester within the Apple store account.
So followed the steps as per the above image.</p>
<p>But there is no way exist to copy the UDID and direct copy option, I can able to get only half UDID.
Please check below image:</p>
<p><a href="https://i.stack.imgur.com/r6nhX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/r6nhX.png" alt="enter image description here"></a></p>
<p>How to get full UDID copy in text form? So I can paste at the Apple store account.</p>
| 0debug
|
Allign Main Slider image to center : I work on small project , and have one little problem that dont know how to resolve myself. I have Image Gallery with many images but want active image, to be showed into center , without change resolution or image width/height ratio. Link from issue [here][1]. Login is user / password . i tryed to manipulate with this CSS:
.img {
margin-left: 200px;
}
but seems to ruin bottom slider. What to do to set main image on center without change image ratio? See image also, where is marked what i want to do.
[![enter image description here][2]][2]
[1]: https://echographie-sans-frontieres.com/staging/gallery-item/gallery/
[2]: https://i.stack.imgur.com/bu0D1.jpg
| 0debug
|
Why am i getting the wrong output? (Python random number generator calculator) : <p>This program is suppose to generate two random numbers and have the user input the result. If the user input is correct, then the program will print 'You are correct!' If wrong, the program will print 'You are wrong!' However, when the user's answer is correct, the program still outputs "You are wrong!' Not sure why</p>
<pre><code> import random
first = random.randint(0,9)
second = random.randint(0,9)
result = first + second
answer = input(str(first) + ' + ' + str(second) + ': ')
if result == answer:
print('You are correct!')
else:
print('Sorry you are wrong!')
</code></pre>
| 0debug
|
static inline void downmix_3f_1r_to_dolby(float *samples)
{
int i;
for (i = 0; i < 256; i++) {
samples[i] += (samples[i + 256] - samples[i + 768]);
samples[i + 256] += (samples[i + 512] + samples[i + 768]);
samples[i + 512] = samples[i + 768] = 0;
}
}
| 1threat
|
static void kqemu_record_pc(unsigned long pc)
{
unsigned long h;
PCRecord **pr, *r;
h = pc / PC_REC_SIZE;
h = h ^ (h >> PC_REC_HASH_BITS);
h &= (PC_REC_HASH_SIZE - 1);
pr = &pc_rec_hash[h];
for(;;) {
r = *pr;
if (r == NULL)
break;
if (r->pc == pc) {
r->count++;
return;
}
pr = &r->next;
}
r = malloc(sizeof(PCRecord));
r->count = 1;
r->pc = pc;
r->next = NULL;
*pr = r;
nb_pc_records++;
}
| 1threat
|
Using Jackson to map object from specific node in JSON tree : <p>Is it possible to have Jackson's <code>ObjectMapper</code> unmarshall only from a specific node (and 'down') in a JSON tree?</p>
<p>The use case is an extensible document format. I want to walk the tree, and then publish the current path to an extensible set of plugins, to see if the user is using and plugins that know what to do with that part of the document.</p>
<p>I'd like for plugin authors to not have to deal with the low-level details of <code>JsonNode</code> or the streaming API; instead, just be passed some context and a specific <code>JsonNode</code>, and then be able to use the lovely and convenient <code>ObjectMapper</code> to unmarshall an instance of their class, considering the node passed as the root of the tree.</p>
| 0debug
|
static void trigger_page_fault(CPUS390XState *env, target_ulong vaddr,
uint32_t type, uint64_t asc, int rw)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
int ilen = ILEN_LATER;
int bits = trans_bits(env, asc);
if (rw == 2) {
ilen = 2;
}
DPRINTF("%s: vaddr=%016" PRIx64 " bits=%d\n", __func__, vaddr, bits);
stq_phys(cs->as,
env->psa + offsetof(LowCore, trans_exc_code), vaddr | bits);
trigger_pgm_exception(env, type, ilen);
}
| 1threat
|
Missing template arguments before 's' C++ : <p>Well I am doing an assignment but not sure what my problem is </p>
<p>this is my assignment</p>
<p>Instructions You have two parts to this assignment. The parts are related, but different in their implementation. To better understand the assignment itself, it may be helpful to go back through the book, slides, notes, etc. and do implementations of the regular array-based and linked list-based Stack, along with the Stack ADT. </p>
<p>Part I
One widespread use of stacks is to provide the undo operation, familiar to us from many different applications. While support for undo can be implemented with an unbounded stack (one that keeps growing and growing as long as memory permits), many applications provide only limited support for such an undo history. In other words, the stack is fixed-capacity.
When such a stack is full, and push is invoked, rather than throwing an exception, a more typical approach is to accept the pushed element at the top, while removing the oldest element from the bottom of the stack to make room. This is known as “leaking.” Note that this does not mean that the ADT exposes a method to allow removal from the bottom directly. This is only performed when the stack becomes full.
For this part, you are to give an implementation of such a LeakyStack abstraction, using some array-based implementation.
Note that you must create a Leaky Stack interface, and then use the C++ : operator to implement that interface (using public inheritance) with your LeakyArrayStack implementation. See the Interface specified near the end of the assignment instructions. </p>
<p>Part II Repeat Part I, but use a singly linked list instead of an array for the actual data storage, and allow for a maximum capacity specified as a parameter to the constructor. </p>
<p>NOTES: • Both the array-based and linked-list based Leaky Stacks should use the same LeakyStackInterface, specified below. Remember – this is a LeakyStack ADT. It specifies what the LeakyStack does, not how. So, the interface should not be different in order to provide an implementation. • Use public inheritance in both Parts • You should write a SinglyLinkedList class first, before trying to do part II o Then, use containment (aggregation or composition, a has-a relationship) to implement the part II</p>
<p>I GOT TO USE THE INTERFACE IN THE PICTURE</p>
<p>this is my code</p>
<pre><code> #include <iostream>
#ifndef LEAKYStacksINTERFACE
#define LEAKYStacksINTERFACE
#define cap 10
using namespace std;
template<typename ItemType>
class LeakyStacksInterface
{ public:
//returns whether Stacks is empty or not
virtual bool isEmpty() const = 0;
//adds a new entry to the top of the Stacks
//if the Stacks is full, the bottom item is removed
//or "leaked" first, and then the new item is set to the top
//---> If the Stacks was full when the push was attempted, return false
//---> If the Stacks was not full when the push was attempted, return true
virtual bool push(const ItemType& newEntry) = 0;
//remove the top item
//if the Stacks is empty, return false to indicate failure
virtual bool pop() = 0;
//return a copy of the top of the Stacks
virtual ItemType peek() const = 0;
//destroys the Stacks and frees up memory
//that was allocated
// virtual ~StacksInterface() {}
};
template<typename ItemType>
struct node
{
int data;
struct node *next;
};
template<typename ItemType>
class Stacks : public LeakyStacksInterface<ItemType>
{
struct node<ItemType> *top;
public:
int size;
ItemType *myArray;
Stacks()
{
top=NULL;
size = 0;
myArray = new ItemType[cap];
}
~Stacks() {
size = 0;
}
public:
// pure virtual function providing interface framework.
bool isEmpty() const {
return(size == 0);
}
bool push(const ItemType& newEntry) {
if(size == cap) {
for(int i = 0; i < size-1; i++) {
myArray[i] = myArray[i+1];
}
myArray[size-1] = newEntry;
return false;
}
}
ItemType peek() const {
return myArray[size-1];
}
void display()
{
cout<<"Stacks: [ ";
for(int i=size-1; i>=0; i--)
{
cout<<myArray[i]<<" ";
}
cout<<" ] "<<endl;
}
};
int main()
{
Stacks s;
int choice;
while(1)
{
cout<<"n-----------------------------------------------------------";
cout<<"nttSTACK USING LINKED LISTnn";
cout<<"1:PUSHn2:POPn3:DISPLAY STACKn4:EXIT";
cout<<"nEnter your choice(1-4): ";
cin>>choice;
switch(choice)
{
case 1:
s.push();
break;
case 2:
s.pop();
break;
case 3:
s.show();
break;
case 4:
return 0;
break;
default:
cout<<"Please enter correct choice(1-4)!!";
break;
}
}
return 0;
}
#endif
</code></pre>
<p>HERE ARE MY ERRORS :
ERROR:missing template arguments before 's'
ERROR:expected ';' before 's'
ERROR:'s' was not delcared in this scope</p>
<p>please help!
Thank You!</p>
<p><a href="https://i.stack.imgur.com/0Dx5A.png" rel="nofollow noreferrer">INTERFACE PICTURE</a></p>
| 0debug
|
Making an HTML string from a React component in background, how to use the string by dangerouslySetInnerHTML in another React component : <p>I'm trying to render LaTeX strings in a React project.
Although I use the <code>react-mathjax</code> React components, I want to get an HTML string made from the LaTeX strings in order to concatenate it and the other strings and set it by dangerouslySetInnerHTML.</p>
<h2>My current code I tried</h2>
<p>Sample code is here: <a href="https://github.com/Nyoho/test-react-project/blob/component2string/src/components/tex.jsx" rel="noreferrer">https://github.com/Nyoho/test-react-project/blob/component2string/src/components/tex.jsx</a></p>
<ol>
<li>LaTeX strings are given as strings</li>
<li>Make an empty DOM <code>aDom</code> by <code>document.createElement('span')</code> (in background. not in the document DOM tree.)</li>
<li>Render a LaTeX string by <code>ReactDOM.render</code> into <code>aDom</code></li>
<li>After rendering, get a string by <code>aDom.innerHTML</code> or <code>.outerHTML</code></li>
</ol>
<h2>Problem</h2>
<p>The value of <code>aDom.innerHTML</code> (or <code>.outerHTML</code>) is <code>"<span><span data-reactroot=\"\"></span></span>"</code> (almost empty)
although <code>aDom</code> has a perfect tree that MathJax generated.</p>
<p>Briefly,</p>
<ol>
<li><code>aDom</code>: 🙆</li>
<li><code>aDom.outerHTML</code>: 🙅</li>
</ol>
<p><a href="https://i.stack.imgur.com/2Q2v8.png" rel="noreferrer">A screenshot console.log of <code>aDom</code> and <code>aDom.outerHTML</code></a></p>
<h2>Question</h2>
<p>How can I get the 'correct' HTML string from <code>aDom</code> above?</p>
| 0debug
|
What's the data type of this variable? : <pre><code>Dim FilesA As String()
Dim FilesB() As String
</code></pre>
<p>What is the data type for FilesA?
What is the difference between above two declarations?
Can they be used interchangeably?</p>
| 0debug
|
Problem with Loop In Python loop is not defined : <p>my loop won't work</p>
<pre><code>Loop = True
while loop:
print ("hi")
#should constanly print hi
</code></pre>
<p>NameError: name 'loop' is not defined</p>
| 0debug
|
static void trim_aio_cancel(BlockAIOCB *acb)
{
TrimAIOCB *iocb = container_of(acb, TrimAIOCB, common);
iocb->j = iocb->qiov->niov - 1;
iocb->i = (iocb->qiov->iov[iocb->j].iov_len / 8) - 1;
iocb->ret = -ECANCELED;
if (iocb->aiocb) {
bdrv_aio_cancel_async(iocb->aiocb);
iocb->aiocb = NULL;
}
}
| 1threat
|
How to change date format of a date inside a string? : <p>I have a string "Hello please change the date from 04/24/2017 by putting month in the middle"</p>
<pre><code>class Paragraph:
@staticmethod
def change_date_format(paragraph):
return None
print(Paragraph.change_date_format('Hello please change the date from 04-24-2017 by putting month in the middle'))
</code></pre>
<p>I need to change this to "Hello please change the date from 24/04/2017 by putting month in the middle"</p>
| 0debug
|
static int decode_user_data(MpegEncContext *s, GetBitContext *gb){
char buf[256];
int i;
int e;
int ver, build, ver2, ver3;
char last;
for(i=0; i<255; i++){
if(show_bits(gb, 23) == 0) break;
buf[i]= get_bits(gb, 8);
}
buf[i]=0;
e=sscanf(buf, "DivX%dBuild%d%c", &ver, &build, &last);
if(e<2)
e=sscanf(buf, "DivX%db%d%c", &ver, &build, &last);
if(e>=2){
s->divx_version= ver;
s->divx_build= build;
s->divx_packed= e==3 && last=='p';
}
e=sscanf(buf, "FFmpe%*[^b]b%d", &build)+3;
if(e!=4)
e=sscanf(buf, "FFmpeg v%d.%d.%d / libavcodec build: %d", &ver, &ver2, &ver3, &build);
if(e!=4){
e=sscanf(buf, "Lavc%d.%d.%d", &ver, &ver2, &ver3)+1;
build= (ver<<16) + (ver2<<8) + ver3;
}
if(e!=4){
if(strcmp(buf, "ffmpeg")==0){
s->lavc_build= 4600;
}
}
if(e==4){
s->lavc_build= build;
}
e=sscanf(buf, "XviD%d", &build);
if(e==1){
s->xvid_build= build;
}
return 0;
}
| 1threat
|
Does an exception handler passed to CompletableFuture.exceptionally() have to return a meaningful value? : <p>I'm used to the <a href="https://github.com/google/guava/wiki/ListenableFutureExplained" rel="noreferrer"><code>ListenableFuture</code></a> pattern, with <code>onSuccess()</code> and <code>onFailure()</code> callbacks, e.g.</p>
<pre><code>ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
ListenableFuture<String> future = service.submit(...)
Futures.addCallback(future, new FutureCallback<String>() {
public void onSuccess(String result) {
handleResult(result);
}
public void onFailure(Throwable t) {
log.error("Unexpected error", t);
}
})
</code></pre>
<p>It seems like Java 8's <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html" rel="noreferrer"><code>CompletableFuture</code></a> is meant to handle more or less the same use case. Naively, I could start to translate the above example as:</p>
<pre><code>CompletableFuture<String> future = CompletableFuture<String>.supplyAsync(...)
.thenAccept(this::handleResult)
.exceptionally((t) -> log.error("Unexpected error", t));
</code></pre>
<p>This is certainly less verbose than the <code>ListenableFuture</code> version and looks very promising.</p>
<p>However, it doesn't compile, because <code>exceptionally()</code> doesn't take a <code>Consumer<Throwable></code>, it takes a <code>Function<Throwable, ? extends T></code> -- in this case, a <code>Function<Throwable, ? extends String></code>.</p>
<p>This means that I can't just log the error, I have to come up with a <code>String</code> value to return in the error case, and there is no meaningful <code>String</code> value to return in the error case. I can return <code>null</code>, just to get the code to compile:</p>
<pre><code> .exceptionally((t) -> {
log.error("Unexpected error", t);
return null; // hope this is ignored
});
</code></pre>
<p>But this is starting to get verbose again, and beyond verbosity, I don't like having that <code>null</code> floating around -- it suggests that someone might try to retrieve or capture that value, and that at some point much later I might have an unexpected <code>NullPointerException</code>.</p>
<p>If <code>exceptionally()</code> took a <code>Function<Throwable, Supplier<T>></code> I could at least do something like this --</p>
<pre><code> .exceptionally((t) -> {
log.error("Unexpected error", t);
return () -> {
throw new IllegalStateException("why are you invoking this?");
}
});
</code></pre>
<p>-- but it doesn't.</p>
<p>What's the right thing to do when <code>exceptionally()</code> should never produce a valid value? Is there something else I can do with <code>CompletableFuture</code>, or something else in the new Java 8 libraries, that better supports this use case?</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.