problem
stringlengths
26
131k
labels
class label
2 classes
angular 2 template use console.log : <p>I would like to use the console.log inside the inline template but can't find any directions.</p> <pre><code>@Component({ selector:"main", providers: [ItemService], template:` &lt;ul&gt; &lt;li *ngFor="let item of items"&gt; {{console.log(item)}} &lt;----- ??? &lt;p&gt;{{item.name}}&lt;/p&gt; &lt;/li&gt; &lt;/ul&gt; ` }) export class HomeComponent { private items: Array&lt;ItemModel&gt;; constructor() {} } </code></pre>
0debug
Check if a Youtube ID is valid with Nokogori and Rails : #video_controller.rb submitted_link = "https://www.googleapis.com/youtube/v3/videos?part=id&id="+@results[:id]+"&key="+ENV["KEY_YOUTUBE"] link_result = Nokogiri::HTML(open(submitted_link)) I get this result { "kind": "youtube#videoListResponse", "etag": "\"uQc-MPTsstrHkQcRXL3IWLmeNsM/GWU- KIYwNWh_dAkOcA5xDaFhS48\"", "pageInfo": { "totalResults": 1, "resultsPerPage": 1 }, "items": [ { "kind": "youtube#video", "etag": "\"uQc- MPTsstrHkQcRXL3IWLmeNsM/wp71OkMYYohvwOjzLL_4NN8r7w0\"", "id": "m9h7qCdgPN4" } ] } I want to isolate the pageInfo -> TotalResults in order to check if the link is valid (= 1) Have you an idea ? Thank you
0debug
does python has a way to implement C#-like indexers? : <p>how to implement in python c# indexers-like this[int i] {get set}? In other words, how to write the follow code in python?</p> <pre><code>public class foo{ ... List&lt;foo2&gt; objfoo; ... public foo2 this[int i] { get{ return objfoo[i]; }} }//end class foo //in another class or method... ofoo = new foo(); ... foo2 X = ofoo[3]; </code></pre>
0debug
Is it possible to track user activity in his iDevice : As the title Describe to Track, Is it possible to track every activity of a user in his iphone and display it For example - A user "X" unlock his iphone(slide to unlock)<br> then he make a call after that played a game<br> then open a camera and taken a picture <br>then enter some reminder<br> and finally he close / lock his iphone The challenge is to display all details when user unlock his phone, lock his phone and other activity he has done in his iphone<br> [Example - user open a UITableView application where the tableview data is populated with those activity like the image below<br> .......... any link or any tutorial for reference Thanks you in advance friends [![UITableView][1]][1] [1]: http://i.stack.imgur.com/zSENr.png
0debug
void helper_lcall_protected(CPUX86State *env, int new_cs, target_ulong new_eip, int shift, int next_eip_addend) { int new_stack, i; uint32_t e1, e2, cpl, dpl, rpl, selector, offset, param_count; uint32_t ss = 0, ss_e1 = 0, ss_e2 = 0, sp, type, ss_dpl, sp_mask; uint32_t val, limit, old_sp_mask; target_ulong ssp, old_ssp, next_eip; next_eip = env->eip + next_eip_addend; LOG_PCALL("lcall %04x:%08x s=%d\n", new_cs, (uint32_t)new_eip, shift); LOG_PCALL_STATE(CPU(x86_env_get_cpu(env))); if ((new_cs & 0xfffc) == 0) { raise_exception_err(env, EXCP0D_GPF, 0); } if (load_segment(env, &e1, &e2, new_cs) != 0) { raise_exception_err(env, EXCP0D_GPF, new_cs & 0xfffc); } cpl = env->hflags & HF_CPL_MASK; LOG_PCALL("desc=%08x:%08x\n", e1, e2); if (e2 & DESC_S_MASK) { if (!(e2 & DESC_CS_MASK)) { raise_exception_err(env, EXCP0D_GPF, new_cs & 0xfffc); } dpl = (e2 >> DESC_DPL_SHIFT) & 3; if (e2 & DESC_C_MASK) { if (dpl > cpl) { raise_exception_err(env, EXCP0D_GPF, new_cs & 0xfffc); } } else { rpl = new_cs & 3; if (rpl > cpl) { raise_exception_err(env, EXCP0D_GPF, new_cs & 0xfffc); } if (dpl != cpl) { raise_exception_err(env, EXCP0D_GPF, new_cs & 0xfffc); } } if (!(e2 & DESC_P_MASK)) { raise_exception_err(env, EXCP0B_NOSEG, new_cs & 0xfffc); } #ifdef TARGET_X86_64 if (shift == 2) { target_ulong rsp; rsp = env->regs[R_ESP]; PUSHQ(rsp, env->segs[R_CS].selector); PUSHQ(rsp, next_eip); env->regs[R_ESP] = rsp; cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl, get_seg_base(e1, e2), get_seg_limit(e1, e2), e2); env->eip = new_eip; } else #endif { sp = env->regs[R_ESP]; sp_mask = get_sp_mask(env->segs[R_SS].flags); ssp = env->segs[R_SS].base; if (shift) { PUSHL(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHL(ssp, sp, sp_mask, next_eip); } else { PUSHW(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHW(ssp, sp, sp_mask, next_eip); } limit = get_seg_limit(e1, e2); if (new_eip > limit) { raise_exception_err(env, EXCP0D_GPF, new_cs & 0xfffc); } SET_ESP(sp, sp_mask); cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl, get_seg_base(e1, e2), limit, e2); env->eip = new_eip; } } else { type = (e2 >> DESC_TYPE_SHIFT) & 0x1f; dpl = (e2 >> DESC_DPL_SHIFT) & 3; rpl = new_cs & 3; switch (type) { case 1: case 9: case 5: if (dpl < cpl || dpl < rpl) { raise_exception_err(env, EXCP0D_GPF, new_cs & 0xfffc); } switch_tss(env, new_cs, e1, e2, SWITCH_TSS_CALL, next_eip); CC_OP = CC_OP_EFLAGS; return; case 4: case 12: break; default: raise_exception_err(env, EXCP0D_GPF, new_cs & 0xfffc); break; } shift = type >> 3; if (dpl < cpl || dpl < rpl) { raise_exception_err(env, EXCP0D_GPF, new_cs & 0xfffc); } if (!(e2 & DESC_P_MASK)) { raise_exception_err(env, EXCP0B_NOSEG, new_cs & 0xfffc); } selector = e1 >> 16; offset = (e2 & 0xffff0000) | (e1 & 0x0000ffff); param_count = e2 & 0x1f; if ((selector & 0xfffc) == 0) { raise_exception_err(env, EXCP0D_GPF, 0); } if (load_segment(env, &e1, &e2, selector) != 0) { raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc); } if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK))) { raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc); } dpl = (e2 >> DESC_DPL_SHIFT) & 3; if (dpl > cpl) { raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc); } if (!(e2 & DESC_P_MASK)) { raise_exception_err(env, EXCP0B_NOSEG, selector & 0xfffc); } if (!(e2 & DESC_C_MASK) && dpl < cpl) { get_ss_esp_from_tss(env, &ss, &sp, dpl); LOG_PCALL("new ss:esp=%04x:%08x param_count=%d env->regs[R_ESP]=" TARGET_FMT_lx "\n", ss, sp, param_count, env->regs[R_ESP]); if ((ss & 0xfffc) == 0) { raise_exception_err(env, EXCP0A_TSS, ss & 0xfffc); } if ((ss & 3) != dpl) { raise_exception_err(env, EXCP0A_TSS, ss & 0xfffc); } if (load_segment(env, &ss_e1, &ss_e2, ss) != 0) { raise_exception_err(env, EXCP0A_TSS, ss & 0xfffc); } ss_dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3; if (ss_dpl != dpl) { raise_exception_err(env, EXCP0A_TSS, ss & 0xfffc); } if (!(ss_e2 & DESC_S_MASK) || (ss_e2 & DESC_CS_MASK) || !(ss_e2 & DESC_W_MASK)) { raise_exception_err(env, EXCP0A_TSS, ss & 0xfffc); } if (!(ss_e2 & DESC_P_MASK)) { raise_exception_err(env, EXCP0A_TSS, ss & 0xfffc); } old_sp_mask = get_sp_mask(env->segs[R_SS].flags); old_ssp = env->segs[R_SS].base; sp_mask = get_sp_mask(ss_e2); ssp = get_seg_base(ss_e1, ss_e2); if (shift) { PUSHL(ssp, sp, sp_mask, env->segs[R_SS].selector); PUSHL(ssp, sp, sp_mask, env->regs[R_ESP]); for (i = param_count - 1; i >= 0; i--) { val = cpu_ldl_kernel(env, old_ssp + ((env->regs[R_ESP] + i * 4) & old_sp_mask)); PUSHL(ssp, sp, sp_mask, val); } } else { PUSHW(ssp, sp, sp_mask, env->segs[R_SS].selector); PUSHW(ssp, sp, sp_mask, env->regs[R_ESP]); for (i = param_count - 1; i >= 0; i--) { val = cpu_lduw_kernel(env, old_ssp + ((env->regs[R_ESP] + i * 2) & old_sp_mask)); PUSHW(ssp, sp, sp_mask, val); } } new_stack = 1; } else { sp = env->regs[R_ESP]; sp_mask = get_sp_mask(env->segs[R_SS].flags); ssp = env->segs[R_SS].base; new_stack = 0; } if (shift) { PUSHL(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHL(ssp, sp, sp_mask, next_eip); } else { PUSHW(ssp, sp, sp_mask, env->segs[R_CS].selector); PUSHW(ssp, sp, sp_mask, next_eip); } if (new_stack) { ss = (ss & ~3) | dpl; cpu_x86_load_seg_cache(env, R_SS, ss, ssp, get_seg_limit(ss_e1, ss_e2), ss_e2); } selector = (selector & ~3) | dpl; cpu_x86_load_seg_cache(env, R_CS, selector, get_seg_base(e1, e2), get_seg_limit(e1, e2), e2); cpu_x86_set_cpl(env, dpl); SET_ESP(sp, sp_mask); env->eip = offset; } }
1threat
void ff_estimate_b_frame_motion(MpegEncContext * s, int mb_x, int mb_y) { MotionEstContext * const c= &s->me; const int penalty_factor= c->mb_penalty_factor; int fmin, bmin, dmin, fbmin, bimin, fimin; int type=0; const int xy = mb_y*s->mb_stride + mb_x; init_ref(c, s->new_picture.f.data, s->last_picture.f.data, s->next_picture.f.data, 16 * mb_x, 16 * mb_y, 2); get_limits(s, 16*mb_x, 16*mb_y); c->skip=0; if (s->codec_id == AV_CODEC_ID_MPEG4 && s->next_picture.mbskip_table[xy]) { int score= direct_search(s, mb_x, mb_y); score= ((unsigned)(score*score + 128*256))>>16; c->mc_mb_var_sum_temp += score; s->current_picture.mc_mb_var[mb_y*s->mb_stride + mb_x] = score; s->mb_type[mb_y*s->mb_stride + mb_x]= CANDIDATE_MB_TYPE_DIRECT0; return; } if (s->codec_id == AV_CODEC_ID_MPEG4) dmin= direct_search(s, mb_x, mb_y); else dmin= INT_MAX; c->skip=0; fmin = estimate_motion_b(s, mb_x, mb_y, s->b_forw_mv_table, 0, s->f_code) + 3 * penalty_factor; c->skip=0; bmin = estimate_motion_b(s, mb_x, mb_y, s->b_back_mv_table, 2, s->b_code) + 2 * penalty_factor; av_dlog(s, " %d %d ", s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1]); c->skip=0; fbmin= bidir_refine(s, mb_x, mb_y) + penalty_factor; av_dlog(s, "%d %d %d %d\n", dmin, fmin, bmin, fbmin); if(s->flags & CODEC_FLAG_INTERLACED_ME){ c->skip=0; c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV; fimin= interlaced_search(s, 0, s->b_field_mv_table[0], s->b_field_select_table[0], s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1], 0); c->current_mv_penalty= c->mv_penalty[s->b_code] + MAX_MV; bimin= interlaced_search(s, 2, s->b_field_mv_table[1], s->b_field_select_table[1], s->b_back_mv_table[xy][0], s->b_back_mv_table[xy][1], 0); }else fimin= bimin= INT_MAX; { int score= fmin; type = CANDIDATE_MB_TYPE_FORWARD; if (dmin <= score){ score = dmin; type = CANDIDATE_MB_TYPE_DIRECT; } if(bmin<score){ score=bmin; type= CANDIDATE_MB_TYPE_BACKWARD; } if(fbmin<score){ score=fbmin; type= CANDIDATE_MB_TYPE_BIDIR; } if(fimin<score){ score=fimin; type= CANDIDATE_MB_TYPE_FORWARD_I; } if(bimin<score){ score=bimin; type= CANDIDATE_MB_TYPE_BACKWARD_I; } score= ((unsigned)(score*score + 128*256))>>16; c->mc_mb_var_sum_temp += score; s->current_picture.mc_mb_var[mb_y*s->mb_stride + mb_x] = score; } if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){ type= CANDIDATE_MB_TYPE_FORWARD | CANDIDATE_MB_TYPE_BACKWARD | CANDIDATE_MB_TYPE_BIDIR | CANDIDATE_MB_TYPE_DIRECT; if(fimin < INT_MAX) type |= CANDIDATE_MB_TYPE_FORWARD_I; if(bimin < INT_MAX) type |= CANDIDATE_MB_TYPE_BACKWARD_I; if(fimin < INT_MAX && bimin < INT_MAX){ type |= CANDIDATE_MB_TYPE_BIDIR_I; } if(dmin>256*256*16) type&= ~CANDIDATE_MB_TYPE_DIRECT; if(s->codec_id == AV_CODEC_ID_MPEG4 && type&CANDIDATE_MB_TYPE_DIRECT && s->flags&CODEC_FLAG_MV0 && *(uint32_t*)s->b_direct_mv_table[xy]) type |= CANDIDATE_MB_TYPE_DIRECT0; } s->mb_type[mb_y*s->mb_stride + mb_x]= type; }
1threat
Why is my code not working (Error: str object is not callable) : <p><strong>You get a Task to solve (math). - No taks with solutions below zero - No tasks with solutions that have decimal places</strong></p> <p>When the loop runs the first time everything works just fine. But after the first task it sends this error:</p> <p>File ".\Task Generator.py", line 43, in input = input() TypeError: 'str' object is not callable</p> <p>What is the problem with the User Input?</p> <p>I tried to restructure the whole input part. But then the whole code doesn´t work.</p> <pre class="lang-py prettyprint-override"><code>import random score = 0 #Loop loop = True while loop == True: tasksolution = None #Task generation badtask = True while badtask == True: nums = list(range(1, 101)) ops = ["+", "-", "/", "x"] num1 = str(random.choice(nums)) num2 = str(random.choice(nums)) operator = random.choice(ops) task = str(num1 + operator + num2) #Tasksolution def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): return x / y if operator == "+": tasksolution = round(add(int(num1), int(num2)), 1) elif operator == "-": tasksolution = round(subtract(int(num1), int(num2)), 1) elif operator == "x": tasksolution = round(multiply(int(num1), int(num2)), 1) elif operator == "/": tasksolution = round(divide(int(num1), int(num2)), 1) if tasksolution &gt;= 0 and (tasksolution % 2 == 0 or tasksolution % 3 == 0): badtask = False #User input print("Task: " + task) input = input() #Input check if str.isdigit(input): if int(input) == tasksolution: print("Correct!") score + 1 elif not int(input) == tasksolution: print("Wrong!") print("The correct solution: " + str(tasksolution)) print("You´ve solved " + str(score) + " tasks!") break else: print("Something went wrong :(") else: print("Please enter a number!") break </code></pre> <p>The loop should run without breaking except you enter a wrong solution.</p>
0debug
static void raw_refresh_limits(BlockDriverState *bs, Error **errp) { BDRVRawState *s = bs->opaque; struct stat st; if (!fstat(s->fd, &st)) { if (S_ISBLK(st.st_mode)) { int ret = hdev_get_max_transfer_length(s->fd); if (ret >= 0) { bs->bl.max_transfer_length = ret; } } } raw_probe_alignment(bs, s->fd, errp); bs->bl.min_mem_alignment = s->buf_align; bs->bl.opt_mem_alignment = MAX(s->buf_align, getpagesize()); }
1threat
int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) { int i; buflen = FFMIN(buflen - 1, maxlen); for (i = 0; i < buflen; i++) if (!(buf[i] = avio_r8(s))) return i + 1; if (buflen) buf[i] = 0; for (; i < maxlen; i++) if (!avio_r8(s)) return i + 1; return maxlen; }
1threat
Show Date as Mmmm d, yyyy SQL : Trying to show the date as August 2, 2018 format. Its stored as 20180802 in the table. The column type is set is char. Any help is appreciated. Thanks
0debug
ERROR in [at-loader] node_modules\@types\jasmine : <p>My webpack build started failing out of nowhere with no packages being updated. I assume some minor version update caused this, but can't figure out how to get around it. Does anyone know what to do?</p> <pre><code>ERROR in [at-loader] node_modules\@types\jasmine\index.d.ts:39:52 TS1005: '=' expected. ERROR in [at-loader] node_modules\@types\jasmine\index.d.ts:39:38 TS2371: A parameter initializer is only allowed in a function or constructor implementation. ERROR in [at-loader] node_modules\@types\jasmine\index.d.ts:39:46 TS2304: Cannot find name 'keyof'. </code></pre> <p>package.json</p> <pre><code> "dependencies": { "@angular/common": "2.4.7", "@angular/compiler": "~2.4.4", "@angular/core": "2.4.7", "@angular/forms": "2.4.7", "@angular/http": "~2.4.4", "@angular/material": "^2.0.0-beta.1", "@angular/platform-browser": "~2.4.4", "@angular/platform-browser-dynamic": "~2.4.4", "@angular/platform-server": "~2.4.4", "@angular/router": "~3.4.1", "@angularclass/conventions-loader": "^1.0.2", "@angularclass/hmr": "~1.2.2", "@angularclass/hmr-loader": "~3.0.2", "@vaadin/angular2-polymer": "^1.0.0", "animate.css": "^3.5.2", "assets-webpack-plugin": "^3.4.0", "bootstrap-sass": "^3.3.7", "bootstrap-select": "^1.12.1", "bootstrap-tour": "^0.11.0", "core-js": "^2.4.1", "font-awesome": "^4.7.0", "http-server": "^0.9.0", "icheck": "^1.0.2", "ie-shim": "^0.1.0", "jasmine-core": "^2.5.2", "metismenu": "2.0.2", "nestable": "^0.2.0", "ng2-modal": "0.0.24", "ng2-tag-input": "~0.8.4", "pace": "0.0.4", "pace-progress": "^1.0.2", "primeng": "^1.1.4", "reflect-metadata": "^0.1.9", "rxjs": "~5.1.0", "summernote": "^0.8.2", "zone.js": "0.7.4", "ag-grid": "~8.0.1", "ag-grid-enterprise": "~8.0.1", "ag-grid-ng2": "~8.0.0" }, "devDependencies": { "@angular/compiler-cli": "~2.4.1", "@types/hammerjs": "^2.0.33", "@types/jasmine": "^2.2.34", "@types/node": "^6.0.38", "@types/selenium-webdriver": "2.53.38", "@types/source-map": "^0.5.0", "@types/uglify-js": "^2.0.27", "@types/webpack": "^2.0.0", "angular-router-loader": "^0.4.0", "angular2-template-loader": "^0.6.0", "assets-webpack-plugin": "^3.4.0", "awesome-typescript-loader": "~3.0.4-rc.2", "codelyzer": "~2.0.0-beta.4", "copy-webpack-plugin": "^4.0.0", "css-loader": "^0.26.0", "exports-loader": "^0.6.3", "expose-loader": "^0.7.1", "extract-text-webpack-plugin": "^2.0.0-beta.4", "file-loader": "^0.9.0", "gh-pages": "^0.12.0", "html-webpack-plugin": "^2.21.0", "imports-loader": "^0.7.0", "istanbul-instrumenter-loader": "1.2.0", "jasmine-core": "^2.5.2", "json-loader": "^0.5.4", "karma": "^1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-coverage": "^1.1.1", "karma-jasmine": "^1.0.2", "karma-mocha-reporter": "^2.0.0", "karma-remap-coverage": "^0.1.4", "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "1.8.1", "ngc-webpack": "^1.0.2", "node-sass": "^4.1.1", "npm-run-all": "^4.0.0", "parse5": "^3.0.1", "protractor": "^4.0.10", "raw-loader": "0.5.1", "rimraf": "~2.5.4", "sass-loader": "^4.1.1", "script-ext-html-webpack-plugin": "^1.3.2", "source-map-loader": "^0.1.5", "string-replace-loader": "1.0.5", "style-loader": "^0.13.1", "to-string-loader": "^1.1.4", "ts-helpers": "1.1.2", "ts-node": "^2.0.0", "tslint": "4.2.0", "tslint-loader": "^3.3.0", "typedoc": "^0.5.3", "typescript": "2.0.10", "url-loader": "^0.5.7", "v8-lazy-parse-webpack-plugin": "^0.3.0", "webpack": "2.2.1", "webpack-dev-middleware": "^1.10.0", "webpack-dev-server": "2.3.0", "webpack-dll-bundles-plugin": "^1.0.0-beta.5", "webpack-md5-hash": "^0.0.5", "webpack-merge": "~2.6.1" } </code></pre>
0debug
how to convert string to date or date to string : <p>I have a tableview cell with a Date type Date, it shows me the following error and I don't know how to fix it:</p> <blockquote> <p>Error: Cannot assign value of type 'Date' to type 'String?'</p> </blockquote> <pre><code>cell.Resum_Controls_Data_txt.text = control.data </code></pre> <p>control.data (is type Date)</p>
0debug
static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc, AVStream *st, int i){ NUTContext *nut = avctx->priv_data; AVCodecContext *codec = st->codec; unsigned codec_tag = av_codec_get_tag(ff_nut_codec_tags, codec->codec_id); ff_put_v(bc, i); switch(codec->codec_type){ case AVMEDIA_TYPE_VIDEO: ff_put_v(bc, 0); break; case AVMEDIA_TYPE_AUDIO: ff_put_v(bc, 1); break; case AVMEDIA_TYPE_SUBTITLE: ff_put_v(bc, 2); break; default : ff_put_v(bc, 3); break; } ff_put_v(bc, 4); if (!codec_tag) codec_tag = codec->codec_tag; if (codec_tag) { avio_wl32(bc, codec_tag); } else { av_log(avctx, AV_LOG_ERROR, "No codec tag defined for stream %d\n", i); return AVERROR(EINVAL); } ff_put_v(bc, nut->stream[i].time_base - nut->time_base); ff_put_v(bc, nut->stream[i].msb_pts_shift); ff_put_v(bc, nut->stream[i].max_pts_distance); ff_put_v(bc, codec->has_b_frames); avio_w8(bc, 0); ff_put_v(bc, codec->extradata_size); avio_write(bc, codec->extradata, codec->extradata_size); switch(codec->codec_type){ case AVMEDIA_TYPE_AUDIO: ff_put_v(bc, codec->sample_rate); ff_put_v(bc, 1); ff_put_v(bc, codec->channels); break; case AVMEDIA_TYPE_VIDEO: ff_put_v(bc, codec->width); ff_put_v(bc, codec->height); if(st->sample_aspect_ratio.num<=0 || st->sample_aspect_ratio.den<=0){ ff_put_v(bc, 0); ff_put_v(bc, 0); }else{ ff_put_v(bc, st->sample_aspect_ratio.num); ff_put_v(bc, st->sample_aspect_ratio.den); } ff_put_v(bc, 0); break; default: break; } return 0; }
1threat
bash script to search directory only specific file types : <p>I'm trying to write a bash script that will search a folder for specific file extensions (lets say .txt and .csv). The folder can have thousands of each type of extension. If the folder has only these two extensions across all files then the script can proceed. If any other extensions are present (and the two allowed extesions may also be preset), the script copies the folder to a holding bucket and writes to a log file. The folder that is being searched will never have subfolders.</p> <p>So, if the folder has: .txt and .csv, this passes If the folder has: .mp3, this fails If the folder has: .txt, .csv and .mp3, this also fails.</p> <p>Thanks!</p>
0debug
static uint16_t nvme_write_zeros(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req) { NvmeRwCmd *rw = (NvmeRwCmd *)cmd; const uint8_t lba_index = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas); const uint8_t data_shift = ns->id_ns.lbaf[lba_index].ds; uint64_t slba = le64_to_cpu(rw->slba); uint32_t nlb = le16_to_cpu(rw->nlb) + 1; uint64_t aio_slba = slba << (data_shift - BDRV_SECTOR_BITS); uint32_t aio_nlb = nlb << (data_shift - BDRV_SECTOR_BITS); if (slba + nlb > ns->id_ns.nsze) { return NVME_LBA_RANGE | NVME_DNR; } req->has_sg = false; block_acct_start(blk_get_stats(n->conf.blk), &req->acct, 0, BLOCK_ACCT_WRITE); req->aiocb = blk_aio_pwrite_zeroes(n->conf.blk, aio_slba, aio_nlb, BDRV_REQ_MAY_UNMAP, nvme_rw_cb, req); return NVME_NO_COMPLETE; }
1threat
How is CSS pixel movement same in every monitor resolution : <p>Lets says I have the following CSS:</p> <pre><code>#div-1 { position:relative; top:20px; left:-40px; } </code></pre> <p>If load it on Monitor A and drag my browser to monitor B with a different resolution, HTML div will be at the same spot, although pixel numbers are different in monitors. How does that work?</p>
0debug
BeatifoulSoup: nested elements : I would like to extract the Impact Factor (0.806) with BeatifoulSoup from this HTML text: <div id="quick-facts-container" class="SideBox"> <ul class="ListStack ListStack--float"> <li> <span>Impact Factor</span> <span>0.806</span> </li> </ul> </div> Because it's nested and I would like to get the content of the second <span> I don't know, how to do it. Thanks in advance for any solution!
0debug
RCPP - temporary variable : i wanna ask about temporary variable, in this code i want to replace the k-th row of Ynew1 by zero, and in every iteration the value of Ynew1 is updated by X (first value). but in my code not only row of Ynew1 are replace by 0, but the X too. and, unfortunately the result is Ynew1 is matrix all zero (i expected the result just last row has zero value). this is the code : cppFunction(' NumericMatrix cobo(NumericMatrix X){ int n = X.nrow(); NumericMatrix Ynew1(n,1); for (int k=0;k<n;k++){ Ynew1 = X; for(int i=0;i<n;i++){ Ynew1(k,i)=0; } } return(Ynew1); } ')
0debug
Breadcrumb libraries (html5/css) : <p>I am looking for a library which has some custom breadcrumbs as the following:</p> <p><a href="https://i.stack.imgur.com/aJAoN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aJAoN.png" alt="enter image description here"></a></p> <p>Any idea what I could use to have a result looking as my image (ish).</p>
0debug
static void rtl8139_do_receive(void *opaque, const uint8_t *buf, int size, int do_interrupt) { RTL8139State *s = opaque; uint32_t packet_header = 0; uint8_t buf1[60]; static const uint8_t broadcast_macaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; DEBUG_PRINT((">>> RTL8139: received len=%d\n", size)); if (!s->clock_enabled) { DEBUG_PRINT(("RTL8139: stopped ==========================\n")); return; } if (!rtl8139_receiver_enabled(s)) { DEBUG_PRINT(("RTL8139: receiver disabled ================\n")); return; } if (s->RxConfig & AcceptAllPhys) { DEBUG_PRINT((">>> RTL8139: packet received in promiscuous mode\n")); } else { if (!memcmp(buf, broadcast_macaddr, 6)) { if (!(s->RxConfig & AcceptBroadcast)) { DEBUG_PRINT((">>> RTL8139: broadcast packet rejected\n")); ++s->tally_counters.RxERR; return; } packet_header |= RxBroadcast; DEBUG_PRINT((">>> RTL8139: broadcast packet received\n")); ++s->tally_counters.RxOkBrd; } else if (buf[0] & 0x01) { if (!(s->RxConfig & AcceptMulticast)) { DEBUG_PRINT((">>> RTL8139: multicast packet rejected\n")); ++s->tally_counters.RxERR; return; } int mcast_idx = compute_mcast_idx(buf); if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7)))) { DEBUG_PRINT((">>> RTL8139: multicast address mismatch\n")); ++s->tally_counters.RxERR; return; } packet_header |= RxMulticast; DEBUG_PRINT((">>> RTL8139: multicast packet received\n")); ++s->tally_counters.RxOkMul; } else if (s->phys[0] == buf[0] && s->phys[1] == buf[1] && s->phys[2] == buf[2] && s->phys[3] == buf[3] && s->phys[4] == buf[4] && s->phys[5] == buf[5]) { if (!(s->RxConfig & AcceptMyPhys)) { DEBUG_PRINT((">>> RTL8139: rejecting physical address matching packet\n")); ++s->tally_counters.RxERR; return; } packet_header |= RxPhysical; DEBUG_PRINT((">>> RTL8139: physical address matching packet received\n")); ++s->tally_counters.RxOkPhy; } else { DEBUG_PRINT((">>> RTL8139: unknown packet\n")); ++s->tally_counters.RxERR; return; } } if (size < MIN_BUF_SIZE) { memcpy(buf1, buf, size); memset(buf1 + size, 0, MIN_BUF_SIZE - size); buf = buf1; size = MIN_BUF_SIZE; } if (rtl8139_cp_receiver_enabled(s)) { DEBUG_PRINT(("RTL8139: in C+ Rx mode ================\n")); #define CP_RX_OWN (1<<31) #define CP_RX_EOR (1<<30) #define CP_RX_BUFFER_SIZE_MASK ((1<<13) - 1) #define CP_RX_TAVA (1<<16) #define CP_RX_VLAN_TAG_MASK ((1<<16) - 1) int descriptor = s->currCPlusRxDesc; target_phys_addr_t cplus_rx_ring_desc; cplus_rx_ring_desc = rtl8139_addr64(s->RxRingAddrLO, s->RxRingAddrHI); cplus_rx_ring_desc += 16 * descriptor; DEBUG_PRINT(("RTL8139: +++ C+ mode reading RX descriptor %d from host memory at %08x %08x = %016" PRIx64 "\n", descriptor, s->RxRingAddrHI, s->RxRingAddrLO, (uint64_t)cplus_rx_ring_desc)); uint32_t val, rxdw0,rxdw1,rxbufLO,rxbufHI; cpu_physical_memory_read(cplus_rx_ring_desc, (uint8_t *)&val, 4); rxdw0 = le32_to_cpu(val); cpu_physical_memory_read(cplus_rx_ring_desc+4, (uint8_t *)&val, 4); rxdw1 = le32_to_cpu(val); cpu_physical_memory_read(cplus_rx_ring_desc+8, (uint8_t *)&val, 4); rxbufLO = le32_to_cpu(val); cpu_physical_memory_read(cplus_rx_ring_desc+12, (uint8_t *)&val, 4); rxbufHI = le32_to_cpu(val); DEBUG_PRINT(("RTL8139: +++ C+ mode RX descriptor %d %08x %08x %08x %08x\n", descriptor, rxdw0, rxdw1, rxbufLO, rxbufHI)); if (!(rxdw0 & CP_RX_OWN)) { DEBUG_PRINT(("RTL8139: C+ Rx mode : descriptor %d is owned by host\n", descriptor)); s->IntrStatus |= RxOverflow; ++s->RxMissed; ++s->tally_counters.RxERR; ++s->tally_counters.MissPkt; rtl8139_update_irq(s); return; } uint32_t rx_space = rxdw0 & CP_RX_BUFFER_SIZE_MASK; if (size+4 > rx_space) { DEBUG_PRINT(("RTL8139: C+ Rx mode : descriptor %d size %d received %d + 4\n", descriptor, rx_space, size)); s->IntrStatus |= RxOverflow; ++s->RxMissed; ++s->tally_counters.RxERR; ++s->tally_counters.MissPkt; rtl8139_update_irq(s); return; } target_phys_addr_t rx_addr = rtl8139_addr64(rxbufLO, rxbufHI); cpu_physical_memory_write( rx_addr, buf, size ); if (s->CpCmd & CPlusRxChkSum) { } #if defined (RTL8139_CALCULATE_RXCRC) val = cpu_to_le32(crc32(~0, buf, size)); #else val = 0; #endif cpu_physical_memory_write( rx_addr+size, (uint8_t *)&val, 4); #define CP_RX_STATUS_FS (1<<29) #define CP_RX_STATUS_LS (1<<28) #define CP_RX_STATUS_MAR (1<<26) #define CP_RX_STATUS_PAM (1<<25) #define CP_RX_STATUS_BAR (1<<24) #define CP_RX_STATUS_RUNT (1<<19) #define CP_RX_STATUS_CRC (1<<18) #define CP_RX_STATUS_IPF (1<<15) #define CP_RX_STATUS_UDPF (1<<14) #define CP_RX_STATUS_TCPF (1<<13) rxdw0 &= ~CP_RX_OWN; rxdw0 |= CP_RX_STATUS_FS; rxdw0 |= CP_RX_STATUS_LS; if (packet_header & RxBroadcast) rxdw0 |= CP_RX_STATUS_BAR; if (packet_header & RxMulticast) rxdw0 |= CP_RX_STATUS_MAR; if (packet_header & RxPhysical) rxdw0 |= CP_RX_STATUS_PAM; rxdw0 &= ~CP_RX_BUFFER_SIZE_MASK; rxdw0 |= (size+4); rxdw1 &= ~CP_RX_TAVA; val = cpu_to_le32(rxdw0); cpu_physical_memory_write(cplus_rx_ring_desc, (uint8_t *)&val, 4); val = cpu_to_le32(rxdw1); cpu_physical_memory_write(cplus_rx_ring_desc+4, (uint8_t *)&val, 4); ++s->tally_counters.RxOk; if (rxdw0 & CP_RX_EOR) { s->currCPlusRxDesc = 0; } else { ++s->currCPlusRxDesc; } DEBUG_PRINT(("RTL8139: done C+ Rx mode ----------------\n")); } else { DEBUG_PRINT(("RTL8139: in ring Rx mode ================\n")); int avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr, s->RxBufferSize); if (avail != 0 && size + 8 >= avail) { DEBUG_PRINT(("rx overflow: rx buffer length %d head 0x%04x read 0x%04x === available 0x%04x need 0x%04x\n", s->RxBufferSize, s->RxBufAddr, s->RxBufPtr, avail, size + 8)); s->IntrStatus |= RxOverflow; ++s->RxMissed; rtl8139_update_irq(s); return; } packet_header |= RxStatusOK; packet_header |= (((size+4) << 16) & 0xffff0000); uint32_t val = cpu_to_le32(packet_header); rtl8139_write_buffer(s, (uint8_t *)&val, 4); rtl8139_write_buffer(s, buf, size); #if defined (RTL8139_CALCULATE_RXCRC) val = cpu_to_le32(crc32(~0, buf, size)); #else val = 0; #endif rtl8139_write_buffer(s, (uint8_t *)&val, 4); s->RxBufAddr = MOD2((s->RxBufAddr + 3) & ~0x3, s->RxBufferSize); DEBUG_PRINT((" received: rx buffer length %d head 0x%04x read 0x%04x\n", s->RxBufferSize, s->RxBufAddr, s->RxBufPtr)); } s->IntrStatus |= RxOK; if (do_interrupt) { rtl8139_update_irq(s); } }
1threat
static int decode_mb_cavlc(H264Context *h){ MpegEncContext * const s = &h->s; int mb_xy; int partition_count; unsigned int mb_type, cbp; int dct8x8_allowed= h->pps.transform_8x8_mode; mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride; s->dsp.clear_blocks(h->mb); tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y); cbp = 0; if(h->slice_type_nos != FF_I_TYPE){ if(s->mb_skip_run==-1) s->mb_skip_run= get_ue_golomb(&s->gb); if (s->mb_skip_run--) { if(FRAME_MBAFF && (s->mb_y&1) == 0){ if(s->mb_skip_run==0) h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&s->gb); else predict_field_decoding_flag(h); } decode_mb_skip(h); return 0; } } if(FRAME_MBAFF){ if( (s->mb_y&1) == 0 ) h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&s->gb); }else h->mb_field_decoding_flag= (s->picture_structure!=PICT_FRAME); h->prev_mb_skipped= 0; mb_type= get_ue_golomb(&s->gb); if(h->slice_type_nos == FF_B_TYPE){ if(mb_type < 23){ partition_count= b_mb_type_info[mb_type].partition_count; mb_type= b_mb_type_info[mb_type].type; }else{ mb_type -= 23; goto decode_intra_mb; } }else if(h->slice_type_nos == FF_P_TYPE){ if(mb_type < 5){ partition_count= p_mb_type_info[mb_type].partition_count; mb_type= p_mb_type_info[mb_type].type; }else{ mb_type -= 5; goto decode_intra_mb; } }else{ assert(h->slice_type_nos == FF_I_TYPE); if(h->slice_type == FF_SI_TYPE && mb_type) mb_type--; decode_intra_mb: if(mb_type > 25){ av_log(h->s.avctx, AV_LOG_ERROR, "mb_type %d in %c slice too large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y); return -1; } partition_count=0; cbp= i_mb_type_info[mb_type].cbp; h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode; mb_type= i_mb_type_info[mb_type].type; } if(MB_FIELD) mb_type |= MB_TYPE_INTERLACED; h->slice_table[ mb_xy ]= h->slice_num; if(IS_INTRA_PCM(mb_type)){ unsigned int x, y; align_get_bits(&s->gb); for(y=0; y<16; y++){ const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3); for(x=0; x<16; x++){ tprintf(s->avctx, "LUMA ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8)); h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= get_bits(&s->gb, 8); } } for(y=0; y<8; y++){ const int index= 256 + 4*(y&3) + 32*(y>>2); for(x=0; x<8; x++){ tprintf(s->avctx, "CHROMA U ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8)); h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8); } } for(y=0; y<8; y++){ const int index= 256 + 64 + 4*(y&3) + 32*(y>>2); for(x=0; x<8; x++){ tprintf(s->avctx, "CHROMA V ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8)); h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8); } } s->current_picture.qscale_table[mb_xy]= 0; memset(h->non_zero_count[mb_xy], 16, 16); s->current_picture.mb_type[mb_xy]= mb_type; return 0; } if(MB_MBAFF){ h->ref_count[0] <<= 1; h->ref_count[1] <<= 1; } fill_caches(h, mb_type, 0); if(IS_INTRA(mb_type)){ int pred_mode; if(IS_INTRA4x4(mb_type)){ int i; int di = 1; if(dct8x8_allowed && get_bits1(&s->gb)){ mb_type |= MB_TYPE_8x8DCT; di = 4; } for(i=0; i<16; i+=di){ int mode= pred_intra_mode(h, i); if(!get_bits1(&s->gb)){ const int rem_mode= get_bits(&s->gb, 3); mode = rem_mode + (rem_mode >= mode); } if(di==4) fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 ); else h->intra4x4_pred_mode_cache[ scan8[i] ] = mode; } write_back_intra_pred_mode(h); if( check_intra4x4_pred_mode(h) < 0) return -1; }else{ h->intra16x16_pred_mode= check_intra_pred_mode(h, h->intra16x16_pred_mode); if(h->intra16x16_pred_mode < 0) return -1; } pred_mode= check_intra_pred_mode(h, get_ue_golomb(&s->gb)); if(pred_mode < 0) return -1; h->chroma_pred_mode= pred_mode; }else if(partition_count==4){ int i, j, sub_partition_count[4], list, ref[2][4]; if(h->slice_type_nos == FF_B_TYPE){ for(i=0; i<4; i++){ h->sub_mb_type[i]= get_ue_golomb(&s->gb); if(h->sub_mb_type[i] >=13){ av_log(h->s.avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); return -1; } sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count; h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type; } if( IS_DIRECT(h->sub_mb_type[0]) || IS_DIRECT(h->sub_mb_type[1]) || IS_DIRECT(h->sub_mb_type[2]) || IS_DIRECT(h->sub_mb_type[3])) { pred_direct_motion(h, &mb_type); h->ref_cache[0][scan8[4]] = h->ref_cache[1][scan8[4]] = h->ref_cache[0][scan8[12]] = h->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE; } }else{ assert(h->slice_type_nos == FF_P_TYPE); for(i=0; i<4; i++){ h->sub_mb_type[i]= get_ue_golomb(&s->gb); if(h->sub_mb_type[i] >=4){ av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); return -1; } sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count; h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type; } } for(list=0; list<h->list_count; list++){ int ref_count= IS_REF0(mb_type) ? 1 : h->ref_count[list]; for(i=0; i<4; i++){ if(IS_DIRECT(h->sub_mb_type[i])) continue; if(IS_DIR(h->sub_mb_type[i], 0, list)){ unsigned int tmp = get_te0_golomb(&s->gb, ref_count); if(tmp>=ref_count){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", tmp); return -1; } ref[list][i]= tmp; }else{ ref[list][i] = -1; } } } if(dct8x8_allowed) dct8x8_allowed = get_dct8x8_allowed(h); for(list=0; list<h->list_count; list++){ for(i=0; i<4; i++){ if(IS_DIRECT(h->sub_mb_type[i])) { h->ref_cache[list][ scan8[4*i] ] = h->ref_cache[list][ scan8[4*i]+1 ]; continue; } h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i]+1 ]= h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i]; if(IS_DIR(h->sub_mb_type[i], 0, list)){ const int sub_mb_type= h->sub_mb_type[i]; const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1; for(j=0; j<sub_partition_count[i]; j++){ int mx, my; const int index= 4*i + block_width*j; int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ]; pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); if(IS_SUB_8X8(sub_mb_type)){ mv_cache[ 1 ][0]= mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx; mv_cache[ 1 ][1]= mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my; }else if(IS_SUB_8X4(sub_mb_type)){ mv_cache[ 1 ][0]= mx; mv_cache[ 1 ][1]= my; }else if(IS_SUB_4X8(sub_mb_type)){ mv_cache[ 8 ][0]= mx; mv_cache[ 8 ][1]= my; } mv_cache[ 0 ][0]= mx; mv_cache[ 0 ][1]= my; } }else{ uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0]; p[0] = p[1]= p[8] = p[9]= 0; } } } }else if(IS_DIRECT(mb_type)){ pred_direct_motion(h, &mb_type); dct8x8_allowed &= h->sps.direct_8x8_inference_flag; }else{ int list, mx, my, i; we should set ref_idx_l? to 0 if we use that later ... if(IS_16X16(mb_type)){ for(list=0; list<h->list_count; list++){ unsigned int val; if(IS_DIR(mb_type, 0, list)){ val= get_te0_golomb(&s->gb, h->ref_count[list]); if(val >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1); } for(list=0; list<h->list_count; list++){ unsigned int val; if(IS_DIR(mb_type, 0, list)){ pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, val, 4); } } else if(IS_16X8(mb_type)){ for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ val= get_te0_golomb(&s->gb, h->ref_count[list]); if(val >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1); } } for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 4); } } }else{ assert(IS_8X16(mb_type)); for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ optimize val= get_te0_golomb(&s->gb, h->ref_count[list]); if(val >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1); } } for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 4); } } } } if(IS_INTER(mb_type)) write_back_motion(h, mb_type); if(!IS_INTRA16x16(mb_type)){ cbp= get_ue_golomb(&s->gb); if(cbp > 47){ av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, s->mb_x, s->mb_y); return -1; } if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp[cbp]; else cbp= golomb_to_inter_cbp[cbp]; } h->cbp = cbp; if(dct8x8_allowed && (cbp&15) && !IS_INTRA(mb_type)){ if(get_bits1(&s->gb)) mb_type |= MB_TYPE_8x8DCT; } s->current_picture.mb_type[mb_xy]= mb_type; if(cbp || IS_INTRA16x16(mb_type)){ int i8x8, i4x4, chroma_idx; int dquant; GetBitContext *gb= IS_INTRA(mb_type) ? h->intra_gb_ptr : h->inter_gb_ptr; const uint8_t *scan, *scan8x8, *dc_scan; if(IS_INTERLACED(mb_type)){ scan8x8= s->qscale ? h->field_scan8x8_cavlc : h->field_scan8x8_cavlc_q0; scan= s->qscale ? h->field_scan : h->field_scan_q0; dc_scan= luma_dc_field_scan; }else{ scan8x8= s->qscale ? h->zigzag_scan8x8_cavlc : h->zigzag_scan8x8_cavlc_q0; scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0; dc_scan= luma_dc_zigzag_scan; } dquant= get_se_golomb(&s->gb); if( dquant > 25 || dquant < -26 ){ av_log(h->s.avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, s->mb_x, s->mb_y); return -1; } s->qscale += dquant; if(((unsigned)s->qscale) > 51){ if(s->qscale<0) s->qscale+= 52; else s->qscale-= 52; } h->chroma_qp[0]= get_chroma_qp(h, 0, s->qscale); h->chroma_qp[1]= get_chroma_qp(h, 1, s->qscale); if(IS_INTRA16x16(mb_type)){ if( decode_residual(h, h->intra_gb_ptr, h->mb, LUMA_DC_BLOCK_INDEX, dc_scan, h->dequant4_coeff[0][s->qscale], 16) < 0){ return -1; continue if partitioned and other return -1 too } assert((cbp&15) == 0 || (cbp&15) == 15); if(cbp&15){ for(i8x8=0; i8x8<4; i8x8++){ for(i4x4=0; i4x4<4; i4x4++){ const int index= i4x4 + 4*i8x8; if( decode_residual(h, h->intra_gb_ptr, h->mb + 16*index, index, scan + 1, h->dequant4_coeff[0][s->qscale], 15) < 0 ){ return -1; } } } }else{ fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1); } }else{ for(i8x8=0; i8x8<4; i8x8++){ if(cbp & (1<<i8x8)){ if(IS_8x8DCT(mb_type)){ DCTELEM *buf = &h->mb[64*i8x8]; uint8_t *nnz; for(i4x4=0; i4x4<4; i4x4++){ if( decode_residual(h, gb, buf, i4x4+4*i8x8, scan8x8+16*i4x4, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 16) <0 ) return -1; } nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ]; nnz[0] += nnz[1] + nnz[8] + nnz[9]; }else{ for(i4x4=0; i4x4<4; i4x4++){ const int index= i4x4 + 4*i8x8; if( decode_residual(h, gb, h->mb + 16*index, index, scan, h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale], 16) <0 ){ return -1; } } } }else{ uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ]; nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0; } } } if(cbp&0x30){ for(chroma_idx=0; chroma_idx<2; chroma_idx++) if( decode_residual(h, gb, h->mb + 256 + 16*4*chroma_idx, CHROMA_DC_BLOCK_INDEX, chroma_dc_scan, NULL, 4) < 0){ return -1; } } if(cbp&0x20){ for(chroma_idx=0; chroma_idx<2; chroma_idx++){ const uint32_t *qmul = h->dequant4_coeff[chroma_idx+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[chroma_idx]]; for(i4x4=0; i4x4<4; i4x4++){ const int index= 16 + 4*chroma_idx + i4x4; if( decode_residual(h, gb, h->mb + 16*index, index, scan + 1, qmul, 15) < 0){ return -1; } } } }else{ uint8_t * const nnz= &h->non_zero_count_cache[0]; nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] = nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0; } }else{ uint8_t * const nnz= &h->non_zero_count_cache[0]; fill_rectangle(&nnz[scan8[0]], 4, 4, 8, 0, 1); nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] = nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0; } s->current_picture.qscale_table[mb_xy]= s->qscale; write_back_non_zero_count(h); if(MB_MBAFF){ h->ref_count[0] >>= 1; h->ref_count[1] >>= 1; } return 0; }
1threat
aio_ctx_check(GSource *source) { AioContext *ctx = (AioContext *) source; QEMUBH *bh; atomic_and(&ctx->notify_me, ~1); aio_notify_accept(ctx); for (bh = ctx->first_bh; bh; bh = bh->next) { if (!bh->deleted && bh->scheduled) { return true; } } return aio_pending(ctx) || (timerlistgroup_deadline_ns(&ctx->tlg) == 0); }
1threat
void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, ptrdiff_t linesize_arg, int block_w, int block_h, int src_x, int src_y, int w, int h) { int x, y; int start_y, start_x, end_y, end_x; emuedge_linesize_type linesize = linesize_arg; if (!w || !h) return; if (src_y >= h) { src -= src_y * linesize; src += (h - 1) * linesize; src_y = h - 1; } else if (src_y <= -block_h) { src -= src_y * linesize; src += (1 - block_h) * linesize; src_y = 1 - block_h; } if (src_x >= w) { src += (w - 1 - src_x) * sizeof(pixel); src_x = w - 1; } else if (src_x <= -block_w) { src += (1 - block_w - src_x) * sizeof(pixel); src_x = 1 - block_w; } start_y = FFMAX(0, -src_y); start_x = FFMAX(0, -src_x); end_y = FFMIN(block_h, h-src_y); end_x = FFMIN(block_w, w-src_x); av_assert2(start_y < end_y && block_h); av_assert2(start_x < end_x && block_w); w = end_x - start_x; src += start_y * linesize + start_x * sizeof(pixel); buf += start_x * sizeof(pixel); for (y = 0; y < start_y; y++) { memcpy(buf, src, w * sizeof(pixel)); buf += linesize; } for (; y < end_y; y++) { memcpy(buf, src, w * sizeof(pixel)); src += linesize; buf += linesize; } src -= linesize; for (; y < block_h; y++) { memcpy(buf, src, w * sizeof(pixel)); buf += linesize; } buf -= block_h * linesize + start_x * sizeof(pixel); while (block_h--) { pixel *bufp = (pixel *) buf; for(x = 0; x < start_x; x++) { bufp[x] = bufp[start_x]; } for (x = end_x; x < block_w; x++) { bufp[x] = bufp[end_x - 1]; } buf += linesize; } }
1threat
static int rpl_read_header(AVFormatContext *s) { AVIOContext *pb = s->pb; RPLContext *rpl = s->priv_data; AVStream *vst = NULL, *ast = NULL; int total_audio_size; int error = 0; uint32_t i; int32_t audio_format, chunk_catalog_offset, number_of_chunks; AVRational fps; char line[RPL_LINE_LENGTH]; error |= read_line(pb, line, sizeof(line)); error |= read_line(pb, line, sizeof(line)); av_dict_set(&s->metadata, "title" , line, 0); error |= read_line(pb, line, sizeof(line)); av_dict_set(&s->metadata, "copyright", line, 0); error |= read_line(pb, line, sizeof(line)); av_dict_set(&s->metadata, "author" , line, 0); vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_tag = read_line_and_int(pb, &error); vst->codec->width = read_line_and_int(pb, &error); vst->codec->height = read_line_and_int(pb, &error); vst->codec->bits_per_coded_sample = read_line_and_int(pb, &error); error |= read_line(pb, line, sizeof(line)); fps = read_fps(line, &error); avpriv_set_pts_info(vst, 32, fps.den, fps.num); switch (vst->codec->codec_tag) { #if 0 case 122: vst->codec->codec_id = AV_CODEC_ID_ESCAPE122; break; #endif case 124: vst->codec->codec_id = AV_CODEC_ID_ESCAPE124; vst->codec->bits_per_coded_sample = 16; break; case 130: vst->codec->codec_id = AV_CODEC_ID_ESCAPE130; break; default: avpriv_report_missing_feature(s, "Video format %i", vst->codec->codec_tag); vst->codec->codec_id = AV_CODEC_ID_NONE; } supports multiple audio tracks; I don't have any audio_format = read_line_and_int(pb, &error); if (audio_format) { ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_tag = audio_format; ast->codec->sample_rate = read_line_and_int(pb, &error); ast->codec->channels = read_line_and_int(pb, &error); ast->codec->bits_per_coded_sample = read_line_and_int(pb, &error); if (ast->codec->bits_per_coded_sample == 0) ast->codec->bits_per_coded_sample = 4; ast->codec->bit_rate = ast->codec->sample_rate * ast->codec->bits_per_coded_sample * ast->codec->channels; ast->codec->codec_id = AV_CODEC_ID_NONE; switch (audio_format) { case 1: if (ast->codec->bits_per_coded_sample == 16) { ast->codec->codec_id = AV_CODEC_ID_PCM_S16LE; break; } break; case 101: if (ast->codec->bits_per_coded_sample == 8) { ast->codec->codec_id = AV_CODEC_ID_PCM_U8; break; } else if (ast->codec->bits_per_coded_sample == 4) { ast->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD; break; } break; } if (ast->codec->codec_id == AV_CODEC_ID_NONE) avpriv_request_sample(s, "Audio format %i", audio_format); avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate); } else { for (i = 0; i < 3; i++) error |= read_line(pb, line, sizeof(line)); } rpl->frames_per_chunk = read_line_and_int(pb, &error); if (rpl->frames_per_chunk > 1 && vst->codec->codec_tag != 124) av_log(s, AV_LOG_WARNING, "Don't know how to split frames for video format %i. " "Video stream will be broken!\n", vst->codec->codec_tag); number_of_chunks = read_line_and_int(pb, &error); number_of_chunks++; error |= read_line(pb, line, sizeof(line)); error |= read_line(pb, line, sizeof(line)); chunk_catalog_offset = read_line_and_int(pb, &error); error |= read_line(pb, line, sizeof(line)); error |= read_line(pb, line, sizeof(line)); error |= read_line(pb, line, sizeof(line)); avio_seek(pb, chunk_catalog_offset, SEEK_SET); total_audio_size = 0; for (i = 0; !error && i < number_of_chunks; i++) { int64_t offset, video_size, audio_size; error |= read_line(pb, line, sizeof(line)); if (3 != sscanf(line, "%"SCNd64" , %"SCNd64" ; %"SCNd64, &offset, &video_size, &audio_size)) error = -1; av_add_index_entry(vst, offset, i * rpl->frames_per_chunk, video_size, rpl->frames_per_chunk, 0); if (ast) av_add_index_entry(ast, offset + video_size, total_audio_size, audio_size, audio_size * 8, 0); total_audio_size += audio_size * 8; } if (error) return AVERROR(EIO); return 0; }
1threat
HOW TO REMOVE stdClass Object IN CODEIGNITER PHP : **HOW TO REMOVE stdClass Object IN PHP** I AM USING `**$detail['shipping'] = $this->Mymodel->Tcs_get_data('shipment_master');**` IN CONTROLLER HERE IS MY ARRAY VIEW IN VIEW PAGE USING PRINT_R ($shipping); Array ( [0] => stdClass Object ( [sc_id] => 1 [sc_amount_s] => 0 [sc_amount_e] => 4999 [sc_charges] => 150 [sc_status] => 0 [sc_delete] => 0 ) [1] => stdClass Object ( [sc_id] => 2 [sc_amount_s] => 5000 [sc_amount_e] => 9999 [sc_charges] => 100 [sc_status] => 0 [sc_delete] => 0 ) [2] => stdClass Object ( [sc_id] => 4 [sc_amount_s] => 10000 [sc_amount_e] => 99999 [sc_charges] => 0 [sc_status] => 0 [sc_delete] => 0 ) )
0debug
static void test_visitor_in_native_list_bool(TestInputVisitorData *data, const void *unused) { UserDefNativeListUnion *cvalue = NULL; boolList *elem = NULL; Visitor *v; GString *gstr_list = g_string_new(""); GString *gstr_union = g_string_new(""); int i; for (i = 0; i < 32; i++) { g_string_append_printf(gstr_list, "%s", (i % 3 == 0) ? "true" : "false"); if (i != 31) { g_string_append(gstr_list, ", "); } } g_string_append_printf(gstr_union, "{ 'type': 'boolean', 'data': [ %s ] }", gstr_list->str); v = visitor_input_test_init_raw(data, gstr_union->str); visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort); g_assert(cvalue != NULL); g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); for (i = 0, elem = cvalue->u.boolean.data; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, (i % 3 == 0) ? 1 : 0); } g_string_free(gstr_union, true); g_string_free(gstr_list, true); qapi_free_UserDefNativeListUnion(cvalue); }
1threat
static int img_compare(int argc, char **argv) { const char *fmt1 = NULL, *fmt2 = NULL, *cache, *filename1, *filename2; BlockBackend *blk1, *blk2; BlockDriverState *bs1, *bs2; int64_t total_sectors1, total_sectors2; uint8_t *buf1 = NULL, *buf2 = NULL; int pnum1, pnum2; int allocated1, allocated2; int ret = 0; bool progress = false, quiet = false, strict = false; int flags; bool writethrough; int64_t total_sectors; int64_t sector_num = 0; int64_t nb_sectors; int c, pnum; uint64_t progress_base; bool image_opts = false; cache = BDRV_DEFAULT_CACHE; for (;;) { static const struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "hf:F:T:pqs", long_options, NULL); if (c == -1) { break; } switch (c) { case '?': case 'h': help(); break; case 'f': fmt1 = optarg; break; case 'F': fmt2 = optarg; break; case 'T': cache = optarg; break; case 'p': progress = true; break; case 'q': quiet = true; break; case 's': strict = true; break; case OPTION_OBJECT: { QemuOpts *opts; opts = qemu_opts_parse_noisily(&qemu_object_opts, optarg, true); if (!opts) { ret = 2; goto out4; } } break; case OPTION_IMAGE_OPTS: image_opts = true; break; } } if (quiet) { progress = false; } if (optind != argc - 2) { error_exit("Expecting two image file names"); } filename1 = argv[optind++]; filename2 = argv[optind++]; if (qemu_opts_foreach(&qemu_object_opts, user_creatable_add_opts_foreach, NULL, NULL)) { ret = 2; goto out4; } qemu_progress_init(progress, 2.0); flags = 0; ret = bdrv_parse_cache_mode(cache, &flags, &writethrough); if (ret < 0) { error_report("Invalid source cache option: %s", cache); ret = 2; goto out3; } blk1 = img_open(image_opts, filename1, fmt1, flags, writethrough, quiet); if (!blk1) { ret = 2; goto out3; } blk2 = img_open(image_opts, filename2, fmt2, flags, writethrough, quiet); if (!blk2) { ret = 2; goto out2; } bs1 = blk_bs(blk1); bs2 = blk_bs(blk2); buf1 = blk_blockalign(blk1, IO_BUF_SIZE); buf2 = blk_blockalign(blk2, IO_BUF_SIZE); total_sectors1 = blk_nb_sectors(blk1); if (total_sectors1 < 0) { error_report("Can't get size of %s: %s", filename1, strerror(-total_sectors1)); ret = 4; goto out; } total_sectors2 = blk_nb_sectors(blk2); if (total_sectors2 < 0) { error_report("Can't get size of %s: %s", filename2, strerror(-total_sectors2)); ret = 4; goto out; } total_sectors = MIN(total_sectors1, total_sectors2); progress_base = MAX(total_sectors1, total_sectors2); qemu_progress_print(0, 100); if (strict && total_sectors1 != total_sectors2) { ret = 1; qprintf(quiet, "Strict mode: Image size mismatch!\n"); goto out; } for (;;) { int64_t status1, status2; BlockDriverState *file; nb_sectors = sectors_to_process(total_sectors, sector_num); if (nb_sectors <= 0) { break; } status1 = bdrv_get_block_status_above(bs1, NULL, sector_num, total_sectors1 - sector_num, &pnum1, &file); if (status1 < 0) { ret = 3; error_report("Sector allocation test failed for %s", filename1); goto out; } allocated1 = status1 & BDRV_BLOCK_ALLOCATED; status2 = bdrv_get_block_status_above(bs2, NULL, sector_num, total_sectors2 - sector_num, &pnum2, &file); if (status2 < 0) { ret = 3; error_report("Sector allocation test failed for %s", filename2); goto out; } allocated2 = status2 & BDRV_BLOCK_ALLOCATED; if (pnum1) { nb_sectors = MIN(nb_sectors, pnum1); } if (pnum2) { nb_sectors = MIN(nb_sectors, pnum2); } if (strict) { if ((status1 & ~BDRV_BLOCK_OFFSET_MASK) != (status2 & ~BDRV_BLOCK_OFFSET_MASK)) { ret = 1; qprintf(quiet, "Strict mode: Offset %" PRId64 " block status mismatch!\n", sectors_to_bytes(sector_num)); goto out; } } if ((status1 & BDRV_BLOCK_ZERO) && (status2 & BDRV_BLOCK_ZERO)) { nb_sectors = MIN(pnum1, pnum2); } else if (allocated1 == allocated2) { if (allocated1) { ret = blk_pread(blk1, sector_num << BDRV_SECTOR_BITS, buf1, nb_sectors << BDRV_SECTOR_BITS); if (ret < 0) { error_report("Error while reading offset %" PRId64 " of %s:" " %s", sectors_to_bytes(sector_num), filename1, strerror(-ret)); ret = 4; goto out; } ret = blk_pread(blk2, sector_num << BDRV_SECTOR_BITS, buf2, nb_sectors << BDRV_SECTOR_BITS); if (ret < 0) { error_report("Error while reading offset %" PRId64 " of %s: %s", sectors_to_bytes(sector_num), filename2, strerror(-ret)); ret = 4; goto out; } ret = compare_sectors(buf1, buf2, nb_sectors, &pnum); if (ret || pnum != nb_sectors) { qprintf(quiet, "Content mismatch at offset %" PRId64 "!\n", sectors_to_bytes( ret ? sector_num : sector_num + pnum)); ret = 1; goto out; } } } else { if (allocated1) { ret = check_empty_sectors(blk1, sector_num, nb_sectors, filename1, buf1, quiet); } else { ret = check_empty_sectors(blk2, sector_num, nb_sectors, filename2, buf1, quiet); } if (ret) { if (ret < 0) { error_report("Error while reading offset %" PRId64 ": %s", sectors_to_bytes(sector_num), strerror(-ret)); ret = 4; } goto out; } } sector_num += nb_sectors; qemu_progress_print(((float) nb_sectors / progress_base)*100, 100); } if (total_sectors1 != total_sectors2) { BlockBackend *blk_over; int64_t total_sectors_over; const char *filename_over; qprintf(quiet, "Warning: Image size mismatch!\n"); if (total_sectors1 > total_sectors2) { total_sectors_over = total_sectors1; blk_over = blk1; filename_over = filename1; } else { total_sectors_over = total_sectors2; blk_over = blk2; filename_over = filename2; } for (;;) { nb_sectors = sectors_to_process(total_sectors_over, sector_num); if (nb_sectors <= 0) { break; } ret = bdrv_is_allocated_above(blk_bs(blk_over), NULL, sector_num, nb_sectors, &pnum); if (ret < 0) { ret = 3; error_report("Sector allocation test failed for %s", filename_over); goto out; } nb_sectors = pnum; if (ret) { ret = check_empty_sectors(blk_over, sector_num, nb_sectors, filename_over, buf1, quiet); if (ret) { if (ret < 0) { error_report("Error while reading offset %" PRId64 " of %s: %s", sectors_to_bytes(sector_num), filename_over, strerror(-ret)); ret = 4; } goto out; } } sector_num += nb_sectors; qemu_progress_print(((float) nb_sectors / progress_base)*100, 100); } } qprintf(quiet, "Images are identical.\n"); ret = 0; out: qemu_vfree(buf1); qemu_vfree(buf2); blk_unref(blk2); out2: blk_unref(blk1); out3: qemu_progress_end(); out4: return ret; }
1threat
static void pl110_update_display(void *opaque) { PL110State *s = (PL110State *)opaque; SysBusDevice *sbd; DisplaySurface *surface = qemu_console_surface(s->con); drawfn* fntable; drawfn fn; int dest_width; int src_width; int bpp_offset; int first; int last; if (!pl110_enabled(s)) { return; } sbd = SYS_BUS_DEVICE(s); switch (surface_bits_per_pixel(surface)) { case 0: return; case 8: fntable = pl110_draw_fn_8; dest_width = 1; break; case 15: fntable = pl110_draw_fn_15; dest_width = 2; break; case 16: fntable = pl110_draw_fn_16; dest_width = 2; break; case 24: fntable = pl110_draw_fn_24; dest_width = 3; break; case 32: fntable = pl110_draw_fn_32; dest_width = 4; break; default: fprintf(stderr, "pl110: Bad color depth\n"); exit(1); } if (s->cr & PL110_CR_BGR) bpp_offset = 0; else bpp_offset = 24; if ((s->version != PL111) && (s->bpp == BPP_16)) { switch (s->mux_ctrl) { case 3: bpp_offset = (BPP_16_565 - BPP_16); break; case 1: break; case 0: case 2: default: bpp_offset += (BPP_16_565 - BPP_16); break; } } if (s->cr & PL110_CR_BEBO) fn = fntable[s->bpp + 8 + bpp_offset]; else if (s->cr & PL110_CR_BEPO) fn = fntable[s->bpp + 16 + bpp_offset]; else fn = fntable[s->bpp + bpp_offset]; src_width = s->cols; switch (s->bpp) { case BPP_1: src_width >>= 3; break; case BPP_2: src_width >>= 2; break; case BPP_4: src_width >>= 1; break; case BPP_8: break; case BPP_16: case BPP_16_565: case BPP_12: src_width <<= 1; break; case BPP_32: src_width <<= 2; break; } dest_width *= s->cols; first = 0; framebuffer_update_display(surface, sysbus_address_space(sbd), s->upbase, s->cols, s->rows, src_width, dest_width, 0, s->invalidate, fn, s->palette, &first, &last); if (first >= 0) { dpy_gfx_update(s->con, 0, first, s->cols, last - first + 1); } s->invalidate = 0; }
1threat
Insert date in DD MM YY format in php myadmin : <p>I want to insert date in dd mm yy format and this is my php script</p> <pre><code>date_default_timezone_set('Asia/Kolkata'); $date = date('Y-m-d'); $qry="INSERT INTO `nesbaty_offer`( `provider_id`, `offer_punch`, `offer_description`, `terms`, `sales_discount`, `referal`, `duration`, `billing_type`, `status`, `service_location`, `time`) VALUES('".$provider_id."', '".$offer_punch."', '".$offer_description."', '".$terms."', '".$sales_discount."', '".$referral."', '".$duration."', '".$billing_type."', '".$status."', '".$service_location."', '".$date."')"; </code></pre> <p>Currently it is storing like this </p> <pre><code>YY-MM-DD 2018-05-22 </code></pre> <p>But i want this </p> <pre><code>22-05-2018 </code></pre> <p>Is it possible?</p>
0debug
Extracting xml tags and values of clob data in a table : One of my tables has a clob column with above data(as shown in the picture) please help me with a query which results the number of rows which contain <location> tag. [1]: https://i.stack.imgur.com/zoiak.png
0debug
int cpu_ppc_register (CPUPPCState *env, ppc_def_t *def) { env->msr_mask = def->msr_mask; env->mmu_model = def->mmu_model; env->excp_model = def->excp_model; env->bus_model = def->bus_model; env->bfd_mach = def->bfd_mach; if (create_ppc_opcodes(env, def) < 0) return -1; init_ppc_proc(env, def); #if defined(PPC_DUMP_CPU) { const unsigned char *mmu_model, *excp_model, *bus_model; switch (env->mmu_model) { case POWERPC_MMU_32B: mmu_model = "PowerPC 32"; break; case POWERPC_MMU_601: mmu_model = "PowerPC 601"; break; case POWERPC_MMU_SOFT_6xx: mmu_model = "PowerPC 6xx/7xx with software driven TLBs"; break; case POWERPC_MMU_SOFT_74xx: mmu_model = "PowerPC 74xx with software driven TLBs"; break; case POWERPC_MMU_SOFT_4xx: mmu_model = "PowerPC 4xx with software driven TLBs"; break; case POWERPC_MMU_SOFT_4xx_Z: mmu_model = "PowerPC 4xx with software driven TLBs " "and zones protections"; break; case POWERPC_MMU_REAL_4xx: mmu_model = "PowerPC 4xx real mode only"; break; case POWERPC_MMU_BOOKE: mmu_model = "PowerPC BookE"; break; case POWERPC_MMU_BOOKE_FSL: mmu_model = "PowerPC BookE FSL"; break; #if defined (TARGET_PPC64) case POWERPC_MMU_64B: mmu_model = "PowerPC 64"; break; case POWERPC_MMU_64BRIDGE: mmu_model = "PowerPC 64 bridge"; break; #endif default: mmu_model = "Unknown or invalid"; break; } switch (env->excp_model) { case POWERPC_EXCP_STD: excp_model = "PowerPC"; break; case POWERPC_EXCP_40x: excp_model = "PowerPC 40x"; break; case POWERPC_EXCP_601: excp_model = "PowerPC 601"; break; case POWERPC_EXCP_602: excp_model = "PowerPC 602"; break; case POWERPC_EXCP_603: excp_model = "PowerPC 603"; break; case POWERPC_EXCP_603E: excp_model = "PowerPC 603e"; break; case POWERPC_EXCP_604: excp_model = "PowerPC 604"; break; case POWERPC_EXCP_7x0: excp_model = "PowerPC 740/750"; break; case POWERPC_EXCP_7x5: excp_model = "PowerPC 745/755"; break; case POWERPC_EXCP_74xx: excp_model = "PowerPC 74xx"; break; case POWERPC_EXCP_BOOKE: excp_model = "PowerPC BookE"; break; #if defined (TARGET_PPC64) case POWERPC_EXCP_970: excp_model = "PowerPC 970"; break; #endif default: excp_model = "Unknown or invalid"; break; } switch (env->bus_model) { case PPC_FLAGS_INPUT_6xx: bus_model = "PowerPC 6xx"; break; case PPC_FLAGS_INPUT_BookE: bus_model = "PowerPC BookE"; break; case PPC_FLAGS_INPUT_405: bus_model = "PowerPC 405"; break; case PPC_FLAGS_INPUT_401: bus_model = "PowerPC 401/403"; break; #if defined (TARGET_PPC64) case PPC_FLAGS_INPUT_970: bus_model = "PowerPC 970"; break; #endif default: bus_model = "Unknown or invalid"; break; } printf("PowerPC %-12s : PVR %08x MSR %016" PRIx64 "\n" " MMU model : %s\n", def->name, def->pvr, def->msr_mask, mmu_model); if (env->tlb != NULL) { printf(" %d %s TLB in %d ways\n", env->nb_tlb, env->id_tlbs ? "splitted" : "merged", env->nb_ways); } printf(" Exceptions model : %s\n" " Bus model : %s\n", excp_model, bus_model); } dump_ppc_insns(env); dump_ppc_sprs(env); fflush(stdout); #endif return 0; }
1threat
static int spapr_populate_memory(sPAPREnvironment *spapr, void *fdt) { uint32_t associativity[] = {cpu_to_be32(0x4), cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(0x0)}; char mem_name[32]; hwaddr node0_size, mem_start; uint64_t mem_reg_property[2]; int i, off; node0_size = (nb_numa_nodes > 1) ? node_mem[0] : ram_size; mem_reg_property[0] = 0; mem_reg_property[1] = cpu_to_be64(spapr->rma_size); off = fdt_add_subnode(fdt, 0, "memory@0"); _FDT(off); _FDT((fdt_setprop_string(fdt, off, "device_type", "memory"))); _FDT((fdt_setprop(fdt, off, "reg", mem_reg_property, sizeof(mem_reg_property)))); _FDT((fdt_setprop(fdt, off, "ibm,associativity", associativity, sizeof(associativity)))); if (node0_size > spapr->rma_size) { mem_reg_property[0] = cpu_to_be64(spapr->rma_size); mem_reg_property[1] = cpu_to_be64(node0_size - spapr->rma_size); sprintf(mem_name, "memory@" TARGET_FMT_lx, spapr->rma_size); off = fdt_add_subnode(fdt, 0, mem_name); _FDT(off); _FDT((fdt_setprop_string(fdt, off, "device_type", "memory"))); _FDT((fdt_setprop(fdt, off, "reg", mem_reg_property, sizeof(mem_reg_property)))); _FDT((fdt_setprop(fdt, off, "ibm,associativity", associativity, sizeof(associativity)))); } mem_start = node0_size; for (i = 1; i < nb_numa_nodes; i++) { mem_reg_property[0] = cpu_to_be64(mem_start); mem_reg_property[1] = cpu_to_be64(node_mem[i]); associativity[3] = associativity[4] = cpu_to_be32(i); sprintf(mem_name, "memory@" TARGET_FMT_lx, mem_start); off = fdt_add_subnode(fdt, 0, mem_name); _FDT(off); _FDT((fdt_setprop_string(fdt, off, "device_type", "memory"))); _FDT((fdt_setprop(fdt, off, "reg", mem_reg_property, sizeof(mem_reg_property)))); _FDT((fdt_setprop(fdt, off, "ibm,associativity", associativity, sizeof(associativity)))); mem_start += node_mem[i]; } return 0; }
1threat
static void test_visitor_out_null(TestOutputVisitorData *data, const void *unused) { QObject *arg; QDict *qdict; QObject *nil; visit_start_struct(data->ov, NULL, NULL, 0, &error_abort); visit_type_null(data->ov, "a", &error_abort); visit_check_struct(data->ov, &error_abort); visit_end_struct(data->ov, NULL); arg = visitor_get(data); g_assert(qobject_type(arg) == QTYPE_QDICT); qdict = qobject_to_qdict(arg); g_assert_cmpint(qdict_size(qdict), ==, 1); nil = qdict_get(qdict, "a"); g_assert(nil); g_assert(qobject_type(nil) == QTYPE_QNULL); }
1threat
Explain "Active-object" pattern : <p>What is the goal of the Active object pattern? Can you show me any abstract example to understand it easily?</p>
0debug
Convert Tensorflow model to Caffe model : <p>I would like to be able to convert a Tensorflow model to Caffe model.</p> <p>I searched on google but I was able to find only converters from caffe to tensorflow but not the opposite.</p> <p>Does anyone have an idea on how to do it?</p> <p>Thanks, Evi</p>
0debug
static void opt_qmax(const char *arg) { video_qmax = atoi(arg); if (video_qmax < 0 || video_qmax > 31) { fprintf(stderr, "qmax must be >= 1 and <= 31\n"); exit(1); } }
1threat
static ssize_t sdp_svc_search(struct bt_l2cap_sdp_state_s *sdp, uint8_t *rsp, const uint8_t *req, ssize_t len) { ssize_t seqlen; int i, count, start, end, max; int32_t handle; for (i = 0; i < sdp->services; i ++) sdp->service_list[i].match = 0; if (len < 1) return -SDP_INVALID_SYNTAX; if ((*req & ~SDP_DSIZE_MASK) == SDP_DTYPE_SEQ) { seqlen = sdp_datalen(&req, &len); if (seqlen < 3 || len < seqlen) return -SDP_INVALID_SYNTAX; len -= seqlen; while (seqlen) if (sdp_svc_match(sdp, &req, &seqlen)) return -SDP_INVALID_SYNTAX; } else if (sdp_svc_match(sdp, &req, &seqlen)) return -SDP_INVALID_SYNTAX; if (len < 3) return -SDP_INVALID_SYNTAX; max = (req[0] << 8) | req[1]; req += 2; len -= 2; if (*req) { if (len <= sizeof(int)) return -SDP_INVALID_SYNTAX; len -= sizeof(int); memcpy(&start, req + 1, sizeof(int)); } else start = 0; if (len > 1) return -SDP_INVALID_SYNTAX; len = 4; count = 0; end = start; for (i = 0; i < sdp->services; i ++) if (sdp->service_list[i].match) { if (count >= start && count < max && len + 4 < MAX_RSP_PARAM_SIZE) { handle = i; memcpy(rsp + len, &handle, 4); len += 4; end = count + 1; } count ++; } rsp[0] = count >> 8; rsp[1] = count & 0xff; rsp[2] = (end - start) >> 8; rsp[3] = (end - start) & 0xff; if (end < count) { rsp[len ++] = sizeof(int); memcpy(rsp + len, &end, sizeof(int)); len += 4; } else rsp[len ++] = 0; return len; }
1threat
RuntimeError: main thread is not in main loop with Matplotlib and Flask : <p>I'm using flask, matplotlib to save image and tensorflow to create a session. I'm getting the above error when I run the following code. Does the flask route run on a separate thread? How can I make fig.saveFig piece of code run on the Main thread. Thanks a lot</p> <pre><code> @app.route('/open', methods = ['GET', 'POST']) def sendOutput(): global loss,a2,xP,yP,scale,sess,fig test_X,test_Y = own_model.getEvaluateData(scale) cost,ans = sess.run([loss,a2],feed_dict={xP:test_X,yP:test_Y}) d = np.array(ans) - np.array(test_Y) val = hist(d,100) sess.close() fig.saveFig('abc.png') //Errror on this line </code></pre>
0debug
SQL - count (*) not working- : i want to use a simple count (*) code but there is something wrong, please help select fname,lname, dno, count(*) 2 from employee 3 group by dno 4 having count(*) 5 / ERROR at line 4: ORA-00920: invalid relational operator thank you very much
0debug
static void ioreq_release(struct ioreq *ioreq) { struct XenBlkDev *blkdev = ioreq->blkdev; LIST_REMOVE(ioreq, list); memset(ioreq, 0, sizeof(*ioreq)); ioreq->blkdev = blkdev; LIST_INSERT_HEAD(&blkdev->freelist, ioreq, list); blkdev->requests_finished--; }
1threat
Excel VBA select checkboxes and input box from webpage to download data : I'm using Excel VBA to navigate to http://airyards.com/tables.html. - Once I am there, I want to check enable the check boxes for "WR", "TE" and "RB" only. - Then have the input box (i.e. the "add or remove weeks" box) be just a single week, which I can set from a variable earlier in my code. Such as i=5 and input i into that box so I only get data from week 5. - then lastly, I want to click the "download the data" button and save the data to a specific name and folder; preferably something with my variable "i" in it to identify the week and to a folder of my choice. I've been using selenium VBA since I am a little more familiar with it. But I am getting hung up on trying to select the check boxes and not able to input my desired week number in the the "add or remove weeks" input box. Please help!
0debug
onclcik check if that element not hasClass() : i want to check on click that div or li any element not hasClass() then do something .. i am trying to do like this... $(document).on('click',function() { if(!(this).hasClass("help-icons") && !(this).hasClass("help") && (this).hasClass("close")){ $(".help-icons").hide(); }else if((this).hasClass("help")){ $(".help-icons").show(); }else{ $(".help-icons").hide(); } }); help me to solve this problem thanks..
0debug
C# array initialization without new operator : In C#, does the following initialization create instance without usage of new operator? Initialization: string[] strArray = {"one","two","three"};
0debug
Can't use global variable in PHP : <p>I'm trying to use a global variable, but it's saying that there's a unexpected equal sign? How is that...?</p> <pre><code>&lt;?php global $text = "text"; echo $text; ?&gt; </code></pre> <p>Parse error: syntax error, unexpected '=', expecting ',' or ';' in /home/chatwith/public_html/chatwithibot/test.php on line 3</p>
0debug
Inde 0, Size 0 when selection : I create a selection condition inside looping , when data true it will be add into an array, false also. Then i create another selection condition outside the looping process to get the array. then when the looping get true data it will do some true stuff, if false will do some false stuff. But i got error when i create these condition. I try many case but still can't work for me. Here is my code. Anyone please help. val arrayTrue = ArrayList<String?>() val arrayFalse = ArrayList<String?>() for (i in 0 until response.body()!!.size) { if (response.body()?.get(i)?.custNoktp == child.custNoktp == true) { arrayTrue.add("1") }else if (response.body()?.get(i)?.custNoktp == child.custNoktp == false){ arrayFalse.add("0") } } if(arrayTrue.get(0).equals("1")){ progressDialog.setMessage("True...") progressDialog.show() //do stuff here }else if (arrayTrue.isEmpty()== true){ progressDialog.setMessage("False...") progressDialog.show() //do stuff here } I have try this one but still get the same error. if(arrayTrue.get(0).equals("1")){ progressDialog.setMessage("True...") progressDialog.show() //do stuff here }else if (arrayFalse.equals("0")){ progressDialog.setMessage("False...") progressDialog.show() //do stuff here }
0debug
Codeigniter error: syntax error, unexpected 'Eval' (T_EVAL), expecting identifier (T_STRING) : <p>I'm getting the following error: A PHP Error was encountered</p> <p>Severity: Parsing Error</p> <p>Message: syntax error, unexpected 'Eval' (T_EVAL), expecting identifier (T_STRING)</p> <p>Filename: controllers/Eval.php</p> <p>Line Number: 3</p> <p><strong>Here's my code:</strong></p> <p><strong>Eval.php</strong></p> <pre><code>&lt;?php defined('BASEPATH') OR exit('No direct script access allowed'); class Eval extends CI_Controller { function __construct(){ parent::__construct(); $this-&gt;load-&gt;database(); } public function rmostrar() { $this-&gt;load-&gt;model('evalmodel'); $this-&gt;data['reactivos'] = $this-&gt;evalmodel-&gt;obtenerReactivos(); $this-&gt;load-&gt;view('evaluacion',$this-&gt;data); } </code></pre> <p>}</p> <p>I'm following the naming rules for Codeigniter yet I do get that error. Can somebody explain it?</p>
0debug
how to pass data from one activity to another in android studio : this is my first activity call CreateMessageActivity were the user is ask to check the ckeckboxes so that it can calculate the total public void myClickHandler(View view) { double fish1 = 0; double chicken1 = 0; double steak1 = 0; double total; String total1; CheckBox fish = (CheckBox) findViewById(R.id.checkFish); CheckBox chicken = (CheckBox) findViewById(R.id.checkChicken); CheckBox steak = (CheckBox) findViewById(R.id.checkSteak); //switch (view.getId()) { // case R.id.checkFish: if (fish.isChecked()) { fish1 = 5; } else { fish1 = 0; } // break; // case R.id.checkChicken: if (chicken.isChecked()) { chicken1 = 2; } else { chicken1 = 0; } // R.id.checkSteak: if (steak.isChecked()) { steak1 = 10; } else { steak1 = 0; } //break; // } total = fish1 + chicken1 + steak1; total1 = Double.toString(total); i need to pass total1 to the other activity call ReceiveMessageActivity. Intent intent = new Intent(CreateMessageActivity.this, ReceiveMessageActivity.class); intent.putExtra("message", total1); startActivity(intent); } this is my second activity that it have to display total in the textview. protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_receive_message); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); TextView TXT = new TextView(this); Bundle bundle = getIntent().getExtras(); String status = bundle.getString("message"); TXT = (TextView)findViewById(R.id.textViewactivity2); TXT.setText(status);
0debug
How do I use Cognito with the generated Javascript SDK? : <p>I couldn't find any documentation that showed how to do this so I tried my best to figure it out (is this not a common use case)? I've set up my resource to use IAM authentication, set up CORS, etc. Then I deployed it, and downloaded the generated the SDK.</p> <p>On the client-side I'm using the credentials from AWS.CognitoIdentityCredentials with apigClientFactory.newClient. When I try to post to my resource, I get a 403 error response with no body. </p> <p>The response headers contain: <code>x-amz-ErrorType: UnrecognizedClientException</code></p> <p>Could this error possibly be coming from some other AWS service (do they bubble up like that)? If so, how can I tell which one? What else might be causing the error?</p> <p>The code I'm using test test client-side looks like this:</p> <pre><code>function onFacebookLogin(fbtoken) { // get cognito credentials AWS.config.credentials = new AWS.CognitoIdentityCredentials({ IdentityPoolId: 'us-east-1:abcd6789-1234-567a-b123-12ab34cd56ef', Logins: {'graph.facebook.com': fbtoken} }); AWS.config.credentials.get(function(err) { if (err) {return console.error('Credentials error: ', err);} /* I'm assuming that this is what I use for accessKey and secretKey */ var credentials = AWS.config.credentials; apigClient = apigClientFactory.newClient({ accessKey: credentials.accessKeyId, secretKey: credentials.secretAccessKey }); }); } </code></pre>
0debug
static av_cold int libschroedinger_decode_close(AVCodecContext *avctx) { SchroDecoderParams *p_schro_params = avctx->priv_data; schro_decoder_free(p_schro_params->decoder); av_freep(&p_schro_params->format); ff_schro_queue_free(&p_schro_params->dec_frame_queue, libschroedinger_decode_frame_free); return 0; }
1threat
Can we insure the for loop iteration order when we loop over a list by "for item in list:"? : <pre><code>for a in mylist: print(a) </code></pre> <p>I am wondering whether the item in the for loop iteration will always print the item in order?</p> <p>I know "for i in (len(mylist))" can ensure the order but not sure about whether "for a in mylist" can ensure the order. </p> <p>I tried on my computer it seems like it prints out the items in order. But not sure whether it is true everywhere</p> <p>Thanks</p>
0debug
Time difference calculation in php : <p>Lets suppose start time= 2200 and end time= 0500. In PhP how can we check a given time is between start and end time? I only want to check the time, regardless of the date.</p>
0debug
Change log level in unittest : <p>I have the impression (but do not find the documentation for it) that unittest sets the logging level to <code>WARNING</code> <em>for all loggers</em>. I would like to:</p> <ul> <li>be able to specify the logging level for all loggers, from the command line (when running the tests) or from the test module itself</li> <li>avoid unittest messing around with the application logging level: when running the tests I want to have the same logging output (same levels) as when running the application</li> </ul> <p>How can I achieve this?</p>
0debug
Springboot @retryable not retrying : <p>The following code is not retrying. What am I missing?</p> <pre><code>@EnableRetry @SpringBootApplication public class App implements CommandLineRunner { ......... ......... @Retryable() ResponseEntity&lt;String&gt; authenticate(RestTemplate restTemplate, HttpEntity&lt;MultiValueMap&lt;String, String&gt;&gt; entity) throws Exception { System.out.println("try!"); throw new Exception(); //return restTemplate.exchange(auth_endpoint, HttpMethod.POST, entity, String.class); } </code></pre> <p>I have added the following to the pom.xml.</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;org.springframework.retry&lt;/groupId&gt; &lt;artifactId&gt;spring-retry&lt;/artifactId&gt; &lt;version&gt;1.1.2.RELEASE&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-aop&lt;/artifactId&gt; &lt;/dependency&gt; </code></pre> <p>I also tried providing different combinations of arguments to @Retryable.</p> <pre><code>@Retryable(maxAttempts=10,value=Exception.class,backoff=@Backoff(delay = 2000,multiplier=2)) </code></pre> <p>Thanks.</p>
0debug
Tint Navigation Icon in Toolbar : <p>How to tint menu icons is already covered a few times, like here: <a href="https://stackoverflow.com/questions/28219178/toolbar-icon-tinting-on-android">Toolbar icon tinting on Android</a></p> <p>Additionally to this solution there is still the problem of the navigation icon. Applying a Theme(Overlay) to your Toolbar just tints the text and the whitelisted icons (see: <a href="https://stackoverflow.com/a/26817918/2417724">https://stackoverflow.com/a/26817918/2417724</a>)</p> <p>If you set a custom icon (which happens to be quite easy the case, as you need to change it if you don't want to display the default back arrow) then this custom icon does not get tinted.</p> <p>How do you handle your Icons then? All my icons are per default black and I don't want to have special white versions just to use them in the Toolbar then.</p>
0debug
static inline void gen_evmwumiaa(DisasContext *ctx) { TCGv_i64 acc; TCGv_i64 tmp; if (unlikely(!ctx->spe_enabled)) { gen_exception(ctx, POWERPC_EXCP_APU); return; } gen_evmwumi(ctx); acc = tcg_temp_new_i64(); tmp = tcg_temp_new_i64(); gen_load_gpr64(tmp, rD(ctx->opcode)); tcg_gen_ld_i64(acc, cpu_env, offsetof(CPUState, spe_acc)); tcg_gen_add_i64(acc, acc, tmp); tcg_gen_st_i64(acc, cpu_env, offsetof(CPUState, spe_acc)); gen_store_gpr64(rD(ctx->opcode), acc); tcg_temp_free_i64(acc); tcg_temp_free_i64(tmp); }
1threat
window.location.href = 'http://attack.com?user=' + user_input;
1threat
Why does my if statement not work? What is wrong with my code? : <p>So when I put in the proper credentials in the EditText bars, I still get the ACCESS DENIED message. What should happen is that I should get the ACCESS GRANTED message instead of ACCESS DENIED. So what is wrong with my if statement?</p> <pre><code> LinearLayout layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; TextView userText = new TextView(this); TextView passText = new TextView(this); EditText userInput = new EditText(this); EditText passInput = new EditText(this); TextView access = new TextView(this); access.Text = ""; Button loginButton = new Button(this); loginButton.Text = "Login"; userText.Text = "Username"; passText.Text = "Password"; userInput.SetMaxLines(1); passInput.SetMaxLines(1); string username = userInput.Text; string password = passInput.Text; loginButton.Click += (sender, e) =&gt; { CheckCredentials(); }; void CheckCredentials() { if (username == "Admin" &amp;&amp; password == "adminpass") { access.Text = "ACCESS GRANTED!"; } else { access.Text = "ACCESS DENIED!"; } } SetContentView(layout); layout.AddView(userText); layout.AddView(userInput); layout.AddView(passText); layout.AddView(passInput); layout.AddView(loginButton); layout.AddView(access); </code></pre> <p>Should print out ACCESS GRANTED when you put 'Admin' as the username and 'adminpass' as the password.</p>
0debug
void put_no_rnd_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) { POWERPC_TBL_DECLARE(altivec_put_no_rnd_pixels8_xy2_num, 1); #ifdef ALTIVEC_USE_REFERENCE_C_CODE int j; POWERPC_TBL_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1); for (j = 0; j < 2; j++) { int i; const uint32_t a = (((const struct unaligned_32 *) (pixels))->l); const uint32_t b = (((const struct unaligned_32 *) (pixels + 1))->l); uint32_t l0 = (a & 0x03030303UL) + (b & 0x03030303UL) + 0x01010101UL; uint32_t h0 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2); uint32_t l1, h1; pixels += line_size; for (i = 0; i < h; i += 2) { uint32_t a = (((const struct unaligned_32 *) (pixels))->l); uint32_t b = (((const struct unaligned_32 *) (pixels + 1))->l); l1 = (a & 0x03030303UL) + (b & 0x03030303UL); h1 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2); *((uint32_t *) block) = h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL); pixels += line_size; block += line_size; a = (((const struct unaligned_32 *) (pixels))->l); b = (((const struct unaligned_32 *) (pixels + 1))->l); l0 = (a & 0x03030303UL) + (b & 0x03030303UL) + 0x01010101UL; h0 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2); *((uint32_t *) block) = h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL); pixels += line_size; block += line_size; } pixels += 4 - line_size * (h + 1); block += 4 - line_size * h; } POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1); #else register int i; register vector unsigned char pixelsv1, pixelsv2, pixelsavg; register vector unsigned char blockv, temp1, temp2; register vector unsigned short pixelssum1, pixelssum2, temp3; register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0); register const vector unsigned short vcone = (const vector unsigned short)vec_splat_u16(1); register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2); temp1 = vec_ld(0, pixels); temp2 = vec_ld(16, pixels); pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels)); if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F) { pixelsv2 = temp2; } else { pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels)); } pixelsv1 = vec_mergeh(vczero, pixelsv1); pixelsv2 = vec_mergeh(vczero, pixelsv2); pixelssum1 = vec_add((vector unsigned short)pixelsv1, (vector unsigned short)pixelsv2); pixelssum1 = vec_add(pixelssum1, vcone); POWERPC_TBL_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1); for (i = 0; i < h ; i++) { int rightside = ((unsigned long)block & 0x0000000F); blockv = vec_ld(0, block); temp1 = vec_ld(line_size, pixels); temp2 = vec_ld(line_size + 16, pixels); pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels)); if (((((unsigned long)pixels) + line_size) & 0x0000000F) == 0x0000000F) { pixelsv2 = temp2; } else { pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels)); } pixelsv1 = vec_mergeh(vczero, pixelsv1); pixelsv2 = vec_mergeh(vczero, pixelsv2); pixelssum2 = vec_add((vector unsigned short)pixelsv1, (vector unsigned short)pixelsv2); temp3 = vec_add(pixelssum1, pixelssum2); temp3 = vec_sra(temp3, vctwo); pixelssum1 = vec_add(pixelssum2, vcone); pixelsavg = vec_packsu(temp3, (vector unsigned short) vczero); if (rightside) { blockv = vec_perm(blockv, pixelsavg, vcprm(0, 1, s0, s1)); } else { blockv = vec_perm(blockv, pixelsavg, vcprm(s0, s1, 2, 3)); } vec_st(blockv, 0, block); block += line_size; pixels += line_size; } POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1); #endif }
1threat
Set the file name and open blob pdf type in new tab : <p>I am trying to open the blob byte streams in the new tab of the browser. It is works, but I am not sure how to set the file name so that each of the documents will have the unique name when downloaded. Now, the document was defaulted to 'document.pdf' when saved. </p> <pre><code>var blob = new Blob([response.data], { type: "application/pdf" }); if (blob) { var fileURL = window.URL.createObjectURL(blob); window.open(fileURL); } </code></pre>
0debug
serviceworkers focus tab: clients is empty on notificationclick : <p>I have a common serviceworker escenario, where I want catch a notification click and focus the tab where the notification has come from. However, clients variable is always empty, its lenght is 0</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>console.log("sw startup"); self.addEventListener('install', function (event) { console.log("SW installed"); }); self.addEventListener('activate', function (event) { console.log("SW activated"); }); self.addEventListener("notificationclick", function (e) { // Android doesn't automatically close notifications on click console.log(e); e.notification.close(); // Focus tab if open e.waitUntil(clients.matchAll({ type: 'window' }).then(function (clientList) { console.log("clients:" + clientList.length); for (var i = 0; i &lt; clientList.length; ++i) { var client = clientList[i]; if (client.url === '/' &amp;&amp; 'focus' in client) { return client.focus(); } } if (clients.openWindow) { return clients.openWindow('/'); } })); });</code></pre> </div> </div> </p> <p>And the registration is this one:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> this.doNotify = function (notification) { if ('serviceWorker' in navigator) { navigator.serviceWorker.register('sw.js').then(function (reg) { requestCreateNotification(notification, reg); }, function (err) { console.log('sw reg error:' + err); }); } ... }</code></pre> </div> </div> </p> <p>chrome://serviceworker-internals/ output shows that registration and installation are fine. However, when a notification is pushed, clientList is empty. I have tried removing the filter type:'window' but the result is still the same. As clients are empty, a new window is always opened. What am I doing wrong?</p>
0debug
How do I UPDATE from a SELECT in SQL command C#? : I need to update Book table and Stock table same time using single query.Because ISBN_No in Book table is equal to ISBN_No in stock table.I would like to know how to put following query inside of the sql command UPDATE Table_A SET Table_A.col1 = Table_B.col1, Table_A.col2 = Table_B.col2 FROM Some_Table AS Table_A INNER JOIN Other_Table AS Table_B ON Table_A.id = Table_B.id WHERE Table_A.col3 = 'cool'
0debug
static unsigned tget(GetByteContext *gb, int type, int le) { switch (type) { case TIFF_BYTE : return bytestream2_get_byteu(gb); case TIFF_SHORT: return tget_short(gb, le); case TIFF_LONG : return tget_long(gb, le); default : return UINT_MAX; } }
1threat
Execute certain code in function (Calling function in function)? Python : <p>I want to execute a certain lines of codes in a function and not other ones.</p> <p>Example:</p> <pre><code>def function1(): print("execute function 1") def function2(): print("execute funciton 2") def function3(): print("execute function 3") function1() </code></pre> <p>This gives an output of: <code>execute function 1</code> </p> <p>How can i get an output of <code>execute function 1</code> <code>execute function 2</code> </p> <p>Or <code>execute function 1</code> <code>execute function 3</code> </p>
0debug
extracting data from .txt file using python : <p>I have a txt file which contains the following information</p> <pre><code>03/05/2016 3020 04/05/2016 1605 05/05/2016 2015 06/05/2016 1014 07/05/2016 558 08/05/2016 509 09/05/2016 1510 10/05/2016 1010 </code></pre> <p>I want to extract this data form this txt file and store it in an variable in python.. How can i achieve this... I am using pyth</p>
0debug
void qemu_bh_delete(QEMUBH *bh) { qemu_free(bh); }
1threat
static inline struct rgbvec interp_tetrahedral(const LUT3DContext *lut3d, const struct rgbvec *s) { const struct rgbvec d = {s->r - PREV(s->r), s->g - PREV(s->g), s->b - PREV(s->b)}; const struct rgbvec c000 = lut3d->lut[PREV(s->r)][PREV(s->g)][PREV(s->b)]; const struct rgbvec c001 = lut3d->lut[PREV(s->r)][PREV(s->g)][NEXT(s->b)]; const struct rgbvec c010 = lut3d->lut[PREV(s->r)][NEXT(s->g)][PREV(s->b)]; const struct rgbvec c011 = lut3d->lut[PREV(s->r)][NEXT(s->g)][NEXT(s->b)]; const struct rgbvec c100 = lut3d->lut[NEXT(s->r)][PREV(s->g)][PREV(s->b)]; const struct rgbvec c101 = lut3d->lut[NEXT(s->r)][PREV(s->g)][NEXT(s->b)]; const struct rgbvec c110 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][PREV(s->b)]; const struct rgbvec c111 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][NEXT(s->b)]; struct rgbvec c; if (d.r > d.g) { if (d.g > d.b) { c.r = (1-d.r) * c000.r + (d.r-d.g) * c100.r + (d.g-d.b) * c110.r + (d.b) * c111.r; c.g = (1-d.r) * c000.g + (d.r-d.g) * c100.g + (d.g-d.b) * c110.g + (d.b) * c111.g; c.b = (1-d.r) * c000.b + (d.r-d.g) * c100.b + (d.g-d.b) * c110.b + (d.b) * c111.b; } else if (d.r > d.b) { c.r = (1-d.r) * c000.r + (d.r-d.b) * c100.r + (d.b-d.g) * c101.r + (d.g) * c111.r; c.g = (1-d.r) * c000.g + (d.r-d.b) * c100.g + (d.b-d.g) * c101.g + (d.g) * c111.g; c.b = (1-d.r) * c000.b + (d.r-d.b) * c100.b + (d.b-d.g) * c101.b + (d.g) * c111.b; } else { c.r = (1-d.b) * c000.r + (d.b-d.r) * c001.r + (d.r-d.g) * c101.r + (d.g) * c111.r; c.g = (1-d.b) * c000.g + (d.b-d.r) * c001.g + (d.r-d.g) * c101.g + (d.g) * c111.g; c.b = (1-d.b) * c000.b + (d.b-d.r) * c001.b + (d.r-d.g) * c101.b + (d.g) * c111.b; } } else { if (d.b > d.g) { c.r = (1-d.b) * c000.r + (d.b-d.g) * c001.r + (d.g-d.r) * c011.r + (d.r) * c111.r; c.g = (1-d.b) * c000.g + (d.b-d.g) * c001.g + (d.g-d.r) * c011.g + (d.r) * c111.g; c.b = (1-d.b) * c000.b + (d.b-d.g) * c001.b + (d.g-d.r) * c011.b + (d.r) * c111.b; } else if (d.b > d.r) { c.r = (1-d.g) * c000.r + (d.g-d.b) * c010.r + (d.b-d.r) * c011.r + (d.r) * c111.r; c.g = (1-d.g) * c000.g + (d.g-d.b) * c010.g + (d.b-d.r) * c011.g + (d.r) * c111.g; c.b = (1-d.g) * c000.b + (d.g-d.b) * c010.b + (d.b-d.r) * c011.b + (d.r) * c111.b; } else { c.r = (1-d.g) * c000.r + (d.g-d.r) * c010.r + (d.r-d.b) * c110.r + (d.b) * c111.r; c.g = (1-d.g) * c000.g + (d.g-d.r) * c010.g + (d.r-d.b) * c110.g + (d.b) * c111.g; c.b = (1-d.g) * c000.b + (d.g-d.r) * c010.b + (d.r-d.b) * c110.b + (d.b) * c111.b; } } return c; }
1threat
static target_ulong h_set_mode_resouce_addr_trans_mode(PowerPCCPU *cpu, target_ulong mflags, target_ulong value1, target_ulong value2) { CPUState *cs; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); target_ulong prefix; if (!(pcc->insns_flags2 & PPC2_ISA207S)) { return H_P2; } if (value1) { return H_P3; } if (value2) { return H_P4; } switch (mflags) { case H_SET_MODE_ADDR_TRANS_NONE: prefix = 0; break; case H_SET_MODE_ADDR_TRANS_0001_8000: prefix = 0x18000; break; case H_SET_MODE_ADDR_TRANS_C000_0000_0000_4000: prefix = 0xC000000000004000; break; default: return H_UNSUPPORTED_FLAG; } CPU_FOREACH(cs) { CPUPPCState *env = &POWERPC_CPU(cpu)->env; set_spr(cs, SPR_LPCR, mflags << LPCR_AIL_SHIFT, LPCR_AIL); env->excp_prefix = prefix; } return H_SUCCESS; }
1threat
static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log) { uint64_t features = dev->acked_features; int r; if (enable_log) { features |= 0x1ULL << VHOST_F_LOG_ALL; } r = dev->vhost_ops->vhost_set_features(dev, features); if (r < 0) { VHOST_OPS_DEBUG("vhost_set_features failed"); } return r < 0 ? -errno : 0; }
1threat
Facebook App Login: How to control expiration date of an image URL I got? : <p>I'm developing an app, which uses the facebook login. After login the user must set additional informations and a profile picture, with the picture being provided from that logged in facebook account as well. Now the whole account details, including the URL to that profile picture, are saved in my database.</p> <p>To my surprise the profile picture has suddenly stopped working. Opening it's URL in a browser gives me this message "URL signature expired"</p> <p><a href="https://scontent.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/p720x720/10846350_10204966809307370_2779189783437306470_n.jpg?oh=245bbada6c23f280a1e531e724be85ed&amp;oe=56894D69" rel="noreferrer">https://scontent.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/p720x720/10846350_10204966809307370_2779189783437306470_n.jpg?oh=245bbada6c23f280a1e531e724be85ed&amp;oe=56894D69</a></p> <p>Downloading those photos and save them to my own server is not really an option for me. Is there anything I can do to make that URL durable?</p>
0debug
Visual Studio Code disable auto-quote : <p>How do I disable the auto-quotes feature?</p> <p>When I hit the ' or " key, I do not EVER want it to automatically insert another one anywhere. No matter how smart they make it, it just comes across to me as "unpredictable" and distracts me from what I'm trying to do.</p> <p>I type over 100 wpm, I really don't need help hitting the ' or " key.</p> <p>I have tried the following settings, but none of them have disabled this undesired behavior:</p> <pre><code>{ "editor.autoClosingBrackets": false, "editor.wordWrap": "off", "html.autoClosingTags": false, "editor.formatOnType": false, "editor.suggestOnTriggerCharacters": false, "editor.acceptSuggestionOnEnter": "off", } </code></pre>
0debug
IPv6 structure definition error : <pre><code> common.c:150:17: error: ‘const struct sockaddr_in6’ has no member named ‘sa_family’ </code></pre> <p>This is the error I get when solving resolution of my incoming IPv6 from client. Please advice</p>
0debug
static void pl031_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); k->init = pl031_init; dc->no_user = 1; dc->vmsd = &vmstate_pl031; }
1threat
Basic FlatList code throws Warning - React Native : <p>FlatList does not seem to be working. I get this warning.</p> <p><strong>VirtualizedList: missing keys for items, make sure to specify a key property on each item or provide a custom keyExtractor.</strong> </p> <p>Code:</p> <pre><code>&lt;FlatList data={[{name: 'a'}, {name: 'b'}]} renderItem={ (item) =&gt; &lt;Text key={Math.random().toString()}&gt;{item.name}&lt;/Text&gt; } key={Math.random().toString()} /&gt; </code></pre>
0debug
multi sort list of double lists : <p>I have a List of Double Lists, </p> <pre><code>List&lt;List&lt;double&gt;&gt; </code></pre> <p>like this </p> <pre><code>{ 0.0 , 0.0 , -1.0 , 123.1 , 123.2 , 123.3 } { 0.0 , 40.0 , 1.0 , 123.1 , 123.2 , 123.3 } { 1.0 , 40.0 , 1.0 , 123.1 , 123.2 , 123.3 } { 1.0 , 0.0 , -1.0 , 123.1 , 123.2 , 123.3 } </code></pre> <p>The list needs to be sorted by the first 3 columns; and the sort priority matches the sequence, first column sort, then second then third to provide result below</p> <pre><code>{ 0.0 , 0.0 , -1.0 , 123.1 , 123.2 , 123.3 } { 0.0 , 40.0 , 1.0 , 123.1 , 123.2 , 123.3 } { 1.0 , 0.0 , -1.0 , 123.1 , 123.2 , 123.3 } { 1.0 , 40.0 , 1.0 , 123.1 , 123.2 , 123.3 } </code></pre> <p>how is this done? Thx.</p>
0debug
MVC C# dynamic url depending on page variable : So I want it so that if someone loads say three or four entries when they search and they select entry two to edit when they click the open button how would i make it go to say /entry/2 or if they opened entry three it would say /entry/3 Im new to MVC so im really not sure what I am doing. @model IEnumerable<Savvy_CRM_MVC.Models.RootObject> @{ Layout = null; } @foreach (var m in Model) { } <table class="mui-table"> <thead> <tr> <th>Case ID</th> <th>Forename</th> <th>Surname</th> <th>Postcode</th> <th></th> </tr> </thead> <tbody> @foreach (var m in Model) { <tr> <td>@m.Caseid</td> <td>@m.Forename</td> <td>@m.Surname</td> <td>@m.Postcode</td> <td><button>Open Case</button></td> </tr> } </tbody> </table> so on clicking the button i want the url to change and it to load the data of that entry to the page in a format that will be decided later.
0debug
Unable to setup DKIM TXT-Value as DNS-Record : <p>I have a domain name which DNS is edited via Google Cloud DNS. And I have a Google Apps for Work Account with that domain name.</p> <p>I wanted to set up DKIM-authentication but when I try to save the corresponding TXT-Record I get the error that the Tag is invalid.</p> <p>I did the same before and it worked perfectly. I checked the old setup and I saw that the old DKIM-record was about half the length. The new one seems to be too long for a TXT-record in the Google Cloud Platform.</p> <p>Does anyone have a solution?</p>
0debug
static av_cold int decimate_init(AVFilterContext *ctx) { DecimateContext *dm = ctx->priv; AVFilterPad pad = { .name = av_strdup("main"), .type = AVMEDIA_TYPE_VIDEO, .filter_frame = filter_frame, .config_props = config_input, }; if (!pad.name) return AVERROR(ENOMEM); ff_insert_inpad(ctx, INPUT_MAIN, &pad); if (dm->ppsrc) { pad.name = av_strdup("clean_src"); pad.config_props = NULL; if (!pad.name) return AVERROR(ENOMEM); ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad); } if ((dm->blockx & (dm->blockx - 1)) || (dm->blocky & (dm->blocky - 1))) { av_log(ctx, AV_LOG_ERROR, "blockx and blocky settings must be power of two\n"); return AVERROR(EINVAL); } dm->start_pts = AV_NOPTS_VALUE; return 0; }
1threat
Hibernate interceptor and event listeners : <p>I wonder if it's possible to find out what hibernate <em>really</em> did to the database (i.e., committed changes). I'd like to notify another process on certain changes.</p> <p>I guess that the <a href="https://docs.jboss.org/hibernate/orm/5.0/javadocs/org/hibernate/event/spi/EventType.html">EventType</a>s <code>POST_COMMIT_DELETE</code>, <code>POST_COMMIT_UPDATE</code> and <code>POST_COMMIT_INSERT</code> should do, but given exactly zero documentation, it's only a guess. Can someone confirm? Am I missing any?</p> <p>I'm also unsure about how to obtain what gets really written. The <code>PostInsertEvent</code> contains both <code>Object entity</code> and <code>Object[] state</code>, which of the two should I trust?</p> <hr> <p>A side question: I'm using no XML, no Spring, no JPA, just <code>Configuration</code> and <code>buildSessionFactory</code>. Is this really the way listeners should be registered?</p> <pre><code> EventListenerRegistry registry = ((SessionFactoryImpl) sessionFactory) .getServiceRegistry() .getService(EventListenerRegistry.class); registry.appendListeners(....); </code></pre> <p>I'm asking as its 1. dependent on an implementation detail, 2 totally ugly, 3. nearly perfectly undiscoverable.</p>
0debug
void load_seg(int seg_reg, int selector) { SegmentCache *sc; SegmentDescriptorTable *dt; int index; uint32_t e1, e2; uint8_t *ptr; env->segs[seg_reg] = selector; sc = &env->seg_cache[seg_reg]; if (env->eflags & VM_MASK) { sc->base = (void *)(selector << 4); sc->limit = 0xffff; sc->seg_32bit = 0; } else { if (selector & 0x4) dt = &env->ldt; else dt = &env->gdt; index = selector & ~7; if ((index + 7) > dt->limit) raise_exception_err(EXCP0D_GPF, selector); ptr = dt->base + index; e1 = ldl(ptr); e2 = ldl(ptr + 4); sc->base = (void *)((e1 >> 16) | ((e2 & 0xff) << 16) | (e2 & 0xff000000)); sc->limit = (e1 & 0xffff) | (e2 & 0x000f0000); if (e2 & (1 << 23)) sc->limit = (sc->limit << 12) | 0xfff; sc->seg_32bit = (e2 >> 22) & 1; #if 0 fprintf(logfile, "load_seg: sel=0x%04x base=0x%08lx limit=0x%08lx seg_32bit=%d\n", selector, (unsigned long)sc->base, sc->limit, sc->seg_32bit); #endif } }
1threat
def set_Bit_Number(n): if (n == 0): return 0; msb = 0; n = int(n / 2); while (n > 0): n = int(n / 2); msb += 1; return (1 << msb)
0debug
static void xhci_event(XHCIState *xhci, XHCIEvent *event, int v) { XHCIInterrupter *intr; dma_addr_t erdp; unsigned int dp_idx; if (v >= xhci->numintrs) { DPRINTF("intr nr out of range (%d >= %d)\n", v, xhci->numintrs); return; } intr = &xhci->intr[v]; if (intr->er_full) { DPRINTF("xhci_event(): ER full, queueing\n"); if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) { DPRINTF("xhci: event queue full, dropping event!\n"); return; } intr->ev_buffer[intr->ev_buffer_put++] = *event; if (intr->ev_buffer_put == EV_QUEUE) { intr->ev_buffer_put = 0; } return; } erdp = xhci_addr64(intr->erdp_low, intr->erdp_high); if (erdp < intr->er_start || erdp >= (intr->er_start + TRB_SIZE*intr->er_size)) { DPRINTF("xhci: ERDP out of bounds: "DMA_ADDR_FMT"\n", erdp); DPRINTF("xhci: ER[%d] at "DMA_ADDR_FMT" len %d\n", v, intr->er_start, intr->er_size); xhci_die(xhci); return; } dp_idx = (erdp - intr->er_start) / TRB_SIZE; assert(dp_idx < intr->er_size); if ((intr->er_ep_idx+1) % intr->er_size == dp_idx) { DPRINTF("xhci_event(): ER full, queueing\n"); #ifndef ER_FULL_HACK XHCIEvent full = {ER_HOST_CONTROLLER, CC_EVENT_RING_FULL_ERROR}; xhci_write_event(xhci, &full); #endif intr->er_full = 1; if (((intr->ev_buffer_put+1) % EV_QUEUE) == intr->ev_buffer_get) { DPRINTF("xhci: event queue full, dropping event!\n"); return; } intr->ev_buffer[intr->ev_buffer_put++] = *event; if (intr->ev_buffer_put == EV_QUEUE) { intr->ev_buffer_put = 0; } } else { xhci_write_event(xhci, event, v); } xhci_intr_raise(xhci, v); }
1threat
bool object_property_get_bool(Object *obj, const char *name, Error **errp) { QObject *ret = object_property_get_qobject(obj, name, errp); QBool *qbool; bool retval; if (!ret) { return false; } qbool = qobject_to_qbool(ret); if (!qbool) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean"); retval = false; } else { retval = qbool_get_bool(qbool); } QDECREF(qbool); return retval; }
1threat
def divisible_by_digits(startnum, endnum): return [n for n in range(startnum, endnum+1) \ if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]
0debug
Why does this print 8? Simple Python list : <pre><code>list = [1, 1, 2, 3, 5, 8, 13] print(list[list[4]]) </code></pre> <p>Why does this print 8? I don't understand that particular print statement syntax</p>
0debug
Xamarin build-times extremely slow : <p>I have developed several (experimental and prototype) iOS apps using Xamarin and the new Visual Studio for Mac OS and the build-times intermittently take about 5-10 minutes on average. When starting a new project, build-times are fine. After a few changes in the source code while working on my apps (no specific changes). For no reason, build times start increasing to 5-10 minutes. I've tried all possible build-options (linking, no linking, SDK versions, new consigning certificate, etc..).</p> <p>Upon investigation with the Activities-app (Mac OS, Sierra) i find that the "codesign" process is taking up 110% CPU and runs for as long as the build takes to complete.</p> <p>Does anyone have any experience with this problem?</p>
0debug
Golang, it is safe storing pem encrypted block? : Well, hi, i have some experience using Go, but now i don't really understand the complexity in security of what i am doing, so i need to ask. I am creating a rsa private key, converting to pem and then encryping it with a passphrase. So, how secure is to store it in a public place? I'm not looking for asnwers like "it's ok, just change the passphrase over time", i really want to know wich mechanism of cypher Golang is using to do it and if is safe to leave the encrypted pem in, for example, a public blockchain and why i can do it or why i cannot. I'm leaving here the code i am using right now: <pre> func New(passphrase string)(*pem.Block, error){ pk, err := createPrivateKey(2048) if err != nil { return false, err } pem := getPemFromPK(pk) block, err := EncryptPEMBlock(pem,passphrase) if err != nil { return false, err } return block,nil } func createPrivateKey(bits int) (*rsa.PrivateKey, error){ pk, err := rsa.GenerateKey(rand.Reader, bits) if err != nil { return nil, err } return pk,nil } func getPemFromPK(pk *rsa.PrivateKey) (*pem.Block){ block := &pem.Block{ Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(pk), } return block } func EncryptPEMBlock(block *pem.Block, passphrase string) (*pem.Block, error){ block, err := x509.EncryptPEMBlock(rand.Reader, block.Type, block.Bytes, []byte(passphrase), x509.PEMCipherAES256) if err != nil { return nil, err } return block,nil } </pre> Thank you very much.
0debug
Sql server What happens in delete with index : I have a heap table of 36 mill,am trying to delete selected 6 mill.. When i delete in 100 of batches reads is 16++++++ and write is 113 so i add NON-clus index on Identity column to make read faster, now read is 34899 and write is 3508 with adding one NON-clus Idx it increase the write IO shoot up. So what to know why this much difference what does sql server does in behind as in plan i see table delete is 8% and no more details. just to add more before doing this I drop 2 Nvarchar column, and clean the table and rebuild it
0debug
Kindly someone help. I am linking one activity to another using a button and the app crashes after clicking the button : I have a home activity, QuizActivity, ResultActivity all with its xml files. I have put a button in home activity to link to QuestionActivity to start the quiz. But the app crashes after clicking of the button "unfortunately, .... has stoped" Below are the codes. Kindly someone identify where I am doing it wrong activity_home.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@mipmap/kiss_home" tools:context=".Home"> <TextView android:id="@+id/textView" android:layout_width="244dp" android:layout_height="52dp" android:text="Are you a good Kisser?" android:textSize="22dp" android:textColor="@android:color/holo_blue_bright" tools:layout_editor_absoluteX="76dp" tools:layout_editor_absoluteY="22dp" android:layout_alignParentTop="true" android:layout_alignRight="@+id/button" android:layout_alignEnd="@+id/button" android:layout_marginTop="53dp" /> <Button android:id="@+id/button" android:layout_width="262dp" android:layout_height="80dp" android:text="@string/start_quiz" android:textSize="20dp" android:background="@color/colorAccent" tools:layout_editor_absoluteX="74dp" tools:layout_editor_absoluteY="207dp" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginLeft="50dp" android:layout_marginStart="50dp" android:layout_marginBottom="128dp" /> android:onClick="onClick" </RelativeLayout>
0debug
static void serial_update_irq(SerialState *s) { uint8_t tmp_iir = UART_IIR_NO_INT; if ((s->ier & UART_IER_RLSI) && (s->lsr & UART_LSR_INT_ANY)) { tmp_iir = UART_IIR_RLSI; } else if ((s->ier & UART_IER_RDI) && s->timeout_ipending) { tmp_iir = UART_IIR_CTI; } else if ((s->ier & UART_IER_RDI) && (s->lsr & UART_LSR_DR)) { if (!(s->fcr & UART_FCR_FE)) { tmp_iir = UART_IIR_RDI; } else if (s->recv_fifo.count >= s->recv_fifo.itl) { tmp_iir = UART_IIR_RDI; } } else if ((s->ier & UART_IER_THRI) && s->thr_ipending) { tmp_iir = UART_IIR_THRI; } else if ((s->ier & UART_IER_MSI) && (s->msr & UART_MSR_ANY_DELTA)) { tmp_iir = UART_IIR_MSI; } s->iir = tmp_iir | (s->iir & 0xF0); if (tmp_iir != UART_IIR_NO_INT) { qemu_irq_raise(s->irq); } else { qemu_irq_lower(s->irq); } }
1threat
static int vmdk_write(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { BDRVVmdkState *s = bs->opaque; VmdkExtent *extent = NULL; int n; int64_t index_in_cluster; uint64_t cluster_offset; VmdkMetaData m_data; if (sector_num > bs->total_sectors) { fprintf(stderr, "(VMDK) Wrong offset: sector_num=0x%" PRIx64 " total_sectors=0x%" PRIx64 "\n", sector_num, bs->total_sectors); return -1; } while (nb_sectors > 0) { extent = find_extent(s, sector_num, extent); if (!extent) { return -EIO; } cluster_offset = get_cluster_offset( bs, extent, &m_data, sector_num << 9, 1); if (!cluster_offset) { return -1; } index_in_cluster = sector_num % extent->cluster_sectors; n = extent->cluster_sectors - index_in_cluster; if (n > nb_sectors) { n = nb_sectors; } if (bdrv_pwrite(bs->file, cluster_offset + index_in_cluster * 512, buf, n * 512) != n * 512) { return -1; } if (m_data.valid) { if (vmdk_L2update(extent, &m_data) == -1) { return -1; } } nb_sectors -= n; sector_num += n; buf += n * 512; if (!s->cid_updated) { vmdk_write_cid(bs, time(NULL)); s->cid_updated = true; } } return 0; }
1threat
iOS Swift - Get the Current Local Time and Date Timestamp : <p>I'm trying to make an attendance app and I am really confused about date and time in iOS and Firebase.</p> <p>I use date as Key, this is the structure of my Firebase database.</p> <pre><code>--Employees --Unique_ID --Details Name: John --Attendance --dateToday Timein: 8:00 AM Timeout: 5:00 PM BreakStart: 12:00 PM BreakFinish: 1:00 PM </code></pre> <p>This is my code to get the date timestamp I used as Key</p> <pre><code> override func viewDidLoad() { super.viewDidLoad() let now = NSDate() let nowTimeStamp = self.getCurrentTimeStampWOMiliseconds(dateToConvert: now) // I save this dateToday as Key in Firebase dateToday = nowTimeStamp } func getCurrentTimeStampWOMiliseconds(dateToConvert: NSDate) -&gt; String { let objDateformat: DateFormatter = DateFormatter() objDateformat.dateFormat = "yyyy-MM-dd" let strTime: String = objDateformat.string(from: dateToConvert as Date) let objUTCDate: NSDate = objDateformat.date(from: strTime)! as NSDate let milliseconds: Int64 = Int64(objUTCDate.timeIntervalSince1970) let strTimeStamp: String = "\(milliseconds)" return strTimeStamp } </code></pre> <p>But when I convert it back to date I get 2017-09-22 16:00:00 +0000, which is wrong because it is 23rd of September in my location.</p> <p>What is the right code to use so that I can get the correct date timestamp and time timestamp? </p>
0debug
C++ Start Process / Apllication : I have a dll source file, I want to create a function in it, which call an exe. The exe is in the Data/Common/PPI.exe How can I start this from the c++ code? I tryed with CreateProcess and ShellExec, can anybody create an example for me to know how to make it, with this path and with this exe name. I dont want to add the full directory path because if its changed or something I need to rebuild the exe... so the dll is in the root folder the dll call this function and the function start the Data/common/PPI.exe, thats it all. Thanks!
0debug
void ppc_hash64_set_sdr1(PowerPCCPU *cpu, target_ulong value, Error **errp) { CPUPPCState *env = &cpu->env; target_ulong htabsize = value & SDR_64_HTABSIZE; env->spr[SPR_SDR1] = value; if (htabsize > 28) { error_setg(errp, "Invalid HTABSIZE 0x" TARGET_FMT_lx" stored in SDR1", htabsize); htabsize = 28; } env->htab_mask = (1ULL << (htabsize + 18 - 7)) - 1; env->htab_base = value & SDR_64_HTABORG; }
1threat
Pandas dataframe: truncate string fields : <p>I have a dataframe and would like to truncate each field to up to 20 characters. I've been naively trying the following:</p> <pre><code>df = df.astype(str).apply(lambda x: x[:20]) </code></pre> <p>however it has no effect whatsoever. If, however, I wanted to add an 'Y' to each field, this works like a charm:</p> <pre><code>df = df.astype(str).apply(lambda x: x+'Y') </code></pre> <p>What am I doing wrong?</p>
0debug
document.getElementById('input').innerHTML = user_input;
1threat
Wordpress Speed : <p>I'm looking for some additional ideas on how to speed up our WordPress Portal, which we've built from the ground up. </p> <p>The pages are taking a little longer that would like to load and it causing some concerns. </p> <p>Things i've tried: </p> <p>Putting CDN's in for as much as possible. </p> <pre><code> wp_enqueue_style( 'font-awesome-stylesheet', 'https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font- awesome.min.css', array(), '1.0.0' ); </code></pre> <ul> <li>Optimising images. </li> <li>Keeping all plugins updating and removing</li> <li>unnecessary ones. Reducing database calls</li> <li>Reducing Post revisions </li> <li>Hosting is on it's on VPS. The portal is the only thing on the VPS and the VPS is of good specification </li> <li>A variety of code changes to speed up</li> </ul> <p>Can anyone help with thoughts? </p>
0debug
static int handle_intercept(S390CPU *cpu) { CPUState *cs = CPU(cpu); struct kvm_run *run = cs->kvm_run; int icpt_code = run->s390_sieic.icptcode; int r = 0; DPRINTF("intercept: 0x%x (at 0x%lx)\n", icpt_code, (long)cs->kvm_run->psw_addr); switch (icpt_code) { case ICPT_INSTRUCTION: r = handle_instruction(cpu, run); break; case ICPT_WAITPSW: if (s390_del_running_cpu(cpu) == 0) { if (is_special_wait_psw(cs)) { qemu_system_shutdown_request(); } else { QObject *data; data = qobject_from_jsonf("{ 'action': %s }", "pause"); monitor_protocol_event(QEVENT_GUEST_PANICKED, data); qobject_decref(data); vm_stop(RUN_STATE_GUEST_PANICKED); } } r = EXCP_HALTED; break; case ICPT_CPU_STOP: if (s390_del_running_cpu(cpu) == 0) { qemu_system_shutdown_request(); } r = EXCP_HALTED; break; case ICPT_SOFT_INTERCEPT: fprintf(stderr, "KVM unimplemented icpt SOFT\n"); exit(1); break; case ICPT_IO: fprintf(stderr, "KVM unimplemented icpt IO\n"); exit(1); break; default: fprintf(stderr, "Unknown intercept code: %d\n", icpt_code); exit(1); break; } return r; }
1threat
How to keep collored output using sed : <p>Hi I'm using <code>sed</code> command and I want to keep collored output from previous command.</p> <pre><code>la | sed -En '/Desktop/q;p' </code></pre> <p>But sed cut off all color codes</p>
0debug
import re def remove(list): pattern = '[0-9]' list = [re.sub(pattern, '', i) for i in list] return list
0debug
static void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type) { Property *prop; prop = qdev_prop_find(dev, name); if (!prop) { fprintf(stderr, "%s: property \"%s.%s\" not found\n", __FUNCTION__, object_get_typename(OBJECT(dev)), name); abort(); } if (prop->info->type != type) { fprintf(stderr, "%s: property \"%s.%s\" type mismatch\n", __FUNCTION__, object_get_typename(OBJECT(dev)), name); abort(); } qdev_prop_cpy(dev, prop, src); }
1threat