problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Question from SQL exam that I find hard to answer : <p>I had an exam from relational databases.
I had a question (translated from Polish) which I cannot find any clues to answer:
"What are the problems (three of them) of data deletion in presence of foreign key?
What solutions are available?"
RD are my achilles' heel :(</p>
| 0debug |
Regex to find words starting with Capital Letters but not the ones that are at the beginning of sentence : I've managed to find the words beginning with Capital Letters but can't figure out a regex to filter out the ones starting at the beginning of the sentence. Also each of the sentence ends with a full stop and a space.
String : This is a Test sentence. The sentence is Supposed to Ignore the Words at the beginning of the Sentence.
Capital Words : 'This', 'Test', 'The', 'Supposed', 'Ignore', 'Words', 'Sentence'
Desired Output : 'Test', 'Supposed', 'Ignore', 'Words', 'Sentence'
Btw I'm Coding in Python.
Will be glad if someone can help me out with the regex :) | 0debug |
Java error i have done everything correct and i m unable to identify mistake. : This is a java code, i have created 4 classes 3 constructor and i am getting error of method area in class Rect cannot be applied to given types; similar error for rest of 2 class aswell. in this program basically i ahve created 4 classes 1 for calculating area of rect 1 for 1 for calculating area of Tri and 1 for calculating area of Square and last one is to acess main function. i have created 3 constructor for all the 3 classes rect tri and square and i am unable to spot the mistake in this program so please help me out with this.
class Rect //1st class rect
{
double l,b; //variables
Rect(double l, double b) //constructor for rect
{
this.l=l;
this.b=b;
}
double area(double l,double b) //method to cal Rect area
{
return l*b;
}
}
class Square //square class
{
double s;
Square(Double s) //constructor for class
{
this.s=s;
}
double area(double s) //method to cal area for square
{
return s*s;
}
}
class Tri // class for triangle
{
double l,b,h; //variables
Tri(double l,double b,double h) // constructor for tri
{
this.l=l;
this.h=h;
this.b=b;
}
double area(double l,double b,double h) //method to cal area for tri
{
return 0.5*l*b*h;
}
}
class Area3
{
public static void main(String args[])
{
Rect r=new Rect(10, 10); //constructor initialization for Rect
Square s=new Square(15.0);//constructor initialization for Square
Tri t=new Tri(10.0,20.0,30.0);//constructor initialization for Tri
System.out.print(" "+r.area()+""+s.area+""+t.area); //print areas
}
} | 0debug |
How to create a SearchResponce in java elastic api, with aggregations and sort? : <p>How to create a SearchResponce in java elastic api, with aggregations? So that it looks like a request to elastic?
Example:</p>
<pre><code>{
"_source":"username",
"size":0,
"aggs":{
"users":{
"terms":{
"field":"username.keyword",
"order": {
"sum":"desc"
}
},
"aggs": {
"sum": {
"sum": {
"field":"fileSize"
}
}
}
},
"total": {
"cardinality": {
"field":"username.keyword"
}
}
}
}
</code></pre>
| 0debug |
Python. Threading : <p>Hi I have a Server/client model using SocketServer module. The server job is to receive test name from the clients and launch the test.
the test is launched using subprocess module.
I would like the server to keep answering clients and any new jobs to be stacked on a list or queue and launch one after the other, the only restriction I have is the server should not launch the test unless currently running one is completed.</p>
<p>Thanks</p>
| 0debug |
static void add_pc_test_cases(void)
{
QDict *response, *minfo;
QList *list;
const QListEntry *p;
QObject *qobj;
QString *qstr;
const char *mname, *path;
PCTestData *data;
qtest_start("-machine none");
response = qmp("{ 'execute': 'query-machines' }");
g_assert(response);
list = qdict_get_qlist(response, "return");
g_assert(list);
for (p = qlist_first(list); p; p = qlist_next(p)) {
minfo = qobject_to_qdict(qlist_entry_obj(p));
g_assert(minfo);
qobj = qdict_get(minfo, "name");
g_assert(qobj);
qstr = qobject_to_qstring(qobj);
g_assert(qstr);
mname = qstring_get_str(qstr);
if (!g_str_has_prefix(mname, "pc-")) {
continue;
}
data = g_malloc(sizeof(PCTestData));
data->machine = mname;
data->cpu_model = "Haswell";
data->sockets = 1;
data->cores = 3;
data->threads = 2;
data->maxcpus = data->sockets * data->cores * data->threads * 2;
if (g_str_has_suffix(mname, "-1.4") ||
(strcmp(mname, "pc-1.3") == 0) ||
(strcmp(mname, "pc-1.2") == 0) ||
(strcmp(mname, "pc-1.1") == 0) ||
(strcmp(mname, "pc-1.0") == 0) ||
(strcmp(mname, "pc-0.15") == 0) ||
(strcmp(mname, "pc-0.14") == 0) ||
(strcmp(mname, "pc-0.13") == 0) ||
(strcmp(mname, "pc-0.12") == 0) ||
(strcmp(mname, "pc-0.11") == 0) ||
(strcmp(mname, "pc-0.10") == 0)) {
path = g_strdup_printf("cpu/%s/init/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
data->threads, data->maxcpus);
qtest_add_data_func(path, data, test_pc_without_cpu_add);
} else {
path = g_strdup_printf("cpu/%s/add/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
data->threads, data->maxcpus);
qtest_add_data_func(path, data, test_pc_with_cpu_add);
}
}
qtest_end();
}
| 1threat |
Specify requirement for a REST server : I am writing the requirements of a REST web-sever that needs to be implemented. One of the non-functional requirements is that each function (component) of the system can be activated or deactivated independent ob the other ones.
To make it more clear, the web server offer different services, the services provider should be able to deactivate one of the offered services at any time without affecting the other ones.
Is there a word describing this specification that could be wrote in the requirements and make a developer understand the needs ? | 0debug |
static TRBCCode xhci_reset_ep(XHCIState *xhci, unsigned int slotid,
unsigned int epid)
{
XHCISlot *slot;
XHCIEPContext *epctx;
USBDevice *dev;
trace_usb_xhci_ep_reset(slotid, epid);
assert(slotid >= 1 && slotid <= xhci->numslots);
if (epid < 1 || epid > 31) {
fprintf(stderr, "xhci: bad ep %d\n", epid);
return CC_TRB_ERROR;
}
slot = &xhci->slots[slotid-1];
if (!slot->eps[epid-1]) {
DPRINTF("xhci: slot %d ep %d not enabled\n", slotid, epid);
return CC_EP_NOT_ENABLED_ERROR;
}
epctx = slot->eps[epid-1];
if (epctx->state != EP_HALTED) {
fprintf(stderr, "xhci: reset EP while EP %d not halted (%d)\n",
epid, epctx->state);
return CC_CONTEXT_STATE_ERROR;
}
if (xhci_ep_nuke_xfers(xhci, slotid, epid) > 0) {
fprintf(stderr, "xhci: FIXME: endpoint reset w/ xfers running, "
"data might be lost\n");
}
uint8_t ep = epid>>1;
if (epid & 1) {
ep |= 0x80;
}
dev = xhci->slots[slotid-1].uport->dev;
if (!dev) {
return CC_USB_TRANSACTION_ERROR;
}
xhci_set_ep_state(xhci, epctx, NULL, EP_STOPPED);
if (epctx->nr_pstreams) {
xhci_reset_streams(epctx);
}
return CC_SUCCESS;
}
| 1threat |
static void exynos4210_ltick_recalc_count(struct tick_timer *s)
{
uint64_t to_count;
if ((s->cnt_run && s->last_tcnto) || (s->int_run && s->last_icnto)) {
if (s->last_tcnto) {
to_count = s->last_tcnto * s->last_icnto;
} else {
to_count = s->last_icnto;
}
} else {
if (s->icntb) {
s->distance = s->tcntb * s->icntb;
} else {
s->distance = s->tcntb;
}
to_count = s->distance;
s->progress = 0;
}
if (to_count > MCT_LT_COUNTER_STEP) {
s->count = MCT_LT_COUNTER_STEP;
} else {
s->count = to_count;
}
}
| 1threat |
static int check(AVIOContext *pb, int64_t pos, uint32_t *ret_header)
{
int64_t ret = avio_seek(pb, pos, SEEK_SET);
unsigned header;
MPADecodeHeader sd;
if (ret < 0)
return ret;
header = avio_rb32(pb);
if (ff_mpa_check_header(header) < 0)
return -1;
if (avpriv_mpegaudio_decode_header(&sd, header) == 1)
return -1;
if (ret_header)
*ret_header = header;
return sd.frame_size;
}
| 1threat |
How to develope prolog parser for pl code? : I am new in prolog i have a code that i want to read from file then parse this is perl code here
var x;
x <- (5 * 2);
return (x + 1).
now in prolog i want to tokenize this like this first
[βvarβ, βxβ, β;β, βxβ,β<-β, β(β, 5, β*β, 2, β)β, β;β, βreturnβ, β(β, βxβ, β+β, 1, β)β, β.β]
the i want to implement predicate
parse(+TokenList, -AST)
then again
evaluate(+AST, -Number)
using **SWIProlog**
The parser should not allow the keywords of the language (e.g., the arithmetic operators, <-,
var, return) as variable identifiers | 0debug |
int MPV_encode_init(AVCodecContext *avctx)
{
MpegEncContext *s = avctx->priv_data;
int i, dummy;
int chroma_h_shift, chroma_v_shift;
avctx->pix_fmt = PIX_FMT_YUV420P;
s->bit_rate = avctx->bit_rate;
s->width = avctx->width;
s->height = avctx->height;
if(avctx->gop_size > 600){
av_log(avctx, AV_LOG_ERROR, "Warning keyframe interval too large! reducing it ...\n");
avctx->gop_size=600;
}
s->gop_size = avctx->gop_size;
s->avctx = avctx;
s->flags= avctx->flags;
s->flags2= avctx->flags2;
s->max_b_frames= avctx->max_b_frames;
s->codec_id= avctx->codec->id;
s->luma_elim_threshold = avctx->luma_elim_threshold;
s->chroma_elim_threshold= avctx->chroma_elim_threshold;
s->strict_std_compliance= avctx->strict_std_compliance;
s->data_partitioning= avctx->flags & CODEC_FLAG_PART;
s->quarter_sample= (avctx->flags & CODEC_FLAG_QPEL)!=0;
s->mpeg_quant= avctx->mpeg_quant;
s->rtp_mode= !!avctx->rtp_payload_size;
if (s->gop_size <= 1) {
s->intra_only = 1;
s->gop_size = 12;
} else {
s->intra_only = 0;
}
s->me_method = avctx->me_method;
s->fixed_qscale = !!(avctx->flags & CODEC_FLAG_QSCALE);
s->adaptive_quant= ( s->avctx->lumi_masking
|| s->avctx->dark_masking
|| s->avctx->temporal_cplx_masking
|| s->avctx->spatial_cplx_masking
|| s->avctx->p_masking
|| (s->flags&CODEC_FLAG_QP_RD))
&& !s->fixed_qscale;
s->obmc= !!(s->flags & CODEC_FLAG_OBMC);
s->loop_filter= !!(s->flags & CODEC_FLAG_LOOP_FILTER);
s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN);
if(avctx->rc_max_rate && !avctx->rc_buffer_size){
av_log(avctx, AV_LOG_ERROR, "a vbv buffer size is needed, for encoding with a maximum bitrate\n");
return -1;
}
if(avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate){
av_log(avctx, AV_LOG_INFO, "Warning min_rate > 0 but min_rate != max_rate isnt recommanded!\n");
}
if((s->flags & CODEC_FLAG_4MV) && s->codec_id != CODEC_ID_MPEG4
&& s->codec_id != CODEC_ID_H263 && s->codec_id != CODEC_ID_H263P){
av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n");
return -1;
}
if(s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE){
av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with simple mb decission\n");
return -1;
}
if(s->obmc && s->codec_id != CODEC_ID_H263 && s->codec_id != CODEC_ID_H263P){
av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with H263(+)\n");
return -1;
}
if(s->quarter_sample && s->codec_id != CODEC_ID_MPEG4){
av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n");
return -1;
}
if(s->data_partitioning && s->codec_id != CODEC_ID_MPEG4){
av_log(avctx, AV_LOG_ERROR, "data partitioning not supported by codec\n");
return -1;
}
if(s->max_b_frames && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO){
av_log(avctx, AV_LOG_ERROR, "b frames not supported by codec\n");
return -1;
}
if(s->mpeg_quant && s->codec_id != CODEC_ID_MPEG4){
av_log(avctx, AV_LOG_ERROR, "mpeg2 style quantization not supporetd by codec\n");
return -1;
}
if((s->flags & CODEC_FLAG_CBP_RD) && !(s->flags & CODEC_FLAG_TRELLIS_QUANT)){
av_log(avctx, AV_LOG_ERROR, "CBP RD needs trellis quant\n");
return -1;
}
if((s->flags & CODEC_FLAG_QP_RD) && s->avctx->mb_decision != FF_MB_DECISION_RD){
av_log(avctx, AV_LOG_ERROR, "QP RD needs mbd=2\n");
return -1;
}
if(s->avctx->scenechange_threshold < 1000000000 && (s->flags & CODEC_FLAG_CLOSED_GOP)){
av_log(avctx, AV_LOG_ERROR, "closed gop with scene change detection arent supported yet\n");
return -1;
}
i= ff_gcd(avctx->frame_rate, avctx->frame_rate_base);
if(i > 1){
av_log(avctx, AV_LOG_INFO, "removing common factors from framerate\n");
avctx->frame_rate /= i;
avctx->frame_rate_base /= i;
}
if(s->codec_id==CODEC_ID_MJPEG){
s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1);
s->inter_quant_bias= 0;
}else if(s->mpeg_quant || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO){
s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3);
s->inter_quant_bias= 0;
}else{
s->intra_quant_bias=0;
s->inter_quant_bias=-(1<<(QUANT_BIAS_SHIFT-2));
}
if(avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS)
s->intra_quant_bias= avctx->intra_quant_bias;
if(avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS)
s->inter_quant_bias= avctx->inter_quant_bias;
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);
av_reduce(&s->time_increment_resolution, &dummy, s->avctx->frame_rate, s->avctx->frame_rate_base, (1<<16)-1);
s->time_increment_bits = av_log2(s->time_increment_resolution - 1) + 1;
switch(avctx->codec->id) {
case CODEC_ID_MPEG1VIDEO:
s->out_format = FMT_MPEG1;
s->low_delay= 0;
avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
break;
case CODEC_ID_MPEG2VIDEO:
s->out_format = FMT_MPEG1;
s->low_delay= 0;
avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
s->rtp_mode= 1;
break;
case CODEC_ID_LJPEG:
case CODEC_ID_MJPEG:
s->out_format = FMT_MJPEG;
s->intra_only = 1;
s->mjpeg_write_tables = 1;
s->mjpeg_data_only_frames = 0;
s->mjpeg_vsample[0] = 1<<chroma_v_shift;
s->mjpeg_vsample[1] = 1;
s->mjpeg_vsample[2] = 1;
s->mjpeg_hsample[0] = 1<<chroma_h_shift;
s->mjpeg_hsample[1] = 1;
s->mjpeg_hsample[2] = 1;
if (mjpeg_init(s) < 0)
return -1;
avctx->delay=0;
s->low_delay=1;
break;
#ifdef CONFIG_RISKY
case CODEC_ID_H263:
if (h263_get_picture_format(s->width, s->height) == 7) {
av_log(avctx, AV_LOG_INFO, "Input picture size isn't suitable for h263 codec! try h263+\n");
return -1;
}
s->out_format = FMT_H263;
s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
avctx->delay=0;
s->low_delay=1;
break;
case CODEC_ID_H263P:
s->out_format = FMT_H263;
s->h263_plus = 1;
s->umvplus = (avctx->flags & CODEC_FLAG_H263P_UMV) ? 1:0;
s->h263_aic= (avctx->flags & CODEC_FLAG_H263P_AIC) ? 1:0;
s->modified_quant= s->h263_aic;
s->alt_inter_vlc= (avctx->flags & CODEC_FLAG_H263P_AIV) ? 1:0;
s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
s->loop_filter= (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1:0;
s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus;
s->h263_slice_structured= (s->flags & CODEC_FLAG_H263P_SLICE_STRUCT) ? 1:0;
avctx->delay=0;
s->low_delay=1;
break;
case CODEC_ID_FLV1:
s->out_format = FMT_H263;
s->h263_flv = 2;
s->unrestricted_mv = 1;
s->rtp_mode=0;
avctx->delay=0;
s->low_delay=1;
break;
case CODEC_ID_RV10:
s->out_format = FMT_H263;
avctx->delay=0;
s->low_delay=1;
break;
case CODEC_ID_MPEG4:
s->out_format = FMT_H263;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->low_delay= s->max_b_frames ? 0 : 1;
avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
break;
case CODEC_ID_MSMPEG4V1:
s->out_format = FMT_H263;
s->h263_msmpeg4 = 1;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version= 1;
avctx->delay=0;
s->low_delay=1;
break;
case CODEC_ID_MSMPEG4V2:
s->out_format = FMT_H263;
s->h263_msmpeg4 = 1;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version= 2;
avctx->delay=0;
s->low_delay=1;
break;
case CODEC_ID_MSMPEG4V3:
s->out_format = FMT_H263;
s->h263_msmpeg4 = 1;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version= 3;
s->flipflop_rounding=1;
avctx->delay=0;
s->low_delay=1;
break;
case CODEC_ID_WMV1:
s->out_format = FMT_H263;
s->h263_msmpeg4 = 1;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version= 4;
s->flipflop_rounding=1;
avctx->delay=0;
s->low_delay=1;
break;
case CODEC_ID_WMV2:
s->out_format = FMT_H263;
s->h263_msmpeg4 = 1;
s->h263_pred = 1;
s->unrestricted_mv = 1;
s->msmpeg4_version= 5;
s->flipflop_rounding=1;
avctx->delay=0;
s->low_delay=1;
break;
#endif
default:
return -1;
}
{
static int done=0;
if(!done){
int i;
done=1;
default_mv_penalty= av_mallocz( sizeof(uint8_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
memset(default_mv_penalty, 0, sizeof(uint8_t)*(MAX_FCODE+1)*(2*MAX_MV+1));
memset(default_fcode_tab , 0, sizeof(uint8_t)*(2*MAX_MV+1));
for(i=-16; i<16; i++){
default_fcode_tab[i + MAX_MV]= 1;
}
}
}
s->me.mv_penalty= default_mv_penalty;
s->fcode_tab= default_fcode_tab;
if (s->me_method < ME_EPZS) s->me.mv_penalty = default_mv_penalty;
s->encoding = 1;
if (MPV_common_init(s) < 0)
return -1;
if(s->modified_quant)
s->chroma_qscale_table= ff_h263_chroma_qscale_table;
s->progressive_frame=
s->progressive_sequence= !(avctx->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME));
ff_set_cmp(&s->dsp, s->dsp.ildct_cmp, s->avctx->ildct_cmp);
ff_init_me(s);
#ifdef CONFIG_ENCODERS
#ifdef CONFIG_RISKY
if (s->out_format == FMT_H263)
h263_encode_init(s);
if(s->msmpeg4_version)
ff_msmpeg4_encode_init(s);
#endif
if (s->out_format == FMT_MPEG1)
ff_mpeg1_encode_init(s);
#endif
for(i=0;i<64;i++) {
int j= s->dsp.idct_permutation[i];
#ifdef CONFIG_RISKY
if(s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){
s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i];
s->inter_matrix[j] = ff_mpeg4_default_non_intra_matrix[i];
}else if(s->out_format == FMT_H263){
s->intra_matrix[j] =
s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
}else
#endif
{
s->intra_matrix[j] = ff_mpeg1_default_intra_matrix[i];
s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
}
if(s->avctx->intra_matrix)
s->intra_matrix[j] = s->avctx->intra_matrix[i];
if(s->avctx->inter_matrix)
s->inter_matrix[j] = s->avctx->inter_matrix[i];
}
if (s->out_format != FMT_MJPEG) {
convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16,
s->intra_matrix, s->intra_quant_bias, 1, 31);
convert_matrix(&s->dsp, s->q_inter_matrix, s->q_inter_matrix16,
s->inter_matrix, s->inter_quant_bias, 1, 31);
}
if(ff_rate_control_init(s) < 0)
return -1;
s->picture_number = 0;
s->input_picture_number = 0;
s->picture_in_gop_number = 0;
s->f_code = 1;
s->b_code = 1;
return 0;
}
| 1threat |
static void v9fs_req_recv(P9Req *req, uint8_t id)
{
QVirtIO9P *v9p = req->v9p;
P9Hdr hdr;
int i;
for (i = 0; i < 10; i++) {
qvirtio_wait_queue_isr(v9p->dev, v9p->vq, 1000 * 1000);
v9fs_memread(req, &hdr, 7);
le32_to_cpus(&hdr.size);
le16_to_cpus(&hdr.tag);
if (hdr.size >= 7) {
break;
}
v9fs_memrewind(req, 7);
}
g_assert_cmpint(hdr.size, >=, 7);
g_assert_cmpint(hdr.size, <=, P9_MAX_SIZE);
g_assert_cmpint(hdr.tag, ==, req->tag);
if (hdr.id != id) {
g_printerr("Received response %d (%s) instead of %d (%s)\n",
hdr.id, rmessage_name(hdr.id), id, rmessage_name(id));
if (hdr.id == P9_RLERROR) {
uint32_t err;
v9fs_uint32_read(req, &err);
g_printerr("Rlerror has errno %d (%s)\n", err, strerror(err));
}
}
g_assert_cmpint(hdr.id, ==, id);
}
| 1threat |
Can I not use $ctrl. in angular component template : <p>I am using angular 1.5 and I wanted to extract part of my DOM into a <a href="https://docs.angularjs.org/guide/component" rel="noreferrer">component</a>.<br>
Here is what I have done so far:</p>
<pre><code>angular.module('my-app').component("menuItem",{
templateUrl : "lib/menu-item.tmpl.html",
bindings : {
index : "<",
first : "<",
last : "<",
item : "=",
onDelete : "&",
onMoveUp : "&",
onMoveDown : "&"
},
controller : function($scope) {
}
});
</code></pre>
<p>And the template looks like so:</p>
<pre><code><div>
<aside class="sort-buttons">
<ul>
<li>
<button ng-click="$ctrl.onMoveUp({index : $ctrl.index})"
ng-disabled="$ctrl.first">
<i class="icon icon-up"></i>
</button>
</li>
<li>
<button ng-click="$ctrl.onMoveDown({index : $ctrl.index})"
ng-disabled="$ctrl.last">
<i class="icon icon-down"></i>
</button>
</li>
</ul>
</aside>
<div class="row">
<button class="btn btn-danger btn-icon btn-remove"
ng-click="$ctrl.onDelete({index : $ctrl.index})">
<i class="icon icon-remove"></i>
</button>
</div>
</div>
</code></pre>
<p>I use this component (far from finished!) like so:</p>
<pre><code><section class="container menu">
<menu-item index="$index" first="$first" last="$last" item="item"
on-delete="removeItem(index)"
on-move-up="moveItemUp(index)"
on-move-down="moveItemDown(index)"
ng-repeat="item in menu">
</menu-item>
<!-- some other display details of `$ctrl.item` -->
</section>
</code></pre>
<p>I have three main questions I guess:</p>
<ol>
<li>Why do I have to use <code>$ctrl</code> everywhere in my template? There is <code>$scope</code> so why all the bindings go to <code>$ctrl</code> rather than <code>$scope</code>? And is there a way to change this?</li>
<li>Can I somehow have values like <code>$index</code>, <code>$first</code> and <code>$last</code> passed in? It seems to me like it is a "buttery butter" to pass them in...</li>
<li>Is this even the right approach? Or should I use directive? I know components have isolated scope, and directives can have not-isolated scope. but could I mix/match in a directive (share the scope with controller, but also add my own functions to be used within directive/template only?)</li>
</ol>
<p>Thanks for your help.</p>
| 0debug |
static int init_common(VC9Context *v)
{
static int done = 0;
int i;
v->mv_type_mb_plane = v->direct_mb_plane = v->skip_mb_plane = NULL;
v->pq = -1;
#if HAS_ADVANCED_PROFILE
v->ac_pred_plane = v->over_flags_plane = NULL;
v->hrd_rate = v->hrd_buffer = NULL;
#endif
#if 0
for(i=0; i<64; i++){
int code= (vc9_norm6_spec[i][1] << vc9_norm6_spec[i][4]) + vc9_norm6_spec[i][3];
av_log(NULL, AV_LOG_DEBUG, "0x%03X, ", code);
if(i%16==15) av_log(NULL, AV_LOG_DEBUG, "\n");
}
for(i=0; i<64; i++){
int code= vc9_norm6_spec[i][2] + vc9_norm6_spec[i][4];
av_log(NULL, AV_LOG_DEBUG, "%2d, ", code);
if(i%16==15) av_log(NULL, AV_LOG_DEBUG, "\n");
}
#endif
if(!done)
{
done = 1;
INIT_VLC(&vc9_bfraction_vlc, VC9_BFRACTION_VLC_BITS, 23,
vc9_bfraction_bits, 1, 1,
vc9_bfraction_codes, 1, 1, 1);
INIT_VLC(&vc9_norm2_vlc, VC9_NORM2_VLC_BITS, 4,
vc9_norm2_bits, 1, 1,
vc9_norm2_codes, 1, 1, 1);
INIT_VLC(&vc9_norm6_vlc, VC9_NORM6_VLC_BITS, 64,
vc9_norm6_bits, 1, 1,
vc9_norm6_codes, 2, 2, 1);
INIT_VLC(&vc9_cbpcy_i_vlc, VC9_CBPCY_I_VLC_BITS, 64,
vc9_cbpcy_i_bits, 1, 1,
vc9_cbpcy_i_codes, 2, 2, 1);
INIT_VLC(&vc9_imode_vlc, VC9_IMODE_VLC_BITS, 7,
vc9_imode_bits, 1, 1,
vc9_imode_codes, 1, 1, 1);
for(i=0; i<3; i++)
{
INIT_VLC(&vc9_4mv_block_pattern_vlc[i], VC9_4MV_BLOCK_PATTERN_VLC_BITS, 16,
vc9_4mv_block_pattern_bits[i], 1, 1,
vc9_4mv_block_pattern_codes[i], 1, 1, 1);
INIT_VLC(&vc9_cbpcy_p_vlc[i], VC9_CBPCY_P_VLC_BITS, 64,
vc9_cbpcy_p_bits[i], 1, 1,
vc9_cbpcy_p_codes[i], 2, 2, 1);
}
for (i=0; i<2; i++)
{
INIT_VLC(&vc9_mv_diff_vlc[i], VC9_MV_DIFF_VLC_BITS, 73,
vc9_mv_diff_bits[i], 1, 1,
vc9_mv_diff_codes[i], 2, 2, 1);
INIT_VLC(&vc9_luma_dc_vlc[i], VC9_LUMA_DC_VLC_BITS, 120,
vc9_luma_dc_bits[i], 1, 1,
vc9_luma_dc_codes[i], 4, 4, 1);
INIT_VLC(&vc9_ttmb_vlc[i], VC9_TTMB_VLC_BITS, 16,
vc9_ttmb_bits[i], 1, 1,
vc9_ttmb_codes[i], 2, 2, 1);
}
}
return 0;
}
| 1threat |
Should I rewrite my entire JavaScript code into jQuery? : <p>I'm currently developing a web application and I was forced to use jQuery for some animations and other specific purposes, but still most of my code is written in JavaScript.</p>
<p>Should I rewrite these JavaScript modules if after all jQuery is being loaded every time? I know that in some cases it is better to use JavaScript instead of jQuery because it is faster and some other advantages but I'm already using jQuery throughout the page and I'm wondering should I use it everywhere instead of loading the whole library for few chunks of code.</p>
<p>Will there be any significant difference in the performance if the library is already loaded?</p>
| 0debug |
How can I share files between a raspberry pi and windows? : <p>How can I share files between a raspberry pi and a windows computer?
(Like in a public folder or something like that)</p>
| 0debug |
C macro - expression is not assignable : I get this error when compiling:
macro.c:11:2: error: expression is not assignable
ProdottoAumentato(10, 20);
I don't know why it says this, I can't find any errors.
Here's the code:
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#define ProdottoAumentato(X, Y) X++; X * Y;
int main(void) {
ProdottoAumentato(10, 20);
printf("\nEnd\n");
return(0);
}
| 0debug |
static void phys_page_set_level(PhysPageEntry *lp, hwaddr *index,
hwaddr *nb, uint16_t leaf,
int level)
{
PhysPageEntry *p;
int i;
hwaddr step = (hwaddr)1 << (level * P_L2_BITS);
if (lp->skip && lp->ptr == PHYS_MAP_NODE_NIL) {
lp->ptr = phys_map_node_alloc();
p = next_map.nodes[lp->ptr];
if (level == 0) {
for (i = 0; i < P_L2_SIZE; i++) {
p[i].skip = 0;
p[i].ptr = PHYS_SECTION_UNASSIGNED;
}
}
} else {
p = next_map.nodes[lp->ptr];
}
lp = &p[(*index >> (level * P_L2_BITS)) & (P_L2_SIZE - 1)];
while (*nb && lp < &p[P_L2_SIZE]) {
if ((*index & (step - 1)) == 0 && *nb >= step) {
lp->skip = 0;
lp->ptr = leaf;
*index += step;
*nb -= step;
} else {
phys_page_set_level(lp, index, nb, leaf, level - 1);
}
++lp;
}
}
| 1threat |
static uint32_t pci_apb_ioreadb (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
val = cpu_inb(addr & IOPORTS_MASK);
return val;
}
| 1threat |
What does this javascript syntax mean ? (0, _parseKey2.default)(something) : <p>I find this notation everywhere in Webpack generated libs but I don't understand it :</p>
<pre><code>var a = (0, _parseKey2.default)(something)
</code></pre>
<p>What does the <code>(0, _parseKey2.default)</code> stands for ? I don't remember seeing those coma separated expressions between parenthesis elsewhere that in function parameters, so maybe I am just missing something simple.</p>
<p>Thanks for your help.</p>
| 0debug |
Swift Custom NavBar Back Button Image and Text : <p>I need to customise the look of a back button in a Swift project.</p>
<p>Here's what I have:
<a href="https://i.stack.imgur.com/WBW7p.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WBW7p.png" alt="Default Back Button"></a></p>
<p>Here's what I want:
<a href="https://i.stack.imgur.com/KaGCs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KaGCs.png" alt="Custom Back Button"></a></p>
<p>I've tried creating my own UIBarButtonItem but I can't figure out how to get the image to be beside the text, rather than as a background or a replacement for the text.</p>
<pre><code>let backButton = UIBarButtonItem(title: "Custom", style: .Plain, target: self, action: nil )
//backButton.image = UIImage(named: "imageName") //Replaces title
backButton.setBackgroundImage(UIImage(named: "imageName"), forState: .Normal, barMetrics: .Default) // Stretches image
navigationItem.setLeftBarButtonItem(backButton, animated: false)
</code></pre>
| 0debug |
How to fix 'Incorrect syntax near the keyword 'WHEN'' error in SQL server? : I'm trying to implement this two when condition in the Case statement but it is just not happening. Please help me fix this ?
```
SELECT BR, CID, TRNDATE,
CASE
WHEN TRNTYPE = '108' THEN -1 else 1 * TrnAmt/100
WHEN TRNTYPE = '114' THEN (TrnIntAmt - TrnTaxAmt)/100
END as TransactionAmount
FROM T_TRNHIST | 0debug |
How to use case without using declare? : I need the ouput from this.. i knw this is wrong it is just an example
select customer_name,((Qty * 0.5)*
(case when (datediff (month, Appointment_Date,getdate())) < 12 )'Incentive'
from t1,t2
where t1.customer_code = t2.customer_code | 0debug |
Optimeze Postgres query : Table with two columns (transaction_id, user_id), both with index. Approx 10M records in table.
transaction_id is unique
transaction_id count on user_id varies from very few to thousands.
What I need is to find the max(transaction_id), with respect to that the top25 transaction_id's on a given user must be ignored.
Eg a user_id with 21 transaction_id's will not be selected. A user_id with 47 transactions will return transction 26.
I have tried several ways by using offset, limit etc, but they all seem to be to slow (very high cost).
Help is very appriciated :)
| 0debug |
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-basement:[15.0.0,16.0.0) : <p>I am getting this error:
Here is my build.gradle(Module:app)</p>
<pre><code>apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.mycompany.myapp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding.enabled = true
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.firebase:firebase-core:15.0.0'
compileOnly "org.projectlombok:lombok:1.16.20"
annotationProcessor 'org.projectlombok:lombok:1.16.20'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.google.android.gms:play-services-maps:15.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.google.android.gms:play-services-places:15.0.0'
implementation 'com.paytm.pgsdk:pgsdk:1.0.8'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.crashlytics.sdk.android:crashlytics:2.9.1'
}
apply plugin: 'com.google.gms.google-services'
</code></pre>
<p>and Here is my build.gradle(Project: myApp)</p>
<pre><code>buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'io.fabric.tools:gradle:1.25.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
</code></pre>
<p>I have checked other solutions, most of them suggest to add</p>
<p><code>maven { url "https://maven.google.com" }</code></p>
<p>to build.gradle of project. I have already tried this but I am still getting same error.</p>
<p>I am on android studio 3.0.
I have also tried adding <code>google()</code> instead of maven (another suggestion)</p>
| 0debug |
static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum)
{
int64_t length;
int64_t n;
int64_t ret, ret2;
length = bdrv_getlength(bs);
if (length < 0) {
return length;
}
if (sector_num >= (length >> BDRV_SECTOR_BITS)) {
*pnum = 0;
return 0;
}
n = bs->total_sectors - sector_num;
if (n < nb_sectors) {
nb_sectors = n;
}
if (!bs->drv->bdrv_co_get_block_status) {
*pnum = nb_sectors;
ret = BDRV_BLOCK_DATA;
if (bs->drv->protocol_name) {
ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE);
}
return ret;
}
ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum);
if (ret < 0) {
*pnum = 0;
return ret;
}
if (ret & BDRV_BLOCK_RAW) {
assert(ret & BDRV_BLOCK_OFFSET_VALID);
return bdrv_get_block_status(bs->file, ret >> BDRV_SECTOR_BITS,
*pnum, pnum);
}
if (!(ret & BDRV_BLOCK_DATA)) {
if (bdrv_has_zero_init(bs)) {
ret |= BDRV_BLOCK_ZERO;
} else if (bs->backing_hd) {
BlockDriverState *bs2 = bs->backing_hd;
int64_t length2 = bdrv_getlength(bs2);
if (length2 >= 0 && sector_num >= (length2 >> BDRV_SECTOR_BITS)) {
ret |= BDRV_BLOCK_ZERO;
}
}
}
if (bs->file &&
(ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) &&
(ret & BDRV_BLOCK_OFFSET_VALID)) {
ret2 = bdrv_co_get_block_status(bs->file, ret >> BDRV_SECTOR_BITS,
*pnum, pnum);
if (ret2 >= 0) {
ret |= (ret2 & BDRV_BLOCK_ZERO);
}
}
return ret;
}
| 1threat |
void ff_dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx)
{
int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_MMX) {
#if HAVE_INLINE_ASM
const int idct_algo = avctx->idct_algo;
if (avctx->bits_per_raw_sample <= 8) {
if (idct_algo == FF_IDCT_AUTO || idct_algo == FF_IDCT_SIMPLEMMX) {
c->idct_put = ff_simple_idct_put_mmx;
c->idct_add = ff_simple_idct_add_mmx;
c->idct = ff_simple_idct_mmx;
c->idct_permutation_type = FF_SIMPLE_IDCT_PERM;
} else if (idct_algo == FF_IDCT_CAVS) {
c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
} else if (idct_algo == FF_IDCT_XVIDMMX) {
if (mm_flags & AV_CPU_FLAG_SSE2) {
c->idct_put = ff_idct_xvid_sse2_put;
c->idct_add = ff_idct_xvid_sse2_add;
c->idct = ff_idct_xvid_sse2;
c->idct_permutation_type = FF_SSE2_IDCT_PERM;
} else if (mm_flags & AV_CPU_FLAG_MMXEXT) {
c->idct_put = ff_idct_xvid_mmx2_put;
c->idct_add = ff_idct_xvid_mmx2_add;
c->idct = ff_idct_xvid_mmx2;
} else {
c->idct_put = ff_idct_xvid_mmx_put;
c->idct_add = ff_idct_xvid_mmx_add;
c->idct = ff_idct_xvid_mmx;
}
}
}
#endif
dsputil_init_mmx(c, avctx, mm_flags);
}
if (mm_flags & AV_CPU_FLAG_MMXEXT)
dsputil_init_mmx2(c, avctx, mm_flags);
if (mm_flags & AV_CPU_FLAG_3DNOW && HAVE_AMD3DNOW)
dsputil_init_3dnow(c, avctx, mm_flags);
if (mm_flags & AV_CPU_FLAG_3DNOWEXT && HAVE_AMD3DNOWEXT)
dsputil_init_3dnowext(c, avctx, mm_flags);
if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE)
dsputil_init_sse(c, avctx, mm_flags);
if (mm_flags & AV_CPU_FLAG_SSE2)
dsputil_init_sse2(c, avctx, mm_flags);
if (mm_flags & AV_CPU_FLAG_SSSE3)
dsputil_init_ssse3(c, avctx, mm_flags);
if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE)
dsputil_init_sse4(c, avctx, mm_flags);
if (mm_flags & AV_CPU_FLAG_AVX)
dsputil_init_avx(c, avctx, mm_flags);
if (CONFIG_ENCODERS)
ff_dsputilenc_init_mmx(c, avctx);
}
| 1threat |
$_POST method turns emty : Firstable, hello everyone. I have issue about the $_POST method, when I write this code block;
if (isset($_POST['menuduzenle'])) {
$menu_id=$_POST['menu_id']; //It didn't turn with value in mysql
$ayarguncelle=mysql_query("update menuler set menu_ad='".$_POST['menu_ad']."',menu_link='".$_POST['menu_link']."'where menu_id='$menu_id'");
if(mysql_affected_rows())
{
header("Location:../menuleriduzenle.php?guncelleme=basarili&menu_id=$menu_id");
}else{
header("Location:../menuleriduzenle.php?guncelleme=basarisiz&menu_id=$menu_id");}
}
menu_id turns emty, what I need to do for solve this?
| 0debug |
(0|10)* regular expression : <p>what strings are accepted by this expression (0|10)* regular expression? I was thinking 0, 10, and was wondering if it would accept something like 010 since it is an or?</p>
<p>Thanks</p>
| 0debug |
Question about adding three digits with each other in java : <p>I have a task to add each numbers. One of my colleague helped me out and here's the code.</p>
<pre><code>public class Solution {
public static void main(String[] args) {
System.out.println(sumDigitsInNumber(546));
}
public static int sumDigitsInNumber(int number) {
int sum = 0;
sum = sum + number%10;
number = number/10;
sum = sum + number%10;
number = number/10;
sum = sum + number%10;
number = number/10;
return sum;//write your code here
}
</code></pre>
<p>I'm not sure exactly how this works. Can someone please explain to me? Thanks.</p>
| 0debug |
What wrong with the frist line? : I am reading the Bjarne Stroustrup's book. This book is very abstract for me. May be the English is not my first language. The book says expression() will never get beyong its first line: Expression()stars by calling expression()which starts by calling expression() and so on "forever". Is the the double expression() calling the double left = expression(); forever? How is work?
Thanks.
double expression()
{
double left = expression();
Token t = get_token();
swich(t.kind) {
case'+':
return left + term();
case'-':
return left - term();
default:
return left;
}
} | 0debug |
ANDROID | How to create button mode vertical in AlertDialog? : <p>I not have idea about this...
maybe you all can help me for code to make alert dialog like this
<a href="https://i.stack.imgur.com/jG6nG.jpg" rel="nofollow noreferrer">see image alert dialog here</a></p>
<p>thanks all....</p>
| 0debug |
host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
uint16List *host_nodes = NULL;
uint16List **node = &host_nodes;
unsigned long value;
value = find_first_bit(backend->host_nodes, MAX_NODES);
node = host_memory_append_node(node, value);
if (value == MAX_NODES) {
goto out;
}
do {
value = find_next_bit(backend->host_nodes, MAX_NODES, value + 1);
if (value == MAX_NODES) {
break;
}
node = host_memory_append_node(node, value);
} while (true);
out:
visit_type_uint16List(v, name, &host_nodes, errp);
}
| 1threat |
Unable to search for a string in an Array : <p>The Program is designed to read in album information from a .txt file, once the user inputs their desired track, the program checks an array to see if it contains that track. I have been successfully able to read the tracks into the array, but my program cannot identify if a string lies in this array or not.</p>
<p>The Ruby File</p>
<pre><code>require './input_functions'
module Genre
POP, CLASSIC, JAZZ, ROCK = *1..4
end
$genre_names = ['Null', 'Pop', 'Classic', 'Jazz', 'Rock']
class Album
attr_accessor :title, :artist, :genre, :tracks
def initialize (title, artist, genre)
# insert lines here
@title = title
@artist = artist
@genre = genre
end
end
class Track
attr_accessor :name, :location
def initialize (name, location)
@name = name
@location = location
end
end
def read_track(music_file)
track_name = music_file.gets
track_location = music_file.gets
track = Track.new(track_name, track_location)
end
def read_tracks(music_file)
tracks = Array.new
count = music_file.gets.to_i
index = 0
while index < count
tracks << read_track(music_file)
index += 1
end
tracks
end
def print_tracks(tracks)
index = 0
while (index < tracks.length)
puts 'Track Number ' + index.to_s + ' is:'
print_track(tracks[index])
index = index + 1
end
tracks
end
def read_album music_file
album_artist = music_file.gets
album_title = music_file.gets
album_genre = music_file.gets
album = Album.new(album_title, album_artist, album_genre)
album
end
def print_album album
puts 'Album title is ' + album.title.to_s
puts 'Album artist is ' + album.artist.to_s
puts 'Genre is ' + album.genre.to_s
puts $genre_names[album.genre.to_i]
# print out the tracks
puts 'Tracks are ' + print_tracks(album.tracks).to_s
end
def print_track track
puts('Track title is: ' + track.name.to_s)
puts('Track file location is: ' + track.location.to_s)
end
** This is where I am having my problem
# search for track by name.
# Returns the index of the track or -1 if not found
def search_for_track_name(tracks, search_string)
search_string = gets.chomp
index = 0
while (index < tracks.length)
tracks.include?(search_string)
index = index + 1
end
if tracks.include?(search_string)
return index
else
index = -1
end
return index
end
# Reads in an Album from a file and then prints all the album
# to the terminal
def main
music_file = File.new("album.txt", "r")
if music_file
album = read_album(music_file)
album.tracks = read_tracks(music_file)
music_file.close()
end
search_string = read_string("Enter the track name you wish to find: ")
index = search_for_track_name(album.tracks, search_string)
if index.to_i > -1
puts "Found " + album.tracks[index].name + " at " + index.to_s
else
puts "Entry not Found"
end
end
main
</code></pre>
<p>This is the .txt file</p>
<pre><code>Neil Diamond
Greatest Hits
1
3
Crackling Rose
sounds/01-Cracklin-rose.wav
Soolaimon
sounds/06-Soolaimon.wav
Sweet Caroline
sounds/20-Sweet_Caroline.wav
</code></pre>
<p>When the user enters "Sweet Caroline", the program should return that it has found the track, instead it does:</p>
<pre><code>Enter the track name you wish to find:
Sweet Caroline
Entry not Found
Tracks are [#<Track:0x000000000331be58 @name="Crackling Rose\n", @location="sounds/01-Cracklin-rose.wav\n">, #<Track:0x000000000331bdb8 @name="Soolaimon\n", @location="sounds/06-Soolaimon.wav\n">, #<Track:0x000000000331bd18 @name="Sweet Caroline\n", @location="sounds/20-Sweet_Caroline.wav\n">]
</code></pre>
| 0debug |
I unable to handle bootstrap modal using selenium with java :
[1]: http://www.seleniumeasy.com/test/bootstrap-modal-demo.html
please tell me how to handle the bootstrap modal,please open above link and click on **Launch modal** button of **Single modal** example | 0debug |
static void v9fs_xattrcreate(void *opaque)
{
int flags;
int32_t fid;
int64_t size;
ssize_t err = 0;
V9fsString name;
size_t offset = 7;
V9fsFidState *file_fidp;
V9fsFidState *xattr_fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dsqd",
&fid, &name, &size, &flags);
file_fidp = get_fid(pdu, fid);
if (file_fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
xattr_fidp = file_fidp;
xattr_fidp->fid_type = P9_FID_XATTR;
xattr_fidp->fs.xattr.copied_len = 0;
xattr_fidp->fs.xattr.len = size;
xattr_fidp->fs.xattr.flags = flags;
v9fs_string_init(&xattr_fidp->fs.xattr.name);
v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
if (size) {
xattr_fidp->fs.xattr.value = g_malloc(size);
} else {
xattr_fidp->fs.xattr.value = NULL;
}
err = offset;
put_fid(pdu, file_fidp);
out_nofid:
complete_pdu(s, pdu, err);
v9fs_string_free(&name);
} | 1threat |
Why does my function return 0 even when it shouldn't? : I am trying to count and update the immediate neighbors of a cell with non zero values. So left, right, upper, lower, upper-left ...
Anyway all the eight directions.
int grid[100][100];
int genNeibrs(int x, int y, int n, int m)
{
m--;
n--;
int c = 0, xs = ((x - 1) < 0) ? 0 : (x - 1), xe = ((x + 1) > n) ? n : (x + 1), ys = ((y - 1) < 0) ? 0 : (y - 1), ye = ((y + 1) > m) ? m : (y + 1);
for (auto i = xs; i <= xe; i++)
{
for (auto j = ys; j <= ye; j++)
{
if (grid[i][j])
++c;
}
}
return c;
}
void getGrs(int n, int m) //m
{
for (auto i = 0; i < n; i++)
{
for (auto j = 0; j < m; j++)
if (grid[i][j])
{
int q = genNeibrs(i, j, m, n);
if (q)
grid[i][j] = q;
}
}
}
Here the value of q becomes 0 for successive iterations other than 0,0 for
`grid = {{1, 0, 1, 1, 0, 1, 1, 1, 1, 0 <repeats 91 times>}, {0, 0, 0, 1, 0, 1, 0, 0, 1, 0 <repeats 91 times>}, {0 <repeats 100 times>} <repeats 98 times>}`, m and n being 9 and 2 respectively.
While debugging with gdb the function `genNeibrs` returns as expected but over execution I managed to pin it down to the line where q is being initialized. It somehow gets initialized to zero even when it shouldn't.
So what am I doing wrong or is this a compiler problem?
Expected value of `grid = {{1, 0 ,2 ,2 ,0, 2, 3, 3, 2, 0 <repeats 91 times>},{0, 0, 0, 2, 0, 2, 0, 0, 2, 0 <repeats 91 times>}, {0 <repeats 100 times>} <repeats 98 times>}`
| 0debug |
Invalid syntax in a variable in Python : <p>The code is below</p>
<pre><code>i=0
a=0
Matrix[0]=0
Matrix = [1 for i in range(1000)]
while i<1000:
i=i+1
Matrix[i]=(1/1000)*((i*(1/1000))^2
a=a+Matrix[i]
print (a)
</code></pre>
<p>When I try to run the program, Python highlight the first a in the 8th row and it says invalid syntax.
I can't figure out what is the problem with the code.
<br>Much appreciated if you helped</p>
| 0debug |
JS: Nested promises : <p>I do not understand how to chain promises:</p>
<p><code>getUser</code> is a promise function and also <code>search</code> is a promise function. <code>getUser</code> will return a language value.</p>
<p>With this data is not an array value, which should be returned by the <code>search</code> function</p>
<pre><code>getUser(userId)
.then(({ language }) => {
const data = search('content', language)
res.send(200, {
content: data,
user: { language }
})
})
.catch((error) => next(error))
</code></pre>
| 0debug |
void hmp_drive_add(Monitor *mon, const QDict *qdict)
{
DriveInfo *dinfo = NULL;
const char *opts = qdict_get_str(qdict, "opts");
dinfo = add_init_drive(opts);
if (!dinfo) {
goto err;
}
if (dinfo->devaddr) {
monitor_printf(mon, "Parameter addr not supported\n");
goto err;
}
switch (dinfo->type) {
case IF_NONE:
monitor_printf(mon, "OK\n");
break;
default:
if (pci_drive_hot_add(mon, qdict, dinfo)) {
goto err;
}
}
return;
err:
if (dinfo) {
blk_unref(blk_by_legacy_dinfo(dinfo));
}
}
| 1threat |
The processing speed is too slow : I made this program that create random words letter by letter to make up random names. but this program is apparently slow. is there anyway to make it faster?
I tried Cython but I noticed that cython only support python 2.x while I use python 3.x
Heres the Code : [Name Generator][1]
Probably what make it slow is my name Filtering Function heres some example :
def name_filtering():
Β Β Β Β while True:
Β Β Β Β Β Β this_name = generator()
Β Β Β Β Β Β VOCAL_WRONG = False
Β Β Β Β Β Β CONSONANT_WRONG = False
Β Β Β Β Β Β univ_wrong_point = 0
Β Β Β Β Β Β wrong_point = 0
Β Β Β Β Β Β for y in this_name:
Β Β Β Β Β Β Β Β if y in lc_vocal:
Β Β Β Β Β Β Β Β Β Β wrong_point += 1
Β Β Β Β Β Β Β Β if wrong_point >= len(this_name):
Β Β Β Β Β Β Β Β Β Β univ_wrong_point += 1
Β Β Β Β Β Β Β Β Β Β if verbose is True:
Β Β Β Β Β Β Β Β Β Β Β Β print("ALL VOCAL DETECTED " + this_name)
Β Β Β Β Β Β Β Β Β Β Β Β VOCAL_WRONG = True
Β
Β Β Β Β Β Β wrong_point_2 = 0
Β Β Β Β Β Β for z in range(len(this_name)):
Β Β Β Β Β Β Β Β if this_name[z] in lc_alphabet:
Β Β Β Β Β Β Β Β Β Β wrong_point_2 += 1
Β Β Β Β Β Β Β Β if wrong_point_2 == len(this_name):
Β Β Β Β Β Β Β Β Β Β univ_wrong_point += 1
Β Β Β Β Β Β Β Β Β Β if verbose is True:
Β Β Β Β Β Β Β Β Β Β Β Β print("ALL CONSONANT DETECTED " + this_name)
Β Β Β Β Β Β Β Β Β Β Β Β CONSONANT_WRONG = True
Β Β Β Β Β if univ_wrong_point == 0:
Β Β Β Β Β Β Β return this_name
Β
I don't know how to Optimize my code. probably you guys can give me the basic logic how to optimize any code. Thank you.
[1]: https://pastebin.com/LTTYVbGD | 0debug |
static void usb_hid_handle_destroy(USBDevice *dev)
{
USBHIDState *s = (USBHIDState *)dev;
if (s->kind != USB_KEYBOARD)
qemu_remove_mouse_event_handler(s->ptr.eh_entry);
}
| 1threat |
static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVDMGState *s = bs->opaque;
DmgHeaderState ds;
uint64_t rsrc_fork_offset, rsrc_fork_length;
uint64_t plist_xml_offset, plist_xml_length;
int64_t offset;
int ret;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
false, errp);
if (!bs->file) {
return -EINVAL;
}
block_module_load_one("dmg-bz2");
bs->read_only = true;
s->n_chunks = 0;
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
ds.data_fork_offset = 0;
ds.max_compressed_size = 1;
ds.max_sectors_per_chunk = 1;
offset = dmg_find_koly_offset(bs->file, errp);
if (offset < 0) {
ret = offset;
goto fail;
}
ret = read_uint64(bs, offset + 0x18, &ds.data_fork_offset);
if (ret < 0) {
goto fail;
} else if (ds.data_fork_offset > offset) {
ret = -EINVAL;
goto fail;
}
ret = read_uint64(bs, offset + 0x28, &rsrc_fork_offset);
if (ret < 0) {
goto fail;
}
ret = read_uint64(bs, offset + 0x30, &rsrc_fork_length);
if (ret < 0) {
goto fail;
}
if (rsrc_fork_offset >= offset ||
rsrc_fork_length > offset - rsrc_fork_offset) {
ret = -EINVAL;
goto fail;
}
ret = read_uint64(bs, offset + 0xd8, &plist_xml_offset);
if (ret < 0) {
goto fail;
}
ret = read_uint64(bs, offset + 0xe0, &plist_xml_length);
if (ret < 0) {
goto fail;
}
if (plist_xml_offset >= offset ||
plist_xml_length > offset - plist_xml_offset) {
ret = -EINVAL;
goto fail;
}
ret = read_uint64(bs, offset + 0x1ec, (uint64_t *)&bs->total_sectors);
if (ret < 0) {
goto fail;
}
if (bs->total_sectors < 0) {
ret = -EINVAL;
goto fail;
}
if (rsrc_fork_length != 0) {
ret = dmg_read_resource_fork(bs, &ds,
rsrc_fork_offset, rsrc_fork_length);
if (ret < 0) {
goto fail;
}
} else if (plist_xml_length != 0) {
ret = dmg_read_plist_xml(bs, &ds, plist_xml_offset, plist_xml_length);
if (ret < 0) {
goto fail;
}
} else {
ret = -EINVAL;
goto fail;
}
s->compressed_chunk = qemu_try_blockalign(bs->file->bs,
ds.max_compressed_size + 1);
s->uncompressed_chunk = qemu_try_blockalign(bs->file->bs,
512 * ds.max_sectors_per_chunk);
if (s->compressed_chunk == NULL || s->uncompressed_chunk == NULL) {
ret = -ENOMEM;
goto fail;
}
if (inflateInit(&s->zstream) != Z_OK) {
ret = -EINVAL;
goto fail;
}
s->current_chunk = s->n_chunks;
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->types);
g_free(s->offsets);
g_free(s->lengths);
g_free(s->sectors);
g_free(s->sectorcounts);
qemu_vfree(s->compressed_chunk);
qemu_vfree(s->uncompressed_chunk);
return ret;
}
| 1threat |
Please explain the output : <pre><code>#include<stdio.h>
int main()
{
int a=9;
if (a=5)
printf("a is five \t");
else
printf("a is not five \t");
printf(" Value of a is %d \n",a);
return 0;
}
</code></pre>
<p>The following programs gives output ....
<code>a is five Value of a is 5</code> </p>
<p>please explain this</p>
| 0debug |
static int select_reference_stream(AVFormatContext *s)
{
SegmentContext *seg = s->priv_data;
int ret, i;
seg->reference_stream_index = -1;
if (!strcmp(seg->reference_stream_specifier, "auto")) {
int type_index_map[AVMEDIA_TYPE_NB];
static const enum AVMediaType type_priority_list[] = {
AVMEDIA_TYPE_VIDEO,
AVMEDIA_TYPE_AUDIO,
AVMEDIA_TYPE_SUBTITLE,
AVMEDIA_TYPE_DATA,
AVMEDIA_TYPE_ATTACHMENT
};
enum AVMediaType type;
for (i = 0; i < AVMEDIA_TYPE_NB; i++)
type_index_map[i] = -1;
for (i = 0; i < s->nb_streams; i++) {
type = s->streams[i]->codec->codec_type;
if ((unsigned)type < AVMEDIA_TYPE_NB && type_index_map[type] == -1
&& !(s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC))
type_index_map[type] = i;
}
for (i = 0; i < FF_ARRAY_ELEMS(type_priority_list); i++) {
type = type_priority_list[i];
if ((seg->reference_stream_index = type_index_map[type]) >= 0)
break;
}
} else {
for (i = 0; i < s->nb_streams; i++) {
ret = avformat_match_stream_specifier(s, s->streams[i],
seg->reference_stream_specifier);
if (ret < 0)
break;
if (ret > 0) {
seg->reference_stream_index = i;
break;
}
}
}
if (seg->reference_stream_index < 0) {
av_log(s, AV_LOG_ERROR, "Could not select stream matching identifier '%s'\n",
seg->reference_stream_specifier);
return AVERROR(EINVAL);
}
return 0;
}
| 1threat |
This simple If statment send me an SyntaxError: invalid syntax on Python 3.6 need help Thank : elephant_weight = 3000
ant_weight = 0.1
If elephant_weight > ant_weight:
square()
File "c:/Users/AIRWEBDEV/Documents/exercice.py", line 37
If elephant_weight > ant_weight:
^
SyntaxError: invalid syntax | 0debug |
Creating legend with circles leaflet R : <p>I'm trying to create a leaflet map with points sized by a variable. Is it possible to create a legend with different sized circles representing the different variable values? I found another post showing how to convert squares to circles in the legend, but am not sure how to change the size of different circles in the legend. </p>
<p>For example, here's a dummy script which creates 10 points associated with 2 classes of a variable (5 and 10). I'd like a legend with two circles the same size as that specified with addCircleMarkers with a radius of 5 and 10. If anyone can modify to create what I want I would be extremely grateful! Thanks!</p>
<pre><code>library(shiny)
library(leaflet)
#create data
Points<-data.frame(x=runif(10,20,21), y=runif(10,0,1), var=rep(c(5,10),5))
map = leaflet() %>% addTiles()
# Set up shiny app
shinyApp(ui=bootstrapPage(
tags$style(type = "text/css", "html, body {width:100%;height:100%}",
".leaflet .legend i{
border-radius: 50%;
width: 10px;
height: 10px;
margin-top: 4px;
}
"
),
leafletOutput("myMap", width = "100%", height = "100%")),
server= function(input, output){
output$myMap = renderLeaflet({map %>%
addCircleMarkers(Points$x,Points$y,radius=Points$var) %>%
addLegend(colors=rep("blue",2), labels=c(5,10))
})
})
</code></pre>
| 0debug |
def amicable_numbers_sum(limit):
if not isinstance(limit, int):
return "Input is not an integer!"
if limit < 1:
return "Input must be bigger than 0!"
amicables = set()
for num in range(2, limit+1):
if num in amicables:
continue
sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])
sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])
if num == sum_fact2 and num != sum_fact:
amicables.add(num)
amicables.add(sum_fact2)
return sum(amicables) | 0debug |
How do I take multiple inputs in different lines in Python so that inputs can be accessed later? : <p><a href="http://i.stack.imgur.com/1xDpf.jpg" rel="nofollow">I want to take input in similar pattern</a>
I want user to give inputs in multiple lines and value of multiple lines is provided.(5 in given pic)</p>
| 0debug |
In python, how do I regex match the "." char in, say, a string representing an address? : <p>I am getting an address string from the client (first I check that it is a string under a certain length), and I have this so far: ^[a-zA-Z0-9 ]+$ but it will fail if the address has a "." char in it. </p>
<p>I want a single regex that also matches if a "." char shows up: the address can only contain spaces, numbers and letters.</p>
<p>Obviously, one can do if "." in address_string, but I am trying to do my check in one regex match.</p>
<p>How do I also escape/search for a "." char in a string?</p>
| 0debug |
Why is java telling me the string are not matching? : <p>I'm reading in from a text file.
every time the frame number changes I need to check if the ipv6 address is changed.
every time I compare the strings it tells me they don't match even after setting the value to the source address.</p>
| 0debug |
static int get_best_header(FLACParseContext* fpc, const uint8_t **poutbuf,
int *poutbuf_size)
{
FLACHeaderMarker *header = fpc->best_header;
FLACHeaderMarker *child = header->best_child;
if (!child) {
*poutbuf_size = av_fifo_size(fpc->fifo_buf) - header->offset;
} else {
*poutbuf_size = child->offset - header->offset;
check_header_mismatch(fpc, header, child, 0);
}
if (header->fi.channels != fpc->avctx->channels ||
(!fpc->avctx->channel_layout && header->fi.channels <= 6)) {
fpc->avctx->channels = header->fi.channels;
ff_flac_set_channel_layout(fpc->avctx);
}
fpc->avctx->sample_rate = header->fi.samplerate;
fpc->pc->duration = header->fi.blocksize;
*poutbuf = flac_fifo_read_wrap(fpc, header->offset, *poutbuf_size,
&fpc->wrap_buf,
&fpc->wrap_buf_allocated_size);
fpc->best_header_valid = 0;
if (child)
return child->offset - av_fifo_size(fpc->fifo_buf);
return 0;
}
| 1threat |
Picking data storage type in AWS : <p>What would you choose for data storage, S3 or EBS, provided no code change should be made in the existing on premise application?</p>
| 0debug |
pvscsi_ring_init_data(PVSCSIRingInfo *m, PVSCSICmdDescSetupRings *ri)
{
int i;
uint32_t txr_len_log2, rxr_len_log2;
uint32_t req_ring_size, cmp_ring_size;
m->rs_pa = ri->ringsStatePPN << VMW_PAGE_SHIFT;
if ((ri->reqRingNumPages > PVSCSI_SETUP_RINGS_MAX_NUM_PAGES)
|| (ri->cmpRingNumPages > PVSCSI_SETUP_RINGS_MAX_NUM_PAGES)) {
return -1;
}
req_ring_size = ri->reqRingNumPages * PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE;
cmp_ring_size = ri->cmpRingNumPages * PVSCSI_MAX_NUM_CMP_ENTRIES_PER_PAGE;
txr_len_log2 = pvscsi_log2(req_ring_size - 1);
rxr_len_log2 = pvscsi_log2(cmp_ring_size - 1);
m->txr_len_mask = MASK(txr_len_log2);
m->rxr_len_mask = MASK(rxr_len_log2);
m->consumed_ptr = 0;
m->filled_cmp_ptr = 0;
for (i = 0; i < ri->reqRingNumPages; i++) {
m->req_ring_pages_pa[i] = ri->reqRingPPNs[i] << VMW_PAGE_SHIFT;
}
for (i = 0; i < ri->cmpRingNumPages; i++) {
m->cmp_ring_pages_pa[i] = ri->cmpRingPPNs[i] << VMW_PAGE_SHIFT;
}
RS_SET_FIELD(m, reqProdIdx, 0);
RS_SET_FIELD(m, reqConsIdx, 0);
RS_SET_FIELD(m, reqNumEntriesLog2, txr_len_log2);
RS_SET_FIELD(m, cmpProdIdx, 0);
RS_SET_FIELD(m, cmpConsIdx, 0);
RS_SET_FIELD(m, cmpNumEntriesLog2, rxr_len_log2);
trace_pvscsi_ring_init_data(txr_len_log2, rxr_len_log2);
smp_wmb();
return 0;
}
| 1threat |
Writing a function that counts characters and vowels : <p>I need to write a function that counts characters and vowels from a string that a user inputs, and write a routine that calls the function and displays this:</p>
<pre><code>$ ./count_all.py
Enter some words: The sun rises in the East and sets in the West
13 letters in 47 are vowels.
</code></pre>
<p>What would be the best way to do this?</p>
| 0debug |
Why aren't my widgets and buttons showing up on physical device but show up in Android Studio? : I am learning Android Studio for the first time and I'm stuck trying to run a program on a physical android device. The problem I'm having is that none of my content (widgets, textview, buttons) appear on the screen on my device. Is there something wrong with the computer I'm using? I can see and manipulate widgets in the editor but a lot of the things on screen I create don't show up in the correct spot except on the blueprint.
I've attached images of everything so you guys can take a look. I'm running this on an AMD A10- 9600p Radeon R5.
Thanks for the help.
[Image from Android Device][1]
[Android Studio Screenshot][2]
[1]: https://i.stack.imgur.com/kc6KU.png
[2]: https://i.stack.imgur.com/lLdpJ.png
| 0debug |
AAPT: error: attribute android:requestLegacyExternalStorage not found : <p>collection error in AndroidManifest.xml</p>
<p>AAPT: error: attribute android:requestLegacyExternalStorage not found.</p>
<p>Although the attribute is there but it writes an error</p>
<p>My AndroidManifest.xml</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="android.apps">
<uses-feature android:name="android.hardware.wifi" android:required="false" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@mipmap/launcher_icon"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/launcher_icon"
android:supportsRtl="true"
android:theme="@style/Theme.MaterialFiles"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
<activity
android:name="android.apps.filelist.FileListActivity"
android:label="@string/file_list_title"
android:theme="@style/Theme.MaterialFiles.TransparentStatusBar"
android:visibleToInstantApps="true"
tools:ignore="UnusedAttribute">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="inode/directory" />
<data android:mimeType="resource/folder" />
<data android:mimeType="vnd.android.document/directory" />
</intent-filter>
<!-- @see android.apps.file.MimeTypes#isSupportedArchive(String) -->
<!--
~ We don't really support content URI archives.
~ TODO: Figure out a good way to allow choosing this activity only in our app, or
~ support content URI archives.
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/gzip" />
<data android:mimeType="application/java-archive" />
<data android:mimeType="application/rar" />
<data android:mimeType="application/zip" />
<data android:mimeType="application/vnd.android.package-archive" />
<data android:mimeType="application/vnd.debian.binary-package" />
<data android:mimeType="application/x-7z-compressed" />
<data android:mimeType="application/x-bzip2" />
<data android:mimeType="application/x-compress" />
<data android:mimeType="application/x-cpio" />
<data android:mimeType="application/x-deb" />
<data android:mimeType="application/x-debian-package" />
<data android:mimeType="application/x-gtar" />
<data android:mimeType="application/x-gtar-compressed" />
<data android:mimeType="application/x-java-archive" />
<data android:mimeType="application/x-lzma" />
<data android:mimeType="application/x-tar" />
<data android:mimeType="application/x-xz" />
</intent-filter>
-->
<!-- @see https://android.googlesource.com/platform/packages/apps/DocumentsUI/+/master/AndroidManifest.xml -->
<intent-filter>
<action android:name="android.intent.action.OPEN_DOCUMENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="*/*" />
</intent-filter>
<!--
~ Unusable until we implement DocumentsProvider.
<intent-filter>
<action android:name="android.intent.action.CREATE_DOCUMENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="*/*" />
</intent-filter>
-->
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="*/*" />
</intent-filter>
<!--
~ Unusable until we implement DocumentsProvider.
<intent-filter>
<action android:name="android.intent.action.OPEN_DOCUMENT_TREE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
-->
<intent-filter>
<action android:name="android.apps.intent.action.VIEW_DOWNLOADS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity
android:name="android.apps.filelist.OpenFileAsDialogActivity"
android:autoRemoveFromRecents="true"
android:icon="@drawable/open_as_icon"
android:label="@string/file_open_as_title"
android:theme="@style/Theme.MaterialFiles.Translucent" />
<activity
android:name="android.apps.ftpserver.FtpServerActivity"
android:label="@string/ftp_server_title"
android:launchMode="singleTop"
android:theme="@style/Theme.MaterialFiles">
<intent-filter>
<action android:name="android.apps.intent.action.MANAGE_FTP_SERVER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="android.apps.filelist.FileListActivity" />
</activity>
<activity
android:name="apps.settings.SettingsActivity"
android:label="@string/settings_title"
android:launchMode="singleTop"
android:theme="@style/Theme.MaterialFiles">
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="android.apps.filelist.FileListActivity" />
</activity>
<activity
android:name="android.apps.settings.StandardDirectoriesActivity"
android:label="@string/settings_standard_directories_title"
android:launchMode="singleTop"
android:theme="@style/Theme.MaterialFiles">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="android.apps.settings.SettingsActivity" />
</activity>
<activity
android:name="android.apps.settings.BookmarkDirectoriesActivity"
android:label="@string/settings_bookmark_directories_title"
android:launchMode="singleTop"
android:theme="@style/Theme.MaterialFiles">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="android.apps.settings.SettingsActivity" />
</activity>
<activity
android:name="android.apps.about.AboutActivity"
android:label="@string/about_title"
android:launchMode="singleTop"
android:theme="@style/Theme.MaterialFiles">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.filemanagere.android.apps.filelist.FileListActivity" />
</activity>
<activity
android:name="android.apps.filejob.FileJobActionDialogActivity"
android:autoRemoveFromRecents="true"
android:theme="@style/Theme.MaterialFiles.Translucent" />
<activity
android:name="android.apps.filejob.FileJobConflictDialogActivity"
android:autoRemoveFromRecents="true"
android:theme="@style/Theme.MaterialFiles.Translucent" />
<activity
android:name="android.apps.viewer.text.TextEditorActivity"
android:label="@string/text_editor_title"
android:theme="@style/Theme.MaterialFiles">
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/ecmascript" />
<data android:mimeType="application/javascript" />
<data android:mimeType="application/json" />
<data android:mimeType="application/typescript" />
<data android:mimeType="application/x-sh" />
<data android:mimeType="application/x-shellscript" />
<data android:mimeType="application/xml" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
<activity
android:name="android.apps.viewer.image.ImageViewerActivity"
android:label="@string/image_viewer_title"
android:theme="@style/Theme.MaterialFiles.Immersive">
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
<service android:name="android.apps.filejob.FileJobService" />
<service android:name="android.apps.ftpserver.FtpServerService" />
<provider
android:name="android.apps.AppProvider"
android:authorities="@string/app_provider_authority"
android:exported="false" />
<provider
android:name="android.apps.file.FileProvider"
android:authorities="@string/file_provider_authority"
android:exported="false"
android:grantUriPermissions="true" />
<receiver android:name="android.apps.filejob.FileJobReceiver" />
<receiver android:name="android.apps.ftpserver.FtpServerReceiver" />
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
<!-- We need to reference a MD2 theme in XML for R8 to keep relevant resources. -->
<activity
android:name=".KeepMd2Resources"
android:theme="@style/Theme.MaterialFiles.Md2" />
</application>
</code></pre>
<p></p>
<p>ΠΠ½Π°Π΅ΡΠ΅ ΠΊΠΎΠ³ΠΎ-Π½ΠΈΠ±ΡΠ΄Ρ, ΠΊΡΠΎ ΠΌΠΎΠΆΠ΅Ρ ΠΎΡΠ²Π΅ΡΠΈΡΡ?
ΠΎΡΠΈΠ±ΠΊΠ° ΡΠ±ΠΎΡΠ° Π² AndroidManifest.xml</p>
<p>AAPT: ΠΎΡΠΈΠ±ΠΊΠ°: Π°ΡΡΠΈΠ±ΡΡ android: requestLegacyExternalStorage Π½Π΅ Π½Π°ΠΉΠ΄Π΅Π½.</p>
| 0debug |
how setEntity method works in java : I am develop a java program which will send my file in whole junk of file to my server for scanning via certain url http://ServerUrl:portNumber/file but i am getting this error in my eclipse compiler <br>The method setEntity(HttpEntity) in the type HttpEntityEnclosingRequestBase is not applicable for the arguments (InputStream). Is it because Java Inputstream cant use together with setEntity method? I cant read the file byte by byte because the file will not only have document file,it's might have .exe file as well. <br> Here is my source code <br>
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.*;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
public class SentFile {
public static void main(String [] args)
{
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://192.168.0.25:8008/file");
File file = new File("testScanFile.txt");
InputStream is = new FileInputStream(file);
post.setEntity(is);
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
}
}
| 0debug |
How can I create a parallel stream from an array? : <p>I can create a Stream from an array using <code>Arrays.stream(array)</code> or <code>Stream.of(values)</code>. Similarly, is it possible to create a ParallelStream directly from an array, <em>without creating an intermediate collection</em> as in <code>Arrays.asList(array).parallelStream()</code>?</p>
| 0debug |
How to clear Route Caching on server: Laravel 5.2.37 : <p>This is regarding route cache on localhost</p>
<h1>About Localhost</h1>
<p>I have 2 routes in my route.php file. Both are working fine. No problem in that. I was learning route:clear and route:cache and found a small problem below.</p>
<p>if I comment any one route in my route.php file and then run below command</p>
<pre><code>php artisan route:cache
</code></pre>
<p>This will keep the route disabled because the route list is in cache now. Now, go to route.php file and try to remove commented route and then try to run that enabled url. still it will show 404 because I need to remove cache by using below command</p>
<pre><code>php artisan route:clear
</code></pre>
<p>So far everything is understood in localhost. No problem in that.</p>
<h1>After deploying on shared hosting server on godaddy</h1>
<p>Question : How can I remove the route cache on server?</p>
| 0debug |
static int vp3_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb;
static int counter = 0;
int i;
init_get_bits(&gb, buf, buf_size * 8);
if (s->theora && get_bits1(&gb))
{
#if 1
av_log(avctx, AV_LOG_ERROR, "Header packet passed to frame decoder, skipping\n");
return -1;
#else
int ptype = get_bits(&gb, 7);
skip_bits(&gb, 6*8);
switch(ptype)
{
case 1:
theora_decode_comments(avctx, gb);
break;
case 2:
theora_decode_tables(avctx, gb);
init_dequantizer(s);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype);
}
return buf_size;
#endif
}
s->keyframe = !get_bits1(&gb);
if (!s->theora)
skip_bits(&gb, 1);
s->last_quality_index = s->quality_index;
s->quality_index = get_bits(&gb, 6);
if (s->theora >= 0x030200)
skip_bits1(&gb);
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n",
s->keyframe?"key":"", counter, s->quality_index);
counter++;
if (s->quality_index != s->last_quality_index) {
init_dequantizer(s);
init_loop_filter(s);
}
if (s->keyframe) {
if (!s->theora)
{
skip_bits(&gb, 4);
skip_bits(&gb, 4);
if (s->version)
{
s->version = get_bits(&gb, 5);
if (counter == 1)
av_log(s->avctx, AV_LOG_DEBUG, "VP version: %d\n", s->version);
}
}
if (s->version || s->theora)
{
if (get_bits1(&gb))
av_log(s->avctx, AV_LOG_ERROR, "Warning, unsupported keyframe coding type?!\n");
skip_bits(&gb, 2);
}
if (s->last_frame.data[0] == s->golden_frame.data[0]) {
if (s->golden_frame.data[0])
avctx->release_buffer(avctx, &s->golden_frame);
s->last_frame= s->golden_frame;
} else {
if (s->golden_frame.data[0])
avctx->release_buffer(avctx, &s->golden_frame);
if (s->last_frame.data[0])
avctx->release_buffer(avctx, &s->last_frame);
}
s->golden_frame.reference = 3;
if(avctx->get_buffer(avctx, &s->golden_frame) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n");
return -1;
}
memcpy(&s->current_frame, &s->golden_frame, sizeof(AVFrame));
if (!s->pixel_addresses_inited)
{
if (!s->flipped_image)
vp3_calculate_pixel_addresses(s);
else
theora_calculate_pixel_addresses(s);
}
} else {
s->current_frame.reference = 3;
if(avctx->get_buffer(avctx, &s->current_frame) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "vp3: get_buffer() failed\n");
return -1;
}
}
s->current_frame.qscale_table= s->qscale_table;
s->current_frame.qstride= 0;
{START_TIMER
init_frame(s, &gb);
STOP_TIMER("init_frame")}
#if KEYFRAMES_ONLY
if (!s->keyframe) {
memcpy(s->current_frame.data[0], s->golden_frame.data[0],
s->current_frame.linesize[0] * s->height);
memcpy(s->current_frame.data[1], s->golden_frame.data[1],
s->current_frame.linesize[1] * s->height / 2);
memcpy(s->current_frame.data[2], s->golden_frame.data[2],
s->current_frame.linesize[2] * s->height / 2);
} else {
#endif
{START_TIMER
if (unpack_superblocks(s, &gb)){
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_superblocks\n");
return -1;
}
STOP_TIMER("unpack_superblocks")}
{START_TIMER
if (unpack_modes(s, &gb)){
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_modes\n");
return -1;
}
STOP_TIMER("unpack_modes")}
{START_TIMER
if (unpack_vectors(s, &gb)){
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_vectors\n");
return -1;
}
STOP_TIMER("unpack_vectors")}
{START_TIMER
if (unpack_dct_coeffs(s, &gb)){
av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n");
return -1;
}
STOP_TIMER("unpack_dct_coeffs")}
{START_TIMER
reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height);
if ((avctx->flags & CODEC_FLAG_GRAY) == 0) {
reverse_dc_prediction(s, s->u_fragment_start,
s->fragment_width / 2, s->fragment_height / 2);
reverse_dc_prediction(s, s->v_fragment_start,
s->fragment_width / 2, s->fragment_height / 2);
}
STOP_TIMER("reverse_dc_prediction")}
{START_TIMER
for (i = 0; i < s->macroblock_height; i++)
render_slice(s, i);
STOP_TIMER("render_fragments")}
{START_TIMER
apply_loop_filter(s);
STOP_TIMER("apply_loop_filter")}
#if KEYFRAMES_ONLY
}
#endif
*data_size=sizeof(AVFrame);
*(AVFrame*)data= s->current_frame;
if ((s->last_frame.data[0]) &&
(s->last_frame.data[0] != s->golden_frame.data[0]))
avctx->release_buffer(avctx, &s->last_frame);
memcpy(&s->last_frame, &s->current_frame, sizeof(AVFrame));
s->current_frame.data[0]= NULL;
return buf_size;
}
| 1threat |
TypeScript + ES6 Map + Index signature of object type implicitly has an 'any' type : <p>I have the following code in TypeScript:</p>
<pre><code>export class Config
{
private options = new Map<string, string>();
constructor() {
}
public getOption(name: string): string {
return this.options[name]; // <-- This line causes the error.
}
}
</code></pre>
<p>And the compiler is giving me this error:</p>
<p><code>Error:(10, 16) TS7017: Index signature of object type implicitly has an 'any' type.</code></p>
<p>The Map is 'possible' through es6-shim. I am not quite sure what is going on here. Actually this Map confuses me a little. Map is supposed to come from es6-shim which is supposed to implement es6 functionality. But es6 doesn't have static types, right? So, why the Map expects the key/value types as generic arguments? I have seen some people adding a 'noImplicitAny' flag but I want to solve the problem, not ignore it.</p>
<p>Thank you.</p>
| 0debug |
Why was I not able to access window or console in a javascript file without prefixing with .this? : <p>I was working in a javascript file where I was unable to use <code>window</code> or <code>console</code> to find out the value of variables. I had to write <code>this.window</code> or <code>this.console</code> instead.</p>
<p>What was going on here? I thought that window was always possible?</p>
<p>PS. This was within a function passed in angular.extend.</p>
| 0debug |
What does "Program type already present" mean? : <p>I'm trying to build an app in Android Studio. After adding the Eclipse Paho library as a gradle dependency(or is it Maven? I'm new to the Android ecosystem), I got the following error:</p>
<pre><code>Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
Message{kind=ERROR, text=Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat, sources=[Unknown source file], tool name=Optional.of(D8)}
</code></pre>
<p>I've checked many different StackOverflow questions relating to this error, but the answers are all specific to certain libraries. <strong>I'm looking not only for a solution to the error, but an understanding of what the error <em>means</em>.</strong> That way it'll be easier for people to figure out solutions for their specific cases. So far, no answer has provided that.</p>
<p>From other StackOverflow answers, I've gathered that it has something to do with my gradle file. So, here's app/build.gradle:</p>
<pre><code>apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "---REDACTED FOR PRIVACY---"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:support-media-compat:27.1.0'
implementation 'com.android.support:support-v13:27.1.0'
implementation 'com.google.android.gms:play-services-maps:12.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.0.2'
}
repositories {
maven { url 'https://repo.eclipse.org/content/repositories/paho-releases/' }
}
</code></pre>
| 0debug |
def ntimes_list(nums,n):
result = map(lambda x:n*x, nums)
return list(result) | 0debug |
Disable specific dates of day in Android date picker : <p>I'm using the datePicker and I can disable last days of today and later days after 30 days by the following code:</p>
<pre><code>DatePickerDialog datePicker = new DatePickerDialog();
Calendar calender = Calendar.getInstance();
long today = calender.getTimeInMillis();
final long oneDay = 24 * 60 * 60 * 1000L;
Date previousDays = new Date(today - 1000);
datePicker.setMinDate(DateToCalendar(previousDays));
Date nextMonth = new Date(today + 30 * oneDay);
datePicker.setMaxDate(DateToCalendar(nextMonth));
</code></pre>
<p>If I want to disable Friday of every month, how can I do this?</p>
| 0debug |
void do_subfe (void)
{
T0 = T1 + ~T0 + xer_ca;
if (likely(T0 >= T1 && (xer_ca == 0 || T0 != T1))) {
xer_ca = 0;
} else {
xer_ca = 1;
}
}
| 1threat |
ThreadPool *thread_pool_new(AioContext *ctx)
{
ThreadPool *pool = g_new(ThreadPool, 1);
thread_pool_init_one(pool, ctx);
return pool;
}
| 1threat |
Understanding relative position in css : <p>Following this <a href="https://www.w3schools.com/css/css_positioning.asp" rel="nofollow noreferrer">link</a>.</p>
<p>It states:</p>
<blockquote>
<p>An element with position: relative; is positioned relative to its normal position.</p>
</blockquote>
<p>How can we define 'normal position'? Is it in context of parent element or overall screen(viewport)?</p>
| 0debug |
What is bots in Xcode 9 and how to use it? : I have read about the Xcode 9, there is some interesting term bots, which will do the CI/CD works for you but didn't got any proper guide. could any one help me to find the configuration guide on it.
Thanks in advance. | 0debug |
static int proxy_unlinkat(FsContext *ctx, V9fsPath *dir,
const char *name, int flags)
{
int ret;
V9fsString fullname;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir->data, name);
ret = proxy_remove(ctx, fullname.data);
v9fs_string_free(&fullname);
return ret;
}
| 1threat |
static int ide_qdev_init(DeviceState *qdev, DeviceInfo *base)
{
IDEDevice *dev = DO_UPCAST(IDEDevice, qdev, qdev);
IDEDeviceInfo *info = DO_UPCAST(IDEDeviceInfo, qdev, base);
IDEBus *bus = DO_UPCAST(IDEBus, qbus, qdev->parent_bus);
if (!dev->conf.bs) {
fprintf(stderr, "%s: no drive specified\n", qdev->info->name);
goto err;
}
if (dev->unit == -1) {
dev->unit = bus->master ? 1 : 0;
}
switch (dev->unit) {
case 0:
if (bus->master) {
fprintf(stderr, "ide: tried to assign master twice\n");
goto err;
}
bus->master = dev;
break;
case 1:
if (bus->slave) {
fprintf(stderr, "ide: tried to assign slave twice\n");
goto err;
}
bus->slave = dev;
break;
default:
goto err;
}
return info->init(dev);
err:
return -1;
}
| 1threat |
How to insert today's Date and Time into python script or Jupyter Notebook : I am creating a python app (DASH app) and I would like insert **Today's DATE and TIME**.
Could you please help me on adding it to my app?
Thanks, | 0debug |
Use of semicolons in ES6 : <p>I was under the impression semicolons became obsolete with ES6. However, I came across this today:</p>
<p>Doesn't work:</p>
<pre><code>let i = 0
[0, 1, 2, 3, 4, 5, 6].forEach(item => console.log(item))
</code></pre>
<p>Works:</p>
<pre><code>let i = 0;
[0, 1, 2, 3, 4, 5, 6].forEach(item => console.log(item))
</code></pre>
<p>Why is the semicolon necessary here, and when should I use them?</p>
| 0debug |
writev_f(int argc, char **argv)
{
struct timeval t1, t2;
int Cflag = 0, qflag = 0;
int c, cnt;
char *buf;
int64_t offset;
int total;
int nr_iov;
int pattern = 0xcd;
QEMUIOVector qiov;
while ((c = getopt(argc, argv, "CqP:")) != EOF) {
switch (c) {
case 'C':
Cflag = 1;
break;
case 'q':
qflag = 1;
break;
case 'P':
pattern = atoi(optarg);
break;
default:
return command_usage(&writev_cmd);
}
}
if (optind > argc - 2)
return command_usage(&writev_cmd);
offset = cvtnum(argv[optind]);
if (offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
return 0;
}
optind++;
if (offset & 0x1ff) {
printf("offset %lld is not sector aligned\n",
(long long)offset);
return 0;
}
nr_iov = argc - optind;
buf = create_iovec(&qiov, &argv[optind], nr_iov, pattern);
gettimeofday(&t1, NULL);
cnt = do_aio_writev(&qiov, offset, &total);
gettimeofday(&t2, NULL);
if (cnt < 0) {
printf("writev failed: %s\n", strerror(-cnt));
return 0;
}
if (qflag)
return 0;
t2 = tsub(t2, t1);
print_report("wrote", &t2, offset, qiov.size, total, cnt, Cflag);
qemu_io_free(buf);
return 0;
}
| 1threat |
Benefit of constexpr on non-changing expressions : <p>So I understand that the use of <code>constexpr</code> in C++ is for defined expressions that are be evaluated at compile time, and more obviously to declare a variable or function as a constant expression. My confusion comes from understanding any benefits of using it for simple functions that will not change.</p>
<p>Suppose you have a function to simply square a value...</p>
<pre><code>int square(int x) {
return x * x;
}
</code></pre>
<p>Typically that will never change, or be overridden, however, I've seen people say that it would be better practice to instead define it as...</p>
<pre><code>constexpr int square(int x) {
return x * x;
}
</code></pre>
<p>To me, this seems like such a trivial change. Can anyone enlighten me on serious advantages of declaring such simple expressions as <code>constexpr</code>?</p>
| 0debug |
read_insn_microblaze (bfd_vma memaddr,
struct disassemble_info *info,
struct op_code_struct **opr)
{
unsigned char ibytes[4];
int status;
struct op_code_struct * op;
unsigned long inst;
status = info->read_memory_func (memaddr, ibytes, 4, info);
if (status != 0)
{
info->memory_error_func (status, memaddr, info);
return 0;
}
if (info->endian == BFD_ENDIAN_BIG)
inst = (ibytes[0] << 24) | (ibytes[1] << 16) | (ibytes[2] << 8) | ibytes[3];
else if (info->endian == BFD_ENDIAN_LITTLE)
inst = (ibytes[3] << 24) | (ibytes[2] << 16) | (ibytes[1] << 8) | ibytes[0];
else
abort ();
for (op = opcodes; op->name != 0; op ++)
if (op->bit_sequence == (inst & op->opcode_mask))
break;
*opr = op;
return inst;
}
| 1threat |
void ff_h264_h_lpf_luma_inter_msa(uint8_t *data, int img_width,
int alpha, int beta, int8_t *tc)
{
uint8_t bs0 = 1;
uint8_t bs1 = 1;
uint8_t bs2 = 1;
uint8_t bs3 = 1;
if (tc[0] < 0)
bs0 = 0;
if (tc[1] < 0)
bs1 = 0;
if (tc[2] < 0)
bs2 = 0;
if (tc[3] < 0)
bs3 = 0;
avc_loopfilter_luma_inter_edge_ver_msa(data,
bs0, bs1, bs2, bs3,
tc[0], tc[1], tc[2], tc[3],
alpha, beta, img_width);
}
| 1threat |
Unknown behaviour of OR operator in C++ : <p>I have this code running by chance and when i put anything as the answer it is showing me correct. I know we have to put ans before YES and yay, but this code was compiled too, as i mentioned if i put any word as the input the output is correct:</p>
<pre><code>string ans;
cin >> ans;
if(ans == "yes" || "YES" || "yay") {
cout << "Correct";
}else {
cout << "Incorrect";
}
</code></pre>
| 0debug |
convert crc javascript func to c$ func : <p>i have a problem whit c#,
please someone convert this javascript function to c#.</p>
<pre><code>function mycrc(str) {
var c;
var crcTable = [];
for(var n = 0; n < 256; n++){
c = n;
for(var k = 0; k < 8; k++){
c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
}
crcTable[n] = c;
}
var crc = 0 ^ (-1);
for (var i = 0; i < str.length; i++ ) {
crc = (crc >>> 8) ^ crcTable[(crc ^ str.charCodeAt(i)) & 0xFF];
}
return (crc ^ (-1)) >>> 0;
}
</code></pre>
| 0debug |
Purpose of reference template arguments : <p>You can use a reference to a global object as a template parameter. For example thus:</p>
<pre><code>class A {};
template<A& x>
void fun()
{
}
A alpha;
int main()
{
fun<alpha>();
}
</code></pre>
<p>In what situation might a reference template argument be useful?</p>
| 0debug |
Android Sqlite result start with zero : <p>Morning </p>
<p>Hopefully this will be a generically simple question for someone</p>
<p>I currently have a database within my Android studio project of which it contains times e.g. the hours in a 24 clock standard.</p>
<p>When searching for an hour which starts with a zero e.g. 09 I simply get the result 0 but If I search for 13 I will then receive the correct result of 13.</p>
<p>I Just wanted to know if there is a way of searching for results which start with a zero?</p>
<p>Thanks</p>
| 0debug |
Python multiprocessing with generator : <p>I'm trying to process a file(every line is a json document). The size of the file can go up to 100's of mbs to gb's. So I wrote a generator code to fetch each document line by line from file.</p>
<pre><code>def jl_file_iterator(file):
with codecs.open(file, 'r', 'utf-8') as f:
for line in f:
document = json.loads(line)
yield document
</code></pre>
<p>My system has 4 cores, So I would like to process 4 lines of the file in parallel. Currently I have this code which takes 4 lines at a time and calls the code for parallel processing</p>
<pre><code>threads = 4
files, i = [], 1
for jl in jl_file_iterator(input_path):
files.append(jl)
if i % (threads) == 0:
# pool.map(processFile, files)
parallelProcess(files, o)
files = []
i += 1
if files:
parallelProcess(files, o)
files = []
</code></pre>
<p>This is my code where actual processing happens</p>
<pre><code>def parallelProcess(files, outfile):
processes = []
for i in range(len(files)):
p = Process(target=processFile, args=(files[i],))
processes.append(p)
p.start()
for i in range(len(files)):
processes[i].join()
def processFile(doc):
extractors = {}
... do some processing on doc
o.write(json.dumps(doc) + '\n')
</code></pre>
<p>As you can see I wait for all the 4 lines to finish processing before I send the next 4 files to process. But what I would like to do is as soon as one process finish processing file I want to start the next line to be assigned to realeased processor. How do I do that? </p>
<p>PS: The problem is since its an generator I cannot load all the files and use something like map to run the processes. </p>
<p>Thanks for your help</p>
| 0debug |
Please, help me optimize this MySQL query which takes more than 4s... :( : SELECT
COUNT(*) AS dctrn_count
FROM
(
SELECT
DISTINCT id_4
FROM
(
SELECT
1 / LOCATE(
?,
CONCAT(
CONCAT(
CONCAT(w0_.firstname, ' '),
CONCAT(w0_.lastname, ' ')
),
w1_.fullname
)
) AS sclr_0,
1 / LOCATE(
?,
CONCAT(
CONCAT(
CONCAT(w0_.firstname, ' '),
CONCAT(w0_.lastname, ' ')
),
w1_.shortname
)
) AS sclr_1,
1 / LOCATE(
?,
CONCAT(
CONCAT(
CONCAT(w0_.nickname, ' '),
CONCAT(w0_.lastname, ' ')
),
w1_.fullname
)
) AS sclr_2,
1 / LOCATE(
?,
CONCAT(
CONCAT(
CONCAT(w0_.nickname, ' '),
CONCAT(w0_.lastname, ' ')
),
w1_.shortname
)
) AS sclr_3,
w0_.id AS id_4,
w0_.slug AS slug_5,
w0_.firstname AS firstname_6,
w0_.lastname AS lastname_7,
w0_.nickname AS nickname_8,
w0_.gender AS gender_9,
w0_.email AS email_10,
w0_.email_checked AS email_checked_11,
w0_.title_en AS title_en_12,
w0_.short_title AS short_title_13,
w0_.start_date AS start_date_14,
w0_.end_date AS end_date_15,
w0_.is_board_member AS is_board_member_16,
w0_.board_date AS board_date_17,
w0_.created AS created_18,
w0_.updated AS updated_19,
w0_.published AS published_20,
w1_.id AS id_21,
w1_.fullname AS fullname_22,
w1_.shortname AS shortname_23,
w1_.slug AS slug_24,
w1_.workforce AS workforce_25,
w1_.fiscal_year_end AS fiscal_year_end_26,
w1_.about_en AS about_en_27,
w1_.about_fr AS about_fr_28,
w1_.stock_symbol AS stock_symbol_29,
w1_.stock_exchange AS stock_exchange_30,
w1_.is_to_watch AS is_to_watch_31,
w1_.count_executives AS count_executives_32,
w1_.count_following AS count_following_33,
w1_.review_class AS review_class_34,
w1_.created AS created_35,
w1_.updated AS updated_36,
w2_.id AS id_37,
w3_.id AS id_38,
w3_.country_name AS country_name_39,
w3_.country_name_fr AS country_name_fr_40,
w3_.country_name_en AS country_name_en_41,
w3_.slug AS slug_42,
w4_.id AS id_43,
w4_.city_name AS city_name_44,
w4_.slug AS slug_45,
w4_.is_top AS is_top_46,
w5_.id AS id_47,
w5_.firstname AS firstname_48,
w5_.lastname AS lastname_49,
w5_.nickname AS nickname_50,
w5_.birth_date AS birth_date_51,
w5_.twitter_account AS twitter_account_52,
w5_.twitter_url AS twitter_url_53,
w5_.biography_fr AS biography_fr_54,
w5_.biography_en AS biography_en_55,
w5_.created AS created_56,
w5_.updated AS updated_57,
w6_.id AS id_58,
w6_.web_text AS web_text_59,
w6_.created AS created_60
FROM
wmn_executive w0_
INNER JOIN wmn_company w1_ ON w0_.company_id = w1_.id
INNER JOIN wmn_industry w7_ ON w1_.industry_id = w7_.id
INNER JOIN wmn_location w2_ ON w1_.location_id = w2_.id
INNER JOIN wmn_country w3_ ON w2_.country_id = w3_.id
INNER JOIN wmn_city w4_ ON w2_.city_id = w4_.id
LEFT JOIN wmn_executive_link w5_ ON w0_.link_id = w5_.id
LEFT JOIN wmn_web_executive w6_ ON w0_.id = w6_.executive_id
WHERE
w0_.original_id IS NULL
AND w0_.user_id IS NOT NULL
AND (
w0_.firstname LIKE ?
OR w0_.lastname LIKE ?
OR w0_.nickname LIKE ?
OR w1_.fullname LIKE ?
OR w1_.shortname LIKE ?
OR w0_.title_en LIKE ?
OR w0_.short_title LIKE ?
OR w7_.industry_name_en LIKE ?
OR w7_.industry_name_fr LIKE ?
OR w3_.country_name_en LIKE ?
OR w3_.country_name_fr LIKE ?
OR w4_.city_name LIKE ?
)
ORDER BY
sclr_0 DESC,
sclr_1 DESC,
sclr_2 DESC,
sclr_3 DESC
) dctrn_result
) dctrn_table | 0debug |
iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num,
QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb,
void *opaque)
{
IscsiLun *iscsilun = bs->opaque;
struct iscsi_context *iscsi = iscsilun->iscsi;
IscsiAIOCB *acb;
size_t qemu_read_size;
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
int i;
#endif
int ret;
uint64_t lba;
uint32_t num_sectors;
qemu_read_size = BDRV_SECTOR_SIZE * (size_t)nb_sectors;
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
trace_iscsi_aio_readv(iscsi, sector_num, nb_sectors, opaque, acb);
acb->iscsilun = iscsilun;
acb->qiov = qiov;
acb->canceled = 0;
acb->bh = NULL;
acb->status = -EINPROGRESS;
acb->read_size = qemu_read_size;
acb->buf = NULL;
acb->read_offset = 0;
if (iscsilun->block_size > BDRV_SECTOR_SIZE) {
uint64_t bdrv_offset = BDRV_SECTOR_SIZE * sector_num;
acb->read_offset = bdrv_offset % iscsilun->block_size;
}
num_sectors = (qemu_read_size + iscsilun->block_size
+ acb->read_offset - 1)
/ iscsilun->block_size;
acb->task = malloc(sizeof(struct scsi_task));
if (acb->task == NULL) {
error_report("iSCSI: Failed to allocate task for scsi READ16 "
"command. %s", iscsi_get_error(iscsi));
qemu_aio_release(acb);
return NULL;
}
memset(acb->task, 0, sizeof(struct scsi_task));
acb->task->xfer_dir = SCSI_XFER_READ;
lba = sector_qemu2lun(sector_num, iscsilun);
acb->task->expxferlen = qemu_read_size;
switch (iscsilun->type) {
case TYPE_DISK:
acb->task->cdb_size = 16;
acb->task->cdb[0] = 0x88;
*(uint32_t *)&acb->task->cdb[2] = htonl(lba >> 32);
*(uint32_t *)&acb->task->cdb[6] = htonl(lba & 0xffffffff);
*(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors);
break;
default:
acb->task->cdb_size = 10;
acb->task->cdb[0] = 0x28;
*(uint32_t *)&acb->task->cdb[2] = htonl(lba);
*(uint16_t *)&acb->task->cdb[7] = htons(num_sectors);
break;
}
ret = iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task,
iscsi_aio_read16_cb,
NULL,
acb);
if (ret != 0) {
scsi_free_scsi_task(acb->task);
qemu_aio_release(acb);
return NULL;
}
#if defined(LIBISCSI_FEATURE_IOVECTOR)
scsi_task_set_iov_in(acb->task, (struct scsi_iovec*) acb->qiov->iov, acb->qiov->niov);
#else
for (i = 0; i < acb->qiov->niov; i++) {
scsi_task_add_data_in_buffer(acb->task,
acb->qiov->iov[i].iov_len,
acb->qiov->iov[i].iov_base);
}
#endif
iscsi_set_events(iscsilun);
return &acb->common;
}
| 1threat |
query = 'SELECT * FROM customers WHERE email = ' + email_input | 1threat |
void *qemu_malloc(size_t size)
{
return malloc(size);
}
| 1threat |
DISAS_INSN(frestore)
{
qemu_assert(0, "FRESTORE not implemented");
}
| 1threat |
static void *rcu_read_stress_test(void *arg)
{
int i;
int itercnt = 0;
struct rcu_stress *p;
int pc;
long long n_reads_local = 0;
volatile int garbage = 0;
rcu_register_thread();
*(struct rcu_reader_data **)arg = &rcu_reader;
while (goflag == GOFLAG_INIT) {
g_usleep(1000);
}
while (goflag == GOFLAG_RUN) {
rcu_read_lock();
p = atomic_rcu_read(&rcu_stress_current);
if (p->mbtest == 0) {
n_mberror++;
}
rcu_read_lock();
for (i = 0; i < 100; i++) {
garbage++;
}
rcu_read_unlock();
pc = p->pipe_count;
rcu_read_unlock();
if ((pc > RCU_STRESS_PIPE_LEN) || (pc < 0)) {
pc = RCU_STRESS_PIPE_LEN;
}
atomic_inc(&rcu_stress_count[pc]);
n_reads_local++;
if ((++itercnt % 0x1000) == 0) {
synchronize_rcu();
}
}
atomic_add(&n_reads, n_reads_local);
rcu_unregister_thread();
return NULL;
}
| 1threat |
I recieved these errors while coding in javascript can somebody help me : Error:expected an identifier and instead saw '<'
expected')' and instead saw 'span'
missing semicolon
expected an identifier and instead saw ')'
syntax error
Code:
(function() {
'use strict';
// Your code here...
})(<span id="sbBalance">);
<span id="sbBalanceAmount">14</span> SB</span>; | 0debug |
Error: EACCES: permission denied when trying to install ESLint using npm : <p>I'm trying to install <a href="http://eslint.org/docs/user-guide/getting-started">ESLint</a> with npm by going:</p>
<pre><code>npm install -g eslint
</code></pre>
<p>However I get the following error:</p>
<pre><code>Deans-Air:~ deangibson$ npm install -g eslint
npm ERR! tar.unpack untar error /Users/deangibson/.npm/eslint/2.4.0/package.tgz
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "eslint"
npm ERR! node v4.2.3
npm ERR! npm v2.14.7
npm ERR! path /usr/local/lib/node_modules/eslint
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/eslint'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/eslint']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/eslint',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/eslint',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR! 'FSReqWrap.oncomplete (fs.js:82:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/deangibson/npm-debug.log
</code></pre>
<p>And to be honest I get this every single time I try and install something with npm. Sometimes using 'sudo' works, sometimes it doesn't... How can I fix this once and for all?</p>
| 0debug |
static void text_console_update(void *opaque, console_ch_t *chardata)
{
QemuConsole *s = (QemuConsole *) opaque;
int i, j, src;
if (s->text_x[0] <= s->text_x[1]) {
src = (s->y_base + s->text_y[0]) * s->width;
chardata += s->text_y[0] * s->width;
for (i = s->text_y[0]; i <= s->text_y[1]; i ++)
for (j = 0; j < s->width; j ++, src ++)
console_write_ch(chardata ++, s->cells[src].ch |
(s->cells[src].t_attrib.fgcol << 12) |
(s->cells[src].t_attrib.bgcol << 8) |
(s->cells[src].t_attrib.bold << 21));
dpy_text_update(s, s->text_x[0], s->text_y[0],
s->text_x[1] - s->text_x[0], i - s->text_y[0]);
s->text_x[0] = s->width;
s->text_y[0] = s->height;
s->text_x[1] = 0;
s->text_y[1] = 0;
}
if (s->cursor_invalidate) {
dpy_text_cursor(s, s->x, s->y);
s->cursor_invalidate = 0;
}
}
| 1threat |
Cannot load JPEG with java created by Samsung phone : <p>I am having trouble loading a JPEG image shot by a Samsung Galaxy S7 edge with javafx (image available at <a href="https://www.dropbox.com/s/w6lvdnqwcgw321s/20171122_140732.jpg?dl=0" rel="noreferrer">https://www.dropbox.com/s/w6lvdnqwcgw321s/20171122_140732.jpg?dl=0</a>). I am using the Image class to load the image.</p>
<pre><code>import java.io.FileInputStream;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class JPEGProblem extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage window) throws Exception {
Image img = new Image(new FileInputStream("/path/to/image.jpg"));
if (img.getException() != null)
throw img.getException();
ImageView imgView = new ImageView(img);
window.setScene(new Scene(new Pane(imgView)));
window.show();
}
}
</code></pre>
<p>The constructor call, which tries to load the image prints the following error message on the error stream:</p>
<blockquote>
<p>Feb 04, 2018 11:48:23 PM
com.sun.javafx.tk.quantum.PrismImageLoader2$PrismLoadListener imageLoadWarning
WARNING: Invalid SOS parameters for sequential JPEG</p>
</blockquote>
<p>The exception, that I get from the image object is an IOException with the message:</p>
<blockquote>
<p>Unsupported marker type 0x65</p>
</blockquote>
<p>I've done some research and it turns out, that it is a known issue with panorama images shot by a samsung phone. As pointed out in this thread: <a href="https://forums.adobe.com/thread/2131432" rel="noreferrer">https://forums.adobe.com/thread/2131432</a>, some of the 0xFF bytes, that indicate the following byte to be meta information rather than actual data are not escaped by adding a following 0x00 byte after the 0xFF.<br>
However I tried to write code that manipulates the image data in order to add the missing 0x00 bytes, but that turned out to be far more complicated, than expected and I don't want to write my own JPEG parser/loader.<br>
There are some programs, that can display those invalid JPEG images e.g. Microsoft Fotos or Paint. It seems like they tolerate these invalid images, treating those spurious markers as content data.<br>
Is there any way to load these invalid images with java, without dealing with the single bytes myself?</p>
| 0debug |
int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
H264ParamSets *ps, int ignore_truncation)
{
AVBufferRef *sps_buf;
int profile_idc, level_idc, constraint_set_flags = 0;
unsigned int sps_id;
int i, log2_max_frame_num_minus4;
SPS *sps;
sps_buf = av_buffer_allocz(sizeof(*sps));
if (!sps_buf)
return AVERROR(ENOMEM);
sps = (SPS*)sps_buf->data;
sps->data_size = gb->buffer_end - gb->buffer;
if (sps->data_size > sizeof(sps->data)) {
av_log(avctx, AV_LOG_WARNING, "Truncating likely oversized SPS\n");
sps->data_size = sizeof(sps->data);
}
memcpy(sps->data, gb->buffer, sps->data_size);
profile_idc = get_bits(gb, 8);
constraint_set_flags |= get_bits1(gb) << 0;
constraint_set_flags |= get_bits1(gb) << 1;
constraint_set_flags |= get_bits1(gb) << 2;
constraint_set_flags |= get_bits1(gb) << 3;
constraint_set_flags |= get_bits1(gb) << 4;
constraint_set_flags |= get_bits1(gb) << 5;
skip_bits(gb, 2);
level_idc = get_bits(gb, 8);
sps_id = get_ue_golomb_31(gb);
if (sps_id >= MAX_SPS_COUNT) {
av_log(avctx, AV_LOG_ERROR, "sps_id %u out of range\n", sps_id);
goto fail;
}
sps->sps_id = sps_id;
sps->time_offset_length = 24;
sps->profile_idc = profile_idc;
sps->constraint_set_flags = constraint_set_flags;
sps->level_idc = level_idc;
sps->full_range = -1;
memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4));
memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8));
sps->scaling_matrix_present = 0;
sps->colorspace = 2;
if (sps->profile_idc == 100 ||
sps->profile_idc == 110 ||
sps->profile_idc == 122 ||
sps->profile_idc == 244 ||
sps->profile_idc == 44 ||
sps->profile_idc == 83 ||
sps->profile_idc == 86 ||
sps->profile_idc == 118 ||
sps->profile_idc == 128 ||
sps->profile_idc == 138 ||
sps->profile_idc == 144) {
sps->chroma_format_idc = get_ue_golomb_31(gb);
if (sps->chroma_format_idc > 3U) {
avpriv_request_sample(avctx, "chroma_format_idc %u",
sps->chroma_format_idc);
goto fail;
} else if (sps->chroma_format_idc == 3) {
sps->residual_color_transform_flag = get_bits1(gb);
if (sps->residual_color_transform_flag) {
av_log(avctx, AV_LOG_ERROR, "separate color planes are not supported\n");
goto fail;
}
}
sps->bit_depth_luma = get_ue_golomb(gb) + 8;
sps->bit_depth_chroma = get_ue_golomb(gb) + 8;
if (sps->bit_depth_chroma != sps->bit_depth_luma) {
avpriv_request_sample(avctx,
"Different chroma and luma bit depth");
goto fail;
}
if (sps->bit_depth_luma < 8 || sps->bit_depth_luma > 14 ||
sps->bit_depth_chroma < 8 || sps->bit_depth_chroma > 14) {
av_log(avctx, AV_LOG_ERROR, "illegal bit depth value (%d, %d)\n",
sps->bit_depth_luma, sps->bit_depth_chroma);
goto fail;
}
sps->transform_bypass = get_bits1(gb);
sps->scaling_matrix_present |= decode_scaling_matrices(gb, sps, NULL, 1,
sps->scaling_matrix4, sps->scaling_matrix8);
} else {
sps->chroma_format_idc = 1;
sps->bit_depth_luma = 8;
sps->bit_depth_chroma = 8;
}
log2_max_frame_num_minus4 = get_ue_golomb(gb);
if (log2_max_frame_num_minus4 < MIN_LOG2_MAX_FRAME_NUM - 4 ||
log2_max_frame_num_minus4 > MAX_LOG2_MAX_FRAME_NUM - 4) {
av_log(avctx, AV_LOG_ERROR,
"log2_max_frame_num_minus4 out of range (0-12): %d\n",
log2_max_frame_num_minus4);
goto fail;
}
sps->log2_max_frame_num = log2_max_frame_num_minus4 + 4;
sps->poc_type = get_ue_golomb_31(gb);
if (sps->poc_type == 0) {
unsigned t = get_ue_golomb(gb);
if (t>12) {
av_log(avctx, AV_LOG_ERROR, "log2_max_poc_lsb (%d) is out of range\n", t);
goto fail;
}
sps->log2_max_poc_lsb = t + 4;
} else if (sps->poc_type == 1) {
sps->delta_pic_order_always_zero_flag = get_bits1(gb);
sps->offset_for_non_ref_pic = get_se_golomb(gb);
sps->offset_for_top_to_bottom_field = get_se_golomb(gb);
sps->poc_cycle_length = get_ue_golomb(gb);
if ((unsigned)sps->poc_cycle_length >=
FF_ARRAY_ELEMS(sps->offset_for_ref_frame)) {
av_log(avctx, AV_LOG_ERROR,
"poc_cycle_length overflow %d\n", sps->poc_cycle_length);
goto fail;
}
for (i = 0; i < sps->poc_cycle_length; i++)
sps->offset_for_ref_frame[i] = get_se_golomb(gb);
} else if (sps->poc_type != 2) {
av_log(avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
goto fail;
}
sps->ref_frame_count = get_ue_golomb_31(gb);
if (avctx->codec_tag == MKTAG('S', 'M', 'V', '2'))
sps->ref_frame_count = FFMAX(2, sps->ref_frame_count);
if (sps->ref_frame_count > MAX_DELAYED_PIC_COUNT) {
av_log(avctx, AV_LOG_ERROR,
"too many reference frames %d\n", sps->ref_frame_count);
goto fail;
}
sps->gaps_in_frame_num_allowed_flag = get_bits1(gb);
sps->mb_width = get_ue_golomb(gb) + 1;
sps->mb_height = get_ue_golomb(gb) + 1;
sps->frame_mbs_only_flag = get_bits1(gb);
if (sps->mb_height >= INT_MAX / 2) {
av_log(avctx, AV_LOG_ERROR, "height overflow\n");
goto fail;
}
sps->mb_height *= 2 - sps->frame_mbs_only_flag;
if (!sps->frame_mbs_only_flag)
sps->mb_aff = get_bits1(gb);
else
sps->mb_aff = 0;
if ((unsigned)sps->mb_width >= INT_MAX / 16 ||
(unsigned)sps->mb_height >= INT_MAX / 16 ||
av_image_check_size(16 * sps->mb_width,
16 * sps->mb_height, 0, avctx)) {
av_log(avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
goto fail;
}
sps->direct_8x8_inference_flag = get_bits1(gb);
#ifndef ALLOW_INTERLACE
if (sps->mb_aff)
av_log(avctx, AV_LOG_ERROR,
"MBAFF support not included; enable it at compile-time.\n");
#endif
sps->crop = get_bits1(gb);
if (sps->crop) {
unsigned int crop_left = get_ue_golomb(gb);
unsigned int crop_right = get_ue_golomb(gb);
unsigned int crop_top = get_ue_golomb(gb);
unsigned int crop_bottom = get_ue_golomb(gb);
int width = 16 * sps->mb_width;
int height = 16 * sps->mb_height;
if (avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) {
av_log(avctx, AV_LOG_DEBUG, "discarding sps cropping, original "
"values are l:%d r:%d t:%d b:%d\n",
crop_left, crop_right, crop_top, crop_bottom);
sps->crop_left =
sps->crop_right =
sps->crop_top =
sps->crop_bottom = 0;
} else {
int vsub = (sps->chroma_format_idc == 1) ? 1 : 0;
int hsub = (sps->chroma_format_idc == 1 ||
sps->chroma_format_idc == 2) ? 1 : 0;
int step_x = 1 << hsub;
int step_y = (2 - sps->frame_mbs_only_flag) << vsub;
if (crop_left & (0x1F >> (sps->bit_depth_luma > 8)) &&
!(avctx->flags & AV_CODEC_FLAG_UNALIGNED)) {
crop_left &= ~(0x1F >> (sps->bit_depth_luma > 8));
av_log(avctx, AV_LOG_WARNING,
"Reducing left cropping to %d "
"chroma samples to preserve alignment.\n",
crop_left);
}
if (crop_left > (unsigned)INT_MAX / 4 / step_x ||
crop_right > (unsigned)INT_MAX / 4 / step_x ||
crop_top > (unsigned)INT_MAX / 4 / step_y ||
crop_bottom> (unsigned)INT_MAX / 4 / step_y ||
(crop_left + crop_right ) * step_x >= width ||
(crop_top + crop_bottom) * step_y >= height
) {
av_log(avctx, AV_LOG_ERROR, "crop values invalid %d %d %d %d / %d %d\n", crop_left, crop_right, crop_top, crop_bottom, width, height);
goto fail;
}
sps->crop_left = crop_left * step_x;
sps->crop_right = crop_right * step_x;
sps->crop_top = crop_top * step_y;
sps->crop_bottom = crop_bottom * step_y;
}
} else {
sps->crop_left =
sps->crop_right =
sps->crop_top =
sps->crop_bottom =
sps->crop = 0;
}
sps->vui_parameters_present_flag = get_bits1(gb);
if (sps->vui_parameters_present_flag) {
int ret = decode_vui_parameters(gb, avctx, sps);
if (ret < 0)
goto fail;
}
if (get_bits_left(gb) < 0) {
av_log(avctx, ignore_truncation ? AV_LOG_WARNING : AV_LOG_ERROR,
"Overread %s by %d bits\n", sps->vui_parameters_present_flag ? "VUI" : "SPS", -get_bits_left(gb));
if (!ignore_truncation)
goto fail;
}
if (!sps->bitstream_restriction_flag &&
(sps->ref_frame_count || avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT)) {
sps->num_reorder_frames = MAX_DELAYED_PIC_COUNT - 1;
for (i = 0; i < FF_ARRAY_ELEMS(level_max_dpb_mbs); i++) {
if (level_max_dpb_mbs[i][0] == sps->level_idc) {
sps->num_reorder_frames = FFMIN(level_max_dpb_mbs[i][1] / (sps->mb_width * sps->mb_height),
sps->num_reorder_frames);
break;
}
}
}
if (!sps->sar.den)
sps->sar.den = 1;
if (avctx->debug & FF_DEBUG_PICT_INFO) {
static const char csp[4][5] = { "Gray", "420", "422", "444" };
av_log(avctx, AV_LOG_DEBUG,
"sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%u/%u/%u/%u %s %s %"PRId32"/%"PRId32" b%d reo:%d\n",
sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type,
sps->ref_frame_count,
sps->mb_width, sps->mb_height,
sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"),
sps->direct_8x8_inference_flag ? "8B8" : "",
sps->crop_left, sps->crop_right,
sps->crop_top, sps->crop_bottom,
sps->vui_parameters_present_flag ? "VUI" : "",
csp[sps->chroma_format_idc],
sps->timing_info_present_flag ? sps->num_units_in_tick : 0,
sps->timing_info_present_flag ? sps->time_scale : 0,
sps->bit_depth_luma,
sps->bitstream_restriction_flag ? sps->num_reorder_frames : -1
);
}
if (ps->sps_list[sps_id] &&
!memcmp(ps->sps_list[sps_id]->data, sps_buf->data, sps_buf->size)) {
av_buffer_unref(&sps_buf);
} else {
remove_sps(ps, sps_id);
ps->sps_list[sps_id] = sps_buf;
}
return 0;
fail:
av_buffer_unref(&sps_buf);
return AVERROR_INVALIDDATA;
}
| 1threat |
void start_auth_sasl(VncState *vs)
{
const char *mechlist = NULL;
sasl_security_properties_t secprops;
int err;
char *localAddr, *remoteAddr;
int mechlistlen;
VNC_DEBUG("Initialize SASL auth %d\n", vs->csock);
if (!(localAddr = vnc_socket_local_addr("%s;%s", vs->csock)))
goto authabort;
if (!(remoteAddr = vnc_socket_remote_addr("%s;%s", vs->csock))) {
g_free(localAddr);
goto authabort;
}
err = sasl_server_new("vnc",
NULL,
NULL,
localAddr,
remoteAddr,
NULL,
SASL_SUCCESS_DATA,
&vs->sasl.conn);
g_free(localAddr);
g_free(remoteAddr);
localAddr = remoteAddr = NULL;
if (err != SASL_OK) {
VNC_DEBUG("sasl context setup failed %d (%s)",
err, sasl_errstring(err, NULL, NULL));
vs->sasl.conn = NULL;
goto authabort;
}
#ifdef CONFIG_VNC_TLS
if (vs->auth == VNC_AUTH_VENCRYPT &&
vs->subauth == VNC_AUTH_VENCRYPT_X509SASL) {
gnutls_cipher_algorithm_t cipher;
sasl_ssf_t ssf;
cipher = gnutls_cipher_get(vs->tls.session);
if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) {
VNC_DEBUG("%s", "cannot TLS get cipher size\n");
sasl_dispose(&vs->sasl.conn);
vs->sasl.conn = NULL;
goto authabort;
}
ssf *= 8;
err = sasl_setprop(vs->sasl.conn, SASL_SSF_EXTERNAL, &ssf);
if (err != SASL_OK) {
VNC_DEBUG("cannot set SASL external SSF %d (%s)\n",
err, sasl_errstring(err, NULL, NULL));
sasl_dispose(&vs->sasl.conn);
vs->sasl.conn = NULL;
goto authabort;
}
} else
#endif
vs->sasl.wantSSF = 1;
memset (&secprops, 0, sizeof secprops);
if (vs->vd->is_unix
#ifdef CONFIG_VNC_TLS
|| (vs->auth == VNC_AUTH_VENCRYPT &&
vs->subauth == VNC_AUTH_VENCRYPT_X509SASL)
#endif
) {
secprops.min_ssf = 0;
secprops.max_ssf = 0;
secprops.maxbufsize = 8192;
secprops.security_flags = 0;
} else {
secprops.min_ssf = 56;
secprops.max_ssf = 100000;
secprops.maxbufsize = 8192;
secprops.security_flags =
SASL_SEC_NOANONYMOUS | SASL_SEC_NOPLAINTEXT;
}
err = sasl_setprop(vs->sasl.conn, SASL_SEC_PROPS, &secprops);
if (err != SASL_OK) {
VNC_DEBUG("cannot set SASL security props %d (%s)\n",
err, sasl_errstring(err, NULL, NULL));
sasl_dispose(&vs->sasl.conn);
vs->sasl.conn = NULL;
goto authabort;
}
err = sasl_listmech(vs->sasl.conn,
NULL,
"",
",",
"",
&mechlist,
NULL,
NULL);
if (err != SASL_OK) {
VNC_DEBUG("cannot list SASL mechanisms %d (%s)\n",
err, sasl_errdetail(vs->sasl.conn));
sasl_dispose(&vs->sasl.conn);
vs->sasl.conn = NULL;
goto authabort;
}
VNC_DEBUG("Available mechanisms for client: '%s'\n", mechlist);
vs->sasl.mechlist = g_strdup(mechlist);
mechlistlen = strlen(mechlist);
vnc_write_u32(vs, mechlistlen);
vnc_write(vs, mechlist, mechlistlen);
vnc_flush(vs);
VNC_DEBUG("Wait for client mechname length\n");
vnc_read_when(vs, protocol_client_auth_sasl_mechname_len, 4);
return;
authabort:
vnc_client_error(vs);
}
| 1threat |
How can i set fixed width using css? : is there a way to define only fixed width and not height?
Because the position: fixed; is not good for me.
I have a Navbar, which it's background not expanding on the full screen on minimized window (because i have an element defined with pixels bigger than the minimized window width, and when i scroll it is not fixed). position: fixed; is working for the width of the page, but it's not good for the height. Please help me
thanks!! | 0debug |
Can someone explain this java.lang.ArrayIndexOutOfBoundsException to me : <p>Here's my code:</p>
<pre><code>import java.util.Arrays;
public class TwelveInts {
public static void main(String[] args) {
int bucky[]={1,2,3,4,5,6,7,8,9,10,11,12};
System.out.println("First to last: ");
for(int i = 0; i<bucky.length; i++){
System.out.print(bucky[i] + " ");
}
System.out.println("");
System.out.println("Opposite order :) ");
**for(int i = bucky.length; i >=0; i--){**
System.out.print(bucky[i] + " ");
}
}
}
</code></pre>
<p>I realize that the line of problematic code is this:</p>
<pre><code>for(int i = bucky.length; i >=0; i--)
</code></pre>
<p>It should be written as follows to get rid of the exception:</p>
<pre><code>for(int i = bucky.length - 1; i >=0; i--){
</code></pre>
<p>I just don't understand why though. I know that the reason is because it's due to an illegal index, but I just don't understand this exception error in application to this problem. If someone can help me understand why this exception occurs in this problem without the "<strong>-1"</strong>, that would be great. I'm just having a really hard time visualizing it for this. </p>
| 0debug |
How can I tightly wrap a Column of widgets inside a Card? : <p>I have a page of my app that consists solely of a <code>Card</code> that holds a <code>Column</code> at the end of which is a <code>MaterialList</code>. Even if my list only has one or two items, the Card extends its vertical space to the bottom of the screen rather than stopping at the end of the list items. The <a href="https://docs.flutter.io/flutter/widgets/Column-class.html" rel="noreferrer">Column documentation</a> suggests this is normal Column behavior ("Layout each child a null or zero flex factor (e.g., those that are not Expanded) with unbounded vertical constraints"). I thought wrapping the list in a <code>Flexible</code> might achieve my desired effect but when I tried I got the following error:</p>
<pre><code>RenderFlex children have non-zero flex but incoming height constraints are unbounded.
I/flutter (11469): When a column is in a parent that does not provide a finite height constraint, for example if it is
I/flutter (11469): in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a
I/flutter (11469): flex on a child (e.g. using a Flexible) indicates that the child is to expand to fill the remaining
I/flutter (11469): space in the vertical direction.
I/flutter (11469): These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child
I/flutter (11469): cannot simultaneously expand to fit its parent.
</code></pre>
<p>I'm clearly misunderstanding something about how this layout is supposed to work. </p>
<p>Here is sample code of what I have now as the body of the <code>Scaffold</code> for this page:</p>
<pre><code>new Container(
// Outer container so we can set margins and padding for the cards
// that will hold the rest of the view.
alignment: FractionalOffset.topCenter,
margin: new EdgeInsets.only(top: style.wideMargin),
padding: new EdgeInsets.symmetric(horizontal: style.defaultMargin),
child: new Card(
child: new Column(
children: [
new CustomHeader(), // <-- a Row with some buttons in it
new Divider(),
new MaterialList(
type: MaterialListType.twoLine,
children: listItems, // <-- a list of custom Rows
),
],
),
),
</code></pre>
<p>)</p>
<p>How can I have a Card that tightly wraps a <code>Column</code> of widgets?</p>
| 0debug |
Logout after don't navigate before page : Login.php and logout.php page provided below.
How to create an session varible and once logout successful don't navigate before page.
require( 'dbConfig.php');
session_start();
$msg = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST["userid"];
if ($name == '' ) {
$msg = "You must enter all fields";
}
else
{
$sql = "SELECT * FROM user WHERE userid = '$name' ";
$query = mysql_query($sql);
if ($query === false) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($query) > 0) {
$_SESSION['userid'] = $name;
header('Location: teams.php');
exit;
}
$msg = "Username do not match";
}
}
?>
<?php
session_start();
if(session_destroy())
{
header("Location: index.php");
}
?>
After logout of the page navigating back pages.please disable solution. | 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.