problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
void xtensa_cpu_list(FILE *f, fprintf_function cpu_fprintf)
{
cpu_fprintf(f, "Available CPUs:\n"
" Xtensa core\n");
}
| 1threat
|
udp_emu(struct socket *so, struct mbuf *m)
{
struct sockaddr_in addr;
int addrlen = sizeof(addr);
#ifdef EMULATE_TALK
CTL_MSG_OLD *omsg;
CTL_MSG *nmsg;
char buff[sizeof(CTL_MSG)];
u_char type;
struct talk_request {
struct talk_request *next;
struct socket *udp_so;
struct socket *tcp_so;
} *req;
static struct talk_request *req_tbl = 0;
#endif
struct cu_header {
uint16_t d_family;
uint16_t d_port;
uint32_t d_addr;
uint16_t s_family;
uint16_t s_port;
uint32_t so_addr;
uint32_t seqn;
uint16_t message;
uint16_t data_type;
uint16_t pkt_len;
} *cu_head;
switch(so->so_emu) {
#ifdef EMULATE_TALK
case EMU_TALK:
case EMU_NTALK:
if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0)
return;
#define IS_OLD (so->so_emu == EMU_TALK)
#define COPY_MSG(dest, src) { dest->type = src->type; \
dest->id_num = src->id_num; \
dest->pid = src->pid; \
dest->addr = src->addr; \
dest->ctl_addr = src->ctl_addr; \
memcpy(&dest->l_name, &src->l_name, NAME_SIZE_OLD); \
memcpy(&dest->r_name, &src->r_name, NAME_SIZE_OLD); \
memcpy(&dest->r_tty, &src->r_tty, TTY_SIZE); }
#define OTOSIN(ptr, field) ((struct sockaddr_in *)&ptr->field)
if (IS_OLD) {
omsg = mtod(m, CTL_MSG_OLD*);
nmsg = (CTL_MSG *) buff;
type = omsg->type;
OTOSIN(omsg, ctl_addr)->sin_port = addr.sin_port;
OTOSIN(omsg, ctl_addr)->sin_addr = our_addr;
strncpy(omsg->l_name, getlogin(), NAME_SIZE_OLD);
} else {
omsg = (CTL_MSG_OLD *) buff;
nmsg = mtod(m, CTL_MSG *);
type = nmsg->type;
OTOSIN(nmsg, ctl_addr)->sin_port = addr.sin_port;
OTOSIN(nmsg, ctl_addr)->sin_addr = our_addr;
strncpy(nmsg->l_name, getlogin(), NAME_SIZE_OLD);
}
if (type == LOOK_UP)
return;
if (IS_OLD) {
COPY_MSG(nmsg, omsg);
nmsg->vers = 1;
nmsg->answer = 0;
} else
COPY_MSG(omsg, nmsg);
if (type == ANNOUNCE) {
int s;
u_short temp_port;
for(req = req_tbl; req; req = req->next)
if (so == req->udp_so)
break;
if (!req) {
req = (struct talk_request *)
malloc(sizeof(struct talk_request));
req->udp_so = so;
req->tcp_so = solisten(0,
OTOSIN(omsg, addr)->sin_addr.s_addr,
OTOSIN(omsg, addr)->sin_port,
SS_FACCEPTONCE);
req->next = req_tbl;
req_tbl = req;
}
addrlen = sizeof(addr);
getsockname(req->tcp_so->s,
(struct sockaddr *) &addr,
&addrlen);
OTOSIN(omsg, addr)->sin_port = addr.sin_port;
OTOSIN(omsg, addr)->sin_addr = our_addr;
OTOSIN(nmsg, addr)->sin_port = addr.sin_port;
OTOSIN(nmsg, addr)->sin_addr = our_addr;
temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
OTOSIN(omsg, ctl_addr)->sin_port = 0;
OTOSIN(nmsg, ctl_addr)->sin_port = 0;
omsg->type = nmsg->type = LEAVE_INVITE;
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
addr.sin_addr = our_addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(517);
sendto(s, (char *)omsg, sizeof(*omsg), 0,
(struct sockaddr *)&addr, sizeof(addr));
addr.sin_port = htons(518);
sendto(s, (char *)nmsg, sizeof(*nmsg), 0,
(struct sockaddr *) &addr, sizeof(addr));
closesocket(s) ;
omsg->type = nmsg->type = ANNOUNCE;
OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
}
if (type == DELETE) {
struct talk_request *temp_req, *req_next;
int s;
u_short temp_port;
temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
OTOSIN(omsg, ctl_addr)->sin_port = 0;
OTOSIN(nmsg, ctl_addr)->sin_port = 0;
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
addr.sin_addr = our_addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(517);
sendto(s, (char *)omsg, sizeof(*omsg), 0,
(struct sockaddr *)&addr, sizeof(addr));
addr.sin_port = htons(518);
sendto(s, (char *)nmsg, sizeof(*nmsg), 0,
(struct sockaddr *)&addr, sizeof(addr));
closesocket(s);
OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
if (so == req_tbl->udp_so) {
temp_req = req_tbl;
req_tbl = req_tbl->next;
free(temp_req);
} else {
temp_req = req_tbl;
for(req = req_tbl->next; req; req = req_next) {
req_next = req->next;
if (so == req->udp_so) {
temp_req->next = req_next;
free(req);
break;
} else {
temp_req = req;
}
}
}
}
return;
#endif
case EMU_CUSEEME:
if (m->m_len >= sizeof (*cu_head)) {
if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0)
return;
cu_head = mtod(m, struct cu_header *);
cu_head->s_port = addr.sin_port;
cu_head->so_addr = our_addr.s_addr;
}
return;
}
}
| 1threat
|
How to put text on top of image when images arranged in list and heavily styled : Link to HTML + CSS:
https://jsfiddle.net/babis95/zdhne95u/
I have some HTML and CSS setup for a simple image gallery.
I've been trying to add white text on top of each of the images in the center.
I researched different ways but none seem to work with they way i set up my code:
```
.section-images p
{
color: white;
margin: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
```
This code seem to work on single image in a div, but not when multiple images are used.
| 0debug
|
void nand_setpins(DeviceState *dev, uint8_t cle, uint8_t ale,
uint8_t ce, uint8_t wp, uint8_t gnd)
{
NANDFlashState *s = (NANDFlashState *) dev;
s->cle = cle;
s->ale = ale;
s->ce = ce;
s->wp = wp;
s->gnd = gnd;
if (wp)
s->status |= NAND_IOSTATUS_UNPROTCT;
else
s->status &= ~NAND_IOSTATUS_UNPROTCT;
}
| 1threat
|
Which deep learning library support the compression of the deep learning models to be used on the phones? : <p>I want to build an advanced deep learning model (for example: a model that uses attention) and use it on android phones (without training of course) i will only use it for inference.<br>
and i want a library that can do that and can compress the model size to be used on the phone or android.<br>
and do you know any projects or apps similar to my goal?</p>
| 0debug
|
JQuery 3 and SignalR 2.2.0 : <p>I use SignalR 2.2.0 in a MVC5 project. SignalR depends of JQuery in client-side.</p>
<p>JQuery recently released new version, I updated it from Nuget, specifically from version 2.2.4 to 3.0.0.1, but then SignalR stopped working. Startup command "$.connection.hub" in javascript fails.
After a long time head scratching, I downgrade JQuery to 2.2.4 and everything is fine again.</p>
<p>Am I the only one getting this problem? There is any workaround?</p>
<p>Thanks.</p>
| 0debug
|
c++ windows gui change button colors : I wanna change button colors when the user click on it.
The main plan is: every month 10th one worker's button go to red and if the worker done his job then click on the button and it going to be green.
I have no idea what to do.
I already have this code... I just created a window and add a button to it:
#include <windows.h>
LRESULT CALLBACK WindowProcedure(HWND,UINT,WPARAM,LPARAM);
void AddButton(HWND hwnd);
LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wp,
LPARAM lp)
{
switch (msg) {
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_CREATE:
AddButton(hWnd);
break;
default:
return DefWindowProcW(hWnd, msg, wp, lp);
}
}
void AddButton(HWND hWnd)
{
CreateWindowW(L"Button", L"Change colors", WS_VISIBLE | WS_CHILD,
350, 200,
100, 100,
hWnd,
NULL,
NULL,
NULL);
}
So I tried WM_LBUTTONDOWN... I think this is something when the user click on the button the program will do something. i put in the switch(msg) case WM_LBUTTONDOWN:
but no idea what's next
| 0debug
|
How do a while loop terminates without proper terminating condition? : [how do while terminates when count becomes 0 without a condition like count!=0]
`#include<stdio.h>
static int count=5;
void func(void);
void main()
{
while(count--)
func();
}
void func(void)
{
static int i=5;
i++;
printf("%d\t%d\n",i,count);
}`
[1]: https://i.stack.imgur.com/KbXOd.png
| 0debug
|
static void mch_update_smram(MCHPCIState *mch)
{
PCIDevice *pd = PCI_DEVICE(mch);
bool h_smrame = (pd->config[MCH_HOST_BRIDGE_ESMRAMC] & MCH_HOST_BRIDGE_ESMRAMC_H_SMRAME);
uint32_t tseg_size;
if (pd->config[MCH_HOST_BRIDGE_SMRAM] & MCH_HOST_BRIDGE_SMRAM_D_LCK) {
pd->config[MCH_HOST_BRIDGE_SMRAM] &= ~MCH_HOST_BRIDGE_SMRAM_D_OPEN;
pd->wmask[MCH_HOST_BRIDGE_SMRAM] = MCH_HOST_BRIDGE_SMRAM_WMASK_LCK;
pd->wmask[MCH_HOST_BRIDGE_ESMRAMC] = MCH_HOST_BRIDGE_ESMRAMC_WMASK_LCK;
}
memory_region_transaction_begin();
if (pd->config[MCH_HOST_BRIDGE_SMRAM] & SMRAM_D_OPEN) {
memory_region_set_enabled(&mch->smram_region, h_smrame);
memory_region_set_enabled(&mch->open_high_smram, h_smrame);
} else {
memory_region_set_enabled(&mch->smram_region, true);
memory_region_set_enabled(&mch->open_high_smram, false);
}
if (pd->config[MCH_HOST_BRIDGE_SMRAM] & SMRAM_G_SMRAME) {
memory_region_set_enabled(&mch->low_smram, !h_smrame);
memory_region_set_enabled(&mch->high_smram, h_smrame);
} else {
memory_region_set_enabled(&mch->low_smram, false);
memory_region_set_enabled(&mch->high_smram, false);
}
if (pd->config[MCH_HOST_BRIDGE_ESMRAMC] & MCH_HOST_BRIDGE_ESMRAMC_T_EN) {
switch (pd->config[MCH_HOST_BRIDGE_ESMRAMC] &
MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_MASK) {
case MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_1MB:
tseg_size = 1024 * 1024;
break;
case MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_2MB:
tseg_size = 1024 * 1024 * 2;
break;
case MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_8MB:
tseg_size = 1024 * 1024 * 8;
break;
default:
tseg_size = 0;
break;
}
} else {
tseg_size = 0;
}
memory_region_del_subregion(mch->system_memory, &mch->tseg_blackhole);
memory_region_set_enabled(&mch->tseg_blackhole, tseg_size);
memory_region_set_size(&mch->tseg_blackhole, tseg_size);
memory_region_add_subregion_overlap(mch->system_memory,
mch->below_4g_mem_size - tseg_size,
&mch->tseg_blackhole, 1);
memory_region_set_enabled(&mch->tseg_window, tseg_size);
memory_region_set_size(&mch->tseg_window, tseg_size);
memory_region_set_address(&mch->tseg_window,
mch->below_4g_mem_size - tseg_size);
memory_region_set_alias_offset(&mch->tseg_window,
mch->below_4g_mem_size - tseg_size);
memory_region_transaction_commit();
}
| 1threat
|
static int vc1_decode_p_mb(VC1Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &s->gb;
int i, j;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int cbp;
int mqdiff, mquant;
int ttmb = v->ttfrm;
int mb_has_coeffs = 1;
int dmv_x, dmv_y;
int index, index1;
int val, sign;
int first_block = 1;
int dst_idx, off;
int skipped, fourmv;
int block_cbp = 0, pat;
int apply_loop_filter;
mquant = v->pq;
if (v->mv_type_is_raw)
fourmv = get_bits1(gb);
else
fourmv = v->mv_type_mb_plane[mb_pos];
if (v->skip_is_raw)
skipped = get_bits1(gb);
else
skipped = v->s.mbskip_table[mb_pos];
s->dsp.clear_blocks(s->block[0]);
apply_loop_filter = s->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY);
if (!fourmv)
{
if (!skipped)
{
GET_MVDATA(dmv_x, dmv_y);
if (s->mb_intra) {
s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
}
s->current_picture.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16;
vc1_pred_mv(s, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]);
if (s->mb_intra && !mb_has_coeffs)
{
GET_MQUANT();
s->ac_pred = get_bits1(gb);
cbp = 0;
}
else if (mb_has_coeffs)
{
if (s->mb_intra) s->ac_pred = get_bits1(gb);
cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
GET_MQUANT();
}
else
{
mquant = v->pq;
cbp = 0;
}
s->current_picture.qscale_table[mb_pos] = mquant;
if (!v->ttmbf && !s->mb_intra && mb_has_coeffs)
ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table,
VC1_TTMB_VLC_BITS, 2);
if(!s->mb_intra) vc1_mc_1mv(v, 0);
dst_idx = 0;
for (i=0; i<6; i++)
{
s->dc_val[0][s->block_index[i]] = 0;
dst_idx += i >> 2;
val = ((cbp >> (5 - i)) & 1);
off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
v->mb_type[0][s->block_index[i]] = s->mb_intra;
if(s->mb_intra) {
v->a_avail = v->c_avail = 0;
if(i == 2 || i == 3 || !s->first_slice_line)
v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
if(i == 1 || i == 3 || s->mb_x)
v->c_avail = v->mb_type[0][s->block_index[i] - 1];
vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset);
if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
s->dsp.vc1_inv_trans_8x8(s->block[i]);
if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2));
if(v->pq >= 9 && v->overlap) {
if(v->c_avail)
s->dsp.vc1_h_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2));
if(v->a_avail)
s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2));
}
if(apply_loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){
int left_cbp, top_cbp;
if(i & 4){
left_cbp = v->cbp[s->mb_x - 1] >> (i * 4);
top_cbp = v->cbp[s->mb_x - s->mb_stride] >> (i * 4);
}else{
left_cbp = (i & 1) ? (cbp >> ((i-1)*4)) : (v->cbp[s->mb_x - 1] >> ((i+1)*4));
top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4));
}
if(left_cbp & 0xC)
s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, 1, i & 4 ? s->uvlinesize : s->linesize, 8, mquant);
if(top_cbp & 0xA)
s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, 1, 8, mquant);
}
block_cbp |= 0xF << (i << 2);
} else if(val) {
int left_cbp = 0, top_cbp = 0, filter = 0;
if(apply_loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){
filter = 1;
if(i & 4){
left_cbp = v->cbp[s->mb_x - 1] >> (i * 4);
top_cbp = v->cbp[s->mb_x - s->mb_stride] >> (i * 4);
}else{
left_cbp = (i & 1) ? (cbp >> ((i-1)*4)) : (v->cbp[s->mb_x - 1] >> ((i+1)*4));
top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4));
}
if(left_cbp & 0xC)
s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, 1, i & 4 ? s->uvlinesize : s->linesize, 8, mquant);
if(top_cbp & 0xA)
s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, 1, 8, mquant);
}
pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), filter, left_cbp, top_cbp);
block_cbp |= pat << (i << 2);
if(!v->ttmbf && ttmb < 8) ttmb = -1;
first_block = 0;
}
}
}
else
{
s->mb_intra = 0;
for(i = 0; i < 6; i++) {
v->mb_type[0][s->block_index[i]] = 0;
s->dc_val[0][s->block_index[i]] = 0;
}
s->current_picture.mb_type[mb_pos] = MB_TYPE_SKIP;
s->current_picture.qscale_table[mb_pos] = 0;
vc1_pred_mv(s, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_1mv(v, 0);
return 0;
}
}
else
{
if (!skipped )
{
int intra_count = 0, coded_inter = 0;
int is_intra[6], is_coded[6];
cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
for (i=0; i<6; i++)
{
val = ((cbp >> (5 - i)) & 1);
s->dc_val[0][s->block_index[i]] = 0;
s->mb_intra = 0;
if(i < 4) {
dmv_x = dmv_y = 0;
s->mb_intra = 0;
mb_has_coeffs = 0;
if(val) {
GET_MVDATA(dmv_x, dmv_y);
}
vc1_pred_mv(s, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]);
if(!s->mb_intra) vc1_mc_4mv_luma(v, i);
intra_count += s->mb_intra;
is_intra[i] = s->mb_intra;
is_coded[i] = mb_has_coeffs;
}
if(i&4){
is_intra[i] = (intra_count >= 3);
is_coded[i] = val;
}
if(i == 4) vc1_mc_4mv_chroma(v);
v->mb_type[0][s->block_index[i]] = is_intra[i];
if(!coded_inter) coded_inter = !is_intra[i] & is_coded[i];
}
if(!intra_count && !coded_inter) return 0;
dst_idx = 0;
GET_MQUANT();
s->current_picture.qscale_table[mb_pos] = mquant;
{
int intrapred = 0;
for(i=0; i<6; i++)
if(is_intra[i]) {
if(((!s->first_slice_line || (i==2 || i==3)) && v->mb_type[0][s->block_index[i] - s->block_wrap[i]])
|| ((s->mb_x || (i==1 || i==3)) && v->mb_type[0][s->block_index[i] - 1])) {
intrapred = 1;
break;
}
}
if(intrapred)s->ac_pred = get_bits1(gb);
else s->ac_pred = 0;
}
if (!v->ttmbf && coded_inter)
ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
for (i=0; i<6; i++)
{
dst_idx += i >> 2;
off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
s->mb_intra = is_intra[i];
if (is_intra[i]) {
v->a_avail = v->c_avail = 0;
if(i == 2 || i == 3 || !s->first_slice_line)
v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
if(i == 1 || i == 3 || s->mb_x)
v->c_avail = v->mb_type[0][s->block_index[i] - 1];
vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant, (i&4)?v->codingset2:v->codingset);
if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
s->dsp.vc1_inv_trans_8x8(s->block[i]);
if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize);
if(v->pq >= 9 && v->overlap) {
if(v->c_avail)
s->dsp.vc1_h_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2));
if(v->a_avail)
s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2));
}
if(v->s.loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){
int left_cbp, top_cbp;
if(i & 4){
left_cbp = v->cbp[s->mb_x - 1] >> (i * 4);
top_cbp = v->cbp[s->mb_x - s->mb_stride] >> (i * 4);
}else{
left_cbp = (i & 1) ? (cbp >> ((i-1)*4)) : (v->cbp[s->mb_x - 1] >> ((i+1)*4));
top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4));
}
if(left_cbp & 0xC)
s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, 1, i & 4 ? s->uvlinesize : s->linesize, 8, mquant);
if(top_cbp & 0xA)
s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, 1, 8, mquant);
}
block_cbp |= 0xF << (i << 2);
} else if(is_coded[i]) {
int left_cbp = 0, top_cbp = 0, filter = 0;
if(v->s.loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){
filter = 1;
if(i & 4){
left_cbp = v->cbp[s->mb_x - 1] >> (i * 4);
top_cbp = v->cbp[s->mb_x - s->mb_stride] >> (i * 4);
}else{
left_cbp = (i & 1) ? (cbp >> ((i-1)*4)) : (v->cbp[s->mb_x - 1] >> ((i+1)*4));
top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4));
}
if(left_cbp & 0xC)
s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, 1, i & 4 ? s->uvlinesize : s->linesize, 8, mquant);
if(top_cbp & 0xA)
s->dsp.vc1_loop_filter(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, 1, 8, mquant);
}
pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), filter, left_cbp, top_cbp);
block_cbp |= pat << (i << 2);
if(!v->ttmbf && ttmb < 8) ttmb = -1;
first_block = 0;
}
}
return 0;
}
else MB
{
s->mb_intra = 0;
s->current_picture.qscale_table[mb_pos] = 0;
for (i=0; i<6; i++) {
v->mb_type[0][s->block_index[i]] = 0;
s->dc_val[0][s->block_index[i]] = 0;
}
for (i=0; i<4; i++)
{
vc1_pred_mv(s, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_4mv_luma(v, i);
}
vc1_mc_4mv_chroma(v);
s->current_picture.qscale_table[mb_pos] = 0;
return 0;
}
}
v->cbp[s->mb_x] = block_cbp;
return -1;
}
| 1threat
|
Loading vs linking in Cython modules : <p>While exploring Cython compile steps, I found I need to link C libraries like math explicitly in setup.py. However, such step was not needed for numpy. Why so? Is numpy being imported through usual python import mechanism? If that is the case, we need not explicitly link <em>any</em> extension module in Cython?</p>
<p>I tried to rummage through the official documentation, but unfortunately there was no explanation as to when an explicit linking is required and when it will be dealt automatically.</p>
| 0debug
|
void hmp_savevm(Monitor *mon, const QDict *qdict)
{
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
int ret;
QEMUFile *f;
int saved_vm_running;
uint64_t vm_state_size;
qemu_timeval tv;
struct tm tm;
const char *name = qdict_get_try_str(qdict, "name");
Error *local_err = NULL;
bs = NULL;
while ((bs = bdrv_next(bs))) {
if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
continue;
if (!bdrv_can_snapshot(bs)) {
monitor_printf(mon, "Device '%s' is writable but does not support snapshots.\n",
bdrv_get_device_name(bs));
bs = find_vmstate_bs();
if (!bs) {
monitor_printf(mon, "No block device can accept snapshots\n");
saved_vm_running = runstate_is_running();
vm_stop(RUN_STATE_SAVE_VM);
memset(sn, 0, sizeof(*sn));
qemu_gettimeofday(&tv);
sn->date_sec = tv.tv_sec;
sn->date_nsec = tv.tv_usec * 1000;
sn->vm_clock_nsec = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
if (name) {
ret = bdrv_snapshot_find(bs, old_sn, name);
if (ret >= 0) {
pstrcpy(sn->name, sizeof(sn->name), old_sn->name);
pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
} else {
pstrcpy(sn->name, sizeof(sn->name), name);
} else {
localtime_r((const time_t *)&tv.tv_sec, &tm);
strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm);
if (name && del_existing_snapshots(mon, name) < 0) {
goto the_end;
f = qemu_fopen_bdrv(bs, 1);
if (!f) {
monitor_printf(mon, "Could not open VM state file\n");
goto the_end;
ret = qemu_savevm_state(f, &local_err);
vm_state_size = qemu_ftell(f);
qemu_fclose(f);
if (ret < 0) {
monitor_printf(mon, "%s\n", error_get_pretty(local_err));
error_free(local_err);
goto the_end;
bs1 = NULL;
while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1)) {
sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
ret = bdrv_snapshot_create(bs1, sn);
if (ret < 0) {
monitor_printf(mon, "Error while creating snapshot on '%s'\n",
bdrv_get_device_name(bs1));
the_end:
if (saved_vm_running) {
vm_start();
| 1threat
|
How to hydrate a Dictionary with the results of async calls? : <p>Suppose I have code that looks like this:</p>
<pre><code>public async Task<string> DoSomethingReturnString(int n) { ... }
int[] numbers = new int[] { 1, 2 , 3};
</code></pre>
<p>Suppose that I want to create a dictionary that contains the result of calling <code>DoSomethingReturnString</code> for each number similar to this:</p>
<pre><code>Dictionary<int, string> dictionary = numbers.ToDictionary(n => n,
n => DoSomethingReturnString(n));
</code></pre>
<p>That won't work because DoSomethingReturnString returns <code>Task<string></code> rather than <code>string</code>. The intellisense suggested that I try specifying my lambda expression to be async, but this didn't seem to fix the problem either.</p>
| 0debug
|
int cpu_get_dump_info(ArchDumpInfo *info,
const struct GuestPhysBlockList *guest_phys_blocks)
{
PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
info->d_machine = EM_PPC64;
info->d_class = ELFCLASS64;
if ((*pcc->interrupts_big_endian)(cpu)) {
info->d_endian = ELFDATA2MSB;
} else {
info->d_endian = ELFDATA2LSB;
return 0;
| 1threat
|
I am getting a syntax error in insert into statement. while trying to save : Private Sub savebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles savebtn.Click
Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\vb8\Mini-project\Mini-project\mini_db.mdb")
Dim query As String
Try
con.Open()
query = "INSERT INTO minitab VALUES (" & TextBox1.Text & "," & TextBox2.Text & ",@dob ," & TextBox5.Text & "," & TextBox6.Text & "," & TextBox7.Text & "," & TextBox8.Text & "," & TextBox9.Text & ")"
Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(query, con)
Dim dt As New DataTable
da.Fill(dt)
MsgBox("Data has been saved", MsgBoxStyle.SystemModal, "ok")
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
End Sub
| 0debug
|
Strong password autofill appears in iOS simulator : <p>Our UI test suites are showing some unexpected behaviour where our Create Password screen intermittently auto-completes both the username and password - this results in the test being failed.</p>
<p>The process is something like:</p>
<ul>
<li>Tap in the first create password field</li>
<li>Enter a password</li>
<li>Tap in the confirm password field</li>
<li>Enter the same password</li>
</ul>
<p>This last step fails because the passwords in both fields have been auto-completed.</p>
<p><a href="https://i.stack.imgur.com/J8TQ8.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/J8TQ8.jpg" alt="enter image description here"></a></p>
<p>This happens for about one in every ten to twenty test executions. </p>
<p>Our understanding is that the password auto-fill should never be seen in any simulator, so it's very confusing to see this at all. Is there something that we can do to <em>extra</em> disable autofill, or otherwise prevent this from happening?</p>
| 0debug
|
Setup ASP.NET MVC 4 or 5 project with Angular 2 : <p>I am learning angular 2 with Typescript.</p>
<p>I am using following resource.
<a href="https://angular.io/docs/ts/latest/quickstart.html" rel="noreferrer">QuickStart with Angular 2</a></p>
<p>Now from there and other examples i found that they telling to create package.json file that lists all dependencies for project.</p>
<p><strong>I think creating this package.json file and listing all dependency packages this kind of structure is followed in .NetCore Project.</strong></p>
<p><strong>In MVC 4 or 5 we have packages.config file which lists although packages that we are going to use.</strong></p>
<p>I am not saying we can not use package.json file when we have package.config file.</p>
<p><strong>But is there any simple way to integrate Angular 2 with typescript in MVC Webapplication project using NUGet Packages and get started?</strong></p>
<p><strong>If not available please let me know how can i setup Angular 2 with type script in ASP.Net MVC 4 or 5?</strong></p>
| 0debug
|
Android WebView - access classes from one iframe inside another iframe : <p>We have a native ios application, which displays a web view with HTML web page and two iframes. Inside those iframes, we display our articles from HTML files located in resources of the app. Inside the articles, there are often javascript scripts which operate on both articles at the same time. For example, make some part of the text bold. To do this, it lists all of the elements with a particular class and modify its CSS style.</p>
<pre><code>$(".question").length()
</code></pre>
<p>would return the number of elements with class <code>.question</code> in both iframes on iOS, where it would only return elements from current iframe on Android. By "current" I mean the one that user interacted with to start the script.</p>
<p>We have a requirement to also release an android app.
It all went fine, until I tested an article, where javascript has to operate on both iframes. Unfortunately, it can only access elements from one iframe.</p>
<p>Is there any way I could make it work without changing the code of the javascripts attached to the articles? I have no authority there [besides it could be thousands of articles with plenty of custom javascripts to update].</p>
<p>Thank you</p>
| 0debug
|
static void perf_cost(void)
{
const unsigned long maxcycles = 40000000;
unsigned long i = 0;
double duration;
unsigned long ops;
Coroutine *co;
g_test_timer_start();
while (i++ < maxcycles) {
co = qemu_coroutine_create(perf_cost_func);
qemu_coroutine_enter(co, &i);
qemu_coroutine_enter(co, NULL);
}
duration = g_test_timer_elapsed();
ops = (long)(maxcycles / (duration * 1000));
g_test_message("Run operation %lu iterations %f s, %luK operations/s, "
"%luns per coroutine",
maxcycles,
duration, ops,
(unsigned long)(1000000000 * duration) / maxcycles);
}
| 1threat
|
Use ObjectId.GenerateNewId() or leave MongoDB to create one? : <p>In C# I can use the ObjectId.GenerateNewId() to generate ObjectId values.</p>
<p>Most of the time when I insert a document in a collection I do not set the value of _id fields. MongoDB creates the ObjectId values automatically.</p>
<p>I would like to ask if it is safe to set it manually by using the ObjectId.GenerateNewId() method.</p>
| 0debug
|
Convert a List to List<Iterator<>> in java : <p>I have a <code>list<something></code> which passed to a method but the method expects like <code>List<Iterator<something>></code>.</p>
<p>How could i achieve this?</p>
<p>Thanks</p>
| 0debug
|
Connect Java SSL Server to a Java SSL server : <p>I'm having a hard time when trying to connect a java ssl server to another java ssl server. both of them running with the same ssl key.</p>
<p>This is what the first server looks like:</p>
<pre><code>public HostServer() throws IOException {
System.setProperty("javax.net.ssl.keyStore", HOST_SERVER_KEY_FILE);
System.setProperty("javax.net.ssl.keyStorePassword", SSL_KEY_PASSWORD);
serverSocket = ((SSLServerSocketFactory) SSLServerSocketFactory.getDefault()).createServerSocket(HOST_SERVER_PORT);
System.out.println("Host server is running and waiting for clients to connect...");
connectedRequestServers = new ArrayList<ClientData>();
connectedRequestServersSemaphore = new Semaphore(1);
}
public void start() {
try {
while (true) {
Socket socket = serverSocket.accept();
Thread clientHandler = new Thread(new ClientHandler(socket));
clientHandler.start();
}
} catch (IOException ex) {
Logger.getLogger(HostServer.class.getName()).log(Level.SEVERE, null, ex);
}
}
</code></pre>
<p>This is what the second server looks like:</p>
<pre><code> public RequstServer() throws IOException, NoSuchAlgorithmException, KeyManagementException, GeneralSecurityException {
System.setProperty("javax.net.ssl.keyStore", HostServer.HOST_SERVER_KEY_FILE);// REQUST_SERVER_KEY_FILE);
System.setProperty("javax.net.ssl.keyStorePassword", HostServer.SSL_KEY_PASSWORD); //SSL_KEY_PASSWORD);
serverSocket = ((SSLServerSocketFactory) SSLServerSocketFactory.getDefault()).createServerSocket(REQUEST_SERVER_PORT);
System.out.println("Request Server is up and running!");
System.setProperty("javax.net.ssl.trustStore", HostServer.HOST_SERVER_KEY_FILE);
hostSocket = ((SSLSocketFactory) SSLSocketFactory.getDefault()).createSocket(HostServer.HOST_SERVER_ADDRESS, HostServer.HOST_SERVER_PORT);
os = new ObjectOutputStream(hostSocket.getOutputStream());
is = new ObjectInputStream(hostSocket.getInputStream());
}
</code></pre>
<p>The first server is running fine, but when ever i'm trying to run the second server, I get the follwing error, meaning that the connection to the first server has failed.
If anyone can help me I will be so happy!</p>
<pre><code>Request Server is up and running!
3:12:47 PM Ver1.RequstServer main
SEVERE: null
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1877)
at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1786)
at java.io.ObjectOutputStream.<init>(ObjectOutputStream.java:247)
at Ver1.RequstServer.<init>(RequstServer.java:70)
at Ver1.RequstServer.main(RequstServer.java:38)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
at sun.security.validator.Validator.validate(Validator.java:260)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491)
... 12 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
... 18 more
</code></pre>
| 0debug
|
int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname)
{
char line[1024], group[64], id[64], arg[64], value[1024];
Location loc;
QemuOptsList *list = NULL;
Error *local_err = NULL;
QemuOpts *opts = NULL;
int res = -1, lno = 0;
loc_push_none(&loc);
while (fgets(line, sizeof(line), fp) != NULL) {
loc_set_file(fname, ++lno);
if (line[0] == '\n') {
continue;
}
if (line[0] == '#') {
continue;
}
if (sscanf(line, "[%63s \"%63[^\"]\"]", group, id) == 2) {
list = find_list(lists, group, &local_err);
if (local_err) {
error_report_err(local_err);
goto out;
}
opts = qemu_opts_create(list, id, 1, NULL);
continue;
}
if (sscanf(line, "[%63[^]]]", group) == 1) {
list = find_list(lists, group, &local_err);
if (local_err) {
error_report_err(local_err);
goto out;
}
opts = qemu_opts_create(list, NULL, 0, &error_abort);
continue;
}
value[0] = '\0';
if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2 ||
sscanf(line, " %63s = \"\"", arg) == 1) {
if (opts == NULL) {
error_report("no group defined");
goto out;
}
qemu_opt_set(opts, arg, value, &local_err);
if (local_err) {
error_report_err(local_err);
goto out;
}
continue;
}
error_report("parse error");
goto out;
}
if (ferror(fp)) {
error_report("error reading file");
goto out;
}
res = 0;
out:
loc_pop(&loc);
return res;
}
| 1threat
|
int ff_load_image(uint8_t *data[4], int linesize[4],
int *w, int *h, enum AVPixelFormat *pix_fmt,
const char *filename, void *log_ctx)
{
AVInputFormat *iformat = NULL;
AVFormatContext *format_ctx = NULL;
AVCodec *codec;
AVCodecContext *codec_ctx;
AVFrame *frame;
int frame_decoded, ret = 0;
AVPacket pkt;
av_register_all();
iformat = av_find_input_format("image2");
if ((ret = avformat_open_input(&format_ctx, filename, iformat, NULL)) < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Failed to open input file '%s'\n", filename);
return ret;
}
codec_ctx = format_ctx->streams[0]->codec;
codec = avcodec_find_decoder(codec_ctx->codec_id);
if (!codec) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to find codec\n");
ret = AVERROR(EINVAL);
goto end;
}
if ((ret = avcodec_open2(codec_ctx, codec, NULL)) < 0) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to open codec\n");
goto end;
}
if (!(frame = avcodec_alloc_frame()) ) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to alloc frame\n");
ret = AVERROR(ENOMEM);
goto end;
}
ret = av_read_frame(format_ctx, &pkt);
if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to read frame from file\n");
goto end;
}
ret = avcodec_decode_video2(codec_ctx, frame, &frame_decoded, &pkt);
if (ret < 0 || !frame_decoded) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to decode image from file\n");
goto end;
}
ret = 0;
*w = frame->width;
*h = frame->height;
*pix_fmt = frame->format;
if ((ret = av_image_alloc(data, linesize, *w, *h, *pix_fmt, 16)) < 0)
goto end;
ret = 0;
av_image_copy(data, linesize, (const uint8_t **)frame->data, frame->linesize, *pix_fmt, *w, *h);
end:
avcodec_close(codec_ctx);
if (format_ctx)
avformat_close_input(&format_ctx);
av_freep(&frame);
if (ret < 0)
av_log(log_ctx, AV_LOG_ERROR, "Error loading image file '%s'\n", filename);
return ret;
}
| 1threat
|
How to select unique nested dictionaries from list : <p>I have a list with nesetd dictionaries:</p>
<pre><code>lst = [
{'a':{'a1':1,'a2':2},
'b':{'b1':1,'b2':2},
'c':{'c1':1,'c2':2}},
{'a':{'a2':2,'a1':1},
'b':{'b1':1,'b2':2},
'c':{'c1':1,'c2':2}},
{'a':{'a1':1,'a2':2},
'b':{'bb1':11,'bb2':22},
'c':{'c1':1,'c2':2}},
{'b':{'b1':1,'b2':2},
'a':{'a1':1,'a2':2},
'c':{'c1':1,'c2':2}},
{'a':{'a1':1,'a2':2},
'b':{'b1':1,'b2':2}}]
</code></pre>
<p>I want to select only unique ones( it means that they have the same names of keys and values and the same amount of keys and values, but if some dictionaries are same but with different orders of keys with values they are the same type).
So the ouput must be like this:</p>
<pre><code>[
{'a':{'a1':1,'a2':2},
'b':{'b1':1,'b2':2},
'c':{'c1':1,'c2':2}},
{'a':{'a1':1,'a2':2},
'b':{'bb1':11,'bb2':22},
'c':{'c1':1,'c2':2}},
{'a':{'a1':1,'a2':2},
'b':{'b1':1,'b2':2}}]
</code></pre>
<p>How could i do that?</p>
| 0debug
|
static void qtrle_decode_16bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change)
{
int rle_code;
int pixel_ptr;
int row_inc = s->frame.linesize[0];
unsigned short rgb16;
unsigned char *rgb = s->frame.data[0];
int pixel_limit = s->frame.linesize[0] * s->avctx->height;
while (lines_to_change--) {
CHECK_STREAM_PTR(2);
pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 2;
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
if (rle_code == 0) {
CHECK_STREAM_PTR(1);
pixel_ptr += (s->buf[stream_ptr++] - 1) * 2;
CHECK_PIXEL_PTR(0);
} else if (rle_code < 0) {
rle_code = -rle_code;
CHECK_STREAM_PTR(2);
rgb16 = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
CHECK_PIXEL_PTR(rle_code * 2);
while (rle_code--) {
*(unsigned short *)(&rgb[pixel_ptr]) = rgb16;
pixel_ptr += 2;
}
} else {
CHECK_STREAM_PTR(rle_code * 2);
CHECK_PIXEL_PTR(rle_code * 2);
while (rle_code--) {
rgb16 = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
*(unsigned short *)(&rgb[pixel_ptr]) = rgb16;
pixel_ptr += 2;
}
}
}
row_ptr += row_inc;
}
}
| 1threat
|
Gitlab CI Build failed gitlab-runner-prebuilt.tar.xz: no such file or directory : <p>I just installed Gitlab Runner on my dev machine (Ubuntu 17.10) for testing.
When I run the runner I got:</p>
<pre><code>$: sudo gitlab-runner exec docker test
Running with gitlab-ci-multi-runner dev (1.4.2)
Using Docker executor with image php:5.6 ...
ERROR: Build failed (system failure): open /var/lib/gitlab-runner/gitlab-runner-prebuilt.tar.xz: no such file or directory
FATAL: open /var/lib/gitlab-runner/gitlab-runner-prebuilt.tar.xz: no such file or directory
</code></pre>
<p>.gitlab-ci.yml file:</p>
<pre><code>image: php:5.6
before_script:
- php -v
stages:
- test
test:
script:
- php -v
</code></pre>
<p>Current installation process:</p>
<pre><code>sudo apt-get install gitlab-runner
</code></pre>
<p>Output:</p>
<pre><code>...
Configuring gitlab-ci-multi-runner (1.4.2+dfsg-1) ...
I: generating GitLab Runner Docker image. This may take a while...
E: No mirror specified and no default available
W: please run 'sudo /usr/lib/gitlab-runner/mk-prebuilt-images.sh' to generate Docker image.
...
</code></pre>
<p>So I did:</p>
<pre><code>$: sudo /usr/lib/gitlab-runner/mk-prebuilt-images.sh
I: generating GitLab Runner Docker image. This may take a while...
E: No mirror specified and no default available
</code></pre>
| 0debug
|
static void push_output_configuration(AACContext *ac) {
if (ac->oc[1].status == OC_LOCKED || ac->oc[0].status == OC_NONE) {
ac->oc[0] = ac->oc[1];
}
ac->oc[1].status = OC_NONE;
}
| 1threat
|
C# Win Forms text box format : This may be a vague question but I am trying to find a function that sets all text boxes on a form to a currency format. On my form I have some preset boxes but many will be dynamic with the push of a button. The information in these text boxes will come from Access. I have a sample function for clearing text boxes, I'm curious if there is something similar for what I'm asking.
private void RecursiveClearTextBoxes(Control.ControlCollection cc) // clear all textboxes,combos and keep date on form
{
foreach (Control ctrl in cc)
{
System.Windows.Forms.TextBox tb = ctrl as System.Windows.Forms.TextBox;
if (tb != null)
tb.Clear();
else
RecursiveClearTextBoxes(ctrl.Controls);
}
}
| 0debug
|
Password strength detector in C doesn't work : <p>The password needs a letter and a number. Here's the code:</p>
<pre><code>#include <ctype.h>
int main()
{
char password;
printf("Please enter a password.\n");
scanf("%c", &password);
if ((isalpha (password) && isdigit(password))){
printf("Your password is strong!\n");
} else {
printf("Your password is weak!");
}
return 0;
}
</code></pre>
<p>However, when I compile it, it always prints "Your password is weak" even when I type in both characters and numbers. What's wrong? </p>
| 0debug
|
swift force-unwrapping exception not propagated : <p>I've run into this silly behaviour in swift where force-unwrapping an optional does not propagate.</p>
<p>From the documentation:</p>
<blockquote>
<p>Trying to use ! to access a non-existent optional value triggers a runtime error. Always make sure that an optional contains a non-nil value before using ! to force-unwrap its value.</p>
</blockquote>
<p>To reproduce:</p>
<pre><code>func foo(bar:String?) throws{
print(bar!);
}
</code></pre>
<p>And</p>
<pre><code>try foo(nil);
</code></pre>
<p>This does not seem logical or consistent to me and I can't find any documentation on this subject.</p>
<p>Is this by design?</p>
| 0debug
|
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
{
void **p = ptr;
if (min_size < *size)
return;
min_size= FFMAX(17*min_size/16 + 32, min_size);
av_free(*p);
*p = av_malloc(min_size);
if (!*p) min_size = 0;
*size= min_size;
}
| 1threat
|
Setting Background Color Of Button in WPF on runtime : <p>I am trying to set Background Color of Button(Names: b0,b1,b2,b3,b4,b5,b6,b7,b8,b9) in WPF on runtime. </p>
<p>Color Name is getting from Database that is Red right now. But it's giving me System.NullReferenceExceptionn: Object reference not set to an instance of an object</p>
<pre><code>private void ButtonBgColor()
{
string qryBgColor = "select Name from lookup where code in (select VALUE from qSettings where name='BUTTON_BG_COLOR') and type='BgColor'";
try
{
sqlConnection.Open();
sqlCommand = new SqlCommand(qryBgColor, sqlConnection);
sqlDataReader = sqlCommand.ExecuteReader();
if (sqlDataReader.Read())
{
string BUTTON_BG_COLOR = sqlDataReader["Name"].ToString();
Button[] b = new Button[9];
for (int i = 0; i < b.Length; i++)
{
var textBlock08 = (TextBlock)b[i].Template.FindName("myTextBlock", b[i]);
textBlock08.Background = (System.Windows.Media.SolidColorBrush)new System.Windows.Media.BrushConverter().ConvertFromString(BUTTON_BG_COLOR);
}
}
}
catch (Exception exp)
{
MessageBox.Show(exp.ToString(), "Button Background Color Exception");
}
</code></pre>
<p>Can anyone help me to resolve this problem ?</p>
<p>Thanks in advance</p>
| 0debug
|
HTML files don't refresh unless they are accessed : <p>I have a setup in which I make AJAX calls to load the html files containing to be displayed data. Let's say the main page is index.html and I have two other pages: pages/1.html and pages/2.html. In index.html either 1 or 2 is set as content. My browser however caches both 1 and 2 and when I change either of them and reload the page it won't display the changes I've made because I didn't actually refresh 1.html or 2.html. How can I make it so that this is not an issue?</p>
| 0debug
|
LINQ search inside a collection based on a given list of items : Lets say I am given a list<string> as input:
IList<string> availableFruits = {orange, banana}
I have a fruit entity that looks like this:
public Fruit
{
public int ID { get; set; }
public string name { get; set; }
}
we define some fruits:
var f1 = new Fruit { Id = 1, name = "apple" };
var f2 = new Fruit { Id = 2, name = "banana" };
var f3 = new Fruit { Id = 3, name = "orange" };
var f4 = new Fruit { Id = 4, name = "pineapple" };
Finally, we have a menu where these fruits go:
public class Menu
{
public int ID { get; set; }
public ICollection<Fruit> fruits;
}
var menus = new List<Menu>
{
new Menu {ID = 0, fruits = new List<Fruit> { f1, f2 } },
new Menu {ID = 1, fruits = new List<Fruit> { f1, f3, f4 } },
new Menu {ID = 2, fruits = new List<Fruit> { f1, f4 } },
new Menu {ID = 3, fruits = new List<Fruit> { f2 } },
};
I need a LINQ query that searches in the menus and returns all menus that contains 'ANY' of the fruits passed in the avaiableFruits list. Thus in this case it will return menus with ID's 0, 1 and 3.
Thanks in advance for you help.
Fike
| 0debug
|
Use new firebase sdk in android eclipse project : <p>new firebase with awesome features was just announced, but according to documentation (<a href="https://firebase.google.com/docs/android/setup#prerequisites" rel="noreferrer">https://firebase.google.com/docs/android/setup#prerequisites</a>) android studio (as well as gradle) is required now. For now in my cocos2d-x apps I have to use ADT/Eclipse to build apps, because gradle isn't supported yet (however cocos2d-x team is working on it). I'm now using an older version of the sdk, which is just a jar file. Is there a way to use new firebase in eclipse? What worries me the most is that plugin:</p>
<pre><code>apply plugin: 'com.google.gms.google-services'
</code></pre>
| 0debug
|
void ff_avg_h264_qpel4_mc00_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avg_width4_msa(src, stride, dst, stride, 4);
}
| 1threat
|
Auriez-vous une solution pour détecter les erreurs de memoire dans un programme en C? : Salut,
je suis actuellement en train de recoder certaines fonctions de la lib C et je suis confronté à un problème de type "détection d'erreur mémoire".
Pour la fonction strcpy,
...
char *my_strcpy(char *str1, char *str2)
{
int i = 0;
for (; str2[i] != 0; i++)
str1[i] = str2[i];
str1[i] = 0;
return (str1);
}
...
en utilisant le test criterion suivant:
...
#include <criterion/criterion.h>
char *my_strcpy(char *str1, char *str2);
Test(my_strcpy, in_allocated_string)
{
char *src = "Hello World";
char dest[11];
my_strcpy(dest, src);
cr_assert_str_eq(dest, "Hello World");
cr_assert_eq(dest, my_strcpy(dest, src));
}
...
la destination étant plus petite que la source je devrai obtenir un segfault, pourtant ni valgrind ni scan build ne me donne d'information ou d'erreur, le programme compile et s'execute sans erreur.
je vous laisse un petit makefile pour compile avec ou sans les tests.
...
SRC = code.c \
SRC_TEST = test.c \
LDFLAGS = -L./lib/my -lmy
OBJ = $(SRC:.c=.o)
CC = gcc
CFLAGS = -W -Wall -Wextra -Werror -fstack-protector -fstack-protector-all -fstack-protector-strong -Wstack-protector
NAME = libmy.a
all: $(NAME)
$(NAME): $(OBJ)
ar rc $@ $^
test: $(SRC) $(SRC_TEST)
$(CC) -fprofile-arcs -ftest-coverage -Isrc/main -DMOCKING $(CFLAGS) $(shell pkg-config --libs --cflags criterion) $^ -o tests
./tests
clean:
rm -rf *.gcda *.gcno *.info $(OBJ)
fclean: clean
rm -f $(NAME)
rm -rf tests
re: fclean all
...
Auriez-vous une solution pour détecter les erreurs de memoire dans un programme en C ?
| 0debug
|
Error when trying to publish an azure function from Visual Studio : <p>I get the following error message when I try to publish my function using Visual Studio, any idea how to fix this?</p>
<blockquote>
<p>System.AggregateException: One or more errors occurred. --->
System.Exception: Publish has encountered an error. We were unable to
determine the cause of the error. Check the output log for more
details. --- End of inner exception stack trace --- at
System.Threading.Tasks.Task.ThrowIfExceptional(Boolean
includeTaskCanceledExceptions) at
System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout,
CancellationToken cancellationToken) at
Microsoft.Publish.Framework.Model.DefaultPublishSteps.<>c__DisplayClass26_0.b__2()
at System.Threading.Tasks.Task`1.InnerInvoke() at
System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.Publish.Framework.Model.DefaultPublishSteps.d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel.d__213.MoveNext()
---> (Inner Exception #0) System.Exception: Publish has encountered an error. We were unable to determine the cause of the error. Check the
output log for more details. <---</p>
<p>System.Exception: Publish has encountered an error. We were unable to
determine the cause of the error. Check the output log for more
details. </p>
<p>===================</p>
</blockquote>
| 0debug
|
void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
bool has_base, const char *base,
bool has_top, const char *top,
bool has_backing_file, const char *backing_file,
bool has_speed, int64_t speed,
Error **errp)
{
BlockDriverState *bs;
BlockDriverState *base_bs, *top_bs;
AioContext *aio_context;
Error *local_err = NULL;
BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;
if (!has_speed) {
speed = 0;
}
bs = qmp_get_root_bs(device, &local_err);
if (!bs) {
bs = bdrv_lookup_bs(device, device, NULL);
if (!bs) {
error_free(local_err);
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
} else {
error_propagate(errp, local_err);
}
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT_SOURCE, errp)) {
goto out;
}
top_bs = bs;
if (has_top && top) {
if (strcmp(bs->filename, top) != 0) {
top_bs = bdrv_find_backing_image(bs, top);
}
}
if (top_bs == NULL) {
error_setg(errp, "Top image file %s not found", top ? top : "NULL");
goto out;
}
assert(bdrv_get_aio_context(top_bs) == aio_context);
if (has_base && base) {
base_bs = bdrv_find_backing_image(top_bs, base);
} else {
base_bs = bdrv_find_base(top_bs);
}
if (base_bs == NULL) {
error_setg(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");
goto out;
}
assert(bdrv_get_aio_context(base_bs) == aio_context);
if (bdrv_op_is_blocked(base_bs, BLOCK_OP_TYPE_COMMIT_TARGET, errp)) {
goto out;
}
if (top_bs == base_bs) {
error_setg(errp, "cannot commit an image into itself");
goto out;
}
if (top_bs == bs) {
if (has_backing_file) {
error_setg(errp, "'backing-file' specified,"
" but 'top' is the active layer");
goto out;
}
commit_active_start(has_job_id ? job_id : NULL, bs, base_bs, speed,
on_error, block_job_cb, bs, &local_err, false);
} else {
commit_start(has_job_id ? job_id : NULL, bs, base_bs, top_bs, speed,
on_error, block_job_cb, bs,
has_backing_file ? backing_file : NULL, &local_err);
}
if (local_err != NULL) {
error_propagate(errp, local_err);
goto out;
}
out:
aio_context_release(aio_context);
}
| 1threat
|
static inline void RENAME(rgb16to32)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
#if COMPILE_TEMPLATE_MMX
const uint16_t *mm_end;
#endif
uint8_t *d = dst;
const uint16_t *s = (const uint16_t*)src;
end = s + src_size/2;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
__asm__ volatile("pxor %%mm7,%%mm7 \n\t":::"memory");
__asm__ volatile("pcmpeqd %%mm6,%%mm6 \n\t":::"memory");
mm_end = end - 3;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq %1, %%mm1 \n\t"
"movq %1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
PACK_RGB32
:"=m"(*d)
:"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r)
:"memory");
d += 16;
s += 4;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
#endif
while (s < end) {
register uint16_t bgr;
bgr = *s++;
#if HAVE_BIGENDIAN
*d++ = 255;
*d++ = (bgr&0xF800)>>8;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0x1F)<<3;
#else
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0xF800)>>8;
*d++ = 255;
#endif
}
}
| 1threat
|
Can't get my Labels to update in tkinter : I'm trying to create a program in where you put a word in a box, press add, and this word goes to a list, which is also displayed on the right side. When I press the forward button the first thing on teh list is deleted. Problem is I can't get the labels to update when I press teh buttons / edit the list...
Thx in advance.
from tkinter import *
root = Tk()
root.title('Speakers List')
root.minsize(800, 600)
speakers = ['none']
spe = speakers[0]
def add():
if spe == 'none':
speakers.insert(0, [s])
e.delete(0, END)
spe.config(text=speakers[0])
else:
speakers[-2] = [s]
e.delete(0, END)
spe.config(text=speakers[0])
return
def forward():
if len(speakers) is 0:
return
else:
del speakers[0]
spe.config(text=speakers[0])
return
entry = StringVar()
e = Entry(root, width=30, font=("Arial", 20), textvariable=entry)
e.grid(row=0, sticky=W)
s = e.get()
button1 = Button(root, padx=10, pady=10, bd=5, text='Add', fg='black', command=add)
button1.grid(row=0, column=1)
button2 = Button(root, padx=10, pady=10, bd=5, text='Next', fg='black', command=forward)
button2.grid(row=1, column=1)
n = Label(root, font=("Arial", 35), bd=2, text=spe)
n.grid(row=1, sticky=W)
listdisplay = Label(root, font=('Arial', 20), text=speakers)
listdisplay.grid(row=0, column=10)
root.mainloop()
| 0debug
|
static void rcu_qtest(const char *test, int duration, int nreaders)
{
int i;
long long n_removed_local = 0;
struct list_element *el, *prev_el;
rcu_qtest_init();
for (i = 0; i < nreaders; i++) {
create_thread(rcu_q_reader);
}
create_thread(rcu_q_updater);
rcu_qtest_run(duration, nreaders);
QLIST_FOREACH_SAFE_RCU(prev_el, &Q_list_head, entry, el) {
QLIST_REMOVE_RCU(prev_el, entry);
call_rcu1(&prev_el->rcu, reclaim_list_el);
n_removed_local++;
}
atomic_add(&n_nodes_removed, n_removed_local);
synchronize_rcu();
while (n_nodes_removed > n_reclaims) {
g_usleep(100);
synchronize_rcu();
}
if (g_test_in_charge) {
g_assert_cmpint(n_nodes_removed, ==, n_reclaims);
} else {
printf("%s: %d readers; 1 updater; nodes read: " \
"%lld, nodes removed: %lld; nodes reclaimed: %lld\n",
test, nthreadsrunning - 1, n_reads, n_nodes_removed, n_reclaims);
exit(0);
}
}
| 1threat
|
Generate random number with arc4random_uniform : <p>I want to generate some random numbers (1 to limit) and store them with an array. Here's my codes:</p>
<pre><code>var results = [Int]()
for i in 0...qut
{
let lim = limit - 1
results[i] = Int(arc4random_uniform(lim)) + 1
}
</code></pre>
<p>And then xcode told me that "Cannot convert value of type 'Int' to expected argument type 'UInt32'. "</p>
<p>So I made some changes:</p>
<pre><code>results[i] = Int(arc4random_uniform(UInt32(lim))) + 1
</code></pre>
<p>There's no error now. But when I run it, it report an error: "Fatal error: Index out of range."</p>
<p>Could someone tell me how can I fix that?</p>
| 0debug
|
Android dataBinding - how to use bool resource to trigger visibility of layout : <p>I currently have a bool.xml file in android which looks like this:</p>
<pre><code> <?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="showAds">true</bool>
</resources>
</code></pre>
<p>Now i have a layout.xml file which uses databinding. I want to show or hide the visilibity of a adView based on a the boolean showAds defined above. So far i have this:</p>
<pre><code> <com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="@{@bool/showAds ? View.Visible:View:gone}"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-1234567/34343">
</code></pre>
<p>but it does not compile. how can i get the boolean to decide if the ad should show or not ?The syntax is wrong. </p>
| 0debug
|
How to remove spaces using JavaScript? : <p>how to remove spaces.
i use onkeyup to show output in div</p>
<p>Thanks</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-js lang-js prettyprint-override"><code>var inputBox = document.getElementById('chatinput');
inputBox.onkeyup = function() {
document.getElementById('printchatbox').innerHTML = inputBox.value;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="form-group">
<label>Title Page</label>
<input type="text" id="chatinput" class="form-control" required="">
</div>
<div class="form-group">
<div><b>Permalink: </b>http://doamin.com/<span id="printchatbox" class="cl-blue"></span></div>
</div></code></pre>
</div>
</div>
</p>
| 0debug
|
static int xan_decode_chroma(AVCodecContext *avctx, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
XanContext *s = avctx->priv_data;
uint8_t *U, *V;
unsigned chroma_off;
int val, uval, vval;
int i, j;
const uint8_t *src, *src_end;
const uint8_t *table;
int mode, offset, dec_size;
chroma_off = AV_RL32(buf + 4);
if (!chroma_off)
return 0;
if (chroma_off + 10 >= avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "Invalid chroma block position\n");
return -1;
}
src = avpkt->data + 4 + chroma_off;
table = src + 2;
mode = bytestream_get_le16(&src);
offset = bytestream_get_le16(&src) * 2;
if (src - avpkt->data >= avpkt->size - offset) {
av_log(avctx, AV_LOG_ERROR, "Invalid chroma block offset\n");
return -1;
}
memset(s->scratch_buffer, 0, s->buffer_size);
dec_size = xan_unpack(s->scratch_buffer, s->buffer_size, src + offset,
avpkt->size - offset - (src - avpkt->data));
if (dec_size < 0) {
av_log(avctx, AV_LOG_ERROR, "Chroma unpacking failed\n");
return -1;
}
U = s->pic.data[1];
V = s->pic.data[2];
src = s->scratch_buffer;
src_end = src + dec_size;
if (mode) {
for (j = 0; j < avctx->height >> 1; j++) {
for (i = 0; i < avctx->width >> 1; i++) {
val = *src++;
if (val) {
val = AV_RL16(table + (val << 1));
uval = (val >> 3) & 0xF8;
vval = (val >> 8) & 0xF8;
U[i] = uval | (uval >> 5);
V[i] = vval | (vval >> 5);
}
if (src == src_end)
return 0;
}
U += s->pic.linesize[1];
V += s->pic.linesize[2];
}
} else {
uint8_t *U2 = U + s->pic.linesize[1];
uint8_t *V2 = V + s->pic.linesize[2];
for (j = 0; j < avctx->height >> 2; j++) {
for (i = 0; i < avctx->width >> 1; i += 2) {
val = *src++;
if (val) {
val = AV_RL16(table + (val << 1));
uval = (val >> 3) & 0xF8;
vval = (val >> 8) & 0xF8;
U[i] = U[i+1] = U2[i] = U2[i+1] = uval | (uval >> 5);
V[i] = V[i+1] = V2[i] = V2[i+1] = vval | (vval >> 5);
}
}
U += s->pic.linesize[1] * 2;
V += s->pic.linesize[2] * 2;
U2 += s->pic.linesize[1] * 2;
V2 += s->pic.linesize[2] * 2;
}
}
return 0;
}
| 1threat
|
I need to sort the count of tokens in descending order, is there any other method than creating a dataframe? : token_map = {}
words = []
with open('test.csv', 'r') as fopen:
lines = fopen.readlines()
for line in lines:
line = str.strip(line)
words_in_line = str.split(line, " ")
token_map[line] = "" + str(len(words_in_line)) +","+ str(len(line))
words.append(words_in_line)
print words
print token_map
| 0debug
|
TSQL determine specific character : In my table, I got the Data '98753201_en_GB.dwg'. I want to determine the '.' and from there, I want the 6 characters before: '_en_GB'. It must be variable, so I cannot just use Substring. Any Ideas?
| 0debug
|
how to count some rows in a specific field in mysql tabl3 in codeigniter : i want to get some statistics like below
--------------------------------------
NAME HIGH MEDIUM LOW TOTAL
--------------------------------------
ali 2 0 1 3
hacen 1 1 0 2
--------------------------------------
from table TASKS
----------------------------------
NAME ASSIGNED-TO PERIORITY
----------------------------------
task-1 ali high
task-2 ali high
task-3 ali low
task-4 hacen high
task-5 hacen medium
----------------------------------
using codeigniter 3
| 0debug
|
static void raw_decode(uint8_t *dst, const int8_t *src, int src_size)
{
while (src_size--)
*dst++ = *src++ + 128;
}
| 1threat
|
static void coroutine_fn pdu_complete(V9fsPDU *pdu, ssize_t len)
{
int8_t id = pdu->id + 1;
V9fsState *s = pdu->s;
if (len < 0) {
int err = -len;
len = 7;
if (s->proto_version != V9FS_PROTO_2000L) {
V9fsString str;
str.data = strerror(err);
str.size = strlen(str.data);
len += pdu_marshal(pdu, len, "s", &str);
id = P9_RERROR;
}
len += pdu_marshal(pdu, len, "d", err);
if (s->proto_version == V9FS_PROTO_2000L) {
id = P9_RLERROR;
}
trace_v9fs_rerror(pdu->tag, pdu->id, err);
}
pdu_marshal(pdu, 0, "dbw", (int32_t)len, id, pdu->tag);
pdu->size = len;
pdu->id = id;
pdu_push_and_notify(pdu);
qemu_co_queue_next(&pdu->complete);
pdu_free(pdu);
}
| 1threat
|
How to make a 'mat-select' readonly? : <p>I am working on a angular 5 project. There are many <code>mat-select</code> elements which is supposed to be readonly like text boxes. I found out that there is a <code>disabled</code> feature which is: </p>
<pre><code> <mat-form-field>
<mat-select placeholder="Choose an option" [disabled]="disableSelect.value">
<mat-option value="option1">Option 1</mat-option>
<mat-option value="option2" disabled>Option 2 (disabled)</mat-option>
<mat-option value="option3">Option 3</mat-option>
</mat-select>
</mat-form-field>
</code></pre>
<p>which out put looks like:</p>
<p><a href="https://i.stack.imgur.com/OA4ne.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OA4ne.png" alt="enter image description here"></a></p>
<p>It fades out the text and the lining below get changes, is it possible to make it readonly?</p>
| 0debug
|
Can I require a module specifically for iOS in React Native? : <p>I am currently using <a href="https://github.com/naoufal/react-native-safari-view" rel="noreferrer"><code>react-native-safari-view</code></a> module in my React Native project for showing web views in iOS.</p>
<p>As the module is not yet implemented for Android, when I try to build the project for Android, it gives me an error at this line:</p>
<pre><code>import SafariView from 'react-native-safari-view'
</code></pre>
<p>I am going to use the <a href="https://facebook.github.io/react-native/docs/linking.html" rel="noreferrer"><code>Linking</code></a> library for Android, but I don't know how to use the same code for two platforms.</p>
<p>I tried:</p>
<pre><code>if (Platform.OS == 'ios') {
import SafariView from 'react-native-safari-view'
}
</code></pre>
<p>And it gives me this error:</p>
<blockquote>
<p>import' and 'export' may only appear at the top level</p>
</blockquote>
<p>How do I get around this?</p>
| 0debug
|
Organize table in MSSQL Server : I need help, how organize table in MSSQL 2014 (one or two table) for question and answer, and with stored procedure return result as:
[{
"question": "What is the full form of IP?",
"choices": ["Internet Provider", "Internet Port", "Internet Protocol"],
"correct": "Internet Protocol"
}, {
"question": "Who is the founder of Microsoft?",
"choices": ["Bill Gates", "Steve Jobs", "Steve Wozniak"],
"correct": "Bill Gates"
}, {
"question": "1 byte = ?",
"choices": ["8 bits", "64 bits", "1024 bits"],
"correct": "8 bits"
}, {
"question": "The C programming language was developed by?",
"choices": ["Brendan Eich", "Dennis Ritchie", "Guido van Rossum"],
"correct": "Dennis Ritchie"
}, {
"question": "What does CC mean in emails?",
"choices": ["Carbon Copy", "Creative Commons", "other"],
"correct": "Carbon Copy"
}];
| 0debug
|
void ff_put_h264_qpel4_mc02_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_vt_4w_msa(src - (stride * 2), stride, dst, stride, 4);
}
| 1threat
|
sql how to execute 2 select statement in a single query ,,,it is showing me : I want to count column first: as total number of instances of each column ,
second ,count total number of instances based on condition
I am using this
Select group_name, Definition_Range ,count([group_name]) as Number_of_Clients from [Computer Status] where Definition_Range =' 0-10 Days' group by group_name,(select count([group_name]) as Total_Clients from [Computer Status] group by group_name)
| 0debug
|
Could you please explain this statement by providing an implementation of the design pattern it alludes to? : <p>The <a href="https://msdn.microsoft.com/en-us/library/1c9txz50%28v=vs.110%29.aspx" rel="nofollow">Managed Threading Best Practices</a> page states:</p>
<p><em>Avoid providing static methods that alter static state. In common server scenarios, static state is shared across requests, which means multiple threads can execute that code at the same time. This opens up the possibility of threading bugs. <strong>Consider using a design pattern that encapsulates data into instances that are not shared across requests.</strong> Furthermore, if static data are synchronized, calls between static methods that alter state can result in deadlocks or redundant synchronization, adversely affecting performance.</em></p>
<p>I understand all the rest except for the one sentence that is in bold.</p>
<p>How would you do this without essentially changing the field from a static one to an instance one? Isn't that saying, "In a server scenario, avoid using static class-level members as much as you can?"</p>
<p>If it isn't, could you please provide an implementation of the design pattern it is alluding to?</p>
| 0debug
|
static int configure_filtergraph(FilterGraph *fg)
{
return fg->graph_desc ? configure_complex_filter(fg) : configure_video_filters(fg);
}
| 1threat
|
V.b net if-stetman : If s > 0 Then
sh = (4 * s * 3.14)
Console.WriteLine("Sqhere Area")
Console.WriteLine(sh)
Else
How to convert it to
select case ?
| 0debug
|
C++ [Error] declaration of 'char ' shadows a parameter. what does it mean? : <p>I am trying to giving some <code>char</code> to a variable within a function by using <code>strcpy</code>. And I am getting the following errors </p>
<pre><code>[Error] declaration of 'char str3 [100]' shadows a parameter
[Error] invalid initialization of non-const reference of type 'std::string& {aka std::basic_string<char>&}' from an rvalue of type 'char*'
[Note] in passing argument 2 of 'void read_string(std::string&, std::string&)'
</code></pre>
<p>Here is my code as follows :</p>
<pre><code>#include <iostream>
#include <string.h>
using namespace std;
void read_string(std::string &to, std :: string &str3)
{
to = "test";
std::cout << &to << std::endl;
char str3[100];
strcpy (str3,"copy successful");
std::cout << str3<<std :: endl;
}
int main()
{
std::string s = "This should be changed.";
char ss[100];
read_string(s,ss);
std::cout << &s << std::endl;
std::cout<<ss<<std::endl;
return 0;
}
</code></pre>
| 0debug
|
Does anyone know any useful gem to create voting system in Sinatra? : <p>Hi I am creating a small Sinatra app and trying to create a voting system in it.</p>
<p>I tried using acts_as_votable gem but it is giving me some error.</p>
<pre><code>rake db:migrate
rake aborted!
TypeError: ActsAsVotable is not a class
</code></pre>
<p>Here is my migration file which I tried to make from source code of gem.
class ActsAsVotable < ActiveRecord::Migration[5.1]
def self.up
create_table :votes do |t|</p>
<pre><code> t.references :votable, :polymorphic => true
t.references :voter, :polymorphic => true
t.boolean :vote_flag
t.string :vote_scope
t.integer :vote_weight
t.timestamps
end
if ActiveRecord::VERSION::MAJOR < 4
add_index :votes, [:votable_id, :votable_type]
add_index :votes, [:voter_id, :voter_type]
end
add_index :votes, [:voter_id, :voter_type, :vote_scope]
add_index :votes, [:votable_id, :votable_type, :vote_scope]
end
def self.down
drop_table :votes
end
end
</code></pre>
<p>I also created Acts_as_votable module from the gem source code. Please see below code</p>
<pre><code>require 'active_record'
require 'active_support/inflector'
$LOAD_PATH.unshift(File.dirname(__FILE__))
module ActsAsVotable
if defined?(ActiveRecord::Base)
require 'acts_as_votable/extenders/votable'
require 'acts_as_votable/extenders/voter'
require 'acts_as_votable/vote'
ActiveRecord::Base.extend ActsAsVotable::Extenders::Votable
ActiveRecord::Base.extend ActsAsVotable::Extenders::Voter
end
end
require 'acts_as_votable/extenders/controller'
ActiveSupport.on_load(:action_controller) do
include ActsAsVotable::Extenders::Controller
end
</code></pre>
<p>Any suggestion to make this work or any other alternet solution for Sinatra?</p>
| 0debug
|
void audio_encode_example(const char *filename)
{
AVCodec *codec;
AVCodecContext *c= NULL;
int frame_size, i, j, out_size, outbuf_size;
FILE *f;
short *samples;
float t, tincr;
uint8_t *outbuf;
printf("Audio encoding\n");
codec = avcodec_find_encoder(CODEC_ID_MP2);
if (!codec) {
fprintf(stderr, "codec not found\n");
exit(1);
}
c= avcodec_alloc_context();
c->bit_rate = 64000;
c->sample_rate = 44100;
c->channels = 2;
if (avcodec_open(c, codec) < 0) {
fprintf(stderr, "could not open codec\n");
exit(1);
}
frame_size = c->frame_size;
samples = malloc(frame_size * 2 * c->channels);
outbuf_size = 10000;
outbuf = malloc(outbuf_size);
f = fopen(filename, "w");
if (!f) {
fprintf(stderr, "could not open %s\n", filename);
exit(1);
}
t = 0;
tincr = 2 * M_PI * 440.0 / c->sample_rate;
for(i=0;i<200;i++) {
for(j=0;j<frame_size;j++) {
samples[2*j] = (int)(sin(t) * 10000);
samples[2*j+1] = samples[2*j];
t += tincr;
}
out_size = avcodec_encode_audio(c, outbuf, outbuf_size, samples);
fwrite(outbuf, 1, out_size, f);
}
fclose(f);
free(outbuf);
free(samples);
avcodec_close(c);
free(c);
}
| 1threat
|
static struct ioreq *ioreq_start(struct XenBlkDev *blkdev)
{
struct ioreq *ioreq = NULL;
if (LIST_EMPTY(&blkdev->freelist)) {
if (blkdev->requests_total >= max_requests)
goto out;
ioreq = qemu_mallocz(sizeof(*ioreq));
ioreq->blkdev = blkdev;
blkdev->requests_total++;
qemu_iovec_init(&ioreq->v, BLKIF_MAX_SEGMENTS_PER_REQUEST);
} else {
ioreq = LIST_FIRST(&blkdev->freelist);
LIST_REMOVE(ioreq, list);
qemu_iovec_reset(&ioreq->v);
}
LIST_INSERT_HEAD(&blkdev->inflight, ioreq, list);
blkdev->requests_inflight++;
out:
return ioreq;
}
| 1threat
|
res is not defined in nodejs(Mongoose) : How can i put res in a normal function i.e not an exported one which is not part of routes.
function createNewStudent(v,callBackOne){
if (callBackOne) {
studentInfo.callBackOneStudent = callBackOne;
}
// common filter json
var filterjson = common.defaultFilterJson();
filterjson['active'] = true;
filterjson['email'] = v.email;
// student initialization
var student = new Student(v);
async.waterfall([
function (done) {
student.save(function (err) {
if (!err) {
studentInfo.callBackOneStudent();
Employee.update({_id: student.created_by},{"$push": { "students": student._id } }).exec(function (err, employee) { });
done();
}
});
}
}
});
},
function (done) {
var url = config.mailer.studentActivateUrl + student._id;
---error is here-----
res.render('modules/users/server/templates/student-confirmation-email', {
name: student.first_name + ' ' + student.last_name,
appName: 'GAIPP',
url: url
}, function (err, emailHTML) {
done(err, emailHTML, student);
});
}
});
,My error is 'res' is not defined.Can anyone please help me to solve this error.Thanks.
| 0debug
|
User-Specific Workspace Settings in VS Code : <p>Working on a Python project and I want to define the path to where I store my virtualenv for the project.</p>
<p>I have linting settings in my <code>.vscode/settings.json</code> workspace settings, however this is checked into my git repository and is common across any collaborators on the project, thus I don't think it would make sense to reference where I personally keep my virtualenv for this project in the workspace settings.</p>
<p>As it is a project-specific virtualenv, it does not make sense to reference it in my user settings either.</p>
<p>Is there a way I can store my path to my virtualenv for this project?</p>
| 0debug
|
ow can I create an access data base that delete entries after a specific dates : How can I create an access data base that delete entries after a specific dates
For example, the expiry date of a medicine in my stock is today. The entry of that medicine must be automatically deleted from my database after today.
**
> what macro programming must I do?????
**
| 0debug
|
def max_sum_of_three_consecutive(arr, n):
sum = [0 for k in range(n)]
if n >= 1:
sum[0] = arr[0]
if n >= 2:
sum[1] = arr[0] + arr[1]
if n > 2:
sum[2] = max(sum[1], max(arr[1] + arr[2], arr[0] + arr[2]))
for i in range(3, n):
sum[i] = max(max(sum[i-1], sum[i-2] + arr[i]), arr[i] + arr[i-1] + sum[i-3])
return sum[n-1]
| 0debug
|
Swift UIViewReportBrokenSuperviewChain cause by Layer manipulation : <p>I run into a problem after migrating my code to Swift 3.
I guess iOS10 raises new issues now and it's actually not related to Swift itself.</p>
<p>The error:</p>
<pre><code>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'View has lost track of its superview, most likely through unsupported use of CALayer API on the view's layer. If this isn't a crash yet, it will be in the near future.
Problem view: <UIToolbar: 0x102552d80; frame = (0 0; 375 683); alpha = 0.97; opaque = NO; layer = <CALayer: 0x1700383e0>>
Expected parent: <MyModelView: 0x10250ecd0; frame = (0 -16; 375 683); hidden = YES; layer = <CALayer: 0x17003d4a0>>
Break on UIViewReportBrokenSuperviewChain to debug.'
</code></pre>
<p>The code triggering the issue is :</p>
<pre><code>[c presentViewController:tabBarViewController animated:NO completion:^{
</code></pre>
<p>The sub code responsible for the problem seems to be:</p>
<pre><code>- (void)addBlurView
{
CGRect viewBounds = [[UIScreen mainScreen]applicationFrame];
self.myModelView = [[MyModalView alloc] initWithFrame:CGRectMake(viewBounds.origin.x, -16, viewBounds.size.width, viewBounds.size.height+36)];
if(![self toolbar]) {
_toolbar = [[UIToolbar alloc] initWithFrame:[self.myModelView bounds]];
[_toolbar setBarStyle:UIBarStyleBlack];
_toolbar.alpha = 0.97;
[self.myModelView.layer insertSublayer:_toolbar.layer atIndex:0];
}
[self.view addSubview:self.myModelView];
}
</code></pre>
| 0debug
|
Remove blank line in c++ : <p><strong>How to remover blank lines after reading a text file using c++?</strong></p>
<pre><code>while(arry[i]="/n"){
i++;
}
</code></pre>
<p>This is my code.It gives some output.But it is not a expected output.</p>
| 0debug
|
Create a simple macro that runs another macro based on the value of another cell : I am wanting to create a macro that will run "macro2" (already created) if the value of another cell is greater than 1 otherwise it will run "macro3" (already created). I am not sure where to start with this. All the other similar questions I checked were different enough to leave me in the dark.
| 0debug
|
Why sin function in programming language returning strange sin value unlike calculators : <p>I get familiar value of sin in calculator</p>
<p><a href="https://i.stack.imgur.com/JznvD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JznvD.jpg" alt="enter image description here"></a></p>
<p>When i calculate it in either java program or Google.i am getting strange value like below</p>
<p><a href="https://i.stack.imgur.com/Syc9h.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Syc9h.jpg" alt="enter image description here"></a></p>
<p>Please anyone let me know how it works and what if i want calculator sin function in my java program?</p>
| 0debug
|
Rfid reader shows (Authentication failed() : communication error) when scanning card : I am working on a project. In the project I am using arduino uno atmega328p board to take input from rfid reader(MFRC522). With reader I got Keychain tag and identity_card tag. The library I am using is MFRC522. I downloaded it from github. In that I tried dumpinfo example code to scan card. Reader works fine with default cards. (Keychain and identity_card tag). Now the problem is When I scan my college identity card it shows an error "Authentication failed () :communication error". please help me. Thanks in advance
| 0debug
|
Gitlab CI - docker: command not found : <p>I am trying to build my docker image within the gitlab ci pipeline.</p>
<p>However it is not able to find the docker command.</p>
<blockquote>
<p>/bin/bash: line 69: docker: command not found ERROR: Job failed: error
executing remote command: command terminated with non-zero exit code:
Error executing in Docker Container: 1</p>
</blockquote>
<p><strong>.gitlab-ci.yml</strong></p>
<pre><code>stages:
- quality
- test
- build
- deploy
image: node:8.11.3
services:
- mongo
- docker:dind
before_script:
- npm install
quality:
stage: quality
script:
- npm run-script lint
test:
stage: test
script:
- npm run-script test
build:
stage: build
script:
- docker build -t server .
deploy:
stage: deploy
script:
- echo "TODO deploy push docker image"
</code></pre>
| 0debug
|
Letting users two times a day on Application : I just wanna know how to let users for **maximum two times a day** on my application. That means that the app will block the users if they are going to enter for a third time in a day.
| 0debug
|
How to install oracle-java8-installer on docker debian:jessie : <p>I am trying to install java 8 through oracle-java8-installer on a debian:jessie docker container. The following is my Dockerfile:</p>
<pre><code>FROM debian:jessie
ENV JAVA_VERSION 1.8.0
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" > /etc/apt/sources.list.d/webupd8team-java.list
RUN echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" >> /etc/apt/sources.list.d/webupd8team-java.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
RUN echo "debconf shared/accepted-oracle-license-v1-1 select true" | /usr/bin/debconf-set-selections
RUN apt-get update
RUN apt-get install -y --force-yes vim
RUN apt-get install -y --force-yes oracle-java8-installer
</code></pre>
<p>Yet this gives:</p>
<pre><code>Connecting to download.oracle.com (download.oracle.com)|23.63.224.171|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-01-17 12:31:05 ERROR 404: Not Found.
download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/sh -c apt-get install -y --force-yes oracle-java8-installer' returned a non-zero code: 100
</code></pre>
<p>I have found many similar issues described online, but none of the proposed solutions worked for me. Any idea?</p>
| 0debug
|
iterate over list of objects in jquery : i'm trying to some work around , i have to send ajax request to ajax and get array of objects in format of json, what i can't do is how to iterate over this list and add the data to html table :
jsp page :
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="jquery-3.2.1.min.js" type="text/javascript"></script>
</head>
<body>
<button id="but">click me </button>
<div id="test">
</div>
<script>
$(document).on("click", "#but", function () { // When HTML DOM "click" event is invoked on element with ID "somebutton", execute the following function...
$.get("testServlet", function (responseJson) { // Execute Ajax GET request on URL of "someservlet" and execute the following function with Ajax response JSON...
var $ul = $("<table>").appendTo($("#test")); // Create HTML <ul> element and append it to HTML DOM element with ID "somediv".
console.log(responseJson);
$.each(responseJson, function (index, item) { // Iterate over the JSON array.
$("<tr>").appendTo($ul)
.apeend($("<td>").text(item.id).appendTo($ul))// Create HTML <li> element, set its text content with currently iterated item and append it to the <ul>.
.apeend($("<td>").text(item.fname).appendTo($ul))
.apeend($("<td>").text(item.lname).appendTo($ul));
});
});
});
</script>
</body>
</html>
servlet.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
user u = new user(1, "john", "doe");
user u1 = new user(2, "foo", "foo");
user u2 = new user(3, "bar", "bar");
List<user> list = new ArrayList<>();
list.add(u);
list.add(u1);
list.add(u2);
String json = new Gson().toJson(list);
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(json);
}
the output is like that :
[![enter image description here][1]][1]
and the console shows that error ?
Uncaught TypeError: $(...).appendTo(...).apeend is not a function
at Object.<anonymous> (test2.jsp:23)
at Function.each (jquery-3.2.1.min.js:2)
at Object.success (test2.jsp:21)
at i (jquery-3.2.1.min.js:2)
at Object.fireWith [as resolveWith] (jquery-3.2.1.min.js:2)
at A (jquery-3.2.1.min.js:4)
at XMLHttpRequest.<anonymous> (jquery-3.2.1.min.js:4)
[1]: https://i.stack.imgur.com/vcYzE.png
| 0debug
|
Class inheritance Ruby :
Obviously my parameters for Getemploy.new make no sense, but I jsut did it randomly. That being said. Why is number being returned as an array?
I.e the output is `The employee number is : ["1", "2", "3", "4"] with id : 2 with phone 3 with adress: 4`
class Employee
def initialize(n,i,ph,ad)
@number = n, @id = i , @phone = ph, @adress =ad
end
def getInfo
return @number,@id,@phone,@ad
end
end
class Getemploy < Employee
def get_data
return "The employee number is : #{@number} with id : #{@id} with phone #{@phone} with adress: #{@adress}"
end
end
employ = Getemploy.new("1","2","3","4")
puts employ.get_data()
| 0debug
|
How to get click event on a new created row with Jquery : <p>I have a <code>table</code> :</p>
<pre><code><table id="myTable" style="cursor :pointer;">
<tr>
<td>col 1</td><td>col2</td>
</tr>
<tr>
<td>field</td><td>Field 2</td>
</tr>
<tr>
<td>another field</td><td>one more field</td>
</tr>
</table>
</code></pre>
<p>when I click on a <code>row</code> this code add a new <code>row</code> :</p>
<pre><code>$("#myTable tr").click(function(){
$(this).addClass('selected').siblings().removeClass('selected');
var value=$(this).find('td:eq(1)').html();
if (value) {
alert('adding New Row !')
$('#myTable').find('tbody:last').append('<tr><td>new Field</td><td>New Field</td></tr>');
}
});
</code></pre>
<p><a href="https://jsfiddle.net/s0h9mwms/" rel="nofollow noreferrer">JSFiddle Demo</a></p>
<p>But now when I click on the new created <code>row</code> nothing append.
Why another <code>row</code>is not created ?</p>
<p>Is there a way to do that ?</p>
| 0debug
|
How to display images in jsp file from css file, which are in different folders? : How to display images(present in assets/img/plus.png) in temp.jsp file (present in jsp folder) . Shown in image.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/4mkls.png
| 0debug
|
Guys, How can i make a TextBox as IsReadOnly="True" based on the item selected on the ComboBox? : I would be so greatful if you could help meee, thx!
HERE IS THE XAML
<ComboBox Margin="8" Name="cmbox" SelectionChanged="cmbox_SelectionChanged" >
<ComboBoxItem IsSelected="True">ESCALONADO</ComboBoxItem>
<ComboBoxItem>INTEGRAL</ComboBoxItem>
</ComboBox>
<TextBox IsReadOnly="{Binding Testcmb}" Grid.Column="1" Margin="8"/>
HERE IS A LITTLE BIT OF THE CODE BEHIND
I tried to attribute the value of the property Testcmb based on the selected item on the combobox, and then make the bindin to the textbox to turn it as a IsReadOnly="true". Is the sintax right?
private void cmbox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if(cmbox.SelectedIndex > 0)
{
(Object).Testcmb = true;
}
else
{
(Object).Testcmb = false;
}
}
private bool _testcmb;
public bool Testcmb
{
get { return _testcmb; }
set
{
if (this._testcmb != value)
{
this._testcmb = value;
this.NotifyPropertyChanged("Testcmb");
};
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propName));
}
}
| 0debug
|
int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode,
V9fsStatDotl *v9stat)
{
int err = 0;
V9fsState *s = pdu->s;
if (v9fs_request_cancelled(pdu)) {
return -EINTR;
if (s->ctx.exops.get_st_gen) {
v9fs_path_read_lock(s);
v9fs_co_run_in_worker(
{
err = s->ctx.exops.get_st_gen(&s->ctx, path, st_mode,
&v9stat->st_gen);
if (err < 0) {
err = -errno;
});
v9fs_path_unlock(s);
return err;
| 1threat
|
could not find gradle 3.0.0-alpha4 : <p>a few days ago i have installed android studio 3.0 (preview) and after that in stable version (studio 2.3.3) when i try to import project it give me an error.
In preview everything works fine.
this is an error:</p>
<pre><code>Error:Could not find com.android.tools.build:gradle:3.0.0-alpha4.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha4/gradle-3.0.0-alpha4.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha4/gradle-3.0.0-alpha4.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha4/gradle-3.0.0-alpha4.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha4/gradle-3.0.0-alpha4.jar
Required by:
project :
</code></pre>
| 0debug
|
static void mpeg1_encode_sequence_header(MpegEncContext *s)
{
unsigned int vbv_buffer_size;
unsigned int fps, v;
int i;
uint64_t time_code;
float best_aspect_error= 1E10;
float aspect_ratio= av_q2d(s->avctx->sample_aspect_ratio);
int constraint_parameter_flag;
if(aspect_ratio==0.0) aspect_ratio= 1.0;
if (s->current_picture.key_frame) {
AVRational framerate= frame_rate_tab[s->frame_rate_index];
put_header(s, SEQ_START_CODE);
put_bits(&s->pb, 12, s->width);
put_bits(&s->pb, 12, s->height);
for(i=1; i<15; i++){
float error= aspect_ratio;
if(s->codec_id == CODEC_ID_MPEG1VIDEO || i <=1)
error-= 1.0/mpeg1_aspect[i];
else
error-= av_q2d(mpeg2_aspect[i])*s->height/s->width;
error= ABS(error);
if(error < best_aspect_error){
best_aspect_error= error;
s->aspect_ratio_info= i;
}
}
put_bits(&s->pb, 4, s->aspect_ratio_info);
put_bits(&s->pb, 4, s->frame_rate_index);
if(s->avctx->rc_max_rate){
v = (s->avctx->rc_max_rate + 399) / 400;
if (v > 0x3ffff && s->codec_id == CODEC_ID_MPEG1VIDEO)
v = 0x3ffff;
}else{
v= 0x3FFFF;
}
if(s->avctx->rc_buffer_size)
vbv_buffer_size = s->avctx->rc_buffer_size;
else
vbv_buffer_size = (( 20 * s->bit_rate) / (1151929 / 2)) * 8 * 1024;
vbv_buffer_size= (vbv_buffer_size + 16383) / 16384;
put_bits(&s->pb, 18, v & 0x3FFFF);
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 10, vbv_buffer_size & 0x3FF);
constraint_parameter_flag=
s->width <= 768 && s->height <= 576 &&
s->mb_width * s->mb_height <= 396 &&
s->mb_width * s->mb_height * framerate.num <= framerate.den*396*25 &&
framerate.num <= framerate.den*30 &&
vbv_buffer_size <= 20 &&
v <= 1856000/400 &&
s->codec_id == CODEC_ID_MPEG1VIDEO;
put_bits(&s->pb, 1, constraint_parameter_flag);
ff_write_quant_matrix(&s->pb, s->avctx->intra_matrix);
ff_write_quant_matrix(&s->pb, s->avctx->inter_matrix);
if(s->codec_id == CODEC_ID_MPEG2VIDEO){
put_header(s, EXT_START_CODE);
put_bits(&s->pb, 4, 1);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 3, 4);
put_bits(&s->pb, 4, 8);
put_bits(&s->pb, 1, s->progressive_sequence);
put_bits(&s->pb, 2, 1);
put_bits(&s->pb, 2, 0);
put_bits(&s->pb, 2, 0);
put_bits(&s->pb, 12, v>>18);
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 8, vbv_buffer_size >>10);
put_bits(&s->pb, 1, s->low_delay);
put_bits(&s->pb, 2, 0);
put_bits(&s->pb, 5, 0);
}
put_header(s, GOP_START_CODE);
put_bits(&s->pb, 1, 0);
fps = (framerate.num + framerate.den/2)/ framerate.den;
time_code = s->current_picture_ptr->coded_picture_number;
s->gop_picture_number = time_code;
put_bits(&s->pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
put_bits(&s->pb, 6, (uint32_t)((time_code / (fps * 60)) % 60));
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 6, (uint32_t)((time_code / fps) % 60));
put_bits(&s->pb, 6, (uint32_t)((time_code % fps)));
put_bits(&s->pb, 1, !!(s->flags & CODEC_FLAG_CLOSED_GOP));
put_bits(&s->pb, 1, 0);
}
}
| 1threat
|
static int vmdk_create_extent(const char *filename, int64_t filesize,
bool flat, bool compress, bool zeroed_grain,
Error **errp)
{
int ret, i;
BlockDriverState *bs = NULL;
VMDK4Header header;
Error *local_err;
uint32_t tmp, magic, grains, gd_sectors, gt_size, gt_count;
uint32_t *gd_buf = NULL;
int gd_buf_size;
ret = bdrv_create_file(filename, NULL, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto exit;
}
ret = bdrv_file_open(&bs, filename, NULL, NULL, BDRV_O_RDWR, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto exit;
}
if (flat) {
ret = bdrv_truncate(bs, filesize);
if (ret < 0) {
error_setg(errp, "Could not truncate file");
}
goto exit;
}
magic = cpu_to_be32(VMDK4_MAGIC);
memset(&header, 0, sizeof(header));
header.version = zeroed_grain ? 2 : 1;
header.flags = VMDK4_FLAG_RGD | VMDK4_FLAG_NL_DETECT
| (compress ? VMDK4_FLAG_COMPRESS | VMDK4_FLAG_MARKER : 0)
| (zeroed_grain ? VMDK4_FLAG_ZERO_GRAIN : 0);
header.compressAlgorithm = compress ? VMDK4_COMPRESSION_DEFLATE : 0;
header.capacity = filesize / BDRV_SECTOR_SIZE;
header.granularity = 128;
header.num_gtes_per_gt = BDRV_SECTOR_SIZE;
grains = DIV_ROUND_UP(filesize / BDRV_SECTOR_SIZE, header.granularity);
gt_size = DIV_ROUND_UP(header.num_gtes_per_gt * sizeof(uint32_t),
BDRV_SECTOR_SIZE);
gt_count = DIV_ROUND_UP(grains, header.num_gtes_per_gt);
gd_sectors = DIV_ROUND_UP(gt_count * sizeof(uint32_t), BDRV_SECTOR_SIZE);
header.desc_offset = 1;
header.desc_size = 20;
header.rgd_offset = header.desc_offset + header.desc_size;
header.gd_offset = header.rgd_offset + gd_sectors + (gt_size * gt_count);
header.grain_offset =
ROUND_UP(header.gd_offset + gd_sectors + (gt_size * gt_count),
header.granularity);
header.version = cpu_to_le32(header.version);
header.flags = cpu_to_le32(header.flags);
header.capacity = cpu_to_le64(header.capacity);
header.granularity = cpu_to_le64(header.granularity);
header.num_gtes_per_gt = cpu_to_le32(header.num_gtes_per_gt);
header.desc_offset = cpu_to_le64(header.desc_offset);
header.desc_size = cpu_to_le64(header.desc_size);
header.rgd_offset = cpu_to_le64(header.rgd_offset);
header.gd_offset = cpu_to_le64(header.gd_offset);
header.grain_offset = cpu_to_le64(header.grain_offset);
header.compressAlgorithm = cpu_to_le16(header.compressAlgorithm);
header.check_bytes[0] = 0xa;
header.check_bytes[1] = 0x20;
header.check_bytes[2] = 0xd;
header.check_bytes[3] = 0xa;
ret = bdrv_pwrite(bs, 0, &magic, sizeof(magic));
if (ret < 0) {
error_set(errp, QERR_IO_ERROR);
goto exit;
}
ret = bdrv_pwrite(bs, sizeof(magic), &header, sizeof(header));
if (ret < 0) {
error_set(errp, QERR_IO_ERROR);
goto exit;
}
ret = bdrv_truncate(bs, le64_to_cpu(header.grain_offset) << 9);
if (ret < 0) {
error_setg(errp, "Could not truncate file");
goto exit;
}
gd_buf_size = gd_sectors * BDRV_SECTOR_SIZE;
gd_buf = g_malloc0(gd_buf_size);
for (i = 0, tmp = le64_to_cpu(header.rgd_offset) + gd_sectors;
i < gt_count; i++, tmp += gt_size) {
gd_buf[i] = cpu_to_le32(tmp);
}
ret = bdrv_pwrite(bs, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_SIZE,
gd_buf, gd_buf_size);
if (ret < 0) {
error_set(errp, QERR_IO_ERROR);
goto exit;
}
for (i = 0, tmp = le64_to_cpu(header.gd_offset) + gd_sectors;
i < gt_count; i++, tmp += gt_size) {
gd_buf[i] = cpu_to_le32(tmp);
}
ret = bdrv_pwrite(bs, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SIZE,
gd_buf, gd_buf_size);
if (ret < 0) {
error_set(errp, QERR_IO_ERROR);
goto exit;
}
ret = 0;
exit:
if (bs) {
bdrv_unref(bs);
}
g_free(gd_buf);
return ret;
}
| 1threat
|
Is it possible to pass data from fragment to fragment without touching activity in android : Present I am working on Fragments so i want know whether it is possible to pass data from fragment to fragment without touching Activity.
| 0debug
|
static void validate_teardown(TestInputVisitorData *data,
const void *unused)
{
qobject_decref(data->obj);
data->obj = NULL;
if (data->qiv) {
visit_free(data->qiv);
data->qiv = NULL;
}
}
| 1threat
|
Python & json search : {
"note":"This file contains the sample data for testing",
"comments":[
{
"name":"Romina",
"count":97
},
{
"name":"Laurie",
"count":97
},
{
"name":"Bayli",
"count":90
}
]
}
Hello everyone. This is my first question here. I need to sum the count values. how can i do this ???
| 0debug
|
static void core_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
cpu_register_physical_memory_log(section, section->readonly);
}
| 1threat
|
How do I compile code using Clang with the MinGW C/C++ Library? (Particular issue with float.h) : <p>I have a simple program which I can successfully compile with clang, using MinGW's C/C++ Library:</p>
<pre><code>#include <stdio.h>
int main(int argc, char **argv) { printf("Hello world!\n"); return 0; }
</code></pre>
<p>I am able to compile this with mingw-gcc successfully:</p>
<pre><code> $ gcc test.c -o test
$ ./test
Hello world!
</code></pre>
<p>I am also able to compile it successfully using clang+mingw:</p>
<pre><code> $ clang test.c -o test -target
$ ./test
Hello world!
</code></pre>
<p>However, if I make a small change to my program (include float.h), it continues to compile with gcc but no longer compiles with clang:</p>
<pre><code>#include <stdio.h>
#include <float.h>
int main(int argc, char **argv) { printf("Hello world!\n"); return 0; }
</code></pre>
<pre><code> $ gcc test.c -o test
$ ./test
Hello world!
$ clang test.c -o test -target x86_64-pc-windows-gnu
In file included from test.c:2:
In file included from C:\llvm\built\lib\clang\8.0.0\include\float.h:45:
C:\mingw64-8.1.0\x86_64-w64-mingw32\include\float.h:28:15: fatal error: 'float.h' file not found
#include_next <float.h>
^~~~~~~~~
1 error generated.
</code></pre>
<p>Is there some configuration issue with clang or some missing command line argument? Googling around a bit, it appears that the order of paths when including float.h is important, but this is all supposed to be handled internally by the clang driver. </p>
| 0debug
|
Local variable problem in python, variable is not defines : <p>I am working on a project and keep getting variable not defined errors when I run the script. How can I solve this without declaring global variables</p>
<pre><code>def func1():
x = 1
def func2():
y=5
x + y = z
print(z)
</code></pre>
| 0debug
|
static int get_packet(URLContext *s, int for_header)
{
RTMPContext *rt = s->priv_data;
int ret;
uint8_t *p;
const uint8_t *next;
uint32_t data_size;
uint32_t ts, cts, pts=0;
if (rt->state == STATE_STOPPED)
return AVERROR_EOF;
for (;;) {
RTMPPacket rpkt = { 0 };
if ((ret = ff_rtmp_packet_read(rt->stream, &rpkt,
rt->chunk_size, rt->prev_pkt[0])) <= 0) {
if (ret == 0) {
return AVERROR(EAGAIN);
} else {
return AVERROR(EIO);
}
}
rt->bytes_read += ret;
if (rt->bytes_read > rt->last_bytes_read + rt->client_report_size) {
av_log(s, AV_LOG_DEBUG, "Sending bytes read report\n");
gen_bytes_read(s, rt, rpkt.timestamp + 1);
rt->last_bytes_read = rt->bytes_read;
}
ret = rtmp_parse_result(s, rt, &rpkt);
if (ret < 0) {
ff_rtmp_packet_destroy(&rpkt);
return -1;
}
if (rt->state == STATE_STOPPED) {
ff_rtmp_packet_destroy(&rpkt);
return AVERROR_EOF;
}
if (for_header && (rt->state == STATE_PLAYING || rt->state == STATE_PUBLISHING)) {
ff_rtmp_packet_destroy(&rpkt);
return 0;
}
if (!rpkt.data_size || !rt->is_input) {
ff_rtmp_packet_destroy(&rpkt);
continue;
}
if (rpkt.type == RTMP_PT_VIDEO || rpkt.type == RTMP_PT_AUDIO ||
(rpkt.type == RTMP_PT_NOTIFY && !memcmp("\002\000\012onMetaData", rpkt.data, 13))) {
ts = rpkt.timestamp;
rt->flv_off = 0;
rt->flv_size = rpkt.data_size + 15;
rt->flv_data = p = av_realloc(rt->flv_data, rt->flv_size);
bytestream_put_byte(&p, rpkt.type);
bytestream_put_be24(&p, rpkt.data_size);
bytestream_put_be24(&p, ts);
bytestream_put_byte(&p, ts >> 24);
bytestream_put_be24(&p, 0);
bytestream_put_buffer(&p, rpkt.data, rpkt.data_size);
bytestream_put_be32(&p, 0);
ff_rtmp_packet_destroy(&rpkt);
return 0;
} else if (rpkt.type == RTMP_PT_METADATA) {
rt->flv_off = 0;
rt->flv_size = rpkt.data_size;
rt->flv_data = av_realloc(rt->flv_data, rt->flv_size);
next = rpkt.data;
ts = rpkt.timestamp;
while (next - rpkt.data < rpkt.data_size - 11) {
next++;
data_size = bytestream_get_be24(&next);
p=next;
cts = bytestream_get_be24(&next);
cts |= bytestream_get_byte(&next) << 24;
if (pts==0)
pts=cts;
ts += cts - pts;
pts = cts;
bytestream_put_be24(&p, ts);
bytestream_put_byte(&p, ts >> 24);
next += data_size + 3 + 4;
}
memcpy(rt->flv_data, rpkt.data, rpkt.data_size);
ff_rtmp_packet_destroy(&rpkt);
return 0;
}
ff_rtmp_packet_destroy(&rpkt);
}
}
| 1threat
|
Regex to extract time information from a string : <p>I'm receiving data from a third party device. I need to extract two pieces of information. I think I need to use a Regular Expression, but I don't know anything of this.</p>
<p>Below you can find a few example strings:</p>
<pre><code>TN 12 1 17:45:19.90400 7173
TN 4 4 17:45:20.51800 7173
TN 13 1 17:45:24.03200 7173
TN 5 4 17:45:26.06300 7173
TN 6 4 17:45:29.28700 7173
TN 14 1 17:45:31.03200 7173
</code></pre>
<p>From each of these strings I need to extract two pieces of data:</p>
<ul>
<li>the time</li>
<li>the number before the time</li>
</ul>
<p>So the data I'm looking for is this:</p>
<pre><code>1 and 17:45:19.90400
4 and 17:45:20.51800
1 and 17:45:24.03200
4 and 17:45:26.06300
4 and 17:45:29.28700
1 and 17:45:31.03200
</code></pre>
<p>The number will always be present and it will always be 1, 2, 3 or 4.
The time will also be the same format but I'm not sure if there will be single digit hours. So I don't know if 9 o'clock will be displayed as </p>
<blockquote>
<p>9 or 09</p>
</blockquote>
<p>Any suggestions on how I can extract this using a RegEx?</p>
<p>Thanks</p>
| 0debug
|
reader.HasRows Returns FALSE Every Time : <p>I'm new with C# and I'm writing a desktop application to read an MS-Access Invoice table so I can perform further processing on it. But I can't get my "reader.HasRows" statement to return rows from my SELECT statement even though there are rows in the table. Every time I run the application I get the "No Invoice records found" MessageBox displayed.</p>
<p>I have researched and read several other posts on this forum of similar problems, but none seem to address my particular issue. I've also searched the Internet for a solution with no results. Can someone help me spot what I'm doing wrong?</p>
<pre><code> private void AddContactsAcconutNumberToInvoices()
{
//Use a variable to hold the SQL statement.
string inputString = "SELECT Invoices.[Job_Name], * FROM Invoices " +
"WHERE Invoices.[Account_Number] = Null";
try
{
//Create an OleDbCommand object and pass in the SQL statement and OleDbConnection object
OleDbCommand cmd = new OleDbCommand(inputString, conn);
//Send the CommandText to the connection, and then build an OleDbDataReader.
OleDbDataReader reader = cmd.ExecuteReader();
// Read through the database and test the integrity of the data
if (reader.HasRows)
{
while (reader.Read())
{
var jobname = reader.GetString(0);
var contactsQuery = "SELECT Account_Number FROM CONTACTS WHERE Contacts.Full_Name = " + jobname;
MessageBox.Show("Contacts query contatins: " + contactsQuery);
}
}
else { MessageBox.Show("No Invoice records found"); }
}
catch (Exception ex)
{
error_message = ex.Message;
MessageBox.Show(error_message);
}
}
</code></pre>
| 0debug
|
Long time waiting Request to Service Worker : <p>I have noticed that the time waiting for service workers to respond with items from the cache is not as fast as you would expect it to be. I have seen the same wait times with both <code>sw-precache</code> and a custom written service worker.</p>
<p><a href="https://i.stack.imgur.com/9cBsR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9cBsR.png" alt="Request to ServiceWorker"></a></p>
<p>What are the possible causes for this wait time time and how could I reduce it?</p>
<p>My <code>fetch</code> event on the custom service worker looks like:</p>
<pre><code>self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(response) {
if (response) {
return response;
}
return fetch(event.request);
})
);
});
</code></pre>
| 0debug
|
UI state restoration for a scene in iOS 13 while still supporting iOS 12. No storyboards : <p><em>This is a little long but it's not trivial and it takes a lot to demonstrate this issue.</em></p>
<p>I'm trying to figure out how to update a little sample app from iOS 12 to iOS 13. This sample app doesn't use any storyboards (other than the launch screen). It's a simple app that shows one view controller with a label that is updated by a timer. It uses state restoration so the counter starts from where it left off. I want to be able to support iOS 12 and iOS 13. In iOS 13 I want to update to the new scene architecture.</p>
<p>Under iOS 12 the app works just fine. On a fresh install the counter starts at 0 and goes up. Put the app in the background and then restart the app and the counter continues from where it left off. The state restoration all works.</p>
<p>Now I'm trying to get that working under iOS 13 using a scene. The problem I'm having is figuring out the correct way to initialize the scene's window and restore the navigation controller and the main view controller to the scene.</p>
<p>I've been through as much of the Apple documentation as I can find related to state restoration and scenes. I've watched WWDC videos related to windows and scenes (<a href="https://developer.apple.com/videos/play/wwdc2019/258/" rel="noreferrer">212 - Introducing Multiple Windows on iPad</a>, <a href="https://developer.apple.com/videos/play/wwdc2019/258/" rel="noreferrer">258 - Architecting Your App for Multiple Windows</a>). But I seem to be missing a piece that puts it all together.</p>
<p>When I run the app under iOS 13, all of the expected delegate methods (both AppDelegate and SceneDelegate) are being called. The state restoration is restoring the nav controller and the main view controller but I can't figure out how to set the <code>rootViewController</code> of the scene's window since all of the UI state restoration is in the AppDelegate.</p>
<p>There also seems to be something related to an <code>NSUserTask</code> that should be used but I can't connect the dots.</p>
<p><strong>The missing pieces seem to be in the <code>willConnectTo</code> method of <code>SceneDelegate</code>. I'm sure I also need some changes in <code>stateRestorationActivity</code> of <code>SceneDelegate</code>. There may also need to be changes in the <code>AppDelegate</code>. I doubt anything in <code>ViewController</code> needs to be changed.</strong></p>
<hr>
<p>To replicate what I'm doing, create a new iOS project with Xcode 11 (beta 4 at the moment) using the Single View App template. Set the Deployment Target to iOS 11 or 12.</p>
<p>Delete the main storyboard. Remove the two references in the Info.plist to Main (one at the top level and one deep inside the Application Scene Manifest. Update the 3 swift files as follows.</p>
<p>AppDelegate.swift:</p>
<pre class="lang-swift prettyprint-override"><code>import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
print("AppDelegate willFinishLaunchingWithOptions")
// This probably shouldn't be run under iOS 13?
self.window = UIWindow(frame: UIScreen.main.bounds)
return true
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
print("AppDelegate didFinishLaunchingWithOptions")
if #available(iOS 13.0, *) {
// What needs to be here?
} else {
// If the root view controller wasn't restored, create a new one from scratch
if (self.window?.rootViewController == nil) {
let vc = ViewController()
let nc = UINavigationController(rootViewController: vc)
nc.restorationIdentifier = "RootNC"
self.window?.rootViewController = nc
}
self.window?.makeKeyAndVisible()
}
return true
}
func application(_ application: UIApplication, viewControllerWithRestorationIdentifierPath identifierComponents: [String], coder: NSCoder) -> UIViewController? {
print("AppDelegate viewControllerWithRestorationIdentifierPath")
// If this is for the nav controller, restore it and set it as the window's root
if identifierComponents.first == "RootNC" {
let nc = UINavigationController()
nc.restorationIdentifier = "RootNC"
self.window?.rootViewController = nc
return nc
}
return nil
}
func application(_ application: UIApplication, willEncodeRestorableStateWith coder: NSCoder) {
print("AppDelegate willEncodeRestorableStateWith")
// Trigger saving of the root view controller
coder.encode(self.window?.rootViewController, forKey: "root")
}
func application(_ application: UIApplication, didDecodeRestorableStateWith coder: NSCoder) {
print("AppDelegate didDecodeRestorableStateWith")
}
func application(_ application: UIApplication, shouldSaveApplicationState coder: NSCoder) -> Bool {
print("AppDelegate shouldSaveApplicationState")
return true
}
func application(_ application: UIApplication, shouldRestoreApplicationState coder: NSCoder) -> Bool {
print("AppDelegate shouldRestoreApplicationState")
return true
}
// The following four are not called in iOS 13
func applicationWillEnterForeground(_ application: UIApplication) {
print("AppDelegate applicationWillEnterForeground")
}
func applicationDidEnterBackground(_ application: UIApplication) {
print("AppDelegate applicationDidEnterBackground")
}
func applicationDidBecomeActive(_ application: UIApplication) {
print("AppDelegate applicationDidBecomeActive")
}
func applicationWillResignActive(_ application: UIApplication) {
print("AppDelegate applicationWillResignActive")
}
// MARK: UISceneSession Lifecycle
@available(iOS 13.0, *)
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
print("AppDelegate configurationForConnecting")
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
@available(iOS 13.0, *)
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
print("AppDelegate didDiscardSceneSessions")
}
}
</code></pre>
<p>SceneDelegate.swift:</p>
<pre class="lang-swift prettyprint-override"><code>import UIKit
@available(iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
print("SceneDelegate willConnectTo")
guard let winScene = (scene as? UIWindowScene) else { return }
// Got some of this from WWDC2109 video 258
window = UIWindow(windowScene: winScene)
if let activity = connectionOptions.userActivities.first ?? session.stateRestorationActivity {
// Now what? How to connect the UI restored in the AppDelegate to this window?
} else {
// Create the initial UI if there is nothing to restore
let vc = ViewController()
let nc = UINavigationController(rootViewController: vc)
nc.restorationIdentifier = "RootNC"
self.window?.rootViewController = nc
window?.makeKeyAndVisible()
}
}
func stateRestorationActivity(for scene: UIScene) -> NSUserActivity? {
print("SceneDelegate stateRestorationActivity")
// What should be done here?
let activity = NSUserActivity(activityType: "What?")
activity.persistentIdentifier = "huh?"
return activity
}
func scene(_ scene: UIScene, didUpdate userActivity: NSUserActivity) {
print("SceneDelegate didUpdate")
}
func sceneDidDisconnect(_ scene: UIScene) {
print("SceneDelegate sceneDidDisconnect")
}
func sceneDidBecomeActive(_ scene: UIScene) {
print("SceneDelegate sceneDidBecomeActive")
}
func sceneWillResignActive(_ scene: UIScene) {
print("SceneDelegate sceneWillResignActive")
}
func sceneWillEnterForeground(_ scene: UIScene) {
print("SceneDelegate sceneWillEnterForeground")
}
func sceneDidEnterBackground(_ scene: UIScene) {
print("SceneDelegate sceneDidEnterBackground")
}
}
</code></pre>
<p>ViewController.swift:</p>
<pre class="lang-swift prettyprint-override"><code>import UIKit
class ViewController: UIViewController, UIViewControllerRestoration {
var label: UILabel!
var count: Int = 0
var timer: Timer?
static func viewController(withRestorationIdentifierPath identifierComponents: [String], coder: NSCoder) -> UIViewController? {
print("ViewController withRestorationIdentifierPath")
return ViewController()
}
override init(nibName nibNameOrNil: String? = nil, bundle nibBundleOrNil: Bundle? = nil) {
print("ViewController init")
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
restorationIdentifier = "ViewController"
restorationClass = ViewController.self
}
required init?(coder: NSCoder) {
print("ViewController init(coder)")
super.init(coder: coder)
}
override func viewDidLoad() {
print("ViewController viewDidLoad")
super.viewDidLoad()
view.backgroundColor = .green // be sure this vc is visible
label = UILabel(frame: .zero)
label.translatesAutoresizingMaskIntoConstraints = false
label.text = "\(count)"
view.addSubview(label)
NSLayoutConstraint.activate([
label.centerXAnchor.constraint(equalTo: view.centerXAnchor),
label.centerYAnchor.constraint(equalTo: view.centerYAnchor),
])
}
override func viewWillAppear(_ animated: Bool) {
print("ViewController viewWillAppear")
super.viewWillAppear(animated)
timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { (timer) in
self.count += 1
self.label.text = "\(self.count)"
})
}
override func viewDidDisappear(_ animated: Bool) {
print("ViewController viewDidDisappear")
super.viewDidDisappear(animated)
timer?.invalidate()
timer = nil
}
override func encodeRestorableState(with coder: NSCoder) {
print("ViewController encodeRestorableState")
super.encodeRestorableState(with: coder)
coder.encode(count, forKey: "count")
}
override func decodeRestorableState(with coder: NSCoder) {
print("ViewController decodeRestorableState")
super.decodeRestorableState(with: coder)
count = coder.decodeInteger(forKey: "count")
label.text = "\(count)"
}
}
</code></pre>
<p>Run this under iOS 11 or 12 and it works just fine.</p>
<p>You can run this under iOS 13 and on a fresh install of the app you get the UI. But any subsequent run of the app gives a black screen because the UI restored via state restoration isn't connected to the scene's window.</p>
<p>What am I missing? Is this just missing a line or two of code or is my entire approach to iOS 13 scene state restoration wrong?</p>
<p>Keep in mind that once I get this figured out the next step will be supporting multiple windows. So the solution should work for multiple scenes, not just one.</p>
| 0debug
|
Linq for nested loop : <p>I have a loop as follows:</p>
<pre><code>foreach(x in myColl)
{
foreach(var y in x.MyList)
{
result.Add(x.MyKey + y)
}
}
</code></pre>
<p>That means within my inner loop I need access to a property of the current outer element. </p>
<p>I´m looking for a LINQ-statement but I´m unsure on it. I tried it by using </p>
<pre><code>result = myColl
.SelectMany(x => x.MyList)
.SelectMany(x => /* how to get the key of the outer loop here */ + x)
</code></pre>
| 0debug
|
NEED SQL QUERY FOR DESIRED OUTPUT : <p>Below is the sample data which gets filled into sql server database from PLC machine. DATETIME, CYCLETIME(TIME TAKEN TO PRODUCE THAT MATERIAL) AND SHIFT</p>
<p><a href="https://i.stack.imgur.com/T1UMw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T1UMw.png" alt="enter image description here"></a></p>
<p>There are 3 shifts in company A(6:30Am to 2:30PM), B(2:30 to 10:30), C(10:30 to 6:30AM).Only C shift sample data is shown above </p>
<p>when i take C Shift count, my query should take next day data also till 6:30AM time. Where as A shift should take current day data starting from 6:30Am to 2:30Pm.Where as B shift should take current day data starting from 2:31pm to 10:30PM.</p>
<p>QUANITY shown below IS COUNT OF ROWS in each shift.</p>
<p>DESIRED OUTPUT 1: SHIFTWISE DATA
<a href="https://i.stack.imgur.com/dMRDL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dMRDL.png" alt="enter image description here"></a></p>
<p>DESIRED OUTPUT 2: DAYWISE DATA
<a href="https://i.stack.imgur.com/twvxf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/twvxf.png" alt="enter image description here"></a></p>
| 0debug
|
void qemu_chr_printf(CharDriverState *s, const char *fmt, ...)
{
char buf[4096];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
qemu_chr_write(s, (uint8_t *)buf, strlen(buf));
va_end(ap);
}
| 1threat
|
Notify all group members of failed pipelines in GitLab : <p>The Goal is to have everyone get a notification for every failed pipeline (at their discretion). Currently any of us can run a pipeline on this project branch, and the creator of the pipeline gets an email, no one else does. I have tried setting the notification level to <code>watch</code> and <code>custom (with failed pipelines checked)</code> at project, group and global levels without success. The help page regarding <a href="https://docs.gitlab.com/ee/workflow/notifications.html" rel="noreferrer">notifications</a> says the failed pipeline checkbox for custom notification levels notifies the author of the pipeline (which is the behavior I am experiencing). Is there any way to allow multiple people to get notified of a failed pipeline? </p>
<ul>
<li>Using Gitlab CE v10.0</li>
<li>Have Group (security::internal)</li>
<li>Group has Project (security::internal)</li>
<li>Project has scheduled pipleine (runs nighly)</li>
<li>Pipeline runs integration tests (purposely failing)</li>
<li>Schedule created by me (schedules have to have an owner) </li>
<li>When the automated pipeline runs and fails I get an email(Good)</li>
<li>No one else gets email(bad) </li>
</ul>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.