problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Initialize map with pair of std::arrays c++11 : <p>I would like to compile this lines. Insert to map pair of std::arrays.</p>
<pre><code>#include<iostream>
#include<map>
#include<array>
#include<utility>
using namespace std;
int main()
{
array<double, 8> l;
array<double, 8> r;
map<double, pair<array<double, 8>, array<double, 8>>> m;
pair<array<double, 8>, array<double, 8>> p;
p = make_pair(l, r);//ok
m.insert(1., make_pair(l, r));//not ok
return 0;
}
//clear && g++ getMinPosition.cpp -std=c++11 -o getMinPosition && ./getMinPosition
</code></pre>
| 0debug
|
Need more clarification of the css syntax : in css block:
.navbar-custom .nav li a:hover{
outline:none;
background-color: rgba(255,255,255,0.2);
}
does this mean: 'hover effect applies to the a tag in the navbar-custom's sub class nav' list element "?
If no please clarify
| 0debug
|
static int drive_init(struct drive_opt *arg, int snapshot,
QEMUMachine *machine)
{
char buf[128];
char file[1024];
char devname[128];
char serial[21];
const char *mediastr = "";
BlockInterfaceType type;
enum { MEDIA_DISK, MEDIA_CDROM } media;
int bus_id, unit_id;
int cyls, heads, secs, translation;
BlockDriverState *bdrv;
BlockDriver *drv = NULL;
int max_devs;
int index;
int cache;
int bdrv_flags, onerror;
int drives_table_idx;
char *str = arg->opt;
static const char * const params[] = { "bus", "unit", "if", "index",
"cyls", "heads", "secs", "trans",
"media", "snapshot", "file",
"cache", "format", "serial", "werror",
NULL };
if (check_params(buf, sizeof(buf), params, str) < 0) {
fprintf(stderr, "qemu: unknown parameter '%s' in '%s'\n",
buf, str);
return -1;
}
file[0] = 0;
cyls = heads = secs = 0;
bus_id = 0;
unit_id = -1;
translation = BIOS_ATA_TRANSLATION_AUTO;
index = -1;
cache = 3;
if (machine->use_scsi) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
pstrcpy(devname, sizeof(devname), "scsi");
} else {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
pstrcpy(devname, sizeof(devname), "ide");
}
media = MEDIA_DISK;
if (get_param_value(buf, sizeof(buf), "bus", str)) {
bus_id = strtol(buf, NULL, 0);
if (bus_id < 0) {
fprintf(stderr, "qemu: '%s' invalid bus id\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "unit", str)) {
unit_id = strtol(buf, NULL, 0);
if (unit_id < 0) {
fprintf(stderr, "qemu: '%s' invalid unit id\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "if", str)) {
pstrcpy(devname, sizeof(devname), buf);
if (!strcmp(buf, "ide")) {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
} else if (!strcmp(buf, "scsi")) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
} else if (!strcmp(buf, "floppy")) {
type = IF_FLOPPY;
max_devs = 0;
} else if (!strcmp(buf, "pflash")) {
type = IF_PFLASH;
max_devs = 0;
} else if (!strcmp(buf, "mtd")) {
type = IF_MTD;
max_devs = 0;
} else if (!strcmp(buf, "sd")) {
type = IF_SD;
max_devs = 0;
} else if (!strcmp(buf, "virtio")) {
type = IF_VIRTIO;
max_devs = 0;
} else {
fprintf(stderr, "qemu: '%s' unsupported bus type '%s'\n", str, buf);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "index", str)) {
index = strtol(buf, NULL, 0);
if (index < 0) {
fprintf(stderr, "qemu: '%s' invalid index\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "cyls", str)) {
cyls = strtol(buf, NULL, 0);
}
if (get_param_value(buf, sizeof(buf), "heads", str)) {
heads = strtol(buf, NULL, 0);
}
if (get_param_value(buf, sizeof(buf), "secs", str)) {
secs = strtol(buf, NULL, 0);
}
if (cyls || heads || secs) {
if (cyls < 1 || cyls > 16383) {
fprintf(stderr, "qemu: '%s' invalid physical cyls number\n", str);
return -1;
}
if (heads < 1 || heads > 16) {
fprintf(stderr, "qemu: '%s' invalid physical heads number\n", str);
return -1;
}
if (secs < 1 || secs > 63) {
fprintf(stderr, "qemu: '%s' invalid physical secs number\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "trans", str)) {
if (!cyls) {
fprintf(stderr,
"qemu: '%s' trans must be used with cyls,heads and secs\n",
str);
return -1;
}
if (!strcmp(buf, "none"))
translation = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(buf, "lba"))
translation = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(buf, "auto"))
translation = BIOS_ATA_TRANSLATION_AUTO;
else {
fprintf(stderr, "qemu: '%s' invalid translation type\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "media", str)) {
if (!strcmp(buf, "disk")) {
media = MEDIA_DISK;
} else if (!strcmp(buf, "cdrom")) {
if (cyls || secs || heads) {
fprintf(stderr,
"qemu: '%s' invalid physical CHS format\n", str);
return -1;
}
media = MEDIA_CDROM;
} else {
fprintf(stderr, "qemu: '%s' invalid media\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "snapshot", str)) {
if (!strcmp(buf, "on"))
snapshot = 1;
else if (!strcmp(buf, "off"))
snapshot = 0;
else {
fprintf(stderr, "qemu: '%s' invalid snapshot option\n", str);
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "cache", str)) {
if (!strcmp(buf, "off") || !strcmp(buf, "none"))
cache = 0;
else if (!strcmp(buf, "writethrough"))
cache = 1;
else if (!strcmp(buf, "writeback"))
cache = 2;
else {
fprintf(stderr, "qemu: invalid cache option\n");
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "format", str)) {
if (strcmp(buf, "?") == 0) {
fprintf(stderr, "qemu: Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
fprintf(stderr, "\n");
return -1;
}
drv = bdrv_find_format(buf);
if (!drv) {
fprintf(stderr, "qemu: '%s' invalid format\n", buf);
return -1;
}
}
if (arg->file == NULL)
get_param_value(file, sizeof(file), "file", str);
else
pstrcpy(file, sizeof(file), arg->file);
if (!get_param_value(serial, sizeof(serial), "serial", str))
memset(serial, 0, sizeof(serial));
onerror = BLOCK_ERR_REPORT;
if (get_param_value(buf, sizeof(serial), "werror", str)) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO) {
fprintf(stderr, "werror is no supported by this format\n");
return -1;
}
if (!strcmp(buf, "ignore"))
onerror = BLOCK_ERR_IGNORE;
else if (!strcmp(buf, "enospc"))
onerror = BLOCK_ERR_STOP_ENOSPC;
else if (!strcmp(buf, "stop"))
onerror = BLOCK_ERR_STOP_ANY;
else if (!strcmp(buf, "report"))
onerror = BLOCK_ERR_REPORT;
else {
fprintf(stderr, "qemu: '%s' invalid write error action\n", buf);
return -1;
}
}
if (index != -1) {
if (bus_id != 0 || unit_id != -1) {
fprintf(stderr,
"qemu: '%s' index cannot be used with bus and unit\n", str);
return -1;
}
if (max_devs == 0)
{
unit_id = index;
bus_id = 0;
} else {
unit_id = index % max_devs;
bus_id = index / max_devs;
}
}
if (unit_id == -1) {
unit_id = 0;
while (drive_get_index(type, bus_id, unit_id) != -1) {
unit_id++;
if (max_devs && unit_id >= max_devs) {
unit_id -= max_devs;
bus_id++;
}
}
}
if (max_devs && unit_id >= max_devs) {
fprintf(stderr, "qemu: '%s' unit %d too big (max is %d)\n",
str, unit_id, max_devs - 1);
return -1;
}
if (drive_get_index(type, bus_id, unit_id) != -1)
return 0;
if (type == IF_IDE || type == IF_SCSI)
mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
if (max_devs)
snprintf(buf, sizeof(buf), "%s%i%s%i",
devname, bus_id, mediastr, unit_id);
else
snprintf(buf, sizeof(buf), "%s%s%i",
devname, mediastr, unit_id);
bdrv = bdrv_new(buf);
drives_table_idx = drive_get_free_idx();
drives_table[drives_table_idx].bdrv = bdrv;
drives_table[drives_table_idx].type = type;
drives_table[drives_table_idx].bus = bus_id;
drives_table[drives_table_idx].unit = unit_id;
drives_table[drives_table_idx].onerror = onerror;
drives_table[drives_table_idx].drive_opt_idx = arg - drives_opt;
strncpy(drives_table[nb_drives].serial, serial, sizeof(serial));
nb_drives++;
switch(type) {
case IF_IDE:
case IF_SCSI:
switch(media) {
case MEDIA_DISK:
if (cyls != 0) {
bdrv_set_geometry_hint(bdrv, cyls, heads, secs);
bdrv_set_translation_hint(bdrv, translation);
}
break;
case MEDIA_CDROM:
bdrv_set_type_hint(bdrv, BDRV_TYPE_CDROM);
break;
}
break;
case IF_SD:
case IF_FLOPPY:
bdrv_set_type_hint(bdrv, BDRV_TYPE_FLOPPY);
break;
case IF_PFLASH:
case IF_MTD:
case IF_VIRTIO:
break;
}
if (!file[0])
return 0;
bdrv_flags = 0;
if (snapshot) {
bdrv_flags |= BDRV_O_SNAPSHOT;
cache = 2;
}
if (cache == 0)
bdrv_flags |= BDRV_O_NOCACHE;
else if (cache == 2)
bdrv_flags |= BDRV_O_CACHE_WB;
else if (cache == 3)
bdrv_flags |= BDRV_O_CACHE_DEF;
if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0 || qemu_key_check(bdrv, file)) {
fprintf(stderr, "qemu: could not open disk image %s\n",
file);
return -1;
}
return 0;
}
| 1threat
|
Discarding alpha channel from images stored as Numpy arrays : <p>I load images with numpy/scikit. I know that all images are 200x200 pixels.</p>
<p>When the images are loaded, I notice some have an alpha channel, and therefore have shape (200, 200, 4) instead of (200, 200, 3) which I expect.</p>
<p>Is there a way to delete that last value, discarding the alpha channel and get all images to a nice (200, 200, 3) shape?</p>
| 0debug
|
AioContext *qemu_get_aio_context(void)
{
return qemu_aio_context;
}
| 1threat
|
Why I Am Getting Error While Running a Bat File? : The code is as follows:
@Echo off
Set _File=SQLQuery.txt
Set /a _Lines=0
For /f %j in ('Type %_File%^|Find "" /v /c') Do Set /a _Lines=%j
Echo %_File% has %_Lines% lines.
When I run as a bat file it gives me error as 'the syntax of the command is incorrect' .
And when I run all the above commands it runs successfully.
Why this is so?
| 0debug
|
AWS CodeCommit - fatal: repository 'https://git-codecommit.us-east-1..' not found : <p>I have an AWS account. I created a repository in us-east-1 region. When I try to access it from my Mac's terminal I get an error <code>fatal: repository 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/demo/' not found</code>. I was able to access this repository using SourceTree GIT client.</p>
<p>I create another repository in California region and I was able to access that repository from the terminal itself.</p>
<p>Why my Mac's terminal can't find repositories in a particular AWS region?</p>
| 0debug
|
Set global $PATH environment variable in VS Code : <p>I'm defining a custom <code>$PATH</code> environment variable in my <code>~/.bash_profile</code> (on a Mac), like so:</p>
<pre><code>PATH="$HOME/.cargo/bin:$PATH:$HOME/bin"
</code></pre>
<p>However, VS Code of course does not run my <code>.bash_profile</code>, so it does not have my custom paths. In fact, if I <em>Toggle Developer Tools</em> and check <code>process.env.PATH</code>, it doesn't even seem to have <code>/usr/local/bin</code>.</p>
<p>How do I globally set the <code>$PATH</code> environment variable in VS Code?</p>
<p>(I want to set it globally, not per project or per task, since I'm maintaining a lot of small packages.)</p>
| 0debug
|
text field should get active in reverse order : i have six text fields one after another which is used for typing passcode.
after one character , next text field becomes active.But how to do for backspace? On keyboard backspace , text field should get active in reverse order
| 0debug
|
void kvm_ioapic_dump_state(Monitor *mon, const QDict *qdict)
{
IOAPICCommonState s;
kvm_ioapic_get(&s);
ioapic_print_redtbl(mon, &s);
}
| 1threat
|
static inline void gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj = -1;
int num_insns;
int max_insns;
pc_start = tb->pc;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
ctx.nip = pc_start;
ctx.tb = tb;
ctx.exception = POWERPC_EXCP_NONE;
ctx.spr_cb = env->spr_cb;
ctx.mem_idx = env->mmu_idx;
ctx.access_type = -1;
ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_sf;
#endif
ctx.fpu_enabled = msr_fp;
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
ctx.spe_enabled = msr_spe;
else
ctx.spe_enabled = 0;
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
ctx.altivec_enabled = msr_vr;
else
ctx.altivec_enabled = 0;
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
ctx.singlestep_enabled = CPU_SINGLE_STEP;
else
ctx.singlestep_enabled = 0;
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
if (unlikely(env->singlestep_enabled))
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
#if defined (DO_SINGLE_STEP) && 0
msr_se = 1;
#endif
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_icount_start();
while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) {
if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) {
QTAILQ_FOREACH(bp, &env->breakpoints, entry) {
if (bp->pc == ctx.nip) {
gen_debug_exception(ctxp);
break;
}
}
}
if (unlikely(search_pc)) {
j = gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
gen_opc_instr_start[lj++] = 0;
}
gen_opc_pc[lj] = ctx.nip;
gen_opc_instr_start[lj] = 1;
gen_opc_icount[lj] = num_insns;
}
LOG_DISAS("----------------\n");
LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n",
ctx.nip, ctx.mem_idx, (int)msr_ir);
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(ctx.le_mode)) {
ctx.opcode = bswap32(ldl_code(ctx.nip));
} else {
ctx.opcode = ldl_code(ctx.nip);
}
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), little_endian ? "little" : "big");
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP)))
tcg_gen_debug_insn_start(ctx.nip);
ctx.nip += 4;
table = env->opcodes;
num_insns++;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
}
}
if (unlikely(handler->handler == &gen_invalid)) {
if (qemu_log_enabled()) {
qemu_log("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
} else {
printf("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
}
} else {
if (unlikely((ctx.opcode & handler->inval) != 0)) {
if (qemu_log_enabled()) {
qemu_log("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx "\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
} else {
printf("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx "\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
}
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
break;
}
}
(*(handler->handler))(&ctx);
#if defined(DO_PPC_STATISTICS)
handler->count++;
#endif
if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&
ctx.exception != POWERPC_SYSCALL &&
ctx.exception != POWERPC_EXCP_TRAP &&
ctx.exception != POWERPC_EXCP_BRANCH)) {
gen_exception(ctxp, POWERPC_EXCP_TRACE);
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
(env->singlestep_enabled) ||
singlestep ||
num_insns >= max_insns)) {
break;
}
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (ctx.exception == POWERPC_EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
if (unlikely(env->singlestep_enabled)) {
gen_debug_exception(ctxp);
}
tcg_gen_exit_tb(0);
}
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
if (unlikely(search_pc)) {
j = gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
} else {
tb->size = ctx.nip - pc_start;
tb->icount = num_insns;
}
#if defined(DEBUG_DISAS)
qemu_log_mask(CPU_LOG_TB_CPU, "---------------- excp: %04x\n", ctx.exception);
log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0);
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
int flags;
flags = env->bfd_mach;
flags |= ctx.le_mode << 16;
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(pc_start, ctx.nip - pc_start, flags);
qemu_log("\n");
}
#endif
}
| 1threat
|
android studio issue in signing in to an application : I have an issue regarding signing in..!
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
package com.example.myapplication;
import android.app.ProgressDialog;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.HashMap;
public class RegisterActivity extends AppCompatActivity
{
private Button CreateAccountButton;
private EditText InputName, InputPhoneNumber, InputPassword;
private ProgressDialog loadingBar;
FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
CreateAccountButton = (Button) findViewById(R.id.main_register_btn);
InputName = (EditText) findViewById(R.id.register_username_input);
InputPassword = (EditText) findViewById(R.id.register_password_input);
InputPhoneNumber = (EditText) findViewById(R.id.register_phone_number_input);
loadingBar = new ProgressDialog(this);
mAuth = FirebaseAuth.getInstance();
CreateAccountButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
CreateAccount();
}
});
}
private void CreateAccount()
{
String name = InputName.getText().toString();
String phone = InputPhoneNumber.getText().toString();
String password = InputPassword.getText().toString();
if (TextUtils.isEmpty(name))
{
Toast.makeText(this, "please enter your name", Toast.LENGTH_SHORT).show();
}
else if (TextUtils.isEmpty(phone))
{
Toast.makeText(this, "please enter your phone number", Toast.LENGTH_SHORT).show();
}
else if (TextUtils.isEmpty(password))
{
Toast.makeText(this, "please enter your password", Toast.LENGTH_SHORT).show();
}
else
{
loadingBar.setTitle("Create Account");
loadingBar.setMessage("Please wait, While we are checking the credentials");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
validatephonenumber(name, phone, password);
}
}
private void validatephonenumber(final String name, final String phone, final String password)
{
final DatabaseReference RootRef;
RootRef = FirebaseDatabase.getInstance().getReference();
RootRef.addListenerForSingleValueEvent(new ValueEventListener()
{
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{
if(dataSnapshot.child("Users").child(phone).exists())
{ Toast.makeText(RegisterActivity.this, "this" +phone+ "alredy exists", Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
Toast.makeText(RegisterActivity.this, "Please try using another phone number", Toast.LENGTH_SHORT).show();
Intent intent= new Intent(RegisterActivity.this, MainActivity.class);
startActivity(intent);
}
else
{
HashMap<String, Object> userdataMap = new HashMap<>();
userdataMap.put("Phone", phone);
userdataMap.put("password", password);
userdataMap.put("name", name);
RootRef.child("User").child(phone).updateChildren(userdataMap)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task)
{
if (task.isSuccessful())
{
Toast.makeText(RegisterActivity.this, "Congratulations your account has been created ", Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
Intent intent= new Intent(RegisterActivity.this, loginActivity.class);
startActivity(intent);
}
else
{
loadingBar.dismiss();
Toast.makeText(RegisterActivity.this, "Network Error: Please try again", Toast.LENGTH_SHORT).show();
}
}
});
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
}
<!-- end snippet -->
when I'm using this code and signing in with a phone number for second it should actually prompt "this number already exists" but its working and upon siging in with same number again all the older names and passwords are being replpaced by new ones....how can i solve this issue???
| 0debug
|
CSS3 selectors p.para vs. p .para : <p>I read the following, but I don;t fully understand the meaning of these selectors. Could you please provide an example showing the difference between them? Thx.</p>
<p><a href="https://i.stack.imgur.com/Gllss.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gllss.jpg" alt="enter image description here"></a></p>
| 0debug
|
static void palmte_onoff_gpios(void *opaque, int line, int level)
{
switch (line) {
case 0:
printf("%s: current to MMC/SD card %sabled.\n",
__FUNCTION__, level ? "dis" : "en");
break;
case 1:
printf("%s: internal speaker amplifier %s.\n",
__FUNCTION__, level ? "down" : "on");
break;
case 2:
case 3:
case 4:
printf("%s: LCD GPIO%i %s.\n",
__FUNCTION__, line - 1, level ? "high" : "low");
break;
case 5:
case 6:
printf("%s: Audio GPIO%i %s.\n",
__FUNCTION__, line - 4, level ? "high" : "low");
break;
}
}
| 1threat
|
static inline TCGv gen_ld32(TCGv addr, int index)
{
TCGv tmp = new_tmp();
tcg_gen_qemu_ld32u(tmp, addr, index);
return tmp;
}
| 1threat
|
static void sbr_hf_assemble(int Y1[38][64][2],
const int X_high[64][40][2],
SpectralBandReplication *sbr, SBRData *ch_data,
const int e_a[2])
{
int e, i, j, m;
const int h_SL = 4 * !sbr->bs_smoothing_mode;
const int kx = sbr->kx[1];
const int m_max = sbr->m[1];
static const SoftFloat h_smooth[5] = {
{ 715827883, -1 },
{ 647472402, -1 },
{ 937030863, -2 },
{ 989249804, -3 },
{ 546843842, -4 },
};
SoftFloat (*g_temp)[48] = ch_data->g_temp, (*q_temp)[48] = ch_data->q_temp;
int indexnoise = ch_data->f_indexnoise;
int indexsine = ch_data->f_indexsine;
if (sbr->reset) {
for (i = 0; i < h_SL; i++) {
memcpy(g_temp[i + 2*ch_data->t_env[0]], sbr->gain[0], m_max * sizeof(sbr->gain[0][0]));
memcpy(q_temp[i + 2*ch_data->t_env[0]], sbr->q_m[0], m_max * sizeof(sbr->q_m[0][0]));
}
} else if (h_SL) {
for (i = 0; i < 4; i++) {
memcpy(g_temp[i + 2 * ch_data->t_env[0]],
g_temp[i + 2 * ch_data->t_env_num_env_old],
sizeof(g_temp[0]));
memcpy(q_temp[i + 2 * ch_data->t_env[0]],
q_temp[i + 2 * ch_data->t_env_num_env_old],
sizeof(q_temp[0]));
}
}
for (e = 0; e < ch_data->bs_num_env; e++) {
for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
memcpy(g_temp[h_SL + i], sbr->gain[e], m_max * sizeof(sbr->gain[0][0]));
memcpy(q_temp[h_SL + i], sbr->q_m[e], m_max * sizeof(sbr->q_m[0][0]));
}
}
for (e = 0; e < ch_data->bs_num_env; e++) {
for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
SoftFloat g_filt_tab[48];
SoftFloat q_filt_tab[48];
SoftFloat *g_filt, *q_filt;
if (h_SL && e != e_a[0] && e != e_a[1]) {
g_filt = g_filt_tab;
q_filt = q_filt_tab;
for (m = 0; m < m_max; m++) {
const int idx1 = i + h_SL;
g_filt[m].mant = g_filt[m].exp = 0;
q_filt[m].mant = q_filt[m].exp = 0;
for (j = 0; j <= h_SL; j++) {
g_filt[m] = av_add_sf(g_filt[m],
av_mul_sf(g_temp[idx1 - j][m],
h_smooth[j]));
q_filt[m] = av_add_sf(q_filt[m],
av_mul_sf(q_temp[idx1 - j][m],
h_smooth[j]));
}
}
} else {
g_filt = g_temp[i + h_SL];
q_filt = q_temp[i];
}
sbr->dsp.hf_g_filt(Y1[i] + kx, X_high + kx, g_filt, m_max,
i + ENVELOPE_ADJUSTMENT_OFFSET);
if (e != e_a[0] && e != e_a[1]) {
sbr->dsp.hf_apply_noise[indexsine](Y1[i] + kx, sbr->s_m[e],
q_filt, indexnoise,
kx, m_max);
} else {
int idx = indexsine&1;
int A = (1-((indexsine+(kx & 1))&2));
int B = (A^(-idx)) + idx;
int *out = &Y1[i][kx][idx];
int shift, round;
SoftFloat *in = sbr->s_m[e];
for (m = 0; m+1 < m_max; m+=2) {
shift = 22 - in[m ].exp;
if (shift < 32) {
round = 1 << (shift-1);
out[2*m ] += (in[m ].mant * A + round) >> shift;
}
shift = 22 - in[m+1].exp;
if (shift < 32) {
round = 1 << (shift-1);
out[2*m+2] += (in[m+1].mant * B + round) >> shift;
}
}
if(m_max&1)
{
shift = 22 - in[m ].exp;
if (shift < 32) {
round = 1 << (shift-1);
out[2*m ] += (in[m ].mant * A + round) >> shift;
}
}
}
indexnoise = (indexnoise + m_max) & 0x1ff;
indexsine = (indexsine + 1) & 3;
}
}
ch_data->f_indexnoise = indexnoise;
ch_data->f_indexsine = indexsine;
}
| 1threat
|
static mfxIMPL choose_implementation(const InputStream *ist)
{
static const struct {
const char *name;
mfxIMPL impl;
} impl_map[] = {
{ "auto", MFX_IMPL_AUTO },
{ "sw", MFX_IMPL_SOFTWARE },
{ "hw", MFX_IMPL_HARDWARE },
{ "auto_any", MFX_IMPL_AUTO_ANY },
{ "hw_any", MFX_IMPL_HARDWARE_ANY },
{ "hw2", MFX_IMPL_HARDWARE2 },
{ "hw3", MFX_IMPL_HARDWARE3 },
{ "hw4", MFX_IMPL_HARDWARE4 },
};
mfxIMPL impl = MFX_IMPL_AUTO_ANY;
int i;
if (ist->hwaccel_device) {
for (i = 0; i < FF_ARRAY_ELEMS(impl_map); i++)
if (!strcmp(ist->hwaccel_device, impl_map[i].name)) {
impl = impl_map[i].impl;
break;
}
if (i == FF_ARRAY_ELEMS(impl_map))
impl = strtol(ist->hwaccel_device, NULL, 0);
}
return impl;
}
| 1threat
|
DeviceState *pxa2xx_gpio_init(target_phys_addr_t base,
CPUState *env, qemu_irq *pic, int lines)
{
DeviceState *dev;
dev = qdev_create(NULL, "pxa2xx-gpio");
qdev_prop_set_int32(dev, "lines", lines);
qdev_prop_set_int32(dev, "ncpu", env->cpu_index);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[PXA2XX_PIC_GPIO_0]);
sysbus_connect_irq(sysbus_from_qdev(dev), 1, pic[PXA2XX_PIC_GPIO_1]);
sysbus_connect_irq(sysbus_from_qdev(dev), 2, pic[PXA2XX_PIC_GPIO_X]);
return dev;
}
| 1threat
|
programaticaly setting grid width as a string, ie: "auto" or "*", "10", or "*2", or "*3", etc : Here's what i'm trying to do:
XAML:
<local:MegaGrid MegaRow="auto,auto,*">
<Button Grid.Row="0" Content="btn1"/>
<Button Grid.Row="1" Content="btn2"/>
<Button Grid.Row="2" Content="btn3 stretch"/>
</local:MegaGrid>
C#:
public class MegaGrid : Grid
{
private string zMegaRow = "";
public string MegaRow(string RowSetterString)
{
get {return zMegaRow;}
set {
zMegaRow = value;
RowDefinitions.Clear();
string[] items = value.Split(", \t");
foreach (string item in items)
{
RowDefinitions.Add(
**??? How to Convert "value" string into a RowDefinition???**
});
}
}
}
}
What I need to know, is how to call the same String to RowDefinitions converter that the XAML uses to create the RowDefintions object. Except to invoke it from C# instead of from XAML.
| 0debug
|
Filters vs interceptors in web application : <p>I could not get the correct difference between filters and interceptors. So
Please explain me the exact
use of filters and interceptors
in java based web application with some sample snippet.</p>
| 0debug
|
Java library for encoding/decoding audio files, such as mp3 and mp4 : <p>Could you please provide me some non-deprecated java library for usage in maven repository for encoding/decoding audio files, such as mp3 and mp4? </p>
<p>What I need exactly is to convert mp3 to mp4 on the fly and vice versa.</p>
<p>I've found some JAVE (<a href="http://www.sauronsoftware.it/projects/jave/" rel="nofollow">http://www.sauronsoftware.it/projects/jave/</a>), Xuggler (<a href="http://www.xuggle.com/xuggler/" rel="nofollow">http://www.xuggle.com/xuggler/</a>), but seems these projects are no more alive.</p>
| 0debug
|
Modify spellNumber VBA so the words not starts with "one" : My issue is that I want to modify the VBA code of converting numbers to words so I don't want the words to start with "one" for now it's not clear for you let me make it more clear for you:
Current VBA result:
100 One Hundred
1000 One Thousand
Desired VBA result:
100 Hundred
1000 Thousand
Reason: because I want to convert it to Turkish language and in Turkish language it's wrong to say One Hundred "Bir Yüz" the correct in Turkish language is Hundred "Yüz".
So how to perform that I am not that expert person in VBA and I need your help
below is the VBA Code:
Function NumberstoWords(ByVal pNumber)
'Updateby20140220
Dim Dollars
arr = Array("", "", " Thousand ", " Million ", " Billion ", " Trillion ")
pNumber = Trim(Str(pNumber))
xDecimal = InStr(pNumber, ".")
If xDecimal > 0 Then
pNumber = Trim(Left(pNumber, xDecimal - 1))
End If
xIndex = 1
Do While pNumber <> ""
xHundred = ""
xValue = Right(pNumber, 3)
If Val(xValue) <> 0 Then
xValue = Right("000" & xValue, 3)
If Mid(xValue, 1, 1) <> "0" Then
xHundred = GetDigit(Mid(xValue, 1, 1)) & " Hundred "
End If
If Mid(xValue, 2, 1) <> "0" Then
xHundred = xHundred & GetTens(Mid(xValue, 2))
Else
xHundred = xHundred & GetDigit(Mid(xValue, 3))
End If
End If
If xHundred <> "" Then
Dollars = xHundred & arr(xIndex) & Dollars
End If
If Len(pNumber) > 3 Then
pNumber = Left(pNumber, Len(pNumber) - 3)
Else
pNumber = ""
End If
xIndex = xIndex + 1
Loop
NumberstoWords = Dollars
End Function
Function GetTens(pTens)
Dim Result As String
Result = ""
If Val(Left(pTens, 1)) = 1 Then
Select Case Val(pTens)
Case 10: Result = "Ten"
Case 11: Result = "Eleven"
Case 12: Result = "Twelve"
Case 13: Result = "Thirteen"
Case 14: Result = "Fourteen"
Case 15: Result = "Fifteen"
Case 16: Result = "Sixteen"
Case 17: Result = "Seventeen"
Case 18: Result = "Eighteen"
Case 19: Result = "Nineteen"
Case Else
End Select
Else
Select Case Val(Left(pTens, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
Case 4: Result = "Forty "
Case 5: Result = "Fifty "
Case 6: Result = "Sixty "
Case 7: Result = "Seventy "
Case 8: Result = "Eighty "
Case 9: Result = "Ninety "
Case Else
End Select
Result = Result & GetDigit(Right(pTens, 1))
End If
GetTens = Result
End Function
Function GetDigit(pDigit)
Select Case Val(pDigit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four"
Case 5: GetDigit = "Five"
Case 6: GetDigit = "Six"
Case 7: GetDigit = "Seven"
Case 8: GetDigit = "Eight"
Case 9: GetDigit = "Nine"
Case Else: GetDigit = ""
End Select
End Function
Thanks
| 0debug
|
void bdrv_register(BlockDriver *bdrv)
{
if (!bdrv->bdrv_co_readv) {
bdrv->bdrv_co_readv = bdrv_co_readv_em;
bdrv->bdrv_co_writev = bdrv_co_writev_em;
if (!bdrv->bdrv_aio_readv) {
bdrv->bdrv_aio_readv = bdrv_aio_readv_em;
bdrv->bdrv_aio_writev = bdrv_aio_writev_em;
} else if (!bdrv->bdrv_read) {
bdrv->bdrv_read = bdrv_read_em;
bdrv->bdrv_write = bdrv_write_em;
}
}
if (!bdrv->bdrv_aio_flush)
bdrv->bdrv_aio_flush = bdrv_aio_flush_em;
QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list);
}
| 1threat
|
Algorithm for merging spatially close paths / line segments : <p>I am looking for (the name of) a geometric algorithm for cartographic generalization of a street map.</p>
<p>In my map data, I have many paths (ordered list of points, connected by line segments) that lay close and almost parallel to one another. How do I <strong>(1)</strong> identify these “adjacent pathsˮ (i.e. how to find paths that are closer than a certain threshold) and <strong>(2)</strong> merge them into one path (i.e. how to compute the centerline between close paths)?</p>
<p>As an example, consider the following graph of roads / lanes of roads created with data from OpenStreetMaps:</p>
<p><a href="https://i.stack.imgur.com/9pkTC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9pkTC.png" alt="Graph of a road network, consisting of three horizontal lines running across the image almost in parallel and one vertical line intersecting them in the middle"></a></p>
<p>As you can see, the two lanes of the road running horizontally are modeled as two separate paths. For detail views this is useful, but for a more zoomed out view I need to merge the two paths (lanes) to display only one line for the road.</p>
<p>What are the established algorithms used in map renderers to achieve this? Obviously, Google Maps, OSM, etc. do this -- how?</p>
| 0debug
|
Rust external library macro : I have a project tree like this:
main.rs:
external crate lib;
mod a;
fn main() {
a::some_func();
}
a.rs:
use lib;
fn some_func() {
lib::func();
}
this works ok.
but when i try to use a macro from 'lib', it gives me an error of macro undefined.
I tried putting #[macro_use] in front of the 'external crate lib', then i get a lot of unresolved errors inside of the external crate. And i have already looked inside of the external crate, there is nothing wrong. Also, the fact that i can use functions from the library kinda proves (to me, im a rust noob) that the library is ok, and i'm doing something wrong.
| 0debug
|
How to use jQuery with rails webpacker 3 : <p>I generate a new rails app :
<code>
rails new titi --webpack=vue
</code></p>
<p>and would like to use jQuery (or other libs like popper, vue-resource...).</p>
<p>I tried to <code>yarn add jquery</code>which was fine, but I don't have access to jQuery in my JavaScript code.</p>
<p>In previous Webpacker gem, there was much more conf and I had to write this in <code>shared.js</code> :</p>
<pre><code>module.exports = {
...
plugins: [
...
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
]
...
resolve: {
extensions: settings.extensions,
modules: [
resolve(settings.source_path),
'node_modules'
],
alias: {
jquery: "jquery/src/jquery",
vue: "vue/dist/vue.js",
vue_resource: "vue-resource/dist/vue-resource",
}
}
</code></pre>
<p>What is the cleanest way to include libraries in current Webpacker version ? Something in <code>config/webpacker.yml</code>? </p>
| 0debug
|
Use Conda environment in pycharm : <p>Conda env is activated using <strong>source activate env_name</strong>. </p>
<p>How can I activate the environment in pycharm ?</p>
| 0debug
|
How to calculate count and percentage of total for each rank using pandas : I have a data set with a column called ratings from 1 to 5. The result should be as follows:
Rating Count Count %
1 10 6.66%
2 20 13.33%
3 30 20.00%
4 40 26.66%
5 50 33.33%
Total Ratings: 150
(1) All percentages should be approximated in 2 decimal places
(2) The result should be in a data frame with column names - Rating, Count & Count%
How to get this result using pandas?
| 0debug
|
Excel Cell Range Name Clears After Saving File : I have a problem regarding excel cell range. So I have an excel file containing cell ranges but when I save it and reopened the same file some cell ranges were missing. I have tried "save as" but still same results. I have also searched but still no luck. Hope someone helps me. Thank you in advanced. I'm losing time figuring it out. Any help would be really appreciated!
| 0debug
|
Tensorflow apply op to each element of a 2d tensor : <p>What I'm after is the ability to apply a tensorflow op to each element of a 2d tensor e.g.</p>
<pre><code>input = tf.Variable([[1.0, 2.0], [3.0, 4.0])
myCustomOp = ... # some kind of custom op that operates on 1D tensors
finalResult = tf.[thing I'm after](input, myCustomOp)
# when run final result should look like: [myCustomOp([1.0, 2.0]), myCustomOp([3.0, 4.0)]
</code></pre>
<p>Any ideas?</p>
| 0debug
|
how can i add value in different variable after clicking + in javascript : document.querySelector('.buttons').addEventListener('click',function(e) {
var targetElement = event.target || event.srcElement;
var selectednumber=targetElement.dataset.number;
var element = document.getElementById('display');
element.value +=selectednumber;
oldvalue=element.value;
console.log("in old :"+ oldvalue);
if(targetElement.dataset.number==='+'){
//after click of +
var element=document.getElementById('display');
newvalue=oldvalue;
console.log("i ma new "+newvalue);
console.log(newvalue);
}
if (targetElement.dataset.number==="=") {
sum=oldvalue+newvalue;
| 0debug
|
how to add circle ImagView to the left side of button : [how to add circle ImagView to the left side of button similar like this][1]
[1]: https://i.stack.imgur.com/QPnxW.jpg
| 0debug
|
static void test_validate_fail_struct(TestInputVisitorData *data,
const void *unused)
{
TestStruct *p = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo', 'extra': 42 }");
visit_type_TestStruct(v, NULL, &p, &err);
error_free_or_abort(&err);
g_assert(!p);
}
| 1threat
|
void qemu_sem_post(QemuSemaphore *sem)
{
int rc;
#if defined(__APPLE__) || defined(__NetBSD__)
pthread_mutex_lock(&sem->lock);
if (sem->count == INT_MAX) {
rc = EINVAL;
} else if (sem->count++ < 0) {
rc = pthread_cond_signal(&sem->cond);
} else {
rc = 0;
}
pthread_mutex_unlock(&sem->lock);
if (rc != 0) {
error_exit(rc, __func__);
}
#else
rc = sem_post(&sem->sem);
if (rc < 0) {
error_exit(errno, __func__);
}
#endif
}
| 1threat
|
Search for code in GitHub using GraphQL (v4 API) : <p>I am using the GitHub's GraphQL API to search for files/code containing a particular word. A simple (contrived) example of a search which in this case is to find the term "beef" in files located in "recipes" (the repo) for "someuser" (the owner for the repo) is shown below:</p>
<pre><code>{
search(query: "beef repo:someuser/recipes", type: REPOSITORY, first: 10) {
repositoryCount
edges {
node {
... on Repository {
name
}
}
}
}
}
</code></pre>
<p>I tried this in GitHub's GraphQL Explorer (<a href="https://developer.github.com/v4/explorer/" rel="noreferrer">https://developer.github.com/v4/explorer/</a>) and receive zero results from the search which is incorrect as I can confirm that the word ("beef" in the example above) is in the files in the repo:</p>
<pre><code>{
"data": {
"search": {
"repositoryCount": 0,
"edges": []
}
}
}
</code></pre>
<p>When I try this using GitHub's REST API (v3) via curl, I definitely get results:</p>
<pre><code>curl --header 'Accept: application/vnd.github.v3.raw' https://api.github.com/search/code?q=beef+repo:someuser/recipes
</code></pre>
<p>... So I know that the query (REST v3 API) is valid, and my understanding is that the query string in the GraphQL (v4) API is identical to that for the REST (v3) API.</p>
<p>My questions are:</p>
<ol>
<li>Am I incorrectly using the GitHub GraphQL (v4) API or am I specifying the query string improperly, or am I trying to use functionality that is not yet supported?</li>
<li>Is there an example of how to do this that someone can provide (or link to) that illustrates how to search code for specific words?</li>
</ol>
| 0debug
|
void vnc_client_write(void *opaque)
{
VncState *vs = opaque;
vnc_lock_output(vs);
if (vs->output.offset
#ifdef CONFIG_VNC_WS
|| vs->ws_output.offset
#endif
) {
vnc_client_write_locked(opaque);
} else if (vs->csock != -1) {
qemu_set_fd_handler(vs->csock, vnc_client_read, NULL, vs);
}
vnc_unlock_output(vs);
}
| 1threat
|
JS limit the number of decimal places in a number : <p>I have a js that grabs values, multiplies, sums, divides, and then puts them in a cell of a table. The result can be up to (I think) 15 decimal places. How do I limit it to two?</p>
<p>ex.:
Result of math operation: 5.223567
I want: 5.22</p>
<p>I want to truncate or round the remaining decimal places. I am open to solutions that requires resources outside of js but would prefer a js solution if one exists. </p>
| 0debug
|
void ff_cavs_mv(AVSContext *h, enum cavs_mv_loc nP, enum cavs_mv_loc nC,
enum cavs_mv_pred mode, enum cavs_block size, int ref)
{
cavs_vector *mvP = &h->mv[nP];
cavs_vector *mvA = &h->mv[nP-1];
cavs_vector *mvB = &h->mv[nP-4];
cavs_vector *mvC = &h->mv[nC];
const cavs_vector *mvP2 = NULL;
mvP->ref = ref;
mvP->dist = h->dist[mvP->ref];
if (mvC->ref == NOT_AVAIL || (nP == MV_FWD_X3) || (nP == MV_BWD_X3 ))
mvC = &h->mv[nP - 5];
if (mode == MV_PRED_PSKIP &&
(mvA->ref == NOT_AVAIL ||
mvB->ref == NOT_AVAIL ||
(mvA->x | mvA->y | mvA->ref) == 0 ||
(mvB->x | mvB->y | mvB->ref) == 0)) {
mvP2 = &un_mv;
} else if (mvA->ref >= 0 && mvB->ref < 0 && mvC->ref < 0) {
mvP2 = mvA;
} else if (mvA->ref < 0 && mvB->ref >= 0 && mvC->ref < 0) {
mvP2 = mvB;
} else if (mvA->ref < 0 && mvB->ref < 0 && mvC->ref >= 0) {
mvP2 = mvC;
} else if (mode == MV_PRED_LEFT && mvA->ref == ref) {
mvP2 = mvA;
} else if (mode == MV_PRED_TOP && mvB->ref == ref) {
mvP2 = mvB;
} else if (mode == MV_PRED_TOPRIGHT && mvC->ref == ref) {
mvP2 = mvC;
}
if (mvP2) {
mvP->x = mvP2->x;
mvP->y = mvP2->y;
} else
mv_pred_median(h, mvP, mvA, mvB, mvC);
if (mode < MV_PRED_PSKIP) {
mvP->x += get_se_golomb(&h->gb);
mvP->y += get_se_golomb(&h->gb);
}
set_mvs(mvP, size);
}
| 1threat
|
what are ( Angular, Node.js, AJAX, JQuery)? : <p>I really have a hard time to distinguish between all those frameworks, libraries or API I don't know, and how they related to each if they do.</p>
| 0debug
|
How to plot three sets of comparative data in R : <p>I have this dataframe called <code>mydf</code> where I have column <code>Gene_symbol</code> and three different columns (cancers), <code>AML</code>,<code>CLL</code>,<code>MDS</code>. I want to plot the percentage of each gene in these cancers. What would be the good way to represent this in plot?</p>
<pre><code>mydf <- structure(list(GENE_SYMBOL = c("NPM1", "DNMT3A", "TET2", "IDH1",
"IDH2"), AML = c("28.00%", "24.00%", "8.00%", "9.00%", "10.00%"
), CLL = c("0.00%", "8.00%", "0.00%", "3.00%", "1.00%"), MDS = c("7.00%",
"28.00%", "7.00%", "10.00%", "3.00%")), .Names = c("GENE_SYMBOL",
"AML", "CLL", "MDS"), row.names = c(NA, 5L), class = "data.frame")
</code></pre>
| 0debug
|
Why True != True != True is False. : If explanation given in python then will be very much help full.
True != True is false
False != True should be true. Please correct me where i am doing wrong.
| 0debug
|
static int xen_pt_msgctrl_reg_write(XenPCIPassthroughState *s,
XenPTReg *cfg_entry, uint16_t *val,
uint16_t dev_value, uint16_t valid_mask)
{
XenPTRegInfo *reg = cfg_entry->reg;
XenPTMSI *msi = s->msi;
uint16_t writable_mask = 0;
uint16_t throughable_mask = 0;
uint16_t raw_val;
if (*val & PCI_MSI_FLAGS_QSIZE) {
XEN_PT_WARN(&s->dev, "Tries to set more than 1 vector ctrl %x\n", *val);
}
writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask;
cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask);
msi->flags |= cfg_entry->data & ~PCI_MSI_FLAGS_ENABLE;
raw_val = *val;
throughable_mask = ~reg->emu_mask & valid_mask;
*val = XEN_PT_MERGE_VALUE(*val, dev_value, throughable_mask);
if (raw_val & PCI_MSI_FLAGS_ENABLE) {
if (!msi->initialized) {
XEN_PT_LOG(&s->dev, "setup MSI\n");
if (xen_pt_msi_setup(s)) {
*val &= ~PCI_MSI_FLAGS_ENABLE;
XEN_PT_WARN(&s->dev, "Can not map MSI.\n");
return 0;
}
if (xen_pt_msi_update(s)) {
*val &= ~PCI_MSI_FLAGS_ENABLE;
XEN_PT_WARN(&s->dev, "Can not bind MSI\n");
return 0;
}
msi->initialized = true;
msi->mapped = true;
}
msi->flags |= PCI_MSI_FLAGS_ENABLE;
} else {
msi->flags &= ~PCI_MSI_FLAGS_ENABLE;
}
*val &= ~PCI_MSI_FLAGS_ENABLE;
*val |= raw_val & PCI_MSI_FLAGS_ENABLE;
return 0;
}
| 1threat
|
How to find /dev/ name of USB Device for Serial Reading on Mac OS? : <p>I am trying to plug in a device into my Macbook and connect to it to read it's serial port. I know the device connects on baudrate 115200.</p>
<p>Currently, I run the command</p>
<p><code>ioreg -p IOUSB -l -b | grep -E "@|PortNum|USB Serial Number"</code></p>
<p>I can see the embedded device plugged in</p>
<pre><code>+-o Root Hub Simulation Simulation@14000000
| +-o iBridge@14200000
| | "PortNum" = 2
| +-o USB2.0 Hub@14100000
| | "PortNum" = 1
| +-o 4-Port USB 2.0 Hub@14120000
| | | "PortNum" = 2
| | +-o MBED CMSIS-DAP@14122000
| | "PortNum" = 2
| | "USB Serial Number" = "024002267822ce0a00000000000000000000000085fb33b2"
| +-o USB Keyboard @14110000
| "PortNum" = 1
| "USB Serial Number" = "0000000000000001"
</code></pre>
<p><strong>note:</strong> There's a tag close to </p>
<p><code><class AppleUSBDevice, id 0x100014343, registered, matched, active, busy 0 (363 ms), retain 33></code> </p>
<p>next to every device's name above, but I removed them for formatting issues (as I don't think they're related to the question). In the event they are, that is the tag for my embedded device).</p>
<p><strong>The Question</strong></p>
<p>How would I find out the MBED device's association in /dev/?</p>
<p>I am trying to find the device <code>MBED CMSIS-DAP@14122000</code> inside the /dev/ directory, so that I can read its serial output. This is where I am lost. </p>
<p>The end goal is that I could use <code>screen</code> or <code>putty</code> or something similar to:</p>
<p><code>screen /dev/ttyTHIS_MBED_DEVICE 115200</code></p>
| 0debug
|
Javascript .animate() not working in HTML page : As simple as it is, I am wondering how is it possible that my little div is not getting any bigger. Anyone knows why?
(p.s. I've tried to run it on every browser and i really can't find any syntax errors, I'm getting blind.. or just older)
<!DOCTYPE html>
<html>
<head>
<script>
$(document).ready(function () {
$(document.getElementById("abc").animate({
height:"500px",
width:"500px",
}, 5000, function() {
// Animation complete.
});
});
</script>
<style>
#abc {
border:1px solid green;
width: 100px;
height:100px;
}
</style>
</head>
<body>
<div id="abc"></div>
</body>
</html>
| 0debug
|
How to bind params in PDO when using OOP : I am using OOP for my project and PDO. I have a class, in that class, I have a method
like this:
public function insert($fields){
//$fields is the array containing key and values like this
// $fields['name'=>'name_field','city'=>'city_field'];
//INSERT INTO table_name (name,city) VALUES (':name',':city')
$sql = "";
$sql .= "INSERT INTO table_name (".implode(',', array_keys($fields)).") VALUES ";
$sql .= "(':".implode("',':", array_keys($fields)).")";
$stmt = $this->connect()->prepare($sql);
//so here how can I bind parameters??
$stmtExec = $stmt->execute();
}
| 0debug
|
int bdrv_is_sg(BlockDriverState *bs)
{
return bs->sg;
}
| 1threat
|
Countdown timer decrements in a delayed manner? : <p>I've been working on a game; in which one of the main components is a countdown timer- however this timer is delayed and I am not able to deduce why. I would like it to decrement once per second, however it seems to be decrementing at once every 6 seconds.</p>
<p>Here is how I have the timer set up:</p>
<pre><code>loops = 0
minute = 1
tens = 0
ones = 0
#Timer Calculation
screen.blit(cloudSky, (0,0))
if go == True:
loops = loops + 1
if (loops % 60)== 0:
if ones == 0 and tens == 0 and minute != 0:
tens = 6
ones = 0
minute = minute - 1
if ones == 0 and tens != 0:
ones = 9
tens = tens - 1
elif ones != 0:
ones = ones - 1
elif tens == 0 and ones == 0:
tens = 5
minute = minute - 1
elif ones == 0 and tens != 0:
tens = tens - 1
if minute <= 0 and tens == 0 and ones == 0:
go = False
</code></pre>
<p>I print it on the screen with the code below: </p>
<pre><code>#Draw Clock Time
time = timeFont.render(str (minute)+ ":" + str (tens) + str (ones), True, WHITE)
screen.blit(time, (750,10))
</code></pre>
<p>Any help is greatly appreciated!</p>
| 0debug
|
static VirtIOSerialPort *find_port_by_name(char *name)
{
VirtIOSerial *vser;
QLIST_FOREACH(vser, &vserdevices.devices, next) {
VirtIOSerialPort *port;
QTAILQ_FOREACH(port, &vser->ports, next) {
if (!strcmp(port->name, name)) {
return port;
}
}
}
return NULL;
}
| 1threat
|
Pyhton - Functions using Dictionary name and Key as argument : qualifier_2 = {'KKR' : {'Chris Lynn': 4,
'Sunil Narine': 10,
'Gautam Gambhir (c)': 12,
'Robin Uthappa (wk)': 1,
'Ishank Jaggi': 28,
'Colin Grandhomme': 0,
'Suryakumar Yadav': 31,
'Piyush Chawla': 2,
'Nathan Coulter-Nile': 6,
'Umesh Yadav': 2,
'Ankit Rajpoot': 4,
'Extra runs': 7,
'Total batted': 10},
'MI': {'Lendl Simmons': 3,
'Parthiv Patel (wk)': 14,
'Ambati Rayudu': 6,
'Rohit Sharma (c)': 26,
'Krunal Pandya': 45,
'Kieron Pollard': 9,
'Extra runs': 8,
'Total batted': 6}}
I want to write a function that takes dictionary and team as an argument and returns the total runs
i.e Dictionary -> qualifier_2 and Team -> KKR/MI
| 0debug
|
How to add Conditional CSS class based on Python If statement : <p>How do you add a conditional CSS class based on a Python if statement in the following example to show the <code>has-success has-feedback</code> form element?</p>
<pre><code><div class="form-group {% if not error_username %} has-success has-feedback {% endif %}">
</code></pre>
| 0debug
|
Converting an method from objective c to swift : <p>Hi guys how can i convert this code into swift.</p>
<pre><code> (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC
{
}
</code></pre>
<p>I have been trying to figure it out but cant.</p>
<p>Thanks in advance
Aryan</p>
| 0debug
|
m_get(Slirp *slirp)
{
register struct mbuf *m;
int flags = 0;
DEBUG_CALL("m_get");
if (slirp->m_freelist.m_next == &slirp->m_freelist) {
m = (struct mbuf *)malloc(SLIRP_MSIZE);
if (m == NULL) goto end_error;
slirp->mbuf_alloced++;
if (slirp->mbuf_alloced > MBUF_THRESH)
flags = M_DOFREE;
m->slirp = slirp;
} else {
m = slirp->m_freelist.m_next;
remque(m);
}
insque(m,&slirp->m_usedlist);
m->m_flags = (flags | M_USEDLIST);
m->m_size = SLIRP_MSIZE - sizeof(struct m_hdr);
m->m_data = m->m_dat;
m->m_len = 0;
m->m_nextpkt = NULL;
m->m_prevpkt = NULL;
end_error:
DEBUG_ARG("m = %lx", (long )m);
return m;
}
| 1threat
|
static inline void RENAME(rgb32to15)(const uint8_t *src, uint8_t *dst, unsigned src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
mm_end = end - 15;
#if 1
asm volatile(
"movq %3, %%mm5 \n\t"
"movq %4, %%mm6 \n\t"
"movq %5, %%mm7 \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 32(%1) \n\t"
"movd (%1), %%mm0 \n\t"
"movd 4(%1), %%mm3 \n\t"
"punpckldq 8(%1), %%mm0 \n\t"
"punpckldq 12(%1), %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm3, %%mm4 \n\t"
"pand %%mm6, %%mm0 \n\t"
"pand %%mm6, %%mm3 \n\t"
"pmaddwd %%mm7, %%mm0 \n\t"
"pmaddwd %%mm7, %%mm3 \n\t"
"pand %%mm5, %%mm1 \n\t"
"pand %%mm5, %%mm4 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"psrld $6, %%mm0 \n\t"
"pslld $10, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, (%0) \n\t"
"add $16, %1 \n\t"
"add $8, %0 \n\t"
"cmp %2, %1 \n\t"
" jb 1b \n\t"
: "+r" (d), "+r"(s)
: "r" (mm_end), "m" (mask3215g), "m" (mask3216br), "m" (mul3215)
);
#else
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_15mask),"m"(green_15mask));
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psrlq $3, %%mm0\n\t"
"psrlq $3, %%mm3\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm3\n\t"
"psrlq $6, %%mm1\n\t"
"psrlq $6, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $9, %%mm2\n\t"
"psrlq $9, %%mm5\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_15mask):"memory");
d += 4;
s += 16;
}
#endif
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
const int src= *s; s += 4;
*d++ = ((src&0xFF)>>3) + ((src&0xF800)>>6) + ((src&0xF80000)>>9);
}
}
| 1threat
|
How do you debug an Angular 6 library : <p>I'm writing an Angular 6 Library and cannot figure out how to step into the typescript.</p>
<p>I generated the app using: <code>ng new mylibapp</code></p>
<p>I then added the library using: <code>ng g library @abc/cool-lib -p abc</code></p>
<p>when I perform: <code>ng build @abc/cool-lib</code></p>
<p>it generates the code in the <code>mylibapp/dist/abc/cool-lib</code> folder</p>
<p>How can I now debug this code and set breakpoints in the ts file located at <code>mylibapp/projects/abc/cool-lib/src/lib</code></p>
| 0debug
|
static av_cold int svq1_encode_end(AVCodecContext *avctx)
{
SVQ1EncContext *const s = avctx->priv_data;
int i;
av_log(avctx, AV_LOG_DEBUG, "RD: %f\n",
s->rd_total / (double)(avctx->width * avctx->height *
avctx->frame_number));
s->m.mb_type = NULL;
ff_mpv_common_end(&s->m);
av_freep(&s->m.me.scratchpad);
av_freep(&s->m.me.map);
av_freep(&s->m.me.score_map);
av_freep(&s->mb_type);
av_freep(&s->dummy);
av_freep(&s->scratchbuf);
for (i = 0; i < 3; i++) {
av_freep(&s->motion_val8[i]);
av_freep(&s->motion_val16[i]);
}
av_frame_free(&s->current_picture);
av_frame_free(&s->last_picture);
av_frame_free(&avctx->coded_frame);
return 0;
}
| 1threat
|
How do I combine multiple OpenAPI 3 specification files together? : <p>I want to combine an API specification written using the OpenAPI 3 spec, that is currently divided into multiple files that reference each other using <code>$ref</code>. How can I do that?</p>
| 0debug
|
Unexpected && T_BOOLEAN_AND with username and password form - PHP : <p>So I've got a very simple html page which uses a post php method to send the username and password to the php script. However I get the error: unexpected '&&' (T_BOOLEAN_AND) when the details are passed to the script. Any ideas why?</p>
<p>Here's the html form: </p>
<pre><code><form action="login.php" method="post">
<p> Username: </p>
<input type="text" name="username"/>
<p> Password: </p>
<input type="text" name="password"/>
<input type="submit" value="Submit"/>
</form>
</code></pre>
<p></p>
<p>And here is the login.php script:</p>
<pre><code> <?php
if ($_POST["username"] == "t5" ) &&
($_POST["password"] == "just4fun") {
session_start();
$_SESSION[‘username’] = true;
header('Location menu.php');
}
else { header('Location loginform.html') }
?>
</code></pre>
<p>Thanks in advance.</p>
| 0debug
|
S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id, Error **errp)
{
S390CPU *cpu = S390_CPU(object_new(typename));
Error *err = NULL;
object_property_set_int(OBJECT(cpu), core_id, "core-id", &err);
if (err != NULL) {
goto out;
}
object_property_set_bool(OBJECT(cpu), true, "realized", &err);
out:
if (err) {
error_propagate(errp, err);
object_unref(OBJECT(cpu));
cpu = NULL;
}
return cpu;
}
| 1threat
|
"app keep stopping" why cant i run my app? : My app keeps stopping when I open the emulator when it opens.
tried putting in a different application only the first screen and class and still stopped.
its shows:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.dearpet, PID: 31496
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.dearpet/com.example.dearpet.MainActivity}: java.lang.InstantiationException: java.lang.Class<com.example.dearpet.MainActivity> cannot be instantiated
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2839)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.InstantiationException: java.lang.Class<com.example.dearpet.MainActivity> cannot be instantiated
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1180)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2829)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Application terminated.
| 0debug
|
static void adb_kbd_reset(DeviceState *dev)
{
ADBDevice *d = ADB_DEVICE(dev);
KBDState *s = ADB_KEYBOARD(dev);
d->handler = 1;
d->devaddr = ADB_DEVID_KEYBOARD;
memset(s->data, 0, sizeof(s->data));
s->rptr = 0;
s->wptr = 0;
s->count = 0;
}
| 1threat
|
Next.js: fetching data in getInitialProps(): server-side vs client-side : <p>I'm using Next.js, and I have a custom server using Express. I have a page that requires some data from the database.</p>
<p><code>getInitialProps()</code>, when running on the server, could just grab the data from the database and return it, without any problems.
However, <code>getInitialProps()</code> can also run on the client side (when the user initially requests a different page, then navigates to this one). In that case, since I'm on the client side, I obviously can't just fetch the data from the database - I have to use AJAX to talk to the server and ask it to retrieve it for me.</p>
<p>Of course, this also means that I have define a new Express route on the server to handle this request, which will contain exactly the same code as the server-side part of <code>getInitialProps()</code>, which is very undesirable.</p>
<p>What's the best way to handle this?</p>
| 0debug
|
C the Heap using in Fuctions still not clear : <p>I'm still confused about the errors that I get while compiling to solve my code. I tried to make two simple functions. One that initialize an array and put 0 in every index and the other that prints that function out.</p>
<p>Following code:</p>
<pre class="lang-c prettyprint-override"><code>#include <stdio.h>
#include <stdlib.h>
int arraybuilder(int len)
{
int *array;
array = (int*) malloc(len * sizeof(int));
for(int i = 0; i<len; i++)
{
array[i] = 0;
}
free(array);
return array;
}
void printarray(int array[], int len)
{
for(int i = 0; i < len; i++)
{
printf("array[%d] = %d\n", i, array[i]);
}
}
int main(int argc, char* argv[])
{
int len = 100;
int *array = arraybuilder(len);
printarray(array, len);
return 0;
}
</code></pre>
<p>></p>
<blockquote>
<p>malloctest.c: In function ‘arraybuilder’:
malloctest.c:15:9: warning: return makes integer from pointer without a cast [-Wint-conversion]
return array;
^</p>
</blockquote>
<p>And:</p>
<blockquote>
<p>malloctest.c: In function ‘main’:
malloctest.c:31:15: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
int *array = arraybuilder(len);</p>
</blockquote>
<p>Thank you in advance for the help :)</p>
| 0debug
|
How to relate two sql table : Hi I have two tables cars and owners . ownerno is the primary key in table owners. I would like to know how I can put ownerno as foreign key in cars table and still insert values that are different from my first table
cars
REGNO MAKE COLOUR PRICE OWNERNO
KAA462J FORD RED 120000 824
KAB230Q SKODA BLUE 110000 828
KAV201W MERCEDES BLUE 220000 832
KAA306T TOYOTA BLUE 130000 836
Owners
OWNERNO OWNERNAME OWNERADDRESS
724 Atieno Otieno 567 Umoja
828 Hassan Hussein 987 Kayole
932 Wanjiru Wanjiri 735 Kariobangi
| 0debug
|
CharDriverState *qemu_chr_open_msmouse(void)
{
CharDriverState *chr;
chr = g_malloc0(sizeof(CharDriverState));
chr->chr_write = msmouse_chr_write;
chr->chr_close = msmouse_chr_close;
chr->explicit_be_open = true;
qemu_add_mouse_event_handler(msmouse_event, chr, 0, "QEMU Microsoft Mouse");
return chr;
}
| 1threat
|
static void bonito_spciconf_writew(void *opaque, target_phys_addr_t addr,
uint32_t val)
{
PCIBonitoState *s = opaque;
PCIDevice *d = PCI_DEVICE(s);
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
uint32_t pciaddr;
uint16_t status;
DPRINTF("bonito_spciconf_writew "TARGET_FMT_plx" val %x\n", addr, val);
assert((addr & 0x1) == 0);
pciaddr = bonito_sbridge_pciaddr(s, addr);
if (pciaddr == 0xffffffff) {
return;
}
phb->config_reg = (pciaddr) | (1u << 31);
pci_data_write(phb->bus, phb->config_reg, val, 2);
status = pci_get_word(d->config + PCI_STATUS);
status &= ~(PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT);
pci_set_word(d->config + PCI_STATUS, status);
}
| 1threat
|
Manually constructing a trivial base class via placement-new : <p><em>Beware, we're skirting the dragon's lair.</em></p>
<p>Consider the following two classes:</p>
<pre><code>struct Base {
std::string const *str;
};
struct Foo : Base {
Foo() { std::cout << *str << "\n"; }
};
</code></pre>
<p>As you can see, I'm accessing an uninitialized pointer. Or am I?</p>
<p>Let's assume I'm only working with <code>Base</code> classes that are <a href="http://en.cppreference.com/w/cpp/types/is_trivial" rel="noreferrer">trivial</a>, nothing more than (potentially nested) bags of pointers.</p>
<pre><code>static_assert(std::is_trivial<Base>{}, "!");
</code></pre>
<p>I would like to construct <code>Foo</code> in three steps:</p>
<ol>
<li><p>Allocate raw storage for a <code>Foo</code></p></li>
<li><p>Initialize a suitably-placed <code>Base</code> subobject via placement-new</p></li>
<li><p>Construct <code>Foo</code> via placement-new.</p></li>
</ol>
<p>My implementation is as follows:</p>
<pre><code>std::unique_ptr<Foo> makeFooWithBase(std::string const &str) {
static_assert(std::is_trivial<Base>{}, "!");
// (1)
auto storage = std::make_unique<
std::aligned_storage_t<sizeof(Foo), alignof(Foo)>
>();
Foo * const object = reinterpret_cast<Foo *>(storage.get());
Base * const base = object;
// (2)
new (base) Base{&str};
// (3)
new (object) Foo();
storage.release();
return std::unique_ptr<Foo>{object};
}
</code></pre>
<p>Since <code>Base</code> is trivial, my understanding is that:</p>
<ul>
<li><p>Skipping the trivial destructor of the <code>Base</code> constructed at <code>(2)</code> is fine;</p></li>
<li><p>The trivial default constructor of the <code>Base</code> subobject constructed as part of the <code>Foo</code> at <code>(3)</code> does nothing;</p></li>
</ul>
<p>And so <code>Foo</code> receives an initialized pointer, and all is well.</p>
<p>Of course, this is what happens in practice, even at -O3 (<a href="http://coliru.stacked-crooked.com/a/44ecfa3329cf6226" rel="noreferrer">see for yourself!</a>).<br>
But is it safe, or will the dragon snatch and eat me one day?</p>
| 0debug
|
How can I change the height of the ListView item(UWP) that is clicked? Like Mail App does : I have created a simple ListView item in XAML and I want to change height of Item that is clicked, like the Mail app does in Windows. And also please don't suggest method that require MMVM, cos I am new to devloping.
| 0debug
|
Auto update chat system : <p>I am trying to auto update my chat system whenever a user
Types a message but there are no good tutorials on YouTube i can update when a user starts typing but i want it to be live ive tried:
Infinite loops (page crashed) and
When a user Types update (i want it live)</p>
<p>And my page crashed.
I have access to jquery ajax and built in JavaScript ajax.
Thank you.</p>
| 0debug
|
When should I use `publishReplay` vs `shareReplay`? : <p>I already know that</p>
<ul>
<li><p><code>publish</code> shares a single subscription and also returns a <code>ConnectableObservable</code> ( so we have to <code>Connect()</code>)</p></li>
<li><p><code>Share()</code> is <code>publish().refcount()</code></p></li>
</ul>
<p>The <code>Replay</code> postfix is pretty obvious , it returns its last emission/s.</p>
<p>Let's take for example an Angular http request with present AND future subscription :</p>
<pre><code><p>{{ (person | async)?.id }}</p> //present markup
<p *ngIf=”show”>{{ (person | async)?.userId }}</p> //future markup
</code></pre>
<p>If I don't want multiple <code>http</code> requests I can use : </p>
<p><code>publishReplay().Connect()</code></p>
<p>But I can also use : <code>shareReplay()</code> , but I'm sure that there is one here that is more correct to use than the other.</p>
<p><strong>Question :</strong></p>
<p>When should I use <code>publishReplay</code> vs <code>shareReplay</code> ? What will be the difference in terms of that Http present & future request ?</p>
<p><sub>NB
Why there's not documentation about <code>shareReplay</code> ?
</sub></p>
| 0debug
|
static void kill_channel(DBDMA_channel *ch)
{
DBDMA_DPRINTF("kill_channel\n");
ch->regs[DBDMA_STATUS] |= cpu_to_be32(DEAD);
ch->regs[DBDMA_STATUS] &= cpu_to_be32(~ACTIVE);
qemu_irq_raise(ch->irq);
}
| 1threat
|
tslint-loader with webpack 2.1.0-beta.25 : <p>I have an angular2 Project that I compress/compile with webpack.</p>
<p>I use tslink loader with webpack so I have tslint related configuration in <code>webpack.config.js</code>.</p>
<pre><code>module.exports = {
...
tslint: {
configuration: {
rules: {
quotemark: [true, "double"]
}
},
// tslint errors are displayed by default as warnings
// set emitErrors to true to display them as errors
emitErrors: false,
// tslint does not interrupt the compilation by default
// if you want any file with tslint errors to fail
// set failOnHint to true
failOnHint: true,
// name of your formatter (optional)
formatter: "",
// path to directory containing formatter (optional)
formattersDirectory: "node_modules/tslint-loader/formatters/",
// These options are useful if you want to save output to files
// for your continuous integration server
fileOutput: {
// The directory where each file"s report is saved
dir: "./webpack-log/",
// The extension to use for each report"s filename. Defaults to "txt"
ext: "xml",
// If true, all files are removed from the report directory at the beginning of run
clean: true,
// A string to include at the top of every report file.
// Useful for some report formats.
header: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<checkstyle version=\"5.7\">",
// A string to include at the bottom of every report file.
// Useful for some report formats.
footer: "</checkstyle>"
}
},
...
preLoaders: [
{
test: /\.ts$/,
loader: "tslint"
}
],
}
}
</code></pre>
<p>I updated webpack 1.13.1 to 2.1.0-beta.25 and tslint configuration breaks the complication process of <code>npm run build</code>.</p>
<p>I changed the <code>preLoaders</code> directive to <code>loaders</code></p>
<pre><code>module: {
....
{
test: /\.ts$/,
loader: 'tslint',
exclude: /(node_modules)/,
enforce: 'pre'
},
],
}
</code></pre>
<p>that's not enough cause I still get the error </p>
<pre><code>For loader options: webpack 2 no longer allows custom properties in configuration.
Loaders should be updated to allow passing options via loader options in module.rules.
</code></pre>
<p>so I should move the tslint configuration and place it somewhere else. kinda lost here. so any information regarding the issue would be greatly appreciated.</p>
<p>thanks!</p>
| 0debug
|
static TCGv gen_lea_indexed(CPUM68KState *env, DisasContext *s, TCGv base)
{
uint32_t offset;
uint16_t ext;
TCGv add;
TCGv tmp;
uint32_t bd, od;
offset = s->pc;
ext = cpu_lduw_code(env, s->pc);
s->pc += 2;
if ((ext & 0x800) == 0 && !m68k_feature(s->env, M68K_FEATURE_WORD_INDEX))
return NULL_QREG;
if (ext & 0x100) {
if (!m68k_feature(s->env, M68K_FEATURE_EXT_FULL))
return NULL_QREG;
if ((ext & 0x30) > 0x10) {
if ((ext & 0x30) == 0x20) {
bd = (int16_t)cpu_lduw_code(env, s->pc);
s->pc += 2;
} else {
bd = read_im32(env, s);
} else {
bd = 0;
tmp = tcg_temp_new();
if ((ext & 0x44) == 0) {
add = gen_addr_index(ext, tmp);
} else {
add = NULL_QREG;
if ((ext & 0x80) == 0) {
if (IS_NULL_QREG(base)) {
base = tcg_const_i32(offset + bd);
bd = 0;
if (!IS_NULL_QREG(add)) {
tcg_gen_add_i32(tmp, add, base);
add = tmp;
} else {
add = base;
if (!IS_NULL_QREG(add)) {
if (bd != 0) {
tcg_gen_addi_i32(tmp, add, bd);
add = tmp;
} else {
add = tcg_const_i32(bd);
if ((ext & 3) != 0) {
base = gen_load(s, OS_LONG, add, 0);
if ((ext & 0x44) == 4) {
add = gen_addr_index(ext, tmp);
tcg_gen_add_i32(tmp, add, base);
add = tmp;
} else {
add = base;
if ((ext & 3) > 1) {
if ((ext & 3) == 2) {
od = (int16_t)cpu_lduw_code(env, s->pc);
s->pc += 2;
} else {
od = read_im32(env, s);
} else {
od = 0;
if (od != 0) {
tcg_gen_addi_i32(tmp, add, od);
add = tmp;
} else {
tmp = tcg_temp_new();
add = gen_addr_index(ext, tmp);
if (!IS_NULL_QREG(base)) {
tcg_gen_add_i32(tmp, add, base);
if ((int8_t)ext)
tcg_gen_addi_i32(tmp, tmp, (int8_t)ext);
} else {
tcg_gen_addi_i32(tmp, add, offset + (int8_t)ext);
add = tmp;
return add;
| 1threat
|
Set in javascript : Can you clarify why boolean is used while adding objects to the WeakMaps in the code below. I understand set takes two(key and value) arguments. The boolean values gets printed in the console as well…that is my doubt…
Thanks in Advance.
const book1 = { title: ‘Pride and Prejudice’, author: ‘Jane Austen’ };
const book2 = { title: ‘The Catcher in the Rye’, author: ‘J.D. Salinger’ };
const book3 = { title: ‘Gulliver’s Travels’, author: ‘Jonathan Swift’ };
const library = new WeakMap();
library.set(book1, true);
library.set(book2, false);
library.set(book3, true);
console.log(library);
WeakMap {Object {title: ‘Pride and Prejudice’, author: ‘Jane Austen’} => true, Object {title: ‘The Catcher in the Rye’, author: ‘J.D. Salinger’} => false, Object {title: ‘Gulliver’s Travels’, author: ‘Jonathan Swift’} => true}
| 0debug
|
Parse JSON using Newtonsoft.Json C# : <p>I have the following json string:</p>
<pre><code>{
"data":
{
"id": "1",
"city": "London"
},
"cityDetails":
{
"_id": "1",
"location": "UK",
"th": 0,
"title": "Default Group",
}
},
"limit": 0.60451203584671021,
"_id": "1234"
}
</code></pre>
<p>How can I extract the the 'city' name from the 'data' section of the JSON string using Newtonsoft.Json in C#.</p>
| 0debug
|
.NET decompiler distinction between "using" and "try...finally" : <p>Given the following C# code in which the <em>Dispose</em> method is called in two different ways:</p>
<pre><code>class Disposable : IDisposable
{
public void Dispose()
{
}
}
class Program
{
static void Main(string[] args)
{
using (var disposable1 = new Disposable())
{
Console.WriteLine("using");
}
var disposable2 = new Disposable();
try
{
Console.WriteLine("try");
}
finally
{
if (disposable2 != null)
((IDisposable)disposable2).Dispose();
}
}
}
</code></pre>
<p>Once compiled using release configuration then disassembled with ildasm, the MSIL looks like this:</p>
<pre><code>.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
// Code size 57 (0x39)
.maxstack 1
.locals init ([0] class ConsoleApplication9.Disposable disposable2,
[1] class ConsoleApplication9.Disposable disposable1)
IL_0000: newobj instance void ConsoleApplication9.Disposable::.ctor()
IL_0005: stloc.1
.try
{
IL_0006: ldstr "using"
IL_000b: call void [mscorlib]System.Console::WriteLine(string)
IL_0010: leave.s IL_001c
} // end .try
finally
{
IL_0012: ldloc.1
IL_0013: brfalse.s IL_001b
IL_0015: ldloc.1
IL_0016: callvirt instance void [mscorlib]System.IDisposable::Dispose()
IL_001b: endfinally
} // end handler
IL_001c: newobj instance void ConsoleApplication9.Disposable::.ctor()
IL_0021: stloc.0
.try
{
IL_0022: ldstr "try"
IL_0027: call void [mscorlib]System.Console::WriteLine(string)
IL_002c: leave.s IL_0038
} // end .try
finally
{
IL_002e: ldloc.0
IL_002f: brfalse.s IL_0037
IL_0031: ldloc.0
IL_0032: callvirt instance void [mscorlib]System.IDisposable::Dispose()
IL_0037: endfinally
} // end handler
IL_0038: ret
} // end of method Program::Main
</code></pre>
<p>How does a .NET decompiler such as <em>DotPeek</em> or <em>JustDecompile</em> make the difference between <em>using</em> and <em>try...finally</em>?</p>
| 0debug
|
static uint64_t nvic_sysreg_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
uint32_t offset = addr;
if (offset >= 0xfe0) {
if (offset & 3) {
return 0;
}
return nvic_id[(offset - 0xfe0) >> 2];
}
if (size == 4) {
return nvic_readl(opaque, offset);
}
hw_error("NVIC: Bad read of size %d at offset 0x%x\n", size, offset);
}
| 1threat
|
static sPAPRDREntitySense logical_entity_sense(sPAPRDRConnector *drc)
{
if (drc->dev
&& (drc->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE)) {
return SPAPR_DR_ENTITY_SENSE_PRESENT;
} else {
return SPAPR_DR_ENTITY_SENSE_UNUSABLE;
}
}
| 1threat
|
How to change button color by click another button from another activity permanently : i have a problem
i have button A in first activity and button B in second activity,i want when someone click button B in second activity then color of A button is change permanently it never reverse to previous colour again when ever user not uninstall the app
| 0debug
|
how to run the python script file which contains some arguments to pass? : I have a module which contains the python code and I execute using the following code:
python script.py \
--eps 12 \
--minpts \
--train \
--predict \
--lower_case \
--input_file data.csv \
--dev_file devdata.csv \
--output_dir /output/
I use the parameters that are provided within the script and i don't have any methods or functions in it. But I wanted to take those parameters as input parameters to a function and the function has to execute the above python script with the given parameters. Is there any way of doing it??
Note: I know that I can write the entire code in script.py file into functions or classes but i just wanted to know if i can do it in this way just like an sql statement executed within the python code?
| 0debug
|
Getting error ImportMismatchError while running py.test : <p>When I am running tests locally its working fine, but after creating the docker and running inside the container I am getting below error.</p>
<pre><code> /usr/local/lib/python3.5/site-packages/_pytest/config.py:325: in _getconftestmodules
return self._path2confmods[path]
E KeyError: local('/apis/db/tests')
During handling of the above exception, another exception occurred:
/usr/local/lib/python3.5/site-packages/_pytest/config.py:356: in _importconftest
return self._conftestpath2mod[conftestpath]
E KeyError: local('/apis/db/tests/conftest.py')
During handling of the above exception, another exception occurred:
/usr/local/lib/python3.5/site-packages/_pytest/config.py:362: in _importconftest
mod = conftestpath.pyimport()
/usr/local/lib/python3.5/site-packages/py/_path/local.py:680: in pyimport
raise self.ImportMismatchError(modname, modfile, self)
_pytest.config.ConftestImportFailure: ImportMismatchError('conftest', '/projects/my_project/db/tests/conftest.py', local('/apis/db/tests/conftest.py'))
</code></pre>
<p>/apis - its the WORKDIR in Dockerfile.</p>
| 0debug
|
Ho do I perform an active sleep/timeout in Nodejs? : <p>I know that Javascript is single-threaded and blocking the event loop is not the right way. But I was wondering if there is a way to perform something like <code>sleep(5000ms)</code> to <strong>simulate</strong> code that takes a long time to perform.</p>
<p>I need this for debugging purposes.</p>
| 0debug
|
angular 2 include html templates : <p>in angular 2 I need to create a large html-template with redundant parts.
Therefore I want to create multiple html-templates and put them together by including them in the main html-file (like ng-include in angular1)</p>
<p>But how can I include sub-templates in the main-template?</p>
<p>example:</p>
<pre><code><!-- test.html -->
<div>
this is my Sub-Item
<!-- include sub1.html here-->
</div>
<div>
this is second Sub-Item
<!-- include sub2.html here-->
</div>
</code></pre>
<p>-</p>
<pre><code><!-- sub1.html -->
<div>
<button>I'am sub1</button>
</div>
</code></pre>
<p>-</p>
<pre><code><!-- sub2.html -->
<div>
<div>I'am sub2</div>
</div>
</code></pre>
| 0debug
|
static void scsi_do_read(void *opaque, int ret)
{
SCSIDiskReq *r = opaque;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint32_t n;
if (r->req.aiocb != NULL) {
r->req.aiocb = NULL;
bdrv_acct_done(s->qdev.conf.bs, &r->acct);
}
if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) {
goto done;
}
}
if (r->req.io_canceled) {
return;
}
scsi_req_ref(&r->req);
if (r->req.sg) {
dma_acct_start(s->qdev.conf.bs, &r->acct, r->req.sg, BDRV_ACCT_READ);
r->req.resid -= r->req.sg->size;
r->req.aiocb = dma_bdrv_read(s->qdev.conf.bs, r->req.sg, r->sector,
scsi_dma_complete, r);
} else {
n = scsi_init_iovec(r, SCSI_DMA_BUF_SIZE);
bdrv_acct_start(s->qdev.conf.bs, &r->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_READ);
r->req.aiocb = bdrv_aio_readv(s->qdev.conf.bs, r->sector, &r->qiov, n,
scsi_read_complete, r);
}
done:
if (!r->req.io_canceled) {
scsi_req_unref(&r->req);
}
}
| 1threat
|
I wan't to center my blog body in blogger : I want to center my blog body (Posts and Pages) in blogger, its a custom template
Link: www.temsah.ga
I tried adding this code below `</b:skin>` :
<style>
#sidebar-atas1
{
display: none;
}
#main-wrapper
{
width: 100%; background:#fff;
}
</style>
it removed the sidebar successfully but it didn't center my body.
| 0debug
|
C# - How do I check if all files in folder have certain extension : <p>I need to check if all files in folder have a certain extension. I am trying to display a message/form if all the files in the folder have a .txt extension. Can anyone please provide code on how this can be done? Thanks.</p>
| 0debug
|
static void *sigwait_compat(void *opaque)
{
struct sigfd_compat_info *info = opaque;
int err;
sigset_t all;
sigfillset(&all);
sigprocmask(SIG_BLOCK, &all, NULL);
do {
siginfo_t siginfo;
err = sigwaitinfo(&info->mask, &siginfo);
if (err == -1 && errno == EINTR) {
err = 0;
continue;
}
if (err > 0) {
char buffer[128];
size_t offset = 0;
memcpy(buffer, &err, sizeof(err));
while (offset < sizeof(buffer)) {
ssize_t len;
len = write(info->fd, buffer + offset,
sizeof(buffer) - offset);
if (len == -1 && errno == EINTR)
continue;
if (len <= 0) {
err = -1;
break;
}
offset += len;
}
}
} while (err >= 0);
return NULL;
}
| 1threat
|
C programming error: expected '{' before string constant : <p>Here is the error I am receiving,</p>
<pre><code>drivers/mmc/host/sdhci-msm.c: In function 'sdhci_msm_probe':
drivers/mmc/host/sdhci-msm.c:169:23: error: expected '{' before string constant
#define HOST_MMC_MMC "mmc0"
^
drivers/mmc/host/sdhci-msm.c:2818:9: note: in expansion of macro 'HOST_MMC_MMC'
struct HOST_MMC_MMC;
^
</code></pre>
<p>This issue is perplexing and I am very new to C so any help is appreciated. </p>
| 0debug
|
Python type hints for types not yet defined : <p>How do I provide type hints for an alternative constructor for a class? For example if I have a method like this converting something to my new class,</p>
<pre><code>class MyClass:
@classmethod
def from_string(cl: Type[????], s: str) -> ????:
p, q = some_function(s)
return cl(p, q)
</code></pre>
<p>what should I write for <code>????</code>? It should by nature just be <code>MyClass</code>, but that variable is not defined yet at the time when the method definition is executed.</p>
| 0debug
|
What is the meaning of this -> symbol in Java? : <p>I am not able to understand how to make this code should work in Java7</p>
<pre><code>RetryPolicy retryPolicy = new RetryPolicy()
.retryWhen((ClientResponse response) -> response.getStatus() != 200)
.withDelay(1, TimeUnit.SECONDS)
.withMaxRetries(3);
Recurrent.get(() -> webResource.post(ClientResponse.class, input), retryPolicy);
</code></pre>
<p>What exactly this <code>-></code> symbol mean in java?</p>
<p>If Java7 not support it how to change it so it should work.</p>
| 0debug
|
static int img_convert(int argc, char **argv)
{
int c, ret = 0, n, n1, bs_n, bs_i, compress, cluster_size, cluster_sectors;
int progress = 0, flags;
const char *fmt, *out_fmt, *cache, *out_baseimg, *out_filename;
BlockDriver *drv, *proto_drv;
BlockDriverState **bs = NULL, *out_bs = NULL;
int64_t total_sectors, nb_sectors, sector_num, bs_offset;
uint64_t bs_sectors;
uint8_t * buf = NULL;
const uint8_t *buf1;
BlockDriverInfo bdi;
QEMUOptionParameter *param = NULL, *create_options = NULL;
QEMUOptionParameter *out_baseimg_param;
char *options = NULL;
const char *snapshot_name = NULL;
float local_progress;
int min_sparse = 8;
fmt = NULL;
out_fmt = "raw";
cache = "unsafe";
out_baseimg = NULL;
compress = 0;
for(;;) {
c = getopt(argc, argv, "f:O:B:s:hce6o:pS:t:");
if (c == -1) {
break;
}
switch(c) {
case '?':
case 'h':
help();
break;
case 'f':
fmt = optarg;
break;
case 'O':
out_fmt = optarg;
break;
case 'B':
out_baseimg = optarg;
break;
case 'c':
compress = 1;
break;
case 'e':
error_report("option -e is deprecated, please use \'-o "
"encryption\' instead!");
return 1;
case '6':
error_report("option -6 is deprecated, please use \'-o "
"compat6\' instead!");
return 1;
case 'o':
options = optarg;
break;
case 's':
snapshot_name = optarg;
break;
case 'S':
{
int64_t sval;
char *end;
sval = strtosz_suffix(optarg, &end, STRTOSZ_DEFSUFFIX_B);
if (sval < 0 || *end) {
error_report("Invalid minimum zero buffer size for sparse output specified");
return 1;
}
min_sparse = sval / BDRV_SECTOR_SIZE;
break;
}
case 'p':
progress = 1;
break;
case 't':
cache = optarg;
break;
}
}
bs_n = argc - optind - 1;
if (bs_n < 1) {
help();
}
out_filename = argv[argc - 1];
qemu_progress_init(progress, 2.0);
if (options && !strcmp(options, "?")) {
ret = print_block_option_help(out_filename, out_fmt);
goto out;
}
if (bs_n > 1 && out_baseimg) {
error_report("-B makes no sense when concatenating multiple input "
"images");
ret = -1;
goto out;
}
qemu_progress_print(0, 100);
bs = g_malloc0(bs_n * sizeof(BlockDriverState *));
total_sectors = 0;
for (bs_i = 0; bs_i < bs_n; bs_i++) {
bs[bs_i] = bdrv_new_open(argv[optind + bs_i], fmt, BDRV_O_FLAGS);
if (!bs[bs_i]) {
error_report("Could not open '%s'", argv[optind + bs_i]);
ret = -1;
goto out;
}
bdrv_get_geometry(bs[bs_i], &bs_sectors);
total_sectors += bs_sectors;
}
if (snapshot_name != NULL) {
if (bs_n > 1) {
error_report("No support for concatenating multiple snapshot");
ret = -1;
goto out;
}
if (bdrv_snapshot_load_tmp(bs[0], snapshot_name) < 0) {
error_report("Failed to load snapshot");
ret = -1;
goto out;
}
}
drv = bdrv_find_format(out_fmt);
if (!drv) {
error_report("Unknown file format '%s'", out_fmt);
ret = -1;
goto out;
}
proto_drv = bdrv_find_protocol(out_filename);
if (!proto_drv) {
error_report("Unknown protocol '%s'", out_filename);
ret = -1;
goto out;
}
create_options = append_option_parameters(create_options,
drv->create_options);
create_options = append_option_parameters(create_options,
proto_drv->create_options);
if (options) {
param = parse_option_parameters(options, create_options, param);
if (param == NULL) {
error_report("Invalid options for file format '%s'.", out_fmt);
ret = -1;
goto out;
}
} else {
param = parse_option_parameters("", create_options, param);
}
set_option_parameter_int(param, BLOCK_OPT_SIZE, total_sectors * 512);
ret = add_old_style_options(out_fmt, param, out_baseimg, NULL);
if (ret < 0) {
goto out;
}
out_baseimg_param = get_option_parameter(param, BLOCK_OPT_BACKING_FILE);
if (out_baseimg_param) {
out_baseimg = out_baseimg_param->value.s;
}
if (compress) {
QEMUOptionParameter *encryption =
get_option_parameter(param, BLOCK_OPT_ENCRYPT);
QEMUOptionParameter *preallocation =
get_option_parameter(param, BLOCK_OPT_PREALLOC);
if (!drv->bdrv_write_compressed) {
error_report("Compression not supported for this file format");
ret = -1;
goto out;
}
if (encryption && encryption->value.n) {
error_report("Compression and encryption not supported at "
"the same time");
ret = -1;
goto out;
}
if (preallocation && preallocation->value.s
&& strcmp(preallocation->value.s, "off"))
{
error_report("Compression and preallocation not supported at "
"the same time");
ret = -1;
goto out;
}
}
ret = bdrv_create(drv, out_filename, param);
if (ret < 0) {
if (ret == -ENOTSUP) {
error_report("Formatting not supported for file format '%s'",
out_fmt);
} else if (ret == -EFBIG) {
error_report("The image size is too large for file format '%s'",
out_fmt);
} else {
error_report("%s: error while converting %s: %s",
out_filename, out_fmt, strerror(-ret));
}
goto out;
}
flags = BDRV_O_RDWR;
ret = bdrv_parse_cache_flags(cache, &flags);
if (ret < 0) {
error_report("Invalid cache option: %s", cache);
return -1;
}
out_bs = bdrv_new_open(out_filename, out_fmt, flags);
if (!out_bs) {
ret = -1;
goto out;
}
bs_i = 0;
bs_offset = 0;
bdrv_get_geometry(bs[0], &bs_sectors);
buf = qemu_blockalign(out_bs, IO_BUF_SIZE);
if (compress) {
ret = bdrv_get_info(out_bs, &bdi);
if (ret < 0) {
error_report("could not get block driver info");
goto out;
}
cluster_size = bdi.cluster_size;
if (cluster_size <= 0 || cluster_size > IO_BUF_SIZE) {
error_report("invalid cluster size");
ret = -1;
goto out;
}
cluster_sectors = cluster_size >> 9;
sector_num = 0;
nb_sectors = total_sectors;
local_progress = (float)100 /
(nb_sectors / MIN(nb_sectors, cluster_sectors));
for(;;) {
int64_t bs_num;
int remainder;
uint8_t *buf2;
nb_sectors = total_sectors - sector_num;
if (nb_sectors <= 0)
break;
if (nb_sectors >= cluster_sectors)
n = cluster_sectors;
else
n = nb_sectors;
bs_num = sector_num - bs_offset;
assert (bs_num >= 0);
remainder = n;
buf2 = buf;
while (remainder > 0) {
int nlow;
while (bs_num == bs_sectors) {
bs_i++;
assert (bs_i < bs_n);
bs_offset += bs_sectors;
bdrv_get_geometry(bs[bs_i], &bs_sectors);
bs_num = 0;
}
assert (bs_num < bs_sectors);
nlow = (remainder > bs_sectors - bs_num) ? bs_sectors - bs_num : remainder;
ret = bdrv_read(bs[bs_i], bs_num, buf2, nlow);
if (ret < 0) {
error_report("error while reading sector %" PRId64 ": %s",
bs_num, strerror(-ret));
goto out;
}
buf2 += nlow * 512;
bs_num += nlow;
remainder -= nlow;
}
assert (remainder == 0);
if (n < cluster_sectors) {
memset(buf + n * 512, 0, cluster_size - n * 512);
}
if (!buffer_is_zero(buf, cluster_size)) {
ret = bdrv_write_compressed(out_bs, sector_num, buf,
cluster_sectors);
if (ret != 0) {
error_report("error while compressing sector %" PRId64
": %s", sector_num, strerror(-ret));
goto out;
}
}
sector_num += n;
qemu_progress_print(local_progress, 100);
}
bdrv_write_compressed(out_bs, 0, NULL, 0);
} else {
int has_zero_init = bdrv_has_zero_init(out_bs);
sector_num = 0;
nb_sectors = total_sectors - sector_num;
local_progress = (float)100 /
(nb_sectors / MIN(nb_sectors, IO_BUF_SIZE / 512));
for(;;) {
nb_sectors = total_sectors - sector_num;
if (nb_sectors <= 0) {
break;
}
if (nb_sectors >= (IO_BUF_SIZE / 512)) {
n = (IO_BUF_SIZE / 512);
} else {
n = nb_sectors;
}
while (sector_num - bs_offset >= bs_sectors) {
bs_i ++;
assert (bs_i < bs_n);
bs_offset += bs_sectors;
bdrv_get_geometry(bs[bs_i], &bs_sectors);
}
if (n > bs_offset + bs_sectors - sector_num) {
n = bs_offset + bs_sectors - sector_num;
}
if (has_zero_init) {
if (out_baseimg) {
if (!bdrv_is_allocated(bs[bs_i], sector_num - bs_offset,
n, &n1)) {
sector_num += n1;
continue;
}
n = n1;
}
} else {
n1 = n;
}
ret = bdrv_read(bs[bs_i], sector_num - bs_offset, buf, n);
if (ret < 0) {
error_report("error while reading sector %" PRId64 ": %s",
sector_num - bs_offset, strerror(-ret));
goto out;
}
buf1 = buf;
while (n > 0) {
if (!has_zero_init || out_baseimg ||
is_allocated_sectors_min(buf1, n, &n1, min_sparse)) {
ret = bdrv_write(out_bs, sector_num, buf1, n1);
if (ret < 0) {
error_report("error while writing sector %" PRId64
": %s", sector_num, strerror(-ret));
goto out;
}
}
sector_num += n1;
n -= n1;
buf1 += n1 * 512;
}
qemu_progress_print(local_progress, 100);
}
}
out:
qemu_progress_end();
free_option_parameters(create_options);
free_option_parameters(param);
qemu_vfree(buf);
if (out_bs) {
bdrv_delete(out_bs);
}
if (bs) {
for (bs_i = 0; bs_i < bs_n; bs_i++) {
if (bs[bs_i]) {
bdrv_delete(bs[bs_i]);
}
}
g_free(bs);
}
if (ret) {
return 1;
}
return 0;
}
| 1threat
|
int virtio_bus_device_plugged(VirtIODevice *vdev)
{
DeviceState *qdev = DEVICE(vdev);
BusState *qbus = BUS(qdev_get_parent_bus(qdev));
VirtioBusState *bus = VIRTIO_BUS(qbus);
VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
DPRINTF("%s: plug device.\n", qbus->name);
if (klass->device_plugged != NULL) {
klass->device_plugged(qbus->parent);
}
assert(vdc->get_features != NULL);
vdev->host_features = vdc->get_features(vdev, vdev->host_features);
return 0;
}
| 1threat
|
static int configure_video_filters(FilterGraph *fg)
{
InputStream *ist = fg->inputs[0]->ist;
OutputStream *ost = fg->outputs[0]->ost;
AVFilterContext *in_filter, *out_filter, *filter;
AVCodecContext *codec = ost->st->codec;
AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();
char *pix_fmts;
AVRational sample_aspect_ratio;
char args[255];
int ret;
avfilter_graph_free(&fg->graph);
fg->graph = avfilter_graph_alloc();
if (!fg->graph)
return AVERROR(ENOMEM);
if (ist->st->sample_aspect_ratio.num) {
sample_aspect_ratio = ist->st->sample_aspect_ratio;
} else
sample_aspect_ratio = ist->st->codec->sample_aspect_ratio;
snprintf(args, 255, "%d:%d:%d:%d:%d:%d:%d:flags=%d", ist->st->codec->width,
ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE,
sample_aspect_ratio.num, sample_aspect_ratio.den, SWS_BILINEAR + ((ist->st->codec->flags&CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0));
ret = avfilter_graph_create_filter(&fg->inputs[0]->filter,
avfilter_get_by_name("buffer"),
"src", args, NULL, fg->graph);
if (ret < 0)
return ret;
#if FF_API_OLD_VSINK_API
ret = avfilter_graph_create_filter(&fg->outputs[0]->filter,
avfilter_get_by_name("buffersink"),
"out", NULL, NULL, fg->graph);
#else
ret = avfilter_graph_create_filter(&fg->outputs[0]->filter,
avfilter_get_by_name("buffersink"),
"out", NULL, buffersink_params, fg->graph);
#endif
av_freep(&buffersink_params);
if (ret < 0)
return ret;
in_filter = fg->inputs[0]->filter;
out_filter = fg->outputs[0]->filter;
if (codec->width || codec->height) {
snprintf(args, 255, "%d:%d:flags=0x%X",
codec->width,
codec->height,
(unsigned)ost->sws_flags);
if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
NULL, args, NULL, fg->graph)) < 0)
return ret;
if ((ret = avfilter_link(in_filter, 0, filter, 0)) < 0)
return ret;
in_filter = filter;
}
if ((pix_fmts = choose_pixel_fmts(ost))) {
if ((ret = avfilter_graph_create_filter(&filter,
avfilter_get_by_name("format"),
"format", pix_fmts, NULL,
fg->graph)) < 0)
return ret;
if ((ret = avfilter_link(filter, 0, out_filter, 0)) < 0)
return ret;
out_filter = filter;
av_freep(&pix_fmts);
}
snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags);
fg->graph->scale_sws_opts = av_strdup(args);
if (ost->avfilter) {
AVFilterInOut *outputs = avfilter_inout_alloc();
AVFilterInOut *inputs = avfilter_inout_alloc();
outputs->name = av_strdup("in");
outputs->filter_ctx = in_filter;
outputs->pad_idx = 0;
outputs->next = NULL;
inputs->name = av_strdup("out");
inputs->filter_ctx = out_filter;
inputs->pad_idx = 0;
inputs->next = NULL;
if ((ret = avfilter_graph_parse(fg->graph, ost->avfilter, &inputs, &outputs, NULL)) < 0)
return ret;
av_freep(&ost->avfilter);
} else {
if ((ret = avfilter_link(in_filter, 0, out_filter, 0)) < 0)
return ret;
}
if (ost->keep_pix_fmt)
avfilter_graph_set_auto_convert(fg->graph,
AVFILTER_AUTO_CONVERT_NONE);
if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
return ret;
ost->filter = fg->outputs[0];
return 0;
}
| 1threat
|
how to set the equivalent of a src attribute of an img tag in CSS? : Currently, I am doing like this:
<img class="myimg" />
.mgimg{
content:url('/images/user_logo.png') center no-repeat;
}
But the image is not getting displayed. I want to achieve it without using background image
| 0debug
|
Watch route changes in Vue.js with Typescript : <p>I'd like to detect changes in my URL in a Vue.js application using TypeScript. In JavaScript this can be done as follows:</p>
<pre><code>watch: {
'$route': {
handler: 'onUrlChange',
immediate: true,
deep: true
}
},
onUrlChange(newUrl){
// Some action
}
</code></pre>
<p>How could I do the same in TypeScript?</p>
| 0debug
|
static av_cold int alac_decode_init(AVCodecContext * avctx)
{
int ret;
int req_packed;
ALACContext *alac = avctx->priv_data;
alac->avctx = avctx;
if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
av_log(avctx, AV_LOG_ERROR, "expected %d extradata bytes\n",
ALAC_EXTRADATA_SIZE);
return -1;
}
if (alac_set_info(alac)) {
av_log(avctx, AV_LOG_ERROR, "set_info failed\n");
return -1;
}
req_packed = LIBAVCODEC_VERSION_MAJOR < 55 && !av_sample_fmt_is_planar(avctx->request_sample_fmt);
switch (alac->sample_size) {
case 16: avctx->sample_fmt = req_packed ? AV_SAMPLE_FMT_S16 : AV_SAMPLE_FMT_S16P;
break;
case 24:
case 32: avctx->sample_fmt = req_packed ? AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S32P;
break;
default: av_log_ask_for_sample(avctx, "Sample depth %d is not supported.\n",
alac->sample_size);
return AVERROR_PATCHWELCOME;
}
avctx->bits_per_raw_sample = alac->sample_size;
if (alac->channels < 1) {
av_log(avctx, AV_LOG_WARNING, "Invalid channel count\n");
alac->channels = avctx->channels;
} else {
if (alac->channels > MAX_CHANNELS)
alac->channels = avctx->channels;
else
avctx->channels = alac->channels;
}
if (avctx->channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Unsupported channel count: %d\n",
avctx->channels);
return AVERROR_PATCHWELCOME;
}
avctx->channel_layout = alac_channel_layouts[alac->channels - 1];
if ((ret = allocate_buffers(alac)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
return ret;
}
avcodec_get_frame_defaults(&alac->frame);
avctx->coded_frame = &alac->frame;
return 0;
}
| 1threat
|
With Circe Json why is implicit resolution slower at runtime : <p>Why is Circe Json slower with implicit decoder lookup compared to saving the implicit decoder to a val.</p>
<p>I would expect these to be the same because implicit resolution is done at runtime.</p>
<pre><code>import io.circe._
import io.circe.generic.auto._
import io.circe.jackson
import io.circe.syntax._
private val decoder = implicitly[Decoder[Data.Type]]
def decode(): Either[Error, Type] = {
jackson.decode[Data.Type](Data.json)(decoder)
}
def decodeAuto(): Either[Error, Type] = {
jackson.decode[Data.Type](Data.json)
}
[info] DecodeTest.circeJackson thrpt 200 69157.472 ± 283.285 ops/s
[info] DecodeTest.circeJacksonAuto thrpt 200 67946.734 ± 315.876 ops/s
</code></pre>
<p>The full repo can be found here.
<a href="https://github.com/stephennancekivell/some-jmh-json-benchmarks-circe-jackson">https://github.com/stephennancekivell/some-jmh-json-benchmarks-circe-jackson</a></p>
| 0debug
|
MYSQL HELP PLEASE CANNOT INPUT ENTRY BECAUSE OF FOREIGN KEY? : Hello i need help please, i keep getting this error when trying to add an entry to one of my tables.
Trying to add this code: `INSERT INTO ROUTE VALUES ('7418','66','200','313');`
into this table
CREATE TABLE ROUTE (
ROUTE_ID INT NOT NULL PRIMARY KEY,
ROUTE_NAME VARCHAR(45) NOT NULL,
DELIVERY_VEHICLE_VEH_ID INT NOT NULL,
DELIVERY_DRIVER_DR_ID INT NOT NULL,
CONSTRAINT FK_ROUTE_DELIVERY FOREIGN KEY (DELIVERY_VEHICLE_VEH_ID) REFERENCES DELIVERY (VEHICLE_VEH_ID),
FOREIGN KEY (DELIVERY_DRIVER_DR_ID) REFERENCES DELIVERY (DRIVER_DR_ID));
Other related tables
CREATE TABLE DELIVERY (
VEHICLE_VEH_ID INT NOT NULL,
DRIVER_DR_ID INT NOT NULL,
DEL_DATE DATETIME NOT NULL,
DEL_TIME DATETIME NOT NULL,
PRIMARY KEY (VEHICLE_VEH_ID , DRIVER_DR_ID),
INDEX (DRIVER_DR_ID),
INDEX (VEHICLE_VEH_ID),
CONSTRAINT FK_VEHICLE_HAS_DRIVER_VEHICLE FOREIGN KEY (VEHICLE_VEH_ID) REFERENCES VEHICLE (VEH_ID),
CONSTRAINT FK_VEHICLE_HAS_DRIVER_DRIVER FOREIGN KEY (DRIVER_DR_ID) REFERENCES DRIVER (DR_ID));
CREATE TABLE DRIVER (
DR_ID INT NOT NULL PRIMARY KEY,
DR_TITLE VARCHAR(15) NOT NULL,
DR_FNAME VARCHAR(45) NOT NULL,
DR_LNAME VARCHAR(45) NOT NULL,
DR_DOB DATETIME NOT NULL,
DR_LICENCENO VARCHAR(45) NOT NULL,
DR_PHONE VARCHAR(15) NOT NULL,
DR_EMAIL VARCHAR(45) NOT NULL);
| 0debug
|
static int proxy_readdir_r(FsContext *ctx, V9fsFidOpenState *fs,
struct dirent *entry,
struct dirent **result)
{
return readdir_r(fs->dir, entry, result);
}
| 1threat
|
How to convert date of string format to another string format in swift(ios) : <p>I have a string "<strong>2020-01-01T00:00:00</strong>". How shall I convert it to another string of format <strong>"01-Jan-2020"</strong> in swift (iOS)?</p>
| 0debug
|
Javascript new Date() giving different outputs for different timezones : <p>I have below code in my function</p>
<pre><code>alert(date);
var result = new Date(date);
alert(result);
</code></pre>
<p>Output as below</p>
<p>When I set my system time as India</p>
<pre><code>2017-11-07
Tue Nov 07 2017 05:30:00 GMT+0530 (India Standard Time)
</code></pre>
<p>When I set my System timezone as US & Canada</p>
<pre><code>2017-11-07
Mon Nov 06 2017 18:00:00 GMT-0600 (Central Standard Time)
</code></pre>
<p>What is the issue here and how can I fix this?</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.