problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
db.execute('SELECT * FROM employees WHERE id = ' + user_input) | 1threat |
static void pfpu_write(void *opaque, target_phys_addr_t addr, uint64_t value,
unsigned size)
{
MilkymistPFPUState *s = opaque;
trace_milkymist_pfpu_memory_write(addr, value);
addr >>= 2;
switch (addr) {
case R_CTL:
if (value & CTL_START_BUSY) {
pfpu_start(s);
}
break;
case R_MESHBASE:
case R_HMESHLAST:
case R_VMESHLAST:
case R_CODEPAGE:
case R_VERTICES:
case R_COLLISIONS:
case R_STRAYWRITES:
case R_LASTDMA:
case R_PC:
case R_DREGBASE:
case R_CODEBASE:
s->regs[addr] = value;
break;
case GPR_BEGIN ... GPR_END:
s->gp_regs[addr - GPR_BEGIN] = value;
break;
case MICROCODE_BEGIN ... MICROCODE_END:
s->microcode[get_microcode_address(s, addr)] = value;
break;
default:
error_report("milkymist_pfpu: write access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
}
| 1threat |
java.lang.ClassCastException: com.jcraft.jsch.ChannelSftp$2 cannot be cast to java.io.FileInputStream : <p>I'm downloading a file from remote server using sftp channel as inputstream and trying to cast into fileinputstream. Then I'm receiving following exception from jvm 1.8</p>
<p>java.lang.ClassCastException: com.jcraft.jsch.ChannelSftp$2 cannot be cast to java.io.FileInputStream</p>
<p>Please someone help. I'm stuck here</p>
| 0debug |
Difference between scope and access modifier in Java : <p>Let me know the difference between scope and access modifier in Java.Do these have any similarity?</p>
| 0debug |
Parse this date format or what it means "D:20170328092616+01'00'"? : I have this format from a PDF file "D:20170328092616+01'00'" and I'm trying to parse this format
DateTime parsedDate = DateTime.ParseExact("D:20170328092616+01'00'", "0:yyyyMMddhhmmss", CultureInfo.CurrentCulture, DateTimeStyles.None);,any one has any idea. | 0debug |
void gen_intermediate_code_internal_a64(ARMCPU *cpu,
TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUARMState *env = &cpu->env;
DisasContext dc1, *dc = &dc1;
CPUBreakpoint *bp;
int j, lj;
target_ulong pc_start;
target_ulong next_page_start;
int num_insns;
int max_insns;
pc_start = tb->pc;
dc->tb = tb;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->singlestep_enabled = cs->singlestep_enabled;
dc->condjmp = 0;
dc->aarch64 = 1;
dc->el3_is_aa64 = arm_el_is_aa64(env, 3);
dc->thumb = 0;
dc->bswap_code = 0;
dc->condexec_mask = 0;
dc->condexec_cond = 0;
dc->mmu_idx = ARM_TBFLAG_MMUIDX(tb->flags);
dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx);
#if !defined(CONFIG_USER_ONLY)
dc->user = (dc->current_el == 0);
#endif
dc->cpacr_fpen = ARM_TBFLAG_AA64_FPEN(tb->flags);
dc->vec_len = 0;
dc->vec_stride = 0;
dc->cp_regs = cpu->cp_regs;
dc->features = env->features;
dc->ss_active = ARM_TBFLAG_SS_ACTIVE(tb->flags);
dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(tb->flags);
dc->is_ldex = false;
dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el);
init_tmp_a64_array(dc);
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
lj = -1;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0) {
max_insns = CF_COUNT_MASK;
}
gen_tb_start(tb);
tcg_clear_temp_count();
do {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == dc->pc) {
gen_exception_internal_insn(dc, 0, EXCP_DEBUG);
dc->pc += 2;
goto done_generating;
}
}
}
if (search_pc) {
j = tcg_op_buf_count();
if (lj < j) {
lj++;
while (lj < j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
}
tcg_ctx.gen_opc_pc[lj] = dc->pc;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(dc->pc);
}
if (dc->ss_active && !dc->pstate_ss) {
assert(num_insns == 0);
gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),
default_exception_el(dc));
dc->is_jmp = DISAS_EXC;
break;
}
disas_a64_insn(env, dc);
if (tcg_check_temp_count()) {
fprintf(stderr, "TCG temporary leak before "TARGET_FMT_lx"\n",
dc->pc);
}
num_insns++;
} while (!dc->is_jmp && !tcg_op_buf_full() &&
!cs->singlestep_enabled &&
!singlestep &&
!dc->ss_active &&
dc->pc < next_page_start &&
num_insns < max_insns);
if (tb->cflags & CF_LAST_IO) {
gen_io_end();
}
if (unlikely(cs->singlestep_enabled || dc->ss_active)
&& dc->is_jmp != DISAS_EXC) {
assert(dc->is_jmp != DISAS_TB_JUMP);
if (dc->is_jmp != DISAS_JUMP) {
gen_a64_set_pc_im(dc->pc);
}
if (cs->singlestep_enabled) {
gen_exception_internal(EXCP_DEBUG);
} else {
gen_step_complete_exception(dc);
}
} else {
switch (dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 1, dc->pc);
break;
default:
case DISAS_UPDATE:
gen_a64_set_pc_im(dc->pc);
case DISAS_JUMP:
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
case DISAS_EXC:
case DISAS_SWI:
break;
case DISAS_WFE:
gen_a64_set_pc_im(dc->pc);
gen_helper_wfe(cpu_env);
break;
case DISAS_WFI:
gen_a64_set_pc_im(dc->pc);
gen_helper_wfi(cpu_env);
break;
}
}
done_generating:
gen_tb_end(tb, num_insns);
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, dc->pc - pc_start,
4 | (dc->bswap_code << 1));
qemu_log("\n");
}
#endif
if (search_pc) {
j = tcg_op_buf_count();
lj++;
while (lj <= j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
} else {
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
}
| 1threat |
How to cache Django Rest Framework API calls? : <p>I'm using Memcached as backend to my django app. This code works fine in normal django query:</p>
<pre><code>def get_myobj():
cache_key = 'mykey'
result = cache.get(cache_key, None)
if not result:
result = Product.objects.all().filter(draft=False)
cache.set(cache_key, result)
return result
</code></pre>
<p>But it doesn't work when used with django-rest-framework api calls:</p>
<pre><code>class ProductListAPIView(generics.ListAPIView):
def get_queryset(self):
product_list = Product.objects.all()
return product_list
serializer_class = ProductSerializer
</code></pre>
<p>I'm about to try DRF-extensions which provide caching functionality:</p>
<p><a href="https://github.com/chibisov/drf-extensions" rel="noreferrer">https://github.com/chibisov/drf-extensions</a></p>
<p>but the build status on github is currently saying "build failing".</p>
<p>My app is very read-heavy on api calls. Is there a way to cache these calls?</p>
<p>Thank you.</p>
| 0debug |
Pass function as parameter, JAVA : Have to port a little piece of code from JavaScript to JAVA:
var N = 3;
var w = 8, h = 8;
var matrix = [
[1, 0, 0, 0, 0, 0, 0, 0],
[1, 1, 0, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 0, 0, 0],
[1, 1, 1, 1, 1, 1, 0, 0],
[1, 1, 1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 1, 1, 1]
];
//[1, 1, 1, 1, 1, 1, 0, 1, 1]
console.log(complexFunction(2, 1));
//first function
function simpleFunction(f_) {
var out = new Array(N * N);
for (var y = 0; y < N; y++) {
for (var x = 0; x < N; x++) {
out[x + y * N] = f_(x, y);
}
}
return out;
};
//second function
function complexFunction(x_, y_) {
return simpleFunction(function (dx, dy) { return matrix[(x + dx) % w][(y + dy) % h]; });
};
Have experimented with Callable without any success.
Ideally, the ported result should have the same structure as JavaScript source. | 0debug |
Python pandas: selecting rows whose column value is null / None / nan : <p>How do I select those rows of a DataFrame whose value in a column is none?</p>
<p>I've coded these to <code>np.nan</code> and can't match against this type.</p>
<pre><code>In [1]: import numpy as np
In [2]: import pandas as pd
In [3]: df = pd.DataFrame([[1, 2, 3], [3, 4, None]])
In [4]: df
Out[4]:
0 1 2
0 1 2 3.0
1 3 4 NaN
In [5]: df = df.fillna(np.nan)
In [6]: df
Out[6]:
0 1 2
0 1 2 3.0
1 3 4 NaN
In [7]: df.iloc[1][2]
Out[7]: nan
In [8]: df.iloc[1][2] == np.nan
Out[8]: False
In [9]: df[df[2] == None]
Out[9]:
Empty DataFrame
Columns: [0, 1, 2]
Index: []
</code></pre>
| 0debug |
static struct pathelem *add_entry(struct pathelem *root, const char *name)
{
root->num_entries++;
root = realloc(root, sizeof(*root)
+ sizeof(root->entries[0])*root->num_entries);
root->entries[root->num_entries-1] = new_entry(root->pathname, root, name);
root->entries[root->num_entries-1]
= add_dir_maybe(root->entries[root->num_entries-1]);
return root;
}
| 1threat |
if (!strcmp(a,b)) when it returns value? : If we have the code below, what is the meaning of `!strcmp(a,b)`? We suppose that we work with `strcmp(a,b)`, and as I know if `a = b`, it returns `0`, if `a<b` it returns `-1`, if `a>b` it returns `1`. `!` sign should negate that function, so when it will return value `i`? I'm confused.
for(i=1;i<var;i++)
if(!strcmp(s,anotherVar[i]))
return i;
| 0debug |
Windows Service Template for Visual Studio 2017 : <p>The Windows Service Template no longer displays by-default for new projects in Visual Studio 2017....and the installer has no 'search' capability.</p>
<p>All this AZURE stuff is great, but I still gotta do normal 'on-prem' work too...and I hate maintaining 2 versions of Visual Studio.</p>
<p>Any thoughts here?</p>
<p><a href="https://i.stack.imgur.com/LqxLn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LqxLn.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/2OUpT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2OUpT.png" alt="enter image description here"></a></p>
| 0debug |
Getting dates in PHP :
echo date("d-m-Y"); // Today
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y")); // tomorrow
echo date('d-m-Y',$tomorrow);
$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); // lastmonth
echo date('d-m-Y',$lastmonth);
$nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1); // nextyear
echo date('d-m-Y',$nextyear);
$afterAweek = mktime(0, 0, 0, date("m") , date("d")+7, date("Y")); // after a week
echo date('d-m-Y',$afterAweek);
| 0debug |
static always_inline int translate_one (DisasContext *ctx, uint32_t insn)
{
uint32_t palcode;
int32_t disp21, disp16, disp12;
uint16_t fn11, fn16;
uint8_t opc, ra, rb, rc, sbz, fpfn, fn7, fn2, islit;
uint8_t lit;
int ret;
opc = insn >> 26;
ra = (insn >> 21) & 0x1F;
rb = (insn >> 16) & 0x1F;
rc = insn & 0x1F;
sbz = (insn >> 13) & 0x07;
islit = (insn >> 12) & 1;
if (rb == 31 && !islit) {
islit = 1;
lit = 0;
} else
lit = (insn >> 13) & 0xFF;
palcode = insn & 0x03FFFFFF;
disp21 = ((int32_t)((insn & 0x001FFFFF) << 11)) >> 11;
disp16 = (int16_t)(insn & 0x0000FFFF);
disp12 = (int32_t)((insn & 0x00000FFF) << 20) >> 20;
fn16 = insn & 0x0000FFFF;
fn11 = (insn >> 5) & 0x000007FF;
fpfn = fn11 & 0x3F;
fn7 = (insn >> 5) & 0x0000007F;
fn2 = (insn >> 5) & 0x00000003;
ret = 0;
#if defined ALPHA_DEBUG_DISAS
if (logfile != NULL) {
fprintf(logfile, "opc %02x ra %d rb %d rc %d disp16 %04x\n",
opc, ra, rb, rc, disp16);
}
#endif
switch (opc) {
case 0x00:
if (palcode >= 0x80 && palcode < 0xC0) {
gen_excp(ctx, EXCP_CALL_PAL + ((palcode & 0x1F) << 6), 0);
#if !defined (CONFIG_USER_ONLY)
} else if (palcode < 0x40) {
if (ctx->mem_idx & 1)
goto invalid_opc;
else
gen_excp(ctx, EXCP_CALL_PALP + ((palcode & 0x1F) << 6), 0);
#endif
} else {
goto invalid_opc;
}
ret = 3;
break;
case 0x01:
goto invalid_opc;
case 0x02:
goto invalid_opc;
case 0x03:
goto invalid_opc;
case 0x04:
goto invalid_opc;
case 0x05:
goto invalid_opc;
case 0x06:
goto invalid_opc;
case 0x07:
goto invalid_opc;
case 0x08:
if (likely(ra != 31)) {
if (rb != 31)
tcg_gen_addi_i64(cpu_ir[ra], cpu_ir[rb], disp16);
else
tcg_gen_movi_i64(cpu_ir[ra], disp16);
}
break;
case 0x09:
if (likely(ra != 31)) {
if (rb != 31)
tcg_gen_addi_i64(cpu_ir[ra], cpu_ir[rb], disp16 << 16);
else
tcg_gen_movi_i64(cpu_ir[ra], disp16 << 16);
}
break;
case 0x0A:
if (!(ctx->amask & AMASK_BWX))
goto invalid_opc;
gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0);
break;
case 0x0B:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1);
break;
case 0x0C:
if (!(ctx->amask & AMASK_BWX))
goto invalid_opc;
gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 1);
break;
case 0x0D:
gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0);
break;
case 0x0E:
gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0);
break;
case 0x0F:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1);
break;
case 0x10:
switch (fn7) {
case 0x00:
if (likely(rc != 31)) {
if (ra != 31) {
if (islit) {
tcg_gen_addi_i64(cpu_ir[rc], cpu_ir[ra], lit);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
} else {
tcg_gen_add_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x02:
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
if (islit)
tcg_gen_addi_i64(tmp, tmp, lit);
else
tcg_gen_add_i64(tmp, tmp, cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], tmp);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x09:
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_subi_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_sub_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], -lit);
else {
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
}
break;
case 0x0B:
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
if (islit)
tcg_gen_subi_i64(tmp, tmp, lit);
else
tcg_gen_sub_i64(tmp, tmp, cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], tmp);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], -lit);
else {
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
}
}
break;
case 0x0F:
gen_arith3(helper_cmpbge, ra, rb, rc, islit, lit);
break;
case 0x12:
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
if (islit)
tcg_gen_addi_i64(tmp, tmp, lit);
else
tcg_gen_add_i64(tmp, tmp, cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], tmp);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x1B:
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
if (islit)
tcg_gen_subi_i64(tmp, tmp, lit);
else
tcg_gen_sub_i64(tmp, tmp, cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], tmp);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], -lit);
else
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
}
}
break;
case 0x1D:
gen_cmp(TCG_COND_LTU, ra, rb, rc, islit, lit);
break;
case 0x20:
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_addi_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_add_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x22:
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
if (islit)
tcg_gen_addi_i64(cpu_ir[rc], tmp, lit);
else
tcg_gen_add_i64(cpu_ir[rc], tmp, cpu_ir[rb]);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x29:
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_subi_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_sub_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], -lit);
else
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x2B:
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
if (islit)
tcg_gen_subi_i64(cpu_ir[rc], tmp, lit);
else
tcg_gen_sub_i64(cpu_ir[rc], tmp, cpu_ir[rb]);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], -lit);
else
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x2D:
gen_cmp(TCG_COND_EQ, ra, rb, rc, islit, lit);
break;
case 0x32:
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
if (islit)
tcg_gen_addi_i64(cpu_ir[rc], tmp, lit);
else
tcg_gen_add_i64(cpu_ir[rc], tmp, cpu_ir[rb]);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x3B:
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
if (islit)
tcg_gen_subi_i64(cpu_ir[rc], tmp, lit);
else
tcg_gen_sub_i64(cpu_ir[rc], tmp, cpu_ir[rb]);
tcg_temp_free(tmp);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], -lit);
else
tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x3D:
gen_cmp(TCG_COND_LEU, ra, rb, rc, islit, lit);
break;
case 0x40:
gen_arith3(helper_addlv, ra, rb, rc, islit, lit);
break;
case 0x49:
gen_arith3(helper_sublv, ra, rb, rc, islit, lit);
break;
case 0x4D:
gen_cmp(TCG_COND_LT, ra, rb, rc, islit, lit);
break;
case 0x60:
gen_arith3(helper_addqv, ra, rb, rc, islit, lit);
break;
case 0x69:
gen_arith3(helper_subqv, ra, rb, rc, islit, lit);
break;
case 0x6D:
gen_cmp(TCG_COND_LE, ra, rb, rc, islit, lit);
break;
default:
goto invalid_opc;
}
break;
case 0x11:
switch (fn7) {
case 0x00:
if (likely(rc != 31)) {
if (ra == 31)
tcg_gen_movi_i64(cpu_ir[rc], 0);
else if (islit)
tcg_gen_andi_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_and_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
}
break;
case 0x08:
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_andi_i64(cpu_ir[rc], cpu_ir[ra], ~lit);
else
tcg_gen_andc_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else
tcg_gen_movi_i64(cpu_ir[rc], 0);
}
break;
case 0x14:
gen_cmov(TCG_COND_EQ, ra, rb, rc, islit, lit, 1);
break;
case 0x16:
gen_cmov(TCG_COND_NE, ra, rb, rc, islit, lit, 1);
break;
case 0x20:
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_ori_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_or_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x24:
gen_cmov(TCG_COND_NE, ra, rb, rc, islit, lit, 0);
break;
case 0x26:
gen_cmov(TCG_COND_EQ, ra, rb, rc, islit, lit, 0);
break;
case 0x28:
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_ori_i64(cpu_ir[rc], cpu_ir[ra], ~lit);
else
tcg_gen_orc_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], ~lit);
else
tcg_gen_not_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x40:
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_xori_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_xor_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], lit);
else
tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x44:
gen_cmov(TCG_COND_GE, ra, rb, rc, islit, lit, 0);
break;
case 0x46:
gen_cmov(TCG_COND_LT, ra, rb, rc, islit, lit, 0);
break;
case 0x48:
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_xori_i64(cpu_ir[rc], cpu_ir[ra], ~lit);
else
tcg_gen_eqv_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
} else {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], ~lit);
else
tcg_gen_not_i64(cpu_ir[rc], cpu_ir[rb]);
}
}
break;
case 0x61:
if (likely(rc != 31)) {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], helper_amask(lit));
else
tcg_gen_helper_1_1(helper_amask, cpu_ir[rc], cpu_ir[rb]);
}
break;
case 0x64:
gen_cmov(TCG_COND_GT, ra, rb, rc, islit, lit, 0);
break;
case 0x66:
gen_cmov(TCG_COND_LE, ra, rb, rc, islit, lit, 0);
break;
case 0x6C:
if (rc != 31)
tcg_gen_helper_1_0(helper_load_implver, cpu_ir[rc]);
break;
default:
goto invalid_opc;
}
break;
case 0x12:
switch (fn7) {
case 0x02:
gen_arith3(helper_mskbl, ra, rb, rc, islit, lit);
break;
case 0x06:
gen_ext_l(&tcg_gen_ext8u_i64, ra, rb, rc, islit, lit);
break;
case 0x0B:
gen_arith3(helper_insbl, ra, rb, rc, islit, lit);
break;
case 0x12:
gen_arith3(helper_mskwl, ra, rb, rc, islit, lit);
break;
case 0x16:
gen_ext_l(&tcg_gen_ext16u_i64, ra, rb, rc, islit, lit);
break;
case 0x1B:
gen_arith3(helper_inswl, ra, rb, rc, islit, lit);
break;
case 0x22:
gen_arith3(helper_mskll, ra, rb, rc, islit, lit);
break;
case 0x26:
gen_ext_l(&tcg_gen_ext32u_i64, ra, rb, rc, islit, lit);
break;
case 0x2B:
gen_arith3(helper_insll, ra, rb, rc, islit, lit);
break;
case 0x30:
gen_arith3(helper_zap, ra, rb, rc, islit, lit);
break;
case 0x31:
gen_arith3(helper_zapnot, ra, rb, rc, islit, lit);
break;
case 0x32:
gen_arith3(helper_mskql, ra, rb, rc, islit, lit);
break;
case 0x34:
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_shri_i64(cpu_ir[rc], cpu_ir[ra], lit & 0x3f);
else {
TCGv shift = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_andi_i64(shift, cpu_ir[rb], 0x3f);
tcg_gen_shr_i64(cpu_ir[rc], cpu_ir[ra], shift);
tcg_temp_free(shift);
}
} else
tcg_gen_movi_i64(cpu_ir[rc], 0);
}
break;
case 0x36:
gen_ext_l(NULL, ra, rb, rc, islit, lit);
break;
case 0x39:
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_shli_i64(cpu_ir[rc], cpu_ir[ra], lit & 0x3f);
else {
TCGv shift = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_andi_i64(shift, cpu_ir[rb], 0x3f);
tcg_gen_shl_i64(cpu_ir[rc], cpu_ir[ra], shift);
tcg_temp_free(shift);
}
} else
tcg_gen_movi_i64(cpu_ir[rc], 0);
}
break;
case 0x3B:
gen_arith3(helper_insql, ra, rb, rc, islit, lit);
break;
case 0x3C:
if (likely(rc != 31)) {
if (ra != 31) {
if (islit)
tcg_gen_sari_i64(cpu_ir[rc], cpu_ir[ra], lit & 0x3f);
else {
TCGv shift = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_andi_i64(shift, cpu_ir[rb], 0x3f);
tcg_gen_sar_i64(cpu_ir[rc], cpu_ir[ra], shift);
tcg_temp_free(shift);
}
} else
tcg_gen_movi_i64(cpu_ir[rc], 0);
}
break;
case 0x52:
gen_arith3(helper_mskwh, ra, rb, rc, islit, lit);
break;
case 0x57:
gen_arith3(helper_inswh, ra, rb, rc, islit, lit);
break;
case 0x5A:
gen_ext_h(&tcg_gen_ext16u_i64, ra, rb, rc, islit, lit);
break;
case 0x62:
gen_arith3(helper_msklh, ra, rb, rc, islit, lit);
break;
case 0x67:
gen_arith3(helper_inslh, ra, rb, rc, islit, lit);
break;
case 0x6A:
gen_ext_h(&tcg_gen_ext16u_i64, ra, rb, rc, islit, lit);
break;
case 0x72:
gen_arith3(helper_mskqh, ra, rb, rc, islit, lit);
break;
case 0x77:
gen_arith3(helper_insqh, ra, rb, rc, islit, lit);
break;
case 0x7A:
gen_ext_h(NULL, ra, rb, rc, islit, lit);
break;
default:
goto invalid_opc;
}
break;
case 0x13:
switch (fn7) {
case 0x00:
if (likely(rc != 31)) {
if (ra == 31)
tcg_gen_movi_i64(cpu_ir[rc], 0);
else {
if (islit)
tcg_gen_muli_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_mul_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]);
}
}
break;
case 0x20:
if (likely(rc != 31)) {
if (ra == 31)
tcg_gen_movi_i64(cpu_ir[rc], 0);
else if (islit)
tcg_gen_muli_i64(cpu_ir[rc], cpu_ir[ra], lit);
else
tcg_gen_mul_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]);
}
break;
case 0x30:
gen_arith3(helper_umulh, ra, rb, rc, islit, lit);
break;
case 0x40:
gen_arith3(helper_mullv, ra, rb, rc, islit, lit);
break;
case 0x60:
gen_arith3(helper_mulqv, ra, rb, rc, islit, lit);
break;
default:
goto invalid_opc;
}
break;
case 0x14:
switch (fpfn) {
case 0x04:
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I32);
tcg_gen_trunc_i64_i32(tmp, cpu_ir[ra]);
tcg_gen_helper_1_1(helper_memory_to_s, cpu_fir[rc], tmp);
tcg_temp_free(tmp);
} else
tcg_gen_movi_i64(cpu_fir[rc], 0);
}
break;
case 0x0A:
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
gen_farith2(&helper_sqrtf, rb, rc);
break;
case 0x0B:
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
gen_farith2(&helper_sqrts, rb, rc);
break;
case 0x14:
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (ra != 31) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I32);
tcg_gen_trunc_i64_i32(tmp, cpu_ir[ra]);
tcg_gen_helper_1_1(helper_memory_to_f, cpu_fir[rc], tmp);
tcg_temp_free(tmp);
} else
tcg_gen_movi_i64(cpu_fir[rc], 0);
}
break;
case 0x24:
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (ra != 31)
tcg_gen_mov_i64(cpu_fir[rc], cpu_ir[ra]);
else
tcg_gen_movi_i64(cpu_fir[rc], 0);
}
break;
case 0x2A:
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
gen_farith2(&helper_sqrtg, rb, rc);
break;
case 0x02B:
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
gen_farith2(&helper_sqrtt, rb, rc);
break;
default:
goto invalid_opc;
}
break;
case 0x15:
switch (fpfn) {
case 0x00:
gen_farith3(&helper_addf, ra, rb, rc);
break;
case 0x01:
gen_farith3(&helper_subf, ra, rb, rc);
break;
case 0x02:
gen_farith3(&helper_mulf, ra, rb, rc);
break;
case 0x03:
gen_farith3(&helper_divf, ra, rb, rc);
break;
case 0x1E:
#if 0
gen_farith2(&helper_cvtdg, rb, rc);
#else
goto invalid_opc;
#endif
break;
case 0x20:
gen_farith3(&helper_addg, ra, rb, rc);
break;
case 0x21:
gen_farith3(&helper_subg, ra, rb, rc);
break;
case 0x22:
gen_farith3(&helper_mulg, ra, rb, rc);
break;
case 0x23:
gen_farith3(&helper_divg, ra, rb, rc);
break;
case 0x25:
gen_farith3(&helper_cmpgeq, ra, rb, rc);
break;
case 0x26:
gen_farith3(&helper_cmpglt, ra, rb, rc);
break;
case 0x27:
gen_farith3(&helper_cmpgle, ra, rb, rc);
break;
case 0x2C:
gen_farith2(&helper_cvtgf, rb, rc);
break;
case 0x2D:
#if 0
gen_farith2(ctx, &helper_cvtgd, rb, rc);
#else
goto invalid_opc;
#endif
break;
case 0x2F:
gen_farith2(&helper_cvtgq, rb, rc);
break;
case 0x3C:
gen_farith2(&helper_cvtqf, rb, rc);
break;
case 0x3E:
gen_farith2(&helper_cvtqg, rb, rc);
break;
default:
goto invalid_opc;
}
break;
case 0x16:
switch (fpfn) {
case 0x00:
gen_farith3(&helper_adds, ra, rb, rc);
break;
case 0x01:
gen_farith3(&helper_subs, ra, rb, rc);
break;
case 0x02:
gen_farith3(&helper_muls, ra, rb, rc);
break;
case 0x03:
gen_farith3(&helper_divs, ra, rb, rc);
break;
case 0x20:
gen_farith3(&helper_addt, ra, rb, rc);
break;
case 0x21:
gen_farith3(&helper_subt, ra, rb, rc);
break;
case 0x22:
gen_farith3(&helper_mult, ra, rb, rc);
break;
case 0x23:
gen_farith3(&helper_divt, ra, rb, rc);
break;
case 0x24:
gen_farith3(&helper_cmptun, ra, rb, rc);
break;
case 0x25:
gen_farith3(&helper_cmpteq, ra, rb, rc);
break;
case 0x26:
gen_farith3(&helper_cmptlt, ra, rb, rc);
break;
case 0x27:
gen_farith3(&helper_cmptle, ra, rb, rc);
break;
case 0x2C:
if (fn11 == 0x2AC) {
gen_farith2(&helper_cvtst, rb, rc);
} else {
gen_farith2(&helper_cvtts, rb, rc);
}
break;
case 0x2F:
gen_farith2(&helper_cvttq, rb, rc);
break;
case 0x3C:
gen_farith2(&helper_cvtqs, rb, rc);
break;
case 0x3E:
gen_farith2(&helper_cvtqt, rb, rc);
break;
default:
goto invalid_opc;
}
break;
case 0x17:
switch (fn11) {
case 0x010:
gen_farith2(&helper_cvtlq, rb, rc);
break;
case 0x020:
if (likely(rc != 31)) {
if (ra == rb)
tcg_gen_mov_i64(cpu_fir[rc], cpu_fir[ra]);
else
gen_farith3(&helper_cpys, ra, rb, rc);
}
break;
case 0x021:
gen_farith3(&helper_cpysn, ra, rb, rc);
break;
case 0x022:
gen_farith3(&helper_cpyse, ra, rb, rc);
break;
case 0x024:
if (likely(ra != 31))
tcg_gen_helper_0_1(helper_store_fpcr, cpu_fir[ra]);
else {
TCGv tmp = tcg_const_i64(0);
tcg_gen_helper_0_1(helper_store_fpcr, tmp);
tcg_temp_free(tmp);
}
break;
case 0x025:
if (likely(ra != 31))
tcg_gen_helper_1_0(helper_load_fpcr, cpu_fir[ra]);
break;
case 0x02A:
gen_fcmov(&helper_cmpfeq, ra, rb, rc);
break;
case 0x02B:
gen_fcmov(&helper_cmpfne, ra, rb, rc);
break;
case 0x02C:
gen_fcmov(&helper_cmpflt, ra, rb, rc);
break;
case 0x02D:
gen_fcmov(&helper_cmpfge, ra, rb, rc);
break;
case 0x02E:
gen_fcmov(&helper_cmpfle, ra, rb, rc);
break;
case 0x02F:
gen_fcmov(&helper_cmpfgt, ra, rb, rc);
break;
case 0x030:
gen_farith2(&helper_cvtql, rb, rc);
break;
case 0x130:
gen_farith2(&helper_cvtqlv, rb, rc);
break;
case 0x530:
gen_farith2(&helper_cvtqlsv, rb, rc);
break;
default:
goto invalid_opc;
}
break;
case 0x18:
switch ((uint16_t)disp16) {
case 0x0000:
ret = 2;
break;
case 0x0400:
ret = 2;
break;
case 0x4000:
break;
case 0x4400:
break;
case 0x8000:
break;
case 0xA000:
break;
case 0xC000:
if (ra != 31)
tcg_gen_helper_1_0(helper_load_pcc, cpu_ir[ra]);
break;
case 0xE000:
if (ra != 31)
tcg_gen_helper_1_0(helper_rc, cpu_ir[ra]);
break;
case 0xE800:
#if 0
ret = 2;
#else
goto invalid_opc;
#endif
break;
case 0xF000:
if (ra != 31)
tcg_gen_helper_1_0(helper_rs, cpu_ir[ra]);
break;
case 0xF800:
break;
default:
goto invalid_opc;
}
break;
case 0x19:
#if defined (CONFIG_USER_ONLY)
goto invalid_opc;
#else
if (!ctx->pal_mode)
goto invalid_opc;
if (ra != 31) {
TCGv tmp = tcg_const_i32(insn & 0xFF);
tcg_gen_helper_1_2(helper_mfpr, cpu_ir[ra], tmp, cpu_ir[ra]);
tcg_temp_free(tmp);
}
break;
#endif
case 0x1A:
if (ra != 31)
tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
if (rb != 31)
tcg_gen_andi_i64(cpu_pc, cpu_ir[rb], ~3);
else
tcg_gen_movi_i64(cpu_pc, 0);
switch (fn2) {
case 0x0:
break;
case 0x1:
break;
case 0x2:
break;
case 0x3:
break;
}
ret = 1;
break;
case 0x1B:
#if defined (CONFIG_USER_ONLY)
goto invalid_opc;
#else
if (!ctx->pal_mode)
goto invalid_opc;
if (ra != 31) {
TCGv addr = tcg_temp_new(TCG_TYPE_I64);
if (rb != 31)
tcg_gen_addi_i64(addr, cpu_ir[rb], disp12);
else
tcg_gen_movi_i64(addr, disp12);
switch ((insn >> 12) & 0xF) {
case 0x0:
tcg_gen_helper_0_2(helper_ldl_raw, cpu_ir[ra], addr);
break;
case 0x1:
tcg_gen_helper_0_2(helper_ldq_raw, cpu_ir[ra], addr);
break;
case 0x2:
tcg_gen_helper_0_2(helper_ldl_l_raw, cpu_ir[ra], addr);
break;
case 0x3:
tcg_gen_helper_0_2(helper_ldq_l_raw, cpu_ir[ra], addr);
break;
case 0x4:
tcg_gen_helper_0_2(helper_ldl_kernel, cpu_ir[ra], addr);
break;
case 0x5:
tcg_gen_helper_0_2(helper_ldq_kernel, cpu_ir[ra], addr);
break;
case 0x6:
goto incpu_ir[ra]id_opc;
case 0x7:
goto incpu_ir[ra]id_opc;
case 0x8:
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_ldl_raw, cpu_ir[ra], addr);
break;
case 0x9:
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_ldq_raw, cpu_ir[ra], addr);
break;
case 0xA:
tcg_gen_qemu_ld32s(cpu_ir[ra], addr, ctx->flags);
break;
case 0xB:
tcg_gen_qemu_ld64(cpu_ir[ra], addr, ctx->flags);
break;
case 0xC:
tcg_gen_helper_0_0(helper_set_alt_mode);
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_ldl_raw, cpu_ir[ra], addr);
tcg_gen_helper_0_0(helper_restore_mode);
break;
case 0xD:
tcg_gen_helper_0_0(helper_set_alt_mode);
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_ldq_raw, cpu_ir[ra], addr);
tcg_gen_helper_0_0(helper_restore_mode);
break;
case 0xE:
tcg_gen_helper_0_0(helper_set_alt_mode);
tcg_gen_helper_0_2(helper_ldl_data, cpu_ir[ra], addr);
tcg_gen_helper_0_0(helper_restore_mode);
break;
case 0xF:
tcg_gen_helper_0_0(helper_set_alt_mode);
tcg_gen_helper_0_2(helper_ldq_data, cpu_ir[ra], addr);
tcg_gen_helper_0_0(helper_restore_mode);
break;
}
tcg_temp_free(addr);
}
break;
#endif
case 0x1C:
switch (fn7) {
case 0x00:
if (!(ctx->amask & AMASK_BWX))
goto invalid_opc;
if (likely(rc != 31)) {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], (int64_t)((int8_t)lit));
else
tcg_gen_ext8s_i64(cpu_ir[rc], cpu_ir[rb]);
}
break;
case 0x01:
if (!(ctx->amask & AMASK_BWX))
goto invalid_opc;
if (likely(rc != 31)) {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], (int64_t)((int16_t)lit));
else
tcg_gen_ext16s_i64(cpu_ir[rc], cpu_ir[rb]);
}
break;
case 0x30:
if (!(ctx->amask & AMASK_CIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], ctpop64(lit));
else
tcg_gen_helper_1_1(helper_ctpop, cpu_ir[rc], cpu_ir[rb]);
}
break;
case 0x31:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x32:
if (!(ctx->amask & AMASK_CIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], clz64(lit));
else
tcg_gen_helper_1_1(helper_ctlz, cpu_ir[rc], cpu_ir[rb]);
}
break;
case 0x33:
if (!(ctx->amask & AMASK_CIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (islit)
tcg_gen_movi_i64(cpu_ir[rc], ctz64(lit));
else
tcg_gen_helper_1_1(helper_cttz, cpu_ir[rc], cpu_ir[rb]);
}
break;
case 0x34:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x35:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x36:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x37:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x38:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x39:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x3A:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x3B:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x3C:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x3D:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x3E:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x3F:
if (!(ctx->amask & AMASK_MVI))
goto invalid_opc;
goto invalid_opc;
break;
case 0x70:
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
if (likely(rc != 31)) {
if (ra != 31)
tcg_gen_mov_i64(cpu_ir[rc], cpu_fir[ra]);
else
tcg_gen_movi_i64(cpu_ir[rc], 0);
}
break;
case 0x78:
if (!(ctx->amask & AMASK_FIX))
goto invalid_opc;
if (rc != 31) {
TCGv tmp1 = tcg_temp_new(TCG_TYPE_I32);
if (ra != 31)
tcg_gen_helper_1_1(helper_s_to_memory, tmp1, cpu_fir[ra]);
else {
TCGv tmp2 = tcg_const_i64(0);
tcg_gen_helper_1_1(helper_s_to_memory, tmp1, tmp2);
tcg_temp_free(tmp2);
}
tcg_gen_ext_i32_i64(cpu_ir[rc], tmp1);
tcg_temp_free(tmp1);
}
break;
default:
goto invalid_opc;
}
break;
case 0x1D:
#if defined (CONFIG_USER_ONLY)
goto invalid_opc;
#else
if (!ctx->pal_mode)
goto invalid_opc;
else {
TCGv tmp1 = tcg_const_i32(insn & 0xFF);
if (ra != 31)
tcg_gen_helper(helper_mtpr, tmp1, cpu_ir[ra]);
else {
TCGv tmp2 = tcg_const_i64(0);
tcg_gen_helper(helper_mtpr, tmp1, tmp2);
tcg_temp_free(tmp2);
}
tcg_temp_free(tmp1);
ret = 2;
}
break;
#endif
case 0x1E:
#if defined (CONFIG_USER_ONLY)
goto invalid_opc;
#else
if (!ctx->pal_mode)
goto invalid_opc;
if (rb == 31) {
tcg_gen_helper_0_0(helper_hw_rei);
} else {
TCGv tmp;
if (ra != 31) {
tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_addi_i64(tmp, cpu_ir[rb], (((int64_t)insn << 51) >> 51));
} else
tmp = tcg_const_i64(((int64_t)insn << 51) >> 51);
tcg_gen_helper_0_1(helper_hw_ret, tmp);
tcg_temp_free(tmp);
}
ret = 2;
break;
#endif
case 0x1F:
#if defined (CONFIG_USER_ONLY)
goto invalid_opc;
#else
if (!ctx->pal_mode)
goto invalid_opc;
else {
TCGv addr, val;
addr = tcg_temp_new(TCG_TYPE_I64);
if (rb != 31)
tcg_gen_addi_i64(addr, cpu_ir[rb], disp12);
else
tcg_gen_movi_i64(addr, disp12);
if (ra != 31)
val = cpu_ir[ra];
else {
val = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_movi_i64(val, 0);
}
switch ((insn >> 12) & 0xF) {
case 0x0:
tcg_gen_helper_0_2(helper_stl_raw, val, addr);
break;
case 0x1:
tcg_gen_helper_0_2(helper_stq_raw, val, addr);
break;
case 0x2:
tcg_gen_helper_1_2(helper_stl_c_raw, val, val, addr);
break;
case 0x3:
tcg_gen_helper_1_2(helper_stq_c_raw, val, val, addr);
break;
case 0x4:
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_stl_raw, val, addr);
break;
case 0x5:
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_stq_raw, val, addr);
break;
case 0x6:
goto invalid_opc;
case 0x7:
goto invalid_opc;
case 0x8:
goto invalid_opc;
case 0x9:
goto invalid_opc;
case 0xA:
goto invalid_opc;
case 0xB:
goto invalid_opc;
case 0xC:
tcg_gen_helper_0_0(helper_set_alt_mode);
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_stl_raw, val, addr);
tcg_gen_helper_0_0(helper_restore_mode);
break;
case 0xD:
tcg_gen_helper_0_0(helper_set_alt_mode);
tcg_gen_helper_1_1(helper_st_virt_to_phys, addr, addr);
tcg_gen_helper_0_2(helper_stl_raw, val, addr);
tcg_gen_helper_0_0(helper_restore_mode);
break;
case 0xE:
goto invalid_opc;
case 0xF:
goto invalid_opc;
}
if (ra != 31)
tcg_temp_free(val);
tcg_temp_free(addr);
}
ret = 2;
break;
#endif
case 0x20:
gen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0);
break;
case 0x21:
gen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0);
break;
case 0x22:
gen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0);
break;
case 0x23:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0);
break;
case 0x24:
gen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0);
break;
case 0x25:
gen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0);
break;
case 0x26:
gen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0);
break;
case 0x27:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0);
break;
case 0x28:
gen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0);
break;
case 0x29:
gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0);
break;
case 0x2A:
gen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0);
break;
case 0x2B:
gen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0);
break;
case 0x2C:
gen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0);
break;
case 0x2D:
gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0);
break;
case 0x2E:
gen_store_mem(ctx, &gen_qemu_stl_c, ra, rb, disp16, 0, 0);
break;
case 0x2F:
gen_store_mem(ctx, &gen_qemu_stq_c, ra, rb, disp16, 0, 0);
break;
case 0x30:
if (ra != 31)
tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp21 << 2));
ret = 1;
break;
case 0x31:
gen_fbcond(ctx, &helper_cmpfeq, ra, disp16);
ret = 1;
break;
case 0x32:
gen_fbcond(ctx, &helper_cmpflt, ra, disp16);
ret = 1;
break;
case 0x33:
gen_fbcond(ctx, &helper_cmpfle, ra, disp16);
ret = 1;
break;
case 0x34:
if (ra != 31)
tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp21 << 2));
ret = 1;
break;
case 0x35:
gen_fbcond(ctx, &helper_cmpfne, ra, disp16);
ret = 1;
break;
case 0x36:
gen_fbcond(ctx, &helper_cmpfge, ra, disp16);
ret = 1;
break;
case 0x37:
gen_fbcond(ctx, &helper_cmpfgt, ra, disp16);
ret = 1;
break;
case 0x38:
gen_bcond(ctx, TCG_COND_EQ, ra, disp16, 1);
ret = 1;
break;
case 0x39:
gen_bcond(ctx, TCG_COND_EQ, ra, disp16, 0);
ret = 1;
break;
case 0x3A:
gen_bcond(ctx, TCG_COND_LT, ra, disp16, 0);
ret = 1;
break;
case 0x3B:
gen_bcond(ctx, TCG_COND_LE, ra, disp16, 0);
ret = 1;
break;
case 0x3C:
gen_bcond(ctx, TCG_COND_NE, ra, disp16, 1);
ret = 1;
break;
case 0x3D:
gen_bcond(ctx, TCG_COND_NE, ra, disp16, 0);
ret = 1;
break;
case 0x3E:
gen_bcond(ctx, TCG_COND_GE, ra, disp16, 0);
ret = 1;
break;
case 0x3F:
gen_bcond(ctx, TCG_COND_GT, ra, disp16, 0);
ret = 1;
break;
invalid_opc:
gen_invalid(ctx);
ret = 3;
break;
}
return ret;
}
| 1threat |
static void quantize(SnowContext *s, SubBand *b, DWTELEM *src, int stride, int bias){
const int level= b->level;
const int w= b->width;
const int h= b->height;
const int qlog= clip(s->qlog + b->qlog, 0, 128);
const int qmul= qexp[qlog&7]<<(qlog>>3);
int x,y;
assert(QROOT==8);
bias= bias ? 0 : (3*qmul)>>3;
if(!bias){
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int i= src[x + y*stride];
if(i>=0){
i<<= QEXPSHIFT;
i/= qmul;
src[x + y*stride]= i;
}else{
i= -i;
i<<= QEXPSHIFT;
i/= qmul;
src[x + y*stride]= -i;
}
}
}
}else{
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int i= src[x + y*stride];
if(i>=0){
i<<= QEXPSHIFT;
i= (i + bias) / qmul;
src[x + y*stride]= i;
}else{
i= -i;
i<<= QEXPSHIFT;
i= (i + bias) / qmul;
src[x + y*stride]= -i;
}
}
}
}
}
| 1threat |
Force intellij to download scala-library sources in an existing project : <p>It seems that Intellij does well when "Download sources" and "Download javadocs" are checked in the import settings.</p>
<p>But if they were <em>not</em> checked then how do we get the scala sources after the fact? In the screenshot below I did click on <code>Download Sources</code> </p>
<p><a href="https://i.stack.imgur.com/fkodT.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/fkodT.jpg" alt="enter image description here"></a></p>
<p>But it failed <code>Sources for 'scala-library.jar' not found</code> . </p>
<p><a href="https://i.stack.imgur.com/PINcp.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/PINcp.jpg" alt="enter image description here"></a></p>
<p>Seems Intellij should realize to properly ornament the <code>scala-library.jar</code> with the appropriate scala version from the project . no? </p>
<p>So is there any alternative to simply nuking the project and re-importing? The reason for the inquiry is I have a number of projects in this state and also would like the flexibility to <em>not</em> always have <code>Download sources</code> checked - due to both longer build time and occasional build failures caused by it.</p>
| 0debug |
How should this Java code look like in Kotlin? : I started Kotlin after Java.
I want to write this function to return `Single<List<LocationData>>`
```java
override fun getDestinations(): Single<List<LocationData>> {
//return ???
}
```
My LocationData class:
```java
@Parcelize
data class LocationData(val latitude: Double, val longitude: Double) : Parcelable
```
How can I create a List of static LocationData objects in Kotlin?
In java I would do this in the function:
```java
public ArrayList<LocationData> getDestinations(){
ArrayList<LocationData> data = new ArrayList<>();
LocationData location1 = new LocationData( 43.21123, 32.67643 );
LocationData location2 = new LocationData( 32.67643, 43.21123 );
data.add( location1 );
data.add( location2 );
return data;
}
```
**So my question is that how would the above Java code look like in Kotlin?**
Thanks! | 0debug |
Reset store after logout with Apollo client : <p>I'm trying to reset the store after logout in my react-apollo application.</p>
<p>So I've created a method called "logout" which is called when I click on a button (and passed by the 'onDisconnect' props). </p>
<p>To do that I've tried to follow this example :
<a href="https://www.apollographql.com/docs/react/recipes/authentication.html" rel="noreferrer">https://www.apollographql.com/docs/react/recipes/authentication.html</a></p>
<p>But in my case I want LayoutComponent as HOC (and it's without graphQL Query).</p>
<p>Here is my component :</p>
<pre><code>import React, {Component} from 'react';
import { withApollo, graphql } from 'react-apollo';
import { ApolloClient } from 'apollo-client';
import AppBar from 'material-ui/AppBar';
import Sidebar from 'Sidebar/Sidebar';
import RightMenu from 'RightMenu/RightMenu';
class Layout extends Component {
constructor(props) {
super(props);
}
logout = () => {
client.resetStore();
alert("YOUHOU");
}
render() {
return (
<div>
<AppBar title="myApp" iconElementRight={<RightMenu onDisconnect={ this.logout() } />} />
</div>
);
}
}
export default withApollo(Layout);
</code></pre>
<p>The issue here is that 'client' is not defined and I can't logout properly.
Do you have any idea to help me to handle this situation or an example/best practices to logout from apollo client ?</p>
<p>Thanks by advance</p>
| 0debug |
static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
Plane *plane, int code, Cell *ref_cell,
const int depth, const int strip_width)
{
Cell curr_cell;
int bytes_used;
if (depth <= 0) {
av_log(avctx, AV_LOG_ERROR, "Stack overflow (corrupted binary tree)!\n");
return AVERROR_INVALIDDATA;
}
curr_cell = *ref_cell;
if (code == H_SPLIT) {
SPLIT_CELL(ref_cell->height, curr_cell.height);
ref_cell->ypos += curr_cell.height;
ref_cell->height -= curr_cell.height;
} else if (code == V_SPLIT) {
if (curr_cell.width > strip_width) {
curr_cell.width = (curr_cell.width <= (strip_width << 1) ? 1 : 2) * strip_width;
} else
SPLIT_CELL(ref_cell->width, curr_cell.width);
ref_cell->xpos += curr_cell.width;
ref_cell->width -= curr_cell.width;
}
while (get_bits_left(&ctx->gb) >= 2) {
RESYNC_BITSTREAM;
switch (code = get_bits(&ctx->gb, 2)) {
case H_SPLIT:
case V_SPLIT:
if (parse_bintree(ctx, avctx, plane, code, &curr_cell, depth - 1, strip_width))
return AVERROR_INVALIDDATA;
break;
case INTRA_NULL:
if (!curr_cell.tree) {
curr_cell.mv_ptr = 0;
curr_cell.tree = 1;
} else {
RESYNC_BITSTREAM;
code = get_bits(&ctx->gb, 2);
if (code >= 2) {
av_log(avctx, AV_LOG_ERROR, "Invalid VQ_NULL code: %d\n", code);
return AVERROR_INVALIDDATA;
}
if (code == 1)
av_log(avctx, AV_LOG_ERROR, "SkipCell procedure not implemented yet!\n");
CHECK_CELL
if (!curr_cell.mv_ptr)
return AVERROR_INVALIDDATA;
copy_cell(ctx, plane, &curr_cell);
return 0;
}
break;
case INTER_DATA:
if (!curr_cell.tree) {
if (!ctx->need_resync)
ctx->next_cell_data = &ctx->gb.buffer[(get_bits_count(&ctx->gb) + 7) >> 3];
curr_cell.mv_ptr = &ctx->mc_vectors[*(ctx->next_cell_data++) << 1];
curr_cell.tree = 1;
UPDATE_BITPOS(8);
} else {
if (!ctx->need_resync)
ctx->next_cell_data = &ctx->gb.buffer[(get_bits_count(&ctx->gb) + 7) >> 3];
CHECK_CELL
bytes_used = decode_cell(ctx, avctx, plane, &curr_cell,
ctx->next_cell_data, ctx->last_byte);
if (bytes_used < 0)
return AVERROR_INVALIDDATA;
UPDATE_BITPOS(bytes_used << 3);
ctx->next_cell_data += bytes_used;
return 0;
}
break;
}
}
return AVERROR_INVALIDDATA;
}
| 1threat |
Connect Access database in HTML using JavaScript : <p>please any one help me to connect local MS Access 2010 database to HTML using JavaScript. I want to retrieve the records (EmpName & EmpTelephone) by searching with their EmpID.</p>
<p>Please help. Im new to HTML.</p>
<p>Thank you</p>
| 0debug |
static int ape_decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
APEContext *s = avctx->priv_data;
int16_t *samples = data;
int nblocks;
int i, n;
int blockstodecode;
int bytes_used;
if (buf_size == 0 && !s->samples) {
*data_size = 0;
return 0;
}
if (BLOCKS_PER_LOOP * 2 * avctx->channels > *data_size) {
av_log (avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc! (max is %d where you have %d)\n", *data_size, s->samples * 2 * avctx->channels);
return -1;
}
if(!s->samples){
s->data = av_realloc(s->data, (buf_size + 3) & ~3);
s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);
s->ptr = s->last_ptr = s->data;
s->data_end = s->data + buf_size;
nblocks = s->samples = bytestream_get_be32(&s->ptr);
n = bytestream_get_be32(&s->ptr);
if(n < 0 || n > 3){
av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n");
s->data = NULL;
return -1;
}
s->ptr += n;
s->currentframeblocks = nblocks;
buf += 4;
if (s->samples <= 0) {
*data_size = 0;
return buf_size;
}
memset(s->decoded0, 0, sizeof(s->decoded0));
memset(s->decoded1, 0, sizeof(s->decoded1));
init_frame_decoder(s);
}
if (!s->data) {
*data_size = 0;
return buf_size;
}
nblocks = s->samples;
blockstodecode = FFMIN(BLOCKS_PER_LOOP, nblocks);
s->error=0;
if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))
ape_unpack_mono(s, blockstodecode);
else
ape_unpack_stereo(s, blockstodecode);
emms_c();
if(s->error || s->ptr > s->data_end){
s->samples=0;
av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n");
return -1;
}
for (i = 0; i < blockstodecode; i++) {
*samples++ = s->decoded0[i];
if(s->channels == 2)
*samples++ = s->decoded1[i];
}
s->samples -= blockstodecode;
*data_size = blockstodecode * 2 * s->channels;
bytes_used = s->samples ? s->ptr - s->last_ptr : buf_size;
s->last_ptr = s->ptr;
return bytes_used;
}
| 1threat |
HtmlDocument does not contain a constructore that takes 1 arguments : I cant seem to understand why this wont work. I keep getting an error that says HtmlDocument does not contain a constructor that takes 1 arguments any help would be greatly appreciated
//Create the Browser Window
BrowserWindow broWin = new BrowserWindow();
broWin.SearchProperties[UITestControl.PropertyNames.Name] = "Execute Automation";
HtmlDocument doc = new HtmlDocument(broWin); | 0debug |
Golang error "invalid memory address or nil pointer dereference", Why this happens? : <pre><code>package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", handler)
http.HandleFunc("/cookie", cookie)
http.ListenAndServe(":8080", nil)
}
func handler(w http.ResponseWriter, r *http.Request) {
// do ...
}
func cookie(w http.ResponseWriter, r *http.Request) {
cd, _ := r.Cookie("hello")
if cd.Value == "username" {
// do ...
}
}
</code></pre>
<p>if run: </p>
<blockquote>
<p>$ go run main.go</p>
</blockquote>
<p>no problem server is work, but in firfox when inserting "/cookie" path the problem occurs.</p>
<p>Error:</p>
<blockquote>
<p>runtime error: invalid memory address or nil pointer dereference</p>
</blockquote>
| 0debug |
how to select one letter from field[0] and the whole name from field[1] in python? : file = open("songs.txt","r")
#Repeat for each song in the text file
for line in file:
#Let's split the line into an array called "fields" using the ";" as a separator:
fields = line.split(";")
#and let's extract the data:
songTitle = fields[0]
artist = fields[1]
#Print the song
print(songTitle + " by " + artist)
#It is good practice to close the file at the end to free up resources
file.close()
this is the songs.txt file
Gods plan;Drake
Umberella;Rihanna
Perfect;Ed Sheeran
Shape of you;Ed sheeran
Hello; Adele
Thank u next; Ariana Grande
Love Yourself; Justin bieber
Confident;Demi lovato
Sorry not sorry;Demi Lovato
Back to you;Selena gomez
Havana; Camila cabello
I like it; Cardi b
Jumanji; B young
Mariah; Koomz
| 0debug |
Script to reverse a table : I have a spreadsheet for employee schedule (you can see a demo in the link below). As you can see in the "original table" I have 2 rows per day and columns for every shift (Shift A, Shift B ... ).
DEMO TABLE:
[https://docs.google.com/spreadsheets/d/1z8ayTVFA6BSLpV2sEMiTYjBp_Huo0KBeG6sMn6BjBfM/edit?usp=sharing][1]
I need to "reverse" the table extracting every shift for any employee (as you can see in the right side of the demo table "calculated table")
I don't think it's possibile with normal formulas, I tried with "join" formula and some ifs but it's not a working solution in my opinion.
Any idea on how can I write a custom formula in Google App Script? Do you know any workaround with formulas? Can you tell me where can I found some examples?
Notice that, sometimes, employee can have two shift in a single day
Thanks
[1]: https://docs.google.com/spreadsheets/d/1z8ayTVFA6BSLpV2sEMiTYjBp_Huo0KBeG6sMn6BjBfM/edit?usp=sharing | 0debug |
Crash on AutoLayout: Location anchors require being paired : <p>The app is crashing on <code>Location anchors require being paired.</code>. I would like to fix it, however no matter how many times did I manually tested the app with this view, I've never run into the crash (got only logs on Crashlytics). Anyone knows what may be wrong here, under what circumstances the crash may happen?</p>
<p>The property <code>centerYConstraint</code> is required because later it allows the user to move the view up/down. </p>
<p>Part of <code>MyView.m</code> file. The crash happens on setting <code>self.centerYConstraint</code>.</p>
<pre><code>- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.centerYConstraint = [self.view.centerYAnchor constraintEqualToAnchor:self.parentViewController.view.centerYAnchor
constant:self.view.center.y - self.parentViewController.view.center.y];
self.centerYConstraint.active = YES;
}
</code></pre>
<p>Crash log:</p>
<pre><code>Fatal Exception: NSInvalidArgumentException
NSLayoutConstraint for <NSLayoutYAxisAnchor:0x16764ae0 "MyView:0x18e6b900.centerY">:
A constraint cannot be made from <NSLayoutYAxisAnchor:0x16764ae0 "MyView:0x18e6b900.centerY"> to a constant.
Location anchors require being paired.
</code></pre>
| 0debug |
sublime how to trigger snippet on arrow '>>' : I want to create a `sublime snippet` for `ES6 lambda`
but the snippet not trigger on arrow **'>>'**, how to make this work?
[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/3krrM.png | 0debug |
Android Studio Import Failing : Ok guys i am trying to implement spinner in in Android Studio
These are my imports
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;
This is my java. Here I get the the setOnItemSelectedListner in red and says cannot be resolved. I am importing it above despite that it is showing. What could be the issue.
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListner(this);
The whole code is like this....
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView.OnItemSelectedListener;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListner(this);
List<String> categories = new ArrayList<String>();
categories.add("Automobile");
categories.add("Business Services");
categories.add("Computers");
categories.add("Education");
categories.add("Personal");
categories.add("Travel");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(dataAdapter);
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String item = parent.getItemAtPosition(position).toString();
Toast.makeText(parent.getContext(), "Selected: " + item, Toast.LENGTH_LONG).show();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
| 0debug |
Number encryption algorithm : <p>I have a list of numbers. I will be calling a service(let's say accountant service) which is going to perform some operation on these list of numbers and will return me the final result.</p>
<p>I don't want to pass my data in plain format. I want to encrypt numbers in such a way if service performs any arithmetic operation and return me the result, I will be able to decrypt it back with actual result.</p>
| 0debug |
getting error when use sqlcommand : I'm getting an error when I used sqlcommand in the code below, please advise.
try
{
sqlConnection sqlConnection1 = new sqlConnection("Server=.\\SQLEXPRESS;Database=Bazy;Integrated Security=true ");
SqlCommand cmd1 = new SqlCommand("select pass from Users where user1='" + user + "'",sqlConnection1);
SqlDataReader sdr;
sqlConnection1.open();
sdr = cmd1.ExecuteReader();
if (sdr.GetString(0) == tBox_oldPassword.Text)
{
cmd1.CommandText = "update Users set Pass='" + tBox_newPassword.Text + "' where User1='" + tBox_userName.Text + "'";
cmd1.ExecuteNonQuery();
}
else
{
MessageBox.Show("ادخل كلمة السر الحالية.");
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
[enter image description here][1]
[1]: https://i.stack.imgur.com/vO0bc.jpg | 0debug |
Recommended way to locate parent element in Protractor : <p>According to the newly published <a href="https://github.com/angular/protractor/blob/master/docs/style-guide.md#never-use-xpath">Style Guide</a>, <em>using the <code>by.xpath()</code> locators is considered a bad practice</em>. I'm actually trying to follow the suggestion, but stuck on getting a parent element.</p>
<p>Currently we are using <code>..</code> XPath expression to get to the element's parent:</p>
<pre><code>this.dashboard = element(by.linkText("Dashboard")).element(by.xpath(".."));
</code></pre>
<p>How can I locate the element's parent using <em>other</em> built into Protractor/WebDriverJS locators?</p>
| 0debug |
Cant Print a list value in python : im trying to organize my server logs a little that are splited by "|"
and now i want to change the positing of the items when i put them in a list and trying to print it out to save it in a new file it give me
print(result[0])
IndexError: list index out of range
it is the same with every position in the list not only 0
with open("logs-DD-MM-YYYY.txt") as f:
for line in f:
result = line.split('|')
print(result[0])
| 0debug |
Difference between two random statements : <p>I want to know why the numbers appearing in the first column will change each time the code is run. The numbers in the second column will always be the same. (83 51 77 90 96 58 35 38 86 54)?</p>
<pre><code> Random randomGenerator = new Random();
Random otherGenerator = new Random(123);
for(int i = 0; i < 10; i++) {
int number1 = 1 + randomGenerator.nextInt(100);
int number2 = 1 + otherGenerator.nextInt(100);
System.out.println("random numbers "+number1+" " +number2);
}
</code></pre>
| 0debug |
vb.net 2010 logout system : I have an error like this :
<i>Too many arguments to 'Public Function MsgBox(Prompt As Object, [Buttons As Microsoft.VisualBasic.MsgBoxStyle = MsgBoxStyle.OkOnly], [Title As Object = Nothing]) As Microsoft.VisualBasic.MsgBoxResult'.<i>
And MyCode is like this :
` Private Sub LogoutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LogoutToolStripMenuItem.Click
If MsgBox("Are You Sure?", vbYesNo, MsgBoxStyle.Question, "Logout") = MsgBoxResult.Yes Then
Form6.ShowDialog()
Me.Close()
End If
End Sub`
and I don't know why...
Am i missing something?
Anybody can fixed ?
thanks
| 0debug |
JavaFx and file : <p>How can I write to file using javaFx and scene builder for a simple form? </p>
<p>I just want the user data to be saved in the file. Also, I have problems creating the file. Should I create the file in a new java Class, or? </p>
| 0debug |
c# method is not returning object : This is a little bit confusing. I came across some posts that provide example that should return object or value like this
public X DoSomething(int number)
{
//do something
return this;
}
if I understand well. It should return object X after performing some action.
However, it is not the case. On the other hand this code returns object
public IEnumerable<Movie> FindMovie(int _movieId)
{
return this.MoviesLibrary.Where(movie => movie.MovieId == _movieId);
}
I want to return a List that can be filtered in a way like this
var library = new Library <Movie> ();
library.GetAvailable().GetByGenre("Action");
Is it better to create extension methods?
So far my attempts to create a method as part of Library class and chaining them together failed. Method displays casting error. It would seem that example I provided in the beginning is incorrect
public IEnumerable<Movie> GetByYear(int _year)
{
this.MoviesLibrary.Where(movie => movie.MovieId == _movieId);
return this;
}
Thanks | 0debug |
uint64_t qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
int *num)
{
BDRVQcowState *s = bs->opaque;
unsigned int l1_index, l2_index;
uint64_t l2_offset, *l2_table, cluster_offset;
int l1_bits, c;
unsigned int index_in_cluster, nb_clusters;
uint64_t nb_available, nb_needed;
index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1);
nb_needed = *num + index_in_cluster;
l1_bits = s->l2_bits + s->cluster_bits;
nb_available = (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) - 1));
nb_available = (nb_available >> 9) + index_in_cluster;
if (nb_needed > nb_available) {
nb_needed = nb_available;
}
cluster_offset = 0;
l1_index = offset >> l1_bits;
if (l1_index >= s->l1_size)
goto out;
l2_offset = s->l1_table[l1_index];
if (!l2_offset)
goto out;
l2_offset &= ~QCOW_OFLAG_COPIED;
l2_table = l2_load(bs, l2_offset);
if (l2_table == NULL)
return 0;
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[l2_index]);
nb_clusters = size_to_clusters(s, nb_needed << 9);
if (!cluster_offset) {
c = count_contiguous_free_clusters(nb_clusters, &l2_table[l2_index]);
} else {
c = count_contiguous_clusters(nb_clusters, s->cluster_size,
&l2_table[l2_index], 0, QCOW_OFLAG_COPIED);
}
nb_available = (c * s->cluster_sectors);
out:
if (nb_available > nb_needed)
nb_available = nb_needed;
*num = nb_available - index_in_cluster;
return cluster_offset & ~QCOW_OFLAG_COPIED;
}
| 1threat |
Project management and interference : <p>I am managing a software project that is hot for the company in terms of it being one of the things that is their bread & butter and it is going well. I have another manager at the company interfering with my project and people. How does one get this interference to go away. One thought that he is not creative enough to create work, I mean there is a lot he can do in other aspects of the business that would make a huge impact. The other piece of this is tasking a person that for a lack of a better way to describe it doesn't actually produce or actually make anything. How does one handle or manage people that don't produce anything I guess is the question.</p>
<p>Would anyone have resource suggestions such as:
- Books
- Paid Training
- Others</p>
<p>Maybe this is not a topic for this forum. :) If so, suggestions for other forums would be greatly appreciated.</p>
| 0debug |
sorecvfrom(so)
struct socket *so;
{
struct sockaddr_in addr;
int addrlen = sizeof(struct sockaddr_in);
DEBUG_CALL("sorecvfrom");
DEBUG_ARG("so = %lx", (long)so);
if (so->so_type == IPPROTO_ICMP) {
char buff[256];
int len;
len = recvfrom(so->s, buff, 256, 0,
(struct sockaddr *)&addr, &addrlen);
if(len == -1 || len == 0) {
u_char code=ICMP_UNREACH_PORT;
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
errno,strerror(errno)));
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
} else {
icmp_reflect(so->so_m);
so->so_m = 0;
}
udp_detach(so);
} else {
struct mbuf *m;
int len, n;
if (!(m = m_get())) return;
m->m_data += IF_MAXLINKHDR;
len = M_FREEROOM(m);
ioctlsocket(so->s, FIONREAD, &n);
if (n > len) {
n = (m->m_data - m->m_dat) + m->m_len + n + 1;
m_inc(m, n);
len = M_FREEROOM(m);
}
m->m_len = recvfrom(so->s, m->m_data, len, 0,
(struct sockaddr *)&addr, &addrlen);
DEBUG_MISC((dfd, " did recvfrom %d, errno = %d-%s\n",
m->m_len, errno,strerror(errno)));
if(m->m_len<0) {
u_char code=ICMP_UNREACH_PORT;
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
m_free(m);
} else {
if (so->so_expire) {
if (so->so_fport == htons(53))
so->so_expire = curtime + SO_EXPIREFAST;
else
so->so_expire = curtime + SO_EXPIRE;
}
udp_output(so, m, &addr);
}
}
}
| 1threat |
static int proxy_lsetxattr(FsContext *ctx, V9fsPath *fs_path, const char *name,
void *value, size_t size, int flags)
{
int retval;
V9fsString xname, xvalue;
v9fs_string_init(&xname);
v9fs_string_sprintf(&xname, "%s", name);
v9fs_string_init(&xvalue);
xvalue.size = size;
xvalue.data = g_malloc(size);
memcpy(xvalue.data, value, size);
retval = v9fs_request(ctx->private, T_LSETXATTR, value, "sssdd",
fs_path, &xname, &xvalue, size, flags);
v9fs_string_free(&xname);
v9fs_string_free(&xvalue);
if (retval < 0) {
errno = -retval;
}
return retval;
}
| 1threat |
static void *handle_apdu_thread(void* arg)
{
EmulatedState *card = arg;
uint8_t recv_data[APDU_BUF_SIZE];
int recv_len;
VReaderStatus reader_status;
EmulEvent *event;
while (1) {
qemu_mutex_lock(&card->handle_apdu_mutex);
qemu_cond_wait(&card->handle_apdu_cond, &card->handle_apdu_mutex);
qemu_mutex_unlock(&card->handle_apdu_mutex);
if (card->quit_apdu_thread) {
card->quit_apdu_thread = 0;
break;
}
qemu_mutex_lock(&card->vreader_mutex);
while (!QSIMPLEQ_EMPTY(&card->guest_apdu_list)) {
event = QSIMPLEQ_FIRST(&card->guest_apdu_list);
assert((unsigned long)event > 1000);
QSIMPLEQ_REMOVE_HEAD(&card->guest_apdu_list, entry);
if (event->p.data.type != EMUL_GUEST_APDU) {
DPRINTF(card, 1, "unexpected message in handle_apdu_thread\n");
g_free(event);
continue;
}
if (card->reader == NULL) {
DPRINTF(card, 1, "reader is NULL\n");
g_free(event);
continue;
}
recv_len = sizeof(recv_data);
reader_status = vreader_xfr_bytes(card->reader,
event->p.data.data, event->p.data.len,
recv_data, &recv_len);
DPRINTF(card, 2, "got back apdu of length %d\n", recv_len);
if (reader_status == VREADER_OK) {
emulated_push_response_apdu(card, recv_data, recv_len);
} else {
emulated_push_error(card, reader_status);
}
g_free(event);
}
qemu_mutex_unlock(&card->vreader_mutex);
}
qemu_mutex_lock(&card->apdu_thread_quit_mutex);
qemu_cond_signal(&card->apdu_thread_quit_cond);
qemu_mutex_unlock(&card->apdu_thread_quit_mutex);
return NULL;
}
| 1threat |
Laravel in_array validation rule : <p>I have defined an array</p>
<pre><code>$this->allslots=array('10:00:00', '10:10:00', '10:20:00', '10:30:00', '10:40:00', '10:50:00', '11:00:00', '11:10:00', '11:20:00', '11:30:00', '11:40:00', '11:50:00', '12:00:00', '12:10:00', '12:20:00', '12:30:00', '12:40:00', '12:50:00', '13:00:00', '13:10:00', '13:20:00', '13:30:00', '13:40:00', '13:50:00', '14:00:00', '14:10:00', '14:20:00', '14:30:00', '14:40:00', '14:50:00', '15:00:00', '15:10:00', '15:20:00', '15:30:00', '15:40:00', '15:50:00', '16:00:00', '16:10:00', '16:20:00', '16:30:00', '16:40:00', '16:50:00');
</code></pre>
<p>Now, I want to validate before saving data to database that, if a given input matches one of the value of the above array. For this I'm doing</p>
<pre><code>$this->validate($request, [
'field' => 'required|in_array:$this->allslots',
]);
</code></pre>
<p>But, this returns validation error for every input. So, how can I do this?</p>
| 0debug |
Is it possible to build a full Node.js web application using Kotlin? : <p>If I understand correctly, with <a href="https://blog.jetbrains.com/kotlin/2017/01/kotlin-1-1-beta-is-here/" rel="noreferrer">the release of Kotlin 1.1</a>, we can <a href="https://kotlinlang.org/docs/reference/js-overview.html" rel="noreferrer">set JavaScript as a compile target</a> for full compilation to JavaScript of Kotlin projects. Is it possible (or feasible) to write an entire Node.js application, such as an express webserver, using only Kotlin code?</p>
<p>As <a href="https://stackoverflow.com/q/44642521/5209322">this question</a> suggests, we can import Node modules into Kotlin classes:</p>
<pre class="lang-kotlin prettyprint-override"><code>external fun require(module: String): dynamic
val express = require('express')
</code></pre>
<p>...which seems like I can create an application using: </p>
<pre><code>val app = express()
</code></pre>
<p>Is this the <em>Kotlin way</em> to set up an express application? Or should I declare a class as <a href="https://kotlinlang.org/docs/reference/js-modules.html" rel="noreferrer">described in the docs</a>: </p>
<pre><code>@JsModule("express")
external class Express { ... }
</code></pre>
<p>What is the canonical way to set up a Kotlin project for Node.js application development? Is Kotlin's JavaScript interoperability robust enough to continue down this path, or will it be more trouble than it's worth?</p>
| 0debug |
void qmp_migrate_set_downtime(double value, Error **errp)
{
value *= 1e9;
value = MAX(0, MIN(UINT64_MAX, value));
max_downtime = (uint64_t)value;
}
| 1threat |
static void pxa2xx_ssp_write(void *opaque, hwaddr addr,
uint64_t value64, unsigned size)
{
PXA2xxSSPState *s = (PXA2xxSSPState *) opaque;
uint32_t value = value64;
switch (addr) {
case SSCR0:
s->sscr[0] = value & 0xc7ffffff;
s->enable = value & SSCR0_SSE;
if (value & SSCR0_MOD)
printf("%s: Attempt to use network mode\n", __FUNCTION__);
if (s->enable && SSCR0_DSS(value) < 4)
printf("%s: Wrong data size: %i bits\n", __FUNCTION__,
SSCR0_DSS(value));
if (!(value & SSCR0_SSE)) {
s->sssr = 0;
s->ssitr = 0;
s->rx_level = 0;
}
pxa2xx_ssp_fifo_update(s);
break;
case SSCR1:
s->sscr[1] = value;
if (value & (SSCR1_LBM | SSCR1_EFWR))
printf("%s: Attempt to use SSP test mode\n", __FUNCTION__);
pxa2xx_ssp_fifo_update(s);
break;
case SSPSP:
s->sspsp = value;
break;
case SSTO:
s->ssto = value;
break;
case SSITR:
s->ssitr = value & SSITR_INT;
pxa2xx_ssp_int_update(s);
break;
case SSSR:
s->sssr &= ~(value & SSSR_RW);
pxa2xx_ssp_int_update(s);
break;
case SSDR:
if (SSCR0_UWIRE(s->sscr[0])) {
if (s->sscr[1] & SSCR1_MWDS)
value &= 0xffff;
else
value &= 0xff;
} else
value &= (1 << SSCR0_DSS(s->sscr[0])) - 1;
if (s->enable) {
uint32_t readval;
readval = ssi_transfer(s->bus, value);
if (s->rx_level < 0x10) {
s->rx_fifo[(s->rx_start + s->rx_level ++) & 0xf] = readval;
} else {
s->sssr |= SSSR_ROR;
}
}
pxa2xx_ssp_fifo_update(s);
break;
case SSTSA:
s->sstsa = value;
break;
case SSRSA:
s->ssrsa = value;
break;
case SSACD:
s->ssacd = value;
break;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
}
| 1threat |
Merge colums/rows? : I have
> 100 105
> 105 120
> 120 130
I need to make them as
>100 130
That is, merge overlapping rows. Sorry if I'm sounding vague, however I don't know how to describe this situation.
Looking for a Shell script because then I can quickly process the 20 files that I need to work with. | 0debug |
Convert a map of maps into single list of values in java 8 : <p>I have a Map of map :</p>
<pre><code>Map<Integer,Map<String,Integer>>
</code></pre>
<p>I need this map to be flattened into just the list of values :</p>
<pre><code>Map<String,Integer> map1 = new HashMap<>();
Map<String,Integer> map2 = new HashMap<>();
map1.putIfAbsent("ABC",123);
map1.putIfAbsent("PQR",345);
map1.putIfAbsent("XYZ",567);
map2.putIfAbsent("ABC",234);
map2.putIfAbsent("FGH",789);
map2.putIfAbsent("BNM",890);
Map<Integer,Map<String,Integer>> mapMap = new HashMap();
mapMap.putIfAbsent(0,map1);
mapMap.putIfAbsent(1,map2);
</code></pre>
<p>Expected output :
123</p>
<p>345</p>
<p>567</p>
<p>234</p>
<p>789</p>
<p>890</p>
<p>I need different solution including java 8 streams!!</p>
<p>Thanks</p>
| 0debug |
static void tcg_out_ri(TCGContext *s, int const_arg, TCGArg arg)
{
if (const_arg) {
assert(const_arg == 1);
tcg_out8(s, TCG_CONST);
tcg_out_i(s, arg);
} else {
tcg_out_r(s, arg);
}
}
| 1threat |
Find max number in array : <p>I am doing this JAVA homework for school and I have this task, but I can't find a beginner explanation on the web. </p>
<p>So I have to print out the biggest number in this array, please help...</p>
<pre><code>int[] mas = {12, 2135, -354, 4353, -1312, 4636, 1312, 3, 51};
</code></pre>
| 0debug |
How to convert Pytorch autograd.Variable to Numpy? : <p>The title says it all. I want to convert a <code>PyTorch autograd.Variable</code> to its equivalent <code>numpy</code> array. In their <a href="http://pytorch.org/tutorials/beginner/former_torchies/tensor_tutorial.html" rel="noreferrer">official documentation</a> they advocated using <code>a.numpy()</code> to get the equivalent <code>numpy</code> array (for <code>PyTorch tensor</code>). But this gives me the following error:</p>
<blockquote>
<p>Traceback (most recent call last): File "stdin", line 1, in module
File
"/home/bishwajit/anaconda3/lib/python3.6/site-packages/torch/autograd/variable.py",
line 63, in <strong>getattr</strong> raise AttributeError(name) AttributeError:
numpy</p>
</blockquote>
<p>Is there any way I can circumvent this?</p>
| 0debug |
CountDownTimer in my class service stop when i destroy my class activity : <p>i have countdowntimer in my service class and when i destroy my activity class then it stop my countdown timer in my service class but it didnt destroy my service class.
Can someone help me why my countdown timer stop?
I need call another activity when my countdown is finish.</p>
| 0debug |
Use Fragments in Koltin : How does one use fragments instead of layouts to give them its on koltin file. Using the navigation drawer template in andriod studio.
override fun onNavigationItemSelected(item: MenuItem): Boolean {
// Handle navigation view item clicks here.
when (item.itemId) {
R.id.nav_home -> {
// Handle the camera action
}
R.id.nav_gallery -> {
}
R.id.nav_slideshow -> {
}
R.id.nav_tools -> {
}
R.id.nav_share -> {
}
R.id.nav_send -> {
}
}
val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
drawerLayout.closeDrawer(GravityCompat.START)
return true
}
Does this constructor automatically switch the view based on their name ie nav_gallery I am new to koltin and java so please excuse my ignorance. | 0debug |
def count(s,c) :
res = 0
for i in range(len(s)) :
if (s[i] == c):
res = res + 1
return res | 0debug |
void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp)
{
if (!error_is_set(errp)) {
v->type_str(v, obj, name, errp);
}
}
| 1threat |
I can't insert data into the table due to an sql error : ***This is the error I get when I insert the data:***
INSERT INTO "44581114"."TEACHING_INFORMATION" (STAFFID, COURSEID, SEMESTER, YEAR) VALUES ('11223344', 'ISYS224', 'S3', '2014')
ORA-02291: integrity constraint (44581114.FK_TEACHING_RELATIONS_COURSE) violated - parent key not found
ORA-06512: at line 1
One error saving changes to table "44581114"."TEACHING_INFORMATION":
Row 1: ORA-02291: integrity constraint (44581114.FK_TEACHING_RELATIONS_COURSE) violated - parent key not found
ORA-06512: at line 1
***If it helps i have attached the DDL script here:***
/*==============================================================*/
/* DBMS name: ORACLE Version 11g */
/* Created on: 11/10/2016 3:47:29 PM */
/*==============================================================*/
alter table ACADEMIC_REC
drop constraint FK_ACADEMIC_RELATIONS_STUDENT;
alter table ACADEMIC_REC
drop constraint FK_ACADEMIC_RELATIONS_COURSE;
alter table COURSE
drop constraint FK_COURSE_OFFERS_DEPARTME;
alter table ENROLS
drop constraint FK_ENROLS_ENROLS_STUDENT;
alter table ENROLS
drop constraint FK_ENROLS_ENROLS2_TUT_PRAC;
alter table HAS_PREREQUISITE
drop constraint FK_HAS_PRER_HAS_PRERE_COURSE;
alter table HAS_PREREQUISITE
drop constraint FK_HAS_PRER_HAS_PRERE_COURSE;
alter table STAFF
drop constraint FK_STAFF_RELATIONS_DEPARTME;
alter table TEACHING_INFORMATION
drop constraint FK_TEACHING_RELATIONS_STAFF;
alter table TEACHING_INFORMATION
drop constraint FK_TEACHING_RELATIONS_COURSE;
alter table TUT_PRAC
drop constraint FK_TUT_PRAC_HAS_COURSE;
alter table TUT_PRAC
drop constraint FK_TUT_PRAC_RELATIONS_STAFF;
drop table ACADEMIC_REC cascade constraints;
drop table COURSE cascade constraints;
drop table ENROLS cascade constraints;
drop table HAS_PREREQUISITE cascade constraints;
drop table STAFF cascade constraints;
drop table STUDENT cascade constraints;
drop table TEACHING_INFORMATION cascade constraints;
drop table TUT_PRAC cascade constraints;
/*==============================================================*/
/* Table: ACADEMIC_REC */
/*==============================================================*/
create table ACADEMIC_REC
(
STUID CHAR(8) not null,
COURSEID CHAR(8) not null,
STATUS VARCHAR2(5),
YEAR NUMBER(4),
SEMESTER CHAR(2),
GRADE VARCHAR2(2)
constraint CKC_GRADE_ACADEMIC check (GRADE is null or (GRADE in ('HD','D','CR','P','F'))),
constraint PK_ACADEMIC_REC primary key (STUID, COURSEID)
);
/*==============================================================*/
/* Table: COURSE */
/*==============================================================*/
create table COURSE
(
COURSEID CHAR(8) not null,
DEPTID CHAR(8) not null,
COURSENAME VARCHAR2(20),
TEXTBOOK VARCHAR2(20),
CREDITHOUR NUMBER(2),
MAX_ENROL NUMBER(4),
ACTUAL_ENROL NUMBER(4),
AVAILABILITY NUMBER(4),
COURSE_TIME CHAR(7),
constraint PK_COURSE primary key (COURSEID)
);
/*==============================================================*/
/* Table: DEPARTMENT */
/*==============================================================*/
create table DEPARTMENT
(
DEPTID CHAR(8) not null,
DEPTNAME VARCHAR2(20),
DEPTCONTACTNO NUMBER(10),
BUILDING VARCHAR2(5),
constraint PK_DEPARTMENT primary key (DEPTID)
);
/*==============================================================*/
/* Table: ENROLS */
/*==============================================================*/
create table ENROLS
(
STUID CHAR(8) not null,
CLASSID CHAR(8) not null,
constraint PK_ENROLS primary key (STUID, CLASSID)
);
/*==============================================================*/
/* Table: HAS_PREREQUISITE */
/*==============================================================*/
create table HAS_PREREQUISITE
(
COURSEID CHAR(8) not null,
PREREQUISITEID CHAR(8) not null,
constraint PK_HAS_PREREQUISITE primary key (COURSEID, PREREQUISITEID)
);
/*==============================================================*/
/* Table: STAFF */
/*==============================================================*/
create table STAFF
(
STAFFID CHAR(8) not null,
DEPARTMENTID CHAR(8) not null,
STAFFNAME VARCHAR2(50),
STAFFADDRESS VARCHAR2(70),
STAFFCONTACTNO NUMBER(10),
STAFFEMAIL VARCHAR2(50),
OFFICENO NUMBER(5),
ROLE VARCHAR2(10),
constraint PK_STAFF primary key (STAFFID)
);
/*==============================================================*/
/* Table: STUDENT */
/*==============================================================*/
create table STUDENT
(
STUID CHAR(8) not null,
DEGREE VARCHAR2(10),
MAJOR VARCHAR2(10),
STU_NAME VARCHAR2(50),
STU_ADDRESS VARCHAR2(70),
CONTACTNO NUMBER(10),
EMAIL VARCHAR2(50),
constraint PK_STUDENT primary key (STUID)
);
/*==============================================================*/
/* Table: TEACHING_INFORMATION */
/*==============================================================*/
create table TEACHING_INFORMATION
(
STAFFID CHAR(8) not null,
COURSEID CHAR(8) not null,
SEMESTER CHAR(2) not null,
YEAR NUMBER(4) not null,
constraint PK_TEACHING_INFORMATION primary key (STAFFID, COURSEID, SEMESTER, YEAR)
);
/*==============================================================*/
/* Table: TUT_PRAC */
/*==============================================================*/
create table TUT_PRAC
(
CLASSID CHAR(8) not null,
COURSEID CHAR(8) not null,
STAFFID CHAR(8) not null,
TYPE VARCHAR2(5),
DAY VARCHAR2(10),
TIME DATE,
ROOMID CHAR(10),
NO_OF_SEATS NUMBER(2),
constraint PK_TUT_PRAC primary key (CLASSID)
);
alter table ACADEMIC_REC
add constraint FK_ACADEMIC_RELATIONS_STUDENT foreign key (STUID)
references STUDENT (STUID);
alter table ACADEMIC_REC
add constraint FK_ACADEMIC_RELATIONS_COURSE foreign key (COURSEID)
references COURSE (COURSEID);
alter table COURSE
add constraint FK_COURSE_OFFERS_DEPARTME foreign key (DEPTID)
references DEPARTMENT (DEPTID);
alter table ENROLS
add constraint FK_ENROLS_ENROLS_STUDENT foreign key (STUID)
references STUDENT (STUID);
alter table ENROLS
add constraint FK_ENROLS_ENROLS2_TUT_PRAC foreign key (CLASSID)
references TUT_PRAC (CLASSID);
alter table HAS_PREREQUISITE
add constraint FK_HAS_PRER_HAS_PRERE_COURSE foreign key (COURSEID)
references COURSE (COURSEID);
alter table HAS_PREREQUISITE
add constraint FK_HAS_PRER_HAS_PRERE_COURSE foreign key (PREREQUISITEID)
references COURSE (COURSEID);
alter table STAFF
add constraint FK_STAFF_RELATIONS_DEPARTME foreign key (DEPARTMENTID)
references DEPARTMENT (DEPTID);
alter table TEACHING_INFORMATION
add constraint FK_TEACHING_RELATIONS_STAFF foreign key (STAFFID)
references STAFF (STAFFID);
alter table TEACHING_INFORMATION
add constraint FK_TEACHING_RELATIONS_COURSE foreign key (COURSEID)
references COURSE (COURSEID);
alter table TUT_PRAC
add constraint FK_TUT_PRAC_HAS_COURSE foreign key (COURSEID)
references COURSE (COURSEID);
alter table TUT_PRAC
add constraint FK_TUT_PRAC_RELATIONS_STAFF foreign key (STAFFID)
references STAFF (STAFFID);
***I'm doing this in sql developer and fairly new at using it hope that helps in figuring the solution***
***Also in teaching information table the staffid and courseid are taken from their parent tables and (semester) and (year) are the attributes of the associative entity between staff & course with many to many cardinalities***
course- *teaching information*-staff
| 0debug |
int ff_h264_decode_extradata(H264Context *h)
{
AVCodecContext *avctx = h->s.avctx;
if (avctx->extradata[0] == 1) {
int i, cnt, nalsize;
unsigned char *p = avctx->extradata;
h->is_avc = 1;
if (avctx->extradata_size < 7) {
av_log(avctx, AV_LOG_ERROR, "avcC too short\n");
return -1;
}
h->nal_length_size = 2;
cnt = *(p + 5) & 0x1f;
p += 6;
for (i = 0; i < cnt; i++) {
nalsize = AV_RB16(p) + 2;
if (p - avctx->extradata + nalsize > avctx->extradata_size)
return -1;
if (decode_nal_units(h, p, nalsize) < 0) {
av_log(avctx, AV_LOG_ERROR,
"Decoding sps %d from avcC failed\n", i);
return -1;
}
p += nalsize;
}
cnt = *(p++);
for (i = 0; i < cnt; i++) {
nalsize = AV_RB16(p) + 2;
if (p - avctx->extradata + nalsize > avctx->extradata_size)
return -1;
if (decode_nal_units(h, p, nalsize) < 0) {
av_log(avctx, AV_LOG_ERROR,
"Decoding pps %d from avcC failed\n", i);
return -1;
}
p += nalsize;
}
h->nal_length_size = (avctx->extradata[4] & 0x03) + 1;
} else {
h->is_avc = 0;
if (decode_nal_units(h, avctx->extradata, avctx->extradata_size) < 0)
return -1;
}
return 0;
}
| 1threat |
av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
int fullRange, int brightness,
int contrast, int saturation)
{
const int isRgb = c->dstFormat == AV_PIX_FMT_RGB32 ||
c->dstFormat == AV_PIX_FMT_RGB32_1 ||
c->dstFormat == AV_PIX_FMT_BGR24 ||
c->dstFormat == AV_PIX_FMT_RGB565BE ||
c->dstFormat == AV_PIX_FMT_RGB565LE ||
c->dstFormat == AV_PIX_FMT_RGB555BE ||
c->dstFormat == AV_PIX_FMT_RGB555LE ||
c->dstFormat == AV_PIX_FMT_RGB444BE ||
c->dstFormat == AV_PIX_FMT_RGB444LE ||
c->dstFormat == AV_PIX_FMT_RGB8 ||
c->dstFormat == AV_PIX_FMT_RGB4 ||
c->dstFormat == AV_PIX_FMT_RGB4_BYTE ||
c->dstFormat == AV_PIX_FMT_MONOBLACK;
const int isNotNe = c->dstFormat == AV_PIX_FMT_NE(RGB565LE, RGB565BE) ||
c->dstFormat == AV_PIX_FMT_NE(RGB555LE, RGB555BE) ||
c->dstFormat == AV_PIX_FMT_NE(RGB444LE, RGB444BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR565LE, BGR565BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR555LE, BGR555BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR444LE, BGR444BE);
const int bpp = c->dstFormatBpp;
uint8_t *y_table;
uint16_t *y_table16;
uint32_t *y_table32;
int i, base, rbase, gbase, bbase, av_uninit(abase), needAlpha;
const int yoffs = fullRange ? 384 : 326;
int64_t crv = inv_table[0];
int64_t cbu = inv_table[1];
int64_t cgu = -inv_table[2];
int64_t cgv = -inv_table[3];
int64_t cy = 1 << 16;
int64_t oy = 0;
int64_t yb = 0;
if (!fullRange) {
cy = (cy * 255) / 219;
oy = 16 << 16;
} else {
crv = (crv * 224) / 255;
cbu = (cbu * 224) / 255;
cgu = (cgu * 224) / 255;
cgv = (cgv * 224) / 255;
}
cy = (cy * contrast) >> 16;
crv = (crv * contrast * saturation) >> 32;
cbu = (cbu * contrast * saturation) >> 32;
cgu = (cgu * contrast * saturation) >> 32;
cgv = (cgv * contrast * saturation) >> 32;
oy -= 256 * brightness;
c->uOffset = 0x0400040004000400LL;
c->vOffset = 0x0400040004000400LL;
c->yCoeff = roundToInt16(cy * 8192) * 0x0001000100010001ULL;
c->vrCoeff = roundToInt16(crv * 8192) * 0x0001000100010001ULL;
c->ubCoeff = roundToInt16(cbu * 8192) * 0x0001000100010001ULL;
c->vgCoeff = roundToInt16(cgv * 8192) * 0x0001000100010001ULL;
c->ugCoeff = roundToInt16(cgu * 8192) * 0x0001000100010001ULL;
c->yOffset = roundToInt16(oy * 8) * 0x0001000100010001ULL;
c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy << 13);
c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);
c->yuv2rgb_v2r_coeff = (int16_t)roundToInt16(crv << 13);
c->yuv2rgb_v2g_coeff = (int16_t)roundToInt16(cgv << 13);
c->yuv2rgb_u2g_coeff = (int16_t)roundToInt16(cgu << 13);
c->yuv2rgb_u2b_coeff = (int16_t)roundToInt16(cbu << 13);
crv = ((crv << 16) + 0x8000) / cy;
cbu = ((cbu << 16) + 0x8000) / cy;
cgu = ((cgu << 16) + 0x8000) / cy;
cgv = ((cgv << 16) + 0x8000) / cy;
av_freep(&c->yuvTable);
switch (bpp) {
case 1:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024 - 110; i++) {
y_table[i + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
yb += cy;
}
fill_table(c->table_gU, 1, cgu, y_table + yoffs);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 4:
case 4 | 128:
rbase = isRgb ? 3 : 0;
gbase = 1;
bbase = isRgb ? 0 : 3;
c->yuvTable = av_malloc(1024 * 3);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024 - 110; i++) {
int yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table[i + 110] = (yval >> 7) << rbase;
y_table[i + 37 + 1024] = ((yval + 43) / 85) << gbase;
y_table[i + 110 + 2048] = (yval >> 7) << bbase;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 8:
rbase = isRgb ? 5 : 0;
gbase = isRgb ? 2 : 3;
bbase = isRgb ? 0 : 6;
c->yuvTable = av_malloc(1024 * 3);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024 - 38; i++) {
int yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table[i + 16] = ((yval + 18) / 36) << rbase;
y_table[i + 16 + 1024] = ((yval + 18) / 36) << gbase;
y_table[i + 37 + 2048] = ((yval + 43) / 85) << bbase;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 12:
rbase = isRgb ? 8 : 0;
gbase = 4;
bbase = isRgb ? 0 : 8;
c->yuvTable = av_malloc(1024 * 3 * 2);
y_table16 = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024; i++) {
uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[i] = (yval >> 4) << rbase;
y_table16[i + 1024] = (yval >> 4) << gbase;
y_table16[i + 2048] = (yval >> 4) << bbase;
yb += cy;
}
if (isNotNe)
for (i = 0; i < 1024 * 3; i++)
y_table16[i] = av_bswap16(y_table16[i]);
fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 15:
case 16:
rbase = isRgb ? bpp - 5 : 0;
gbase = 5;
bbase = isRgb ? 0 : (bpp - 5);
c->yuvTable = av_malloc(1024 * 3 * 2);
y_table16 = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024; i++) {
uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[i] = (yval >> 3) << rbase;
y_table16[i + 1024] = (yval >> (18 - bpp)) << gbase;
y_table16[i + 2048] = (yval >> 3) << bbase;
yb += cy;
}
if (isNotNe)
for (i = 0; i < 1024 * 3; i++)
y_table16[i] = av_bswap16(y_table16[i]);
fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 24:
case 48:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024; i++) {
y_table[i] = av_clip_uint8((yb + 0x8000) >> 16);
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs);
fill_table(c->table_bU, 1, cbu, y_table + yoffs);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 32:
case 64:
base = (c->dstFormat == AV_PIX_FMT_RGB32_1 ||
c->dstFormat == AV_PIX_FMT_BGR32_1) ? 8 : 0;
rbase = base + (isRgb ? 16 : 0);
gbase = base + 8;
bbase = base + (isRgb ? 0 : 16);
needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
if (!needAlpha)
abase = (base + 24) & 31;
c->yuvTable = av_malloc(1024 * 3 * 4);
y_table32 = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024; i++) {
unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table32[i] = (yval << rbase) +
(needAlpha ? 0 : (255u << abase));
y_table32[i + 1024] = yval << gbase;
y_table32[i + 2048] = yval << bbase;
yb += cy;
}
fill_table(c->table_rV, 4, crv, y_table32 + yoffs);
fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + 1024);
fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2048);
fill_gv_table(c->table_gV, 4, cgv);
break;
default:
if(!isPlanar(c->dstFormat) || bpp <= 24)
av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);
return -1;
}
return 0;
}
| 1threat |
INSERT QUERY ERROR--> Recoverable fatal error: Object of class mysqli could not be converted to string in : i have been 3 hours stuck in this code, after the submit button was clicked, the record was not stored. All syntax i have look through, all look fine. Where is the thing againsting it to insert? Help please... cuz most of the guidance i look through almost is because select statement, but now i'm insert statement and same issue occur. here's my code:
<table border='1'>
<tr>
<th colspan="2">
<h1>Property For Rent</h1>
</th>
<form method="post">
<tr><td>Property NO:</td><td><input type="textbox" name="pid"></td></tr>
<tr><td>Street:</td><td><input type="textbox" name="street"></td></tr>
<tr><td>City:</td><td><input type="textbox" name="city"></td></tr>
<tr><td>Post Code:</td><td><input type="textbox" name="postcode"></td></tr>
<tr><td>Type:</td><td><input type="textbox" name="type"></td></tr>
<tr><td>Rooms:</td><td><input type="textbox" name="rooms"></td></tr>
<tr><td>Rent:</td><td><input type="textbox" name="rent"></td></tr>
<tr><td>Owner No:</td><td><select name="ownerno">
<?php
$conon=mysqli_connect('localhost','root','','dreamhome');
$SQLon="select distinct ownerNo from propertyforrent";
$queryresulton = mysqli_query($conon,$SQLon);
while($resulton=mysqli_fetch_array($queryresulton))
{
echo '<option value=" '.$resulton['ownerNo'].' ">'.$resulton['ownerNo'].'</option>';
}
?>
</td></tr>
<tr><td>Staff No:</td><td><select name="staffno">
<?php
$consn=mysqli_connect('localhost','root','','dreamhome');
$SQLsn="select distinct staffNo from propertyforrent";
$queryresultsn = mysqli_query($consn,$SQLsn);
while($resultsn=mysqli_fetch_array($queryresultsn))
{
echo '<option value=" '.$resultsn['staffNo'].' ">'.$resultsn['staffNo'].'</option>';
}
?>
</td></tr>
<tr><td>Branch No:</td><td><select name="branchno">
<?php
$conbn=mysqli_connect('localhost','root','','dreamhome');
$SQLbn="select distinct branchNo from propertyforrent";
$queryresultbn = mysqli_query($conbn,$SQLbn);
while($resultbn=mysqli_fetch_array($queryresultbn))
{
echo '<option value=" '.$resultbn['branchNo'].' ">'.$resultbn['branchNo'].'</option>';
}
?>
</td></tr>
<td><input type="Submit" name="submit">
</td>
</form>
</table>
<?php
if(isset($_POST['submit']))
{
if((!empty($_POST['pid']))&&(!empty($_POST['street']))&&(!empty($_POST['city']))
&&(!empty($_POST['postcode']))&&(!empty($_POST['type']))&&(!empty($_POST['rooms']))&&(!empty($_POST['rent']))
&&(!empty($_POST['ownerno']))&&(!empty($_POST['staffno']))&&(!empty($_POST['branchno'])))
{
$conad=mysqli_connect('localhost','root','','dreamhome');
if(!$conad)
{
echo 'Note connected to server';
}
if(!mysqli_select_db($conad,'dreamhome'))
{
echo 'Database Not Selected';
}
$pid=mysqli_real_escape_string($conad,$_POST['pid']);
$street=mysqli_real_escape_string($conad,$_POST['street']);
$city=mysqli_real_escape_string($conad,$_POST['city']);
$postcode=mysqli_real_escape_string($conad,$_POST['postcode']);
$type=mysqli_real_escape_string($conad,$_POST['type']);
$rooms=mysqli_real_escape_string($conad,$_POST['rooms']);
$rent=mysqli_real_escape_string($conad,$_POST['rent']);
$ownerno=mysqli_real_escape_string($conad,$_POST['ownerno']);
$staffno=mysqli_real_escape_string($conad,$_POST['staffno']);
$branchno=mysqli_real_escape_string($conad,$_POST['branchno']);
$SQLad= "INSERT INTO propertyforrent (propertyNo,street,city,postcode,type,rooms,rent,ownerNo,staffNo,branchNo)
VALUES ('$pid','$street','$city','$postcode','$type','$rooms','$rent','$ownerno','$staffno','$branchno')";
$resultad=mysqli_query($conad,$SQLad);
if(!$resultad)
{
echo "record not save!,mysqli_error($SQLad)";
}
else
{
echo "record save!";
}
}
else
{
echo "<h1>Please fill up all field!</h1>";
}
}
?>
The error prompted out from mysqli_error is
> Recoverable fatal error: Object of class mysqli could not be converted
> to string in | 0debug |
uint64_t helper_fsqrt(CPUPPCState *env, uint64_t arg)
{
CPU_DoubleU farg;
farg.ll = arg;
if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {
farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT);
} else {
if (unlikely(float64_is_signaling_nan(farg.d))) {
fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN);
}
farg.d = float64_sqrt(farg.d, &env->fp_status);
}
return farg.ll;
}
| 1threat |
When to dispose RxJava2 Disposable in ViewModel? : <p>I'm using <a href="https://developer.android.com/topic/libraries/architecture/viewmodel.html" rel="noreferrer">ViewModel</a> from Android Architecture Components in my app. In the ViewModel, I'm using <a href="https://github.com/ReactiveX/RxJava" rel="noreferrer">RxJava2</a> subscription and I keep <code>Disposable</code> object after I subscribe. Before, when I did this in <code>Activity</code>, I was used to dispose the <code>Disposable</code> in <code>onDestroy()</code> - to avoid memory leaks:</p>
<pre><code>@Override
protected void onDestroy() {
disposable.dispose();
super.onDestroy();
}
</code></pre>
<p>When and how should I dispose it in <code>ViewModel</code>? Do I actually need to do that?</p>
| 0debug |
VS Code: Analyzing in the background : <p>When I start a python project in vs code (with the microsoft python extension) it starts "Analyzing in the background" and python keep crashing. It also uses a ton of memory.<a href="https://i.stack.imgur.com/b1YP6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/b1YP6.png" alt="enter image description here"></a></p>
<p>Anyone knows how to fix this? Or is it supposed to do this?</p>
| 0debug |
Can we import .txt file to python? : <p>I am a newbie in python. I have a problem, how do we import a .txt file to python?
I have a .txt file with so many texts inside it for me to analyze with the NLTK.
Can you tell me how to start to analyze the texts?
Thank you in advance</p>
| 0debug |
Functions declared within loops referencing an outer scoped variable may lead to confusing semantics. What is wrong? : <p>Can someone tell me what is wrong with my code, especially the "Full screen event" part. Thanks!</p>
<p>JSLint says "Functions declared within loops referencing an outer scoped variable may lead to confusing semantics."</p>
<pre><code>function initialize() {
var mapProp = {
center: new google.maps.LatLng(45.502808, -73.571486),
};
var map = [];
map[0] = new google.maps.Map(document.getElementById("map1"), mapProp);
map[1] = new google.maps.Map(document.getElementById("map2"), mapProp);
map[2] = new google.maps.Map(document.getElementById("map3"), mapProp);
new google.maps.Marker({
position: new google.maps.LatLng(45.502808, -73.571486),
map: map[0], title: 'Sunnyvale '
});
new google.maps.Marker({
position: new google.maps.LatLng(45.502808, -73.571486),
map: map[1], title: 'Sunnyvale '
});
new google.maps.Marker({
position: new google.maps.LatLng(45.502808, -73.571486),
map: map[2], title: 'Sunnyvale '
});
google.maps.event.addDomListener(window, "resize", function () {
for (i = 0; i < 3; i++) {
var center = map[i].getCenter();
/*var bounds = map[i].getBounds();*/
var zoom = map[i].getZoom();
google.maps.event.trigger(map[i], "resize");
/*map[i].fitBounds(bounds);*/
map[i].setCenter(center);
google.maps.event.addListenerOnce(map[i], 'bounds_changed', function(event) {
this.setZoom(zoom);
});
}
});
/** Full Screen event */
for (i = 0; i < 3; i++) {
var centerChanged = [];
var zoomChanged = [];
google.maps.event.addListener(map[i], 'center_changed', function() {
var centerChanged[i] = map[i].getCenter();
var zoomChanged[i] = map[i].getZoom();
});
$(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange', function() {
map[i].setCenter(centerChanged[i]);
google.maps.event.addListenerOnce(map[i], 'bounds_changed', function (event) {
this.setZoom(zoomChanged[i]);
});
});
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</code></pre>
<p>JSLint says "Functions declared within loops referencing an outer scoped variable may lead to confusing semantics."</p>
| 0debug |
I want to Display local Images in Image Picker Controller from my project folder. : <p>I am new in objective c.where i need to display the images in a grid form in Image Picker Controller from my project.
where i have many images, when the images will display i will click on one of them and it will display on another screen in Image View.
i need your help with source code thanks.</p>
| 0debug |
void qemu_aio_coroutine_enter(AioContext *ctx, Coroutine *co)
{
Coroutine *self = qemu_coroutine_self();
CoroutineAction ret;
trace_qemu_aio_coroutine_enter(ctx, self, co, co->entry_arg);
if (co->caller) {
fprintf(stderr, "Co-routine re-entered recursively\n");
co->caller = self;
co->ctx = ctx;
smp_wmb();
ret = qemu_coroutine_switch(self, co, COROUTINE_ENTER);
qemu_co_queue_run_restart(co);
switch (ret) {
case COROUTINE_YIELD:
return;
case COROUTINE_TERMINATE:
assert(!co->locks_held);
trace_qemu_coroutine_terminate(co);
coroutine_delete(co);
return;
default: | 1threat |
static av_always_inline int vc1_filter_line(uint8_t* src, int stride, int pq){
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int a0 = (2*(src[-2*stride] - src[ 1*stride]) - 5*(src[-1*stride] - src[ 0*stride]) + 4) >> 3;
int a0_sign = a0 >> 31;
a0 = (a0 ^ a0_sign) - a0_sign;
if(a0 < pq){
int a1 = FFABS((2*(src[-4*stride] - src[-1*stride]) - 5*(src[-3*stride] - src[-2*stride]) + 4) >> 3);
int a2 = FFABS((2*(src[ 0*stride] - src[ 3*stride]) - 5*(src[ 1*stride] - src[ 2*stride]) + 4) >> 3);
if(a1 < a0 || a2 < a0){
int clip = src[-1*stride] - src[ 0*stride];
int clip_sign = clip >> 31;
clip = ((clip ^ clip_sign) - clip_sign)>>1;
if(clip){
int a3 = FFMIN(a1, a2);
int d = 5 * (a3 - a0);
int d_sign = (d >> 31);
d = ((d ^ d_sign) - d_sign) >> 3;
d_sign ^= a0_sign;
if( d_sign ^ clip_sign )
d = 0;
else{
d = FFMIN(d, clip);
d = (d ^ d_sign) - d_sign;
src[-1*stride] = cm[src[-1*stride] - d];
src[ 0*stride] = cm[src[ 0*stride] + d];
}
return 1;
}
}
}
return 0;
}
| 1threat |
def multi_list(rownum,colnum):
multi_list = [[0 for col in range(colnum)] for row in range(rownum)]
for row in range(rownum):
for col in range(colnum):
multi_list[row][col]= row*col
return multi_list
| 0debug |
def sort_mixed_list(mixed_list):
int_part = sorted([i for i in mixed_list if type(i) is int])
str_part = sorted([i for i in mixed_list if type(i) is str])
return int_part + str_part | 0debug |
qemu_irq *openpic_init (MemoryRegion **pmem, int nb_cpus,
qemu_irq **irqs, qemu_irq irq_out)
{
openpic_t *opp;
int i, m;
struct {
const char *name;
MemoryRegionOps const *ops;
hwaddr start_addr;
ram_addr_t size;
} const list[] = {
{"glb", &openpic_glb_ops, OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},
{"tmr", &openpic_tmr_ops, OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},
{"src", &openpic_src_ops, OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},
{"cpu", &openpic_cpu_ops, OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},
};
if (nb_cpus != 1)
return NULL;
opp = g_malloc0(sizeof(openpic_t));
memory_region_init(&opp->mem, "openpic", 0x40000);
for (i = 0; i < ARRAY_SIZE(list); i++) {
memory_region_init_io(&opp->sub_io_mem[i], list[i].ops, opp,
list[i].name, list[i].size);
memory_region_add_subregion(&opp->mem, list[i].start_addr,
&opp->sub_io_mem[i]);
}
opp->nb_cpus = nb_cpus;
opp->max_irq = OPENPIC_MAX_IRQ;
opp->irq_ipi0 = OPENPIC_IRQ_IPI0;
opp->irq_tim0 = OPENPIC_IRQ_TIM0;
for (i = 0; i < OPENPIC_EXT_IRQ; i++) {
opp->src[i].type = IRQ_EXTERNAL;
}
for (; i < OPENPIC_IRQ_TIM0; i++) {
opp->src[i].type = IRQ_SPECIAL;
}
m = OPENPIC_IRQ_IPI0;
for (; i < m; i++) {
opp->src[i].type = IRQ_TIMER;
}
for (; i < OPENPIC_MAX_IRQ; i++) {
opp->src[i].type = IRQ_INTERNAL;
}
for (i = 0; i < nb_cpus; i++)
opp->dst[i].irqs = irqs[i];
opp->irq_out = irq_out;
register_savevm(&opp->pci_dev.qdev, "openpic", 0, 2,
openpic_save, openpic_load, opp);
qemu_register_reset(openpic_reset, opp);
opp->irq_raise = openpic_irq_raise;
opp->reset = openpic_reset;
if (pmem)
*pmem = &opp->mem;
return qemu_allocate_irqs(openpic_set_irq, opp, opp->max_irq);
}
| 1threat |
static void notdirty_mem_writeb(void *opaque, target_phys_addr_t ram_addr,
uint32_t val)
{
int dirty_flags;
dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
if (!(dirty_flags & CODE_DIRTY_FLAG)) {
#if !defined(CONFIG_USER_ONLY)
tb_invalidate_phys_page_fast(ram_addr, 1);
dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS];
#endif
}
stb_p(qemu_get_ram_ptr(ram_addr), val);
#ifdef CONFIG_KQEMU
if (cpu_single_env->kqemu_enabled &&
(dirty_flags & KQEMU_MODIFY_PAGE_MASK) != KQEMU_MODIFY_PAGE_MASK)
kqemu_modify_page(cpu_single_env, ram_addr);
#endif
dirty_flags |= (0xff & ~CODE_DIRTY_FLAG);
phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] = dirty_flags;
if (dirty_flags == 0xff)
tlb_set_dirty(cpu_single_env, cpu_single_env->mem_io_vaddr);
}
| 1threat |
What is the meaning of the symbol % between two variables in python? : <p>What is the meaning of the symbol '%' such as in this sentence:</p>
<p><code>assert (timesteps % pool_size == 0)</code></p>
| 0debug |
void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
int64_t speed, BlockCompletionFunc *cb,
void *opaque, Error **errp)
{
BlockBackend *blk;
BlockJob *job;
assert(cb);
if (bs->job) {
error_setg(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
return NULL;
}
blk = blk_new();
blk_insert_bs(blk, bs);
job = g_malloc0(driver->instance_size);
error_setg(&job->blocker, "block device is in use by block job: %s",
BlockJobType_lookup[driver->job_type]);
bdrv_op_block_all(bs, job->blocker);
bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker);
job->driver = driver;
job->id = g_strdup(bdrv_get_device_name(bs));
job->blk = blk;
job->cb = cb;
job->opaque = opaque;
job->busy = true;
job->refcnt = 1;
bs->job = job;
QLIST_INSERT_HEAD(&block_jobs, job, job_list);
blk_add_aio_context_notifier(blk, block_job_attached_aio_context,
block_job_detach_aio_context, job);
if (speed != 0) {
Error *local_err = NULL;
block_job_set_speed(job, speed, &local_err);
if (local_err) {
block_job_unref(job);
error_propagate(errp, local_err);
return NULL;
}
}
return job;
}
| 1threat |
make fluid images with flex box css3 : I have created a showcase section where in I have used flex box to align images to the right. However when I shrink the size of the window the images go out of the window. I am looking for something like this: http://jsfiddle.net/xLc2Le0k/15/
Here is the snippet for HTML :
<div class="showcase shadow">
<div id="places">
<p class="category">Places</p>
<div>
<img src="img\Taj Hotel.png" alt="">
</div>
<div>
<img src="img\Gateway of India.png" alt="">
</div>
<div>
<img src="img\Shack at Goa.png" alt="">
</div>
</div>
<p class="more-text">View more...</p>
</div>
Here is the snippet for SCSS :
.showcase {
width: 100%;
margin-top: 5%;
display: inline-block;
#places {
width: 100%;
display: flex;
div:nth-of-type(1) {
align-self: flex-end;
}
div {
margin-left: 0.5%;
}
}
}
Here is the link for the live web page : https://swizzx.github.io/Photography-Portfolio/
Just a heads up, I have tried setting the width of the parent and the element to 100%, when I do so, it shrinks but does not work as how I want it to like in the JS fiddle provided above. On the contrary setting the width to 100% makes the first image equal to the size of the others which I don't want.
Help would be appreciated, thanks in advance! | 0debug |
My code isn't working,What have i done wrong? : This is a program designed to, ask a customer for their order,then display their order at the end.
For some reason my code isn't working.I have displayed the plan of the code below.
print("Welcome to Hungary house.")
addDrink = input("Do you want a drink?\n").lower()
drinkChoice = "None"
dish = ""
order = []
if addDrink == "yes":
print ("What drink would you prefer?")
print ("1: Fanta")
print ("2: Coke")
print ("3: Pepsi")
print ("4: Sprite")
drinkChoice = input("please select a drink from the options above\n")
if drinkChoice == "1" or drinkChoice == "fanta":
drinkChoice = "Fanta"
order.insert(0,drinkChoice)
if drinkChoice == "2" or drinkChoice == "coke":
drinkChoice = "Coke"
order.insert(0,drinkChoice)
if drinkChoice == "3" or drinkChoice == "pepsi":
drinkChoice = "Pepsi"
order.insert(0,drinkChoice)
if drinkChoice == "4" or drinkChoice == "sprite":
drinkChoice = "Sprite"
order.insert(0,drinkChoice)
print ("you have chosen this drink: " + drinkChoice)
foodGroup = input("Do you want Italian, Indian or Chinese food?\n")
if foodGroup == "italian" or foodGroup == "Italian":
dish = input("Do you want Pasta or Pizza?\n")
if dish == "pizza":
dish = input("Do you want Grilled chicken or Seasonal vegetables?\n")
if dish == "seasonal vegetables":
order.insert(1,dish)
if dish == "grilled chicken":
order.insert(1,dish)
if dish == "pasta":
dish = input("Do you want Vegetarian Toppings or meat toppings?\n")
if dish == "Vegetarian Toppings":
order.insert(1,dish)
if dish == "meat toppings":
order.insert(1,dish)
if foodGroup == "indian" or foodGroup == "Indian":
dish = input("Do you want Curry or onion bhaji?\n")
if dish == "Curry":
dish = input("Do you want Rice or Naan?\n")
if dish == "Rice":
order.insert(1,dish)
if dish == "Naan":
order.insert(1,dish)
if dish == "onion bhaji":
dish = input("Do you want Chilli or Peppers?\n")
if dish == "Chilli":
order.insert(1,dish)
if dish == "Peppers":
order.insert(1,dish)
if foodGroup == "chinese" or foodGroup == "Chinese":
dish = input("Do you want Chicken Wings or onion Noodles?\n")
if dish == "Chicken Wings":
dish = input("Do you want Chips or Red peppers?\n")
if dish == "Chips":
order.insert(1,dish)
if dish == "Red peppers":
order.insert(1,dish)
if dish == "Noodles":
dish = input("Do you want Meatballs or Chicken?\n")
if dish == "Meatballs":
order.insert(1,dish)
if dish == "Chicken":
order.insert(1,dish)
print ("You have ordered",order"enjoy your meal")
This is how the code is supposed to work:
Welcome to Hungary house.
Do you want a drink?
If no, Move on to the next question
If yes, ask what drink the customer wants.
(Coke, Fanta, lemonade are the options)
If coke is chosen, set coke as drink
If Fanta is chosen, set Fanta as drink
If Lemonade is chosen, set Lemonade as drink
Do you want Italian, Indian or Chinese food?
If Italian food is entered ask the following questions.
Do you want Pasta or chicken-cacciatore?
If chicken cacciatore is chosen ask,
Do you want with your chicken-cacciatore?
Grilled free-range chicken
Or
Seasonal vegetables
If Grilled free-range chicken is chosen add that to the chicken-cacciatore.
If Seasonal vegetables is chosen add that to the chicken-cacciatore.
If pasta is chosen ask the following questions.
Do you want Vegetarian Toppings?
If user enters yes, add vegetarian topping add it on the pasta
If user enters no, move on to the next question
Do you want Meaty Toppings?
If yes, add Meaty Toppings on the pasta
If no, add Meaty Toppings on the pasta
If Indian food is entered ask the following questions
Do you want Curry or onion bhaji?
If curry is selected ask the following questions.
What toppings you want on top of your Curry?
Rice
Or
Naan
If user enters rice, add rice on to the curry.
If user enters Naan, add naan on to the curry.
If user enters onion ask the following questions.
What toppings do you want on top of your onion bhaji?
Chilli source
Or
Peppers
If user enters Chilli source, add chilli source on to the onion bhaji.
If user enters Peppers, add Peppers on to the onion bhaji.
If Chinese food is entered ask the following questions.
Do you want Chicken wings or Noodles?
If Chicken wings is chosen ask,
Do you want with your Chicken wings?
Chips
Or
Red Peppers
If Chips is chosen add that to the Chips to the Chicken wings
If Red Peppers are chosen add that to the Chicken wings.
If the user enters Noodles ask the following questions.
Choose the toppings you want with Noodles.
Meatballs
Or
Chicken
If user enters Meatballs, add Meatballs to the Noodles.
If user enters Chicken, add Chicken to the Noodles.
After this, Display the order the user wanted.
Tell the customer that their order will come within the next 10-50 minutes. If they wish to cancel tell them to contact this number ‘077 3475 609334’.
| 0debug |
How to get icon back in dock(Mac)? : <p>I delete <a href="https://i.stack.imgur.com/CYFmR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CYFmR.png" alt="enter image description here"></a> by mistake. How can I get it back? Thanks!</p>
| 0debug |
static RemoveResult remove_hpte(PowerPCCPU *cpu, target_ulong ptex,
target_ulong avpn,
target_ulong flags,
target_ulong *vp, target_ulong *rp)
{
CPUPPCState *env = &cpu->env;
uint64_t token;
target_ulong v, r;
if (!valid_pte_index(env, ptex)) {
return REMOVE_PARM;
}
token = ppc_hash64_start_access(cpu, ptex);
v = ppc_hash64_load_hpte0(cpu, token, 0);
r = ppc_hash64_load_hpte1(cpu, token, 0);
ppc_hash64_stop_access(token);
if ((v & HPTE64_V_VALID) == 0 ||
((flags & H_AVPN) && (v & ~0x7fULL) != avpn) ||
((flags & H_ANDCOND) && (v & avpn) != 0)) {
return REMOVE_NOT_FOUND;
}
*vp = v;
*rp = r;
ppc_hash64_store_hpte(cpu, ptex, HPTE64_V_HPTE_DIRTY, 0);
ppc_hash64_tlb_flush_hpte(cpu, ptex, v, r);
return REMOVE_SUCCESS;
}
| 1threat |
For Loops in Python to iterate over id for each item in column : I want to iterate over a dataframe so for each id and for each fruit, so that for each fruit there is a the other fruits associated with that id and the prices of both.
[example and expected results][1]
[1]: https://i.stack.imgur.com/6Fvhh.png | 0debug |
How to define role/permission security in Swagger : <p>In my API documentation, I would like to define the security necessary for each API endpoint. The project has defined roles and permissions that determine which users can access the APIs. What is the best way in Swagger to document this information? Is there a best practice or recommendation on how to show this detail?</p>
<p>This what I tried out using securityDefinitions and a self-defined variable for the roles, but that information (x-role-names) didn't get copied over into the documentation when I ran it through swagger2markup or using swagger-ui.</p>
<pre><code> "securityDefinitions": {
"baseUserSecurity": {
"type": "basic",
"x-role-names": "test"
}
}
</code></pre>
<p>What's the best way to document the role and permission information per endpoint?</p>
| 0debug |
is "DROP TABLE IF EXISTS " color an indicator of seomething wrong? : ["DROP TABLE IF EXISTS "][1]
[1]: https://i.stack.imgur.com/VyovS.png
As you can see, the line of code that says "DROP TABLE IF EXIST " is not green, but orange. Why is this happening? Is it something ton worry about?
Thanks in advance! | 0debug |
int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
{
Property *prop;
int ret;
prop = qdev_prop_find(dev, name);
if (!prop) {
fprintf(stderr, "property \"%s.%s\" not found\n",
dev->info->name, name);
return -1;
}
if (!prop->info->parse) {
fprintf(stderr, "property \"%s.%s\" has no parser\n",
dev->info->name, name);
return -1;
}
ret = prop->info->parse(dev, prop, value);
if (ret < 0) {
switch (ret) {
case -EEXIST:
fprintf(stderr, "property \"%s.%s\": \"%s\" is already in use\n",
dev->info->name, name, value);
break;
default:
case -EINVAL:
fprintf(stderr, "property \"%s.%s\": failed to parse \"%s\"\n",
dev->info->name, name, value);
break;
case -ENOENT:
fprintf(stderr, "property \"%s.%s\": could not find \"%s\"\n",
dev->info->name, name, value);
break;
}
return -1;
}
return 0;
}
| 1threat |
IE-9 giving fakepath when using input type file : <p>I wasn't able to read the file in IE-9. I am generating base64 from the url. In all the other browsers it works, except for IE-9. Can anyone please help me with this?
I am getting c://fakepath/images.jpg in IE-9</p>
<pre><code>if((navigator.userAgent.indexOf("MSIE") != -1 ) || !!document.documentMode == true )) //IF IE > 10
{
tmppath = $("#hi").val();
console.log("only in ie"+tmppath);
}
else{
var selectedFile = this.files[0];
tmppath = URL.createObjectURL(event.target.files[0]);
console.log("temp path other"+tmppath);
}
console.log("temp path"+tmppath);
<input name="hello1" type="file" id="hi" accept="image/*"/>
</code></pre>
| 0debug |
static int gif_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
{
GifState *s = avctx->priv_data;
AVFrame *picture = data;
int ret;
bytestream2_init(&s->gb, avpkt->data, avpkt->size);
s->picture.pts = avpkt->pts;
s->picture.pkt_pts = avpkt->pts;
s->picture.pkt_dts = avpkt->dts;
s->picture.pkt_duration = avpkt->duration;
if (avpkt->size >= 6) {
s->keyframe = memcmp(avpkt->data, gif87a_sig, 6) == 0 ||
memcmp(avpkt->data, gif89a_sig, 6) == 0;
} else {
s->keyframe = 0;
if (s->keyframe) {
s->keyframe_ok = 0;
if ((ret = gif_read_header1(s)) < 0)
return ret;
if ((ret = av_image_check_size(s->screen_width, s->screen_height, 0, avctx)) < 0)
return ret;
avcodec_set_dimensions(avctx, s->screen_width, s->screen_height);
if (s->picture.data[0])
avctx->release_buffer(avctx, &s->picture);
if ((ret = ff_get_buffer(avctx, &s->picture)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
s->picture.pict_type = AV_PICTURE_TYPE_I;
s->picture.key_frame = 1;
} else {
if ((ret = avctx->reget_buffer(avctx, &s->picture)) < 0) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return ret;
s->picture.pict_type = AV_PICTURE_TYPE_P;
s->picture.key_frame = 0;
ret = gif_parse_next_image(s, got_frame);
if (ret < 0)
return ret;
else if (*got_frame)
*picture = s->picture;
return avpkt->size; | 1threat |
How to disable overscroll effect on RecyclerView ONLY when you can't scroll anyway ? : <h2>Background</h2>
<p>Sometimes, all items of the recyclerView are already visible to the user.</p>
<p>In this case, it wouldn't matter to the user to see overscroll effect, because it's impossible to actually scroll and see more items.</p>
<h2>The problem</h2>
<p>I know that in order to disable overscroll effect on RecyclerView, I can just use:</p>
<pre><code>recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
</code></pre>
<p>but I can't find out when to trigger this, when the scrolling isn't possible anyway.</p>
<h2>The question</h2>
<p>How can I Identify that all items are fully visible and that the user can't really scroll ? </p>
<p>If it helps to assume anything, I always use LinearLayoutManager (vertical and horizontal) for the RecyclerView.</p>
| 0debug |
Javascript .querySelector find <div> by innerTEXT : <p>How can I find DIV with certain text? For example:</p>
<pre><code><div>
SomeText, text continues.
</div>
</code></pre>
<p>Trying to use something like this:</p>
<pre><code>var text = document.querySelector('div[SomeText*]').innerTEXT;
alert(text);
</code></pre>
<p>But ofcourse it will not work. How can I do it?</p>
| 0debug |
RAII vs. Garbage Collector : <p>I recently watched a great talk by Herb Sutter about "Leak Free C++..." at CppCon 2016 where he talked about using smart pointers to implement RAII (Resource acquisition is initialization) - Concepts and how they solve most of the memory leaks issues.</p>
<p>Now I was wondering. If I strictly follow RAII rules, which seems to be a good thing, why would that be any different from having a garbage collector in C++? I know that with RAII the programmer is in full control of when the resources are freed again, but is that in any case beneficial to just having a garbage collector? Would it really be less efficient? I even heard that having a garbage collector can be more efficient, as it can free larger chunks of memory at a time instead of freeing small memory pieces all over the code.</p>
| 0debug |
Java Regex Facebook : I’m trying to figure out a regex expression in java for this facebook url:
https://www.facebook.com/566162426788268/photos/a.566209603450217.1073741828.566162426788268/1214828765254961/?type=3&theater
I have come up with the solution
\w++(?=/\?)
help appreicated | 0debug |
What is characteristics of a good unit test : I need to know that what is characteristics of a good unit test and best practices ? how much code coverage considered good enough ?
In order for our unit tests to become effective we need to lay out some ground rules. What is a good unit test and what can we do to make sure we create tests that actually help us in our development efforts? | 0debug |
static int open_file(AVFormatContext *avf, unsigned fileno)
{
ConcatContext *cat = avf->priv_data;
ConcatFile *file = &cat->files[fileno];
int ret;
if (cat->avf)
avformat_close_input(&cat->avf);
cat->avf = avformat_alloc_context();
if (!cat->avf)
return AVERROR(ENOMEM);
cat->avf->flags |= avf->flags;
cat->avf->interrupt_callback = avf->interrupt_callback;
if ((ret = ff_copy_whiteblacklists(cat->avf, avf)) < 0)
return ret;
if ((ret = avformat_open_input(&cat->avf, file->url, NULL, NULL)) < 0 ||
(ret = avformat_find_stream_info(cat->avf, NULL)) < 0) {
av_log(avf, AV_LOG_ERROR, "Impossible to open '%s'\n", file->url);
avformat_close_input(&cat->avf);
return ret;
}
cat->cur_file = file;
if (file->start_time == AV_NOPTS_VALUE)
file->start_time = !fileno ? 0 :
cat->files[fileno - 1].start_time +
cat->files[fileno - 1].duration;
file->file_start_time = (cat->avf->start_time == AV_NOPTS_VALUE) ? 0 : cat->avf->start_time;
file->file_inpoint = (file->inpoint == AV_NOPTS_VALUE) ? file->file_start_time : file->inpoint;
if (file->duration == AV_NOPTS_VALUE && file->outpoint != AV_NOPTS_VALUE)
file->duration = file->outpoint - file->file_inpoint;
if (cat->segment_time_metadata) {
av_dict_set_int(&file->metadata, "lavf.concatdec.start_time", file->start_time, 0);
if (file->duration != AV_NOPTS_VALUE)
av_dict_set_int(&file->metadata, "lavf.concatdec.duration", file->duration, 0);
}
if ((ret = match_streams(avf)) < 0)
return ret;
if (file->inpoint != AV_NOPTS_VALUE) {
if ((ret = avformat_seek_file(cat->avf, -1, INT64_MIN, file->inpoint, file->inpoint, 0)) < 0)
return ret;
}
return 0;
}
| 1threat |
static abi_long do_bind(int sockfd, abi_ulong target_addr,
socklen_t addrlen)
{
void *addr;
abi_long ret;
if (addrlen < 0)
return -TARGET_EINVAL;
addr = alloca(addrlen+1);
ret = target_to_host_sockaddr(addr, target_addr, addrlen);
if (ret)
return ret;
return get_errno(bind(sockfd, addr, addrlen));
}
| 1threat |
document.getElementById('input').innerHTML = user_input; | 1threat |
Store *.xls *.csv *.xlsx into Microsoft Sql Server : <p>I have a java application with <code>apache-poi 3.5</code>.</p>
<p>My database is <code>Microsoft Sql Server</code>.</p>
<p>In my application i do an upload and i want to know if it's possible to store my file (<code>*.xls</code>, <code>*.csv</code>, <code>*.xlsx</code>) directly in my database ?</p>
| 0debug |
"DELETE TOP (1) FROM @TEMP" or "DELETE FROM #TEMP WHERE.." is faster? : <p>I am wondering which one is much faster in THEORY? </p>
<pre><code>IF EXISTS(SELECT TOP 1 1 FROM @ControlOrderList )
BEGIN
SET @RowNumber= (SELECT TOP 1 id FROM @ControlOrderList)
...
DELETE @ControlOrderList WHERE id=@RowNumber
END
</code></pre>
<p>or is this much faster?</p>
<pre><code>IF EXISTS(SELECT TOP 1 1 FROM @ControlOrderList )
BEGIN
SET @RowNumber= (SELECT TOP 1 id FROM @ControlOrderList)
...
DELETE TOP 1 @ControlOrderList
END
</code></pre>
<p>And is it secure to use DELETE TOP 1? Can I trust SQL-SERVER to delete the row that I got in "SELECT TOP 1 ....." ?</p>
| 0debug |
How to use check for session and http referer? : <p>I'd like to check for both session and http referer but it's not working for me.</p>
<p>First page:</p>
<pre><code><?php
session_start();
$_SESSION['something'] = '1';
?>
</code></pre>
<p>Second page:</p>
<pre><code><?php
session_start();
if(!strpos($_SERVER["HTTP_REFERER"], "some referer")){
die(header("Location: my site"));
}
if(!isset($_SESSION['something'])){
die(header("Location: my site"));
}
session_destroy();
// rest code
</code></pre>
<p>What am I doing wrong?</p>
| 0debug |
How to remove elements from HTML/Change the page entirely? : <p>I am using the following tag to load my scripts and start the game I am making, but all the original elements stay from the original webpage.</p>
<pre><code><input type="image" src="Images/start.jpg" height='200' width='350' alt='Something went wrong loading the images. Update your Internet plugins and try again.' onclick='INIT_THREE(); INIT_CANNON(); UPDATE();'/>
</code></pre>
<p>Is there any way to remove the elements like the background sound and image when I press the button? I tried using href to load another html page, but I don't think that is the best way to do it, plus it didn't work. Any help appreciated, thanks!</p>
| 0debug |
unable to add firebase authentication to my app : I've successfully connected to firebase but when i click on "Add Firebase Authentication to your app " and click on accept changes nothing is happening Iam not getting any errors as well as Iam not getting the message "dependecies added succesfully".
I've checked the gradle section of my app and the dependencies are added correctly but iam not getting the green star saying "dependencies added succesfully".
These are the dependencies that have been added to my project
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.2.0'
}[enter image description here][1]
[1]: https://i.stack.imgur.com/AMEMt.png | 0debug |
Access webcam using OpenCV (Python) in Docker? : <p>I'm trying to use Docker for one of our projects which uses OpenCV to process webcam feed (Python). But I can't seem to get access to the webcam within docker, here's the code which I use to test webcam access:</p>
<pre><code>python -c "import cv2;print(cv2.VideoCapture(0).isOpened())"
</code></pre>
<p>And here's what I tried so far,</p>
<pre><code> docker run --device=/dev/video0 -it rec bash
docker run --privileged --device=/dev/video0 -it rec bash
sudo docker run --privileged --device=/dev/video0:/dev/video0 -it rec bash
</code></pre>
<p>All of these return <code>False</code>, what am I doing wrong?</p>
| 0debug |
static void gen_tlbilx_booke206(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
TCGv t0;
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
t0 = tcg_temp_new();
gen_addr_reg_index(ctx, t0);
switch((ctx->opcode >> 21) & 0x3) {
case 0:
gen_helper_booke206_tlbilx0(cpu_env, t0);
break;
case 1:
gen_helper_booke206_tlbilx1(cpu_env, t0);
break;
case 3:
gen_helper_booke206_tlbilx3(cpu_env, t0);
break;
default:
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
break;
}
tcg_temp_free(t0);
#endif
}
| 1threat |
Test score vs test accuracy when evaluating model using Keras : <p>Im using a neural network implemented with the Keras library and below is the results during training. At the end it prints a test score and a test accuracy. I can't figure out exactly what the score represents, but the accuracy I assume to be the number of predictions that was correct when running the test.</p>
<blockquote>
<p>Epoch 1/15 1200/1200 [==============================] - 4s - loss:
0.6815 - acc: 0.5550 - val_loss: 0.6120 - val_acc: 0.7525</p>
<p>Epoch 2/15 1200/1200 [==============================] - 3s - loss:
0.5481 - acc: 0.7250 - val_loss: 0.4645 - val_acc: 0.8025</p>
<p>Epoch 3/15 1200/1200 [==============================] - 3s - loss:
0.5078 - acc: 0.7558 - val_loss: 0.4354 - val_acc: 0.7975</p>
<p>Epoch 4/15 1200/1200 [==============================] - 3s - loss:
0.4603 - acc: 0.7875 - val_loss: 0.3978 - val_acc: 0.8350</p>
<p>Epoch 5/15 1200/1200 [==============================] - 3s - loss:
0.4367 - acc: 0.7992 - val_loss: 0.3809 - val_acc: 0.8300</p>
<p>Epoch 6/15 1200/1200 [==============================] - 3s - loss:
0.4276 - acc: 0.8017 - val_loss: 0.3884 - val_acc: 0.8350</p>
<p>Epoch 7/15 1200/1200 [==============================] - 3s - loss:
0.3975 - acc: 0.8167 - val_loss: 0.3666 - val_acc: 0.8400</p>
<p>Epoch 8/15 1200/1200 [==============================] - 3s - loss:
0.3916 - acc: 0.8183 - val_loss: 0.3753 - val_acc: 0.8450</p>
<p>Epoch 9/15 1200/1200 [==============================] - 3s - loss:
0.3814 - acc: 0.8233 - val_loss: 0.3505 - val_acc: 0.8475</p>
<p>Epoch 10/15 1200/1200 [==============================] - 3s - loss:
0.3842 - acc: 0.8342 - val_loss: 0.3672 - val_acc: 0.8450</p>
<p>Epoch 11/15 1200/1200 [==============================] - 3s - loss:
0.3674 - acc: 0.8375 - val_loss: 0.3383 - val_acc: 0.8525</p>
<p>Epoch 12/15 1200/1200 [==============================] - 3s - loss:
0.3624 - acc: 0.8367 - val_loss: 0.3423 - val_acc: 0.8650</p>
<p>Epoch 13/15 1200/1200 [==============================] - 3s - loss:
0.3497 - acc: 0.8475 - val_loss: 0.3069 - val_acc: 0.8825</p>
<p>Epoch 14/15 1200/1200 [==============================] - 3s - loss:
0.3406 - acc: 0.8500 - val_loss: 0.2993 - val_acc: 0.8775</p>
<p>Epoch 15/15 1200/1200 [==============================] - 3s - loss:
0.3252 - acc: 0.8600 - val_loss: 0.2960 - val_acc: 0.8775</p>
<p>400/400 [==============================] - 0s</p>
<p>Test score: 0.299598811865</p>
<p>Test accuracy: 0.88</p>
</blockquote>
<p>Looking at the <a href="https://keras.io/models/model/" rel="noreferrer">Keras documentation</a>, I still don't understand what score is. For the evaluate function, it says: </p>
<blockquote>
<p>Returns the loss value & metrics values for the model in test mode.</p>
</blockquote>
<p>One thing I noticed is that when the test accuracy is lower, the score is higher, and when accuracy is higher, the score is lower.</p>
| 0debug |
Preview is not showing anything in android studio due to a error : I wrote a code for a android app.
There are other questions also like this. But still my problem is not solved
When I installed android studio preview was working very well. But now, the preview is not showing anything. There is a error, given in the image's link below.
https://drive.google.com/open?id=1F_9DlMh9F9HpNw6LN5jnY_5htf-qQVET
That image is my Preview Panel(Or, Whatever we call that)
Firstly I was thinking that this error is only for my current project. But when I opened a existing project, the error was still there.
Though, App is working well in mobile device.
But as the preview is showing my productivity is decreasing.
Please Help me getting rid of this error? | 0debug |
How do I use Reactor's StepVerifier to verify a Mono is empty? : <p>I am using <code>StepVerifier</code> to test values:</p>
<pre><code>@Test
public void testStuff() {
Thing thing = new Thing();
Mono<Thing> result = Mono.just(thing);
StepVerifier.create(result).consumeNextWith(r -> {
assertEquals(thing, r);
}).verifyComplete();
}
</code></pre>
<p>What I'd like to do now is test for the absence of an item in the Mono. Like this:</p>
<pre><code>@Test
public void testNoStuff() {
Mono<Thing> result = Mono.empty();
StepVerifier.create(result)... // what goes here?
}
</code></pre>
<p>I want to test that the Mono is in fact empty. How do I do that?</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.