problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How to delete particular elements in a array of objects : <p><a href="https://i.stack.imgur.com/IktIJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IktIJ.png" alt="enter image description here"></a></p>
<blockquote>
<p>I have an array with multiple objects.How can i delete an element in a
object.</p>
<p>For example i have attached a image in that i need to delete
organization element.</p>
<p>Please help me out to fix.</p>
</blockquote>
| 0debug |
why I have an empty Row in the end of my greedview? : I have always an emty row in the end of my grid View
gv_remboursement.DataSource = listResult;
gv_remboursement.VirtualItemCount = iTotal;
gv_remboursement.DataBind();
listResultContent.Visible = isVisible;
listResult contains the list that I fill from the data base | 0debug |
How to do pattern matching on map keys in function heads in elixir : <p>I can't seem to find a way to pattern match on a map's key in a function head. Is there a way to do this? What I'm trying to do is run different code depending on whether a certain key already exists in a map or not (and also wanted to avoid if/else and the like)</p>
<p>This is what my code looks like</p>
<pre class="lang-ex prettyprint-override"><code>def my_func(key, %{key => _} = map), do: ...
</code></pre>
<p>which gives me this error</p>
<blockquote>
<p>** (CompileError) illegal use of variable key inside map key match, maps can only match on existing variable by using ^key</p>
</blockquote>
<p>Of course I also tried it using the <code>^</code></p>
<pre><code>def my_func(key, %{^key => _} = map), do: ...
</code></pre>
<p>which then gives</p>
<blockquote>
<p>** (CompileError) unbound variable ^key</p>
</blockquote>
<p>I'm using elixir 1.3.1/erlang 19.0 x64 on a windows 8.1 machine.
Thanks for reading!</p>
| 0debug |
How do I use an input in my code (Python)? : So in my program I get an input from the user:
planet = input("Planet: ")
Let's say the user's input was mars. I would want to have the following code like this:
mars[2]*math.sin(mars[3])
How do I do that?
Thanks in advance! | 0debug |
Upgrade PHP 5.5.38 to PHP 7 in CentOS 6.10 : <p>I want to update my server with CentOS 6 with PHP 5.5.38 to PHP 7 because few plugins of wordpress doesn't work very well.
I'm new updating these type of systems and I don't know if it's only remove the old version and install a new one or I need to follow specific steps.</p>
<p>Thank you in advance!</p>
| 0debug |
All modes to combine two arrays : <p>I have a dynamic array in this structure:</p>
<pre><code>$arr = [
['R1', 'R2'],
['A1', 'A2', 'A3'],
['M1', 'M2']
];
</code></pre>
<p>i want to find all combinations for this array i.e:</p>
<pre><code>R1A1M1
R1A1M2
R1A2M1
R1A2M2
R1A3M1
R1A3M2
R2A1M1
R2A1M2
R2A2M1
R2A2M2
R2A3M1
R2A3M2
</code></pre>
<p>because array length is not static we must use a recursive function to solve this problem.
what is code in PHP or js for this problem?</p>
<p>thank you</p>
| 0debug |
run modeler stream inside spss statistics : I have an SPSS syntax file that I am trying to make as automatic as possible. I am looking for a way, inside SPSS Statistics, to do basically the following: open SPSS Modeler and run stream. But, my SPSS syntax has to wait for the file to be created and exported in the Modeler stream before my SPSS syntax can proceed. Is there a way to do this with Python? | 0debug |
Rsync on windows - dup() in/out/err failed : <p>I am using Vagrant to manage virtual machines for developing purpose. My OS is Windows 10 and I am using Vagrant 1.9.1. Since default driver for folder syncing is slow i wanted to implement Rsync.</p>
<p>To to that I used Cygwin and installed Rsyn and OpenSSL.</p>
<p>When I run vagrant up inside Cygwin console I got this error:</p>
<pre><code>There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /cygdrive/c/Users/User/my-project/my-project/
Guest path: /var/www
Command: "rsync" "--verbose" "--archive" "-z" "--chmod=ugo=rwX" "--no-perms" "--no-owner" "--no-group" "--rsync-path" "sudo rsync" "-e" "ssh -p 2222 -o LogLevel=FATAL -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i 'C:/Users/User/my-project/my-project/.vagrant/machines/gbb-my-project-sys-web-dev-1/virtualbox/private_key'" "--exclude" ".vagrant/" "--exclude" ".git/" "/cygdrive/c/Users/User/my-project/my-project/" "vagrant@127.0.0.1:/var/www"
Error: dup() in/out/err failed
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1]
</code></pre>
<p>Commands I used to run vagrant</p>
<pre><code>export VAGRANT_DETECTED_OS=cygwin
VAGRANT_HOME=/cygdrive/c/Users/User
export VAGRANT_HOME
vagrant up
</code></pre>
<p>Vagrant config:</p>
<pre><code>synced_folder:
vflsf_udtdv3aeexfs:
owner: www-data
group: www-data
source: ./
target: /var/www
sync_type: rsync
smb:
smb_host: ''
smb_username: ''
smb_password: ''
mount_options:
dir_mode: '0775'
file_mode: '0664'
rsync:
args:
- '--verbose'
- '--archive'
- '-z'
exclude:
- .vagrant/
- .git/
auto: 'true'
</code></pre>
| 0debug |
Angular 2: Component Interaction, optional input parameters : <p>I have an implementation where parent wants to pass certain data to child component via the use of <code>@Input</code> parameter available at the child component. However, this data transfer is a optional thing and the parent may or may not pass it as per the requirement. Is it possible to have optional input parameters in a component. I have described a scenario below:</p>
<pre><code> <parent>
<child [showName]="true"></child> //passing parameter
<child></child> //not willing to passing any parameter
</parent>
//child component definition
@Component {
selector:'app-child',
template:`<h1>Hi Children!</h1>
<span *ngIf="showName">Alex!</span>`
}
export class child {
@Input showName: boolean;
constructor() { }
}
</code></pre>
| 0debug |
How to listen for an "Insufficient cpu/memory" event in an AWS ECS service? : <p>I am interested in listening/reacting to the event, that a service cannot start start a task because of insufficient cpu or memory. This information can be viewed in the console, if i chose the specific service and look in its "Events" tab. There, an event like the following would be displayed:</p>
<p>"service X was unable to place a task because no container instance met all of its requirements. The closest matching container-instance Y has insufficient CPU units available. For more information, see the Troubleshooting section."</p>
<p>The container instances in the cluster are managed in an AutoScalingGroup, so the appropriate action would be to react to this event, by scaling in an additional instance, which would then allow the task to be scheduled to run. Now, my problem is, how do i react to this event?</p>
<p>I have a LogGroup that contains data from the following files from all the EC2 instances in the cluster:</p>
<ul>
<li>/var/log/dmesg</li>
<li>/var/log/messages</li>
<li>/var/log/docker</li>
<li>/var/log/ecs/ecs-init.log.*</li>
<li>/var/log/ecs/ecs-agent.log.*</li>
</ul>
<p>(The EC2 instances are based on amazon-ecs-optimized images)</p>
<p>Initially, i thought i that the "service X was unable to place a task..." message would appear in one of these log files (more specifically in the ecs-agent.log or ecs-init.log), but that was not the case. </p>
<p>I then realized that "ECS Evenets" is a thing (see more at <a href="http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_cwe_events.html" rel="noreferrer">http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_cwe_events.html</a>). But unfortunately, this specific event, is not one that is supported by the "ECS Events". Only:
<strong>Container Instance State Change Events</strong> and <strong>Task State Change Events</strong>. <strong>NOT "Service State Change Events"</strong>. Even though, one would think that the events from the "Events" tab in the service would be streamed as well, they are not. I came to realize the documentation even says that: </p>
<p>"You can use Amazon ECS event stream for CloudWatch Events to receive near real-time notifications regarding the current state of both the <strong>container instances</strong> within an Amazon ECS cluster, and the current state of all <strong>tasks running</strong> on those container instances."</p>
<p>And thereby, "Amazon ECS Event Stream for CloudWatch Events" is not steaming service events (and thereby not events for tasks that are prevented from running). I really hope that "Service State Change Events" would be included in the future, that way i could make a CloudWatch Event Rule that matches this event, triggers a Lambda function which would then determine if the event was an event of type "service X was unable to place a task...", and based on that, manipulate the AutoScalingGroup to scale in an additional instance to the cluster.</p>
<p>But as stated, this is not supported at the moment. Is there any other way that i can "listen" for this event? I even thought about running a lambda every 2-3 minutes that uses the CLI to invoke "aws ecs describe-services --service X" to output the list of events, and then match on the "service X was unable to place a task..." event. But that just seems wrong...</p>
<p>Any help is very appreciated. Thanks!</p>
| 0debug |
Bootstrap input tags : <p>I have used Bootstrap tag inputs on email field in my application .Am getting as below (Whenever i hit enter , entered values went out of input field)</p>
<p><a href="https://i.stack.imgur.com/K0kWh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K0kWh.png" alt="Tag Input output"></a></p>
<p>But i want my input field as like ,(It should accommodate all inputs in text box itself)</p>
<p><a href="https://i.stack.imgur.com/WNZum.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WNZum.png" alt="Tag Input Expected"></a></p>
<p>I have added bootstrap and bootstrap taginput js in my code.</p>
<p>Can anyone please help me out to achieve this.</p>
| 0debug |
void cpu_x86_fsave(CPUX86State *s, uint8_t *ptr, int data32)
{
CPUX86State *saved_env;
saved_env = env;
env = s;
helper_fsave(ptr, data32);
env = saved_env;
}
| 1threat |
static void pc_system_flash_init(MemoryRegion *rom_memory)
{
int unit;
DriveInfo *pflash_drv;
BlockDriverState *bdrv;
int64_t size;
char *fatal_errmsg = NULL;
hwaddr phys_addr = 0x100000000ULL;
int sector_bits, sector_size;
pflash_t *system_flash;
MemoryRegion *flash_mem;
char name[64];
sector_bits = 12;
sector_size = 1 << sector_bits;
for (unit = 0;
(unit < FLASH_MAP_UNIT_MAX &&
(pflash_drv = drive_get(IF_PFLASH, 0, unit)) != NULL);
++unit) {
bdrv = blk_bs(blk_by_legacy_dinfo(pflash_drv));
size = bdrv_getlength(bdrv);
if (size < 0) {
fatal_errmsg = g_strdup_printf("failed to get backing file size");
} else if (size == 0) {
fatal_errmsg = g_strdup_printf("PC system firmware (pflash) "
"cannot have zero size");
} else if ((size % sector_size) != 0) {
fatal_errmsg = g_strdup_printf("PC system firmware (pflash) "
"must be a multiple of 0x%x", sector_size);
} else if (phys_addr < size || phys_addr - size < FLASH_MAP_BASE_MIN) {
fatal_errmsg = g_strdup_printf("oversized backing file, pflash "
"segments cannot be mapped under "
TARGET_FMT_plx, FLASH_MAP_BASE_MIN);
}
if (fatal_errmsg != NULL) {
Location loc;
loc_push_none(&loc);
if (pflash_drv->opts != NULL) {
qemu_opts_loc_restore(pflash_drv->opts);
}
error_report("%s", fatal_errmsg);
loc_pop(&loc);
g_free(fatal_errmsg);
exit(1);
}
phys_addr -= size;
snprintf(name, sizeof name, "system.flash%d", unit);
system_flash = pflash_cfi01_register(phys_addr, NULL , name,
size, bdrv, sector_size,
size >> sector_bits,
1 ,
0x0000 ,
0x0000 ,
0x0000 ,
0x0000 ,
0 );
if (unit == 0) {
flash_mem = pflash_cfi01_get_memory(system_flash);
pc_isa_bios_init(rom_memory, flash_mem, size);
}
}
}
| 1threat |
Wamp server - php require() - directory change : I am using Wamp server, i pull the project and in index.php there is
"require_once ('app_config_new.php')"
I have a file structure as follows:
project/index.php
project/config/app_config_new.php
what should i change in apache config file to work this code
| 0debug |
void cpu_loop(CPUMIPSState *env)
{
CPUState *cs = CPU(mips_env_get_cpu(env));
target_siginfo_t info;
int trapnr;
abi_long ret;
# ifdef TARGET_ABI_MIPSO32
unsigned int syscall_num;
# endif
for(;;) {
cpu_exec_start(cs);
trapnr = cpu_mips_exec(env);
cpu_exec_end(cs);
switch(trapnr) {
case EXCP_SYSCALL:
env->active_tc.PC += 4;
# ifdef TARGET_ABI_MIPSO32
syscall_num = env->active_tc.gpr[2] - 4000;
if (syscall_num >= sizeof(mips_syscall_args)) {
ret = -TARGET_ENOSYS;
} else {
int nb_args;
abi_ulong sp_reg;
abi_ulong arg5 = 0, arg6 = 0, arg7 = 0, arg8 = 0;
nb_args = mips_syscall_args[syscall_num];
sp_reg = env->active_tc.gpr[29];
switch (nb_args) {
case 8:
if ((ret = get_user_ual(arg8, sp_reg + 28)) != 0) {
goto done_syscall;
}
case 7:
if ((ret = get_user_ual(arg7, sp_reg + 24)) != 0) {
goto done_syscall;
}
case 6:
if ((ret = get_user_ual(arg6, sp_reg + 20)) != 0) {
goto done_syscall;
}
case 5:
if ((ret = get_user_ual(arg5, sp_reg + 16)) != 0) {
goto done_syscall;
}
default:
break;
}
ret = do_syscall(env, env->active_tc.gpr[2],
env->active_tc.gpr[4],
env->active_tc.gpr[5],
env->active_tc.gpr[6],
env->active_tc.gpr[7],
arg5, arg6, arg7, arg8);
}
done_syscall:
# else
ret = do_syscall(env, env->active_tc.gpr[2],
env->active_tc.gpr[4], env->active_tc.gpr[5],
env->active_tc.gpr[6], env->active_tc.gpr[7],
env->active_tc.gpr[8], env->active_tc.gpr[9],
env->active_tc.gpr[10], env->active_tc.gpr[11]);
# endif
if (ret == -TARGET_QEMU_ESIGRETURN) {
break;
}
if ((abi_ulong)ret >= (abi_ulong)-1133) {
env->active_tc.gpr[7] = 1;
ret = -ret;
} else {
env->active_tc.gpr[7] = 0;
}
env->active_tc.gpr[2] = ret;
break;
case EXCP_TLBL:
case EXCP_TLBS:
case EXCP_AdEL:
case EXCP_AdES:
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = env->CP0_BadVAddr;
queue_signal(env, info.si_signo, &info);
break;
case EXCP_CpU:
case EXCP_RI:
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = 0;
queue_signal(env, info.si_signo, &info);
break;
case EXCP_INTERRUPT:
break;
case EXCP_DEBUG:
{
int sig;
sig = gdb_handlesig(cs, TARGET_SIGTRAP);
if (sig)
{
info.si_signo = sig;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
}
}
break;
case EXCP_SC:
if (do_store_exclusive(env)) {
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = env->active_tc.PC;
queue_signal(env, info.si_signo, &info);
}
break;
case EXCP_DSPDIS:
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_ILLOPC;
queue_signal(env, info.si_signo, &info);
break;
case EXCP_BREAK:
{
abi_ulong trap_instr;
unsigned int code;
if (env->hflags & MIPS_HFLAG_M16) {
if (env->insn_flags & ASE_MICROMIPS) {
abi_ulong instr[2];
ret = get_user_u16(instr[0], env->active_tc.PC) ||
get_user_u16(instr[1], env->active_tc.PC + 2);
trap_instr = (instr[0] << 16) | instr[1];
} else {
ret = get_user_u16(trap_instr, env->active_tc.PC);
if (ret != 0) {
goto error;
}
code = (trap_instr >> 6) & 0x3f;
if (do_break(env, &info, code) != 0) {
goto error;
}
break;
}
} else {
ret = get_user_ual(trap_instr, env->active_tc.PC);
}
if (ret != 0) {
goto error;
}
code = ((trap_instr >> 6) & ((1 << 20) - 1));
if (code >= (1 << 10)) {
code >>= 10;
}
if (do_break(env, &info, code) != 0) {
goto error;
}
}
break;
case EXCP_TRAP:
{
abi_ulong trap_instr;
unsigned int code = 0;
if (env->hflags & MIPS_HFLAG_M16) {
abi_ulong instr[2];
ret = get_user_u16(instr[0], env->active_tc.PC) ||
get_user_u16(instr[1], env->active_tc.PC + 2);
trap_instr = (instr[0] << 16) | instr[1];
} else {
ret = get_user_ual(trap_instr, env->active_tc.PC);
}
if (ret != 0) {
goto error;
}
if (!(trap_instr & 0xFC000000)) {
if (env->hflags & MIPS_HFLAG_M16) {
code = ((trap_instr >> 12) & ((1 << 4) - 1));
} else {
code = ((trap_instr >> 6) & ((1 << 10) - 1));
}
}
if (do_break(env, &info, code) != 0) {
goto error;
}
}
break;
default:
error:
fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
trapnr);
cpu_dump_state(cs, stderr, fprintf, 0);
abort();
}
process_pending_signals(env);
}
}
| 1threat |
static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt,
int64_t next_dts, int64_t next_pts)
{
int num, den, presentation_delayed, delay, i;
int64_t offset;
AVRational duration;
int onein_oneout = st->codec->codec_id != AV_CODEC_ID_H264 &&
st->codec->codec_id != AV_CODEC_ID_HEVC;
if (s->flags & AVFMT_FLAG_NOFILLIN)
return;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pkt->dts != AV_NOPTS_VALUE) {
if (pkt->dts == pkt->pts && st->last_dts_for_order_check != AV_NOPTS_VALUE) {
if (st->last_dts_for_order_check <= pkt->dts) {
st->dts_ordered++;
} else {
av_log(s, st->dts_misordered ? AV_LOG_DEBUG : AV_LOG_WARNING,
"DTS %"PRIi64" < %"PRIi64" out of order\n",
pkt->dts,
st->last_dts_for_order_check);
st->dts_misordered++;
}
if (st->dts_ordered + st->dts_misordered > 250) {
st->dts_ordered >>= 1;
st->dts_misordered >>= 1;
}
}
st->last_dts_for_order_check = pkt->dts;
if (st->dts_ordered < 8*st->dts_misordered && pkt->dts == pkt->pts)
pkt->dts = AV_NOPTS_VALUE;
}
if ((s->flags & AVFMT_FLAG_IGNDTS) && pkt->pts != AV_NOPTS_VALUE)
pkt->dts = AV_NOPTS_VALUE;
if (pc && pc->pict_type == AV_PICTURE_TYPE_B
&& !st->codec->has_b_frames)
st->codec->has_b_frames = 1;
delay = st->codec->has_b_frames;
presentation_delayed = 0;
if (delay &&
pc && pc->pict_type != AV_PICTURE_TYPE_B)
presentation_delayed = 1;
if (pkt->pts != AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE &&
st->pts_wrap_bits < 63 &&
pkt->dts - (1LL << (st->pts_wrap_bits - 1)) > pkt->pts) {
if (is_relative(st->cur_dts) || pkt->dts - (1LL<<(st->pts_wrap_bits - 1)) > st->cur_dts) {
pkt->dts -= 1LL << st->pts_wrap_bits;
} else
pkt->pts += 1LL << st->pts_wrap_bits;
}
if (delay == 1 && pkt->dts == pkt->pts &&
pkt->dts != AV_NOPTS_VALUE && presentation_delayed) {
av_log(s, AV_LOG_DEBUG, "invalid dts/pts combination %"PRIi64"\n", pkt->dts);
if ( strcmp(s->iformat->name, "mov,mp4,m4a,3gp,3g2,mj2")
&& strcmp(s->iformat->name, "flv"))
pkt->dts = AV_NOPTS_VALUE;
}
duration = av_mul_q((AVRational) {pkt->duration, 1}, st->time_base);
if (pkt->duration == 0) {
ff_compute_frame_duration(s, &num, &den, st, pc, pkt);
if (den && num) {
duration = (AVRational) {num, den};
pkt->duration = av_rescale_rnd(1,
num * (int64_t) st->time_base.den,
den * (int64_t) st->time_base.num,
AV_ROUND_DOWN);
}
}
if (pkt->duration != 0 && (s->packet_buffer || s->parse_queue))
update_initial_durations(s, st, pkt->stream_index, pkt->duration);
if (pc && st->need_parsing == AVSTREAM_PARSE_TIMESTAMPS && pkt->size) {
offset = av_rescale(pc->offset, pkt->duration, pkt->size);
if (pkt->pts != AV_NOPTS_VALUE)
pkt->pts += offset;
if (pkt->dts != AV_NOPTS_VALUE)
pkt->dts += offset;
}
if (pkt->dts != AV_NOPTS_VALUE &&
pkt->pts != AV_NOPTS_VALUE &&
pkt->pts > pkt->dts)
presentation_delayed = 1;
av_dlog(NULL,
"IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%d delay:%d onein_oneout:%d\n",
presentation_delayed, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts),
pkt->stream_index, pc, pkt->duration, delay, onein_oneout);
if ((delay == 0 || (delay == 1 && pc)) &&
onein_oneout) {
if (presentation_delayed) {
if (pkt->dts == AV_NOPTS_VALUE)
pkt->dts = st->last_IP_pts;
update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts, pkt);
if (pkt->dts == AV_NOPTS_VALUE)
pkt->dts = st->cur_dts;
if (st->last_IP_duration == 0)
st->last_IP_duration = pkt->duration;
if (pkt->dts != AV_NOPTS_VALUE)
st->cur_dts = pkt->dts + st->last_IP_duration;
if (pkt->dts != AV_NOPTS_VALUE &&
pkt->pts == AV_NOPTS_VALUE &&
st->last_IP_duration > 0 &&
(st->cur_dts - next_dts) <= 1 &&
next_dts != next_pts &&
next_pts != AV_NOPTS_VALUE)
pkt->pts = next_dts;
st->last_IP_duration = pkt->duration;
st->last_IP_pts = pkt->pts;
} else if (pkt->pts != AV_NOPTS_VALUE ||
pkt->dts != AV_NOPTS_VALUE ||
pkt->duration ) {
if (pkt->pts == AV_NOPTS_VALUE)
pkt->pts = pkt->dts;
update_initial_timestamps(s, pkt->stream_index, pkt->pts,
pkt->pts, pkt);
if (pkt->pts == AV_NOPTS_VALUE)
pkt->pts = st->cur_dts;
pkt->dts = pkt->pts;
if (pkt->pts != AV_NOPTS_VALUE)
st->cur_dts = av_add_stable(st->time_base, pkt->pts, duration, 1);
}
}
if (pkt->pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY && has_decode_delay_been_guessed(st)) {
st->pts_buffer[0] = pkt->pts;
for (i = 0; i<delay && st->pts_buffer[i] > st->pts_buffer[i + 1]; i++)
FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i + 1]);
pkt->dts = select_from_pts_buffer(st, st->pts_buffer, pkt->dts);
}
if (!onein_oneout)
update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts, pkt);
if (pkt->dts > st->cur_dts)
st->cur_dts = pkt->dts;
av_dlog(NULL, "OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s\n",
presentation_delayed, delay, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts));
if (is_intra_only(st->codec))
pkt->flags |= AV_PKT_FLAG_KEY;
if (pc)
pkt->convergence_duration = pc->convergence_duration;
}
| 1threat |
How to insert a new element in between all elements of a JS array? : <p>I have an array <code>[a, b, c]</code>. I want to be able to insert a value between each elements of this array like that: <code>[0, a, 0, b, 0, c, 0]</code>.</p>
<p>I guess it would be something like this, but I can't make it works.</p>
<pre><code>for (let i = 0; i < array.length; i++) {
newArray = [
...array.splice(0, i),
0,
...array.splice(i, array.length),
];
}
</code></pre>
<p>Thank you for helping me!</p>
| 0debug |
AEM Assets or AEM DAM .? : What is AEM Assets, is it not the OOTB installation AEM DAM is the same AEM Assets .? or is there AEM Assets installation that needs to be done seperately. ? | 0debug |
static int send_status(int sockfd, struct iovec *iovec, int status)
{
ProxyHeader header;
int retval, msg_size;
if (status < 0) {
header.type = T_ERROR;
} else {
header.type = T_SUCCESS;
header.size = sizeof(status);
msg_size = proxy_marshal(iovec, 0, "ddd", header.type,
header.size, status);
retval = socket_write(sockfd, iovec->iov_base, msg_size);
if (retval < 0) {
return retval;
return 0;
| 1threat |
Why is var in same function is not defined? : <p>I have a code like this:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><html>
<head>
<script language="javascript">
window.onload = function() {
var wordlist = [ "A", "BB", "CCC", "DDDD" ];
for(i = 0; i < 26; i++) {
var x = document.createElement("INPUT");
x.setAttribute("type", "button");
x.setAttribute("value", String.fromCharCode(i + 65));
x.setAttribute("id", String.fromCharCode(i + 65));
x.setAttribute("onclick", "isTOF(this.id, wordlist[3])");
document.body.appendChild(x);
}
}
function isTOF(v, word) {
console.log(word);
}
</script>
</head>
<body>
</body>
</html></code></pre>
</div>
</div>
</p>
<p>I thought that <code>console.log(word)</code> will show me "DDDD", but it says like this:</p>
<blockquote>
<p>wordlist is not defined</p>
</blockquote>
<p>How can I make it run?</p>
| 0debug |
How can I provide activity context with Dagger dependecies? : <p><strong>How can I provide activity context in mainModule class ? Thanks!</strong> The code looks like this:</p>
<pre><code> @Singleton
@Component(modules = {AndroidInjectionModule.class, AppModule.class, ActivityBuilder.class})
public interface AppComponent {
@Component.Builder
interface Builder {
@BindsInstance
Builder application(Application application);
AppComponent build();
}
void inject(MvmApp app);
}
</code></pre>
<p>Activtity builder:</p>
<pre><code>@Module
public abstract class ActivityBuilder {
@ContributesAndroidInjector(modules = {MainModule.class})
abstract MainActivity bindMainActivity();
}
</code></pre>
<p>And I have an appModule, and a module for each activity:</p>
<pre><code>@Module
public class AppModule {
@Provides
@Singleton
@ApplicationContext
Context provideContext(Application application) {
return application;
}
@Provides
@Singleton
DataManager provideDataManager(AppDataManager appDataManager) {
return appDataManager;
}
@Provides
@DatabaseInfo
String provideDatabaseName() {
return "carDatabase";
}
@Provides
@Singleton
AppDataBase provideAppDatabase(@DatabaseInfo String dbName, @ApplicationContext Context context) {
return Room.databaseBuilder(context, AppDataBase.class, dbName)
.build();
}
@Provides
@Singleton
DbHelper provideDbHelper(AppDbHelper appDbHelper) {
return appDbHelper;
}
}
</code></pre>
<p>AppClass:</p>
<pre><code>public class MvmApp extends Application implements HasActivityInjector {
@Inject
DispatchingAndroidInjector<Activity> activityDispatchingAndroidInjector;
@Override
public void onCreate() {
super.onCreate();
DaggerAppComponent.builder()
.application(this)
.build()
.inject(this);
}
@Override
public DispatchingAndroidInjector<Activity> activityInjector() {
return activityDispatchingAndroidInjector;
}
}
</code></pre>
<p>All my activities extends a base activity which inject the Dagger dependecies.</p>
<pre><code>public abstract class BaseActivity extends AppCompatActivity implements MvpView {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidInjection.inject(this);
}
}
</code></pre>
<p><strong><em>In mainModule I need to provide the context of the activity.</em></strong></p>
<pre><code>@Module
public class MainModule {
@Provides
MainMvpPresenter<MainMvpView> provideMainPresenter(
MainPresenter<MainMvpView> presenter) {
return presenter;
}
@Provides
CompositeDisposable provideCompositeDisposable() {
return new CompositeDisposable();
}
@Provides
CarAdapter provideCarAdapter( @ActivityContext Context context) {
return new CarAdapter(context);
}
}
</code></pre>
| 0debug |
variable conditions from mysql in switch case on php/mysql? : <p>my problem is that i have to implement variable conditions which means that the user is able to define a VALUE for period of time.This data will be stored in mysql. PHP is used on server-side.</p>
<p>i.e.</p>
<pre><code>FROM 2018-01-01 TO 2018-01-03 VALUE 10;
FROM 2018-01-04 TO 2018-01-06 VALUE 20;
DEFAULT (used if not in time gap) VALUE 100;
</code></pre>
<p>Therefore I thought a switch case can be an option. But is it possible to have a foreach loop on cases?</p>
<p>like:</p>
<pre><code>$date = "2018-01-01";
switch ($date) {
foreach(... as $data){
case $data:
//load variable
break;
}
default:
//load default values
}
</code></pre>
<p>Maybe i'm on the wrong way - pls hlp.</p>
| 0debug |
Is there a .NET Core socket-io client implementation? : <p>Is there a c# client that follows the socket.io protocol? I have an NodeJS application that runs a socket-io server and I need a client in another application in .Net Core that needs to communicate with the socket-io server.</p>
<p>These are some implementations that I've found:</p>
<p><a href="https://github.com/Quobject/SocketIoClientDotNet" rel="noreferrer">SocketIoClientDotNet</a> - Deprecated</p>
<p><a href="https://archive.codeplex.com/?p=socketio4net" rel="noreferrer">socketio4net</a> - Deprecated</p>
<p><a href="https://github.com/IBM/socket-io" rel="noreferrer">IBM.Socket-IO</a> - Doesn't Work in .NET Core</p>
<p>Is there anything more recent that is being maintained that can accomplish this task?</p>
| 0debug |
static void bitband_writeb(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
uint32_t addr;
uint8_t mask;
uint8_t v;
addr = bitband_addr(opaque, offset);
mask = (1 << ((offset >> 2) & 7));
cpu_physical_memory_read(addr, &v, 1);
if (value & 1)
v |= mask;
else
v &= ~mask;
cpu_physical_memory_write(addr, &v, 1);
}
| 1threat |
I am trying to make the user not needing to type in http://. How do I have an input that is prefilled in Python? : <p>I want to have an already prefilled input for the user so they do not need to type in http://. I tried <code>"prefilled=http://"</code> but that did not work.</p>
<pre><code>url = input("Enter a URL address starting with http:// ")
</code></pre>
| 0debug |
static int dx2_decode_slice_5x5(GetBitContext *gb, AVFrame *frame,
int line, int left, uint8_t lru[3][8],
int is_565)
{
int x, y;
int r, g, b;
int width = frame->width;
int stride = frame->linesize[0];
uint8_t *dst = frame->data[0] + stride * line;
for (y = 0; y < left && get_bits_left(gb) > 16; y++) {
for (x = 0; x < width; x++) {
b = decode_sym_565(gb, lru[0], 5);
g = decode_sym_565(gb, lru[1], is_565 ? 6 : 5);
r = decode_sym_565(gb, lru[2], 5);
dst[x * 3 + 0] = (r << 3) | (r >> 2);
dst[x * 3 + 1] = is_565 ? (g << 2) | (g >> 4) : (g << 3) | (g >> 2);
dst[x * 3 + 2] = (b << 3) | (b >> 2);
}
dst += stride;
}
return y;
}
| 1threat |
I want to give serial no in my Query according to Group , how i can write for this query : AS per my below query it print group by data , but i want to give seq serial no per group like for first group 1 , 2 , 3 and then next group again 1, 2 , 3 like this
**select tour_no,version_no,itinerary_detail_no from itinerary_detail group by tour_no,version_no,itinerary_detail_no order by count(*) desc** | 0debug |
How Do I Catch Errors for JUnit Tests? : I'm writing tests for some code I was given. There is a constructor that takes and int as the first parameter. I want to test that it gives an error if something such as a boolean is passed in so I wrote this code.
try
{
nanReview = new WorkshopReview(true, "test");
}
catch (Error err)
{
assertEquals(err.getMessage(), "incompatible types: boolean cannot be converted to int");
}
When I run the test it just throws the error into the console again, shouldn't the test pass at this point because it throws the expected error message?
How do I go about testing stuff like this / should I even be testing this in the first place? | 0debug |
ASP.NET Core Localization with help of SharedResources : <p>Hi I have a question about the SharedResources file. It is glanced over in the tutorial here: <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization" rel="noreferrer"><a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization" rel="noreferrer">https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization</a></a>, and I'm not sure if I get it correctly.</p>
<p>I am supposed to create a <code>SharedResources.cs</code> class, but where should i put it and should it be empty or do I need to fill it with some data?</p>
<p>Same goes for the resource file, should I create a <code>SharedResources.da.resx</code> file and put all my shared strings there? Where should it go?</p>
<p>And when I use <code>IHtmlLocalizer<SharedResources></code> do I just write <code>@using</code> and point it to the namespace where <code>SharedResources.cs</code> resides?</p>
<p>I tried putting <code>SharedResources.cs</code> and <code>SharedResources.da.resx</code> in the Resources folder and use it to change website language to Danish, but it does not work. Using dedicated Resource file like <code>Index.da.resx</code> and <code>IViewLocalizer</code> works fine, but <code>IHtmlLocalizer<SharedResources></code> does not seem to work.</p>
<p>When I looked at the example project linked to at the bottom of the page I didn't find any place where SharedResources is used, it would be great if somebody updated it with an example of that.</p>
<p>Here's how I tried to do it:</p>
<p>Views/Home/Index.cshtml:</p>
<pre><code>@using Funkipedia.Resources
@using Microsoft.AspNetCore.Mvc.Localization
@inject IHtmlLocalizer<Shared> SharedLocalizer
...
<p>@SharedLocalizer["Hei"]</p>
...
</code></pre>
<p>At top of ConfigureServices in Startup.cs:</p>
<pre><code>services.AddLocalization(options => options.ResourcesPath = "Resources");
services.AddMvc()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
</code></pre>
<p>At top of Configure in Startup.cs:</p>
<pre><code>var supportedCultures = new List<CultureInfo>
{
new CultureInfo("nb-NO"),
new CultureInfo("sv-SE"),
new CultureInfo("da-DK")
};
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("nb-NO"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
</code></pre>
<p>Resources folder contains empty class called <code>Shared.cs</code> and <code>Shared.da.resx</code> which contains shared strings. Do I maybe need to change the name of it to <code>SharedResources.cs</code> and <code>SharedResources.da.resx</code>?</p>
| 0debug |
Goroutines and mutex : <pre><code>func (s *Server) start() {
s.Lock()
defer s.Unlock()
if !s.isClosed{
go s.processing()
}
go s.start()
}
func (s *Server) processing() {
s.Lock()
// do stuff
s.Unlock()
}
</code></pre>
<p>I have a working Golang project that has a block of code following the logic shown above. </p>
<p>I don't understand why this logic works as I would've expected a deadlock. </p>
| 0debug |
Python reading only some lines of a text file : <p>I have text file like the following and what I would like to do it read three lines that start with 0 and three lines that start with 1 and so on until 30-40. And would like to print them on the same line. How could I accomplish this? Thank you very much!</p>
<pre><code>0 something
0 something2
0 something3
0 something4
0 something5
0 something6
1 something
1 something2
1 something3
1 something4
1 something5
1 something6
</code></pre>
<p>Desired output:</p>
<pre><code>0 something something2 something3
1 something something2 something3
</code></pre>
| 0debug |
static int check_strtox_error(const char *p, char *endptr, const char **next,
int err)
{
if (err == 0 && endptr == p) {
err = EINVAL;
}
if (!next && *endptr) {
return -EINVAL;
}
if (next) {
*next = endptr;
}
return -err;
}
| 1threat |
vmxnet3_read_next_rx_descr(VMXNET3State *s, int qidx, int ridx,
struct Vmxnet3_RxDesc *dbuf, uint32_t *didx)
{
Vmxnet3Ring *ring = &s->rxq_descr[qidx].rx_ring[ridx];
*didx = vmxnet3_ring_curr_cell_idx(ring);
vmxnet3_ring_read_curr_cell(ring, dbuf);
}
| 1threat |
Is it Possible to Read Specific Block of Text : <p>Is it possible to use <code>Streamreader</code> (or I guess something other than <code>Streamreader</code>) to read a specific block of text? An example would be that I have chart like data in a text file that is separated by date and I want to read each day's data separately. Example of the data is shown below.</p>
<p><a href="https://i.stack.imgur.com/ZjEMG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZjEMG.png" alt="enter image description here"></a></p>
<ul>
<li>Blue - The date </li>
<li>Red - The first chunk of data I want pull per day</li>
<li>Green - The second chunk of data I want pull per day (only the numbers need to be read)</li>
</ul>
<p>When I search for methods to do this I seem to only find reading entire text files or read individuals lines. The second option may seem feasible but the problem there is that I don't have the same amount of entries every day so I would need to dynamically determine how many lines to read. I am thinking the best approach would be to tell my <code>Streamreader</code> to read all the text between two words like "FAIL" and "Total". But since I can't find anything online I'm not sure if it's possible and if it is, how to go about doing it. Any help is appreciated.</p>
<p>Incase it matters I plan on taking the text from the file into Excel so I'll probably have to put the output into an array or something but that's a problem for later.</p>
| 0debug |
static void virtio_9p_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->props = virtio_9p_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->realize = virtio_9p_device_realize;
vdc->get_features = virtio_9p_get_features;
vdc->get_config = virtio_9p_get_config;
} | 1threat |
Python how to find and group similar permutations of 4 digits : I am not good at these, but please bear with me.
I have a set of numbers from my database / list, all is 4 digit numbers with the numbers between and include 0000 through 9999.
Say the `list = [1234, 4354, 6554, 2134, 3214, 5456, 9911, 1199]`
Basically i want to group them in such a way:
1234, 2134, 3214 is group A
6554, 5456 is group B
9911, 1199 is group C
4354 is group D
Then i will find the len(group A), len(group B), len(group C), len(group D)...
and then sort them in decreasing manner.
How to do it?
And if list is huge, is the method still works ok?
| 0debug |
How to check expected intent sent without actually launching activity in Espresso? : <p>I have a UI test which clicks a button, and then launch a new Activity in its onClickListener. The test checks whether expected intent is sent or not.</p>
<p>My problem is, I want to test whether expected intent is sent <strong>without actually launching the activity</strong>. Because I found that new activity initializes its state, and it makes subsequent tests flaky. </p>
<p>I know there are two <a href="https://google.github.io/android-testing-support-library/docs/espresso/intents/index.html" rel="noreferrer">Espresso Intents</a> api, which are <code><a href="https://developer.android.com/reference/android/support/test/espresso/intent/Intents.html#intended(org.hamcrest.Matcher%3Candroid.content.Intent%3E)" rel="noreferrer">intended</a></code> and <code><a href="https://developer.android.com/reference/android/support/test/espresso/intent/Intents.html#intending(org.hamcrest.Matcher%3Candroid.content.Intent%3E)" rel="noreferrer">intending</a></code>, but both fail to meet my needs. <code>intended</code> api actually launches the target activity, and <code>intending</code> api doesn't launch the activity, but it calls <code>onActivityResult</code> callback which I don't want either. Because I'm afraid that code inside <code>onActivityResult</code> may cause another flakiness. Also <code>intending</code> doesn't assert whether matching intent is sent, it just calls <code>onActivityResult</code> callback when matching intent is found, which means I have to check whether <code>onActivityResult</code> is called or not!</p>
<p>Is there any clean way to achieve what I want?</p>
| 0debug |
converting a activity to fragment it shows some errors on array adapter : <pre><code>protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnScan = (Button)findViewById(R.id.scan);
listViewIp = (ListView)findViewById(R.id.listviewip);
bar = (ProgressBar) findViewById(R.id.pbar);
bar.setVisibility(View.INVISIBLE);
ipList = new ArrayList();
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, ipList);
listViewIp.setAdapter(adapter);
btnScan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ScanIpTask().execute();
}
});
</code></pre>
<p>convert it to fragment</p>
<p>ArrayList ipList;
ArrayAdapter adapter;</p>
<pre><code>@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_scan_ip, container, false);
btnScan = (Button)rootView.findViewById(R.id.scan);
listViewIp = (ListView)rootView.findViewById(R.id.listviewip);
bar = (ProgressBar) rootView.findViewById(R.id.pbar);
bar.setVisibility(View.INVISIBLE);
ipList = new ArrayList();
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, ipList);
listViewIp.setAdapter(adapter);
btnScan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ScanIpTask().execute();
}
});
return rootView;
}
</code></pre>
<p>it shows error in this line</p>
<p>adapter = new ArrayAdapter(this,
android.R.layout.simple_list_item_1, android.R.id.text1, ipList);</p>
| 0debug |
App is force closing when a button is clicked inside a fragment : I just started converting my activities to fragments,, just finished a activity and found out that when I click on button in that activity the app is force closing!!!
This is my activity class: Attendence
package wonderkids.wonderkids;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import static wonderkids.wonderkids.R.layout.exam;
public class Attendence extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(exam);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onSupportNavigateUp(){
finish();
return true;
}
Intent browserIntent;
public void one(View v) {
Button clickedButton = (Button) v;
switch (clickedButton.getId()) {
case R.id.button:
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;
case R.id.button2:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button3:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button4:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button5:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button6:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button7:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button8:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button9:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button10:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
/*case R.id.fab:{
Intent i = new Intent(Exams.this, Home.class);
startActivity(i);
break;
}*/
}
startActivity(browserIntent);
}
}
This is the fragment which should replace Attendence
Attendance.java
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
package wonderkids.wonderkids;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import static wonderkids.wonderkids.R.layout.exam;
/**
* A simple {@link Fragment} subclass.
*/
public class Attendance extends Fragment {
public Attendance() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.exam, container,false);
}
Intent browserIntent;
public void one(View v) {
Button clickedButton = (Button) v;
switch (clickedButton.getId()) {
case R.id.button:
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;
case R.id.button2:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button3:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button4:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button5:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button6:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button7:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button8:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button9:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
case R.id.button10:{
browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
break;}
}
startActivity(browserIntent);
}
}
<!-- end snippet -->
This is the main class which switches fragments:
Check onNavigationItemSelected...
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
package wonderkids.wonderkids;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
public class Home extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
private static final String LOG_TAG =
Home.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.start);
Log.d(LOG_TAG,"In Create");
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
Log.d(LOG_TAG,"In Create");
}
public void gall1(View view){
Intent myIntent = new Intent(view.getContext(), Gallery.class);
startActivityForResult(myIntent, 0);
}
public void hw1(View view){
Intent myIntent = new Intent(view.getContext(), Hworks.class);
startActivityForResult(myIntent, 0);
}
public void con1(View view){
Intent myIntent = new Intent(view.getContext(), Contact.class);
startActivityForResult(myIntent, 0);
}
public void res1(View view){
Intent myIntent = new Intent(view.getContext(), Results.class);
startActivityForResult(myIntent, 0);
}
public void sta1(View view){
Intent myIntent = new Intent(view.getContext(), Staff.class);
startActivityForResult(myIntent, 0);
}
public void bus1(View view){
Intent browserIntent=new Intent(Intent.ACTION_VIEW,Uri.parse("https://www.google.com"));
startActivity(browserIntent);
}
public void exa1(View view){
Intent myIntent = new Intent(view.getContext(), Exams.class);
startActivityForResult(myIntent, 0);
}
public void att1(View view){
Intent myIntent = new Intent(view.getContext(), Attendence.class);
startActivityForResult(myIntent, 0);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.home, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
else if(id==R.id.action_exit) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
Fragment fragment = new Fragment();
if (id == R.id.nav_home) {
Intent i = new Intent(Home.this, Home.class);
startActivity(i);
} else if (id == R.id.nav_gal1ery) {
Intent i = new Intent(Home.this, Gallery.class);
startActivity(i);
} else if (id == R.id.nav_exams) {
Intent i = new Intent(Home.this, Exams.class);
startActivity(i);
} else if (id == R.id.nav_attendence) {
fragment = new Attendance();
} else if (id == R.id.nav_results) {
Intent i = new Intent(Home.this, Results.class);
startActivity(i);
} else if (id == R.id.nav_share) {
try {
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_SUBJECT, "Wonder Kids");
String sAux = "\nTry This\n";
sAux = sAux + "https://play.google.com/store/apps/details?id=Orion.Soft \n\n";
i.putExtra(Intent.EXTRA_TEXT, sAux);
startActivity(Intent.createChooser(i, "choose one"));
} catch(Exception e) {
//e.toString();
}
} else if (id == R.id.nav_cotact) {
Intent i = new Intent(Home.this, Contact.class);
startActivity(i);
} else if (id == R.id.nav_newsletter) {
Intent browserIntent=new Intent(Intent.ACTION_VIEW,Uri.parse("https://www.google.com"));
startActivity(browserIntent);
}
transaction.replace(R.id.fragment_container, fragment);
transaction.commit();
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
}
<!-- end snippet -->
And this is the xml file for Attendance(fragment) which I also used for Attendence(activity) and many other... (buttons work fine when accessing exam.xml from another activity)
exam.xml
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back"
tools:context="wonderkids.wonderkids.Attendance">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="27dp"
android:layout_marginStart="27dp"
android:onClick="one"
android:text="1st class"
app:layout_constraintBaseline_toBaselineOf="@+id/button2"
app:layout_constraintLeft_toLeftOf="parent"
tools:layout_constraintBaseline_creator="1"
tools:layout_constraintLeft_creator="1" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="26dp"
android:onClick="one"
android:text="3rd class"
app:layout_constraintBaseline_toBaselineOf="@+id/button2"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintBaseline_creator="1"
tools:layout_constraintRight_creator="1" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="27dp"
android:onClick="one"
android:text="4th class"
app:layout_constraintBaseline_toBaselineOf="@+id/button6"
app:layout_constraintLeft_toLeftOf="parent"
tools:layout_constraintBaseline_creator="1"
tools:layout_constraintLeft_creator="1" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:onClick="one"
android:text="6th class"
app:layout_constraintBaseline_toBaselineOf="@+id/button6"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintBaseline_creator="1"
tools:layout_constraintRight_creator="1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="55dp"
android:onClick="one"
android:text="2nd class"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1" />
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:onClick="one"
android:text="5th class"
app:layout_constraintLeft_toLeftOf="@+id/button2"
app:layout_constraintRight_toRightOf="@+id/button2"
app:layout_constraintTop_toBottomOf="@+id/button2"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1" />
<Button
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:onClick="one"
android:text="7th class"
app:layout_constraintLeft_toLeftOf="@+id/button4"
app:layout_constraintRight_toRightOf="@+id/button4"
app:layout_constraintTop_toBottomOf="@+id/button4"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1" />
<Button
android:id="@+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:onClick="one"
android:text="8th class"
app:layout_constraintLeft_toLeftOf="@+id/button6"
app:layout_constraintRight_toRightOf="@+id/button6"
app:layout_constraintTop_toBottomOf="@+id/button6"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1" />
<Button
android:id="@+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:onClick="one"
android:text="9th class"
app:layout_constraintLeft_toLeftOf="@+id/button5"
app:layout_constraintRight_toRightOf="@+id/button5"
app:layout_constraintTop_toBottomOf="@+id/button5"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1" />
<Button
android:id="@+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="38dp"
android:onClick="one"
android:text="10th class"
app:layout_constraintLeft_toLeftOf="@+id/button8"
app:layout_constraintTop_toBottomOf="@+id/button8"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintTop_creator="1" />
</android.support.constraint.ConstraintLayout>
</FrameLayout>
<!-- end snippet -->
And if needed this is the empty container:
startac.xml
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragment_container"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
<!-- end snippet -->
And when I see Attendance(fragment) near
import static wonderkids.wonderkids.R.layout.exam;
and
one in public void one(View v) {
I get unused import statement and method one is never used!!
If u need any extra code or didn't understand my question please comment!! | 0debug |
void kvm_s390_virtio_irq(S390CPU *cpu, int config_change, uint64_t token)
{
kvm_s390_interrupt_internal(cpu, KVM_S390_INT_VIRTIO, config_change,
token, 1);
}
| 1threat |
START_TEST(qstring_destroy_test)
{
QString *qstring = qstring_from_str("destroy test");
QDECREF(qstring);
}
| 1threat |
JS setTimeout Not Delayed : <p>I'm trying to put a delay in <strong>front</strong> of an <code>AJAX</code> call. </p>
<pre><code>var delay = 2000;
$("#c_name").on("keyup", function() {
var entered = $(this).val();
if (entered.length > 1) {
setTimeout(dosearch(entered), delay)
}
});
</code></pre>
<p>Fo some reason I can't seem to get <code>setTimeout</code> to take hold. It's performing the <code>dosearch()</code> function instantly. </p>
<p>How can I get this to delay properly? Yes <code>JQuery 3.3.1</code> is loaded up top. </p>
| 0debug |
CSS "inline-block" value not working with images : <p>With the "inline-block" value in CSS3, I am trying to align images into the center but it isn't aligning!</p>
<p>I have tried using the "block" value as well but it still doesn't work. Is it my PC? Is it the browser?</p>
<pre><code>.link-images-js{
display: inline-block;
text-align: center;
}
</code></pre>
<p>With Visual Studio Code it doesn't detect anything wrong, same with NP++ and Sublime Text 3. With the "inline-block" value, it has worked once but after that it hasn't worked. Does anyone have any idea what the problem is?</p>
| 0debug |
JSON object clone : <pre><code>this.a = JSON.parse(JSON.stringify(response.data));
this.b = JSON.parse(JSON.stringify(response.data));
</code></pre>
<p>After doing this,i found that a and b have some sort of link that i change value of a, sometimes b also changes.
I want to know how to make a and b don't effect each other's value</p>
| 0debug |
void memory_region_init_io(MemoryRegion *mr,
Object *owner,
const MemoryRegionOps *ops,
void *opaque,
const char *name,
uint64_t size)
{
memory_region_init(mr, owner, name, size);
mr->ops = ops;
mr->opaque = opaque;
mr->terminates = true;
mr->ram_addr = ~(ram_addr_t)0;
}
| 1threat |
Remove/change section header background color in SwiftUI List : <p>With a simple <code>List</code> in SwiftUI, how do I change/remove the standard background color for the section header</p>
<pre><code>struct ContentView : View {
var body: some View {
List {
ForEach(0...3) { section in
Section(header: Text("Section")) {
ForEach(0...3) { row in
Text("Row")
}
}
}
}
}
}
</code></pre>
<p><a href="https://i.stack.imgur.com/VFPk4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VFPk4.png" alt="Screenshot with grey section header background"></a></p>
| 0debug |
void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
ISADevice **rtc_state,
ISADevice **floppy,
bool no_vmport)
{
int i;
DriveInfo *fd[MAX_FD];
DeviceState *hpet = NULL;
int pit_isa_irq = 0;
qemu_irq pit_alt_irq = NULL;
qemu_irq rtc_irq = NULL;
qemu_irq *a20_line;
ISADevice *i8042, *port92, *vmmouse, *pit;
qemu_irq *cpu_exit_irq;
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
if (!no_hpet && (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) {
hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL);
if (hpet) {
for (i = 0; i < GSI_NUM_PINS; i++) {
sysbus_connect_irq(sysbus_from_qdev(hpet), i, gsi[i]);
}
pit_isa_irq = -1;
pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT);
rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT);
}
}
*rtc_state = rtc_init(isa_bus, 2000, rtc_irq);
qemu_register_boot_set(pc_boot_set, *rtc_state);
if (kvm_irqchip_in_kernel()) {
pit = kvm_pit_init(isa_bus, 0x40);
} else {
pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
}
if (hpet) {
qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(&pit->qdev, 0));
}
pcspk_init(isa_bus, pit);
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
serial_isa_init(isa_bus, i, serial_hds[i]);
}
}
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
if (parallel_hds[i]) {
parallel_init(isa_bus, i, parallel_hds[i]);
}
}
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
i8042 = isa_create_simple(isa_bus, "i8042");
i8042_setup_a20_line(i8042, &a20_line[0]);
if (!no_vmport) {
vmport_init(isa_bus);
vmmouse = isa_try_create(isa_bus, "vmmouse");
} else {
vmmouse = NULL;
}
if (vmmouse) {
qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
qdev_init_nofail(&vmmouse->qdev);
}
port92 = isa_create_simple(isa_bus, "port92");
port92_init(port92, &a20_line[1]);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
*floppy = fdctrl_init_isa(isa_bus, fd);
}
| 1threat |
how can i make an html list in jquery or javascript? : <p>I want to make a list in HTML and then the user selects the list and then do something with the selections.</p>
<p>For example. List of fruits. Apple bannana, grapes.</p>
<p>User selects grapes and if grapes is selected asked how many grapes?</p>
<p>I would like to know how i can do this in Javascript or Jquery</p>
| 0debug |
static inline TCGv gen_load(DisasContext * s, int opsize, TCGv addr, int sign)
{
TCGv tmp;
int index = IS_USER(s);
s->is_mem = 1;
tmp = tcg_temp_new_i32();
switch(opsize) {
case OS_BYTE:
if (sign)
tcg_gen_qemu_ld8s(tmp, addr, index);
else
tcg_gen_qemu_ld8u(tmp, addr, index);
break;
case OS_WORD:
if (sign)
tcg_gen_qemu_ld16s(tmp, addr, index);
else
tcg_gen_qemu_ld16u(tmp, addr, index);
break;
case OS_LONG:
case OS_SINGLE:
tcg_gen_qemu_ld32u(tmp, addr, index);
break;
default:
qemu_assert(0, "bad load size");
}
gen_throws_exception = gen_last_qop;
return tmp;
}
| 1threat |
MIMEMultipart, MIMEText, MIMEBase, and payloads for sending email with file attachment in Python : <p>Without much prior knowledge of MIME, I tried to learned how to write a Python script to send an email with a file attachment. After cross-referencing Python documentation, Stack Overflow questions, and general web searching, I settled with the following code <sup>[1]</sup> and tested it to be working. </p>
<pre><code>import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email import encoders
fromaddr = "YOUR EMAIL"
toaddr = "EMAIL ADDRESS YOU SEND TO"
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "SUBJECT OF THE EMAIL"
body = "TEXT YOU WANT TO SEND"
msg.attach(MIMEText(body, 'plain'))
filename = "NAME OF THE FILE WITH ITS EXTENSION"
attachment = open("PATH OF THE FILE", "rb")
part = MIMEBase('application', 'octet-stream')
part.set_payload((attachment).read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', "attachment; filename= %s" % filename)
msg.attach(part)
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromaddr, "YOUR PASSWORD")
text = msg.as_string()
server.sendmail(fromaddr, toaddr, text)
server.quit()
</code></pre>
<ol>
<li><p>I have a rough idea of how this script works now, and worked out the following workflow. Please let me know how accurate my flowchart(?) is. </p>
<pre><code> as.string()
|
+------------MIMEMultipart
| |---content-type
| +---header---+---content disposition
+----.attach()-----+----MIMEBase----|
| +---payload (to be encoded in Base64)
+----MIMEText
</code></pre></li>
<li><p>How do I know when to use MIMEMultipart, MIMEText and MIMEBase? This seems like a complicated question, so maybe just offer some general rules-of-thumb to me?</p></li>
<li>I read that MIME has a tree-like structure<sup>[2]</sup> , does that mean MIMEMultipart is always at the top? </li>
<li>In the first code block, MIMEMultipart encodes ['From'], ['To'], and ['Subject'], but in the Python documentation, MIMEText can also be used to encode ['From'], ['To'], and ['Subject']. How to do I decide one to use?</li>
<li>What exactly is a "payload"? Is it some content to be transported? If so, what kind of content does this include (I noticed that body text and attachment are treated as payloads)? I thought this would be an easy question but I just could not find a satisfying, reliable, and simple answer. </li>
<li>Is is true that although MIME can attach file formats much simpler than just some texts, at the end all the encoding, header information, and payloads are all turned into strings so that they can be passed into .sendmail()?</li>
</ol>
<p>[1]<a href="http://naelshiab.com/tutorial-send-email-python/" rel="noreferrer">http://naelshiab.com/tutorial-send-email-python/</a><br>
[2]<a href="http://blog.magiksys.net/generate-and-send-mail-with-python-tutorial" rel="noreferrer">http://blog.magiksys.net/generate-and-send-mail-with-python-tutorial</a> </p>
| 0debug |
void ppc_hash64_stop_access(PowerPCCPU *cpu, uint64_t token)
{
if (cpu->env.external_htab == MMU_HASH64_KVM_MANAGED_HPT) {
kvmppc_hash64_free_pteg(token);
}
}
| 1threat |
static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
{
int ret, i;
AVFormatContext *dev = NULL;
AVDeviceInfoList *device_list = NULL;
AVDictionary *tmp_opts = NULL;
if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category))
return AVERROR(EINVAL);
printf("Audo-detected sources for %s:\n", fmt->name);
if (!fmt->get_device_list) {
ret = AVERROR(ENOSYS);
printf("Cannot list sources. Not implemented.\n");
goto fail;
}
av_dict_copy(&tmp_opts, opts, 0);
if ((ret = avformat_open_input(&dev, NULL, fmt, &tmp_opts)) < 0) {
printf("Cannot open device: %s.\n", fmt->name);
goto fail;
}
if ((ret = avdevice_list_devices(dev, &device_list)) < 0) {
printf("Cannot list sources.\n");
goto fail;
}
for (i = 0; i < device_list->nb_devices; i++) {
printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ",
device_list->devices[i]->device_name, device_list->devices[i]->device_description);
}
fail:
av_dict_free(&tmp_opts);
avdevice_free_list_devices(&device_list);
avformat_close_input(&dev);
return ret;
}
| 1threat |
static int nbd_parse_uri(const char *filename, QDict *options)
{
URI *uri;
const char *p;
QueryParams *qp = NULL;
int ret = 0;
bool is_unix;
uri = uri_parse(filename);
if (!uri) {
return -EINVAL;
}
if (!strcmp(uri->scheme, "nbd")) {
is_unix = false;
} else if (!strcmp(uri->scheme, "nbd+tcp")) {
is_unix = false;
} else if (!strcmp(uri->scheme, "nbd+unix")) {
is_unix = true;
} else {
ret = -EINVAL;
goto out;
}
p = uri->path ? uri->path : "/";
p += strspn(p, "/");
if (p[0]) {
qdict_put(options, "export", qstring_from_str(p));
}
qp = query_params_parse(uri->query);
if (qp->n > 1 || (is_unix && !qp->n) || (!is_unix && qp->n)) {
ret = -EINVAL;
goto out;
}
if (is_unix) {
if (uri->server || uri->port || strcmp(qp->p[0].name, "socket")) {
ret = -EINVAL;
goto out;
}
qdict_put(options, "server.type", qstring_from_str("unix"));
qdict_put(options, "server.data.path",
qstring_from_str(qp->p[0].value));
} else {
QString *host;
char *port_str;
if (!uri->server) {
ret = -EINVAL;
goto out;
}
if (uri->server[0] == '[') {
host = qstring_from_substr(uri->server, 1,
strlen(uri->server) - 2);
} else {
host = qstring_from_str(uri->server);
}
qdict_put(options, "server.type", qstring_from_str("inet"));
qdict_put(options, "server.data.host", host);
port_str = g_strdup_printf("%d", uri->port ?: NBD_DEFAULT_PORT);
qdict_put(options, "server.data.port", qstring_from_str(port_str));
g_free(port_str);
}
out:
if (qp) {
query_params_free(qp);
}
uri_free(uri);
return ret;
}
| 1threat |
What does docker container exit status 255 mean? : <p>The <a href="https://docs.docker.com/engine/reference/commandline/ps/#filtering" rel="noreferrer">doc</a> mentions</p>
<blockquote>
<p>You can use a filter to locate containers that exited with status of
137 meaning a SIGKILL(9) killed them</p>
</blockquote>
<p>I'm wondering does exit status 255 mean anything special?</p>
| 0debug |
Can't Draw Filled Rectangle in OpenGL : <p>I am trying to draw a simple filled rectangle in OpenGL. All Google searching tells me that glRectf() should do this, by specifying the color beforehand with glColor4f(), however the rectangle is always drawn unfilled (borders only).</p>
<p>Is there anything I am missing, or need to specify in the code beforehand? Thanks!</p>
| 0debug |
I'm trying to run a .sh file on command prompt and I'm not familiar with the commands. :
>time ./wordcount.sh
> The system cannot accept the time entered.
> Enter the new time:
How can I fix this?
Thanks
| 0debug |
static inline void check_hwrena(CPUMIPSState *env, int reg)
{
if ((env->hflags & MIPS_HFLAG_CP0) || (env->CP0_HWREna & (1 << reg))) {
return;
}
do_raise_exception(env, EXCP_RI, GETPC());
}
| 1threat |
how to develop PHP and MYSQL ecommerce website without CMS : <p>i am a magento developer, one of my client want Pure PHP ecommerce website, client dont want any CMS. </p>
<p>i searched on the internet but i didn't get the idea. anybody please give me an idea how to develop ecommerce website using php.</p>
<p>sujjest any tutorials or free demo templates include both frontend and backend with the database</p>
<p>Thanks in advance</p>
| 0debug |
filter data remove entire dataframe : my data like this
X1e X2e X3e X4e
360 0 0 0
360 0 0 0
260 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
90 0 0 0
360 0 360 0
360 0 360 260
I want to remove the X1e X4e columns between 0 and 270, did not remove 0 row
for (i in c(1,4)){
e <- assign(paste("X",i, "e",sep = ""),i)
dat <- dat[with(dat, !((e>0)&(e<270))), ]
}
but it remove all my dat and my dat became empty, where is my problem
| 0debug |
instance::class.java vs. instance.javaClass : <p>Given Kotlin 1.1. For an <code>instance</code> of some class, <code>instance::class.java</code> and <code>instance.javaClass</code> seem to be nearly equivalent:</p>
<pre><code>val i = 0
println(i::class.java) // int
println(i.javaClass) // int
println(i::class.java === i.javaClass) // true
</code></pre>
<p>There is a subtle difference, however:</p>
<pre><code>val c1: Class<out Int> = i::class.java
val c2: Class<Int> = i.javaClass
</code></pre>
<p><code>instance.javaClass</code> is negligibly shorter, but <code>instance::class.java</code> is more consistent with the corresponding usage on a type. While you can use <code>.javaClass</code> on some types, the result may not be what you would expect:</p>
<pre><code>println(i::class.java === Int::class.java) // true
println(i.javaClass === Int.javaClass) // false
println(Int::class.java === Int.javaClass) // false
println(Int.javaClass) // class kotlin.jvm.internal.IntCompanionObject
</code></pre>
<p>So, I would argue that it is better to never use <code>.javaClass</code> for more consistency. Are there any arguments against that?</p>
| 0debug |
setup_sigcontext(CPUMIPSState *regs, struct target_sigcontext *sc)
{
int err = 0;
int i;
__put_user(exception_resume_pc(regs), &sc->sc_pc);
regs->hflags &= ~MIPS_HFLAG_BMASK;
__put_user(0, &sc->sc_regs[0]);
for (i = 1; i < 32; ++i) {
__put_user(regs->active_tc.gpr[i], &sc->sc_regs[i]);
}
__put_user(regs->active_tc.HI[0], &sc->sc_mdhi);
__put_user(regs->active_tc.LO[0], &sc->sc_mdlo);
__put_user(regs->active_tc.HI[1], &sc->sc_hi1);
__put_user(regs->active_tc.HI[2], &sc->sc_hi2);
__put_user(regs->active_tc.HI[3], &sc->sc_hi3);
__put_user(regs->active_tc.LO[1], &sc->sc_lo1);
__put_user(regs->active_tc.LO[2], &sc->sc_lo2);
__put_user(regs->active_tc.LO[3], &sc->sc_lo3);
{
uint32_t dsp = cpu_rddsp(0x3ff, regs);
__put_user(dsp, &sc->sc_dsp);
}
__put_user(1, &sc->sc_used_math);
for (i = 0; i < 32; ++i) {
__put_user(regs->active_fpu.fpr[i].d, &sc->sc_fpregs[i]);
}
return err;
}
| 1threat |
static int v4l2_read_header(AVFormatContext *s1)
{
struct video_data *s = s1->priv_data;
AVStream *st;
int res = 0;
uint32_t desired_format;
enum AVCodecID codec_id = AV_CODEC_ID_NONE;
enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
struct v4l2_input input = { 0 };
st = avformat_new_stream(s1, NULL);
if (!st)
return AVERROR(ENOMEM);
#if CONFIG_LIBV4L2
v4l2_log_file = fopen("/dev/null", "w");
#endif
s->fd = device_open(s1);
if (s->fd < 0)
return s->fd;
if (s->channel != -1) {
av_log(s1, AV_LOG_DEBUG, "Selecting input_channel: %d\n", s->channel);
if (v4l2_ioctl(s->fd, VIDIOC_S_INPUT, &s->channel) < 0) {
res = AVERROR(errno);
av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_S_INPUT): %s\n", av_err2str(res));
return res;
}
} else {
if (v4l2_ioctl(s->fd, VIDIOC_G_INPUT, &s->channel) < 0) {
res = AVERROR(errno);
av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_INPUT): %s\n", av_err2str(res));
return res;
}
}
input.index = s->channel;
if (v4l2_ioctl(s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
res = AVERROR(errno);
av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMINPUT): %s\n", av_err2str(res));
return res;
}
s->std_id = input.std;
av_log(s1, AV_LOG_DEBUG, "Current input_channel: %d, input_name: %s\n",
s->channel, input.name);
if (s->list_format) {
list_formats(s1, s->fd, s->list_format);
return AVERROR_EXIT;
}
if (s->list_standard) {
list_standards(s1);
return AVERROR_EXIT;
}
avpriv_set_pts_info(st, 64, 1, 1000000);
if (s->pixel_format) {
AVCodec *codec = avcodec_find_decoder_by_name(s->pixel_format);
if (codec)
s1->video_codec_id = codec->id;
pix_fmt = av_get_pix_fmt(s->pixel_format);
if (pix_fmt == AV_PIX_FMT_NONE && !codec) {
av_log(s1, AV_LOG_ERROR, "No such input format: %s.\n",
s->pixel_format);
return AVERROR(EINVAL);
}
}
if (!s->width && !s->height) {
struct v4l2_format fmt;
av_log(s1, AV_LOG_VERBOSE,
"Querying the device for the current frame size\n");
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (v4l2_ioctl(s->fd, VIDIOC_G_FMT, &fmt) < 0) {
res = AVERROR(errno);
av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_FMT): %s\n", av_err2str(res));
return res;
}
s->width = fmt.fmt.pix.width;
s->height = fmt.fmt.pix.height;
av_log(s1, AV_LOG_VERBOSE,
"Setting frame size to %dx%d\n", s->width, s->height);
}
res = device_try_init(s1, pix_fmt, &s->width, &s->height, &desired_format, &codec_id);
if (res < 0) {
v4l2_close(s->fd);
return res;
}
if (codec_id != AV_CODEC_ID_NONE && s1->video_codec_id == AV_CODEC_ID_NONE)
s1->video_codec_id = codec_id;
if ((res = av_image_check_size(s->width, s->height, 0, s1)) < 0)
return res;
s->frame_format = desired_format;
if ((res = v4l2_set_parameters(s1)) < 0)
return res;
st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id);
s->frame_size =
avpicture_get_size(st->codec->pix_fmt, s->width, s->height);
if ((res = mmap_init(s1)) ||
(res = mmap_start(s1)) < 0) {
v4l2_close(s->fd);
return res;
}
s->top_field_first = first_field(s->fd);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = codec_id;
if (codec_id == AV_CODEC_ID_RAWVIDEO)
st->codec->codec_tag =
avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
if (desired_format == V4L2_PIX_FMT_YVU420)
st->codec->codec_tag = MKTAG('Y', 'V', '1', '2');
else if (desired_format == V4L2_PIX_FMT_YVU410)
st->codec->codec_tag = MKTAG('Y', 'V', 'U', '9');
st->codec->width = s->width;
st->codec->height = s->height;
st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
return 0;
}
| 1threat |
static int get_qcc(J2kDecoderContext *s, int n, J2kQuantStyle *q, uint8_t *properties)
{
int compno;
if (s->buf_end - s->buf < 1)
return AVERROR(EINVAL);
compno = bytestream_get_byte(&s->buf);
properties[compno] |= HAD_QCC;
return get_qcx(s, n-1, q+compno);
}
| 1threat |
Solution to build dynamic forms with Android : <p>I am actually developing an Android application on which I should display dynamic forms based on metadata contained inside JSON documents. Basically the way it works (without the details) is that a JSON document represent the structure of a form:</p>
<pre><code>{
"fields": [
{
"name": "fieldA",
"type": "STRING",
"minCharacters": 10,
"maxCharacters": 100
},
{
"name": "fieldB",
"type": "INTEGER",
"min": 10,
"max": 100
},
{
"name": "fieldC",
"type": "BOOLEAN_CHECKBOX",
"defaultValue": true
}
...
],
"name": "Form A"
}
</code></pre>
<p>What I'm doing actually when the application receive one of those JSON documents is that it loop through each fields and parse it to the appropriate view (EditText, Checkbox, custom view, etc.), adding a tag to the view (to be able to retrieve it easily) and add the view to a <code>LinearLayout</code>. Here is a pseudo-code of how it is working actually:</p>
<pre><code>//Add form title
linearLayout.addView(new TextView(form.name));
//Add form fields
for(Field field: form.fields) {
View view;
switch(field.type){
case STRING: view = new EditText();
...
}
view.setTag(field.id);
linearLayout.addView(view);
}
</code></pre>
<p>The issue with this is that with large forms (like >20 fields), it need to inflate lot of views and the UI thread suffer a lot. Another point to take into account is that a single screen may have multiple forms (one after another vertically sorted).</p>
<p>To avoid overloading the UI thread I thought of 2 possible solutions:</p>
<ol>
<li><strong>Using a RecyclerView</strong>.</li>
<li><strong>Using <a href="https://fblitho.com/" rel="noreferrer">Litho by Facebook</a></strong>.</li>
</ol>
<p>But multiple questions comes to me when considering these 2 solutions:</p>
<ol>
<li>Is it a good use case to use Litho? Or using a RecyclerView is enough?</li>
<li>What about the state of my views? If I use a Recycling pattern, would I be able to keep the state of each of my fields (even those off-screen) and so being able to save the form without losing data?</li>
<li>If I use a Recycling pattern to display one form, how would I handle multiple forms? Can we have nested RecyclerView? Forms need to be displayed one after another like inside a vertical RV but if forms themselves are RV, how should I handle this?</li>
</ol>
<p>This is more a "good practice" question and giving the right way or one of the right way of achieving my goal than a need of a specific answer with code example, etc.</p>
<p>Thank's in advance for your time.</p>
| 0debug |
int ff_ape_write_tag(AVFormatContext *s)
{
AVDictionaryEntry *e = NULL;
int64_t start, end;
int size, count = 0;
if (!s->pb->seekable)
return 0;
start = avio_tell(s->pb);
avio_write(s->pb, "APETAGEX", 8);
avio_wl32 (s->pb, APE_TAG_VERSION);
avio_wl32(s->pb, 0);
avio_wl32(s->pb, 0);
avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_CONTAINS_FOOTER |
APE_TAG_FLAG_IS_HEADER);
ffio_fill(s->pb, 0, 8);
while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) {
int val_len = strlen(e->value);
avio_wl32(s->pb, val_len);
avio_wl32(s->pb, 0);
avio_put_str(s->pb, e->key);
avio_write(s->pb, e->value, val_len);
count++;
}
size = avio_tell(s->pb) - start;
avio_write(s->pb, "APETAGEX", 8);
avio_wl32 (s->pb, APE_TAG_VERSION);
avio_wl32(s->pb, size);
avio_wl32(s->pb, count);
avio_wl32(s->pb, APE_TAG_FLAG_CONTAINS_HEADER | APE_TAG_FLAG_CONTAINS_FOOTER);
ffio_fill(s->pb, 0, 8);
end = avio_tell(s->pb);
avio_seek(s->pb, start + 12, SEEK_SET);
avio_wl32(s->pb, size);
avio_wl32(s->pb, count);
avio_seek(s->pb, end, SEEK_SET);
return 0;
}
| 1threat |
Multiplication of positive integers results in 0 (__int64) : <p>I am trying to multiply four integers into a <code>__int64</code>. The value it should have is <code>4096 * 1024 * 64 * 64 = 17,179,869,184</code>. This is too large of a number to store in an <code>int</code>, thats why I'm using <code>__int64</code>.
The output I get however is <code>0</code>.</p>
<p>I've tried casting every single one of the integers to a <code>__int64</code>, which doesnt change the output from being <code>0</code>.
Also, if I check with a debugger, the value of <code>test</code> is in fact <code>0</code>, so it is not a problem with outputting it.</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
int main() {
__int64 test = (__int64)4096 * (__int64)1024 * (__int64)64 * (__int64)64;
printf("%d", test);
getchar();
}
</code></pre>
<p>The output:</p>
<pre><code>0
</code></pre>
<p>The expected output:</p>
<pre><code>17179869184
</code></pre>
| 0debug |
Prevent clang-format from collapsing multi-line if statements into a single line : <p>Using clang-format with default settings, the following:</p>
<pre><code>if ((exprA) &&
(exprB))
</code></pre>
<p>turns into:</p>
<pre><code>if ((exprA) && (exprB))
</code></pre>
<p>I'm trying to prevent the collapsing the conditions into a single line, with no success.<br>
Is there currently a way to achieve this?</p>
<p>In clang-format <a href="https://clang.llvm.org/docs/ClangFormatStyleOptions.html" rel="noreferrer">documentation</a>, the <code>BreakBeforeBinaryOperators</code> parameter seems the closest to what I'm after:</p>
<blockquote>
<p><strong>BreakBeforeBinaryOperators</strong> (BinaryOperatorStyle)<br>
The way to wrap binary operators.</p>
<ul>
<li>BOS_None (in configuration: <code>None</code>) Break after operators.</li>
</ul>
</blockquote>
<p>But it seems to kick in only when wrapping is required (column limit is exceeded), which isn't the usual case.</p>
| 0debug |
R - Create a dataframe that lists down average spend for each day : I have the following data frame, listing the spends for each category for each day
Dataframe: actualSpends
Date Category Spend ($)
2017/01/01 Apple 10
2017/01/02 Apple 12
2017/01/03 Apple 8
2017/01/01 Banana 13
2017/01/02 Banana 15
2017/01/03 Banana 7
I want to create a new data frame that will list down the average amount spend for each category, for each day of the month.
(e.g. On the 3rd of the month, the average spend of all days that have passed in the month, from the 1st to 31st of each month. ) | 0debug |
Code conversion from Objective C to Swift : <p>I have a project in Objective-C and trying to convert it to Swift. It is a Large project. Is there any possibilities to convert it in the same project or have to create a new project?</p>
| 0debug |
How to set an Click in Center of RelativeLayout after load activity : I friends.. I would like know how can I set an Click in center of an RelativeLayout after activity load? | 0debug |
void ff_er_frame_end(ERContext *s)
{
int *linesize = s->cur_pic->f.linesize;
int i, mb_x, mb_y, error, error_type, dc_error, mv_error, ac_error;
int distance;
int threshold_part[4] = { 100, 100, 100 };
int threshold = 50;
int is_intra_likely;
int size = s->b8_stride * 2 * s->mb_height;
if (!s->avctx->error_concealment || s->error_count == 0 ||
s->avctx->lowres ||
s->avctx->hwaccel ||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ||
!s->cur_pic || s->cur_pic->field_picture ||
s->error_count == 3 * s->mb_width *
(s->avctx->skip_top + s->avctx->skip_bottom)) {
return;
}
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
int status = s->error_status_table[mb_x + (s->mb_height - 1) * s->mb_stride];
if (status != 0x7F)
break;
}
if ( mb_x == s->mb_width
&& s->avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO
&& (s->avctx->height&16)
&& s->error_count == 3 * s->mb_width * (s->avctx->skip_top + s->avctx->skip_bottom + 1)
) {
av_log(s->avctx, AV_LOG_DEBUG, "ignoring last missing slice\n");
return;
}
if (s->last_pic) {
if (s->last_pic->f.width != s->cur_pic->f.width ||
s->last_pic->f.height != s->cur_pic->f.height ||
s->last_pic->f.format != s->cur_pic->f.format) {
av_log(s->avctx, AV_LOG_WARNING, "Cannot use previous picture in error concealment\n");
s->last_pic = NULL;
}
}
if (s->next_pic) {
if (s->next_pic->f.width != s->cur_pic->f.width ||
s->next_pic->f.height != s->cur_pic->f.height ||
s->next_pic->f.format != s->cur_pic->f.format) {
av_log(s->avctx, AV_LOG_WARNING, "Cannot use next picture in error concealment\n");
s->next_pic = NULL;
}
}
if (s->cur_pic->motion_val[0] == NULL) {
av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
for (i = 0; i < 2; i++) {
s->cur_pic->ref_index_buf[i] = av_buffer_allocz(s->mb_stride * s->mb_height * 4 * sizeof(uint8_t));
s->cur_pic->motion_val_buf[i] = av_buffer_allocz((size + 4) * 2 * sizeof(uint16_t));
if (!s->cur_pic->ref_index_buf[i] || !s->cur_pic->motion_val_buf[i])
break;
s->cur_pic->ref_index[i] = s->cur_pic->ref_index_buf[i]->data;
s->cur_pic->motion_val[i] = (int16_t (*)[2])s->cur_pic->motion_val_buf[i]->data + 4;
}
if (i < 2) {
for (i = 0; i < 2; i++) {
av_buffer_unref(&s->cur_pic->ref_index_buf[i]);
av_buffer_unref(&s->cur_pic->motion_val_buf[i]);
s->cur_pic->ref_index[i] = NULL;
s->cur_pic->motion_val[i] = NULL;
}
return;
}
}
if (s->avctx->debug & FF_DEBUG_ER) {
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
int status = s->error_status_table[mb_x + mb_y * s->mb_stride];
av_log(s->avctx, AV_LOG_DEBUG, "%2X ", status);
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
}
#if 1
for (error_type = 1; error_type <= 3; error_type++) {
int end_ok = 0;
for (i = s->mb_num - 1; i >= 0; i--) {
const int mb_xy = s->mb_index2xy[i];
int error = s->error_status_table[mb_xy];
if (error & (1 << error_type))
end_ok = 1;
if (error & (8 << error_type))
end_ok = 1;
if (!end_ok)
s->error_status_table[mb_xy] |= 1 << error_type;
if (error & VP_START)
end_ok = 0;
}
}
#endif
#if 1
if (s->partitioned_frame) {
int end_ok = 0;
for (i = s->mb_num - 1; i >= 0; i--) {
const int mb_xy = s->mb_index2xy[i];
int error = s->error_status_table[mb_xy];
if (error & ER_AC_END)
end_ok = 0;
if ((error & ER_MV_END) ||
(error & ER_DC_END) ||
(error & ER_AC_ERROR))
end_ok = 1;
if (!end_ok)
s->error_status_table[mb_xy]|= ER_AC_ERROR;
if (error & VP_START)
end_ok = 0;
}
}
#endif
if (s->avctx->err_recognition & AV_EF_EXPLODE) {
int end_ok = 1;
for (i = s->mb_num - 2; i >= s->mb_width + 100; i--) {
const int mb_xy = s->mb_index2xy[i];
int error1 = s->error_status_table[mb_xy];
int error2 = s->error_status_table[s->mb_index2xy[i + 1]];
if (error1 & VP_START)
end_ok = 1;
if (error2 == (VP_START | ER_MB_ERROR | ER_MB_END) &&
error1 != (VP_START | ER_MB_ERROR | ER_MB_END) &&
((error1 & ER_AC_END) || (error1 & ER_DC_END) ||
(error1 & ER_MV_END))) {
end_ok = 0;
}
if (!end_ok)
s->error_status_table[mb_xy] |= ER_MB_ERROR;
}
}
#if 1
distance = 9999999;
for (error_type = 1; error_type <= 3; error_type++) {
for (i = s->mb_num - 1; i >= 0; i--) {
const int mb_xy = s->mb_index2xy[i];
int error = s->error_status_table[mb_xy];
if (!s->mbskip_table[mb_xy])
distance++;
if (error & (1 << error_type))
distance = 0;
if (s->partitioned_frame) {
if (distance < threshold_part[error_type - 1])
s->error_status_table[mb_xy] |= 1 << error_type;
} else {
if (distance < threshold)
s->error_status_table[mb_xy] |= 1 << error_type;
}
if (error & VP_START)
distance = 9999999;
}
}
#endif
error = 0;
for (i = 0; i < s->mb_num; i++) {
const int mb_xy = s->mb_index2xy[i];
int old_error = s->error_status_table[mb_xy];
if (old_error & VP_START) {
error = old_error & ER_MB_ERROR;
} else {
error |= old_error & ER_MB_ERROR;
s->error_status_table[mb_xy] |= error;
}
}
#if 1
if (!s->partitioned_frame) {
for (i = 0; i < s->mb_num; i++) {
const int mb_xy = s->mb_index2xy[i];
error = s->error_status_table[mb_xy];
if (error & ER_MB_ERROR)
error |= ER_MB_ERROR;
s->error_status_table[mb_xy] = error;
}
}
#endif
dc_error = ac_error = mv_error = 0;
for (i = 0; i < s->mb_num; i++) {
const int mb_xy = s->mb_index2xy[i];
error = s->error_status_table[mb_xy];
if (error & ER_DC_ERROR)
dc_error++;
if (error & ER_AC_ERROR)
ac_error++;
if (error & ER_MV_ERROR)
mv_error++;
}
av_log(s->avctx, AV_LOG_INFO, "concealing %d DC, %d AC, %d MV errors in %c frame\n",
dc_error, ac_error, mv_error, av_get_picture_type_char(s->cur_pic->f.pict_type));
is_intra_likely = is_intra_more_likely(s);
for (i = 0; i < s->mb_num; i++) {
const int mb_xy = s->mb_index2xy[i];
error = s->error_status_table[mb_xy];
if (!((error & ER_DC_ERROR) && (error & ER_MV_ERROR)))
continue;
if (is_intra_likely)
s->cur_pic->mb_type[mb_xy] = MB_TYPE_INTRA4x4;
else
s->cur_pic->mb_type[mb_xy] = MB_TYPE_16x16 | MB_TYPE_L0;
}
if (!(s->last_pic && s->last_pic->f.data[0]) &&
!(s->next_pic && s->next_pic->f.data[0]))
for (i = 0; i < s->mb_num; i++) {
const int mb_xy = s->mb_index2xy[i];
if (!IS_INTRA(s->cur_pic->mb_type[mb_xy]))
s->cur_pic->mb_type[mb_xy] = MB_TYPE_INTRA4x4;
}
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int mb_xy = mb_x + mb_y * s->mb_stride;
const int mb_type = s->cur_pic->mb_type[mb_xy];
const int dir = !(s->last_pic && s->last_pic->f.data[0]);
const int mv_dir = dir ? MV_DIR_BACKWARD : MV_DIR_FORWARD;
int mv_type;
error = s->error_status_table[mb_xy];
if (IS_INTRA(mb_type))
continue;
if (error & ER_MV_ERROR)
continue;
if (!(error & ER_AC_ERROR))
continue;
if (IS_8X8(mb_type)) {
int mb_index = mb_x * 2 + mb_y * 2 * s->b8_stride;
int j;
mv_type = MV_TYPE_8X8;
for (j = 0; j < 4; j++) {
s->mv[0][j][0] = s->cur_pic->motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][0];
s->mv[0][j][1] = s->cur_pic->motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][1];
}
} else {
mv_type = MV_TYPE_16X16;
s->mv[0][0][0] = s->cur_pic->motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][0];
s->mv[0][0][1] = s->cur_pic->motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][1];
}
s->decode_mb(s->opaque, 0 ,
mv_dir, mv_type, &s->mv, mb_x, mb_y, 0, 0);
}
}
if (s->cur_pic->f.pict_type == AV_PICTURE_TYPE_B) {
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
int xy = mb_x * 2 + mb_y * 2 * s->b8_stride;
const int mb_xy = mb_x + mb_y * s->mb_stride;
const int mb_type = s->cur_pic->mb_type[mb_xy];
int mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
error = s->error_status_table[mb_xy];
if (IS_INTRA(mb_type))
continue;
if (!(error & ER_MV_ERROR))
continue;
if (!(error & ER_AC_ERROR))
continue;
if (!(s->last_pic && s->last_pic->f.data[0]))
mv_dir &= ~MV_DIR_FORWARD;
if (!(s->next_pic && s->next_pic->f.data[0]))
mv_dir &= ~MV_DIR_BACKWARD;
if (s->pp_time) {
int time_pp = s->pp_time;
int time_pb = s->pb_time;
av_assert0(s->avctx->codec_id != AV_CODEC_ID_H264);
ff_thread_await_progress(&s->next_pic->tf, mb_y, 0);
s->mv[0][0][0] = s->next_pic->motion_val[0][xy][0] * time_pb / time_pp;
s->mv[0][0][1] = s->next_pic->motion_val[0][xy][1] * time_pb / time_pp;
s->mv[1][0][0] = s->next_pic->motion_val[0][xy][0] * (time_pb - time_pp) / time_pp;
s->mv[1][0][1] = s->next_pic->motion_val[0][xy][1] * (time_pb - time_pp) / time_pp;
} else {
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
s->mv[1][0][0] = 0;
s->mv[1][0][1] = 0;
}
s->decode_mb(s->opaque, 0, mv_dir, MV_TYPE_16X16, &s->mv,
mb_x, mb_y, 0, 0);
}
}
} else
guess_mv(s);
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
goto ec_clean;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
int dc, dcu, dcv, y, n;
int16_t *dc_ptr;
uint8_t *dest_y, *dest_cb, *dest_cr;
const int mb_xy = mb_x + mb_y * s->mb_stride;
const int mb_type = s->cur_pic->mb_type[mb_xy];
error = s->error_status_table[mb_xy];
if (IS_INTRA(mb_type) && s->partitioned_frame)
continue;
dest_y = s->cur_pic->f.data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
dest_cb = s->cur_pic->f.data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
dest_cr = s->cur_pic->f.data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
dc_ptr = &s->dc_val[0][mb_x * 2 + mb_y * 2 * s->b8_stride];
for (n = 0; n < 4; n++) {
dc = 0;
for (y = 0; y < 8; y++) {
int x;
for (x = 0; x < 8; x++)
dc += dest_y[x + (n & 1) * 8 +
(y + (n >> 1) * 8) * linesize[0]];
}
dc_ptr[(n & 1) + (n >> 1) * s->b8_stride] = (dc + 4) >> 3;
}
dcu = dcv = 0;
for (y = 0; y < 8; y++) {
int x;
for (x = 0; x < 8; x++) {
dcu += dest_cb[x + y * linesize[1]];
dcv += dest_cr[x + y * linesize[2]];
}
}
s->dc_val[1][mb_x + mb_y * s->mb_stride] = (dcu + 4) >> 3;
s->dc_val[2][mb_x + mb_y * s->mb_stride] = (dcv + 4) >> 3;
}
}
#if 1
guess_dc(s, s->dc_val[0], s->mb_width*2, s->mb_height*2, s->b8_stride, 1);
guess_dc(s, s->dc_val[1], s->mb_width , s->mb_height , s->mb_stride, 0);
guess_dc(s, s->dc_val[2], s->mb_width , s->mb_height , s->mb_stride, 0);
#endif
filter181(s->dc_val[0], s->mb_width * 2, s->mb_height * 2, s->b8_stride);
#if 1
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
uint8_t *dest_y, *dest_cb, *dest_cr;
const int mb_xy = mb_x + mb_y * s->mb_stride;
const int mb_type = s->cur_pic->mb_type[mb_xy];
error = s->error_status_table[mb_xy];
if (IS_INTER(mb_type))
continue;
if (!(error & ER_AC_ERROR))
continue;
dest_y = s->cur_pic->f.data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
dest_cb = s->cur_pic->f.data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
dest_cr = s->cur_pic->f.data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y);
}
}
#endif
if (s->avctx->error_concealment & FF_EC_DEBLOCK) {
h_block_filter(s, s->cur_pic->f.data[0], s->mb_width * 2,
s->mb_height * 2, linesize[0], 1);
h_block_filter(s, s->cur_pic->f.data[1], s->mb_width,
s->mb_height, linesize[1], 0);
h_block_filter(s, s->cur_pic->f.data[2], s->mb_width,
s->mb_height, linesize[2], 0);
v_block_filter(s, s->cur_pic->f.data[0], s->mb_width * 2,
s->mb_height * 2, linesize[0], 1);
v_block_filter(s, s->cur_pic->f.data[1], s->mb_width,
s->mb_height, linesize[1], 0);
v_block_filter(s, s->cur_pic->f.data[2], s->mb_width,
s->mb_height, linesize[2], 0);
}
ec_clean:
for (i = 0; i < s->mb_num; i++) {
const int mb_xy = s->mb_index2xy[i];
int error = s->error_status_table[mb_xy];
if (s->cur_pic->f.pict_type != AV_PICTURE_TYPE_B &&
(error & (ER_DC_ERROR | ER_MV_ERROR | ER_AC_ERROR))) {
s->mbskip_table[mb_xy] = 0;
}
s->mbintra_table[mb_xy] = 1;
}
s->cur_pic = NULL;
s->next_pic = NULL;
s->last_pic = NULL;
}
| 1threat |
PowerQuery: How can I concatenate grouped values? : <p>If I have the following table (shown in the image below), how can I write a grouped query that would concatenate the grouped results?</p>
<p><a href="https://i.stack.imgur.com/FwYeH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FwYeH.png" alt="InputTable"></a></p>
<p>For this example, I'd want to group by the <code>LetterColumn</code> and concatenate the <code>NumberColumn</code></p>
<p>So the desired results would be:</p>
<p><a href="https://i.stack.imgur.com/0rQwR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0rQwR.png" alt="ResultsTable"></a></p>
| 0debug |
This code doesnt seem to run when compiled : I am creating a program in Java for a restaurant. I am using Array List but for some reason my starter class doesn't seem to run in the main menu.
This is my starter class.
import java.util.ArrayList;
`public class Starter`
`{`
Starter()
{
String[] myList = {"Coffee", "Tea", "Somosas", "Cake"};
//System.out.println(myList[]);
}
`}`
this seems to be correct but when i try to choose from the Main menu it doesn't seem to work.
Main Menu
` import java.util.Scanner; `
`import javax.swing.*;`
`import java.awt.*;`
`import java.awt.event.*;`
`public class Menu`
{
static Scanner input = new Scanner(System.in);
` public static void main(String[]args)`
`{
System.out.println("1=Starter");
System.out.println("2= Main Course");
System.out.println("3=Desert");`
int a =input.nextInt();
input.nextLine();
if(a==1)
{
System.out.println("Starter");
Starter OS1=new Starter();
System.out.println("Your starter is "+OS1.myList[]);
}
The error i get is '.class' expected `System.out.println("Your starter is "+OS1.myList[]);`
How to fix this? | 0debug |
FIND ELEMENT BY XPATH WITH SELENIUM WEBDRIVER USING PYTHON : I want to upload the file on onedrive with python.
But i am unable to locate Upload button. Element found with xpath in driver but while writing in code it throws timeout exception.
HTML CODE:
<div class="CommandBarItem beak-anchor command is-focused" data-bind="css: { 'is-toggled': isOpen() || isToggled(), 'is-disabled': isDisabled, 'is-disabled-invisible': isInvisibleWhenDisabled, 'is-open': isOpen, 'is-focused': focused, 'CommandBarItem--hasPayload': $component.hasPayload, 'icon-only': hasIconOnly, 'is-current-view': isCurrentView, 'is-pivot': isCurrentView !== null, 'is-last-pivot': isLastPivot }, class: commandClass() ? 'od-Command--' + commandClass() : '', hasFocus: isActive, raiseEventOnChange: { eventName: 'layoutChange', bubbleEvent: true, data: layoutChanged }, dismiss: { isOpen: isOpen, isAutomatic: payload && payload.autoDismiss, timeout: payload && payload.timeout, dismissOnResize: false, dismissOnScroll: false }, with: targetCommand(), attr: { tabindex: tabindex, role: role, 'aria-label': $parent.accessibleLabel, 'aria-haspopup': visibleChildren().length > 0 || !!payload, 'aria-selected': isOpen(), 'aria-pressed': isToggled(), 'data-automationid': automationId, 'aria-expanded': visibleChildren().length > 0 ? isOpen().toString() : false, id: newFeatureExperienceAnchor }, teachingBubble: teachingBubble, tooltip: { content: $data.tooltip, isTooltipDisabled: isOpen }" tabindex="0" role="menuitem" aria-label="Upload. Upload files from your computer to this location" aria-haspopup="true" data-automationid="" aria-expanded="false"><div class="CommandBarItem-linkWrapper"><div class="CommandBarItem-link" data-bind="measure: { measure: $parent.measurementReady, async: true }, click: onClick, automation: 'link'" data-automationid="link"><!--ko if: $parent.icon--><span class="CommandBarItem-icon" data-bind="component: { name: 'od-icon-glyph', params: { icon: $parent.icon, badge: $parent.iconBadge } }, attr: { 'is-flipped': $parent.positionIconRight }"><i class="od-IconGlyph ms-Icon ms-Icon--Upload css-46 od-IconGlyph--visible" data-bind="class: iconClasses, attr: { 'data-icon-name': icon }, css: { 'od-IconGlyph--badged': badge, 'od-IconGlyph--visible': icon }, with: badge" data-icon-name="Upload"></i></span><!--/ko--><!--ko if: $parent.iconUrl--><!--/ko--><!--ko if: $parent.label()--><span class="CommandBarItem-commandText" data-bind="text: $parent.label, attr: { 'is-flipped': $parent.positionIconRight, 'role': $parent.hasDynamicText ? 'status' : null, 'aria-live': $parent.hasDynamicText ? 'polite' : null }, css: { 'CommandBarItem-commandText--isStrong': $parent.isStrong, 'ms-accessible': $parent.hasIconOnly() || !$parent.isLabelVisible() }">Upload</span><!--/ko--><!--ko if: visibleChildren().length && !hidesMenuChevron && !isCollapsed() && $parent.isLabelVisible()--><i class="od-CommandBarItem-down ms-Icon css-47" data-bind="class: getChevronDown()"></i><!--/ko--></div><!--ko if: $data.inputType() === ActionInputType.htmlFileUpload--><!--/ko--><!--ko if: $data.inputType() === ActionInputType.folderUpload--><!--/ko--></div><!--ko if: children().length && isOpen() && !isClipped()--><!--/ko--><!--ko if: $component.hasPayload--><!--/ko--></div>
My code:
driver.implicitly_wait(30)
try:
df = wait.until ( EC.presence_of_element_located ( (By.XPATH, '//*[@id="appRoot"]//div[@class="CommandBarItem beak-anchor command is-focused" and @aria-label="Upload. Upload files from your computer to this location"]')))
df.click ()
print (df)
except TimeoutException:
print ( "page time to load" )
But it does not work and throws the time out exception | 0debug |
Copying text in many files in one folder : <p>How can I copy text between [START] and [END]? I think sed is the easiest way. I tried use grep but I haven't seen option to mark where is start and where is end.</p>
| 0debug |
int slirp_can_output(void)
{
return 1;
}
| 1threat |
def hexagonal_num(n):
return n*(2*n - 1) | 0debug |
Delete an object's key-value pairs from JS File using sed command and display changes within the same file : I am having a configuration file in which key-value pair of an object need to be deleted. Is there any way to delete it by sed command only. My sample file is given below:
define({
name: 'ABC',
defaultApp: 'abc',
plugin: 'plugin',
loadOverride: 'load.json',
components: [
{
path: 'upm'
},
{
path: 'ech'
},
{
path: 'hb'
},
{
path: 'st'
},
{
path: 'fo'
},
{
path: 'cm'
},
{
path: 'si'
}
] });
Expected Output:
define({
name: 'ABC',
defaultApp: 'abc',
plugin: 'plugin',
loadOverride: 'load.json',
components: [
{
path: 'hb'
},
{
path: 'fo'
},
{
path: 'cm'
}
] });
Currently, I am removing line by line but if there's any way removing it with direct command.
Thanks.. | 0debug |
"textAlignVertical" is not a valid style property : <p>I am getting an error saying "textAlignVertical" is not a valid style property when attempting to use the 'textAlignVertical' style on a Text element. I've checked the documentation and it says I should be able to use this style property: <a href="https://facebook.github.io/react-native/docs/text.html" rel="noreferrer">https://facebook.github.io/react-native/docs/text.html</a></p>
<p>has anyone else had this issue?</p>
| 0debug |
static int hdcd_envelope(int32_t *samples, int count, int stride, int gain, int target_gain, int extend)
{
int i;
int32_t *samples_end = samples + stride * count;
if (extend) {
for (i = 0; i < count; i++) {
int32_t sample = samples[i * stride];
int32_t asample = abs(sample) - 0x5981;
if (asample >= 0)
sample = sample >= 0 ? peaktab[asample] : -peaktab[asample];
else
sample <<= 15;
samples[i * stride] = sample;
}
} else {
for (i = 0; i < count; i++)
samples[i * stride] <<= 15;
}
if (gain <= target_gain) {
int len = FFMIN(count, target_gain - gain);
for (i = 0; i < len; i++) {
++gain;
APPLY_GAIN(*samples, gain);
samples += stride;
}
count -= len;
} else {
int len = FFMIN(count, (gain - target_gain) >> 3);
for (i = 0; i < len; i++) {
gain -= 8;
APPLY_GAIN(*samples, gain);
samples += stride;
}
if (gain - 8 < target_gain)
gain = target_gain;
count -= len;
}
if (gain == 0) {
if (count > 0)
samples += count * stride;
} else {
while (--count >= 0) {
APPLY_GAIN(*samples, gain);
samples += stride;
}
}
av_assert0(samples == samples_end);
return gain;
}
| 1threat |
static void port92_init(ISADevice *dev, qemu_irq *a20_out)
{
Port92State *s = PORT92(dev);
s->a20_out = a20_out;
}
| 1threat |
No unchecking for checkboxes whose ids are in the list : <p>On my page, i need to prevent checkboxes whose ids are in the list (oh sorry, i've meant 'array' %) from being unchecked. I.e.</p>
<pre><code>for id in ["id1", "id2", "id667"]:
# no unchecking for this id's checkbox, please!
</code></pre>
| 0debug |
static void fdt_add_gic_node(VirtBoardInfo *vbi)
{
vbi->gic_phandle = qemu_fdt_alloc_phandle(vbi->fdt);
qemu_fdt_setprop_cell(vbi->fdt, "/", "interrupt-parent", vbi->gic_phandle);
qemu_fdt_add_subnode(vbi->fdt, "/intc");
qemu_fdt_setprop_string(vbi->fdt, "/intc", "compatible",
"arm,cortex-a15-gic");
qemu_fdt_setprop_cell(vbi->fdt, "/intc", "#interrupt-cells", 3);
qemu_fdt_setprop(vbi->fdt, "/intc", "interrupt-controller", NULL, 0);
qemu_fdt_setprop_sized_cells(vbi->fdt, "/intc", "reg",
2, vbi->memmap[VIRT_GIC_DIST].base,
2, vbi->memmap[VIRT_GIC_DIST].size,
2, vbi->memmap[VIRT_GIC_CPU].base,
2, vbi->memmap[VIRT_GIC_CPU].size);
qemu_fdt_setprop_cell(vbi->fdt, "/intc", "#address-cells", 0x2);
qemu_fdt_setprop_cell(vbi->fdt, "/intc", "#size-cells", 0x2);
qemu_fdt_setprop(vbi->fdt, "/intc", "ranges", NULL, 0);
qemu_fdt_setprop_cell(vbi->fdt, "/intc", "phandle", vbi->gic_phandle);
}
| 1threat |
av_cold int ff_vp8_decode_free(AVCodecContext *avctx)
{
VP8Context *s = avctx->priv_data;
int i;
vp8_decode_flush_impl(avctx, 1);
for (i = 0; i < FF_ARRAY_ELEMS(s->frames); i++)
av_frame_free(&s->frames[i].tf.f);
} | 1threat |
Payeezy | Payeezy.js sandbox not working , SSL issue : <p>Payeezy | Payeezy.js sandbox not working , showing SSL issue Underlying connection was closed , it works fine in live url</p>
<p>How to fix</p>
| 0debug |
static inline uint16_t vring_avail_ring(VirtQueue *vq, int i)
{
VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);
hwaddr pa = offsetof(VRingAvail, ring[i]);
return virtio_lduw_phys_cached(vq->vdev, &caches->avail, pa);
}
| 1threat |
Java script question using for loops and functions : create a generic function that outputs one line of the countdown (ten,nine,eight, seven etc.) on the web page, followed by an alert, and receives the data to output as an input parameter. Use that function to output each line of the countdown, and an alert.
i need to output the countdown to the browser window and an alert is only being used to signal when to output the next line.
i need to use a loop. i also can't use an array
thanks! | 0debug |
static void nbd_parse_filename(const char *filename, QDict *options,
Error **errp)
{
char *file;
char *export_name;
const char *host_spec;
const char *unixpath;
if (qdict_haskey(options, "host")
|| qdict_haskey(options, "port")
|| qdict_haskey(options, "path"))
{
error_setg(errp, "host/port/path and a file name may not be specified "
"at the same time");
return;
}
if (strstr(filename, ":
int ret = nbd_parse_uri(filename, options);
if (ret < 0) {
error_setg(errp, "No valid URL specified");
}
return;
}
file = g_strdup(filename);
export_name = strstr(file, EN_OPTSTR);
if (export_name) {
if (export_name[strlen(EN_OPTSTR)] == 0) {
goto out;
}
export_name[0] = 0;
export_name += strlen(EN_OPTSTR);
qdict_put(options, "export", qstring_from_str(export_name));
}
if (!strstart(file, "nbd:", &host_spec)) {
error_setg(errp, "File name string for NBD must start with 'nbd:'");
goto out;
}
if (!*host_spec) {
goto out;
}
if (strstart(host_spec, "unix:", &unixpath)) {
qdict_put(options, "path", qstring_from_str(unixpath));
} else {
InetSocketAddress *addr = NULL;
addr = inet_parse(host_spec, errp);
if (error_is_set(errp)) {
goto out;
}
qdict_put(options, "host", qstring_from_str(addr->host));
qdict_put(options, "port", qstring_from_str(addr->port));
qapi_free_InetSocketAddress(addr);
}
out:
g_free(file);
}
| 1threat |
syntax error, unexpected (T_IF) : <p>Parse error: syntax error, unexpected 'if' (T_IF) on line 4</p>
<p>I really don't know what is wrong with my code or why this is happening because I am new to PHP.</p>
<p>Line 4 is: if($passcheck == $mypass){</p>
<pre><code> <?php
$mypass="DaPigeon123";
$passcheck=$_POST["password"]
if($passcheck == $mypass){
echo "Welcome," .$_POST["username"]. "! You are now logged in.<br/>";
{
else
echo "Sorry, wrong password. <br/>";
?>
</code></pre>
| 0debug |
Move cypress folder from the root of the project : <p>When I install and run cypress, it scaffolds a <code>cypress/</code> folder in the root of my project.</p>
<p>The problem is that all other test related data is stored in the <code>test/</code> folder. Is there an easy way to move it to <code>test/cypress</code> and configure cypress to look there?</p>
| 0debug |
btnCheckClear - Need to Add 3 Day to current Transaction Date : I am working in C#.
I have a button that needs to add 3 days to the current transaction date already in ArrayList.
How to accomplish this?
The code is as follows:
private void btnCheckCleared_Click(object sender, EventArgs e)
{
foreach (Transaction item in tranArray)
{
if (What goes here?)
{
DateTime.Today.AddDays(3).ToLongDateString();
}
}
}
If you need the whole project, please let me know | 0debug |
I need some vba code that copies the contents of the attachment (a word document) and inserts it into the body of the draft email : I have a program that generates a draft email with an attached letter for the user to send on to the client. Most clients don't want the letter as an attachment but want it in the body of the email. Is it possible to create a button that runs some vba that opens up the attachment of the draft email, copies the text and pastes it into the body of the email?
I have tried to search for something similar but couldn't find anything and am not experienced enough in vba to code it myself. | 0debug |
Getting json body in aws Lambda via API gateway : <p>I'm currently using NodeJS to build a bot on AWS lambda via AWS Api Gateway and I'm running into an issue with POST requests and JSON data. My api uses 'Use Lambda Proxy integration' and even when I test the proxy sending a content-type of Application/json and some json in the body e.g <code>{"foo":"bar"}</code> I can't access the object without parsing it first</p>
<p>e.g</p>
<pre><code> var json = JSON.parse(event.body);
console.log(json.foo);
</code></pre>
<p>Now I know this doesn't seem a big deal just running it through JSON.parse, but I've seen a number of other examples where this isn't the case at all. see here <a href="https://github.com/pinzler/fb-messenger-bot-aws-lambda/blob/master/index.js" rel="noreferrer">https://github.com/pinzler/fb-messenger-bot-aws-lambda/blob/master/index.js</a></p>
<p>Do I need to add anything to my API gateway to handle this correctly? my 'request body' step in the 'post method request' section has a content-type of application/json set-up for the request body. </p>
<p>The readme for the example above doesn't seem to use proxy integration as far as I can tell so I'm not sure what I should be doing here</p>
| 0debug |
Using async/await in node 7.4 : <p>I thought async/await was supported in node 7.4, however this example does not work:</p>
<pre><code>const Promise = require('bluebird');
async function main(){
await Promise.delay(1000)
}
main();
</code></pre>
<p>Results in:</p>
<pre><code>async function main(){
^^^^^^^^
SyntaxError: Unexpected token function
</code></pre>
<p>How can I use async/await with node 7.4?</p>
| 0debug |
ROTATE Google-Map to display my real-time DIRECTION : <p>I am using the Google Maps Android API v2 where I display my Device location as a GoogleMap Marker on a Map.
I have a listener (LocationServices.FusedLocationApi.requestLocationUpdates...) attach to the Map in order to handle every GPS location change.
Every time I receive a new location I update the Marker (my position) as well as the Camera on the Map and pretty much it shows like I am moving as I drive. </p>
<p>However... I need some help in order to have the MAP <strong>rotate</strong> and/or <strong>display</strong> on the same direction that I am moving to. I mean, while I drive I need to rotate the MAP where I can see on my map-left-side what I have on my real-life-left-side, and so the same with the right. Since the MAP direction is static, the Marker (Me) is moving on it but most of the time the direction does not match my car real-time direction.</p>
<p>What should I do with the Map in order to accomplish this visual effect?</p>
| 0debug |
How to sort a JSON file with more than one argument numerical : Well,I need to create a function to my web application. This function receive as parameter a jSON and return the organized list from lowest to highest. The object of my json file have two parameters to analyse.
var medicines = [
{type:"Glibenclamida 5 mg", hour1:2, hour2: 4},
{type:"Noretisterona 0,35 mg", hour1:4, hour2: 8},
{type:"Glibenclamida 99 mg", hour1:8, hour2: 16}
];
So,this is only a example and I need these list return...
1: hour 2- Glibenclamida 5 mg
2: hour 4- Glibenclamida 5 mg, Noretisterona 0,35 mg
3: hour 8- Noretisterona 0,35 mg, Glibenclamida 99 mg
4: hour 16 - Glibenclamida 99 mg
This is just a example I need a organized list like these. | 0debug |
Any android project in my android studio layout preview showing highest this : [enter image description here][1]
This is my window in android studio
[1]: https://i.stack.imgur.com/AR43J.jpg
| 0debug |
static int tpm_passthrough_open_sysfs_cancel(TPMPassthruState *tpm_pt)
{
int fd = -1;
char *dev;
char path[PATH_MAX];
if (tpm_pt->options->cancel_path) {
fd = qemu_open(tpm_pt->options->cancel_path, O_WRONLY);
if (fd < 0) {
error_report("Could not open TPM cancel path : %s",
strerror(errno));
}
return fd;
}
dev = strrchr(tpm_pt->tpm_dev, '/');
if (dev) {
dev++;
if (snprintf(path, sizeof(path), "/sys/class/misc/%s/device/cancel",
dev) < sizeof(path)) {
fd = qemu_open(path, O_WRONLY);
if (fd >= 0) {
tpm_pt->options->cancel_path = g_strdup(path);
} else {
error_report("tpm_passthrough: Could not open TPM cancel "
"path %s : %s", path, strerror(errno));
}
}
} else {
error_report("tpm_passthrough: Bad TPM device path %s",
tpm_pt->tpm_dev);
}
return fd;
}
| 1threat |
Which design pattern is suitable illustrated problem below? : <p>I am developing a project in spring boot. There are common <strong>required steps</strong> will be used by all classes in development phase. For example to make connectivity through jdbc from java program to database the <strong>first step</strong> is load the jdbc driver, <strong>second step</strong> is create connection object and so on.
The problem is design pattern of my project should restrict the new developer of my project to write new classes in such a way that <strong>no requires steps would skip</strong> in such condition which design pattern should i use??</p>
| 0debug |
c++: How to use the values of a variable belonging to a class in another class? : I have this code everything is separated by .h file and. cpp: Fitness.h
class Fitness
{
private:
// Professor's ID
float _fit;
public:
// Inicia los datos del profesor
Fitness(float fit);
// Devuelve professor's ID
inline float GetFit() const { return _fit; }
};
Fitness.cpp
#include "stdafx.h"
#include "Fitness.h"
// Inicializa los datos del fit este es el archivo cpp
Fitness::Fitness(float fit) : _fit(fit) { }
and the part where I use it is here in a class called file called configuracion: Configuracion.h
class Configuracion
{
public:
//Lectura del Fitness
hash_map<float, Fitness*> _fit;
private:
// Indica que aun no se lee la información
bool _isEmpty;
public:
// Inicia datos
Configuracion() : _isEmpty(true) { }
// Libera recursos usados
~Configuracion();
// Analiza datos y guarda datos
void ParseFile(char* fileName);
///Fitness////////////////////////////
inline Fitness* GetFit(float fit)
{
hash_map<float, Fitness*>::iterator it = _fit.find(fit);
return it != _fit.end() ? (*it).second : NULL;
}
inline float GetNFit() const { return (float)_fit.size(); }
Fitness* ParseFitness(ifstream& file);
// Remueve caracteres vacios al principio y fin de la cadena
string& TrimString(string& str);
};
Configuracion.cpp
Configuracion::~Configuracion()
{
////////////////////////////////////////////////
for (hash_map<float, Fitness*>::iterator it = _fit.begin(); it != _fit.end(); it++)
delete (*it).second;
}
void Configuracion::ParseFile(char* fileName)
{
// Limpia objetos previamente analizados
_fit.clear();
string line;
while( input.is_open() && !input.eof() )
{
// Leer linea por linea hasta que se obtenga el inicio de un nuevo objeto
getline( input, line );
TrimString( line );
// Lee, analiza y guarda el tipo de objeto
if (line.compare("#fit") == 0)
{
Fitness* f = ParseFitness(input);
if (f)
_fit.insert(pair<float, Fitness*>(f->GetFit(), f));
}//////////////////cambiar variable o modificar
}
input.close();
_isEmpty = false;
To the use the value of the variable in another file within another class:
float f1 = 0.000000;
//f1 = Configuracion::GetInstance().GetFit();
f1 =(&Configuracion::_fit);
//Horario * f1= &Configuracion::_fit;
if (best->GetFitness() >= 0.45000000)
{
In this line I have an error :
f1 =(&Configuracion::_fit);
This is the error:
Error 2 error C2440: '=' : cannot convert from 'stdext::hash_map<float,Fitness *,stdext::hash_compare<_Kty,std::less<_Kty>>,std::allocator<std::pair<const _Kty,_Ty>>> Configuracion::* ' to 'float' | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.